3 Commits

28 changed files with 2599 additions and 324 deletions
+238
View File
@@ -0,0 +1,238 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "KD_DEF.H"
#define BIO_BUFFER_LEN (512)
////////////////////////////////////////////////////////////////////////////
//
// FreeShape()
//
void FreeShape(struct Shape *shape)
{
if (shape->Data)
MM_FreePtr(&shape->Data);
}
////////////////////////////////////////////////////////////////////////////
//
// UnpackEGAShapeToScreen()
//
int UnpackEGAShapeToScreen(struct Shape *SHP,int startx,int starty)
{
int currenty;
signed char n, Rep, far *Src, far *Dst[8], loop, Plane;
unsigned int BPR, Height;
int NotWordAligned;
NotWordAligned = SHP->BPR & 1;
startx>>=3;
Src = MK_FP(SHP->Data,0);
currenty = starty;
Plane = 0;
Height = SHP->bmHdr.h;
while (Height--)
{
Dst[0] = (MK_FP(0xA000,displayofs));
Dst[0] += ylookup[currenty];
Dst[0] += startx;
for (loop=1; loop<SHP->bmHdr.d; loop++)
Dst[loop] = Dst[0];
for (Plane=0; Plane<SHP->bmHdr.d; Plane++)
{
outport(0x3c4,((1<<Plane)<<8)|2);
BPR = ((SHP->BPR+1) >> 1) << 1; // IGNORE WORD ALIGN
while (BPR)
{
if (SHP->bmHdr.comp)
n = *Src++;
else
n = BPR-1;
if (n < 0)
{
if (n != -128)
{
n = (-n)+1;
BPR -= n;
Rep = *Src++;
if ((!BPR) && (NotWordAligned)) // IGNORE WORD ALIGN
n--;
while (n--)
*Dst[Plane]++ = Rep;
}
else
BPR--;
}
else
{
n++;
BPR -= n;
if ((!BPR) && (NotWordAligned)) // IGNORE WORD ALIGN
n--;
while (n--)
*Dst[Plane]++ = *Src++;
if ((!BPR) && (NotWordAligned)) // IGNORE WORD ALIGN
Src++;
}
}
}
currenty++;
}
return(0);
}
////////////////////////////////////////////////////////////////////////////
//
// Verify()
//
long Verify(char *filename)
{
int handle;
long size;
if ((handle=open(filename,O_BINARY))==-1)
return (0);
size=filelength(handle);
close(handle);
return(size);
}
//--------------------------------------------------------------------------
// InitBufferedIO()
//--------------------------------------------------------------------------
memptr InitBufferedIO(int handle, BufferedIO *bio)
{
bio->handle = handle;
bio->offset = BIO_BUFFER_LEN;
bio->status = 0;
MM_GetPtr(&bio->buffer,BIO_BUFFER_LEN);
return(bio->buffer);
}
//--------------------------------------------------------------------------
// FreeBufferedIO()
//--------------------------------------------------------------------------
void FreeBufferedIO(BufferedIO *bio)
{
if (bio->buffer)
MM_FreePtr(&bio->buffer);
}
//--------------------------------------------------------------------------
// bio_readch()
//--------------------------------------------------------------------------
byte bio_readch(BufferedIO *bio)
{
byte far *buffer;
if (bio->offset == BIO_BUFFER_LEN)
{
bio->offset = 0;
bio_fillbuffer(bio);
}
buffer = MK_FP(bio->buffer,bio->offset++);
return(*buffer);
}
//--------------------------------------------------------------------------
// bio_fillbuffer()
//
// BUGS (Not really bugs... More like RULES!)
//
// 1) This code assumes BIO_BUFFER_LEN is no smaller than
// NEAR_BUFFER_LEN!!
//
// 2) BufferedIO.status should be altered by this code to report
// read errors, end of file, etc... If you know how big the file
// is you're reading, determining EOF should be no problem.
//
//--------------------------------------------------------------------------
void bio_fillbuffer(BufferedIO *bio)
{
#define NEAR_BUFFER_LEN (64)
byte near_buffer[NEAR_BUFFER_LEN];
short bio_length,bytes_read,bytes_requested;
bytes_read = 0;
bio_length = BIO_BUFFER_LEN;
while (bio_length)
{
if (bio_length > NEAR_BUFFER_LEN-1)
bytes_requested = NEAR_BUFFER_LEN;
else
bytes_requested = bio_length;
read(bio->handle,near_buffer,bytes_requested);
_fmemcpy(MK_FP(bio->buffer,bytes_read),near_buffer,bytes_requested);
bio_length -= bytes_requested;
bytes_read += bytes_requested;
}
}
///////////////////////////////////////////////////////////////////////////
//
// SwapLong()
//
void SwapLong(long far *Var)
{
asm les bx,Var
asm mov ax,[es:bx]
asm xchg ah,al
asm xchg ax,[es:bx+2]
asm xchg ah,al
asm mov [es:bx],ax
}
///////////////////////////////////////////////////////////////////////////
//
// SwapWord()
//
void SwapWord(unsigned int far *Var)
{
asm les bx,Var
asm mov ax,[es:bx]
asm xchg ah,al
asm mov [es:bx],ax
}
////////////////////////////////////////////////////////////////////////////
//
// MoveGfxDst()
//
void MoveGfxDst(short x, short y)
{
unsigned address;
address = (y*linewidth)+(x/8);
bufferofs = displayofs = address;
}
+48
View File
@@ -0,0 +1,48 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "SL_FILE.h"
#include "id_mm.h"
///////////////////////////////////////////////////////////////////////////
//
// Defines
//
struct BitMapHeader {
unsigned int w,h,x,y;
unsigned char d,trans,comp,pad;
};
struct BitMap {
unsigned int Width;
unsigned int Height;
unsigned int Depth;
unsigned int BytesPerRow;
char far *Planes[8];
};
struct Shape {
memptr Data;
long size;
unsigned int BPR;
struct BitMapHeader bmHdr;
};
void FreeShape(struct Shape *shape);
int UnpackEGAShapeToScreen(struct Shape *SHP,int startx,int starty);
+1 -1
View File
@@ -1,7 +1,7 @@
;=====================================
;
; Graphics .EQU file for .KDR
; IGRAB-ed on Fri Aug 21 03:04:31 1992
; IGRAB-ed on Fri Sep 10 11:18:08 1993
;
;=====================================
+1 -1
View File
@@ -19,7 +19,7 @@
//////////////////////////////////////
//
// Graphics .H file for .KDR
// IGRAB-ed on Fri Aug 21 03:04:31 1992
// IGRAB-ed on Fri Sep 10 11:18:07 1993
//
//////////////////////////////////////
+1 -1
View File
@@ -6,7 +6,7 @@ CGAGR = 1
EGAGR = 2
VGAGR = 3
GRMODE = CGAGR
GRMODE = EGAGR
PROFILE = 0 ; 1=keep stats on tile drawing
SC_INDEX = 03C4h
+20 -12
View File
@@ -673,9 +673,10 @@ void CAL_SetupGrFile (void)
// load ???dict.ext (huffman dictionary for graphics files)
//
if ((handle = open(GREXT"DICT."EXTENSION,
// if ((handle = open(GREXT"DICT.",
if ((handle = open("KDREAMS.EGA",
O_RDONLY | O_BINARY, S_IREAD)) == -1)
Quit ("Can't open "GREXT"DICT."EXTENSION"!");
Quit ("Can't open KDREAMS.EGA!");
read(handle, &grhuffman, sizeof(grhuffman));
close(handle);
@@ -699,9 +700,10 @@ void CAL_SetupGrFile (void)
//
// Open the graphics file, leaving it open until the game is finished
//
grhandle = open(GREXT"GRAPH."EXTENSION, O_RDONLY | O_BINARY);
// grhandle = open(GREXT"GRAPH."EXTENSION, O_RDONLY | O_BINARY); NOLAN
grhandle = open("KDREAMS.EGA", O_RDONLY | O_BINARY);
if (grhandle == -1)
Quit ("Cannot open "GREXT"GRAPH."EXTENSION"!");
Quit ("Cannot open KDREAMS.EGA!");
//
@@ -757,9 +759,10 @@ void CAL_SetupMapFile (void)
// load maphead.ext (offsets and tileinfo for map file)
//
#ifndef MAPHEADERLINKED
if ((handle = open("MAPHEAD."EXTENSION,
// if ((handle = open("MAPHEAD."EXTENSION,
if ((handle = open("KDREAMS.MAP",
O_RDONLY | O_BINARY, S_IREAD)) == -1)
Quit ("Can't open MAPHEAD."EXTENSION"!");
Quit ("Can't open KDREAMS.MAP!");
length = filelength(handle);
MM_GetPtr (&(memptr)tinf,length);
CA_FarRead(handle, tinf, length);
@@ -776,9 +779,9 @@ void CAL_SetupMapFile (void)
// open the data file
//
#ifdef MAPHEADERLINKED
if ((maphandle = open("GAMEMAPS."EXTENSION,
if ((maphandle = open("KDREAMS.MAP",
O_RDONLY | O_BINARY, S_IREAD)) == -1)
Quit ("Can't open GAMEMAPS."EXTENSION"!");
Quit ("Can't open KDREAMS.MAP!");
#else
if ((maphandle = open("MAPTEMP."EXTENSION,
O_RDONLY | O_BINARY, S_IREAD)) == -1)
@@ -828,9 +831,10 @@ void CAL_SetupAudioFile (void)
O_RDONLY | O_BINARY, S_IREAD)) == -1)
Quit ("Can't open AUDIOT."EXTENSION"!");
#else
if ((audiohandle = open("AUDIO."EXTENSION,
// if ((audiohandle = open("AUDIO."EXTENSION, NOLAN
if ((audiohandle = open("KDREAMS.AUD",
O_RDONLY | O_BINARY, S_IREAD)) == -1)
Quit ("Can't open AUDIO."EXTENSION"!");
Quit ("Can't open KDREAMS.AUD!");
#endif
}
@@ -1580,7 +1584,7 @@ void CA_DownLevel (void)
Quit ("CA_DownLevel: Down past level 0!");
ca_levelbit>>=1;
ca_levelnum--;
CA_CacheMarks(titleptr[ca_levelnum]);
CA_CacheMarks(titleptr[ca_levelnum], 1);
}
//===========================================================================
@@ -1639,7 +1643,7 @@ void CA_ClearAllMarks (void)
#define BARSTEP 8
#define MAXEMPTYREAD 1024
void CA_CacheMarks (char *title)
void CA_CacheMarks (char *title, boolean cachedownlevel)
{
boolean dialog;
int i,next,homex,homey,x,y,thx,thy,numcache,lastx,xl,xh;
@@ -1655,6 +1659,10 @@ void CA_CacheMarks (char *title)
titleptr[ca_levelnum] = title;
dialog = (title!=NULL);
if (cachedownlevel)
dialog = false;
if (dialog)
{
//
+1 -1
View File
@@ -119,5 +119,5 @@ void CA_ClearAllMarks (void);
void CA_CacheGrChunk (int chunk);
void CA_CacheMap (int mapnum);
void CA_CacheMarks (char *title);
void CA_CacheMarks (char *title, boolean cachedownlevel);
+1 -1
View File
@@ -44,7 +44,7 @@
#define EGAGR 2
#define VGAGR 3
#define GRMODE CGAGR
#define GRMODE EGAGR
#if GRMODE == EGAGR
#define GREXT "EGA"
+1 -1
View File
@@ -481,7 +481,7 @@ void MM_GetPtr (memptr *baseptr,unsigned long size)
}
}
Quit ("MM_GetPtr: Out of memory!");
Quit ("Out of memory! Please make sure you have enough free memory.");
}
//==========================================================================
+18 -13
View File
@@ -275,7 +275,7 @@ USL_ReadConfig(void)
SMMode sm;
ControlType ctl;
if ((file = open("CONFIG."EXTENSION,O_BINARY | O_RDONLY)) != -1)
if ((file = open("KDREAMS.CFG",O_BINARY | O_RDONLY)) != -1)
{
read(file,Scores,sizeof(HighScore) * MaxScores);
read(file,&sd,sizeof(sd));
@@ -312,7 +312,7 @@ USL_WriteConfig(void)
{
int file;
file = open("CONFIG."EXTENSION,O_CREAT | O_BINARY | O_WRONLY,
file = open("KDREAMS.CFG", O_CREAT | O_BINARY | O_WRONLY,
S_IREAD | S_IWRITE | S_IFREG);
if (file != -1)
{
@@ -493,6 +493,7 @@ USL_ClearTextScreen(void)
_DH = 24; // Bottom row
_AH = 0x02;
geninterrupt(0x10);
}
///////////////////////////////////////////////////////////////////////////
@@ -571,6 +572,8 @@ USL_ShowMem(word x,word y,long mem)
USL_ScreenDraw(x,y,buf,0x48);
}
#if 0
///////////////////////////////////////////////////////////////////////////
//
// US_UpdateTextScreen() - Called after the ID libraries are started up.
@@ -585,7 +588,6 @@ US_UpdateTextScreen(void)
word i;
longword totalmem;
#if 0
// Show video card info
b = (grmode == CGAGR);
USL_Show(21,7,4,(videocard >= CGAcard) && (videocard <= VGAcard),b);
@@ -626,9 +628,10 @@ US_UpdateTextScreen(void)
// Change Initializing... to Loading...
USL_ScreenDraw(27,22," Loading... ",0x9c);
#endif
}
#endif
///////////////////////////////////////////////////////////////////////////
//
// US_FinishTextScreen() - After the main program has finished its initial
@@ -639,7 +642,6 @@ void
US_FinishTextScreen(void)
{
// Change Loading... to Press a Key
// USL_ScreenDraw(29,22," Ready - Press a Key ",0x9a);
USL_ScreenDraw(30, 18, "Ready - Press a Key",0xCE);
if (!tedlevel)
@@ -2189,6 +2191,7 @@ USL_CtlCJoyButtonCustom(UserCall call,word i,word n)
FlushHelp = true;
fontcolor = F_SECONDCOLOR;
while (!(Done))
{
USL_ShowHelp("Move Joystick to the Upper-Left");
@@ -2223,8 +2226,10 @@ USL_CtlCJoyButtonCustom(UserCall call,word i,word n)
Done = true;
}
if (LastScan != sc_Escape)
while (IN_GetJoyButtonsDB(joy));
while (IN_GetJoyButtonsDB(joy))
;
if (LastScan)
IN_ClearKeysDown();
@@ -2598,10 +2603,10 @@ extern char far gametext,far context,far story;
break;
}
MM_GetPtr(&dupe,5000);
_fmemcpy((char far *)dupe,buf,5000);
MM_GetPtr(&dupe,5600);
_fmemcpy((char far *)dupe,buf,5600);
USL_DoHelp(dupe,5000);
USL_DoHelp(dupe,5600);
MM_FreePtr(&dupe);
if (LineOffsets)
@@ -3325,14 +3330,14 @@ USL_TearDownCtlPanel(void)
if (!QuitToDos)
{
US_CenterWindow(20,8);
US_CPrint("Loading");
// US_CenterWindow(20,8); //NOLAN
// US_CPrint("Loading");
#if 0
fontcolor = F_SECONDCOLOR;
US_CPrint("Sounds");
fontcolor = F_BLACK;
#endif
VW_UpdateScreen();
// VW_UpdateScreen();
CA_LoadAllSounds();
}
@@ -3369,7 +3374,7 @@ US_ControlPanel(void)
CA_MarkGrChunk(i);
CA_MarkGrChunk(CTL_LITTLEMASKPICM);
CA_MarkGrChunk(CTL_LSMASKPICM);
CA_CacheMarks("Options Screen");
CA_CacheMarks("Options Screen", 0);
USL_SetUpCtlPanel();
+120
View File
@@ -0,0 +1,120 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <alloc.h>
#include <fcntl.h>
#include <dos.h>
#include <io.h>
#include "kd_def.h"
//#include "gelib.h"
#include "jam_io.h"
//----------------------------------------------------------------------------
//
// PTR/PTR COMPRESSION ROUTINES
//
//
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------
// WritePtr() -- Outputs data to a particular ptr type
//
// PtrType MUST be of type DEST_TYPE.
//
// NOTE : For PtrTypes DEST_MEM a ZERO (0) is always returned.
//
//---------------------------------------------------------------------------
char WritePtr(long outfile, unsigned char data, unsigned PtrType)
{
int returnval = 0;
switch (PtrType & DEST_TYPES)
{
case DEST_FILE:
write(*(int far *)outfile,(char *)&data,1);
break;
case DEST_FFILE:
returnval = putc(data, *(FILE **)outfile);
break;
case DEST_IMEM:
printf("WritePtr - unsupported ptr type\n");
exit(0);
break;
case DEST_MEM:
*((char far *)*(char far **)outfile)++ = data;
break;
}
return(returnval);
}
//---------------------------------------------------------------------------
// ReadPtr() -- Reads data from a particular ptr type
//
// PtrType MUST be of type SRC_TYPE.
//
// RETURNS :
// The char read in or EOF for SRC_FFILE type of reads.
//
//
//---------------------------------------------------------------------------
int ReadPtr(long infile, unsigned PtrType)
{
int returnval = 0;
switch (PtrType & SRC_TYPES)
{
case SRC_FILE:
read(*(int far *)infile,(char *)&returnval,1);
break;
case SRC_FFILE:
returnval = getc(*(FILE far **)infile);
break;
case SRC_BFILE:
returnval = bio_readch((BufferedIO *)*(void far **)infile);
break;
// case SRC_IMEM:
// printf("WritePtr - unsupported ptr type\n");
// exit(0);
// break;
case SRC_MEM:
returnval = (unsigned char)*((char far *)*(char far **)infile)++;
break;
}
return(returnval);
}
+107
View File
@@ -0,0 +1,107 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//
// UNIT : JAM_IO.h
//
// FUNCTION : General defines, prototypes, typedefs used in all the
// supported compression techniques used in JAMPAK Ver x.x
//
//
//==========================================================================
//
// PARAMETER PASSING TYPES
//
//
// SOURCE PARAMS (LO BYTE)
#define SRC_FILE (0x0001) // GE Buffered IO
#define SRC_FFILE (0x0002) // Stdio File IO (fwrite etc.)
#define SRC_MEM (0x0004) // Std void ptr (alloc etc)
#define SRC_BFILE (0x0008) // Buffered File I/O
#define SRC_TYPES (SRC_FILE | SRC_FFILE | SRC_MEM | SRC_BFILE)
// DESTINATION PARAMS (HI BYTE)
#define DEST_FILE (0x0100) // GE Buffered IO
#define DEST_FFILE (0x0200) // Stdio File IO (fwrite etc.)
#define DEST_MEM (0x0400) // Std void ptr (alloc etc)
#define DEST_IMEM (0x0800) // ID Memory alloc
#define DEST_TYPES (DEST_FILE | DEST_FFILE | DEST_MEM | DEST_IMEM)
//=========================================================================
//
// FILE CHUNK IDs
//
// NOTE: The only reason for changing from COMP to CMP1 and having multi
// comp header structs is for downward compatablity.
//
#define COMP ("COMP") // Comp type is ct_LZW ALWAYS!
#define CMP1 ("CMP1") // Comp type is determined in header.
//
// COMPRESSION TYPES
//
typedef enum ct_TYPES
{
ct_NONE = 0, // No compression - Just data..Rarely used!
ct_LZW, // LZW data compression
ct_LZH,
} ct_TYPES;
//
// FILE CHUNK HEADER FORMATS
//
struct COMPStruct
{
unsigned long DecompLen;
};
struct CMP1Header
{
unsigned CompType; // SEE: ct_TYPES above for list of pos.
unsigned long OrginalLen; // Orginal FileLength of compressed Data.
unsigned long CompressLen; // Length of data after compression (A MUST for LZHUFF!)
};
//---------------------------------------------------------------------------
//
// FUNCTION PROTOTYPEING
//
//---------------------------------------------------------------------------
char WritePtr(long outfile, unsigned char data, unsigned PtrType);
int ReadPtr(long infile, unsigned PtrType);
+52
View File
@@ -20,6 +20,8 @@
#include "ID_HEADS.H"
#include <BIOS.H>
#include "SOFT.H"
#include "SL_FILE.H"
#define FRILLS 0 // Cut out frills for 360K - MIKE MAYNARD
@@ -32,6 +34,8 @@
=============================================================================
*/
#define CREDITS 0
#define MAXACTORS MAXSPRITES
#define ACCGRAVITY 3
@@ -131,6 +135,35 @@ typedef struct objstruct
} objtype;
struct BitMapHeader {
unsigned int w,h,x,y;
unsigned char d,trans,comp,pad;
};
struct BitMap {
unsigned int Width;
unsigned int Height;
unsigned int Depth;
unsigned int BytesPerRow;
char far *Planes[8];
};
struct Shape {
memptr Data;
long size;
unsigned int BPR;
struct BitMapHeader bmHdr;
};
typedef struct {
int handle; // handle of file
memptr buffer; // pointer to buffer
word offset; // offset into buffer
word status; // read/write status
} BufferedIO;
/*
=============================================================================
@@ -312,3 +345,22 @@ extern statetype s_deathwait2;
extern statetype s_deathwait3;
extern statetype s_deathboom1;
extern statetype s_deathboom2;
/////////////////////////////////////////////////////////////////////////////
//
// GELIB.C DEFINITIONS
//
/////////////////////////////////////////////////////////////////////////////
void FreeShape(struct Shape *shape);
int UnpackEGAShapeToScreen(struct Shape *SHP,int startx,int starty);
long Verify(char *filename);
memptr InitBufferedIO(int handle, BufferedIO *bio);
void FreeBufferedIO(BufferedIO *bio);
byte bio_readch(BufferedIO *bio);
void bio_fillbuffer(BufferedIO *bio);
void SwapLong(long far *Var);
void SwapWord(unsigned int far *Var);
void MoveGfxDst(short x, short y);
+89 -87
View File
@@ -18,11 +18,12 @@
// KD_DEMO.C
#include <dir.h>
#include "KD_DEF.H"
#pragma hdrstop
#pragma hdrstop
#define RLETAG 0xABCD
#define RLETAG 0xABCD
/*
=============================================================================
@@ -63,9 +64,9 @@
void NewGame (void)
{
word i;
word i;
gamestate.worldx = 0; // spawn keen at starting spot
gamestate.worldx = 0; // spawn keen at starting spot
gamestate.mapon = 0;
gamestate.score = 0;
@@ -90,7 +91,7 @@ int WaitOrKey (int vbls)
{
while (vbls--)
{
IN_ReadControl(0,&c); // get player input
IN_ReadControl(0,&c); // get player input
if (LastScan || c.button0 || c.button1)
{
IN_ClearKeysDown ();
@@ -138,7 +139,7 @@ GameOver (void)
void StatusWindow (void)
{
word x;
word x;
// DEBUG - make this look better
@@ -197,9 +198,9 @@ void StatusWindow (void)
boolean
SaveGame(int file)
{
word i,size,compressed,expanded;
objtype *o;
memptr bigbuffer;
word i,size,compressed,expanded;
objtype *o;
memptr bigbuffer;
if (!CA_FarWrite(file,(void far *)&gamestate,sizeof(gamestate)))
return(false);
@@ -207,7 +208,7 @@ SaveGame(int file)
expanded = mapwidth * mapheight * 2;
MM_GetPtr (&bigbuffer,expanded);
for (i = 0;i < 3;i++) // Write all three planes of the map
for (i = 0;i < 3;i++) // Write all three planes of the map
{
//
// leave a word at start of compressed data for compressed length
@@ -239,12 +240,12 @@ SaveGame(int file)
boolean
LoadGame(int file)
{
word i,j,size;
objtype *o;
word i,j,size;
objtype *o;
int orgx,orgy;
objtype *prev,*next,*followed;
unsigned compressed,expanded;
memptr bigbuffer;
objtype *prev,*next,*followed;
unsigned compressed,expanded;
memptr bigbuffer;
if (!CA_FarRead(file,(void far *)&gamestate,sizeof(gamestate)))
return(false);
@@ -255,7 +256,7 @@ LoadGame(int file)
ca_levelbit >>= 1;
ca_levelnum--;
SetupGameLevel (false); // load in and cache the base old level
SetupGameLevel (false); // load in and cache the base old level
titleptr[ca_levelnum] = levelnames[mapon];
ca_levelbit <<= 1;
@@ -264,7 +265,7 @@ LoadGame(int file)
expanded = mapwidth * mapheight * 2;
MM_GetPtr (&bigbuffer,expanded);
for (i = 0;i < 3;i++) // Read all three planes of the map
for (i = 0;i < 3;i++) // Read all three planes of the map
{
if (!CA_FarRead(file,(void far *)&compressed,sizeof(compressed)) )
{
@@ -315,9 +316,9 @@ LoadGame(int file)
break;
}
*((long *)&(scoreobj->temp1)) = -1; // force score to be updated
scoreobj->temp3 = -1; // and flower power
scoreobj->temp4 = -1; // and lives
*((long *)&(scoreobj->temp1)) = -1; // force score to be updated
scoreobj->temp3 = -1; // and flower power
scoreobj->temp4 = -1; // and lives
return(true);
}
@@ -329,7 +330,7 @@ ResetGame(void)
ca_levelnum--;
CA_ClearMarks();
titleptr[ca_levelnum] = NULL; // don't reload old level
titleptr[ca_levelnum] = NULL; // don't reload old level
ca_levelnum++;
}
@@ -345,11 +346,11 @@ TEDDeath(void)
static boolean
MoveTitleTo(int offset)
{
boolean done;
int dir,
boolean done;
int dir,
chunk,
move;
longword lasttime,delay;
longword lasttime,delay;
if (offset < originxglobal)
dir = -1;
@@ -427,10 +428,20 @@ ShowText(int offset,WindowRec *wr,char *s)
void
DemoLoop (void)
{
char *s;
word move;
longword lasttime;
WindowRec mywin;
char *s;
word move;
longword lasttime;
char *FileName1;
struct Shape FileShape1;
#if CREDITS
char *FileName2;
struct Shape FileShape2;
#endif
struct ffblk ffblk;
WindowRec mywin;
int bufsave = bufferofs;
int dissave = displayofs;
#if FRILLS
//
@@ -450,94 +461,85 @@ DemoLoop (void)
//
US_SetLoadSaveHooks(LoadGame,SaveGame,ResetGame);
restartgame = gd_Continue;
if (findfirst("KDREAMS.CMP", &ffblk, 0) == -1)
Quit("Couldn't find KDREAMS.CMP");
while (true)
{
// Load the Title map
gamestate.mapon = 20; // title map number
loadedgame = false;
SetupGameLevel(true);
FileName1 = "TITLESCR.LBM";
if (LoadLIBShape("KDREAMS.CMP", FileName1, &FileShape1))
Quit("Can't load TITLE SCREEN");
#if CREDITS
FileName2 = "CREDITS.LBM";
if (LoadLIBShape("KDREAMS.CMP", FileName2, &FileShape2))
Quit("Can't load CREDITS SCREEN");
#endif
while (!restartgame && !loadedgame)
{
VW_InitDoubleBuffer();
IN_ClearKeysDown();
while (true)
{
// Display the Title map
RF_NewPosition((5 * TILEGLOBAL) + (TILEGLOBAL / 2),
(TILEGLOBAL * 2) + (TILEGLOBAL / 2)
+ (TILEGLOBAL / 4));
RF_ForceRefresh();
RF_Refresh();
RF_Refresh();
if (Wait(TickBase * 2))
break;
VW_SetScreen(0, 0);
MoveGfxDst(0, 200);
UnpackEGAShapeToScreen(&FileShape1, 0, 0);
VW_ScreenToScreen (64*200,0,40,200);
mywin.x = (16 * 13) + 4;
mywin.y = 0;
mywin.w = 16 * 7;
mywin.h = 200;
mywin.px = mywin.x + 0;
mywin.py = mywin.y + 10;
s = "Game\n"
"John Carmack\n"
"\n"
"Utilities\n"
"John Romero\n"
"\n"
"Interface/Sound\n"
"Jason Blochowiak\n"
"\n"
"Creative Director\n"
"Tom Hall\n"
"\n"
"Art\n"
"Adrian Carmack\n";
if (ShowText((9 * TILEGLOBAL) - (PIXGLOBAL * 2),&mywin,s))
#if CREDITS
if (IN_UserInput(TickBase * 8, false))
break;
#else
if (IN_UserInput(TickBase * 4, false))
break;
#endif
mywin.x = 4;
mywin.y = 0;
mywin.w = 16 * 7;
mywin.h = 200;
mywin.px = mywin.x + 0;
mywin.py = mywin.y + 10;
s = "\n"
"\"Keen Dreams\"\n"
"Copyright 1991-93\n"
"Softdisk, Inc.\n"
"\n"
"\n"
"\n"
"\n"
"Commander Keen\n"
"Copyright 1990-91\n"
"Id Software, Inc.\n"
"\n"
"Press F1 for Help\n"
"SPACE to Start\n";
if (ShowText((2 * TILEGLOBAL) + (PIXGLOBAL * 2),&mywin,s))
break;
#if CREDITS
MoveGfxDst(0, 200);
UnpackEGAShapeToScreen(&FileShape2, 0, 0);
VW_ScreenToScreen (64*200,0,40,200);
if (MoveTitleTo((5 * TILEGLOBAL) + (TILEGLOBAL / 2)))
break;
if (Wait(TickBase * 3))
if (IN_UserInput(TickBase * 7, false))
break;
#else
MoveGfxDst(0, 200);
UnpackEGAShapeToScreen(&FileShape1, 0, 0);
VW_ScreenToScreen (64*200,0,40,200);
if (IN_UserInput(TickBase * 3, false))
break;
#endif
displayofs = 0;
VWB_Bar(0,0,320,200,FIRSTCOLOR);
US_DisplayHighScores(-1);
if (IN_UserInput(TickBase * 8,false))
if (IN_UserInput(TickBase * 6, false))
break;
}
bufferofs = bufsave;
displayofs = dissave;
VW_FixRefreshBuffer();
US_ControlPanel ();
}
if (!loadedgame)
NewGame();
FreeShape(&FileShape1);
#if CREDITS
FreeShape(&FileShape2);
#endif
GameLoop();
}
}
+46 -79
View File
@@ -33,8 +33,6 @@
#include "KD_DEF.H"
#pragma hdrstop
#define CATALOG
/*
=============================================================================
@@ -51,9 +49,9 @@
=============================================================================
*/
char str[80],str2[20];
boolean singlestep,jumpcheat,godmode,tedlevel;
unsigned tedlevelnum;
char str[80],str2[20];
boolean singlestep,jumpcheat,godmode,tedlevel;
unsigned tedlevelnum;
/*
=============================================================================
@@ -63,13 +61,13 @@ unsigned tedlevelnum;
=============================================================================
*/
void DebugMemory (void);
void TestSprites(void);
int DebugKeys (void);
void ShutdownId (void);
void Quit (char *error);
void InitGame (void);
void main (void);
void DebugMemory (void);
void TestSprites(void);
int DebugKeys (void);
void ShutdownId (void);
void Quit (char *error);
void InitGame (void);
void main (void);
//===========================================================================
@@ -112,14 +110,14 @@ void DebugMemory (void)
===================
*/
#define DISPWIDTH 110
#define TEXTWIDTH 40
#define DISPWIDTH 110
#define TEXTWIDTH 40
void TestSprites(void)
{
int hx,hy,sprite,oldsprite,bottomy,topx,shift;
spritetabletype far *spr;
spritetype _seg *block;
unsigned mem,scan;
spritetype _seg *block;
unsigned mem,scan;
VW_FixRefreshBuffer ();
@@ -171,7 +169,7 @@ void TestSprites(void)
else
{
mem = block->sourceoffset[3]+5*block->planesize[3];
mem = (mem+15)&(~15); // round to paragraphs
mem = (mem+15)&(~15); // round to paragraphs
US_PrintUnsigned (mem);
}
@@ -239,7 +237,7 @@ int DebugKeys (void)
int level;
#if FRILLS
if (Keyboard[0x12] && ingame) // DEBUG: end + 'E' to quit level
if (Keyboard[0x12] && ingame) // DEBUG: end + 'E' to quit level
{
if (tedlevel)
TEDDeath();
@@ -247,7 +245,7 @@ int DebugKeys (void)
}
#endif
if (Keyboard[0x22] && ingame) // G = god mode
if (Keyboard[0x22] && ingame) // G = god mode
{
VW_FixRefreshBuffer ();
US_CenterWindow (12,2);
@@ -260,7 +258,7 @@ int DebugKeys (void)
godmode ^= 1;
return 1;
}
else if (Keyboard[0x17]) // I = item cheat
else if (Keyboard[0x17]) // I = item cheat
{
VW_FixRefreshBuffer ();
US_CenterWindow (12,3);
@@ -272,7 +270,7 @@ int DebugKeys (void)
IN_Ack ();
return 1;
}
else if (Keyboard[0x24]) // J = jump cheat
else if (Keyboard[0x24]) // J = jump cheat
{
jumpcheat^=1;
VW_FixRefreshBuffer ();
@@ -286,17 +284,17 @@ int DebugKeys (void)
return 1;
}
#if FRILLS
else if (Keyboard[0x32]) // M = memory info
else if (Keyboard[0x32]) // M = memory info
{
DebugMemory();
return 1;
}
#endif
else if (Keyboard[0x19]) // P = pause with no screen disruptioon
else if (Keyboard[0x19]) // P = pause with no screen disruptioon
{
IN_Ack();
}
else if (Keyboard[0x1f] && ingame) // S = slow motion
else if (Keyboard[0x1f] && ingame) // S = slow motion
{
singlestep^=1;
VW_FixRefreshBuffer ();
@@ -310,13 +308,13 @@ int DebugKeys (void)
return 1;
}
#if FRILLS
else if (Keyboard[0x14]) // T = sprite test
else if (Keyboard[0x14]) // T = sprite test
{
TestSprites();
return 1;
}
#endif
else if (Keyboard[0x11] && ingame) // W = warp to level
else if (Keyboard[0x11] && ingame) // W = warp to level
{
VW_FixRefreshBuffer ();
US_CenterWindow(26,3);
@@ -379,23 +377,9 @@ void Quit (char *error)
clrscr();
puts(error);
puts("\n");
// puts("For techinical assistance with running this software, type HELP at");
// puts(" the DOS prompt or call Softdisk Publishing at 1-318-221-8311");
exit(1);
}
#ifndef CATALOG
_argc = 2;
_argv[1] = "LAST.SHL";
_argv[2] = "ENDSCN.SCN";
_argv[3] = NULL;
if (execv("LOADSCN.EXE", _argv) == -1)
Quit("Couldn't find executable LOADSCN.EXE.\n");
#endif
#ifdef CATALOG
VW_SetScreenMode(TEXTGR);
exit(0);
#endif
exit (0);
}
//===========================================================================
@@ -410,7 +394,9 @@ void Quit (char *error)
==========================
*/
#if 0
#include "piracy.h"
#endif
void InitGame (void)
{
@@ -418,6 +404,7 @@ void InitGame (void)
MM_Startup ();
#if 0
// Handle piracy screen...
//
@@ -425,16 +412,15 @@ void InitGame (void)
while ((bioskey(0)>>8) != sc_Return);
#endif
#if GRMODE == EGAGR
if (mminfo.mainmem < 335l*1024)
{
#pragma warn -pro
#pragma warn -nod
textcolor(7);
textbackground(0);
clrscr(); // we can't include CONIO because of a name conflict
#pragma warn +nod
#pragma warn +pro
#pragma warn -pro
#pragma warn -nod
clrscr(); // we can't include CONIO because of a name conflict
#pragma warn +nod
#pragma warn +pro
puts ("There is not enough memory available to play the game reliably. You can");
puts ("play anyway, but an out of memory condition will eventually pop up. The");
puts ("correct solution is to unload some TSRs or rename your CONFIG.SYS and");
@@ -454,7 +440,7 @@ void InitGame (void)
SD_Startup ();
US_Startup ();
US_UpdateTextScreen();
// US_UpdateTextScreen();
CA_Startup ();
US_Setup ();
@@ -472,7 +458,7 @@ void InitGame (void)
for (i=KEEN_LUMP_START;i<=KEEN_LUMP_END;i++)
CA_MarkGrChunk(i);
CA_CacheMarks (NULL);
CA_CacheMarks (NULL, 0);
MM_SetLock (&grsegs[STARTFONT],true);
MM_SetLock (&grsegs[STARTFONTM],true);
@@ -503,28 +489,24 @@ void InitGame (void)
==========================
*/
static char *EntryParmStrings[] = {"detour",nil};
void main (void)
{
boolean LaunchedFromShell = false;
short i;
textcolor(7);
textbackground(0);
if (stricmp(_argv[1], "/VER") == 0)
{
printf("KEEN DREAMS\n");
printf("CGA Version\n");
printf("Copyright 1991-93 Softdisk Publishing\n");
printf("Version 1.05 (rev 1)\n");
printf("\nKeen Dreams version 1.93 (Rev 1)\n");
printf("developed for use with 100%% IBM compatibles\n");
printf("that have 640K memory, DOS version 3.3 or later,\n");
printf("and an EGA or VGA display adapter.\n");
printf("Copyright 1991-1993 Softdisk Publishing.\n");
printf("Commander Keen is a trademark of Id Software.\n");
exit(0);
}
if (stricmp(_argv[1], "/?") == 0)
{
printf("\nKeen Dreams CGA version 1.05\n");
printf("\nKeen Dreams version 1.93\n");
printf("Copyright 1991-1993 Softdisk Publishing.\n\n");
printf("Commander Keen is a trademark of Id Software.\n");
printf("Type KDREAMS from the DOS prompt to run.\n\n");
@@ -540,27 +522,12 @@ void main (void)
exit(0);
}
for (i = 1;i < _argc;i++)
{
switch (US_CheckParm(_argv[i],EntryParmStrings))
{
case 0:
LaunchedFromShell = true;
break;
}
}
#ifndef CATALOG
if (!LaunchedFromShell)
{
clrscr();
puts("You must type START at the DOS prompt to run KEEN DREAMS.");
exit(0);
}
#endif
textcolor(7);
textbackground(0);
InitGame();
DemoLoop(); // DemoLoop calls Quit when everything is done
DemoLoop(); // DemoLoop calls Quit when everything is done
Quit("Demo loop exited???");
}
+7 -5
View File
@@ -81,14 +81,14 @@ char *levelnames[21] =
"Bridge Bottoms",
"Rhubarb Rapids",
"Parsnip Pass",
"Cheat Level 1",
"Level 6",
"Spud City",
"Cheat Level 2",
"Level 8",
"Apple Acres",
"Grape Grove",
"Cheat Level 3",
"Level 11",
"Brussels Sprout Bay",
"Cheat Level 4",
"Level 13",
"Squash Swamp",
"Boobus' Chamber",
"Castle Tuberia",
@@ -679,6 +679,7 @@ void FadeAndUnhook (void)
{
if (++fadecount==2)
{
RF_ForceRefresh();
VW_FadeIn ();
RF_SetRefreshHook (NULL);
lasttimecount = TimeCount; // don't adaptively time the fade
@@ -738,7 +739,7 @@ void SetupGameLevel (boolean loadnow)
US_PrintCentered ("Boobus Bombs Near!");
VW_UpdateScreen ();
}
CA_CacheMarks (levelnames[mapon]);
CA_CacheMarks (levelnames[mapon], 0);
}
#if 0
@@ -1725,6 +1726,7 @@ struct date d;
VW_WaitVBL(60);
IN_ClearKeysDown ();
IN_Ack();
}
//==========================================================================
BIN
View File
Binary file not shown.
+1069
View File
File diff suppressed because it is too large Load Diff
+35
View File
@@ -0,0 +1,35 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
extern void (*LZH_CompressDisplayVector)();
extern void (*LZH_DecompressDisplayVector)();
//===========================================================================
//
// PROTOTYPES
//
//===========================================================================
long lzhCompress(void far *infile, void far *outfile,unsigned long DataLength,unsigned PtrTypes);
long lzhDecompress(void far *infile, void far *outfile, unsigned long OrginalLength, unsigned long CompressLength, unsigned PtrTypes);
+40
View File
@@ -0,0 +1,40 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//--------------------------------------------------------------------------
//
// EXTERN DEFINITIONS FOR DISPLAY VEC ROUTINES
//
//--------------------------------------------------------------------------
extern void (*LZW_CompressDisplayVector)();
extern void (*LZW_DecompressDisplayVector)();
//---------------------------------------------------------------------------
//
// FUNCTION PROTOTYPEING
//
//---------------------------------------------------------------------------
unsigned long lzwCompress(void far *infile, void far *outfile,unsigned long DataLength,unsigned PtrTypes);
void lzwDecompress(void far *infile, void far *outfile,unsigned long DataLength,unsigned PtrTypes);
+109
View File
@@ -0,0 +1,109 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _SL_FILE_H
#define _SL_FILE_H
//==========================================================================
//
// DEFINES
//
//==========================================================================
#ifndef MakeID
#define MakeID(a,b,c,d) (((long)(d)<<24L)|((long)(c)<<16L)|((long)(b)<<8L)|(long)(a))
#endif
#define ID_SLIB MakeID('S','L','I','B')
#define SLIB ("SLIB")
#define SOFTLIB_VER 2
#define ID_CHUNK MakeID('C','U','N','K')
//==========================================================================
//
// TYPES
//
//==========================================================================
//--------------------------------------------------------------------------
// SOFTLIB File Entry Types
//--------------------------------------------------------------------------
typedef enum LibFileTypes
{
lib_DATA =0, // Just streight raw data
// lib_AUDIO, // Multi chunk audio file
} LibFileTypes;
//--------------------------------------------------------------------------
// SOFTLIB Library File header..
//
// * This header will NEVER change! *
//--------------------------------------------------------------------------
typedef struct SoftLibHdr
{
unsigned Version; // Library Version Num
unsigned FileCount;
} SoftlibHdr;
//--------------------------------------------------------------------------
// SOFTLIB Directory Entry Hdr
//
// This can change according to Version of SoftLib (Make sure we are
// always downward compatable!
//--------------------------------------------------------------------------
#define SL_FILENAMESIZE 16
typedef struct FileEntryHdr
{
char FileName[SL_FILENAMESIZE]; // NOTE : May not be null terminated!
unsigned long Offset;
unsigned long ChunkLen;
unsigned long OrginalLength;
short Compression; // ct_TYPES
} FileEntryHdr;
//--------------------------------------------------------------------------
// SOFTLIB Entry Chunk Header
//--------------------------------------------------------------------------
typedef struct ChunkHeader
{
unsigned long HeaderID;
unsigned long OrginalLength;
short Compression; // ct_TYPES
} ChunkHeader;
#endif
+480
View File
@@ -0,0 +1,480 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <alloc.h>
#include <fcntl.h>
#include <dos.h>
#include <io.h>
#include "kd_def.h"
//#include "gelib.h"
#include "soft.h"
#include "lzw.h"
#include "lzhuff.h"
#include "jam_io.h"
BufferedIO lzwBIO;
//===========================================================================
//
// SWITCHES
//
//===========================================================================
#define LZH_SUPPORT 1
#define LZW_SUPPORT 0
//=========================================================================
//
//
// GENERAL LOAD ROUTINES
//
//
//=========================================================================
//--------------------------------------------------------------------------
// BLoad() -- THIS HAS NOT BEEN FULLY TESTED!
//
// NOTICE : This version of BLOAD is compatable with JAMPak V3.0 and the
// new fileformat...
//--------------------------------------------------------------------------
unsigned long BLoad(char *SourceFile, memptr *DstPtr)
{
int handle;
memptr SrcPtr;
unsigned long i, j, k, r, c;
word flags;
byte Buffer[8];
unsigned long SrcLen,DstLen;
struct CMP1Header CompHeader;
boolean Compressed = false;
memset((void *)&CompHeader,0,sizeof(struct CMP1Header));
//
// Open file to load....
//
if ((handle = open(SourceFile, O_RDONLY|O_BINARY)) == -1)
return(0);
//
// Look for JAMPAK headers
//
read(handle,Buffer,4);
if (!strncmp(Buffer,COMP,4))
{
//
// Compressed under OLD file format
//
Compressed = true;
SrcLen = Verify(SourceFile);
read(handle,(void *)&CompHeader.OrginalLen,4);
CompHeader.CompType = ct_LZW;
MM_GetPtr(DstPtr,CompHeader.OrginalLen);
if (!*DstPtr)
return(0);
}
else
if (!strncmp(Buffer,CMP1,4))
{
//
// Compressed under new file format...
//
Compressed = true;
SrcLen = Verify(SourceFile);
read(handle,(void *)&CompHeader,sizeof(struct CMP1Header));
MM_GetPtr(DstPtr,CompHeader.OrginalLen);
if (!*DstPtr)
return(0);
}
else
DstLen = Verify(SourceFile);
//
// Load the file in memory...
//
if (Compressed)
{
DstLen = CompHeader.OrginalLen;
if ((MM_TotalFree() < SrcLen) && (CompHeader.CompType))
{
if (!InitBufferedIO(handle,&lzwBIO))
Quit("No memory for buffered I/O.");
switch (CompHeader.CompType)
{
#if LZW_SUPPORT
case ct_LZW:
lzwDecompress(&lzwBIO,MK_FP(*DstPtr,0),CompHeader.OrginalLen,(SRC_BFILE|DEST_MEM));
break;
#endif
#if LZH_SUPPORT
case ct_LZH:
lzhDecompress(&lzwBIO,MK_FP(*DstPtr,0),CompHeader.OrginalLen,CompHeader.CompressLen,(SRC_BFILE|DEST_MEM));
break;
#endif
default:
Quit("BLoad() - Unrecognized/Supported compression");
break;
}
FreeBufferedIO(&lzwBIO);
}
else
{
CA_LoadFile(SourceFile,&SrcPtr);
switch (CompHeader.CompType)
{
#if LZW_SUPPORT
case ct_LZW:
lzwDecompress(MK_FP(SrcPtr,8),MK_FP(*DstPtr,0),CompHeader.OrginalLen,(SRC_MEM|DEST_MEM));
break;
#endif
#if LZH_SUPPORT
case ct_LZH:
lzhDecompress(MK_FP(SrcPtr,8),MK_FP(*DstPtr,0),CompHeader.OrginalLen,CompHeader.CompressLen,(SRC_MEM|DEST_MEM));
break;
#endif
default:
Quit("BLoad() - Unrecognized/Supported compression");
break;
}
MM_FreePtr(&SrcPtr);
}
}
else
CA_LoadFile(SourceFile,DstPtr);
close(handle);
return(DstLen);
}
////////////////////////////////////////////////////////////////////////////
//
// LoadLIBShape()
//
int LoadLIBShape(char *SLIB_Filename, char *Filename,struct Shape *SHP)
{
#define CHUNK(Name) (*ptr == *Name) && \
(*(ptr+1) == *(Name+1)) && \
(*(ptr+2) == *(Name+2)) && \
(*(ptr+3) == *(Name+3))
int RT_CODE;
FILE *fp;
char CHUNK[5];
char far *ptr;
memptr IFFfile = NULL;
unsigned long FileLen, size, ChunkLen;
int loop;
RT_CODE = 1;
// Decompress to ram and return ptr to data and return len of data in
// passed variable...
if (!LoadLIBFile(SLIB_Filename,Filename,&IFFfile))
Quit("Error Loading Compressed lib shape!");
// Evaluate the file
//
ptr = MK_FP(IFFfile,0);
if (!CHUNK("FORM"))
goto EXIT_FUNC;
ptr += 4;
FileLen = *(long far *)ptr;
SwapLong((long far *)&FileLen);
ptr += 4;
if (!CHUNK("ILBM"))
goto EXIT_FUNC;
ptr += 4;
FileLen += 4;
while (FileLen)
{
ChunkLen = *(long far *)(ptr+4);
SwapLong((long far *)&ChunkLen);
ChunkLen = (ChunkLen+1) & 0xFFFFFFFE;
if (CHUNK("BMHD"))
{
ptr += 8;
SHP->bmHdr.w = ((struct BitMapHeader far *)ptr)->w;
SHP->bmHdr.h = ((struct BitMapHeader far *)ptr)->h;
SHP->bmHdr.x = ((struct BitMapHeader far *)ptr)->x;
SHP->bmHdr.y = ((struct BitMapHeader far *)ptr)->y;
SHP->bmHdr.d = ((struct BitMapHeader far *)ptr)->d;
SHP->bmHdr.trans = ((struct BitMapHeader far *)ptr)->trans;
SHP->bmHdr.comp = ((struct BitMapHeader far *)ptr)->comp;
SHP->bmHdr.pad = ((struct BitMapHeader far *)ptr)->pad;
SwapWord(&SHP->bmHdr.w);
SwapWord(&SHP->bmHdr.h);
SwapWord(&SHP->bmHdr.x);
SwapWord(&SHP->bmHdr.y);
ptr += ChunkLen;
}
else
if (CHUNK("BODY"))
{
ptr += 4;
size = *((long far *)ptr);
ptr += 4;
SwapLong((long far *)&size);
SHP->BPR = (SHP->bmHdr.w+7) >> 3;
MM_GetPtr(&SHP->Data,size);
if (!SHP->Data)
goto EXIT_FUNC;
movedata(FP_SEG(ptr),FP_OFF(ptr),FP_SEG(SHP->Data),0,size);
ptr += ChunkLen;
break;
}
else
ptr += ChunkLen+8;
FileLen -= ChunkLen+8;
}
RT_CODE = 0;
EXIT_FUNC:;
if (IFFfile)
{
// segptr = (memptr)FP_SEG(IFFfile);
MM_FreePtr(&IFFfile);
}
return (RT_CODE);
}
//----------------------------------------------------------------------------
// LoadLIBFile() -- Copies a file from an existing archive to dos.
//
// PARAMETERS :
//
// LibName - Name of lib file created with SoftLib V1.0
//
// FileName - Name of file to load from lib file.
//
// MemPtr - (IF !NULL) - Pointer to memory to load into ..
// (IF NULL) - Routine allocates necessary memory and
// returns a MEM(SEG) pointer to memory allocated.
//
// RETURN :
//
// (IF !NULL) - A pointer to the loaded data.
// (IF NULL) - Error!
//
//----------------------------------------------------------------------------
memptr LoadLIBFile(char *LibName,char *FileName,memptr *MemPtr)
{
int handle;
unsigned long header;
struct ChunkHeader Header;
unsigned long ChunkLen;
short x;
struct FileEntryHdr FileEntry; // Storage for file once found
struct FileEntryHdr FileEntryHeader; // Header used durring searching
struct SoftLibHdr LibraryHeader; // Library header - Version Checking
boolean FileFound = false;
unsigned long id_slib = ID_SLIB;
unsigned long id_chunk = ID_CHUNK;
//
// OPEN SOFTLIB FILE
//
if ((handle = open(LibName,O_RDONLY|O_BINARY, S_IREAD)) == -1)
return(NULL);
//
// VERIFY it is a SOFTLIB (SLIB) file
//
if (read(handle,&header,4) == -1)
{
close(handle);
return(NULL);
}
if (header != id_slib)
{
close(handle);
return(NULL);
}
//
// CHECK LIBRARY HEADER VERSION NUMBER
//
if (read(handle, &LibraryHeader,sizeof(struct SoftLibHdr)) == -1)
Quit("read error in LoadSLIBFile()\n");
if (LibraryHeader.Version > SOFTLIB_VER)
Quit("Unsupported file ver ");
//
// MANAGE FILE ENTRY HEADERS...
//
for (x = 1;x<=LibraryHeader.FileCount;x++)
{
if (read(handle, &FileEntryHeader,sizeof(struct FileEntryHdr)) == -1)
{
close(handle);
return(NULL);
}
if (!stricmp(FileEntryHeader.FileName,FileName))
{
FileEntry = FileEntryHeader;
FileFound = true;
}
}
//
// IF FILE HAS BEEN FOUND THEN SEEK TO POSITION AND EXTRACT
// ELSE RETURN WITH ERROR CODE...
//
if (FileFound)
{
if (lseek(handle,FileEntry.Offset,SEEK_CUR) == -1)
{
close(handle);
return(NULL);
}
//
// READ CHUNK HEADER - Verify we are at the beginning of a chunk..
//
if (read(handle,(char *)&Header,sizeof(struct ChunkHeader)) == -1)
Quit("LIB File - Unable to read Header!");
if (Header.HeaderID != id_chunk)
Quit("LIB File - BAD HeaderID!");
//
// Allocate memory if Necessary...
//
if (!*MemPtr)
MM_GetPtr(MemPtr,FileEntry.OrginalLength);
//
// Calculate the length of the data (without the chunk header).
//
ChunkLen = FileEntry.ChunkLen - sizeof(struct ChunkHeader);
//
// Extract Data from file
//
switch (Header.Compression)
{
#if LZW_SUPPORT
case ct_LZW:
if (!InitBufferedIO(handle,&lzwBIO))
Quit("No memory for buffered I/O.");
lzwDecompress(&lzwBIO,MK_FP(*MemPtr,0),FileEntry.OrginalLength,(SRC_BFILE|DEST_MEM));
FreeBufferedIO(&lzwBIO);
break;
#endif
#if LZH_SUPPORT
case ct_LZH:
if (!InitBufferedIO(handle,&lzwBIO))
Quit("No memory for buffered I/O.");
lzhDecompress(&lzwBIO, MK_FP(*MemPtr,0), FileEntry.OrginalLength, ChunkLen, (SRC_BFILE|DEST_MEM));
FreeBufferedIO(&lzwBIO);
break;
#endif
case ct_NONE:
if (!CA_FarRead(handle,MK_FP(*MemPtr,0),ChunkLen))
{
// close(handle);
*MemPtr = NULL;
}
break;
default:
close(handle);
Quit("Unknown Chunk.Compression Type!");
break;
}
}
else
*MemPtr = NULL;
close(handle);
return(*MemPtr);
}
+25
View File
@@ -0,0 +1,25 @@
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
//memptr InitBufferedIO(int handle, BufferedIO *bio);
//void FreeBufferedIO(BufferedIO *bio);
//byte bio_readch(BufferedIO *bio);
unsigned long BLoad(char *SourceFile, memptr *DstPtr);
memptr LoadLIBFile(char *LibName,char *FileName,memptr *MemPtr);
int LoadLIBShape(char *SLIB_Filename, char *Filename,struct Shape *SHP);
+31 -84
View File
@@ -1,102 +1,49 @@
HELP: CONTROLS
* * * * * * *
GAME CONTROLS
* * * * * * *
This section will tell you what controls you can use to help Commander Keen move around and do things.
Here's a quick summary chart of the controls you can use. You can change some of the keyboard controls by pressing [F3] during play or in the Control Panel.
Here's a quick summary chart of the default controls you can use.
MOVE KEEN AROUND:
Use the arrow keys or joystick.
MOVE. Use joystick, or the arrow keys and numbers.
JUMP/ENTER. To make Keen jump, or to enter a city, press button 1 on your joystick or Ctrl on the keyboard.
THROW. To throw a Flower Power or Boobus Bomb, press button 2 or Alt.
CLIMB POLE. To shinny up or slide down a pole, stand in front of the pole and move the joystick in that direction. On the keyboard, use the up or down arrow.
JUMP DOWN. If you are on a log or beam, you can jump down from it by moving your joystick down and pressing button 1. On the keyboard, down arrow plus Ctrl does the trick.
DUCK. If you aren't in front of a pole, pressing down will make Keen duck. You can't duck in front of a poleyou'll climb down it!
STATUS WINDOW. Press the spacebar to see how many Keens you have, how many points you need for your next Keen, how many Boobus Bombs you have, and how many keys you have.
ENTER A NEW AREA:
Press the [CTRL] key or joystick Button 1 when Keen is on top of a new area in the big map.
MORE HELP
JUMP UP:
To make Keen jump, press the [CTRL] key or joystick Button 1.
Once you've selected a New Game, you will be placed in the Land of Tuberia, right next to the hill you woke up on. To your left is Horseradish Hill, the first place you can explore in the game. You can move Commander Keen around using the arrow keys, the numeric keypad, or whatever movement keys you define in the Controls section of the Control Panel (you're in the Control Panel right now, in the Help Section).
CLIMB A POLE:
To shinny up or slide down a pole, stand in front of the pole or jump up to it and use the up or down arrow keys or the joystick to climb.
If you get to an area that has vegetable or fruit pictures and you see a waving flag with a "T" on it, that means you can enter this city or area by walking onto it and pressing Ctrl or button 1. You will have to finish some places before you can get past them. Horseradish Hill is one of these places.
THROW:
To throw a Flower Power or Boobus Bomb, press the [ALT] key or joystick Button 2.
Once you enter an area, you must find your way to the exit. However, you need to explore all over, because your mission is to defeat Boobus Tuber, and the only thing that can affect him is a Boobus Bomb. A Boobus Bomb is a round black bomb with a big smiley face on it.
JUMP DOWN:
If you are on a log, beam or other platform, you can jump down from it by pressing the down-arrow plus [CTRL] keys or joystick Button 1 and the joystick down-position.
You will need at least twelve Boobus Bombs to defeat Boobus Tuber. There are more than twelve hidden in the Land of Tuberia, and some are harder to get than others.
DUCK:
If you aren't on a pole, pressing down will make Keen duck. You can't duck in front of a pole---you'll climb down it!
To help you on your way, you can get Flower Powers, which turn monsters into flowers for a little while. A Flower Power is a little silver ball that blinks red and yellow. You can also get a Super Flower Power, which looks like a flowerpot. This will give you five Flower Powers.
* * * * * * *
FUNCTION KEYS
* * * * * * *
There are many other things you can get. For points, you can the following:
F1 - Get Help
Peppermint (100 points)
Cookie (200 points)
Candy Cane (500 points)
Candy Bar (1000 points)
Lollipop (2000 points)
Cotton Candy (5000 points)
F2 - Turn Sound On/Off
You get an extra Keen at 20000 points. You'll have to get twice as many points for each additional Keen (40000, 80000, 160000, etc.).
F3 - Configure keyboard and joystick controls
There are Extra Keens on levels, too. They look like a little waving Keen.
F4 - Restart Game
There are other, even better powerups on the levels, so keep an eye out for them.
F5 - New Game
CAST OF CHARACTERS
F6 - Save or Load game
ESC- Exit current game
*** END OF THIS HELP SECTION ***
If you get touched by one of the bad vegetables, or if you plummet or land on a harmful thing, you will fall back asleep. You only have a certain number of chances to succeed in your quest, so make 'em count!
CARROT COURIERS
These guys have tennis shoes and they are in a HURRY! They won't hurt you but they can push you off whatever you're standing on.
TATER TROOPER
They are dumb, but they can be dangerous!
BROCCOLASH
Watch out or the broccolashes will do their "Broccolash Smash" on you.
TOMATOOTH
Probably the scariest of the vegetables, with their scary teeth.
ASPARAGUSTO
They run fast and they're hard to hit with Flower Powers.
SOUR GRAPE
They'll fall on top of you, unless you can trick them.
CANTELOUPE CART
These can take you over dangerous areas, but don't let them smash you into walls!
FRENCHY
These scary potatoes from France will throw fearsome french fries at you.
SQUASHER
They look friendly until you get closethen they try to squash you!
MELON LIPS
They spit watermelon seeds at you.
APELS
They can climb poles just like you do!
PEA PODS
They run around and spit out Pea Brains.
PEA BRAINS
Don't let these little fellows touch you!
KING BOOBUS TUBER
Sitting in his Castle atop Mount Tuberest, Boobus Tuber brings kids to Tuberia to be his slaves. Defeat him with Boobus Bombs. Then you can turn off his Dream Machine and rescue all the kids!
GAME HINTS
Get candy for points, which will get you extra lives.
Search everywherethere's a LOT of hidden stuff!
Don't assume anything.
CONCLUSION
So, good luck now, Commander Keen! Turn off that stupid Dream Machine!
~
+52 -35
View File
@@ -1,74 +1,91 @@
HELP: CONTROL PANEL
This Help section contains the following topics:
You are now in the Control Panel. The Control Panel is here to help you use Commander Keen the way you want tobut first, you need to know how to look at this Help article.
To read more of this text, you will have to press the down arrow key. If you scroll the text too far, you can press the up arrow key to scroll back up. The Page Up and Page Dn keys work as well. Also, if you have a mouse or joystick connected, they can be used to scroll the text. When you are done reading the text, press Esc. All three Help topics work this way. You can get more help on the controls of the game, and you can read the story of "Keen Dreams."
ABOUT THE CONTROL PANEL
THE 6 CONTROL PANEL OPTIONS
CONTROL PANEL SHORTCUTS
FOR SUPER VGA USERS
COMMAND LINE PARAMETERS
CONTROL PANEL SECTIONS
ABOUT THE CONTROL PANEL
=======================
You are now in the Control Panel of KEEN DREAMS. The Control Panel is here to help you play the way you want to---but first, you need to know how to use the Help sections.
There are six sections to choose in the Control Panel. They are: Game, Help, Disk, Controls, Sound Effects, and Music. You can choose these sections by selecting the buttons on the left side of the screen. With the keyboard, use the arrows to move the ship cursor to the button you want, then press ENTER. The joystick or mouse can also move the ship cursor, and pushing the button will select the item the ship is on.
Use the arrow keys, the Page Up and Page Down keys, or your mouse to move through the text in these sections. Pressing the [ESC] key will exit out of the Help section.
GAME SECTION
You can choose to start a new game in easy, normal, or hard modes. These determine how long your Flower Powers last.
Important note: There is no joystick option available in this game.
If you are in the middle of a game and haven't saved it, starting a new game will wipe out that old game forever.
The 6 CONTROL PANEL OPTIONS
===========================
There are six options to choose from in the Control Panel. They are:
Game
Help
Disk
Controls
Sound Effects
Music
You can choose these sections by selecting the buttons on the left side of the screen. With the keyboard, use the arrows to move the ship cursor to the button you want, then press [ENTER]. The mouse can also move the ship cursor, and pushing the button will select the item the ship is on.
GAME OPTION
You can choose to start a new game in Easy, Normal, or Hard modes. These determine how long your Flower Powers last.
If you are in the middle of a game and haven't saved it, starting a new game will wipe out that old game forever.
You can also choose to resume a game if you went to the Control Panel in the middle of play.
HELP SECTION
This is where you are now. This topic is "Help me, I'm lost!" The others are about the game controls, and the story of "Keen Dreams."
HELP OPTION
This is where you are now.
DISK SECTION
DISK OPTION
You can save your current game or load a previously saved game here. You can name your saved game so you'll remember where you saved it. Loading a game will replace your current game (make sure you saved it). Saving over an old game will replace that game forever.
You can also "Exit to DOS," which will quit the game.
CONTROLS SECTION
You can control the game by keyboard or joystick. If you choose keyboard, you can redefine which keys you wish to use to control Keen. In the Control Panel, you will always use the arrow keys and ENTER.
CONTROLS OPTION
You can control the game by keyboard. You can redefine which keys you wish to use to control Keen. In the Control Panel, you will always use the arrow keys and [ENTER].
SOUND EFFECTS SECTION
If you have an AdLib, Sound Blaster, or Sound Source, you can choose to have the sound effects play on them. ("Keen Dreams" was too full of neat stuff and cool graphics to include digitized sound effects for the Sound Source and Sound Blaster, however.) If you don't have any of these boards, you'll have to choose "No Sound Effects" or "PC Speaker."
SOUND EFFECTS OPTION
You can select to have sound effects played from your computer speaker or from speakers attached to a sound card installed in your computer.
MUSIC SECTION
MUSIC OPTION
Future games using this interface will include music. If you have an AdLib or SoundBlaster, you can choose to have background music playing. Otherwise, no music. We tried to make everything fit for Keen Dreams, but we had to opt for more levels and less frills, like music. (We tried, believe me!)
HOT KEYS: CONTROL PANEL SHORTCUTS
HOT KEYS: CONTROL PANEL SHORTCUTS
=================================
Some of the function keys provide quick shortcuts to parts of the control panel. Here's a quick list of them.
F1: Help
F2: Sounds
F3: Keyboard
F4: Joystick
F5: Restart Game
F6: Load/Save Game
F7: Music
Esc: Quit (or return to game, from Control Panel)
F1: Help
F2: Sounds
F3: Keyboard
F4: -unused-
F5: Restart Game
F6: Load/Save Game
F7: Music
ESC: Quit (or return to game, from Control Panel)
NOTE TO SUPER VGA OWNERS
========================
If you own a Speedstar VGA card or other non-100% compatible SVGA card, you'll need to type "KDREAMS /COMP" on the command line, instead of just "KDREAMS." This should fix all your problems.
OTHER NEAT-O COMMAND LINE PARAMETERS
When some documentation tells you to type more that just the name of the program you want to run (like we did above), those extra bits are called "command line parameters." This is a fancy term for extra information you can give the program when you run it. Normally, you will never have to type these. If the program is having trouble with your hardware, try the appropriate parameter. Here are some command line parameters that work with Commander Keen:
COMMAND LINE PARAMETERS
=======================
When some documentation tells you to type more than just the name of the program you want to run (like we did above), those extra bits are called "command line parameters." This is a fancy term for extra information you can give the program when you run it. Normally, you will never have to type these. If the program is having trouble with your hardware, try the appropriate parameter. Here are some command line parameters that work with Commander Keen:
KDREAMS /NODR (Type this if the program hangs a lot with the drive still on.)
KDREAMS /NOAL (No AdLib or Sound Blaster detection.)
KDREAMS /NOSB (No Sound Blaster detection.)
KDREAMS /NOSS (No Sound Source detection.)
KDREAMS /SST (Put Sound Source in Tandy mode for Tandy computers with the special Sound Source adapter.)
KDREAMS /SS1 (Set Sound Source to LPT1. /SS2 will set it to LPT2, and /SS3, LPT3.)
KDREAMS /NOJOYS (Tell program to ignore joystick.)
KDREAMS /NOMOUSE (Tell program to ignore mouse.)
KDREAMS /HIDDENCARD (Overrides video card detection if the program seems to be detecting your video card incorrectly and not letting you play.)
CONCLUSION
Now go explore the Control Panel, and have fun playing Keen Dreams!
*** END OF THIS HELP SECTION ***
~
Binary file not shown.
Binary file not shown.
+7 -3
View File
@@ -1,11 +1,12 @@
HELP: THE STORY SO FAR
THE STORY SO FAR
Billy Blaze, eight year-old genius, working diligently in his backyard clubhouse has created an interstellar starship from old soup cans, rubber cement, and plastic tubing. While his folks are out on the town and the babysitter has fallen asleep, Billy travels into his backyard workshop, dons his brother's football helmet, and transforms into...
COMMANDER KEENdefender of Earth!
COMMANDER KEEN --- defender of Earth!
In his ship, the Bean-with-Bacon Megarocket, Keen dispenses galactic justice with an iron hand!
THIS EPISODE: "Keen Dreams"
We find young Billy discussing matters of paramount importance with his mother.
@@ -59,5 +60,8 @@ Just then, a child in chains ran up to him.
"Whatever. Save us!" said the child.
So Billy hopped out of bed and started on his quest to defeat King Boobus Tuber and destroy the Dream Machine.
So Billy hopped out of bed and started on his quest to defeat King Boobus Tuber and destroy the Dream Machine!
*** END OF THIS HELP SECTION ***
~