home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
D!Zone (Collector's Edition)
/
D_ZONE_CD.ISO
/
helps
/
dmijum
/
jumble.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-06
|
26KB
|
675 lines
/*
* JUMBLE.C
*
* Version 1.0.0
*
* Abstract:
* This program creates a file, JUMBLE.WAD, that contains the 27 maps
* from DOOM in a random order. The things (characters, items, etc.) in each
* map are shuffled and start out facing in a random direction. Each map
* has a song randomly assigned to it. The Boss levels are special
* exceptions: they remain in the same place (map 8), but they get new,
* wacky music never before heard in a map. Take note: JUMBLE.WAD is over
* 3 megs in size. E3M8 is handled specially, and it is twisted!
*
* After creating JUMBLE.WAD, run DOOM with this form:
* DOOM -file JUMBLE.WAD { other parameters }
*
* History:
* 1.0.0 (April 3, 1994)
*
* Author:
* Michael McMahon
*
****************************************************************************
* Jumble Function Directory
*---------------------------------------------------------------------------
*Index: Name : Description
*---------------------------------------------------------------------------
* #1 : WadfileCopyAndJumbleMap : Can be used instead of 'WadfileCopyMap'.
****************************************************************************
*
* WADLIB SOFTWARE LICENSE AGREEMENT
*
* 1. GRANT OF LICENSE. Michael McMahon and his affiliations (collectively
* the "AUTHOR") grant you (either an individual or an entity) the
* non-exclusive, royalty-free right to use this library source code,
* documentation, and sample code (collectively, the "SOFTWARE") for
* any lawful purpose subject to the terms of this license. By using the
* SOFTWARE you are agreeing to be bound to all the terms of this license.
*
* 2. COPYRIGHT. The SOFTWARE is Copyright (c) 1994, Michael McMahon,
* PO Box 14807, San Luis Nabisco, CA 93406-4807 USA. All Rights Reserved
* Worldwide. You may not use, modify, or distribute the SOFTWARE except
* as otherwise provided herein.
*
* 3. DECLARATION OF PUBLIC DOMAIN DISTRIBUTION AND USE. The distribution
* and use of the SOFTWARE is hereby designated PUBLIC DOMAIN by the
* the AUTHOR. You may not sell, rent, or lease this SOFTWARE. The
* SOFTWARE may be reproduced verbatim in part or in full by any
* reproduction means for any lawful purpose, and may also be subject to
* the following agreement.
*
* 4. AGREEMENT FOR USE OF SOFTWARE. The AUTHOR grants you a non-exclusive,
* royalty-free right to incorporate the SOFTWARE into any production for
* any legal purpose as long as you agree
* (a) to indemnify, hold harmless, and defend the AUTHOR from and against
* any claims or lawsuits, including attorneys' fees, that arise or
* result from the use or distribution of your software production; and
* (b) no matter how much the SOFTWARE is modified, the AUTHOR owns the
* copyright and this original, unmodified copyright notice remains
* intact in the source code; and,
* (c) the AUTHOR is not held responsible for fixing bugs or making
* enhancements or changes to the SOFTWARE for any reason; and,
* (d) the SOFTWARE is not redistributed if it is modified in any way; and,
* (e) otherwise comply with the terms of this agreement; and,
* (f) the AUTHOR is forgiven for making so many demands.
*
* THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE
* AUTHOR FURTHER DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING WITHOUT
* LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS
* FOR A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE
* OR PERFORMANCE OF THE SOFTWARE REMAINS WITH YOU.
*
* The author can be reached at:
* Michael McMahon
* P.O. Box 14807
* San Luis Nabisco, CA 93406-4807 USA
* Internet: mmcmahon@oboe.calpoly.edu
* [Bug reports, suggestions, success stories, etc. are welcome; tech
* support, and other unnecessary two-way mail, is not]
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <mem.h>
#include <time.h>
#include "general.h"
#include "wadfile.h"
#include "dm_mapdf.h"
/* Program-specific definitions */
#define PROG_FILENAME "JUMBLE"
#define PROG_AUTHOR "Michael McMahon"
/* Values to be returned to the operating system */
#define EXIT_ERROR -1
#define EXIT_OK 0
/* System bounds */
#define MAX_ENTRIES 500
#define FILE_NAME_SIZE 200
/* Target filename */
#define JUMBLE_NAME "JUMBLE.WAD"
/* Jumble structure */
typedef struct {
int episode;
int map;
int touched;
char musicName[SIZEOF_WAD_DIR_ENTRY];
} JumbledMapRec;
/* Funny BOSS level music */
char * bossEpisodeMusic[DOOM_LASTEPISODE]={"D_VICTOR","D_INTRO\0","D_BUNNY\0"};
/* Maximum allowable THINGS per map */
#define MAX_THINGS 1000
/* Record used to shuffle THINGS */
struct {
int newLocation;
int touched;
} jumbledThings[MAX_THINGS];
/* Symbol used to determine what maps still need to be defined */
#define JUMBLEREC_UNTOUCHED 0
#define JUMBLEREC_TOUCHED 1
/* Thing types */
#define TYPE_PLAYER1START 1
#define TYPE_PLAYER2START 2
#define TYPE_PLAYER3START 3
#define TYPE_PLAYER4START 4
#define TYPE_BLUEKEY 5
#define TYPE_YELLOWKEY 6
#define TYPE_SPIDERDEMON 7
#define TYPE_DEATHMATCHPOS 11
#define TYPE_REDKEY 13
#define TYPE_TELEPORTER 14
#define TYPE_CYBERLORD 16
#define TYPE_CELL_CASE 17
#define TYPE_REDSKULL 38
#define TYPE_YELLOWSKULL 39
#define TYPE_BLUESKULL 40
#define TYPE_INVULNERABILITY 2022
#define TYPE_CELL_CHARGE 2047
#define TYPE_BARON 3003
#define TYPE_HUMAN 3004
#define TYPE_CACODEMON 3005
/* Constants used in randomizing angle THINGS initially face */
#define NUM_FACES 8
#define TOTAL_DEGREES 360
/*------------------------- Internal routines ---------------------------*/
/**[ Internal 1 of 2 ]****************************************************
* *
* wadMalloc *
* *
* Desc: *
* This is the memory allocation routine for this example program. *
* The memory management routines are stored outside WADFILE.C so *
* it would be compatible with any memory manager. This example *
* uses ANSI C's malloc. *
* *
* Def: *
* static void * wadMalloc(unsigned long size); *
* *
* Parm: *
* size Number of bytes to allocate. *
* *
* Retn: *
* Pointer to allocated memory, or NULL if not enough memory. *
* *
* Notes: *
* Use a pointer to this routine as the first parameter in the *
* 'WadfileInitialize' call. *
* *
*************************************************************************/
static void * wadMalloc (unsigned long size)
{
/* Note: If size is > 64k, some implementations of malloc might not work */
return malloc(size);
}
/**[ Internal 2 of 2 ]****************************************************
* *
* wadFree *
* *
* Desc: *
* This is the memory deallocation routine for this example program. *
* The memory management routines are stored outside WADFILE.C so *
* it would be compatible with any memory manager. This example *
* uses ANSI C's free. *
* *
* Def: