From: sparky4 Date: Tue, 25 Aug 2015 17:09:32 +0000 (-0500) Subject: removed duplicates!! wwww X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=0dfcfd175f6b30ae2ed5ba87d4f91e92e00a73d2;p=16.git removed duplicates!! wwww renamed: 16/v2/source/archives/V2GPL.ZIP -> 16/v2/archives/V2GPL.ZIP deleted: 16/v2/source/ENGINE/MAKE.BAT modified: 16/v2/source/ENGINE/MAKEFILE modified: 16/v2/source/MAPED/GUI.C modified: 16/v2/source/MAPED/RENDER.H deleted: 16/v2/source/verge/ENGINE/AUDIO.H deleted: 16/v2/source/verge/ENGINE/A_MEMORY.C deleted: 16/v2/source/verge/ENGINE/A_MEMORY.H deleted: 16/v2/source/verge/ENGINE/CONLIB.C deleted: 16/v2/source/verge/ENGINE/CONLIB.H deleted: 16/v2/source/verge/ENGINE/CONSOLE.C deleted: 16/v2/source/verge/ENGINE/CONSOLE.H deleted: 16/v2/source/verge/ENGINE/CONTROLS.C deleted: 16/v2/source/verge/ENGINE/CONTROLS.H deleted: 16/v2/source/verge/ENGINE/ENGINE.C deleted: 16/v2/source/verge/ENGINE/ENGINE.H deleted: 16/v2/source/verge/ENGINE/ENTITY.C deleted: 16/v2/source/verge/ENGINE/ENTITY.H deleted: 16/v2/source/verge/ENGINE/FLI.C deleted: 16/v2/source/verge/ENGINE/FLI.H deleted: 16/v2/source/verge/ENGINE/FONT.C deleted: 16/v2/source/verge/ENGINE/FONT.H deleted: 16/v2/source/verge/ENGINE/IMAGE.C deleted: 16/v2/source/verge/ENGINE/IMAGE.H deleted: 16/v2/source/verge/ENGINE/INTER.H deleted: 16/v2/source/verge/ENGINE/KEYBOARD.H deleted: 16/v2/source/verge/ENGINE/KEYBOARD.S deleted: 16/v2/source/verge/ENGINE/MAIN.H deleted: 16/v2/source/verge/ENGINE/MAKEFILE deleted: 16/v2/source/verge/ENGINE/MESSAGE.C deleted: 16/v2/source/verge/ENGINE/MESSAGE.H deleted: 16/v2/source/verge/ENGINE/MIKMOD.A deleted: 16/v2/source/verge/ENGINE/MIKMOD.C deleted: 16/v2/source/verge/ENGINE/MIKMOD.H deleted: 16/v2/source/verge/ENGINE/MODE13H.C deleted: 16/v2/source/verge/ENGINE/MODEINIT.C deleted: 16/v2/source/verge/ENGINE/MODEX.C deleted: 16/v2/source/verge/ENGINE/MTYPES.H deleted: 16/v2/source/verge/ENGINE/PCX.H deleted: 16/v2/source/verge/ENGINE/RENDER.C deleted: 16/v2/source/verge/ENGINE/RENDER.H deleted: 16/v2/source/verge/ENGINE/SINCOS.H deleted: 16/v2/source/verge/ENGINE/SOUND.C deleted: 16/v2/source/verge/ENGINE/SOUND.H deleted: 16/v2/source/verge/ENGINE/STARTUP.C deleted: 16/v2/source/verge/ENGINE/TIMER.C deleted: 16/v2/source/verge/ENGINE/TIMER.H deleted: 16/v2/source/verge/ENGINE/VC.C deleted: 16/v2/source/verge/ENGINE/VC.H deleted: 16/v2/source/verge/ENGINE/VCCODE.H deleted: 16/v2/source/verge/ENGINE/VDRIVER.C deleted: 16/v2/source/verge/ENGINE/VDRIVER.H deleted: 16/v2/source/verge/ENGINE/VERGE.C deleted: 16/v2/source/verge/ENGINE/VERGE.H deleted: 16/v2/source/verge/ENGINE/VESA.C deleted: 16/v2/source/verge/ENGINE/VFILE.C deleted: 16/v2/source/verge/ENGINE/VFILE.H deleted: 16/v2/source/verge/MAPED/A_MEMORY.C deleted: 16/v2/source/verge/MAPED/COLBAK.H deleted: 16/v2/source/verge/MAPED/COLSTUFF.H deleted: 16/v2/source/verge/MAPED/COLUMNS.C deleted: 16/v2/source/verge/MAPED/COLUMNS.H deleted: 16/v2/source/verge/MAPED/CONFIG.C deleted: 16/v2/source/verge/MAPED/CONFIG.H deleted: 16/v2/source/verge/MAPED/CONTROLS.C deleted: 16/v2/source/verge/MAPED/GUI.C deleted: 16/v2/source/verge/MAPED/GUI.H deleted: 16/v2/source/verge/MAPED/GUICOMP.C deleted: 16/v2/source/verge/MAPED/GUICOMP.H deleted: 16/v2/source/verge/MAPED/INTER.H deleted: 16/v2/source/verge/MAPED/KEYBOARD.C deleted: 16/v2/source/verge/MAPED/KEYBOARD.H deleted: 16/v2/source/verge/MAPED/MAKEFILE deleted: 16/v2/source/verge/MAPED/MAPED.C deleted: 16/v2/source/verge/MAPED/MAPED.H deleted: 16/v2/source/verge/MAPED/MIKMOD.C deleted: 16/v2/source/verge/MAPED/MIKMOD.H deleted: 16/v2/source/verge/MAPED/MIKMOD.LIB deleted: 16/v2/source/verge/MAPED/MINIMAP.C deleted: 16/v2/source/verge/MAPED/MINIMAP.H deleted: 16/v2/source/verge/MAPED/MODE13H.C deleted: 16/v2/source/verge/MAPED/MODE13H.H deleted: 16/v2/source/verge/MAPED/MODEX.C deleted: 16/v2/source/verge/MAPED/MODEX.H deleted: 16/v2/source/verge/MAPED/MOUSE.C deleted: 16/v2/source/verge/MAPED/MOUSE.H deleted: 16/v2/source/verge/MAPED/MTYPES.H deleted: 16/v2/source/verge/MAPED/PCX.C deleted: 16/v2/source/verge/MAPED/RENDER.C deleted: 16/v2/source/verge/MAPED/RENDER.H deleted: 16/v2/source/verge/MAPED/SMALFONT.C deleted: 16/v2/source/verge/MAPED/SMALFONT.H deleted: 16/v2/source/verge/MAPED/SSAVER.C deleted: 16/v2/source/verge/MAPED/SSAVER.H deleted: 16/v2/source/verge/MAPED/SSAVER1.C deleted: 16/v2/source/verge/MAPED/TILEED.C deleted: 16/v2/source/verge/MAPED/TILEED.H deleted: 16/v2/source/verge/MAPED/TILESEL.C deleted: 16/v2/source/verge/MAPED/TILESEL.H deleted: 16/v2/source/verge/MAPED/TIMER.C deleted: 16/v2/source/verge/MAPED/TIMER.H deleted: 16/v2/source/verge/MAPED/VDRIVER.C deleted: 16/v2/source/verge/MAPED/VDRIVER.H deleted: 16/v2/source/verge/MAPED/VERGEPAL.H deleted: 16/v2/source/verge/README.TXT deleted: 16/v2/source/verge/UTIL/CHRCONV/CHRCONV.C deleted: 16/v2/source/verge/UTIL/CHRCONV/CHRCONV.TXT deleted: 16/v2/source/verge/UTIL/CHRCONV/DARIN.CHR deleted: 16/v2/source/verge/UTIL/CHRCONV/MAKEDJ.BAT deleted: 16/v2/source/verge/UTIL/CHRMAK/CHRMAK.CC deleted: 16/v2/source/verge/UTIL/CHRMAK/CHRMAK.TXT deleted: 16/v2/source/verge/UTIL/CHRMAK/MAKEDJ.BAT deleted: 16/v2/source/verge/UTIL/CHRMAK/MAKEWAT.BAT deleted: 16/v2/source/verge/UTIL/CHRMAK/VECNA.MAK deleted: 16/v2/source/verge/UTIL/CHRMAK/VECNA.PCX deleted: 16/v2/source/verge/UTIL/CHRMAK/VER deleted: 16/v2/source/verge/UTIL/PACK/MAKEDJ.BAT deleted: 16/v2/source/verge/UTIL/PACK/PACK.C deleted: 16/v2/source/verge/UTIL/PACK/PACK.TXT deleted: 16/v2/source/verge/UTIL/PACK/TEST deleted: 16/v2/source/verge/UTIL/PACK/TODO deleted: 16/v2/source/verge/UTIL/PCX2FNT/FONT0.PCX deleted: 16/v2/source/verge/UTIL/PCX2FNT/FONT02B.PCX deleted: 16/v2/source/verge/UTIL/PCX2FNT/MAKEDJ.BAT deleted: 16/v2/source/verge/UTIL/PCX2FNT/PCX2FNT.C deleted: 16/v2/source/verge/UTIL/PCX2FNT/PCX2FNT.TXT deleted: 16/v2/source/verge/UTIL/TRANS/MAKEDJ.BAT deleted: 16/v2/source/verge/UTIL/TRANS/SULLY.PDF deleted: 16/v2/source/verge/UTIL/TRANS/TRANS.C deleted: 16/v2/source/verge/UTIL/TRANS/TRANS.TXT deleted: 16/v2/source/verge/UTIL/TRANS/TYRIAN.PDF deleted: 16/v2/source/verge/UTIL/TRANS/TYRPAL.PCX deleted: 16/v2/source/verge/UTIL/TRANS/VERGE.PDF deleted: 16/v2/source/verge/UTIL/UNPACK/MAKEDJ.BAT deleted: 16/v2/source/verge/UTIL/UNPACK/TEST deleted: 16/v2/source/verge/UTIL/UNPACK/TODO deleted: 16/v2/source/verge/UTIL/UNPACK/UNPACK.C deleted: 16/v2/source/verge/UTIL/UNPACK/UNPACK.TXT deleted: 16/v2/source/verge/VCC/CLEAN.BAT deleted: 16/v2/source/verge/VCC/CODE.H deleted: 16/v2/source/verge/VCC/COMPILE.C deleted: 16/v2/source/verge/VCC/COMPILE.H deleted: 16/v2/source/verge/VCC/FUNCLIB.C deleted: 16/v2/source/verge/VCC/FUNCLIB.H deleted: 16/v2/source/verge/VCC/LEXICAL.C deleted: 16/v2/source/verge/VCC/LEXICAL.H deleted: 16/v2/source/verge/VCC/MAKEDJ.BAT deleted: 16/v2/source/verge/VCC/PREPROC.C deleted: 16/v2/source/verge/VCC/PREPROC.H deleted: 16/v2/source/verge/VCC/VCC.C deleted: 16/v2/source/verge/VCC/VCC.H deleted: 16/v2/source/verge/VCC/VCCODE.H deleted: 16/v2/source/verge/gnu.txt --- diff --git a/16/v2/source/archives/V2GPL.ZIP b/16/v2/archives/V2GPL.ZIP similarity index 100% rename from 16/v2/source/archives/V2GPL.ZIP rename to 16/v2/archives/V2GPL.ZIP diff --git a/16/v2/source/ENGINE/MAKE.BAT b/16/v2/source/ENGINE/MAKE.BAT deleted file mode 100755 index 291b92ef..00000000 --- a/16/v2/source/ENGINE/MAKE.BAT +++ /dev/null @@ -1,23 +0,0 @@ -wcc386 a_memory.c -wcc386 conlib.c -wcc386 console.c -wcc386 controls.c -wcc386 engine.c -wcc386 entity.c -wcc386 fli.c -wcc386 font.c -wcc386 image.c -wcc386 message.c -wcc386 mikmod.c -wcc386 mode13h.c -wcc386 modeinit.c -wcc386 modex.c -wcc386 render.c -wcc386 sound.c -wcc386 startup.c -wcc386 timer.c -wcc386 vc.c -wcc386 vdriver.c -wcc386 verge.c -wcc386 vesa.c -wcc386 vfile.c diff --git a/16/v2/source/ENGINE/MAKEFILE b/16/v2/source/ENGINE/MAKEFILE index db5016da..f557fa31 100755 --- a/16/v2/source/ENGINE/MAKEFILE +++ b/16/v2/source/ENGINE/MAKEFILE @@ -1,7 +1,7 @@ -CC = wcc386 +CC = gcc CFLAGS = -s -Wall -Werror -OBJ = a_memory.obj conlib.obj console.obj controls.obj engine.obj entity.obj font.obj image.obj keyboard.obj message.obj modeinit.obj render.obj startup.obj timer.obj verge.obj vc.obj vdriver.obj vfile.obj fli.obj sound.obj mikmod.a +OBJ = a_memory.o conlib.o console.o controls.o engine.o entity.o font.o image.o keyboard.o message.o modeinit.o render.o startup.o timer.o verge.o vc.o vdriver.o vfile.o fli.o sound.o mikmod.a verge: $(OBJ) diff --git a/16/v2/source/MAPED/GUI.C b/16/v2/source/MAPED/GUI.C index d4869d42..49bdc469 100755 --- a/16/v2/source/MAPED/GUI.C +++ b/16/v2/source/MAPED/GUI.C @@ -260,7 +260,7 @@ void MainMenu(int dx, int dy) if (my>dy+47 && mydy+53 && mydy+59 && mydy+65 && mydy+65 && mydy+71 && mydy+80 && my>8)) -#define LOWORD(l) ((WORD)(l)) -#define HIWORD(l) ((WORD)((DWORD)(l)>>16)) -#define MAKEWORD(l,h) ((WORD)(((BYTE)(l))|(((WORD)((BYTE)(h)))<<8))) -#define MAKELONG(l,h) ((DWORD)(((WORD)(l))|(((DWORD)((WORD)(h)))<<16))) - -#endif - - -/* audio system version number */ -#define AUDIO_SYSTEM_VERSION 0x0101 - -/* audio capabilities bit fields definitions */ -#define AUDIO_FORMAT_1M08 0x00000001 -#define AUDIO_FORMAT_1S08 0x00000002 -#define AUDIO_FORMAT_1M16 0x00000004 -#define AUDIO_FORMAT_1S16 0x00000008 -#define AUDIO_FORMAT_2M08 0x00000010 -#define AUDIO_FORMAT_2S08 0x00000020 -#define AUDIO_FORMAT_2M16 0x00000040 -#define AUDIO_FORMAT_2S16 0x00000080 -#define AUDIO_FORMAT_4M08 0x00000100 -#define AUDIO_FORMAT_4S08 0x00000200 -#define AUDIO_FORMAT_4M16 0x00000400 -#define AUDIO_FORMAT_4S16 0x00000800 - -/* audio format bit fields defines for devices and waveforms */ -#define AUDIO_FORMAT_8BITS 0x0000 -#define AUDIO_FORMAT_16BITS 0x0001 -#define AUDIO_FORMAT_LOOP 0x0010 -#define AUDIO_FORMAT_BIDILOOP 0x0020 -#define AUDIO_FORMAT_REVERSE 0x0080 -#define AUDIO_FORMAT_MONO 0x0000 -#define AUDIO_FORMAT_STEREO 0x0100 -#define AUDIO_FORMAT_FILTER 0x8000 - -/* audio resource limits defines */ -#define AUDIO_MAX_VOICES 32 -#define AUDIO_MAX_SAMPLES 16 -#define AUDIO_MAX_PATCHES 128 -#define AUDIO_MAX_PATTERNS 256 -#define AUDIO_MAX_ORDERS 256 -#define AUDIO_MAX_NOTES 96 -#define AUDIO_MAX_POINTS 12 -#define AUDIO_MIN_PERIOD 1 -#define AUDIO_MAX_PERIOD 31999 -#define AUDIO_MIN_VOLUME 0x00 -#define AUDIO_MAX_VOLUME 0x40 -#define AUDIO_MIN_PANNING 0x00 -#define AUDIO_MAX_PANNING 0xFF -#define AUDIO_MIN_POSITION 0x00000000L -#define AUDIO_MAX_POSITION 0x00100000L -#define AUDIO_MIN_FREQUENCY 0x00000200L -#define AUDIO_MAX_FREQUENCY 0x00080000L - -/* audio error code defines */ -#define AUDIO_ERROR_NONE 0x0000 -#define AUDIO_ERROR_INVALHANDLE 0x0001 -#define AUDIO_ERROR_INVALPARAM 0x0002 -#define AUDIO_ERROR_NOTSUPPORTED 0x0003 -#define AUDIO_ERROR_BADDEVICEID 0x0004 -#define AUDIO_ERROR_NODEVICE 0x0005 -#define AUDIO_ERROR_DEVICEBUSY 0x0006 -#define AUDIO_ERROR_BADFORMAT 0x0007 -#define AUDIO_ERROR_NOMEMORY 0x0008 -#define AUDIO_ERROR_NODRAMMEMORY 0x0009 -#define AUDIO_ERROR_FILENOTFOUND 0x000A -#define AUDIO_ERROR_BADFILEFORMAT 0x000B -#define AUDIO_LAST_ERROR 0x000B - -/* audio device identifiers */ -#define AUDIO_DEVICE_NONE 0x0000 -#define AUDIO_DEVICE_MAPPER 0xFFFF - -/* audio product identifiers */ -#define AUDIO_PRODUCT_NONE 0x0000 -#define AUDIO_PRODUCT_SB 0x0001 -#define AUDIO_PRODUCT_SB15 0x0002 -#define AUDIO_PRODUCT_SB20 0x0003 -#define AUDIO_PRODUCT_SBPRO 0x0004 -#define AUDIO_PRODUCT_SB16 0x0005 -#define AUDIO_PRODUCT_AWE32 0x0006 -#define AUDIO_PRODUCT_WSS 0x0007 -#define AUDIO_PRODUCT_ESS 0x0008 -#define AUDIO_PRODUCT_GUS 0x0009 -#define AUDIO_PRODUCT_GUSDB 0x000A -#define AUDIO_PRODUCT_GUSMAX 0x000B -#define AUDIO_PRODUCT_IWAVE 0x000C -#define AUDIO_PRODUCT_PAS 0x000D -#define AUDIO_PRODUCT_PAS16 0x000E -#define AUDIO_PRODUCT_ARIA 0x000F -#define AUDIO_PRODUCT_WINDOWS 0x0100 -#define AUDIO_PRODUCT_LINUX 0x0101 -#define AUDIO_PRODUCT_SPARC 0x0102 -#define AUDIO_PRODUCT_SGI 0x0103 -#define AUDIO_PRODUCT_DSOUND 0x0104 - -/* audio envelope bit fields */ -#define AUDIO_ENVELOPE_ON 0x0001 -#define AUDIO_ENVELOPE_SUSTAIN 0x0002 -#define AUDIO_ENVELOPE_LOOP 0x0004 - -/* audio pattern bit fields */ -#define AUDIO_PATTERN_PACKED 0x0080 -#define AUDIO_PATTERN_NOTE 0x0001 -#define AUDIO_PATTERN_SAMPLE 0x0002 -#define AUDIO_PATTERN_VOLUME 0x0004 -#define AUDIO_PATTERN_COMMAND 0x0008 -#define AUDIO_PATTERN_PARAMS 0x0010 - -/* audio module bit fields */ -#define AUDIO_MODULE_AMIGA 0x0000 -#define AUDIO_MODULE_LINEAR 0x0001 -#define AUDIO_MODULE_PANNING 0x8000 - -#pragma pack(1) - -/* audio capabilities structure */ -typedef struct { - WORD wProductId; /* product identifier */ - CHAR szProductName[30]; /* product name */ - DWORD dwFormats; /* formats supported */ -} AUDIOCAPS, *LPAUDIOCAPS; - -/* audio format structure */ -typedef struct { - UINT nDeviceId; /* device identifier */ - WORD wFormat; /* playback format */ - WORD nSampleRate; /* sampling frequency */ -} AUDIOINFO, *LPAUDIOINFO; - -/* audio waveform structure */ -typedef struct { - LPBYTE lpData; /* data pointer */ - DWORD dwHandle; /* waveform handle */ - DWORD dwLength; /* waveform length */ - DWORD dwLoopStart; /* loop start point */ - DWORD dwLoopEnd; /* loop end point */ - WORD nSampleRate; /* sampling rate */ - WORD wFormat; /* format bits */ -} AUDIOWAVE, *LPAUDIOWAVE; - - -/* audio envelope point structure */ -typedef struct { - WORD nFrame; /* envelope frame */ - WORD nValue; /* envelope value */ -} AUDIOPOINT, *LPAUDIOPOINT; - -/* audio envelope structure */ -typedef struct { - AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS]; /* envelope points */ - BYTE nPoints; /* number of points */ - BYTE nSustain; /* sustain point */ - BYTE nLoopStart; /* loop start point */ - BYTE nLoopEnd; /* loop end point */ - WORD wFlags; /* envelope flags */ - WORD nSpeed; /* envelope speed */ -} AUDIOENVELOPE, *LPAUDIOENVELOPE; - -/* audio sample structure */ -typedef struct { - CHAR szSampleName[32]; /* sample name */ - BYTE nVolume; /* default volume */ - BYTE nPanning; /* default panning */ - BYTE nRelativeNote; /* relative note */ - BYTE nFinetune; /* finetune */ - AUDIOWAVE Wave; /* waveform handle */ -} AUDIOSAMPLE, *LPAUDIOSAMPLE; - -/* audio patch structure */ -typedef struct { - CHAR szPatchName[32]; /* patch name */ - BYTE aSampleNumber[AUDIO_MAX_NOTES]; /* multi-sample table */ - WORD nSamples; /* number of samples */ - BYTE nVibratoType; /* vibrato type */ - BYTE nVibratoSweep; /* vibrato sweep */ - BYTE nVibratoDepth; /* vibrato depth */ - BYTE nVibratoRate; /* vibrato rate */ - WORD nVolumeFadeout; /* volume fadeout */ - AUDIOENVELOPE Volume; /* volume envelope */ - AUDIOENVELOPE Panning; /* panning envelope */ - LPAUDIOSAMPLE aSampleTable; /* sample table */ -} AUDIOPATCH, *LPAUDIOPATCH; - -/* audio pattern structure */ -typedef struct { - WORD nPacking; /* packing type */ - WORD nTracks; /* number of tracks */ - WORD nRows; /* number of rows */ - WORD nSize; /* data size */ - LPBYTE lpData; /* data pointer */ -} AUDIOPATTERN, *LPAUDIOPATTERN; - -/* audio module structure */ -typedef struct { - CHAR szModuleName[32]; /* module name */ - WORD wFlags; /* module flags */ - WORD nOrders; /* number of orders */ - WORD nRestart; /* restart position */ - WORD nTracks; /* number of tracks */ - WORD nPatterns; /* number of patterns */ - WORD nPatches; /* number of patches */ - WORD nTempo; /* initial tempo */ - WORD nBPM; /* initial BPM */ - BYTE aOrderTable[AUDIO_MAX_ORDERS]; /* order table */ - BYTE aPanningTable[AUDIO_MAX_VOICES]; /* panning table */ - LPAUDIOPATTERN aPatternTable; /* pattern table */ - LPAUDIOPATCH aPatchTable; /* patch table */ -} AUDIOMODULE, *LPAUDIOMODULE; - -/* audio callback function defines */ -typedef VOID (AIAPI* LPFNAUDIOWAVE)(LPBYTE, UINT); -typedef VOID (AIAPI* LPFNAUDIOTIMER)(VOID); -typedef VOID (AIAPI* LPFNAUDIOCALLBACK)(BYTE, UINT, UINT); - -/* audio handle defines */ -typedef HANDLE HAC; -typedef HAC* LPHAC; - -#pragma pack() - - -/* audio interface API prototypes */ -UINT AIAPI AInitialize(VOID); -UINT AIAPI AGetVersion(VOID); -UINT AIAPI AGetAudioNumDevs(VOID); -UINT AIAPI AGetAudioDevCaps(UINT nDeviceId, LPAUDIOCAPS lpCaps); -UINT AIAPI AGetErrorText(UINT nErrorCode, LPSTR lpText, UINT nSize); - -UINT AIAPI APingAudio(LPUINT lpnDeviceId); -UINT AIAPI AOpenAudio(LPAUDIOINFO lpInfo); -UINT AIAPI ACloseAudio(VOID); -UINT AIAPI AUpdateAudio(VOID); - -UINT AIAPI AOpenVoices(UINT nVoices); -UINT AIAPI ACloseVoices(VOID); - -UINT AIAPI ASetAudioCallback(LPFNAUDIOWAVE lpfnAudioWave); -UINT AIAPI ASetAudioTimerProc(LPFNAUDIOTIMER lpfnAudioTimer); -UINT AIAPI ASetAudioTimerRate(UINT nTimerRate); - -LONG AIAPI AGetAudioDataAvail(VOID); -UINT AIAPI ACreateAudioData(LPAUDIOWAVE lpWave); -UINT AIAPI ADestroyAudioData(LPAUDIOWAVE lpWave); -UINT AIAPI AWriteAudioData(LPAUDIOWAVE lpWave, DWORD dwOffset, UINT nCount); - -UINT AIAPI ACreateAudioVoice(LPHAC lphVoice); -UINT AIAPI ADestroyAudioVoice(HAC hVoice); - -UINT AIAPI APlayVoice(HAC hVoice, LPAUDIOWAVE lpWave); -UINT AIAPI APrimeVoice(HAC hVoice, LPAUDIOWAVE lpWave); -UINT AIAPI AStartVoice(HAC hVoice); -UINT AIAPI AStopVoice(HAC hVoice); - -UINT AIAPI ASetVoicePosition(HAC hVoice, LONG dwPosition); -UINT AIAPI ASetVoiceFrequency(HAC hVoice, LONG dwFrequency); -UINT AIAPI ASetVoiceVolume(HAC hVoice, UINT nVolume); -UINT AIAPI ASetVoicePanning(HAC hVoice, UINT nPanning); - -UINT AIAPI AGetVoicePosition(HAC hVoice, LPLONG lpdwPosition); -UINT AIAPI AGetVoiceFrequency(HAC hVoice, LPLONG lpdwFrequency); -UINT AIAPI AGetVoiceVolume(HAC hVoice, LPUINT lpnVolume); -UINT AIAPI AGetVoicePanning(HAC hVoice, LPUINT lpnPanning); -UINT AIAPI AGetVoiceStatus(HAC hVoice, LPBOOL lpnStatus); - -UINT AIAPI APlayModule(LPAUDIOMODULE lpModule); -UINT AIAPI AStopModule(VOID); -UINT AIAPI APauseModule(VOID); -UINT AIAPI AResumeModule(VOID); -UINT AIAPI ASetModuleVolume(UINT nVolume); -UINT AIAPI ASetModulePosition(UINT nOrder, UINT nRow); -UINT AIAPI AGetModuleVolume(LPUINT lpnVolume); -UINT AIAPI AGetModulePosition(LPUINT pnOrder, LPUINT lpnRow); -UINT AIAPI AGetModuleStatus(LPBOOL lpnStatus); -UINT AIAPI ASetModuleCallback(LPFNAUDIOCALLBACK lpfnAudioCallback); - -UINT AIAPI ALoadModuleFile(LPSTR lpszFileName, - LPAUDIOMODULE* lplpModule, DWORD dwFileOffset); -UINT AIAPI AFreeModuleFile(LPAUDIOMODULE lpModule); - -UINT AIAPI ALoadWaveFile(LPSTR lpszFileName, - LPAUDIOWAVE* lplpWave, DWORD dwFileOffset); -UINT AIAPI AFreeWaveFile(LPAUDIOWAVE lpWave); - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/16/v2/source/verge/ENGINE/A_MEMORY.C b/16/v2/source/verge/ENGINE/A_MEMORY.C deleted file mode 100755 index 9ce7f4c8..00000000 --- a/16/v2/source/verge/ENGINE/A_MEMORY.C +++ /dev/null @@ -1,201 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include - -#include "verge.h" - -// ***** -// TODO: Move the chunk list from an array to a linked list? -// Would eliminate hardcoded chunk limit, but would make -// general operation slower. Probably not The Right Thing, -// sides the chunk limit can be interesting sometimes. If -// it becomes problematic, consider a Binary Tree. -// ***** - -// ***************************** Data ***************************** - -#define MAXCHUNKS 1000 -#define PARANOID -#define PADFILLVALUE 254 -#define PADSIZE 256 - -typedef struct -{ - void *pointer; - int size; - int owner; - char desc[40]; -} memblockType; - -memblockType chunks[MAXCHUNKS+1]; -int numchunks=0; - -// ***************************** Code ***************************** - -void *valloc(int amount, char *desc, int owner) -{ - if (numchunks == MAXCHUNKS) - err("Failed allocated %d bytes (%s), reason: Out of chunks.", - amount, desc); - -#ifdef PARANOID - CheckCorruption(); - chunks[numchunks].pointer = (void *) ((int) malloc(amount + (PADSIZE * 2)) + PADSIZE); - chunks[numchunks].size = amount; - memset((char *) chunks[numchunks].pointer - PADSIZE, PADFILLVALUE, PADSIZE); - memset((char *) chunks[numchunks].pointer + - chunks[numchunks].size, PADFILLVALUE, PADSIZE); -#else - chunks[numchunks].pointer = malloc(amount); - chunks[numchunks].size = amount; -#endif - chunks[numchunks].owner = owner; - strncpy(chunks[numchunks].desc, desc, 39); - return chunks[numchunks++].pointer; -} - -void *qvalloc(int amount) -{ - void *ptr; - - // Quick and dirty memory allocation. Should be used ONLY - // for temporary blocks in speed-critical loops. - - ptr = malloc(amount); - if (!ptr) err("qvalloc: Failed allocating %d bytes.", amount); - return ptr; -} - -void qvfree(void *ptr) -{ - free(ptr); -} - -int TotalBytesAllocated(void) -{ - int i, tally=0; - - for (i=0; is) - { - sprintf(strbuf,"File is in €%s~, index %d~",pack[f->v].mountname, f->i); - Con_Printf(strbuf); - sprintf(strbuf,"Packofs: %d~ current ofs: %d~",pack[f->v].files[f->i].packofs,pack[f->v].files[f->i].curofs); - Con_Printf(strbuf); - if (pack[f->v].files[f->i].extractable) - Con_Printf("File is extractable."); - else Con_Printf("File is not extractable."); - if (pack[f->v].files[f->i].override) - Con_Printf("Override allowed."); - else Con_Printf("Override not allowed."); - } - else Con_Printf("File is external."); - sprintf(strbuf,"File is %d~ bytes.",filesize(f)); - Con_Printf(strbuf); - vclose(f); -} - -void vid_mode() -{ int xres,yres; - - xres=atoi((char *)args[1]); - yres=atoi((char *)args[2]); - Con_NextLine(); - - ShutdownVideo(0); - if (InitVideo(xres, yres)) - { - Con_Printf("{||||||||||||}"); - Con_Printf("Loading new video driver..."); - Con_Printf(DriverDesc); - Con_Printf("{||||||||||||}"); - } - else Con_Printf("Unsupported/unknown video mode."); - set_intensity(63); -} - -void CPU_Usage() -{ - if (numargs==1) - { - sprintf(strbuf,"cpu_usage is %d~", cpu_watch); - Con_Printf(strbuf); - } - else cpu_watch=atoi((char *) args[1]); -} - -void Mount() -{ - MountVFile((char *) args[1]); - sprintf(strbuf,"%s mounted.",args[1]); - Con_Printf(strbuf); -} - -void ZeroConWarp(char **args) -{ - player->x=atoi(args[1])*16; - player->y=atoi(args[2])*16; - player->tx=atoi(args[1]); - player->ty=atoi(args[2]); -} - -void ZeroConBrowseTiles(void) -{ - int x,y,n,k=0,a=0; - - while(last_pressed!=SCAN_Q) - { - ClearScreen(); - UpdateControls(); - CheckMessages(); - if(last_pressed==SCAN_A) { if(a) a=0; else a=1; last_pressed=0; } - if(last_pressed==SCAN_DOWN&&(k+(ty-3)*(tx-3)-tx+4)0) - { - k-=tx-4; - last_pressed=0; - } - for(y=1; yx, player->y); Con_Printf(strbuf); - sprintf(strbuf,"xtc: ‚%d~ ytc: ‚%d~", player->x>>4, player->y>>4); Con_Printf(strbuf); -} - -void PlayerSpeed() -{ - if (!player) - { - Con_Printf("No player."); - return; - } - if (numargs==1) - { - Con_NextLine(); - sprintf(strbuf,"speed is is %d~", player->speed); - Con_Printf(strbuf); - } - else - { - player->speed=atoi((char *) args[1]); - player->speedct=0; - } -} - -void Player() -{ int i; - - i=atoi((char *) args[1]); - if (i', '?', 0, '*', 0, 1, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, - 0, 0, 1, 127, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 13, 0, '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', 0, 0, 0, 0, 0 -}; - -#define NUMCMDS 31 -char *concmds[] = { - "CONSOLEBG","LISTMOUNTS","PACKINFO","LISTCMDS","CD_PLAY","CD_STOP", - "CD_OPEN","CD_CLOSE","EXIT","VID_MODE","CPU_USAGE","MOUNT","MAP", - "VER","BROWSETILES","WARP","CAMERATRACKING","RSTRING","SHOWOBS", - "PHANTOM","ENTITYSTAT","ACTIVEENTS","ENTITY","CURPOS","PLAYERSPEED", - "SPEEDDEMON","RV","SV","PLAYER","SPAWNENTITY","SHOWZONES" - }; -byte sortedcmds[NUMCMDS]; - -// ================================= Code ==================================== - -void SortConCmds(void) -/* -- ric: 03/Jun/98 -- - * creates the sorted index into concmds - */ -{ - int i,j; - int temp; - - for (i=0; i=i; j--) - if (strcmp(concmds[sortedcmds[j-1]],concmds[sortedcmds[j]])>0) - { - // swap the indices - temp=sortedcmds[j-1]; - sortedcmds[j-1]=sortedcmds[j]; - sortedcmds[j]=temp; - } - } -} - -void InitConsole(void) -{ - Logp("Initialize console."); - LoadFont("system.fnt"); - consolebg=VLoadImageBuf("console.gif"); - - consoletext=(char *) valloc(45*50, "consoletext", OID_MISC); - cmd=(byte *) valloc(40, "InitConsole:cmd", OID_MISC); - cmd2=(byte *) valloc(40, "InitConsole:cmd2", OID_MISC); - memset(cmd, 0, 40); - memset(cmd2, 0, 40); - memset(consoletext, 0, 2250); - - lastcmds=(char *) valloc(400, "InitConsole:lastcmds", OID_MISC); - memset(lastcmds, 0, 400); - - SortConCmds(); - LogDone(); -} - -void DrawConsole(); - -void Con_Printf(char *str) -{ char tbuf[2250]; - - // move buffer up a line - memcpy(tbuf, consoletext+50, 2200); - memcpy(consoletext, tbuf, 2200); - - memcpy(consoletext+2200, str, strlen(str)+1); - lines++; -} - -void Con_NextLine(void) -{ - Con_Printf(""); - lines=0; -} - -int ShowConsole(void) -{ - conlines+=2; - if (conlines > 120) - { - callback=0; - conlines=120; - } - return 0; -} - -int HideConsole(void) -{ - if (conlines > 3) - { - conlines-=2; - } - else - { - conlines=1; - callback=0; - } - return 0; -} - -void DrawConsole(void) -{ int i; - int tagline=0; - - lines=0; - tagline=conlines; - - Render(); - CopySpriteZoomClip(0,-120+tagline, 320,120, sx,120, consolebg); - - // write console text - - for (i=0; i<9; i++) - { - GotoXY(1, 1+(i*10)-(120-tagline)); - printstring(0,consoletext+((startln+i)*50)); - } - - GotoXY(1,101-(120-tagline)); - printstring(0,"]"); - printstring(0,(char *) cmd); - - if (systemtime>=cswtime) - { - cursor ^= 1; - cswtime = systemtime+40; - } - - if (cursor) printstring(0, "&"); - - if (startln<36) - { - GotoXY(1, 91-(120-tagline)); - printstring(0, "^ ^ ^ ^ ^ ^ ^ ^ ^ ^"); - } -} - -int Args(int num) -{ - if (numargs>=num) return 1; - sprintf(strbuf,"This function needs %d~ arguments.",num-1); - Con_Printf(strbuf); - return 0; -} - -void ListCmds(void) -{ int i; - - Con_NextLine(); - for (i=0; i ~"); } break; - case 16: CameraTracking(); break; - case 17: if (numargs==1) ZeroGetRString(); - if (numargs==2) ZeroSetRString((char**)args); break; - case 18: Obstructions(); break; - case 19: Phantom(); break; - case 20: EntityStat(); break; - case 21: ListActiveEnts(); break; - case 22: if (Args(2)) EntityS(); break; - case 23: CurPos(); break; - case 24: PlayerSpeed(); break; - case 25: speeddemon=1; break; - case 26: ReadVCVar(); break; - case 27: WriteVCVar(); break; - case 28: if (Args(2)) Player(); break; - case 29: if (Args(4)) SpawnEntity(); break; - case 30: ShowZones(); break; - case NUMCMDS: Con_Printf((char *) cmd); break; - } -} - -void ParseCommand(void) -{ byte *src; - // breaks the command string into arguements and stuff. (in cmd2) - - numargs=0; - src=(byte *) cmd2; - args[0]=src; - - while (*src==' ') src++; - - if (!*src) return; - - while (1) - { - if (*src==' ') - { - while (*src== ' ') - { - *src=0; - src++; - } - if (*src) - { - numargs++; - args[numargs]=src; - } - src--; - } - src++; - if (!*src) - { - numargs++; - return; - } - } -} - -void ProcessCommand(void) -{ byte i; - - memcpy(cmd2, cmd, 40); - strupr((char *) cmd2); - ParseCommand(); - - i=0; - while (i 1) - { - CheckMessages(); - DrawConsole(); - ShowPage(); - } - conlines=0; - key[SCAN_RQUOTA]=0; - timer_count=0; -} diff --git a/16/v2/source/verge/ENGINE/CONSOLE.H b/16/v2/source/verge/ENGINE/CONSOLE.H deleted file mode 100755 index e4e60907..00000000 --- a/16/v2/source/verge/ENGINE/CONSOLE.H +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef CONSOLE_H -#define CONSOLE_H - -#include "main.h" - -// -- externs -- - -extern byte *consolebg; // Console background image -extern byte *consoletext; // Console text buffer -extern byte *cmd, *cmd2, cmdlen; // command line buffer -extern char *lastcmds, numcmds, cmdpos; // last-command memory -extern byte *args[10], numargs; // command argument pointers -extern char cursor, more; // flag on/off cursor visible -extern int cswtime; // cursor switch time. -extern int conlines; // Number of visible lines -extern int lines; // number of lines entered since last draw -extern char startln; // Start display ofs (for scrollback) -extern char allowconsole; -extern char consoleoverride; - -extern byte key_ascii_tbl[128]; -extern byte key_shift_tbl[128]; - -extern char *concmds[]; - -// -- prototypes -- - -extern void InitConsole(void); -extern void Con_Printf(char *str); -extern void Con_NextLine(void); - -extern int ShowConsole(void); -extern int HideConsole(void); - -extern void DrawConsole(void); -extern int Args(int num); -extern void ListCmds(void); -extern void LastCmds(void); -extern void ExecuteCommand(int i); -extern void ParseCommand(void); -extern void ProcessCommand(void); -extern void CommandInput(void); -extern void ActivateConsole(void); - -#endif // CONSOLE_H diff --git a/16/v2/source/verge/ENGINE/CONTROLS.C b/16/v2/source/verge/ENGINE/CONTROLS.C deleted file mode 100755 index 728274a8..00000000 --- a/16/v2/source/verge/ENGINE/CONTROLS.C +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "verge.h" - -// ================================= Data ==================================== - -// -- Hardware Dependent -- // - -int kb1, kb2, kb3, kb4; // keyboard controls -int jb1, jb2, jb3, jb4; // joystick controls - -// -- Unified Interface -- // - -char b1, b2, b3, b4; -char up, down, left, right; - -// -- UnPress support variables -- // - -char wb1, wb2, wb3, wb4; -char wup, wdown, wleft, wright; - -char rb1, rb2, rb3, rb4; -char rup, rdown, rleft, rright; - -// ================================= Code ==================================== - -void UpdateControls() -{ - rb1=0; rb2=0; rb3=0; rb4=0; - rup=0; rdown=0; rleft=0; rright=0; - - if (key[SCAN_UP]) rup=1; - if (key[SCAN_DOWN]) rdown=1; - if (key[SCAN_RIGHT]) rright=1; - if (key[SCAN_LEFT]) rleft=1; - - if (key[kb1]) rb1=1; - if (key[kb2]) rb2=1; - if (key[kb3]) rb3=1; - if (key[kb4]) rb4=1; - - if (wb1 && rb1) rb1=0; - else if (wb1 && !rb1) wb1=0; - b1=rb1; - - if (wb2 && rb2) rb2=0; - else if (wb2 && !rb2) wb2=0; - b2=rb2; - - if (wb3 && rb3) rb3=0; - else if (wb3 && !rb3) wb3=0; - b3=rb3; - - if (wb4 && rb4) rb4=0; - else if (wb4 && !rb4) wb4=0; - b4=rb4; - - if (wup && rup) rup=0; - else if (wup && !rup) wup=0; - up=rup; - - if (wdown && rdown) rdown=0; - else if (wdown && !rdown) wdown=0; - down=rdown; - - if (wleft && rleft) rleft=0; - else if (wleft && !rleft) wleft=0; - left=rleft; - - if (wright && rright) rright=0; - else if (wright && !rright) wright=0; - right=rright; -} - -void UnPress(int control) -{ - switch (control) - { - case 0: wb1=1; wb2=1; wb3=1; wb4=1; - b1=0; b2=0; b3=0; b4=0; - key[kb1]=0; key[kb2]=0; key[kb3]=0; key[kb4]=0; break; - case 1: wb1=1; b1=0; key[kb1]=0; break; - case 2: wb2=1; b2=0; key[kb2]=0; break; - case 3: wb3=1; b3=0; key[kb3]=0; break; - case 4: wb4=1; b4=0; key[kb4]=0; break; - case 5: wup=1; up=0; key[SCAN_UP]=0; break; - case 6: wdown=1; down=0; key[SCAN_DOWN]=0; break; - case 7: wleft=1; left=0; key[SCAN_LEFT]=0; break; - case 8: wright=1; right=0; key[SCAN_RIGHT]=0; break; - } -} diff --git a/16/v2/source/verge/ENGINE/CONTROLS.H b/16/v2/source/verge/ENGINE/CONTROLS.H deleted file mode 100755 index aabd402d..00000000 --- a/16/v2/source/verge/ENGINE/CONTROLS.H +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef CONTROL_H -#define CONTROL_H - -extern int kb1, kb2, kb3, kb4; -extern int jb1, jb2, jb3, jb4; - -extern char b1, b2, b3, b4; -extern char up, down, left, right; - -void UpdateControls(); -void UnPress(int); - -#endif diff --git a/16/v2/source/verge/ENGINE/ENGINE.C b/16/v2/source/verge/ENGINE/ENGINE.C deleted file mode 100755 index 13ca67cd..00000000 --- a/16/v2/source/verge/ENGINE/ENGINE.C +++ /dev/null @@ -1,746 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -// CHANGELOG: -// -// + added ScreenShot() on F11 -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - -#define ENGINE_H -#include "verge.h" - -// ================================= Data ==================================== - -typedef struct -{ - word start; // strand start - word finish; // strand end - word delay; // tile-switch delay - word mode; // tile-animation mode -} vspanim_r; - -typedef struct -{ - char pmultx,pdivx; // parallax multiplier/divisor for X - char pmulty,pdivy; // parallax multiplier/divisor for Y - unsigned short sizex, sizey; // layer dimensions. - unsigned char trans, hline; // transparency flag | hline (raster fx) -} layer_r; - -typedef struct -{ - char name[40]; // zone name/desc - unsigned short script; // script to call thingy - unsigned short percent; // chance of executing - unsigned short delay; // step-delay - unsigned short aaa; // Accept Adjacent Activation - unsigned short entityscript; // script to call for entities -} zoneinfo; - -zoneinfo zones[256]; // zone data records -layer_r layer[6]; // Array of layer data -vspanim_r vspanim[100]; // tile animation data -unsigned short vadelay[100]; // Tile animation delay ctr - -char mapname[60]; // MAP filename -char vspname[60]; // VSP filemap -char musname[60]; // MAP bkgrd music default filename -char rstring[20]; // render-order string -char numlayers; // number of layers in map -byte *obstruct, *zone; // obstruction and zone buffers -char layertoggle[8]; // layer visible toggles -word xstart, ystart; // MAP start x/y location -int bufsize; // how many bytes need to be written -int numzones; // number of active zones - -word *layers[6]; // Raw layer data -int xwin=0, ywin=0; // camera offset - -// -- vsp data -- - -byte *vsp=0,*vspmask; // VSP data buffer. -unsigned short numtiles; // number of tiles in VSP. -unsigned short *tileidx; // tile index thingamajig -char *flipped; // bi-direction looping flag - -// entity stuffs - -char *msbuf[100]; // ptr-table to script offset -char *ms; // script text buffer -byte nms; // number of movescripts - -char numfollowers=0; // number of party followers -byte follower[10]; // maximum of 10 followers. -char laststeps[10]={ 0 }; // record of last movements -int lastent; - -// -- stuff -- - -byte movegranularity; // means nothing now, please remove -byte movectr=0; - -byte phantom=0; // walk-through-walls -byte speeddemon=0; // doublespeed cheat -int bindarray[128]; // bind script offset - -// ================================= Code ==================================== - -void ReadCompressedLayer1(byte *dest, int len, char *buf) -{ - int j,n; - byte run, w; - - n=0; - do - { - w=*buf; buf++; - if (w==0xFF) - { - run=*buf; buf++; - w=*buf; buf++; - for (j=0; jtx, player->ty+1)) return 1; break; - case 1: if (ObstructionAt(player->tx, player->ty-1)) return 1; break; - case 2: if (ObstructionAt(player->tx-1, player->ty)) return 1; break; - case 3: if (ObstructionAt(player->tx+1, player->ty)) return 1; break; - } - switch (dir) - { - case 0: if (EntityObsAt(player->tx, player->ty+1)) return 1; break; - case 1: if (EntityObsAt(player->tx, player->ty-1)) return 1; break; - case 2: if (EntityObsAt(player->tx-1, player->ty)) return 1; break; - case 3: if (EntityObsAt(player->tx+1, player->ty)) return 1; break; - } - return 0; -} - -void CheckZone() -{ - int curzone; - static int lz=0, zonedelay=0; - - curzone=zone[(player->ty * layer[0].sizex) + player->tx]; - if (lz!=curzone) - { - zonedelay=0; - lz=curzone; - } - if (!zones[curzone].percent) return; - if (zonedelay < zones[curzone].delay) - { - zonedelay++; - return; - } - if (curzone) - if (zones[curzone].script && - zones[curzone].percent >= rnd(0,255)) - { - ExecuteEvent(zones[curzone].script); - zonedelay=0; - } -} - -int InvFace() -{ - switch(player -> facing) - { - case 0: return 1; - case 1: return 0; - case 2: return 3; - case 3: return 2; - } - return -1; -} - -void Activate() -{ - byte tz; - int ax=0, ay=0; - - switch(player->facing) - { - case 0: ax=player->tx; ay=player->ty+1; break; - case 1: ax=player->tx; ay=player->ty-1; break; - case 2: ax=player->tx-1; ay=player->ty; break; - case 3: ax=player->tx+1; ay=player->ty; break; - } - tz=zone[(ay*layer[0].sizex)+ax]; - if (zones[tz].aaa) - { - ExecuteEvent(zones[tz].script); - return; - } - if ((tz=EntityAt(ax, ay))) - { - tz--; - if (entity[tz].face) - { - entity[tz].facing=InvFace(); - AnimateEntity(&entity[tz]); - } - if (entity[tz].actscript) - { - lastent=tz; - ExecuteEvent(entity[tz].actscript); - } - } -} - -void ResetFollowers() -{ - int i; - - player->x=player->tx<<4; - player->y=player->ty<<4; - player->moving=0; - player->movecnt=0; - player->reset=1; - for (i=0; ix; - entity[follower[i]].y=player->y; - entity[follower[i]].tx=player->tx; - entity[follower[i]].ty=player->ty; - entity[follower[i]].facing=player->facing; - entity[follower[i]].reset=1; - } - memset(laststeps, 0, 10); -} - -void MoveFollowers() -{ - int i; - - for (i=0; ianimofs=chr[player->chrindex].uanim; - entity[follower[i]].delayct=0; - entity[follower[i]].reset=0; - } - entity[follower[i]].facing=laststeps[i+1]-1; - } -} - -//--- zero 5.7.99 - -void WritePalette(FILE *f) -{ char b; - int i; - byte pal3[768]; - - for (i=0; i<768; i++) - pal3[i]=pal2[i] << 2; - - b=12; fwrite(&b, 1, 1, f); - fwrite(pal3, 1, 768, f); -} - -void WritePCXLine(unsigned char *p,int len,FILE *pcxf) -{ int i; - unsigned char byt, samect, repcode; - - i=0; - do - { byt=p[i++]; - samect=1; - while (samect<(unsigned) 63 && i1 || (byt & 0xC0) != 0) - { - repcode=0xC0 | samect; - fwrite(&repcode,1,1,pcxf); - } - fwrite(&byt,1,1,pcxf); - } while (i16 colors - b1=1; fwrite(&b1, 1, 1, pcxf); // encoding always = 1 - b1=8; fwrite(&b1, 1, 1, pcxf); // 8 bits per pixel, for 256 colors - w1=0; fwrite(&w1, 1, 2, pcxf); // xmin = 0; - w1=0; fwrite(&w1, 1, 2, pcxf); // ymin = 0; - w1=sx-1; fwrite(&w1, 1, 2, pcxf); // xmax = 319; - w1=sy-1; fwrite(&w1, 1, 2, pcxf); // ymax = 199; - w1=sx; fwrite(&w1, 1, 2, pcxf); // hres = 320; - w1=sy; fwrite(&w1, 1, 2, pcxf); // vres = 200; - - fwrite(screen,1,48,pcxf); - - b1=0; fwrite(&b1, 1, 1, pcxf); // reserved always = 0. - b1=1; fwrite(&b1, 1, 1, pcxf); // number of color planes. Just 1 for 8bit. - w1=sx; fwrite(&w1, 1, 2, pcxf); // number of bytes per line - - w1=0; fwrite(&w1, 1, 1, pcxf); - fwrite(screen, 1, 59, pcxf); // filler - - for (w1=0; w1moving) - { - if (down && !PlayerObstructed(0)) - { - player->ty++; - player->moving=1; - player->movecnt=15; - player->y++; - if (player->reset || player->facing != 0) - { - player->animofs=chr[player->chrindex].danim; - player->delayct=0; - player->reset=0; - } - player->facing=0; - LastMove(1); - return; - } - if (up && !PlayerObstructed(1)) - { - player->ty--; - player->moving=2; - player->movecnt=15; - player->y--; - if (player->reset || player->facing != 1) - { - player->animofs=chr[player->chrindex].uanim; - player->delayct=0; - player->reset=0; - } - player->facing=1; - LastMove(2); - return; - } - if (left && !PlayerObstructed(2)) - { - player->tx--; - player->moving=3; - player->movecnt=15; - player->x--; - if (player->reset || player->facing != 2) - { - player->animofs=chr[player->chrindex].lanim; - player->delayct=0; - player->reset=0; - } - player->facing=2; - LastMove(3); - return; - } - if (right && !PlayerObstructed(3)) - { - player->tx++; - player->moving=4; - player->movecnt=15; - player->x++; - if (player->reset || player->facing != 3) - { - player->animofs=chr[player->chrindex].ranim; - player->delayct=0; - player->reset=0; - } - player->facing=3; - LastMove(4); - return; - } - if (down) player->facing=0; - if (up) player->facing=1; - if (left) player->facing=2; - if (right) player->facing=3; - } - - switch (player->moving) - { - case 0: player->reset=1; player->animofs=0; player->delayct=0; break; - case 1: player->y++; player->movecnt--; break; - case 2: player->y--; player->movecnt--; break; - case 3: player->x--; player->movecnt--; break; - case 4: player->x++; player->movecnt--; break; - } - if (!player->movecnt && player->moving) - { - player->moving=0; - CheckZone(); - } - if (!player->movecnt && b1) Activate(); -} - -void ProcessControls() -{ int i; - - if (key[SCAN_RQUOTA]) - { - key[SCAN_RQUOTA]=0; last_pressed=0; - ActivateConsole(); - } - if (key[SCAN_ALT] && key[SCAN_X]) err("Exiting: ALT-X pressed."); -//--- zero 5.7.99 - if (key[SCAN_F11]) - { - Message("ss",50); - ScreenShot(); - key[SCAN_F11]=0; - } -//--- - if (!player) return; - - if (player->speed<4) - { - switch (player->speed) - { - case 1: if (player->speedct<3) { player->speedct++; return; } break; - case 2: if (player->speedct<2) { player->speedct++; return; } break; - case 3: if (player->speedct<1) { player->speedct++; return; } break; - } - } - if (player->speed<5) - { - ProcessControls1(); - player->speedct=0; - AnimateEntity(player); - } - switch (player->speed) - { - case 5: for (i=0; i<2; i++) { ProcessControls1(); AnimateEntity(player); } return; - case 6: for (i=0; i<3; i++) { ProcessControls1(); AnimateEntity(player); } return; - case 7: for (i=0; i<4; i++) { ProcessControls1(); AnimateEntity(player); } return; - } -} - -void GameTick() -{ - UpdateControls(); - CheckMessages(); - if (bindarray[last_pressed]) - HookKey(bindarray[last_pressed]); - ProcessControls(); - if (speeddemon && key[SCAN_CTRL]) ProcessControls(); - ProcessEntities(); -} - diff --git a/16/v2/source/verge/ENGINE/ENGINE.H b/16/v2/source/verge/ENGINE/ENGINE.H deleted file mode 100755 index d65545fe..00000000 --- a/16/v2/source/verge/ENGINE/ENGINE.H +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -// CHANGELOG: -// -// + added ScreenShot() headers -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - -#ifndef ENGINE_H -#define ENGINE_H - -typedef struct -{ - word start; // strand start - word finish; // strand end - word delay; // tile-switch delay - word mode; // tile-animation mode -} vspanim_r; - -typedef struct -{ - char pmultx,pdivx; // parallax multiplier/divisor for X - char pmulty,pdivy; // parallax multiplier/divisor for Y - unsigned short sizex, sizey; // layer dimensions. - unsigned char trans, hline; // transparency flag | hline (raster fx) -} layer_r; - -typedef struct -{ - char name[40]; // zone name/desc - unsigned short script; // script to call thingy - unsigned short percent; // chance of executing - unsigned short delay; // step-delay - unsigned short aaa; // Accept Adjacent Activation - unsigned short entityscript; // script to call for entities -} zoneinfo; - -extern layer_r layer[4]; // Array of layer data -extern vspanim_r vspanim[100]; // tile animation data -extern unsigned short vadelay[100]; // Tile animation delay ctr - -extern char mapname[60]; // MAP filename -extern char vspname[60]; // VSP filemap -extern char rstring[20]; // render-order string -extern char numlayers; // number of layers in map -extern byte *obstruct, *zone; // obstruction and zone buffers -extern int bufsize; // how many bytes need to be written -extern char layertoggle[4]; // layer visible toggles - -extern word *layers[4]; // Raw layer data -extern int xwin, ywin; - -// -- entity things -- - -extern char *msbuf[100]; // ptr-table to script offset -extern char *ms; // script text buffer -extern byte nms; // number of movescripts - -extern char numfollowers; // number of party followers -extern byte follower[10]; // maximum of 10 followers. -extern char laststeps[10]; // record of last movements -extern int lastent; - -// -- vsp data -- - -extern byte *vsp,*vspmask; // VSP data buffer. -extern unsigned short numtiles; // number of tiles in VSP. -extern unsigned short *tileidx; // tile index thingamajig -extern char *flipped; // bi-direction looping flag -extern byte movegranularity, phantom, speeddemon, movectr; -extern int bindarray[128]; - -// -- prototypes -- - -extern void LoadVSP(char *fname); -extern void FreeVSP(void); -extern void LoadMAP(char *fname); -extern void FreeMAP(void); -extern void MAPswitch(void); -extern void MAPstats(void); -extern void ProcessControls(void); -extern void GameTick(void); - -extern void ReadCompressedLayer1(byte*, int, char*); - -//--- zero 5.7.99 -void WritePalette(FILE *f); -void WritePCXLine(unsigned char *p,int len,FILE *pcxf); -void ScreenShot(); -// -#endif // ENGINE_H diff --git a/16/v2/source/verge/ENGINE/ENTITY.C b/16/v2/source/verge/ENGINE/ENTITY.C deleted file mode 100755 index add3758a..00000000 --- a/16/v2/source/verge/ENGINE/ENTITY.C +++ /dev/null @@ -1,716 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -// CHANGELOG: -// -// + corrected oversight in movement script management by sticking a hack in -// MoveScript(). Bug caused Fx commands to not work sometimes. -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -#define ENTITY_H -#include "verge.h" - -// ================================= Data ==================================== - -typedef struct -{ - int x, y; // xwc, ywx position - word tx, ty; // xtc, ytc position - byte facing; // direction entity is facing - byte moving, movecnt; // direction entity is moving - byte frame; // bottom-line frame to display - byte specframe; // special-frame set thingo - byte chrindex, reset; // CHR index | Reset animation - byte obsmode1, obsmode2; // can be obstructed | Is an obstruction - byte speed, speedct; // entity speed, speedcount :) - byte delayct; // animation frame-delay - char *animofs, *scriptofs; // anim script | move script - byte face, actm; // auto-face | activation mode - byte movecode, movescript; // movement type | movement script - byte ctr, mode; // sub-tile move ctr, mode flag (internal) - word step, delay; // step, delay - word stepctr, delayctr; // internal use counters - word data1, data2, data3; // - word data4, data5, data6; // - int actscript; // activation script - int expand1, expand2; // - int expand3, expand4; // - char desc[20]; // Entity description. -} entity_r; - -typedef struct -{ - byte *imagedata; // CHR frame data - int fxsize, fysize; // frame x/y dimensions - int hx, hy; // x/y obstruction hotspot - int totalframes; // total # of frames. - int lidle, ridle; - int uidle, didle; - char lanim[100]; - char ranim[100]; - char uanim[100]; - char danim[100]; -} chrdata; - -typedef struct -{ - char t[60]; -} chrlist_r; - -chrlist_r chrlist[100]; -byte nmchr,playernum; -entity_r *player=0; -entity_r entity[256]; -byte entities=0; -chrdata chr[100]; -byte numchrs=0; -byte entidx[256], cc; -byte movesuccess; - -// ================================= Code ==================================== - -int ObstructionAt(int tx, int ty) -{ - if (obstruct[(ty*layer[0].sizex)+tx]) return 1; - if (tx==-1 || ty==-1) return 1; - if (tx==layer[0].sizex || ty==layer[0].sizey) return 1; - return 0; -} - -int Zone(int tx, int ty) -{ - return zone[(ty*layer[0].sizex)+tx]; -} - -void LoadCHR(char *fname, chrdata *c) -{ - VFILE *f; - char b, *ptr=0; - int i; - - f=vopen(fname); - if (!f) err("Could not open CHR file %s.",fname); - vread(&b, 1, f); - if (b!=2) err("CHR %s incorrect CHR format version.",fname); - vread(&c->fxsize, 2, f); - vread(&c->fysize, 2, f); - vread(&c->hx, 2, f); - vread(&c->hy, 2, f); - vread(strbuf, 4, f); // skip the hotspot size. - vread(&c->totalframes, 2, f); - - vread(&i, 4, f); - ptr=(char *) valloc(i, "LoadCHR:ptr", OID_TEMP); - vread(ptr, i, f); - c->imagedata=(byte *) valloc(c->fxsize * c->fysize * c->totalframes, "LoadCHR:c->imagedata", OID_IMAGE); - ReadCompressedLayer1(c->imagedata, c->fxsize * c->fysize * c->totalframes, ptr); - vfree(ptr); - - - vread(&c->lidle, 4, f); - vread(&c->ridle, 4, f); - vread(&c->uidle, 4, f); - vread(&c->didle, 4, f); - - for (b=0; b<4; b++) - { - switch (b) - { - case 0: ptr=c->lanim; break; - case 1: ptr=c->ranim; break; - case 2: ptr=c->uanim; break; - case 3: ptr=c->danim; break; - } - vread(&i, 4, f); - if (i>100) err("Animation strand too long. %d",i); - vread(ptr, i, f); - } - vclose(f); -} - -int CacheCHR(char *fname) -{ - LoadCHR(fname, &chr[numchrs]); - numchrs++; - return (numchrs-1); -} - -void FreeCHRList() -{ - int i; - - for (i=0; i=numchrs) return; - b=entity[i].specframe ? entity[i].specframe : entity[i].frame; - TCopySpriteClip(dx-chr[a].hx, dy-chr[a].hy, chr[a].fxsize, chr[a].fysize, - (byte *) (chr[a].imagedata+(b*chr[a].fxsize* - chr[a].fysize))); -} - -static int cmpent(const void* a, const void* b) -{ - return entity[*(byte*)a].y - entity[*(byte*)b].y; -} - -void RenderEntities() -{ - int i; - - qsort(entidx, cc, 1, cmpent); - for (i=0; ianimofs==' ') p->animofs++; - while (*p->animofs>=48 && *p->animofs<=57) - { - token[j]=*p->animofs; - p->animofs++; - j++; - } - token[j]=0; - return atoi(token); -} - -void GetNextCommand(entity_r *p) -{ - byte s; - - while (*p->animofs==' ') p->animofs++; - s=*p->animofs; - p->animofs++; - switch (s) - { - case 'F': p->frame=GetArg(p); break; - case 'W': p->delayct=GetArg(p); break; - case 0: if (p->moving) - switch (p->facing) - { - case 0: p->animofs=chr[p->chrindex].danim; break; - case 1: p->animofs=chr[p->chrindex].uanim; break; - case 2: p->animofs=chr[p->chrindex].lanim; break; - case 3: p->animofs=chr[p->chrindex].ranim; break; - } - else - switch (p->facing) - { - case 0: p->animofs=0; p->frame=chr[p->chrindex].didle; break; - case 1: p->animofs=0; p->frame=chr[p->chrindex].uidle; break; - case 2: p->animofs=0; p->frame=chr[p->chrindex].lidle; break; - case 3: p->animofs=0; p->frame=chr[p->chrindex].ridle; break; - } - p->delayct=0; break; - } -} - -void AnimateEntity(entity_r *p) -{ - if (!p->animofs && p->moving) - { - switch (p->facing) - { - case 0: p->animofs=chr[p->chrindex].danim; break; - case 1: p->animofs=chr[p->chrindex].uanim; break; - case 2: p->animofs=chr[p->chrindex].lanim; break; - case 3: p->animofs=chr[p->chrindex].ranim; break; - } - p->delayct=0; - } - if (!p->animofs && !p->moving) - { - switch (p->facing) - { - case 0: p->animofs=0; p->frame=chr[p->chrindex].didle; break; - case 1: p->animofs=0; p->frame=chr[p->chrindex].uidle; break; - case 2: p->animofs=0; p->frame=chr[p->chrindex].lidle; break; - case 3: p->animofs=0; p->frame=chr[p->chrindex].ridle; break; - } - p->delayct=0; - } - if (p->delayct) - { - p->delayct--; - } - else GetNextCommand(p); -} - -int EntityAt(int ex, int ey) -{ int i; - - for (i=0; isx+chr[entity[i].chrindex].fxsize) continue; - if (dy<0 || dy>sy+chr[entity[i].chrindex].fysize) continue; - entidx[cc]=i; cc++; - } -} - -void MoveRight(int i) -{ - int tx,ty; - - tx=entity[i].tx+1; ty=entity[i].ty; - if (entity[i].obsmode1 && (ObstructionAt(tx,ty) || AEntityObsAt(tx,ty))) - { movesuccess=0; return; } - if (entity[i].facing!=3) - { - entity[i].delayct=0; - entity[i].animofs=0; - } - entity[i].x++; entity[i].facing=3; entity[i].moving=4; entity[i].ctr=15; - entity[i].tx++; movesuccess=1; entity[i].reset=0; -} - -void MoveLeft(int i) -{ - int tx, ty; - - tx=entity[i].tx-1; ty=entity[i].ty; - if (entity[i].obsmode1 && (ObstructionAt(tx,ty) || AEntityObsAt(tx,ty))) - { movesuccess=0; return; } - - if (entity[i].facing!=2) - { - entity[i].delayct=0; - entity[i].animofs=0; - } - entity[i].x--; entity[i].facing=2; entity[i].moving=3; entity[i].ctr=15; - entity[i].tx--; movesuccess=1; entity[i].reset=0; -} - -void MoveUp(int i) -{ - int tx, ty; - - tx=entity[i].tx; ty=entity[i].ty-1; - if (entity[i].obsmode1 && (ObstructionAt(tx,ty) || AEntityObsAt(tx,ty))) - { movesuccess=0; return; } - if (entity[i].facing!=1) - { - entity[i].delayct=0; - entity[i].animofs=0; - } - entity[i].y--; entity[i].facing=1; entity[i].moving=2; entity[i].ctr=15; - entity[i].ty--; movesuccess=1; entity[i].reset=0; -} - -void MoveDown(int i) -{ - int tx, ty; - - tx=entity[i].tx; ty=entity[i].ty+1; - if (entity[i].obsmode1 && (ObstructionAt(tx,ty) || AEntityObsAt(tx,ty))) - { movesuccess=0; return; } - if (entity[i].facing!=0) - { - entity[i].delayct=0; - entity[i].animofs=0; - } - entity[i].y++; entity[i].facing=0; entity[i].moving=1; entity[i].ctr=15; - entity[i].ty++; movesuccess=1; entity[i].reset=0; -} - -void Wander1(int i) -{ - if (!entity[i].data1) - { - entity[i].data2=rnd(0,3); - entity[i].data1=entity[i].step+1; - } - if (entity[i].data1==1) - { - entity[i].delayctr++; - if (entity[i].delayctr>=entity[i].delay) - entity[i].data1=0; - return; - } - if (entity[i].data1>1) - { - switch(entity[i].data2) - { - case 0: MoveUp(i); break; - case 1: MoveDown(i); break; - case 2: MoveLeft(i); break; - case 3: MoveRight(i); break; - } - entity[i].data1--; - if (entity[i].data1==1) - { - entity[i].delayctr=0; - entity[i].animofs=0; - entity[i].delayct=0; - } - } -} - -void Wander2(int i) -{ - if (!entity[i].data1) - { - entity[i].data3=rnd(0,3); - entity[i].data1=entity[i].step+1; - } - if (entity[i].data1==1) - { - entity[i].delayctr++; - if (entity[i].delayctr>=entity[i].delay) - entity[i].data1=0; - return; - } - if (entity[i].data1>1) - { - switch(entity[i].data3) - { - case 0: if (Zone(entity[i].tx,entity[i].ty-1)==entity[i].data2) MoveUp(i); break; - case 1: if (Zone(entity[i].tx,entity[i].ty+1)==entity[i].data2) MoveDown(i); break; - case 2: if (Zone(entity[i].tx-1,entity[i].ty)==entity[i].data2) MoveLeft(i); break; - case 3: if (Zone(entity[i].tx+1,entity[i].ty)==entity[i].data2) MoveRight(i); break; - } - entity[i].data1--; - if (entity[i].data1==1) entity[i].delayctr=0; - } -} - -void Wander3(int i) -{ - if (!entity[i].data1) - { - entity[i].data2=rnd(0,3); - entity[i].data1=entity[i].step+1; - } - if (entity[i].data1==1) - { - entity[i].delayctr++; - if (entity[i].delayctr>=entity[i].delay) - entity[i].data1=0; - return; - } - if (entity[i].data1>1) - { - switch(entity[i].data2) - { - case 0: if (entity[i].ty>entity[i].data3) MoveUp(i); break; - case 1: if (entity[i].tyentity[i].data2) MoveLeft(i); break; - case 3: if (entity[i].tx=48 && *entity[i].scriptofs<=57) - { - token[j]=*entity[i].scriptofs; - entity[i].scriptofs++; - j++; - } - token[j]=0; - entity[i].data1=atoi(token); -} - -void GetNextCommandMS(int i) -{ unsigned char s; - - Whitespace(i); - s=*entity[i].scriptofs; - entity[i].scriptofs++; - switch (s) - { - case 'U': entity[i].mode=1; GetArgMS(i); break; - case 'D': entity[i].mode=2; GetArgMS(i); break; - case 'L': entity[i].mode=3; GetArgMS(i); break; - case 'R': entity[i].mode=4; GetArgMS(i); break; - case 'S': entity[i].mode=5; GetArgMS(i); break; - case 'W': entity[i].mode=6; GetArgMS(i); entity[i].animofs=0; - entity[i].delayct=0; break; - case 0: switch (entity[i].facing) - { - case 0: entity[i].animofs=0; entity[i].frame=chr[entity[i].chrindex].didle; break; - case 1: entity[i].animofs=0; entity[i].frame=chr[entity[i].chrindex].uidle; break; - case 2: entity[i].animofs=0; entity[i].frame=chr[entity[i].chrindex].lidle; break; - case 3: entity[i].animofs=0; entity[i].frame=chr[entity[i].chrindex].ridle; break; - } - entity[i].movecode=0; entity[i].mode=7; entity[i].data1=0; - entity[i].scriptofs=0; entity[i].delayct=0; break; - case 'C': entity[i].mode=8; GetArgMS(i); break; - case 'B': entity[i].mode=9; break; - case 'X': entity[i].mode=10; GetArgMS(i); break; - case 'Y': entity[i].mode=11; GetArgMS(i); break; - case 'F': entity[i].mode=12; GetArgMS(i); break; - case 'Z': entity[i].mode=13; GetArgMS(i); break; - default: err("Invalid entity movement script."); - } -} - -void MoveScript(int i) -{ - if (!entity[i].scriptofs) entity[i].scriptofs=(char *) (int) ms+(int) msbuf[entity[i].movescript]; - if (!entity[i].mode) GetNextCommandMS(i); - - switch(entity[i].mode) - { - case 1: MoveUp(i); if (movesuccess) entity[i].data1--; break; - case 2: MoveDown(i); if (movesuccess) entity[i].data1--; break; - case 3: MoveLeft(i); if (movesuccess) entity[i].data1--; break; - case 4: MoveRight(i); if (movesuccess) entity[i].data1--; break; - case 5: entity[i].speed=entity[i].data1; entity[i].data1=0; break; - case 6: entity[i].data1--; break; - case 7: return; - case 8: ExecuteEvent(entity[i].data1); entity[i].data1=0; break; - case 9: entity[i].scriptofs=(char *) (int) ms+(int) msbuf[entity[i].movescript]; - entity[i].data1=0; break; - case 10: if (entity[i].txentity[i].data1) MoveLeft(i); - if (entity[i].tx==entity[i].data1) entity[i].data1=0; break; - break; - case 11: if (entity[i].tyentity[i].data1) MoveUp(i); - if (entity[i].ty==entity[i].data1) entity[i].data1=0; break; - break; - case 12: entity[i].facing=entity[i].data1; - entity[i].data1=0; - //--- zero 5.6.99 - switch(entity[i].facing) - { - case 0: entity[i].frame=chr[entity[i].chrindex].didle; break; - case 1: entity[i].frame=chr[entity[i].chrindex].uidle; break; - case 2: entity[i].frame=chr[entity[i].chrindex].lidle; break; - case 3: entity[i].frame=chr[entity[i].chrindex].ridle; break; - } - //--- - break; - case 13: entity[i].specframe=entity[i].data1; - entity[i].data1=0; break; - } - if (!entity[i].data1) entity[i].mode=0; -} - -void TestActive(int i) -{ - int dx, dy; - - dx=abs(entity[i].x - player->x); - dy=abs(entity[i].y - player->y); - if ((dx<=16 && dy<=3) || (dx<=3 && dy<=16)) - { - if (!entity[i].expand4 && !invc) - { - entity[i].expand4=1; - ExecuteEvent(entity[i].actscript); - } - } - else - entity[i].expand4=0; -} - -void ProcessEntity1(int i) -{ - entity[i].speedct=0; - if (entity[i].actm) TestActive(i); - - if (!entity[i].moving) - { - switch(entity[i].movecode) - { - case 0: return; - case 1: Wander1(i); break; - case 2: Wander2(i); break; - case 3: Wander3(i); break; - case 4: MoveScript(i); break; - default: err("unknown entity movement pattern."); - } - if (!entity[i].reset) return; - } - - if (entity[i].reset) - { - entity[i].animofs=0; - entity[i].delayct=0; - entity[i].reset=0; - } - - if (entity[i].moving) - { - if (entity[i].moving==1) - { entity[i].y++; entity[i].ctr--; AnimateEntity(&entity[i]); } - if (entity[i].moving==2) - { entity[i].y--; entity[i].ctr--; AnimateEntity(&entity[i]); } - if (entity[i].moving==4) - { entity[i].x++; entity[i].ctr--; AnimateEntity(&entity[i]); } - if (entity[i].moving==3) - { entity[i].x--; entity[i].ctr--; AnimateEntity(&entity[i]); } - if (!entity[i].ctr) { entity[i].reset=1; entity[i].moving=0; } - } -} - -void ProcessEntity(int i) -{ int j; - - if (player==&entity[i]) return; - if (entity[i].speed<4) - { - switch (entity[i].speed) - { - case 1: if (entity[i].speedct<3) { entity[i].speedct++; return; } - case 2: if (entity[i].speedct<2) { entity[i].speedct++; return; } - case 3: if (entity[i].speedct<1) { entity[i].speedct++; return; } - } - } - if (entity[i].speed<5) - { - ProcessEntity1(i); - entity[i].speedct=0; - } - switch (entity[i].speed) - { - case 5: for (j=0; j<2; j++) { ProcessEntity1(i); } return; - case 6: for (j=0; j<3; j++) { ProcessEntity1(i); } return; - case 7: for (j=0; j<4; j++) { ProcessEntity1(i); } return; - } -} - -void ProcessEntities() -{ - int i; - - SiftEntities(); - for (i=0; i -#include -#include -#include "verge.h" - -// ================================= Data ==================================== - -#ifndef __WATCOMC__ -#define INT_MAX 0xFFFFFFFF -#define INT_MIN 0 -#endif - -#ifndef MIN -#define MIN(x,y) (((x) < (y)) ? (x) : (y)) -#define MAX(x,y) (((x) > (y)) ? (x) : (y)) -#define MID(x,y,z) MAX((x), MIN((y), (z))) -#endif - -#ifndef ABS -#define ABS(x) (((x) >= 0) ? (x) : (-(x))) -#endif - -#ifndef SGN -#define SGN(x) (((x) >= 0) ? 1 : -1) -#endif - -#define FLI_MAGIC 0xAF11 // file header magic number -#define FLC_MAGIC 0xAF12 // file magic number (Pro) -#define FLI_FRAME_MAGIC 0xF1FA // frame header magic number -#define FLI_FRAME_PREFIX 0xF100 // FLC's prefix info -#define FLI_FRAME_USELESS 0x00A1 // FLC's garbage frame - -typedef struct -{ - int w,h; - byte *data; -} BITMAP; - -#define FLI_OK 0 /* FLI player return values */ -#define FLI_EOF -1 -#define FLI_ERROR -2 -#define FLI_NOT_OPEN -3 - -#ifdef __WATCOMC__ -#define PACKED -#pragma pack(1); -#endif - -#ifdef __DJGPP__ -#define PACKED __attribute__ ((packed)) -#endif - -typedef struct -{ - long size PACKED; - word type PACKED; - word frame_count PACKED; - word width PACKED; - word height PACKED; - word bpp PACKED; - word flags PACKED; - word speed PACKED; - long next_head PACKED; - long frames_in_table PACKED; - char reserved[102] PACKED; -} FLI_HEADER; - -typedef struct -{ - quad size PACKED; - word type PACKED; - word chunks PACKED; - char pad[8] PACKED; -} FLI_FRAME; - -typedef struct -{ - quad size PACKED; - word type PACKED; -} FLI_CHUNK; - -#ifdef __WATCOMC__ -#pragma pack(); -#endif - -static int fli_status = FLI_NOT_OPEN; // current state of the FLI player - -int fli_bitmap_width = 0; -int fli_bitmap_height = 0; -byte *fli_bitmap_data = NULL; // current frame of the FLI -byte fli_palette[768]; // current palette the FLI is using - -int fli_bmp_dirty_from = INT_MAX; // what part of fli_bitmap is dirty -int fli_bmp_dirty_to = INT_MIN; -int fli_pal_dirty_from = INT_MAX; // what part of fli_palette is dirty -int fli_pal_dirty_to = INT_MIN; - -int fli_frame = 0; // current frame number in the FLI -long speed; - -static int fli_file = 0; // the file we are reading - -static byte *fli_mem_data = NULL; // the memory FLI we are playing -static int fli_mem_pos = 0; // position in the memory FLI - -static FLI_HEADER fli_header; // header structure -static FLI_FRAME frame_header; // frame header structure - -// a block of temporary working memory -byte *_scratch_mem = NULL; -int _scratch_mem_size = 0; - -// ================================= Code ==================================== - -void reset_fli_variables(void); -void close_fli(void); -int next_fli_frame(int); -int open_fli(char *); -int open_memory_fli(byte *); - -void _grow_scratch_mem(int size) -{ - if (size > _scratch_mem_size) { - size = (size+1023) & 0xFFFFFC00; - _scratch_mem = realloc(_scratch_mem, size); - _scratch_mem_size = size; - } -} - -void vsync() -{ - while (!(inp(986) & 8)); -} - -void set_palette_range(byte *pal, int from, int to, int sync) -{ - int i; - - // swap? - if (to=256) to=255; - - if (sync) vsync(); - - outp(968, from); - for (i=from; i<=to; i++) - { - outp(969, pal[(i*3)+0]); - outp(969, pal[(i*3)+1]); - outp(969, pal[(i*3)+2]); - } -} - -static byte *fli_read(byte *buf, int size) -{ - int result; - - if (fli_mem_data) - { - if (buf) - memcpy(buf, fli_mem_data+fli_mem_pos, size); - else - buf = fli_mem_data+fli_mem_pos; - - fli_mem_pos += size; - } - else - { - if (!buf) - { - _grow_scratch_mem(size); - buf = _scratch_mem; - } - - result = read(fli_file, buf, size); - if (result != size) - return NULL; - } - return buf; -} - -static void fli_seek(int offset, int mode) -{ - if (fli_mem_data) - { - if (mode == SEEK_CUR) - fli_mem_pos += offset; - else - fli_mem_pos = offset; - } - else - lseek(fli_file, offset, mode); -} - -// helpers for reading FLI chunk data -#define READ_BYTE() ((sz-- > 0) ? *(((byte *)p)++) : 0) -#define READ_CHAR() ((sz-- > 0) ? *(((signed char *)p)++) : 0) -#define READ_SHORT() (((sz-=2) > 0) ? *(((signed short *)p)++) : 0) - -#define READ_BLOCK(pos, size) \ - { \ - if (sz >= (size)) \ - { \ - memcpy(pos, p, size); \ - p += (size); \ - sz -= (size); \ - } \ - else \ - { \ - char *_p = (char *)(pos); \ - int _c; \ - \ - for (_c=0; _c < (size); _c++) \ - *(_p++) = READ_BYTE(); \ - } \ - } - -#define READ_RLE_BYTE(pos, size) \ - { \ - memset(pos, READ_BYTE(), size); \ - } - -#define READ_RLE_WORD(pos, size) \ - { \ - short *_p = (short *)(pos); \ - short _v = READ_SHORT(); \ - int _c; \ - \ - for (_c=0; _c < (size); _c++) \ - *(_p++) = _v; \ - } - -static void do_fli_256_color(byte *p, int sz) -{ - int packets; - int c, c2; - int offset; - int length; - - offset = 0; - packets = READ_SHORT(); - for (c=0; c 0) - { - packets = READ_SHORT(); - - while (packets < 0) - { - if (packets & 0x4000) - y -= packets; - else - fli_bitmap_data[(y*fli_bitmap_width)+fli_bitmap_width-1]=packets&0xff; - //fli_bitmap->line[y][fli_bitmap->w-1] = packets & 0xFF; - - packets = READ_SHORT(); - } - x=0; - while (packets-- > 0) - { - // skip bytes - x += READ_BYTE(); - - size = READ_CHAR(); - - // copy size words - if (size > 0) - { - READ_BLOCK(fli_bitmap_data+(y*fli_bitmap_width)+x, size*2); - //READ_BLOCK(fli_bitmap->line[y]+x, size*2); - x += size*2; - } - // repeat word -size times - else if (size < 0) - { - READ_RLE_WORD(fli_bitmap_data+(y*fli_bitmap_width)+x, -size); - //READ_RLE_WORD(fli_bitmap->line[y]+x, -size); - x -= size*2; - } - } - fli_bmp_dirty_from = MIN(fli_bmp_dirty_from, y); - fli_bmp_dirty_to = MAX(fli_bmp_dirty_to, y); - y++; - } -} - -static void do_fli_color(byte *p, int sz) -{ - int packets; - int c, c2; - int offset; - int length; - - offset = 0; - packets = READ_SHORT(); - - for (c=0; c 0) - { - packets = READ_BYTE(); - x = 0; - while (packets-- > 0) - { - x += READ_BYTE(); - size = READ_CHAR(); - - // copy size bytes - if (size > 0) - { - READ_BLOCK(fli_bitmap_data+(y*fli_bitmap_width)+x, size); - //READ_BLOCK(fli_bitmap->line[y]+x, size); - x += size; - } - else if (size < 0) - { - READ_RLE_BYTE(fli_bitmap_data+(y*fli_bitmap_width)+x, -size); - //READ_RLE_BYTE(fli_bitmap->line[y]+x, -size); - x -= size; - } - } - y++; - } -} - -static void do_fli_black(byte *p, int sz) -{ - memset(fli_bitmap_data, 0, fli_bitmap_width*fli_bitmap_height); - //clear(fli_bitmap); - - fli_bmp_dirty_from = 0; - fli_bmp_dirty_to = fli_bitmap_height-1; -} - -static void do_fli_brun(byte *p, int sz) -{ - int packets; - int size; - int x, y; - - // for each line... - for (y=0; y 0) - { - size = READ_CHAR(); - if (size < 0) - { - READ_BLOCK(fli_bitmap_data+(y*fli_bitmap_width)+x, -size); - //READ_BLOCK(fli_bitmap->line[y]+x, -size); - x -= size; - } - // repeat byte size times - else if (size > 0) - { - READ_RLE_BYTE(fli_bitmap_data+(y*fli_bitmap_width)+x, size); - //READ_RLE_BYTE(fli_bitmap->line[y]+x, size); - x += size; - } - } - } - fli_bmp_dirty_from = 0; - fli_bmp_dirty_to = fli_bitmap_height-1; -} - -static void do_fli_copy(byte *p, int sz) -{ - READ_BLOCK(fli_bitmap_data, fli_bitmap_width * fli_bitmap_height); - //READ_BLOCK(fli_bitmap->dat, fli_bitmap->w * fli_bitmap->h); - - fli_bmp_dirty_from = 0; - fli_bmp_dirty_to = fli_bitmap_height-1; -} - -static void read_frame() -{ - byte *p; - FLI_CHUNK *chunk; - int c, sz; - - if (fli_status != FLI_OK) - return; - -get_another_frame: - if (!fli_read((byte *)&frame_header, sizeof(FLI_FRAME))) - { - fli_status = FLI_ERROR; - return; - } - - if ((frame_header.type == FLI_FRAME_PREFIX) - || (frame_header.type == FLI_FRAME_USELESS)) - { - fli_seek(frame_header.size-sizeof(FLI_FRAME), SEEK_CUR); - fli_frame++; - - goto get_another_frame; - } - - if (frame_header.type != FLI_FRAME_MAGIC) - { - fli_status = FLI_ERROR; - return; - } - - if (frame_header.size == sizeof(FLI_FRAME)) - { - fli_frame++; - return; - } - p = fli_read(NULL, frame_header.size-sizeof(FLI_FRAME)); - if (!p) - { - fli_status = FLI_ERROR; - return; - } - for (c=0; csize - sizeof(FLI_CHUNK); - p += sizeof(FLI_CHUNK); - switch (chunk->type) - { - case 4: do_fli_256_color(p, sz); break; - case 7: do_fli_delta(p, sz); break; - case 11: do_fli_color(p, sz); break; - case 12: do_fli_lc(p, sz); break; - case 13: do_fli_black(p, sz); break; - case 15: do_fli_brun(p, sz); break; - case 16: do_fli_copy(p, sz); break; - default: err("Corrupt FLI chunk."); - } - p = ((byte *)chunk) + chunk->size; - } - fli_frame++; -} - -static int do_play_fli(BITMAP *bmp, int loop, int (*callback)()) -{ - int ret; - - ret = next_fli_frame(loop); - while (ret == FLI_OK) - { - if (fli_pal_dirty_from <= fli_pal_dirty_to) - set_palette_range(fli_palette, fli_pal_dirty_from, fli_pal_dirty_to, 1); - - if (fli_bmp_dirty_from <= fli_bmp_dirty_to) - { - int i,to=fli_bmp_dirty_to; - if (to>=bmp->h) to=bmp->h-1; - -// vsync(); - for (i=fli_bmp_dirty_from; i<=to; i++) - { - memcpy(bmp->data+(i*bmp->w), fli_bitmap_data+(i*fli_bitmap_width), - (fli_bitmap_width>bmp->w) ? bmp->w : fli_bitmap_width); - } - - //blit( - // fli_bitmap, bmp, 0, fli_bmp_dirty_from, 0, fli_bmp_dirty_from, - // fli_bitmap->w, 1+fli_bmp_dirty_to-fli_bmp_dirty_from); - } - - reset_fli_variables(); - - if (callback) - { - ret = (*callback)(); - if (ret != FLI_OK) - break; - } - ret = next_fli_frame(loop); - while (timer_count= fli_header.frame_count) - { - if (loop) - { - fli_seek(sizeof(FLI_HEADER), SEEK_SET); - fli_frame = 0; - } - else - { - fli_status = FLI_EOF; - return fli_status; - } - } - read_frame(); - return fli_status; -} - -void reset_fli_variables() -{ - fli_bmp_dirty_from = INT_MAX; - fli_bmp_dirty_to = INT_MIN; - fli_pal_dirty_from = INT_MAX; - fli_pal_dirty_to = INT_MIN; -} diff --git a/16/v2/source/verge/ENGINE/FLI.H b/16/v2/source/verge/ENGINE/FLI.H deleted file mode 100755 index b18995b4..00000000 --- a/16/v2/source/verge/ENGINE/FLI.H +++ /dev/null @@ -1,28 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef FLI_H -#define FLI_H - -typedef struct -{ - int w,h; - byte *data; -} BITMAP; - -int play_fli(char *filename, BITMAP *bmp, int loop, int (*callback)()); -int play_memory_fli(byte *fli_data, BITMAP *bmp, int loop, int (*callback)()); -#endif diff --git a/16/v2/source/verge/ENGINE/FONT.C b/16/v2/source/verge/ENGINE/FONT.C deleted file mode 100755 index d9621ae4..00000000 --- a/16/v2/source/verge/ENGINE/FONT.C +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#define FONT_H -#include "verge.h" - -// ================================= Data ==================================== - -struct fontstruct -{ - byte width, height; // Font character dimensions - byte *data; // Font bitmap data -}; - -struct fontstruct font[10]; // Font stuff; -int numfonts=0; // number of loaded fonts. -int curx, cury; // x/y font location -char tc=0; // text color - -// ================================= Code ==================================== - -int LoadFont(char *fname) -{ VFILE *f=0; - struct fontstruct *cfont=0; - int z=0; - - if (!(f=vopen(fname))) - err("Could not open font %s. \n",fname); - - // alias current font struct - cfont=font+numfonts; - - if (vgetc(f) != 1) - err("Font file incorrect version number. \n"); - - // font dims - cfont->width=vgetw(f); - cfont->height=vgetw(f); - - // get num of sub-set; calc total bytes as well - z=vgetw(f) * 96 * cfont->width*cfont->height; - - // nab room for font and read it in - cfont->data=(byte *)valloc(z, "LoadFont:cfont->data", OID_IMAGE); - vread(cfont->data, z, f); - - vclose(f); - - return numfonts++; -} - -void TextColor(int c) -{ - tc=c; -} - -void GotoXY(int x, int y) -{ - curx=x; - cury=y; -} - -static void pchar(int fnt, int x, int y, unsigned char c) -{ - int w; - if (c>31 && c<127) - { - w=font[fnt].width,h=font[fnt].height; - TCopySpriteClip(x,y, w,h, font[fnt].data+((c-32)*w*h)+((tc&3)*96*w*h)); - } -} - -void printstring(int fnt, char *str) -{ - if (fnt<0 || fnt >= numfonts) - return; - for (; *str; str++) - { - unsigned char c=*str; - switch (c) - { - case 126: tc=0; str++; continue; - case 128: tc=1; str++; continue; - case 129: tc=2; str++; continue; - case 130: tc=3; str++; continue; - } - pchar(fnt,curx,cury,c); - curx+=font[fnt].width; - } -} \ No newline at end of file diff --git a/16/v2/source/verge/ENGINE/FONT.H b/16/v2/source/verge/ENGINE/FONT.H deleted file mode 100755 index f8300c2d..00000000 --- a/16/v2/source/verge/ENGINE/FONT.H +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef FONT_H -#define FONT_H - -struct fontstruct -{ - byte width, height; // Font character dimensions - byte *data; // Font bitmap data -}; - -extern struct fontstruct font[10]; // Font stuff; -extern int numfonts; // number of loaded fonts. -extern int curx, cury; - -extern int LoadFont(char *fname); -extern void TextColor(int c); -extern void NumColor(int c); -extern void GotoXY(int x, int y); -extern void printstring(int fnt, char *str); -extern void dec_to_asciiz(int num, char *buf); - -#endif // FONT_H diff --git a/16/v2/source/verge/ENGINE/IMAGE.C b/16/v2/source/verge/ENGINE/IMAGE.C deleted file mode 100755 index 25c57ec4..00000000 --- a/16/v2/source/verge/ENGINE/IMAGE.C +++ /dev/null @@ -1,709 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// Mega kudos to aen for porting that GIF code. - -#include -#include "verge.h" - -// ========================= PCX Imaging routines ============================ - -char manufacturer; // pcx header -char version; -char encoding; -char bits_per_pixel; -word xmin, ymin; -word xmax, ymax; -word hres, vres; -char palette[48]; -char reserved; -char color_planes; -word bytes_per_line; -word palette_type; -char filler[58]; - -word width, depth; -word bytes; -byte c, run, ss=0; -quad vidoffset, n=0; -VFILE *pcxf; -char *cb,*src; -int i; - -// ================================= Code ==================================== - -void ReadPCXLine(byte *dest) -{ n=0; - while (n=0xc0) //(c & 0xc0)==0xc0) - { - run=c & 0x3f; - c=vgetc(pcxf); //*src++; - } - while (run--) - dest[vidoffset+n++]=c; - } - vseek(pcxf, bytes_per_line-width, 1); -} - -void LoadPCXHeader(char *fname) -{ - if (!(pcxf=vopen(fname))) err("Could not open PCX file %s.",fname); - vread(&manufacturer,1,pcxf); - vread(&version,1,pcxf); - vread(&encoding,1,pcxf); - vread(&bits_per_pixel,1,pcxf); - vread(&xmin,2,pcxf); - vread(&ymin,2,pcxf); - vread(&xmax,2,pcxf); - vread(&ymax,2,pcxf); - vread(&hres,2,pcxf); - vread(&vres,2,pcxf); - vread(&palette,48,pcxf); - vread(&reserved,1,pcxf); - vread(&color_planes,1,pcxf); - vread(&bytes_per_line,2,pcxf); - vread(&palette_type,2,pcxf); - vread(&filler,58,pcxf); - //vseek(pcxf,filesize(pcxf)-768,SEEK_SET); - //vread(&pal,768,pcxf); - vseek(pcxf,128L,SEEK_SET); - width=xmax-xmin+1; - depth=ymax-ymin+1; - - bytes=bytes_per_line; - - //for (i=0; i<768; i++) - // pal[i]=pal[i] >> 2; -// SetPalette((byte *) &pal); - - //i=filesize(pcxf); - //cb=(char *) valloc(i-896, "LoadPCXHeader:cb", OID_TEMP); - //vread(cb, i-(128+768+1), pcxf); -} - -void LoadPCXHeaderNP(char *fname) -{ - if (!(pcxf=vopen(fname))) err("Could not open PCX file %s.",fname); - vread(&manufacturer,1,pcxf); - vread(&version,1,pcxf); - vread(&encoding,1,pcxf); - vread(&bits_per_pixel,1,pcxf); - vread(&xmin,2,pcxf); - vread(&ymin,2,pcxf); - vread(&xmax,2,pcxf); - vread(&ymax,2,pcxf); - vread(&hres,2,pcxf); - vread(&vres,2,pcxf); - vread(&palette,48,pcxf); - vread(&reserved,1,pcxf); - vread(&color_planes,1,pcxf); - vread(&bytes_per_line,2,pcxf); - vread(&palette_type,2,pcxf); - vread(&filler,58,pcxf); - vseek(pcxf,filesize(pcxf)-768,SEEK_SET); - vread(&pal,768,pcxf); - vseek(pcxf,128L,SEEK_SET); - width=xmax-xmin+1; - depth=ymax-ymin+1; - bytes=bytes_per_line; - - i=filesize(pcxf); - cb=(char *) valloc(i-896, "LoadPCXHeaderNP:cb", OID_TEMP); - vread(cb, i-896, pcxf); -} - -void LoadPCX(char *fname, byte *dest) -{ - LoadPCXHeader(fname); - - src=cb; - for (i=0; i>=2; - } - //vfree(cb); - vclose(pcxf); - return buf; -} - -// ========================= BMP Imaging routines ============================ - -struct RGBQUAD -{ - unsigned char r,g,b,a; -}; - -struct RGBQUAD bmppalette[256]; - -// ================================= Code ==================================== - -byte *LoadBMPBuf(char *fname) -{ byte pad[4], *buf; - VFILE* bmpfile; - int bwidth, bheight, y; - - if (!(bmpfile=vopen(fname))) err("Could not open BMP file %s.",fname); - vseek(bmpfile, 18, SEEK_SET); - vread(&bwidth, 4, bmpfile); width=bwidth; - vread(&bheight, 4, bmpfile); depth=bheight; - vseek(bmpfile, 54, SEEK_SET); - vread(bmppalette, 1024, bmpfile); - buf=(byte*) valloc(bwidth*bheight, "LoadBMPBuf:buf", OID_IMAGE); - - for (y=bheight-1; y>=0; y--) - { - vread((char *)((int)buf+y*width),width,bmpfile); - vread(pad,width%4,bmpfile); - } - for (y=0; y<256; y++) - { - pal[y*3]=bmppalette[y].b >> 2; - pal[y*3+1]=bmppalette[y].g >> 2; - pal[y*3+2]=bmppalette[y].r >> 2; - } - SetPalette((byte*)pal); - vclose(bmpfile); - return buf; -} - -// ========================== GIF Imaging routines =========================== - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned long u32; - -typedef signed char s8; -typedef signed short s16; -typedef signed long s32; - -typedef struct -{ - u8 bits; - u8 background; - u8 * palette; - u8 * image; - s16 wide, deep; -} gif_image_info; - -typedef struct -{ - char sig[7]; - s16 screenwide, screendeep; - u8 hflags; - u8 background; - u8 aspect; -} gif_header; - -typedef struct -{ - s16 top, left; - s16 wide, deep; - u8 iflags; -} gif_image_descriptor; - -int NO_CODE = -1,// TRUE = 1, - ERROR_EOF = 0, ERROR_BAD_CODE = 1, - ERROR_BAD_HEADER = 2, ERROR_BAD_STARTCODE = 3, - ERROR_BAD_FIRST_CODE = 4, ERROR_BAD_FILE = 5, - ERROR_NO_IMAGE = 6; - -char* gif_error_messages[] = -{ - "Unexpected end of file\n", - "Bad code\n", - "Bad gif header\n", - "Bad symbol size\n", - "Bad first code\n", - "Error opening file\n", - "This file doesn't contain an image\n" -}; - -// read colour palette, vga palette values are 6 bit numbers -// while gif allows for 8 bit so shift right to get correct colours - -u8* gif_read_palette(FILE* fp, s32 bytes) -{ - s32 i = 0; - u8* block = 0L; - s32 components = (bytes / 3) * 3; - - block = (unsigned char *)valloc(components, "gif_read_palette:block", OID_IMAGE); - - for (i = 0; i < components; ++i) - block[i] = fgetc(fp) >> 2; - - return block; -} - -// read a block of bytes into memory -s32 block_mem_read(FILE* fp, u8* buffer, s32 bytes) -{ - s32 status = 0; - - status = fread(buffer, 1, bytes, fp); - if (status != bytes) return EOF; - - return TRUE; -} - -// read a unsigned 16 bit value from file, low byte first; note that this -// is reverse endian-ness (ie. fwrite(&s,1,2,fp); writes high byte first). - -s16 read_word_lbf(FILE* fp) -{ - s32 a, b; - - a = fgetc(fp); - b = fgetc(fp); - - return (b << 8) | a; -} - -// read the GIF file header structure into a sequence -gif_header* get_gif_header(FILE* fp) -{ - gif_header* h = 0L; - - h = (gif_header *)valloc(sizeof(gif_header), "get_gif_header:h", OID_IMAGE); - - fread(h->sig, 1, 6, fp); - h->sig[6] = 0; - - if (strncmp(h->sig, "GIF", 3) != 0) - return NULL; - - h->screenwide = read_word_lbf(fp); width=h->screenwide; - h->screendeep = read_word_lbf(fp); depth=h->screendeep; - h->hflags = fgetc(fp); - h->background = fgetc(fp); - h->aspect = fgetc(fp); - - return h; -} - -// gif file can contain more than one image, -// each image is preceeded by a header structure -gif_image_descriptor* get_image_descriptor(FILE* fp) -{ - gif_image_descriptor* id = 0L; - - id = (gif_image_descriptor *)valloc(sizeof(gif_image_descriptor), "get_image_descriptor:id", OID_IMAGE); - - id->left = read_word_lbf(fp); - id->top = read_word_lbf(fp); - id->wide = read_word_lbf(fp); - id->deep = read_word_lbf(fp); - id->iflags = fgetc(fp); - - return id; -} - -static u16 word_mask_table[] = -{ - 0x0000, 0x0001, 0x0003, 0x0007, - 0x000F, 0x001F, 0x003F, 0x007F, - 0x00FF, 0x01FF, 0x03FF, 0x07FF, - 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF -}; - -static u8 inc_table[] = { 8,8,4,2,0 }; -static u8 start_table[] = { 0,4,2,1,0 }; - -// enables me to use indices as per EUPHORiA (ie. converts to C's 0 base) -#define eui(i) ((i)-1) - -// unpack an LZW compressed image -// returns a sequence containing screen display lines of the image -u8* unpack_image(FILE* fp, s32 start_code_size, u32 width, u32 depth, u32 flags) -{ - u8* buffer; - u8* line_buffer; - - u16 first_code_stack[4096]; - u16 last_code_stack[4096]; - u16 code_stack[4096]; - - s32 bits_left; - s32 clear_code; - s32 code_size; - s32 code_size2; - s32 next_code; - s32 this_code; - s32 old_token; - s32 current_code; - s32 old_code; - s32 block_size=0; - s32 line; - s32 a_byte; - s32 pass; - s32 u; - - u8 b[256]; // read buffer; for block reads - u8* p; // current byte in read buffer - u8* q; // last byte in read buffer + 1 - - line_buffer = (u8 *)valloc(width, "unpack_image:line_buffer", OID_TEMP); - buffer = (u8 *)valloc(width * depth, "unpack_image:buffer", OID_IMAGE); - - a_byte = 0; - line = 0; - pass = 0; - bits_left = 8; - - if (start_code_size < 2 || start_code_size > 8) - err("\nERROR_BAD_STARTCODE"); // bad symbol size - - p = b; - q = b; - - clear_code = 1 << start_code_size; //pow(2, start_code_size); - next_code = clear_code + 2; - code_size = start_code_size + 1; - code_size2 = 1 << code_size; //pow(2, code_size); - old_code = NO_CODE; - old_token = NO_CODE; - - while (1) - { - if (bits_left == 8) - { - ++p; - if (p >= q) - { - block_size = fgetc(fp); - if (block_mem_read(fp, b, block_size) == EOF) - err("\nERROR_EOF"); - p = b; - q = b + block_size; - } - bits_left = 0; - } - - this_code = *p; - current_code = code_size + bits_left; - - if (current_code <= 8) - { - *p = *p >> code_size; - bits_left = current_code; - } - else - { - ++p; - if (p >= q) - { - block_size = fgetc(fp); - if (block_mem_read(fp, b, block_size) == EOF) - err("\nERROR_EOF"); - p = b; - q = b + block_size; - } - - this_code |= (*p << (8 - bits_left)); - - if (current_code <= 16) - { - bits_left = current_code - 8; - *p = *p >> bits_left; - } - else - { - if (++p >= q) - { - block_size = fgetc(fp); - if (block_mem_read(fp, b, block_size) == EOF) - err("\nERROR_EOF"); - p = b; - q = b + block_size; - } - - this_code |= (*p << (16 - bits_left)); - - bits_left = current_code - 16; - *p = *p >> bits_left; - } - } - - this_code &= word_mask_table[code_size]; - current_code = this_code; - - if (this_code == (clear_code+1) || block_size == 0) - break; - if (this_code > next_code) - err("\nERROR_BAD_CODE"); - - if (this_code == clear_code) - { - next_code = clear_code + 2; - code_size = start_code_size + 1; - code_size2 = 1 << code_size; //pow(2, code_size); - old_code = NO_CODE; - old_token = NO_CODE; - } - else - { - u = 1; - if (this_code == next_code) - { - if (old_code == NO_CODE) - err("\nERROR_BAD_FIRST_CODE"); - - first_code_stack[eui(u)] = old_token; - u++; - this_code = old_code; - } - - while (this_code >= clear_code) - { - first_code_stack[eui(u)] = last_code_stack[eui(this_code)]; - u++; - this_code = code_stack[eui(this_code)]; - } - - old_token = this_code; - while (1) - { - line_buffer[a_byte] = this_code; - a_byte++; - if (a_byte >= width) - { - // full image line so add it into screen image - memcpy(buffer + (line * width), line_buffer, width); - - a_byte = 0; - if (flags & 0x40) - { - line += inc_table[pass]; - if (line >= depth) - { - pass++; - line = start_table[pass]; - } - } - else - { - line++; - } - } - - // no more bytes on stack - if (u == 1) break; - - u--; - this_code = first_code_stack[eui(u)]; - } - - if (next_code < 4096 && old_code != NO_CODE) - { - code_stack[eui(next_code)] = old_code; - last_code_stack[eui(next_code)] = old_token; - next_code++; - if (next_code >= code_size2 && code_size < 12) - { - code_size++; - code_size2 = 1 << code_size; //pow(2, code_size); - } - } - - old_code = current_code; - } - } - - // completed reading the image so return it - free(b); - return buffer; -} - -// skip the extension blocks as we are only after the image -void skip_extension(FILE* fp) -{ - s32 n; - char temp[256]; - - n = fgetc(fp); // throwaway extension function code - n = fgetc(fp); // get length of block - - while (n > 0 && n != EOF) - { - // throwaway block - fread(temp, 1, n, fp); - - n = fgetc(fp); // get length of next block - } -} - -// unpack the GIF file -// returns ImageInfo sequence containing image and image data -gif_image_info* unpack_gif(char* filename) -{ - VFILE *f; - FILE* fp; - s32 c, b; - gif_header* h = 0L; - gif_image_info* ii = 0L; - gif_image_descriptor* id = 0L; - u8* local_palette = 0L; - - ii = (gif_image_info *)valloc(sizeof(gif_image_info), "unpack_gif:ii", OID_IMAGE); - - f = vopen(filename); - if (!f) err("Could not open GIF file %s.",filename); - fp = f->fp; - if (!fp) err("\nBad filename"); - - // file starts with the Logical Screen Descriptor structure - h = get_gif_header(fp); - - // Size of Global Color Table - ii->bits = (h->hflags & 7) + 1; - ii->background = h->background; - - // get Global colour palette if there is one - if (h->hflags & 0x80) // is flags bit 8 set? - { - c = 3 << ii->bits; // size of global colour map - ii->palette = gif_read_palette(fp, c); - -/* outp(968, 0); - // enforce global color map - for (s32 i=0; i < 768; ++i) - outp(969, ii->palette[i]); */ - memcpy(pal, ii->palette, 768); - } - - c = fgetc(fp); - - while (c == 0x2c || c == 0x21 || c == 0) - { - // image separator so unpack the image - if (c == 0x2c) - { - id = get_image_descriptor(fp); // get the Image Descriptor - // if there is a local Color Table then overwrite the global table - if (id->iflags & 0x80) - { - ii->bits = (id->iflags & 7) + 1; - b = 3 << ii->bits; - if (local_palette) - free(local_palette); - local_palette = gif_read_palette(fp, b); - } - - c = fgetc(fp); // get the LZW Minimum Code Size - ii->image = unpack_image(fp, c, id->wide, id->deep, id->iflags); - vclose(f); - - // error reading image - if (!ii->image) - err("\nerror reading image data"); - - ii->wide = id->wide; - ii->deep = id->deep; - - // return imagedata - return ii; - } - // extension introducer - else if (c == 0x21) - { - skip_extension(fp); // throw the extension away - } - - c = fgetc(fp); - } - - // no image? - return NULL; -} - -byte *LoadGIFBuf(char *fname) -{ - gif_image_info *ii=0; - byte *t; - - ii=unpack_gif(fname); - width=ii->wide; - depth=ii->deep; - t=ii->image; - free(ii); - return t; -} - -// ====================== Universal Imaging Interface ======================== - -byte imagetype; - -// ================================= Code ==================================== - -void DetermineFileType(char *fname) -{ - strlwr(fname); - if (!strcmp(fname+(strlen(fname)-3),"pcx")) imagetype=0; - if (!strcmp(fname+(strlen(fname)-3),"gif")) imagetype=1; - if (!strcmp(fname+(strlen(fname)-3),"bmp")) imagetype=2; -} - -void VLoadImage(char *fname, byte *dest) -{ - imagetype=255; - DetermineFileType(fname); - switch (imagetype) - { - case 0: LoadPCX(fname, dest); break; - case 1: err("VLoadImage() for GIF not supported; use VLoadImageBuf()"); break; - case 2: err("VLoadImage() for BMP not supported; use VLoadImageBuf()"); break; - default: err("%s: Unrecognized image type.",fname); - } -} - -byte *VLoadImageBuf(char *fname) -{ - imagetype=255; - DetermineFileType(fname); - switch (imagetype) - { - case 0: return LoadPCXBuf(fname); break; - case 1: return LoadGIFBuf(fname); break; - case 2: return LoadBMPBuf(fname); break; - default: err("%s: Unrecognized image type.",fname); - } - return 0; -} diff --git a/16/v2/source/verge/ENGINE/IMAGE.H b/16/v2/source/verge/ENGINE/IMAGE.H deleted file mode 100755 index 5b0ac2bc..00000000 --- a/16/v2/source/verge/ENGINE/IMAGE.H +++ /dev/null @@ -1,25 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef IMAGE_H -#define IMAGE_H - -word width, depth; - -void VLoadImage(char *fname, byte *dest); -byte *VLoadImageBuf(char *fname); - -#endif diff --git a/16/v2/source/verge/ENGINE/INTER.H b/16/v2/source/verge/ENGINE/INTER.H deleted file mode 100755 index 93bc667c..00000000 --- a/16/v2/source/verge/ENGINE/INTER.H +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if !defined(INTERINC) -#define INTERINC - -#ifdef __WATCOMC__ - #include - #define REGISTERS union REGS - #define SET_AX(r,v) (r).w.ax=(short)(v) - #define SET_BX(r,v) (r).w.bx=(short)(v) - #define SET_CX(r,v) (r).w.cx=(short)(v) - #define SET_DX(r,v) (r).w.dx=(short)(v) - #define INTERRUPT(i,r) int386((i),&(r),&(r)) -#elif defined(__DJGPP__) - #include - #define REGISTERS __dpmi_regs - #define SET_AX(r,v) (r).x.ax=(short)(v) - #define SET_BX(r,v) (r).x.bx=(short)(v) - #define SET_CX(r,v) (r).x.cx=(short)(v) - #define SET_DX(r,v) (r).x.dx=(short)(v) - #define INTERRUPT(i,r) __dpmi_int((i),&(r)) -// #define inp inportb - #define outp outportb - #define outpw outportw -#endif // watcom | djgpp - -#endif // INTERINC diff --git a/16/v2/source/verge/ENGINE/KEYBOARD.H b/16/v2/source/verge/ENGINE/KEYBOARD.H deleted file mode 100755 index e39d3296..00000000 --- a/16/v2/source/verge/ENGINE/KEYBOARD.H +++ /dev/null @@ -1,115 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef KEYBOARD_H -#define KEYBOARD_H - -extern volatile byte key[128]; -extern volatile byte last_pressed; -extern int InitKeyboard(void); -extern void ShutdownKeyboard(void); -#ifdef DJGPP -extern void keyboard_chain(int toggle); -#endif - -/* Constants for keyboard scan-codes */ - -#define SCAN_ESC 0x01 -#define SCAN_1 0x02 -#define SCAN_2 0x03 -#define SCAN_3 0x04 -#define SCAN_4 0x05 -#define SCAN_5 0x06 -#define SCAN_6 0x07 -#define SCAN_7 0x08 -#define SCAN_8 0x09 -#define SCAN_9 0x0a -#define SCAN_0 0x0b -#define SCAN_MINUS 0x0c -#define SCAN_EQUALS 0x0d -#define SCAN_BACKSP 0x0e -#define SCAN_TAB 0x0f -#define SCAN_Q 0x10 -#define SCAN_W 0x11 -#define SCAN_E 0x12 -#define SCAN_R 0x13 -#define SCAN_T 0x14 -#define SCAN_Y 0x15 -#define SCAN_U 0x16 -#define SCAN_I 0x17 -#define SCAN_O 0x18 -#define SCAN_P 0x19 -#define SCAN_LANGLE 0x1a -#define SCAN_RANGLE 0x1b -#define SCAN_ENTER 0x1c -#define SCAN_CTRL 0x1d -#define SCAN_A 0x1e -#define SCAN_S 0x1f -#define SCAN_D 0x20 -#define SCAN_F 0x21 -#define SCAN_G 0x22 -#define SCAN_H 0x23 -#define SCAN_J 0x24 -#define SCAN_K 0x25 -#define SCAN_L 0x26 -#define SCAN_SCOLON 0x27 -#define SCAN_QUOTA 0x28 -#define SCAN_RQUOTA 0x29 -#define SCAN_LSHIFT 0x2a -#define SCAN_BSLASH 0x2b -#define SCAN_Z 0x2c -#define SCAN_X 0x2d -#define SCAN_C 0x2e -#define SCAN_V 0x2f -#define SCAN_B 0x30 -#define SCAN_N 0x31 -#define SCAN_M 0x32 -#define SCAN_COMA 0x33 -#define SCAN_DOT 0x34 -#define SCAN_SLASH 0x35 -#define SCAN_RSHIFT 0x36 -#define SCAN_GREY_STAR 0x37 -#define SCAN_ALT 0x38 -#define SCAN_SPACE 0x39 -#define SCAN_CAPS 0x3a -#define SCAN_F1 0x3b -#define SCAN_F2 0x3c -#define SCAN_F3 0x3d -#define SCAN_F4 0x3e -#define SCAN_F5 0x3f -#define SCAN_F6 0x40 -#define SCAN_F7 0x41 -#define SCAN_F8 0x42 -#define SCAN_F9 0x43 -#define SCAN_F10 0x44 -#define SCAN_NUMLOCK 0x45 -#define SCAN_SCRLOCK 0x46 -#define SCAN_HOME 0x47 -#define SCAN_UP 0x48 -#define SCAN_PGUP 0x49 -#define SCAN_GREY_MINUS 0x4a -#define SCAN_LEFT 0x4b -#define SCAN_PAD_5 0x4c -#define SCAN_RIGHT 0x4d -#define SCAN_GREY_PLUS 0x4e -#define SCAN_END 0x4f -#define SCAN_DOWN 0x50 -#define SCAN_PGDN 0x51 -#define SCAN_INSERT 0x52 -#define SCAN_DEL 0x53 -#define SCAN_F11 0x57 -#define SCAN_F12 0x58 -#endif diff --git a/16/v2/source/verge/ENGINE/KEYBOARD.S b/16/v2/source/verge/ENGINE/KEYBOARD.S deleted file mode 100755 index a781cded..00000000 --- a/16/v2/source/verge/ENGINE/KEYBOARD.S +++ /dev/null @@ -1,227 +0,0 @@ -# -# Copyright (C) 1998 BJ Eirich (aka vecna) -# 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 Lic -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - - .file "keyboard.s" - - .extern ___djgpp_base_address - .extern ___djgpp_ds_alias - .extern ___djgpp_dos_sel - - # public functions and variables: - - .global _key - .global _InitKeyboard - .global _ShutdownKeyboard - .global _keyboard_chain - .global _last_pressed - - .text - - .align 4 - -locking_region_start: - -_key: .space 0x80, 0 -_last_pressed: .byte 0 -old_vector: -old_vector_ofs: .long 0 -old_vector_sel: .word 0 -chain_flag: .long 1 - - - .align 4 - -handler_procedure: - - # - # .. will be called every time a key is pressed/released - # - pushl %eax - pushl %edx - pushw %ds - # - # Load DS with our data selector - # - movw %cs:___djgpp_ds_alias, %ds - # - # Read the scancode from keyboard port and update key[] - # - inb $0x60, %al - movb %al, %dl - andl $0x7f, %edx - testb $0x80, %al - setz _key(%edx) - cmp $127, %al - ja nolastpressed - movb %edx, _last_pressed -nolastpressed: - - # - # Chain if flag is set, otherwise do what's necessary and return - # - cmpl $0, chain_flag - jne handler_chain - # - # Acknowledge keyboard and interrupt contollers - # - inb $0x61, %al - orb $0x80, %al - outb %al, $0x61 - andb $0x7f, %al - outb %al, $0x61 - movb $0x20, %al - outb %al, $0x20 - - popw %ds - popl %edx - popl %eax - sti - iret - - .align 4 - -handler_chain: popw %ds - popl %edx - popl %eax - ljmp %cs:(old_vector) - -locking_region_end: - - - .align 4 -_InitKeyboard: - - # - # int keyboard_init(void); - # - # Initializes the keyboard handler and hooks the keyboard interrupt. - # Returns -1 on failure, zero on success - # - pushl %esi - pushl %edi - pushl %ebx - # - # First, we need to lock the handler and memory it touches, so - # it doesn't get swapped out to disk. - # - leal locking_region_start, %ecx - leal locking_region_end, %edi - subl %ecx, %edi - addl ___djgpp_base_address, %ecx - shldl $16, %ecx, %ebx # ecx -> bx:cx - shldl $16, %edi, %esi # edi -> si:di - movw $0x0600, %ax # lock linear region - int $0x31 - jc init_error - # - # Now we need to save the old interrupt vector, so we can restore - # it later and also to know where to jump if chaining. - # - movw $0x0204, %ax # get pm int vector - movb $0x09, %bl - int $0x31 - movw %cx, old_vector_sel - movl %edx, old_vector_ofs - # - # Make sure we chain after initialization. - # - movl $1, chain_flag - # - # Set the interrupt vector to point to our handler. - # - movw %cs, %cx - leal handler_procedure, %edx - movb $0x09, %bl - movw $0x0205, %ax # set pm int vector - int $0x31 - #* - #* Actually we would have to unlock the locked region on failure - #* here. But since most programs would exit with an error message - #* in such case, there's no need to worry. - #* - -init_error: - - # - # This sets EAX to -1 if CF is set and to 0 atherwise - # - movl $0, %eax - sbbl $0, %eax - - popl %ebx - popl %edi - popl %esi - ret - - - .align 4 -_ShutdownKeyboard: - - # - # void keyboard_close(void); - # - # Shuts the keyboard handler down. - # - pushl %esi - pushl %edi - pushl %ebx - # - # Unlock the region we locked at initialization - # - leal locking_region_start, %ecx - leal locking_region_end, %edi - subl %ecx, %edi - addl ___djgpp_base_address, %ecx - shldl $16, %ecx, %ebx - shldl $16, %edi, %esi - movw $0x0601, %ax # unlock linear region - int $0x31 - # - # Restore the interrupt vector to its previous value - # - movw old_vector_sel, %cx - movl old_vector_ofs, %edx - movb $0x09, %bl - movw $0x0205, %ax # set pm int vector - int $0x31 - - popl %ebx - popl %edi - popl %esi - ret - # - # void keyboard_chain(int toggle); - # - .align 4 -_keyboard_chain: - cmpl $0, 4(%esp) - je chain_off -chain_on: - - # - # Set the chain_flag and clear BIOS shift/ctrl/alt status bits: - # - movl $1, chain_flag - - push %es - movw ___djgpp_dos_sel, %es - andb $0xf0, %es:0x417 - pop %es - jmp chain_done -chain_off: - movl $0, chain_flag -chain_done: ret - diff --git a/16/v2/source/verge/ENGINE/MAIN.H b/16/v2/source/verge/ENGINE/MAIN.H deleted file mode 100755 index fde93675..00000000 --- a/16/v2/source/verge/ENGINE/MAIN.H +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef MAIN_H -#define MAIN_H - -//void *valloc(int amount); -void err(char *message, ...); -int sgn(int x); -void ver(); -void CheckMessages(); -void Log(char *message, ...); -void Logp(char *message, ...); -void LogDone(); -void InitMouse(int, int); -void ReadMouse(); -void SetMouse(int, int); - -extern char startmap[80], nocdaudio; -extern int mx, my, mb; - -#define vfree(x) if (x) { free(x); x=0; } - -#ifndef DJGPP -#define strncasecmp strnicmp -#define strcasecmp strcmpi -#endif - -#endif diff --git a/16/v2/source/verge/ENGINE/MAKEFILE b/16/v2/source/verge/ENGINE/MAKEFILE deleted file mode 100755 index f557fa31..00000000 --- a/16/v2/source/verge/ENGINE/MAKEFILE +++ /dev/null @@ -1,7 +0,0 @@ -CC = gcc -CFLAGS = -s -Wall -Werror - -OBJ = a_memory.o conlib.o console.o controls.o engine.o entity.o font.o image.o keyboard.o message.o modeinit.o render.o startup.o timer.o verge.o vc.o vdriver.o vfile.o fli.o sound.o mikmod.a - -verge: $(OBJ) - diff --git a/16/v2/source/verge/ENGINE/MESSAGE.C b/16/v2/source/verge/ENGINE/MESSAGE.C deleted file mode 100755 index dd3520e6..00000000 --- a/16/v2/source/verge/ENGINE/MESSAGE.C +++ /dev/null @@ -1,110 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "verge.h" - -// ================================= Data ==================================== - -struct message -{ - char text[44]; // message text - int exptime; // message expire time -}; - -struct message messages[6]; // 5-message buffer -byte num_msgs=0; // number of active messages - -// -- cpu usage -- - -int cputimer=0, frames=0; -char runprf[3]; -// -- final numbers -- -int fps=0; -char profile[3]; - -// ================================= Code ==================================== - -void CheckMessageExpirations() -{ int i; - - for (i=0; imessages[i].exptime) - { - memcpy(messages[i].text, messages[i+1].text, (48*(num_msgs-i+1))); - num_msgs--; - } -} - -void RenderGUI() -{ int i; - - CheckMessageExpirations(); - for (i=0; i -#endif - -#include -#include -#include -#include - -#ifndef __OS2__ -#include -#endif - -#include "wildfile.h" -#include "mikmod.h" - -char helptext[]= - -"Available switches (CaSe SeNsItIvE!):\n" -"\n" -" /d x use device-driver #x for output (0 is autodetect). Default=0\n" -" /ld List all available device-drivers\n" -" /ll List all available loaders\n" -" /x disables protracker extended speed\n" -" /p disables panning effects (9fingers.mod)\n" -" /v xx Sets volume from 0 (silence) to 100. Default=100\n" -" /f xxxx Sets mixing frequency. Default=44100\n" -" /m Force mono output (so sb-pro can mix at 44100)\n" -" /8 Force 8 bit output\n" -" /i Use interpolated mixing\n" -" /r Restart a module when it's done playing"; - - -/* - declarations for boring old sys-v style getopt *yawn*: -*/ -int getopt(int argc, char *argv[], char *optionS); -extern char *optarg; -extern int optind; -extern int opterr; - - -void tickhandler(void) -{ - MP_HandleTick(); /* play 1 tick of the module */ - MD_SetBPM(mp_bpm); -} - - -int main(int argc,char *argv[]) -{ - UNIMOD *mf; - int cmderr=0; /* error in commandline flag */ - int morehelp=0; /* set if user wants more help */ - int quit; - int t; - static int nargc; - static char **nargv; - - puts(mikbanner); - - /* Expand wildcards on commandline */ - - nargc=argc; nargv=argv; -#ifndef __DJGPP__ - MyGlob(&nargc,&nargv,0); -#else - setvbuf(stdout, NULL, _IONBF, 0); - __djgpp_set_ctrl_c(0); -#endif - - /* - Initialize soundcard parameters.. you _have_ to do this - before calling MD_Init(), and it's illegal to change them - after you've called MD_Init() - */ - - md_mixfreq =44100; /* standard mixing freq */ - md_dmabufsize =20000; /* standard dma buf size */ - md_mode =DMODE_16BITS|DMODE_STEREO; /* standard mixing mode */ - md_device =0; /* standard device: autodetect */ - - /* - Register the loaders we want to use.. - */ - - ML_RegisterLoader(&load_m15); /* if you use m15load, register it as first! */ - ML_RegisterLoader(&load_mod); - ML_RegisterLoader(&load_mtm); - ML_RegisterLoader(&load_s3m); - ML_RegisterLoader(&load_stm); - ML_RegisterLoader(&load_ult); - ML_RegisterLoader(&load_uni); - ML_RegisterLoader(&load_xm); - - /* - Register the drivers we want to use: - */ - - MD_RegisterDriver(&drv_nos); -#ifdef __OS2__ - MD_RegisterDriver(&drv_os2); -#elif defined(__WIN32__) - MD_RegisterDriver(&drv_w95); -#else - MD_RegisterDriver(&drv_ss); - MD_RegisterDriver(&drv_sb); - MD_RegisterDriver(&drv_gus); -#endif - - MD_RegisterPlayer(tickhandler); - - /* Parse option switches using standard getopt function: */ - - opterr=0; - - while( !cmderr && - (t=getopt(nargc,nargv,"ohxpm8irv:f:l:d:")) != EOF ){ - - switch(t){ - - case 'd': - md_device=atoi(optarg); - break; - - case 'l': - if(optarg[0]=='d') MD_InfoDriver(); - else if(optarg[0]=='l') ML_InfoLoader(); - else{ - cmderr=1; - break; - } - exit(0); - - case 'r': - mp_loop=1; - break; - - case 'm': - md_mode&=~DMODE_STEREO; - break; - - case '8': - md_mode&=~DMODE_16BITS; - break; - - case 'i': - md_mode|=DMODE_INTERP; - break; - - case 'x': - mp_extspd=0; - break; - - case 'p': - mp_panning=0; - break; - - case 'v': - if((mp_volume=atoi(optarg))>100) mp_volume=100; - break; - - case 'f': - md_mixfreq=atol(optarg); - break; - - case 'h': - morehelp=1; - cmderr=1; - break; - - case '?': - puts("\07Invalid switch or option needs an argument\n"); - cmderr=1; - break; - } - } - - if(cmderr || optind>=nargc){ - - /* - there was an error in the commandline, or there were no true - arguments, so display a usage message - */ - - puts("Usage: MIKMOD [switches] ... \n"); - - if(morehelp) - puts(helptext); - else - puts("Type MIKMOD /h for more help."); - - exit(-1); - } - - /* initialize soundcard */ - - if(!MD_Init()){ - printf("Driver error: %s.\n",myerr); - return 0; - } - - printf("Using %s for %d bit %s %s sound at %u Hz\n\n", - md_driver->Name, - (md_mode&DMODE_16BITS) ? 16:8, - (md_mode&DMODE_INTERP) ? "interpolated":"normal", - (md_mode&DMODE_STEREO) ? "stereo":"mono", - md_mixfreq); - -#ifdef __OS2__ - DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, 5L, 0UL ); -#endif - - for(quit=0; !quit && optind exit with errormsg. */ - - if(mf==NULL){ - printf("MikMod Error: %s\n",myerr); - break; - } - - /* initialize modplayer to play this module */ - - MP_Init(mf); - - printf( "Songname: %s\n" - "Modtype : %s\n" - "Periods : %s,%s\n", - mf->songname, - mf->modtype, - (mf->flags&UF_XMPERIODS) ? "XM type" : "mod type", - (mf->flags&UF_LINEAR) ? "Linear" : "Log"); - - /* - set the number of voices to use.. you - could add extra channels here (e.g. md_numchn=mf->numchn+4; ) - to use for your own soundeffects: - */ - - md_numchn=mf->numchn; - - /* start playing the module: */ - - MD_PlayStart(); - - while(!MP_Ready()){ - - char c; - - c=kbhit() ? getch() : 0; - - if(c=='+') - MP_NextPosition(); - else if(c=='-') - MP_PrevPosition(); - else if(c==0x1b){ - quit=1; - break; - } - else if(c==' ') break; - - MD_Update(); - - /* wait a bit */ - -#if defined(__OS2__) - DosSleep(40); /* hmmmm */ -#elif defined(__WIN32__) - Sleep(10); -#elif defined(__DJGPP__) - /* no wait for djgpp ? */ -#else - delay(10); -#endif - printf("\rsngpos:%d patpos:%d sngspd %d bpm %d ",mp_sngpos,mp_patpos,mp_sngspd,mp_bpm); - } - - MD_PlayStop(); /* stop playing */ - ML_Free(mf); /* and free the module */ - puts("\n"); - } - MD_Exit(); - return 0; -} diff --git a/16/v2/source/verge/ENGINE/MIKMOD.H b/16/v2/source/verge/ENGINE/MIKMOD.H deleted file mode 100755 index 0111ccb3..00000000 --- a/16/v2/source/verge/ENGINE/MIKMOD.H +++ /dev/null @@ -1,580 +0,0 @@ -#ifndef MIKMOD_H -#define MIKMOD_H - -#include -#include "mtypes.h" /* include atomic mikmod types */ - - -#define mikbanner \ -"=======================================================================\n" \ -"MIKMOD v2.10 - Portable version - Programmed by MikMak of HaRDCoDE '95\n" \ -"=======================================================================\n" \ -"This program is SHAREWARE - Read MIKMOD.TXT for more info\n" \ -"E-Mail : mikmak@stack.urc.tue.nl\n" - - -/* - error variables: - =============== -*/ - -extern char *ERROR_ALLOC_STRUCT; -extern char *ERROR_LOADING_PATTERN; -extern char *ERROR_LOADING_TRACK; -extern char *ERROR_LOADING_HEADER; -extern char *ERROR_NOT_A_MODULE; -extern char *ERROR_LOADING_SAMPLEINFO; -extern char *ERROR_OUT_OF_HANDLES; -extern char *ERROR_SAMPLE_TOO_BIG; -extern char *myerr; - - - -#define _mm_rewind(x) _mm_fseek(x,0,SEEK_SET) -int _mm_fseek(FILE *stream,long offset,int whence); -void _mm_setiobase(long iobase); -long _mm_ftell(FILE *stream); - - -extern SBYTE _mm_read_SBYTE (FILE *fp); -extern UBYTE _mm_read_UBYTE (FILE *fp); - -extern SWORD _mm_read_M_SWORD (FILE *fp); -extern SWORD _mm_read_I_SWORD (FILE *fp); - -extern UWORD _mm_read_M_UWORD(FILE *fp); -extern UWORD _mm_read_I_UWORD(FILE *fp); - -extern SLONG _mm_read_M_SLONG (FILE *fp); -extern SLONG _mm_read_I_SLONG (FILE *fp); - -extern ULONG _mm_read_M_ULONG(FILE *fp); -extern ULONG _mm_read_I_ULONG(FILE *fp); - -extern int _mm_read_str(char *str, int size, FILE *fp); - -extern int _mm_read_SBYTES (SBYTE *buffer, int number, FILE *fp); -extern int _mm_read_UBYTES (UBYTE *buffer, int number, FILE *fp); - -extern int _mm_read_M_SWORDS (SWORD *buffer, int number, FILE *fp); -extern int _mm_read_I_SWORDS (SWORD *buffer, int number, FILE *fp); - -extern int _mm_read_M_UWORDS (UWORD *buffer, int number, FILE *fp); -extern int _mm_read_I_UWORDS (UWORD *buffer, int number, FILE *fp); - -extern int _mm_read_M_SLONGS (SLONG *buffer, int number, FILE *fp); -extern int _mm_read_I_SLONGS (SLONG *buffer, int number, FILE *fp); - -extern int _mm_read_M_ULONGS (ULONG *buffer, int number, FILE *fp); -extern int _mm_read_I_ULONGS (ULONG *buffer, int number, FILE *fp); - - -extern void _mm_write_SBYTE (SBYTE data,FILE *fp); -extern void _mm_write_UBYTE (UBYTE data,FILE *fp); - -extern void _mm_write_M_SWORD (SWORD data,FILE *fp); -extern void _mm_write_I_SWORD (SWORD data,FILE *fp); - -extern void _mm_write_M_UWORD (UWORD data,FILE *fp); -extern void _mm_write_I_UWORD (UWORD data,FILE *fp); - -extern void _mm_write_M_SLONG (SLONG data,FILE *fp); -extern void _mm_write_I_SLONG (SLONG data,FILE *fp); - -extern void _mm_write_M_ULONG (ULONG data,FILE *fp); -extern void _mm_write_I_ULONG (ULONG data,FILE *fp); - -extern void _mm_write_SBYTES (SBYTE *data, int number,FILE *fp); -extern void _mm_write_UBYTES (UBYTE *data, int number,FILE *fp); - -extern void _mm_write_M_SWORDS (SWORD *data, int number,FILE *fp); -extern void _mm_write_I_SWORDS (SWORD *data, int number,FILE *fp); - -extern void _mm_write_M_UWORDS (UWORD *data, int number,FILE *fp); -extern void _mm_write_I_UWORDS (UWORD *data, int number,FILE *fp); - -extern void _mm_write_M_SLONGS (SLONG *data, int number,FILE *fp); -extern void _mm_write_I_SLONGS (SLONG *data, int number,FILE *fp); - -extern void _mm_write_M_ULONGS (ULONG *data, int number,FILE *fp); -extern void _mm_write_I_ULONGS (ULONG *data, int number,FILE *fp); - - -/************************************************************************** -****** Unitrack stuff: **************************************************** -**************************************************************************/ - -/* - prototypes: -*/ - -void UniSetRow(UBYTE *t); -UBYTE UniGetByte(void); -UBYTE *UniFindRow(UBYTE *t,UWORD row); -void UniReset(void); -void UniWrite(UBYTE data); -void UniNewline(void); -void UniInstrument(UBYTE ins); -void UniNote(UBYTE note); -void UniPTEffect(UBYTE eff,UBYTE dat); -UBYTE *UniDup(void); -void UniSkipOpcode(UBYTE op); -BOOL UniInit(void); -void UniCleanup(void); -UWORD TrkLen(UBYTE *t); -BOOL MyCmp(UBYTE *a,UBYTE *b,UWORD l); - -/* - all known effects: -*/ - -enum { - UNI_NOTE=1, - UNI_INSTRUMENT, - UNI_PTEFFECT0, - UNI_PTEFFECT1, - UNI_PTEFFECT2, - UNI_PTEFFECT3, - UNI_PTEFFECT4, - UNI_PTEFFECT5, - UNI_PTEFFECT6, - UNI_PTEFFECT7, - UNI_PTEFFECT8, - UNI_PTEFFECT9, - UNI_PTEFFECTA, - UNI_PTEFFECTB, - UNI_PTEFFECTC, - UNI_PTEFFECTD, - UNI_PTEFFECTE, - UNI_PTEFFECTF, - UNI_S3MEFFECTA, - UNI_S3MEFFECTD, - UNI_S3MEFFECTE, - UNI_S3MEFFECTF, - UNI_S3MEFFECTI, - UNI_S3MEFFECTQ, - UNI_S3MEFFECTT, - UNI_XMEFFECTA, - UNI_XMEFFECTG, - UNI_XMEFFECTH, - UNI_XMEFFECTP -}; - - -/************************************************************************** -****** mikmod types: ****************************************************** -**************************************************************************/ - - -/* - Sample format flags: -*/ - -#define SF_16BITS 1 -#define SF_SIGNED 2 -#define SF_DELTA 4 -#define SF_BIG_ENDIAN 8 -#define SF_LOOP 16 -#define SF_BIDI 32 -#define SF_OWNPAN 64 -#define SF_REVERSE 128 - - -/* - Envelope flags: -*/ - -#define EF_ON 1 -#define EF_SUSTAIN 2 -#define EF_LOOP 4 - - -/* - Unimod flags -*/ - -#define UF_XMPERIODS 1 /* if set use XM periods/finetuning */ -#define UF_LINEAR 2 /* if set use LINEAR periods */ - - -typedef struct ENVPT{ - SWORD pos; - SWORD val; -} ENVPT; - - -typedef struct SAMPLE{ - UWORD c2spd; /* finetune frequency */ - SBYTE transpose; /* transpose value */ - UBYTE volume; /* volume 0-64 */ - UBYTE panning; /* panning */ - ULONG length; /* length of sample (in samples!) */ - ULONG loopstart; /* repeat position (relative to start, in samples) */ - ULONG loopend; /* repeat end */ - UWORD flags; /* sample format */ - ULONG seekpos; /* seek position in file */ - char *samplename; /* name of the sample */ - SWORD handle; /* sample handle */ -} SAMPLE; - - -typedef struct INSTRUMENT{ - UBYTE numsmp; - UBYTE samplenumber[96]; - - UBYTE volflg; /* bit 0: on 1: sustain 2: loop */ - UBYTE volpts; - UBYTE volsus; - UBYTE volbeg; - UBYTE volend; - ENVPT volenv[12]; - - UBYTE panflg; /* bit 0: on 1: sustain 2: loop */ - UBYTE panpts; - UBYTE pansus; - UBYTE panbeg; - UBYTE panend; - ENVPT panenv[12]; - - UBYTE vibtype; - UBYTE vibsweep; - UBYTE vibdepth; - UBYTE vibrate; - - UWORD volfade; - char *insname; - SAMPLE *samples; -} INSTRUMENT; - - -/* - MikMod UNImod types: - ==================== -*/ - -typedef struct UNIMOD{ - UBYTE numchn; /* number of channels */ - UWORD numpos; /* number of positions in this song */ - UWORD reppos; /* restart position */ - UWORD numpat; /* number of patterns in this song */ - UWORD numtrk; /* number of tracks */ - UWORD numins; /* number of samples */ - UBYTE initspeed; /* */ - UBYTE inittempo; /* */ - UBYTE positions[256]; /* all positions */ - UBYTE panning[32]; /* 32 panning positions */ - UBYTE flags; /* */ - char *songname; /* name of the song */ - char *modtype; /* string type of module */ - char *comment; /* module comments */ - INSTRUMENT *instruments; /* all samples */ - UWORD *patterns; /* array of PATTERN */ - UWORD *pattrows; /* array of number of rows for each pattern */ - UBYTE **tracks; /* array of pointers to tracks */ -} UNIMOD; - - -/************************************************************************** -****** Loader stuff: ****************************************************** -**************************************************************************/ - -/* - loader structure: -*/ - -typedef struct LOADER{ - struct LOADER *next; - char *type; - char *version; - BOOL (*Init)(void); - BOOL (*Test)(void); - BOOL (*Load)(void); - void (*Cleanup)(void); -} LOADER; - - -/* - public loader variables: -*/ - -extern UNIMOD of; -extern FILE *modfp; -extern UWORD finetune[16]; - - -/* - main loader prototypes: -*/ - -void ML_InfoLoader(void); -void ML_RegisterLoader(LOADER *ldr); -UNIMOD *ML_LoadFP(FILE *fp); -UNIMOD *ML_LoadFN(char *filename); -void ML_Free(UNIMOD *mf); - - -/* - other loader prototypes: (used by the loader modules) -*/ - -BOOL InitTracks(void); -void AddTrack(UBYTE *tr); -BOOL ReadComment(UWORD len); -BOOL AllocPatterns(void); -BOOL AllocTracks(void); -BOOL AllocInstruments(void); -BOOL AllocSamples(INSTRUMENT *i); -char *DupStr(char *s,UWORD len); -void *MyMalloc(size_t size); -void *MyCalloc(size_t nitems,size_t size); - - -/* - Declare external loaders: -*/ -extern LOADER load_uni; -extern LOADER load_mod; -extern LOADER load_m15; -extern LOADER load_mtm; -extern LOADER load_s3m; -extern LOADER load_stm; -extern LOADER load_ult; -extern LOADER load_xm; - - -/************************************************************************** -****** Wavload stuff: ***************************************************** -**************************************************************************/ - -SAMPLE *MW_LoadWavFP(FILE *fp); -SAMPLE *MW_LoadWavFN(char *filename); -void MW_FreeWav(SAMPLE *si); - - -/************************************************************************** -****** Driver stuff: ****************************************************** -**************************************************************************/ - -/* - max. number of handles a driver has to provide. (not strict) -*/ - -#define MAXSAMPLEHANDLES 128 - - -/* - possible mixing mode bits: -*/ - -#define DMODE_STEREO 1 -#define DMODE_16BITS 2 -#define DMODE_INTERP 4 - - -/* - driver structure: -*/ - -typedef struct DRIVER{ - struct DRIVER *next; - char *Name; - char *Version; - BOOL (*IsPresent) (void); - SWORD (*SampleLoad) (FILE *fp,ULONG size,ULONG reppos,ULONG repend,UWORD flags); - void (*SampleUnLoad) (SWORD handle); - BOOL (*Init) (void); - void (*Exit) (void); - void (*PlayStart) (void); - void (*PlayStop) (void); - void (*Update) (void); - void (*VoiceSetVolume) (UBYTE voice,UBYTE vol); - void (*VoiceSetFrequency) (UBYTE voice,ULONG frq); - void (*VoiceSetPanning) (UBYTE voice,UBYTE pan); - void (*VoicePlay) (UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); -} DRIVER; - - -/* - public driver variables: -*/ - -extern DRIVER *md_driver; -extern UWORD md_device; -extern UWORD md_mixfreq; -extern UWORD md_dmabufsize; -extern UWORD md_mode; -extern UBYTE md_numchn; -extern UBYTE md_bpm; -extern void (*md_player)(void); - -/* - main driver prototypes: -*/ - -void MD_InfoDriver(void); -void MD_RegisterDriver(DRIVER *drv); -void MD_RegisterPlayer(void (*plr)(void)); -SWORD MD_SampleLoad(FILE *fp,ULONG size,ULONG reppos,ULONG repend,UWORD flags); -void MD_SampleUnLoad(SWORD handle); -BOOL MD_Init(void); -void MD_Exit(void); -void MD_PlayStart(void); -void MD_PlayStop(void); -void MD_SetBPM(UBYTE bpm); -void MD_Update(void); -void MD_VoiceSetVolume(UBYTE voice,UBYTE ivol); -void MD_VoiceSetFrequency(UBYTE voice,ULONG frq); -void MD_VoiceSetPanning(UBYTE voice,ULONG pan); -void MD_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); -void SL_Init(FILE *fp,UWORD infmt,UWORD outfmt); -void SL_Load(void *buffer,ULONG length); - -/* - Declare external drivers: -*/ - -extern DRIVER drv_gus; /* gravis ultrasound driver */ -extern DRIVER drv_sb; /* soundblaster DSP driver */ -extern DRIVER drv_ss; /* ensoniq soundscape driver */ -extern DRIVER drv_nos; /* nosound driver */ -extern DRIVER drv_raw; /* file output driver */ -extern DRIVER drv_w95; /* win95 driver */ -extern DRIVER drv_awe; /* experimental SB-AWE driver */ -extern DRIVER drv_vox; /* linux voxware driver */ -extern DRIVER drv_af; /* Dec Alpha AudioFile driver */ -extern DRIVER drv_sun; /* Sun driver */ -extern DRIVER drv_os2; /* Os2 driver */ -extern DRIVER drv_tim; /* timing driver */ - -/************************************************************************** -****** Player stuff: ****************************************************** -**************************************************************************/ - - -typedef struct ENVPR{ - UBYTE flg; /* envelope flag */ - UBYTE pts; /* number of envelope points */ - UBYTE sus; /* envelope sustain index */ - UBYTE beg; /* envelope loop begin */ - UBYTE end; /* envelope loop end */ - SWORD p; /* current envelope counter */ - UWORD a; /* envelope index a */ - UWORD b; /* envelope index b */ - ENVPT *env; /* envelope points */ -} ENVPR; - - -typedef struct AUDTMP{ - INSTRUMENT *i; - SAMPLE *s; - - UWORD fadevol; /* fading volume */ - - ENVPR venv; - ENVPR penv; - - UBYTE keyon; /* if true=key is pressed. */ - UBYTE kick; /* if true=sample has to be restarted */ - UBYTE sample; /* which sample number (0-31) */ - SWORD handle; /* which sample-handle */ - - ULONG start; /* The start byte index in the sample */ - - UBYTE panning; /* panning position */ - UBYTE pansspd; /* panslide speed */ - - SBYTE volume; /* amiga volume (0 t/m 64) to play the sample at */ - UWORD period; /* period to play the sample at */ - - /* You should not have to use the values - below in the player routine */ - - SBYTE transpose; - - UBYTE note; /* */ - - SWORD ownper; - SWORD ownvol; - - UBYTE *row; /* row currently playing on this channel */ - - SBYTE retrig; /* retrig value (0 means don't retrig) */ - UWORD c2spd; /* what finetune to use */ - - SBYTE tmpvolume; /* tmp volume */ - - UWORD tmpperiod; /* tmp period */ - UWORD wantedperiod; /* period to slide to (with effect 3 or 5) */ - - UWORD slidespeed; /* */ - UWORD portspeed; /* noteslide speed (toneportamento) */ - - UBYTE s3mtremor; /* s3m tremor (effect I) counter */ - UBYTE s3mtronof; /* s3m tremor ontime/offtime */ - - UBYTE s3mvolslide; /* last used volslide */ - - UBYTE s3mrtgspeed; /* last used retrig speed */ - UBYTE s3mrtgslide; /* last used retrig slide */ - - UBYTE glissando; /* glissando (0 means off) */ - UBYTE wavecontrol; /* */ - - SBYTE vibpos; /* current vibrato position */ - UBYTE vibspd; /* "" speed */ - UBYTE vibdepth; /* "" depth */ - - SBYTE trmpos; /* current tremolo position */ - UBYTE trmspd; /* "" speed */ - UBYTE trmdepth; /* "" depth */ - - UWORD soffset; /* last used sample-offset (effect 9) */ -} AUDTMP; - - -extern AUDTMP mp_audio[32]; /* max eight channels */ -extern UBYTE mp_bpm; /* beats-per-minute speed */ -extern UWORD mp_patpos; /* current row number (0-63) */ -extern SWORD mp_sngpos; /* current song position */ -extern UWORD mp_sngspd; /* current songspeed */ - -extern BOOL mp_loop; -extern BOOL mp_panning; -extern BOOL mp_extspd; -extern UBYTE mp_volume; - -/* - player prototypes: -*/ - -int MP_Ready(void); -void MP_NextPosition(void); -void MP_PrevPosition(void); -void MP_SetPosition(UWORD pos); -void MP_HandleTick(void); -void MP_Init(UNIMOD *m); - - -/************************************************************************** -****** Virtual channel stuff: ********************************************* -**************************************************************************/ - -BOOL VC_Init(void); -void VC_Exit(void); - -void VC_PlayStart(void); -void VC_PlayStop(void); - -SWORD VC_SampleLoad(FILE *fp,ULONG size,ULONG reppos,ULONG repend,UWORD flags); -void VC_SampleUnload(SWORD handle); - -void VC_WriteSamples(SBYTE *buf,UWORD todo); -UWORD VC_WriteBytes(SBYTE *buf,UWORD todo); -void VC_SilenceBytes(SBYTE *buf,UWORD todo); - -void VC_VoiceSetVolume(UBYTE voice,UBYTE vol); -void VC_VoiceSetFrequency(UBYTE voice,ULONG frq); -void VC_VoiceSetPanning(UBYTE voice,UBYTE pan); -void VC_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); - -#endif diff --git a/16/v2/source/verge/ENGINE/MODE13H.C b/16/v2/source/verge/ENGINE/MODE13H.C deleted file mode 100755 index 2dcbf9ce..00000000 --- a/16/v2/source/verge/ENGINE/MODE13H.C +++ /dev/null @@ -1,881 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include "verge.h" - -// ================================= Data ==================================== - -byte *screen, *screenx; // virscr | realscr - -// ================================= Code ==================================== - -void SetMode(int mode) -{ - REGISTERS r; - SET_AX(r, mode); - INTERRUPT(0x10, r); -} - -int Mode13hShutdown(void) -{ - SetMode(0x3); - free(screen); - return 0; -} - -void xShowPage(int startofs) -{ - asm("movl _screen, %%esi \n\t" - "addl %0, %%esi \n\t" - "movl _screenx, %%edi \n\t" - "movl $200, %%eax \n\t" -"lineloop: \n\t" - "movl $80, %%ecx \n\t" - "rep \n\t" - "movsl \n\t" - "addl $32, %%esi \n\t" - "decl %%eax \n\t" - "jnz lineloop \n\t" - : - : "m" (startofs) - : "esi", "edi", "cc", "eax", "ecx"); -} - -int Mode13hShowPage(void) -{ - RenderGUI(); - cpubyte=PFLIP; - xShowPage((16*352)+16); - cpubyte=ETC; - return 0; -} - -int Mode13hCopySprite(int x, int y, int width, int height, byte *src) -{ - cpubyte=RENDER; - - asm("movl %3, %%edx \n\t" - "movl %4, %%esi \n\t" -"csl0: \n\t" - "movl %1, %%eax \n\t" - "imul $352, %%eax \n\t" - "addl %0, %%eax \n\t" - "addl _screen, %%eax \n\t" - "movl %%eax, %%edi \n\t" - "movl %2, %%ecx \n\t" - "shrl $2, %%ecx \n\t" - "repz \n\t" - "movsl \n\t" - "incl %1 \n\t" - "decl %%edx \n\t" - "jnz csl0 \n\t" - : - : "m" (x), "m" (y), "m" (width), "m" (height), "m" (src) - : "eax","edx","esi","edi","ecx","cc" ); - cpubyte=ETC; - return 0; -} - -int Mode13hCopyTile(int x, int y, byte *spr) -{ - cpubyte=RENDER; - - asm("movl $16, %%ecx \n\t" - "movl %2, %%esi \n\t" - "movl %1, %%edi \n\t" - "imul $352, %%edi \n\t" - "addl %0, %%edi \n\t" - "addl _screen, %%edi \n\t" -" ctl0: \n\t" - "movl (%%edi), %%eax \n\t" - "andl $0, %%eax \n\t" - "orl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - "movl 4(%%edi), %%eax \n\t" - "andl $0, %%eax \n\t" - "orl 4(%%esi), %%eax \n\t" - "movl %%eax, 4(%%edi) \n\t" - "movl 8(%%edi), %%eax \n\t" - "andl $0, %%eax \n\t" - "orl 8(%%esi), %%eax \n\t" - "movl %%eax, 8(%%edi) \n\t" - "movl 12(%%edi), %%eax \n\t" - "andl $0, %%eax \n\t" - "orl 12(%%esi), %%eax \n\t" - "movl %%eax, 12(%%edi) \n\t" - "addl $16, %%esi \n\t" - "addl $352, %%edi \n\t" - "decl %%ecx \n\t" - "jnz ctl0 \n\t" - : - : "m" (x), "m" (y), "m" (spr) - : "eax","ecx","esi","edi","cc" ); - cpubyte=ETC; - return 0; -} - -int Mode13hTCopySprite(int x, int y, int width, int height, byte *src) -{ - cpubyte=RENDER; - - asm("movl %3, %%ecx \n\t" - "movl %4, %%esi \n\t" -"tcsl0: \n\t" - "movl %1, %%eax \n\t" - "imul $352, %%eax \n\t" - "addl %0, %%eax \n\t" - "addl _screen, %%eax \n\t" - "movl %%eax, %%edi \n\t" - "movl %2, %%edx \n\t" -"drawloop: \n\t" - "lodsb \n\t" - "orb %%al, %%al \n\t" - "jz nodraw \n\t" - "stosb \n\t" - "decl %%edx \n\t" - "jz endline \n\t" - "jmp drawloop \n\t" -"nodraw: \n\t" - "incl %%edi \n\t" - "decl %%edx \n\t" - "jnz drawloop \n\t" -"endline: \n\t" - "incl %1 \n\t" - "decl %%ecx \n\t" - "jnz tcsl0 \n\t" - : - : "m" (x), "m" (y), "m" (width), "m" (height), "m" (src) - : "eax","edx","esi","edi","ecx","cc" ); - - cpubyte=ETC; - return 0; -} - -int Mode13hTCopyTile(int x, int y, byte *spr, byte *matte) -{ - cpubyte=RENDER; - asm("movl $16, %%ecx \n\t" - "movl %2, %%esi \n\t" - "movl %1, %%edi \n\t" - "imul $352, %%edi \n\t" - "addl %0, %%edi \n\t" - "addl _screen, %%edi \n\t" - "movl %3, %%edx \n\t" -"tctl0: \n\t" - "movl (%%edi), %%eax \n\t" - "andl (%%edx), %%eax \n\t" - "orl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - "movl 4(%%edi), %%eax \n\t" - "andl 4(%%edx), %%eax \n\t" - "orl 4(%%esi), %%eax \n\t" - "movl %%eax, 4(%%edi) \n\t" - "movl 8(%%edi), %%eax \n\t" - "andl 8(%%edx), %%eax \n\t" - "orl 8(%%esi), %%eax \n\t" - "movl %%eax, 8(%%edi) \n\t" - "movl 12(%%edi), %%eax \n\t" - "andl 12(%%edx), %%eax \n\t" - "orl 12(%%esi), %%eax \n\t" - "movl %%eax, 12(%%edi) \n\t" - "addl $16, %%esi \n\t" - "addl $352, %%edi \n\t" - "addl $16, %%edx \n\t" - "decl %%ecx \n\t" - "jnz tctl0 \n\t" - : - : "m" (x), "m" (y), "m" (spr), "m" (matte) - : "eax","ecx","edx","esi","edi","cc" ); - - cpubyte=ETC; - return 0; -} - -int Mode13hCCopySprite(int x,int y,int width,int height,byte *src) -{ - byte *s,*d; - int xl,yl,xs,ys; - int cx1=0, cy1=0, cx2=tsx-1, cy2=tsy-1; - - cpubyte=RENDER; - - xl=width; - yl=height; - xs=ys=0; - - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (x0 && th>0) dys=tsx-xm; - else if (tw>0 && th<0) dys=(0-tsx)-xm; - else if (tw<0 && th>0) dys=tsx+xm; - else if (tw<0 && th<0) dys=(0-tsx)+xm; - - d = screen+(y*tsx)+x; - for (i=0;i>16)]; - d+=xd; - sx+=xs; - } - d+=dys; - sy+=ys; - s+=(sy>>16)*w; - sy&=0xffff; - } - cpubyte=ETC; - return 0; -} - -int Mode13hRenderMAPLine(int x, int y, int yofs, word *map) -{ - cpubyte=RENDER; - asm("movl %1, %%edi \n\t" - "imul $352, %%edi \n\t" - "addl %0, %%edi \n\t" - "addl _screen, %%edi \n\t" - "movl $22, %%ebx \n\t" - "movl %3, %%ecx \n\t" -"tileloop: \n\t" - "movw (%%ecx), %%ax \n\t" - "movzwl %%ax, %%edx \n\t" - "shll $1, %%edx \n\t" - "addl _tileidx, %%edx \n\t" - "movw (%%edx), %%ax \n\t" - "movzwl %%ax, %%esi \n\t" - "shll $8, %%esi \n\t" - "addl _vsp, %%esi \n\t" - "movl %2, %%eax \n\t" - "shll $4, %%eax \n\t" - "addl %%eax, %%esi \n\t" - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - "movl 4(%%esi), %%eax \n\t" - "movl %%eax, 4(%%edi) \n\t" - "movl 8(%%esi), %%eax \n\t" - "movl %%eax, 8(%%edi) \n\t" - "movl 12(%%esi), %%eax \n\t" - "movl %%eax, 12(%%edi) \n\t" - "addl $16, %%edi \n\t" - "addl $2, %%ecx \n\t" - "decl %%ebx \n\t" - "jnz tileloop \n\t" - : - : "m" (x), "m" (y), "m" (yofs), "m" (map) - : "eax","ebx","ecx","edx","esi","edi","cc" ); - - cpubyte=ETC; - return 0; -} - -int Mode13hTRenderMAPLine(int x, int y, int yofs, word *map) -{ - cpubyte=RENDER; - asm("movl %1, %%edi \n\t" - "imul $352, %%edi \n\t" - "addl %0, %%edi \n\t" - "addl _screen, %%edi \n\t" - "movl $22, %%ebx \n\t" - "movl %3, %%ecx \n\t" -"tileloop1: \n\t" - "movw (%%ecx), %%ax \n\t" - "movzwl %%ax, %%edx \n\t" - "shll $1, %%edx \n\t" - "addl _tileidx, %%edx \n\t" - "movw (%%edx), %%ax \n\t" - "orw %%ax, %%ax \n\t" - "jz next1 \n\t" - "movzwl %%ax, %%esi \n\t" - "shll $8, %%esi \n\t" - "movl %%esi, %%edx \n\t" - "addl _vspmask, %%edx \n\t" - "addl _vsp, %%esi \n\t" - "movl %2, %%eax \n\t" - "shll $4, %%eax \n\t" - "addl %%eax, %%esi \n\t" - "addl %%eax, %%edx \n\t" - "movl (%%edi), %%eax \n\t" - "andl (%%edx), %%eax \n\t" - "orl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - "movl 4(%%edi), %%eax \n\t" - "andl 4(%%edx), %%eax \n\t" - "orl 4(%%esi), %%eax \n\t" - "movl %%eax, 4(%%edi) \n\t" - "movl 8(%%edi), %%eax \n\t" - "andl 8(%%edx), %%eax \n\t" - "orl 8(%%esi), %%eax \n\t" - "movl %%eax, 8(%%edi) \n\t" - "movl 12(%%edi), %%eax \n\t" - "andl 12(%%edx), %%eax \n\t" - "orl 12(%%esi), %%eax \n\t" - "movl %%eax, 12(%%edi) \n\t" -"next1: \n\t" - "addl $16, %%edi \n\t" - "addl $2, %%ecx \n\t" - "decl %%ebx \n\t" - "jnz tileloop1 \n\t" - : - : "m" (x), "m" (y), "m" (yofs), "m" (map) - : "eax","ebx","ecx","edx","esi","edi","cc" ); - - cpubyte=ETC; - return 0; -} - -int Mode13hColorField(int x, int y, byte c) -{ - cpubyte=RENDER; - asm("movl %1, %%eax \n\t" - "imul $352, %%eax \n\t" - "addl %0, %%eax \n\t" - "addl _screen, %%eax \n\t" - "movl %%eax, %%edi \n\t" - "movl $8, %%ecx \n\t" - "movb %2, %%al \n\t" -"lineloop1: \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "addl $336, %%edi \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "addl $336, %%edi \n\t" - "decl %%ecx \n\t" - "jnz lineloop1 \n\t" - : - : "m" (x), "m" (y), "m" (c) - : "eax","edi","ecx","cc" ); - cpubyte=ETC; - return 0; -} - -int Mode13hClearScreen() -{ - cpubyte=RENDER; - memset(screen+(352*16)+16,0,(352*200)); - cpubyte=ETC; - return 0; -} - -int Mode13hPutPixel(int x, int y, int color) -{ - cpubyte=RENDER; - - if (xcx2 || y>cy2) - { - cpubyte=ETC; - return 0; - } - - x+=16; - y+=16; - - screen[(y*tsx)+x]=color; - - cpubyte=ETC; - return 0; -} - -int Mode13hGetPixel(int x, int y) -{ - cpubyte=RENDER; - - if (xcx2 || y>cy2) - { - cpubyte=ETC; - return 0; - } - - x+=16; - y+=16; - - cpubyte=ETC; - return screen[(y*tsx)+x]; -} - -int Mode13hHLine(int x, int y, int x2, int color) -{ byte *d; - int width; - - cpubyte=RENDER; - - // swap? - if (x2cx2 || y>cy2 || x+width cx2) width=cx2-x+1; - if (xcx2 || y>cy2 || x cy2) height=cy2-y+1; - if (ycx2 && x2>cx2) - || (y1cy2 && y2>cy2)) - { - cpubyte=ETC; - return 0; - } - - if (x1>x2) - { - i=x1; x1=x2; x2=i; - i=y1; y1=y2; y2=i; - } - - // clip the left side - if (x1cx2) - { int myy=(y2-y1); - int mxx=(x2-x1),b; - if (!mxx) - { - cpubyte=ETC; - return 0; - } - if (myy) - { - b=y1-(y2-y1)*x1/mxx; - y2=myy*cx2/mxx+b; - x2=cx2; - } - else x2=cx2; - } - - if (y1>y2) - { - i=x1; x1=x2; x2=i; - i=y1; y1=y2; y2=i; - } - - // clip the bottom - if (y2>cy2) - { int mxx=(x2-x1); - int myy=(y2-y1),b; - if (!myy) - { - cpubyte=ETC; - return 0; - } - if (mxx) - { - b=y1-(y2-y1)*x1/mxx; - x2=(cy2-b)*mxx/myy; - y2=cy2; - } - else y2=cy2; - } - - // clip the top - if (y1cx2 || x2>cx2 || y1cy2 || y2>cy2) - { - cpubyte=ETC; - return 0; - } - - if (x1>x2) - { xc=x2; xi=x1; } - else { xi=x2; xc=x1; } - - x1+=16;y1+=16; // aen; adjust these here?? - x2+=16;y2+=16; - - // assume y1<=y2 from above swap operation - yi=y2; yc=y1; - - dcx=x1; dcy=y1; - xc=(x2-x1); yc=(y2-y1); - if (xc<0) xi=-1; else xi=1; - if (yc<0) yi=-1; else yi=1; - n=abs(xc); m=abs(yc); - ycyi=abs(2*yc*xi); - er=0; - - if (n>m) - { - xcxi=abs(2*xc*xi); - for (i=0;i<=n;i++) - { - screen[(dcy*tsx)+dcx]=color; - if (er>0) - { dcy+=yi; - er-=xcxi; - } - er+=ycyi; - dcx+=xi; - } - } - else - { - xcyi=abs(2*xc*yi); - for (i=0;i<=m;i++) - { - screen[(dcy*tsx)+dcx]=color; - if (er>0) - { dcx+=xi; - er-=ycyi; - } - er+=xcyi; - dcy+=yi; - } - } - - cpubyte=ETC; - return 0; -} - -int Mode13hCircle(int x, int y, int radius, int color) -{ int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - - do { - Mode13hPutPixel(x+cx,y+cy,color); - if (cx) Mode13hPutPixel(x-cx,y+cy,color); - if (cy) Mode13hPutPixel(x+cx,y-cy,color); - if ((cx) && (cy)) Mode13hPutPixel(x-cx,y-cy,color); - - if (cx != cy) - { - Mode13hPutPixel(x+cy,y+cx,color); - if (cx) Mode13hPutPixel(x+cy,y-cx,color); - if (cy) Mode13hPutPixel(x-cy,y+cx,color); - if (cx && cy) Mode13hPutPixel(x-cy,y-cx,color); - } - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - - cx++; - - } while (cx <= cy); - - cpubyte=ETC; - return 0; -} - -int Mode13hCircleFill(int x, int y, int radius, int color) -{ int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - - do { - Mode13hHLine(x-cy,y-cx,x+cy,color); - if (cx) Mode13hHLine(x-cy,y+cx,x+cy,color); - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - if (cx != cy) - { - Mode13hHLine(x-cx,y-cy,x+cx,color); - if (cy) Mode13hHLine(x-cx,y+cy,x+cx,color); - } - - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - - cx++; - - } while (cx <= cy); - - cpubyte=ETC; - return 0; -} - -int Mode13hRect(int x, int y, int x2, int y2, int color) -{ - Mode13hHLine(x,y,x2,color); - Mode13hHLine(x,y2,x2,color); - Mode13hVLine(x,y+1,y2-1,color); - Mode13hVLine(x2,y+1,y2-1,color); - return 0; -} - -int Mode13hRectFill(int x, int y, int x2, int y2, int color) -{ - cpubyte=RENDER; - - if (y2 -#include -#include "verge.h" - -void BIOS_SetVideoMode(int mode) -{ - REGISTERS r; - SET_AX(r, mode); - INTERRUPT(0x10, r); -} - -// =============================== Mode 13h =================================== - -int Mode13hShutdown(int i) -{ - if (i) BIOS_SetVideoMode(0x3); - free(screen); - return 0; -} - -void InitMode13h(void) -{ - BIOS_SetVideoMode(0x13); - - DriverDesc = "320x200 (Mode 13h, linear)"; - sx=320, sy=200; - tx=20, ty=13; - cx1=0, cy1=0; - cx2=sx-1, cy2=sy-1; - - // setup function drivers - ShowPage=LFB_ShowPage; - ShutdownVideo=Mode13hShutdown; - - video=(byte *) 0xA0000 + __djgpp_conventional_base; - vscreen=(byte *) valloc(sx*sy, "vscreen", 0); - screen=vscreen; - memset(screen, 0, sx*sy); -} - -// ================================= Mode-X ================================== - -#define SEQU_ADDR 0x3c4 -#define CRTC_ADDR 0x3d4 -#define MISC_OUTPUT 0x3c2 - -#define ATTRCON_ADDR 0x3c0 -#define MISC_ADDR 0x3c2 -#define VGAENABLE_ADDR 0x3c3 -#define SEQ_ADDR 0x3c4 -#define GRACON_ADDR 0x3ce -#define CRTC_ADDR 0x3d4 -#define STATUS_ADDR 0x3da - -typedef struct -{ - unsigned port; - byte index, value; -} Register; - -typedef Register *RegisterPtr; - -Register scr256x256[] = -{ - { 0x3c2, 0x00, 0xe3},{ 0x3d4, 0x00, 0x5f},{ 0x3d4, 0x01, 0x3f}, - { 0x3d4, 0x02, 0x40},{ 0x3d4, 0x03, 0x82},{ 0x3d4, 0x04, 0x4A}, - { 0x3d4, 0x05, 0x9A},{ 0x3d4, 0x06, 0x23},{ 0x3d4, 0x07, 0xb2}, - { 0x3d4, 0x08, 0x00},{ 0x3d4, 0x09, 0x61},{ 0x3d4, 0x10, 0x0a}, - { 0x3d4, 0x11, 0xac},{ 0x3d4, 0x12, 0xff},{ 0x3d4, 0x13, 0x20}, - { 0x3d4, 0x14, 0x40},{ 0x3d4, 0x15, 0x07},{ 0x3d4, 0x16, 0x1a}, - { 0x3d4, 0x17, 0xa3},{ 0x3c4, 0x01, 0x01},{ 0x3c4, 0x04, 0x0e}, - { 0x3ce, 0x05, 0x40},{ 0x3ce, 0x06, 0x05},{ 0x3c0, 0x10, 0x41}, - { 0x3c0, 0x13, 0x00} -}; - -// ================================= Code ==================================== - -void plane(byte p) -{ - int hi=1<>2; - - for (y=0; y= sx) - { memcpy(d,s,sx); - bytes-=sx; - s+=sx; - d+=sx; - } - else - { memcpy(d,s,bytes); - s+=bytes; - span=sx-bytes; - - VESASetBank(bank++); - d=video; - bytes=65536; - - memcpy(d,s,span); - bytes-=span; - s+=span; - d+=span; - } - } - cpubyte=ETC; - return 0; -} - -void Set640x480() -{ - REGISTERS r; - - DriverDesc = "640x480 (VESA, Banked)"; - - SET_BX(r, 0x0101); - SET_AX(r, 0x4f02); - INTERRUPT(0x10, r); - - sx=640; sy=480; - tx=40; ty=30; - cx1=0; cy1=0; - cx2=sx-1;cy2=sy-1; -} - -void InitVESA(int xres, int yres) -{ - int found; - - found=0; - if (xres==640 && yres==480) { Set640x480(); found=1; } - - if (!found) - err("Internal error: unknown VESA resolution"); - - // setup driver functions - ShowPage = VESAShowPage; // reassign for banked VESA video blt - ShutdownVideo = VESAShutdown; - - video=(byte *) 0xA0000 + __djgpp_conventional_base; - vscreen=(byte *) valloc(sx*sy, "vscreen", 0); - screen=vscreen; - memset(screen, 0, sx*sy); -} - -// ============================================================================ - -int InitVideo(int xres, int yres) -{ - int found; - - found=0; - if (xres==320 && yres==200) { InitMode13h(); found=1; } - if (xres==320 && yres==240) { InitModeX(xres,yres); found=1; } - if (xres==360 && yres==240) { InitModeX(xres,yres); found=1; } - if (xres==256 && yres==256) { InitModeX(xres,yres); found=1; } - if (xres==640 && yres==480) { InitVESA(xres,yres); found=1; } - - if (found) - { - tsx=xres; tsy=yres; - Logp("Sys: Initializing %s.", DriverDesc); - InitMouse(tsx, tsy); - } - else - { - InitMode13h(); - tsx=320; tsy=200; - Logp("Unknown video mode %dx%d; defaulting to mode 13h.", xres, yres); - InitMouse(tsx, tsy); - } - LogDone(); - return found; -} diff --git a/16/v2/source/verge/ENGINE/MODEX.C b/16/v2/source/verge/ENGINE/MODEX.C deleted file mode 100755 index 6247f8eb..00000000 --- a/16/v2/source/verge/ENGINE/MODEX.C +++ /dev/null @@ -1,1055 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#include -#include -#include "verge.h" - -// ================================= Data ==================================== - -#define SEQU_ADDR 0x3c4 -#define CRTC_ADDR 0x3d4 -#define MISC_OUTPUT 0x3c2 - -byte *screenbase; // ptr to A000:0000 -int endcol,nextl; // end column number thingy | next line -int winofs; - -// ================================= Code ==================================== - -void ModeXSetMode(int mode) -{ - REGISTERS r; - SET_AX(r, mode); - INTERRUPT(0x10, r); -} - -void plane(byte p) -{ - int hi=1<> 8) | 0x0c); - outportb(0x3d4, (offset & 0xff) | 0x0d); - - _enable(); -} - -int ModeXShowPage() -{ - byte *s,*d; - int x,y,k; - int sx2; - int b; - - RenderGUI(); - cpubyte=PFLIP; - - //s=screen+(16*tsx)+16; - b=(16*tsx)+16; - d=screenbase; - sx2=sx>>2; - - //while (!(inp(986) & 8)); - - for (y=0; ycx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (x0 && th>0) dys=tsx-xm; - else if (tw>0 && th<0) dys=(0-tsx)-xm; - else if (tw<0 && th>0) dys=tsx+xm; - else if (tw<0 && th<0) dys=(0-tsx)+xm; - - d = screen+(y*tsx)+x; - for (i=0;i>16)]; - d+=xd; - sx+=xs; - } - d+=dys; - sy+=ys; - s+=(sy>>16)*w; - sy&=0xffff; - } - cpubyte=ETC; - return 0; -} - -int ModeXRenderMAPLine(int x, int y, int yofs, word *map) -{ - cpubyte=RENDER; - asm("movl %1, %%edi \n\t" - "imul _tsx, %%edi \n\t" - "addl %0, %%edi \n\t" - "addl _screen, %%edi \n\t" - "movl _tx, %%ebx \n\t" - "incl %%ebx \n\t" - "movl %3, %%ecx \n\t" -"tileloop: \n\t" - "movw (%%ecx), %%ax \n\t" - "movzwl %%ax, %%edx \n\t" - "shll $1, %%edx \n\t" - "addl _tileidx, %%edx \n\t" - "movw (%%edx), %%ax \n\t" - "movzwl %%ax, %%esi \n\t" - "shll $8, %%esi \n\t" - "addl _vsp, %%esi \n\t" - "movl %2, %%eax \n\t" - "shll $4, %%eax \n\t" - "addl %%eax, %%esi \n\t" - "movl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - "movl 4(%%esi), %%eax \n\t" - "movl %%eax, 4(%%edi) \n\t" - "movl 8(%%esi), %%eax \n\t" - "movl %%eax, 8(%%edi) \n\t" - "movl 12(%%esi), %%eax \n\t" - "movl %%eax, 12(%%edi) \n\t" - "addl $16, %%edi \n\t" - "addl $2, %%ecx \n\t" - "decl %%ebx \n\t" - "jnz tileloop \n\t" - : - : "m" (x), "m" (y), "m" (yofs), "m" (map) - : "eax","ebx","ecx","edx","esi","edi","cc" ); - - cpubyte=ETC; - return 0; -} - -int ModeXTRenderMAPLine(int x, int y, int yofs, word *map) -{ - cpubyte=RENDER; - asm("movl %1, %%edi \n\t" - "imul _tsx, %%edi \n\t" - "addl %0, %%edi \n\t" - "addl _screen, %%edi \n\t" - "movl _tx, %%ebx \n\t" - "incl %%ebx \n\t" - "movl %3, %%ecx \n\t" -"tileloop1: \n\t" - "movw (%%ecx), %%ax \n\t" - "movzwl %%ax, %%edx \n\t" - "shll $1, %%edx \n\t" - "addl _tileidx, %%edx \n\t" - "movw (%%edx), %%ax \n\t" - "orw %%ax, %%ax \n\t" - "jz next1 \n\t" - "movzwl %%ax, %%esi \n\t" - "shll $8, %%esi \n\t" - "movl %%esi, %%edx \n\t" - "addl _vspmask, %%edx \n\t" - "addl _vsp, %%esi \n\t" - "movl %2, %%eax \n\t" - "shll $4, %%eax \n\t" - "addl %%eax, %%esi \n\t" - "addl %%eax, %%edx \n\t" - "movl (%%edi), %%eax \n\t" - "andl (%%edx), %%eax \n\t" - "orl (%%esi), %%eax \n\t" - "movl %%eax, (%%edi) \n\t" - "movl 4(%%edi), %%eax \n\t" - "andl 4(%%edx), %%eax \n\t" - "orl 4(%%esi), %%eax \n\t" - "movl %%eax, 4(%%edi) \n\t" - "movl 8(%%edi), %%eax \n\t" - "andl 8(%%edx), %%eax \n\t" - "orl 8(%%esi), %%eax \n\t" - "movl %%eax, 8(%%edi) \n\t" - "movl 12(%%edi), %%eax \n\t" - "andl 12(%%edx), %%eax \n\t" - "orl 12(%%esi), %%eax \n\t" - "movl %%eax, 12(%%edi) \n\t" -"next1: \n\t" - "addl $16, %%edi \n\t" - "addl $2, %%ecx \n\t" - "decl %%ebx \n\t" - "jnz tileloop1 \n\t" - : - : "m" (x), "m" (y), "m" (yofs), "m" (map) - : "eax","ebx","ecx","edx","esi","edi","cc" ); - - cpubyte=ETC; - return 0; -} - -int ModeXColorField(int x, int y, byte c) -{ - cpubyte=RENDER; - asm("movl %1, %%eax \n\t" - "imul _tsx, %%eax \n\t" - "addl %0, %%eax \n\t" - "addl _screen, %%eax \n\t" - "movl %%eax, %%edi \n\t" - "movl $8, %%ecx \n\t" - "movb %2, %%al \n\t" -"lineloop1: \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "addl _sx, %%edi \n\t" - "addl $16, %%edi \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "incl %%edi \n\t" - "stosb \n\t" - "addl _sx, %%edi \n\t" - "addl $16, %%edi \n\t" - "decl %%ecx \n\t" - "jnz lineloop1 \n\t" - : - : "m" (x), "m" (y), "m" (c) - : "eax","edi","ecx","cc" ); - cpubyte=ETC; - return 0; -} - -int ModeXClearScreen() -{ - cpubyte=RENDER; - memset(screen+(tsx*16)+16,0,(tsx*sy)); - cpubyte=ETC; - return 0; -} - -int ModeXPutPixel(int x, int y, int color) -{ - cpubyte=RENDER; - - if (xcx2 || y>cy2) - { - cpubyte=ETC; - return 0; - } - - x+=16; - y+=16; - - screen[(y*tsx)+x]=color; - - cpubyte=ETC; - return 0; -} - -int ModeXGetPixel(int x, int y) -{ - cpubyte=RENDER; - - if (xcx2 || y>cy2) - { - cpubyte=ETC; - return 0; - } - - x+=16; - y+=16; - - cpubyte=ETC; - return screen[(y*tsx)+x]; -} - -int ModeXHLine(int x, int y, int x2, int color) -{ byte *d; - int width; - - cpubyte=RENDER; - - // swap? - if (x2cx2 || y>cy2 || x+width cx2) width=cx2-x+1; - if (xcx2 || y>cy2 || x cy2) height=cy2-y+1; - if (ycx2 && x2>cx2) - || (y1cy2 && y2>cy2)) - { - cpubyte=ETC; - return 0; - } - - if (x1>x2) - { - i=x1; x1=x2; x2=i; - i=y1; y1=y2; y2=i; - } - - // clip the left side - if (x1cx2) - { int myy=(y2-y1); - int mxx=(x2-x1),b; - if (!mxx) - { - cpubyte=ETC; - return 0; - } - if (myy) - { - b=y1-(y2-y1)*x1/mxx; - y2=myy*cx2/mxx+b; - x2=cx2; - } - else x2=cx2; - } - - if (y1>y2) - { - i=x1; x1=x2; x2=i; - i=y1; y1=y2; y2=i; - } - - // clip the bottom - if (y2>cy2) - { int mxx=(x2-x1); - int myy=(y2-y1),b; - if (!myy) - { - cpubyte=ETC; - return 0; - } - if (mxx) - { - b=y1-(y2-y1)*x1/mxx; - x2=(cy2-b)*mxx/myy; - y2=cy2; - } - else y2=cy2; - } - - // clip the top - if (y1cx2 || x2>cx2 || y1cy2 || y2>cy2) - { - cpubyte=ETC; - return 0; - } - - if (x1>x2) - { xc=x2; xi=x1; } - else { xi=x2; xc=x1; } - - x1+=16;y1+=16; // aen; adjust these here?? - x2+=16;y2+=16; - - // assume y1<=y2 from above swap operation - yi=y2; yc=y1; - - dcx=x1; dcy=y1; - xc=(x2-x1); yc=(y2-y1); - if (xc<0) xi=-1; else xi=1; - if (yc<0) yi=-1; else yi=1; - n=abs(xc); m=abs(yc); - ycyi=abs(2*yc*xi); - er=0; - - if (n>m) - { - xcxi=abs(2*xc*xi); - for (i=0;i<=n;i++) - { - screen[(dcy*tsx)+dcx]=color; - if (er>0) - { dcy+=yi; - er-=xcxi; - } - er+=ycyi; - dcx+=xi; - } - } - else - { - xcyi=abs(2*xc*yi); - for (i=0;i<=m;i++) - { - screen[(dcy*tsx)+dcx]=color; - if (er>0) - { dcx+=xi; - er-=ycyi; - } - er+=xcyi; - dcy+=yi; - } - } - - cpubyte=ETC; - return 0; -} - -int ModeXCircle(int x, int y, int radius, int color) -{ int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - - do { - ModeXPutPixel(x+cx,y+cy,color); - if (cx) ModeXPutPixel(x-cx,y+cy,color); - if (cy) ModeXPutPixel(x+cx,y-cy,color); - if ((cx) && (cy)) ModeXPutPixel(x-cx,y-cy,color); - - if (cx != cy) - { - ModeXPutPixel(x+cy,y+cx,color); - if (cx) ModeXPutPixel(x+cy,y-cx,color); - if (cy) ModeXPutPixel(x-cy,y+cx,color); - if (cx && cy) ModeXPutPixel(x-cy,y-cx,color); - } - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - - cx++; - - } while (cx <= cy); - - cpubyte=ETC; - return 0; -} - -int ModeXCircleFill(int x, int y, int radius, int color) -{ int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - - do { - ModeXHLine(x-cy,y-cx,x+cy,color); - if (cx) ModeXHLine(x-cy,y+cx,x+cy,color); - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - if (cx != cy) - { - ModeXHLine(x-cx,y-cy,x+cx,color); - if (cy) ModeXHLine(x-cx,y+cy,x+cx,color); - } - - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - - cx++; - - } while (cx <= cy); - - cpubyte=ETC; - return 0; -} - -int ModeXRect(int x, int y, int x2, int y2, int color) -{ - ModeXHLine(x,y,x2,color); - ModeXHLine(x,y2,x2,color); - ModeXVLine(x,y+1,y2-1,color); - ModeXVLine(x2,y+1,y2-1,color); - return 0; -} - -int ModeXRectFill(int x, int y, int x2, int y2, int color) -{ - cpubyte=RENDER; - - if (y20 true */ - -#else - -typedef char SBYTE; /* has to be 1 byte signed */ -typedef unsigned char UBYTE; /* has to be 1 byte unsigned */ -typedef short SWORD; /* has to be 2 bytes signed */ -typedef unsigned short UWORD; /* has to be 2 bytes unsigned */ -typedef long SLONG; /* has to be 4 bytes signed */ -typedef unsigned long ULONG; /* has to be 4 bytes unsigned */ -typedef int BOOL; /* doesn't matter.. 0=FALSE, <>0 true */ - -#endif - - -#ifdef __OS2__ -#define INCL_DOS -#define INCL_MCIOS2 -#define INCL_MMIOOS2 -#include -#include -#include -#endif - - -#ifdef __WATCOMC__ -#define inportb(x) inp(x) -#define outportb(x,y) outp(x,y) -#define inport(x) inpw(x) -#define outport(x,y) outpw(x,y) -#define disable() _disable() -#define enable() _enable() -#endif - - -#ifdef __DJGPP__ -#include -#include -#include -#define inp inportw -#define outport outportw -#define inport inportw -#define interrupt -#endif - -#endif diff --git a/16/v2/source/verge/ENGINE/PCX.H b/16/v2/source/verge/ENGINE/PCX.H deleted file mode 100755 index 844e5c7a..00000000 --- a/16/v2/source/verge/ENGINE/PCX.H +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef PCX_H -#define PCX_H - -// -- globals -- - -extern word width,depth; - -// -- prototypes -- - -extern void ReadPCXLine(byte *dest); -extern void LoadPCXHeader(char *fname); -extern void LoadPCXHeaderNP(char *fname); -extern void LoadPCX(char *fname, byte *dest); -extern byte *LoadPCXBuf(char *fname); - -#endif // PCX_H diff --git a/16/v2/source/verge/ENGINE/RENDER.C b/16/v2/source/verge/ENGINE/RENDER.C deleted file mode 100755 index 31151541..00000000 --- a/16/v2/source/verge/ENGINE/RENDER.C +++ /dev/null @@ -1,291 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "verge.h" -#include - -// ================================= Data ==================================== - -int oxw, oyw; -int xofs, yofs; -int xtc, ytc; - -byte curlayer, animate=0; -byte cameratracking=1, tracker=0; -byte showobs=0, showzone=0; - -// ================================= Code ==================================== - -void BlitBackLayer(byte l) -{ - int i,j,c; - byte *img; - - if (!layertoggle[l]) return; - - // Adjust view - - oxw=xwin*layer[l].pmultx/layer[l].pdivx; - oyw=ywin*layer[l].pmulty/layer[l].pdivy; - xofs=-(oxw&15); //(16-(oxw&15)); - yofs=-(oyw&15); //(16-(oyw&15)); - xtc=oxw>>4; - ytc=oyw>>4; - - // Draw it, bitch! - - for (i=0; i>4; - ytc=oyw>>4; - - // Draw it, bitch! - - for (i=0; i>4; - ytc=oyw>>4; - - // Draw it, bitch! - - for (i=0; i>4; - ytc=oyw>>4; - - for (i=0; ix+7)/16)==(xtc+j) && ((player->y+7)/16)==(ytc+i)) - { - ColorField((j*16)+xofs,(i*16)+yofs,31); - } - } - } -} - -void HookScriptThing(char *src) -{ - char mystr[10]; - - src++; - strcpy(mystr, src); - src=mystr; - while (*src != 'X') src++; - *src=0; - ExecuteEvent(atoi(mystr)); -} - -void RenderMAP() -{ char *src; - - curlayer=0; - src=rstring; - while (*src) - { - switch (*src) - { - case '1': BlitLayer(0); break; - case '2': BlitLayer(1); break; - case '3': BlitLayer(2); break; - case '4': BlitLayer(3); break; - case '5': BlitLayer(4); break; - case '6': BlitLayer(5); break; - case 'E': RenderEntities(); break; - case 'S': HookScriptThing(src); break; - case 'R': HookRetrace(); - curlayer++; break; - } - src++; - } - if (!curlayer) ClearScreen(); - if (showobs) DrawObstructions(); - if (showzone) DrawZones(); -} - -void Render() -{ - if (cameratracking==1 && player) - { - if (player->x+8>(sx/2)) xwin=(player->x+8-(sx/2)); else xwin=0; - if (player->y+8>(sy/2)) ywin=(player->y+8-(sy/2)); else ywin=0; - if (xwin>((layer[0].sizex*16)-sx)) xwin=((layer[0].sizex*16)-sx); - if (ywin>((layer[0].sizey*16)-sy)) ywin=((layer[0].sizey*16)-sy); - } - if (cameratracking==2) - { - if (entity[tracker].x+8>(sx/2)) xwin=(entity[tracker].x+8-(sx/2)); else xwin=0; - if (entity[tracker].y+8>(sy/2)) ywin=(entity[tracker].y+8-(sy/2)); else ywin=0; - if (xwin>((layer[0].sizex*16)-sx)) xwin=((layer[0].sizex*16)-sx); - if (ywin>((layer[0].sizey*16)-sy)) ywin=((layer[0].sizey*16)-sy); - } - SiftEntities(); - RenderMAP(); -} - -int rnd(int lo, int hi) -{ - int range=hi-lo+1; - int i=rand() % range; - return i+lo; -} - -void AnimateTile(byte i, int l) -{ - switch (vspanim[i].mode) - { - case 0: if (tileidx[l]vspanim[i].start) tileidx[l]--; - else tileidx[l]=vspanim[i].finish; - break; - case 2: tileidx[l]=rnd(vspanim[i].start,vspanim[i].finish); - break; - case 3: if (flipped[l]) - { - if (tileidx[l]!=vspanim[i].start) tileidx[l]--; - else { tileidx[l]++; flipped[l]=0; } - } - else - { - if (tileidx[l]!=vspanim[i].finish) tileidx[l]++; - else { tileidx[l]--; flipped[l]=1; } - } - } -} - -void Animate(byte i) -{ static int l; - - vadelay[i]=0; - for (l=vspanim[i].start; l<=vspanim[i].finish; l++) - AnimateTile(i,l); -} - -void CheckTileAnimation() -{ static byte i; - - if (!animate) return; - if (!vsp) return; - for (i=0; i<100; i++) - { - if ((vspanim[i].delay) && (vspanim[i].delaynumchn+2; - mp_loop=1; mp_volume=100; - MD_PlayStart(); - PlaySound(0, 0, 0); - PlaySound(0, 0, 0); -} - -void StopMusic() -{ - if (MP_Ready()) return; - MD_PlayStop(); - ML_Free(mf); -} - -int CacheSound(char *fname) -{ - if (!(sfx[nsfx]=MW_LoadWavFN(fname))) - err("WAV [%s] load error: %s", fname, myerr); - return nsfx++; -} - -void FreeAllSounds() -{ - int i; - - for (i=0; i= nsfx) return; - switcher ^= 1; - chanl=md_numchn-1-switcher; - MD_VoiceSetVolume(chanl, vol); - MD_VoiceSetPanning(chanl, pan); - MD_VoiceSetFrequency(chanl, sfx[index]->c2spd); - MD_VoicePlay(chanl, sfx[index]->handle, 0, sfx[index]->length, - 0, 0, sfx[index]->flags); -} diff --git a/16/v2/source/verge/ENGINE/SOUND.H b/16/v2/source/verge/ENGINE/SOUND.H deleted file mode 100755 index 63c71a04..00000000 --- a/16/v2/source/verge/ENGINE/SOUND.H +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SOUND_H -#define SOUND_H - -void InitMusicSystem(); -void PlayMusic(char *); -void StopMusic(); -int CacheSound(char *); -void FreeAllSounds(); -void PlaySound(int, int, int); - -#endif diff --git a/16/v2/source/verge/ENGINE/STARTUP.C b/16/v2/source/verge/ENGINE/STARTUP.C deleted file mode 100755 index 87ee07dc..00000000 --- a/16/v2/source/verge/ENGINE/STARTUP.C +++ /dev/null @@ -1,123 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include // va_*() -#include - -#define MAIN_H -#include "verge.h" -extern void vmain(int argc, char *argv[]); -extern void Log(char *message, ...); - -int mx, my, mb; - -// ================================= Code ==================================== - -void err(char *message, ...) -{ - char tempbuf[256]; - va_list lst; - - ShutdownVideo(1); - ShutdownTimer(); - ShutdownKeyboard(); -// CD_Deinit(); - MD_PlayStop(); - MD_Exit(); - - va_start(lst, message); - vsprintf(tempbuf, message, lst); - va_end(lst); - - printf(tempbuf); - fflush(stdout); - - Log("Sys: Exiting with message: %s", tempbuf); - - exit(-1); -} - -int sgn(int x) -{ - if (x>=0) return 1; - return 0; -} - -void ver() -{ char temp[256]; - - Con_NextLine(); - Con_Printf("{|||||||||||||||||}"); - sprintf(temp,"VERGE v.%s Copyright (C)1998 vecna",VERSION); - Con_Printf(temp); - Con_Printf("All rights reserved. DJGPP/DOS build."); - sprintf(strbuf,"Timestamp %s at %s.",__DATE__, __TIME__); - Con_Printf(strbuf); - Con_Printf("Options: -Wall -m486 -O1 -ffast-math"); - Con_Printf("{|||||||||||||||||}"); -} - -void CheckMessages() -{ - // Win95 can bite me. -} - -void InitMouse(int x, int y) -{ REGISTERS r; - - SET_AX(r,7); - SET_CX(r,0); - SET_DX(r,x); - INTERRUPT(0x33, r); - - SET_AX(r,8); - SET_CX(r,0); - SET_DX(r,y); - INTERRUPT(0x33, r); -} - -void ReadMouse() -{ REGISTERS r; - - SET_AX(r,3); - INTERRUPT(0x33, r); - - mx=r.x.cx; - my=r.x.dx; - mb=r.x.bx; -} - -void SetMouse(int x, int y) -{ REGISTERS r; - - SET_AX(r, 4); - SET_CX(r, x); - SET_DX(r, y); - INTERRUPT(0x33, r); -} - -int main(int argc, char *argv[]) -{ - if (argc==1) - { - printf("VERGE v.%s build %s at %s. \n",VERSION,__DATE__,__TIME__); - printf("Copyright (C)1998 vecna \n"); - delay(500); - } - srand(time(NULL)); - vmain(argc, argv); - return 0; -} diff --git a/16/v2/source/verge/ENGINE/TIMER.C b/16/v2/source/verge/ENGINE/TIMER.C deleted file mode 100755 index b0c9274e..00000000 --- a/16/v2/source/verge/ENGINE/TIMER.C +++ /dev/null @@ -1,141 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#define TIMER_H -#include -#include -#include -#include "verge.h" - -#define PIT0 0x40 -#define PIT1 0x41 -#define PIT2 0x42 -#define PITMODE 0x43 -#define PITCONST 1193180L - -#define OCR1 0x20 -#define IMR1 0x21 - -#define OCR2 0xA0 -#define IMR2 0xA1 - -// ================================= Data ==================================== - -int _crt0_startup_flags = _CRT0_FLAG_NEARPTR; -typedef __dpmi_paddr *PVI; -static PVI oldhandler; - -unsigned int systemtime=0, timer_count=0; -int (*callback) (void); - -// ================================= Code ==================================== - -PVI DJSetHandlerFunc(unsigned char irqno, void (*handler)(), int len) -{ - PVI oldvect = (PVI) malloc(sizeof(__dpmi_paddr)); - int vecno=(irqno>7) ? irqno+0x68 : irqno+0x8; - _go32_dpmi_seginfo wrapper; - __dpmi_paddr new; - - wrapper.pm_offset = (long int) handler; - wrapper.pm_selector = _my_cs(); - _go32_dpmi_allocate_iret_wrapper(&wrapper); - new.offset32 = wrapper.pm_offset; - new.selector = wrapper.pm_selector; - __dpmi_get_and_disable_virtual_interrupt_state(); - if (len) _go32_dpmi_lock_code(handler,len); - _go32_dpmi_lock_data(&wrapper,sizeof(_go32_dpmi_seginfo)); - __dpmi_get_protected_mode_interrupt_vector(vecno,oldvect); - __dpmi_set_protected_mode_interrupt_vector(vecno,&new); - __dpmi_get_and_enable_virtual_interrupt_state(); - return oldvect; -} - -void DJSetHandlerAddr(unsigned char irqno, PVI handler) -{ - int vecno=(irqno>7) ? irqno+0x68 : irqno+0x8; - _go32_dpmi_seginfo wrapper; - __dpmi_paddr oldhandler; - - __dpmi_get_and_disable_virtual_interrupt_state(); - __dpmi_get_protected_mode_interrupt_vector(vecno, &oldhandler); - wrapper.pm_offset = oldhandler.offset32; - wrapper.pm_selector = oldhandler.selector; - _go32_dpmi_free_iret_wrapper(&wrapper); - __dpmi_set_protected_mode_interrupt_vector(vecno,handler); - __dpmi_get_and_enable_virtual_interrupt_state(); - free(handler); -} - -static void SendEOI (unsigned char irqno) -{ - unsigned char ocr=(irqno>7) ? OCR2 : OCR1; - unsigned char eoi=0x60|(irqno&7); - - outportb(ocr,eoi); - if (irqno>7) outportb(OCR1,0x20); -} - -static void newhandler(void) -{ - systemtime++; - timer_count++; - if (cpu_watch) CPUTick(); - if (callback) callback(); - CheckTileAnimation(); - HookTimer(); - MD_Update(); - SendEOI(0); -} - -static void EndNewHandler() { } - -void sethz(unsigned int hz) -{ unsigned int pit0_set, pit0_value; - - disable(); - - outportb(PITMODE, 0x34); - pit0_value=PITCONST / hz; - pit0_set=(pit0_value & 0x00ff); - outportb(PIT0, pit0_set); - pit0_set=(pit0_value >> 8); - outportb(PIT0, pit0_set); - - enable(); -} - -void restorehz() -{ - disable(); - outportb(PITMODE, 0x34); - outportb(PIT0, 0x00); - outportb(PIT0, 0x00); - enable(); -} - -void InitTimer() -{ - oldhandler = DJSetHandlerFunc(0, (void *) newhandler, - ((int) EndNewHandler) - ((int) newhandler)); - sethz(100); -} - -void ShutdownTimer() -{ - DJSetHandlerAddr(0, oldhandler); - restorehz(); -} diff --git a/16/v2/source/verge/ENGINE/TIMER.H b/16/v2/source/verge/ENGINE/TIMER.H deleted file mode 100755 index e195f924..00000000 --- a/16/v2/source/verge/ENGINE/TIMER.H +++ /dev/null @@ -1,26 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef TIMER_H -#define TIMER_H - -void InitTimer(); -void ShutdownTimer(); - -extern int systemtime, timer_count; -extern int (*callback) (void); - -#endif diff --git a/16/v2/source/verge/ENGINE/VC.C b/16/v2/source/verge/ENGINE/VC.C deleted file mode 100755 index 36e86f2c..00000000 --- a/16/v2/source/verge/ENGINE/VC.C +++ /dev/null @@ -1,2242 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -#define VC_H -#include -#include "verge.h" -#include "vccode.h" -#include "sincos.h" -#include "mikmod.h" - -#define USERFUNC_MARKER 10000 - -// ================================= Data ==================================== - -char *sysvc, *mapvc, *basevc; // VC pool ptrs -char *code; // VC current instruction pointer (IP) - -int *globalint; // system.vc global int variables -int maxint; // maximum allocated # of ints -char *stringbuf; // vc string workspace -int vcreturn; // return value of last function -char *movescriptbuf; // VC EntityMove buffer -char vctrack=0; // VC call tracking to verge.log - -quad *vcstack; // VC stack (seperate from main stack) -quad *vcsp; // VC stack pointer [esp] - -int mapevents; // number of map events in this VC -char *mapvctbl[1024]; // map VC offset table - -int hookretrace=0; -int hooktimer=0; -int invc=0; - -// ----------------- - -typedef struct -{ - char fname[40]; - char argtype[20]; - int numargs, numlocals; - int returntype; - int syscodeofs; -} funcdecl; - -funcdecl *funcs; -int numfuncs; - -typedef struct -{ - char vname[40]; - int vsofs; - int arraylen; -} strdecl; - -strdecl *str; -int numstr=0; -int stralloc; - -typedef struct -{ - char vname[40]; - int varstartofs; - int arraylen; -} vardecl; - -vardecl *vars; -int numvars; -char kill=0; - -// -- local func vars -- - -typedef struct -{ - int nargs[20]; - char s[2560]; -} lvars; - -//lvars *lvar; -lvars lvar; - -// ============================== Prototypes ================================= - -void ResolveString(char *buffer); -void ExecuteSection(); -void ExecuteEvent(int i); -void ExecuteUserFunc(int i); - -// ================================= Code ==================================== - -int ProcessOperand(); // Mutually dependant functions suck. -int ProcessIfOperand(); // Hell yeah they do, bitch. -void HandleExternFunc(); -void HandleStdLib(); -void ExecuteBlock(); - -void LoadSystemVC() -{ - VFILE *f=0; - int i=0; - - Log("Initializing VC interpreter"); - if (!(f=vopen("system.idx"))) err("Could not open system.idx."); - vread(&numvars, 4, f); - vars=(vardecl *) valloc(numvars*sizeof(vardecl), "LoadSystemVC:vars", OID_VC); - vread(vars, numvars*48, f); - vread(&numfuncs, 4, f); - funcs=(funcdecl *) valloc(numfuncs*sizeof(funcdecl), "LoadSystemVC:funcs", OID_VC); - vread(funcs, numfuncs*76, f); - vread(&numstr, 4, f); - str=(strdecl *) valloc(numstr*sizeof(strdecl), "LoadSystemVC:str", OID_VC); - vread(str, numstr*44, f); - vclose(f); - - if (!(f=vopen("system.vcs"))) err("Could not open system.vcs"); - i=filesize(f); - sysvc=(char *) valloc(i, "LoadSystemVC:sysvc", OID_VC); - vread(&numfuncs, 4, f); - vread(&maxint, 4, f); - vread(&stralloc, 4, f); - - globalint=(int *) valloc(maxint ? maxint*4 : 4, "globalint", OID_VC); - if (stralloc) - { - stringbuf=(char *) valloc((stralloc*256), - "LoadSystemVC:stringbuf", OID_VC); - } - else - { - stringbuf=(char *) valloc(256, - "LoadSystemVC:stringbuf (256)", OID_VC); - } - vread(sysvc, i, f); - vclose(f); - - // Initialize VC stack - vcstack=(quad *) valloc(6000, "vcstack", OID_VC); - vcsp=vcstack; - - movescriptbuf=(char *) valloc(65535, "movescriptbuf", OID_VC); - -Log("system vclib init: %d funcs, %d ints (%d bytes), %d strings (%d bytes)", - numfuncs, numvars, maxint*4, numstr, stralloc*256); -} - -void LoadMapVC(VFILE *f) -{ int codesize=0; - - vread(&mapevents, 4, f); - vread(mapvctbl, 4*mapevents, f); - vread(&codesize, 4, f); - mapvc=(char *) valloc(codesize, "mapvc", OID_VC); - vread(mapvc, codesize, f); -} - -byte GrabC() -{ - return *code++; -} - -word GrabW(void) -{ - word *ptr=(word *) code; - code+=2; - return *ptr; -} - -quad GrabD(void) -{ - quad *ptr=(quad *) code; - code+=4; - return *ptr; -} - -void GrabString(char *str) -{ int i=0; - - i=0; - while (*code) - { - str[i]=*code; - code++; - i++; - } - str[i]=0; - code++; -} - -int ReadInt(char category, int loc, int ofs) -{ - switch (category) - { - case op_UVAR: return globalint[loc]; - case op_UVARRAY: return globalint[loc]; - case op_HVAR0: switch (loc) - { - case 0: return xwin; - case 1: return ywin; - case 2: return cameratracking; - case 3: return timer_count; - case 4: return up; - case 5: return down; - case 6: return left; - case 7: return right; - case 8: return b1; - case 9: return b2; - case 10: return b3; - case 11: return b4; - case 12: return sx; - case 13: return sy; - case 14: return playernum; - case 15: return cc; - case 16: return tracker; - case 17: return mx; - case 18: return my; - case 19: return mb; - case 20: return vctrack; - case 21: return width; - case 22: return depth; - case 23: return mp_volume; - case 24: return (int)vsp; - case 25: return lastent; - case 26: return last_pressed; - } - case op_HVAR1: switch (loc) - { - case 0: return (int) screen[ofs]; - case 1: return entity[ofs].x; - case 2: return entity[ofs].y; - case 3: return entity[ofs].tx; - case 4: return entity[ofs].ty; - case 5: return entity[ofs].facing; - case 6: return entity[ofs].moving; - case 7: return entity[ofs].specframe; - case 8: return entity[ofs].speed; -// case 9: return entity[ofs].movecode; - case 10: return entidx[ofs]; - case 11: return key[ofs]; - case 12: return layer[ofs].hline; - case 13: return (int) (*(byte *)ofs); - case 14: return (int) (*(word *)ofs); - case 15: return (int) (*(quad *)ofs); - case 16: return (int) pal[ofs]; - case 17: return (int) (*(char *)ofs); - case 18: return (int) (*(short*)ofs); - case 19: return (int) (*(int *)ofs); - } - case op_LVAR: return lvar.nargs[loc]; - default: - err("VC Execution error: Invalid ReadInt category %d", (int) category); - } - return 0; -} - -void WriteInt(char category, int loc, int ofs, int value) -{ - switch (category) - { - case op_UVAR: globalint[loc]=value; break; - case op_UVARRAY: globalint[loc]=value; break; - case op_HVAR0: switch (loc) - { - case 0: xwin=value; return; - case 1: ywin=value; return; - case 2: cameratracking=value; return; - case 3: timer_count=value; return; - case 16: tracker=value; return; - case 20: vctrack=value; return; - case 23: mp_volume=value; return; - case 26: last_pressed=value; return; - } - case op_HVAR1: switch (loc) - { - case 0: screen[ofs]=(byte) value; return; - case 1: entity[ofs].x=value; return; - case 2: entity[ofs].y=value; return; - case 3: entity[ofs].tx=value; return; - case 4: entity[ofs].ty=value; return; - case 5: entity[ofs].facing=value; return; - case 6: entity[ofs].moving=value; return; - case 7: entity[ofs].specframe=value; return; - case 8: entity[ofs].speed=value; return; -// case 9: entity[ofs].movecode=value; return; -// case 10: - case 11: key[ofs]=value; return; - case 12: layer[ofs].hline=value; return; - case 13: (*(byte *)ofs)=(byte) value; return; - case 14: (*(word *)ofs)=(word) value; return; - case 15: (*(quad *)ofs)=(quad) value; return; - case 16: pal[ofs]=value; return; - case 17: (*(char *)ofs)=(byte) value; return; - case 18: (*(short*)ofs)=(word) value; return; - case 19: (*(int *)ofs)=(quad) value; return; - } - case op_LVAR: lvar.nargs[loc]=value; return; - default: - err("VC Execution error: Invalid WriteInt category %d", (int) category); - } -} - -int ResolveOperand() -{ - int cr=0; - int d=0; - byte c=0; - - cr=ProcessOperand(); // Get base number - while (1) - { - c=GrabC(); - switch (c) - { - case op_ADD: cr += ProcessOperand(); continue; - case op_SUB: cr -= ProcessOperand(); continue; - case op_DIV: d=ProcessOperand(); - if (!d) cr=0; else cr /= d; continue; - case op_MULT: cr = cr * ProcessOperand(); continue; - case op_MOD: d=ProcessOperand(); - if (!d) cr=0; else cr %= d; continue; - case op_SHL: cr = cr << ProcessOperand(); continue; - case op_SHR: cr = cr >> ProcessOperand(); continue; - case op_AND: cr = cr & ProcessOperand(); continue; - case op_OR: cr = cr | ProcessOperand(); continue; - case op_XOR: cr = cr ^ ProcessOperand(); continue; - case op_END: break; - } - break; - } - return cr; -} - -int ProcessOperand() -{ byte op_desc=0; - byte c=0; - quad d=0; - quad ofs=0; - - op_desc=GrabC(); - switch (op_desc) - { - case op_IMMEDIATE: return GrabD(); - case op_HVAR0: c=GrabC(); return ReadInt(op_HVAR0, c, 0); - case op_HVAR1: c=GrabC(); ofs=ResolveOperand(); return ReadInt(op_HVAR1, c, ofs); - case op_UVAR: d=GrabD(); return ReadInt(op_UVAR, d, 0); - case op_UVARRAY: d=GrabD(); d+=ResolveOperand(); return ReadInt(op_UVARRAY, d, 0); - case op_LVAR: c=GrabC(); return lvar.nargs[c]; - case op_BFUNC: HandleStdLib(); - return vcreturn; - case op_UFUNC: HandleExternFunc(); - return vcreturn; - case op_GROUP: return ResolveOperand(); - default: sprintf(strbuf,"VC Execution error: Invalid operand %d.",op_desc); - err(strbuf); break; - } - return 0; -} - -void HandleStringOperand(char *buffer) -{ - char tbuf[256]; - char *d=0; - word w=0; - int c=0; - int i=0; - int j=0; - int z=0; - - c=GrabC(); - switch (c) - { - case s_IMMEDIATE: GrabString(buffer); break; - case s_GLOBAL: w=GrabW(); - d=(char *) (int) stringbuf + (w*256); - z=strlen(d); - if (strlen(buffer)+z+1>250) - err("Combined string length exceeds 250 char max."); - memcpy(buffer, d, z+1); - break; - case s_ARRAY: w=GrabW(); - w+=ResolveOperand(); - d=(char *) (int) stringbuf + (w*256); - z=strlen(d); - if (strlen(buffer)+z+1>250) - err("Combined string length exceeds 250 char max."); - memcpy(buffer, d, z+1); - break; - case s_NUMSTR: i=ResolveOperand(); - sprintf(buffer,"%d",i); - break; - case s_LEFT: ResolveString(tbuf); - i=ResolveOperand(); - c=i250) - err("Combined string length exceeds 250 char max."); - memcpy(buffer, tbuf, c); - buffer[c]=0; - break; - case s_RIGHT: ResolveString(tbuf); - i=ResolveOperand(); - c=i250) - err("Combined string length exceeds 250 char max."); - memcpy(buffer, tbuf+strlen(tbuf)-c, c); - buffer[c]=0; - break; - case s_MID: ResolveString(tbuf); - i=ResolveOperand(); - j=ResolveOperand(); - i=i250) - err("Combined string length exceeds 250 char max."); - memcpy(buffer, tbuf+i, j); - buffer[j]=0; - break; - case s_CHR: if (strlen(buffer)+2>50) - err("Combined string length exceeds 250 char max."); - buffer[0]=(char) ResolveOperand(); - buffer[1]=0; - break; - case s_LOCAL: c=GrabC(); - d=&lvar.s[c*256]; - z=strlen(d); - if (strlen(buffer)+z+1>250) - err("Combined string length exceeds 250 char max."); - memcpy(buffer, d, z+1); - break; - default: err("Invalid VC string operand %d", (int) c); - } -} - -void ResolveString(char *buffer) -{ char c=0; - - HandleStringOperand(buffer); - while (1) - { - c=GrabC(); - switch (c) - { - case s_ADD: - HandleStringOperand((char *) (int) buffer + strlen(buffer)); break; - case s_END: return; - default: - err("VC execution error: Unknown string operator %d",(int) c); - } - } -} - -void vcpush(quad info) -{ - if (vcsp>=vcstack+1500) err("VC stack overflow."); - *vcsp=info; - vcsp++; -} - -quad vcpop() -{ - if (vcsp==vcstack) err("VC stack underflow."); - vcsp--; - return *vcsp; -} - -void ReadVCVar() -{ int i=0; - int j=0; - - strlwr((char *) args[1]); - for (i=0; i<=numvars; i++) - if (!strcmp(vars[i].vname, (char *) args[1])) break; - if (i1) - j+=atoi((char *) args[2]); - j=globalint[j]; - sprintf(strbuf,"%s:%d",vars[i].vname, j); - Con_Printf(strbuf); - return; - } - for (i=0; i<=numstr; i++) - if (!strcmp(str[i].vname, (char *) args[1])) break; - if (i1) - { - j+=atoi((char *) args[2]); - globalint[j]=atoi((char *) args[3]); - } - else globalint[j]=atoi((char *) args[2]); - sprintf(strbuf,"%s:%d", vars[i].vname, atoi((char *) args[2])); - Con_Printf(strbuf); - return; - } - for (i=0; i<=numstr; i++) - if (!strcmp(str[i].vname, (char *) args[1])) break; - if (i=entities) err("SetPlayer(): Entity index out of range"); - - player=&entity[i]; - playernum=i; - -// entity[i].movecode=0; - entity[i].moving=0; -} - -void vc_Map() -{ - hookretrace=0; - hooktimer=0; - kill=1; - ResolveString(startmap); -} - -void vc_LoadFont() -{ - char vcstr[80]; - - ResolveString(vcstr); - vcreturn=LoadFont(vcstr); -} - -void vc_PlayFLI() -{ - char s[256]; - BITMAP flibuf; - byte *data=0; - VFILE *f=0; - int i=0; - - ResolveString(s); - flibuf.w=sx; - flibuf.h=sy; - flibuf.data=screen; - if (!(f=vopen(s))) err("PlayFLI: Could not open %s.",s); - i=filesize(f); - data=(byte *) malloc(i); - if (!data) err("Not enough memory to play FLI."); - vread(data, i, f); - vclose(f); - play_memory_fli(data, &flibuf, 0, ShowPage); - timer_count=0; - set_intensity(63); -} - -void vc_PrintString() -{ - char s[256]; - int i=0; - - i=ResolveOperand(); - ResolveString(s); - printstring(i,s); -} - -void vc_LoadRaw() -{ - char s[256]; - char *t=0; - VFILE *f=0; - int i=0; - - ResolveString(s); - if (!(f=vopen(s))) err("LoadRaw(): Could not open file %s",s); - i=filesize(f); - t=(char *) valloc(i, "LoadRaw:t", OID_VC); - vread(t, i, f); - vclose(f); - vcreturn=(int) t; -} - -void vc_SetTile() -{ - int x=0; - int y=0; - int layr=0; - int value=0; - - x=ResolveOperand(); - y=ResolveOperand(); - layr=ResolveOperand(); - value=ResolveOperand(); - - switch (layr) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: layers[layr][(y*layer[layr].sizex)+x] = (short) value; break; - case 6: obstruct[(y*layer[0].sizex)+x] = (byte) value; break; - case 7: zone[(y*layer[0].sizex)+x] = (byte) value; break; - default: err("SetTile(): Invalid layer value"); - } -} - -void vc_ScaleSprite() -{ - int x,y,iw,ih,dw,dh,image; - - x=ResolveOperand(); - y=ResolveOperand(); - iw=ResolveOperand(); - ih=ResolveOperand(); - dw=ResolveOperand(); - dh=ResolveOperand(); - image=ResolveOperand(); - if (!LucentOn) CopySpriteZoomClip(x,y,iw,ih,dw,dh,(byte *)image); - if ( LucentOn) CopySpriteZoomLucentClip(x,y,iw,ih,dw,dh,(byte *)image); -} - -void vc_EntityMove() -{ - int i; - - i=ResolveOperand(); - entity[i].moving=0; - entity[i].speedct=0; - - entity[i].delayct=0; - entity[i].mode=0; - entity[i].data1=0; - - ResolveString((char *) (int) movescriptbuf + (int) (i*256)); - entity[i].scriptofs=(char *) (int) movescriptbuf + (int) (i*256); - entity[i].movecode=4; -} - -void vc_HLine() -{ - int x, y, x2, c; - - x=ResolveOperand(); - y=ResolveOperand(); - x2=ResolveOperand(); - c=ResolveOperand(); - if (!LucentOn) HLineClip(x,y,x2,c); - if ( LucentOn) HLineLucentClip(x,y,x2,c); - -} - -void vc_VLine() -{ - int x, y, y2, c; - - x=ResolveOperand(); - y=ResolveOperand(); - y2=ResolveOperand(); - c=ResolveOperand(); - if (!LucentOn) VLineClip(x,y,y2,c); - if ( LucentOn) VLineLucentClip(x,y,y2,c); -} - -void vc_Line() -{ - int x, y, x2, y2, c; - - x=ResolveOperand(); - y=ResolveOperand(); - x2=ResolveOperand(); - y2=ResolveOperand(); - c=ResolveOperand(); - if (!LucentOn) LineClip(x,y,x2,y2,c); - if ( LucentOn) LineLucentClip(x,y,x2,y2,c); -} - -void vc_Circle() -{ - int x, y, radius, c; - - x=ResolveOperand(); - y=ResolveOperand(); - radius=ResolveOperand(); - c=ResolveOperand(); - if (!LucentOn) CircleClip(x,y,radius,c); - if ( LucentOn) CircleLucentClip(x,y,radius,c); -} - -void vc_CircleFill() -{ - int x, y, radius, c; - - x=ResolveOperand(); - y=ResolveOperand(); - radius=ResolveOperand(); - c=ResolveOperand(); - if (!LucentOn) CircleFillClip(x,y,radius,c); - if ( LucentOn) CircleFillLucentClip(x,y,radius,c); -} - -void vc_Rect() -{ - int x, y, x2, y2, c; - - x=ResolveOperand(); - y=ResolveOperand(); - x2=ResolveOperand(); - y2=ResolveOperand(); - c=ResolveOperand(); - if (!LucentOn) RectClip(x,y,x2,y2,c); - if ( LucentOn) RectLucentClip(x,y,x2,y2,c); -} - -void vc_RectFill() -{ - int x, y, x2, y2, c; - - x=ResolveOperand(); - y=ResolveOperand(); - x2=ResolveOperand(); - y2=ResolveOperand(); - c=ResolveOperand(); - if (!LucentOn) RectFillClip(x,y,x2,y2,c); - if ( LucentOn) RectFillLucentClip(x,y,x2,y2,c); -} - -void vc_strlen() -{ - char str[256]; - - ResolveString(str); - vcreturn=strlen(str); -} - -void vc_strcmp() -{ - char str1[256], str2[256]; - - ResolveString(str1); - ResolveString(str2); - vcreturn=strcmp(str1, str2); -} - -void vc_FontWidth() -{ - int i; - - i=ResolveOperand(); - if (i>=numfonts) - { - vcreturn=0; - return; - } - vcreturn=font[i].width; -} - -void vc_FontHeight() -{ - int i; - - i=ResolveOperand(); - if (i>=numfonts) - { - vcreturn=0; - return; - } - vcreturn=font[i].height; -} - -void vc_SetPixel() -{ - int x, y, c; - - x=ResolveOperand(); - y=ResolveOperand(); - c=ResolveOperand(); - SetPixelClip(x,y,c); -} - -void vc_GetPixel() -{ - int x, y; - - x=ResolveOperand(); - y=ResolveOperand(); - vcreturn=GetPixelClip(x,y); -} - -void vc_EntityOnScreen() -{ - int i,j; - - i=ResolveOperand(); - for (j=0; j63) r=63; - g=ResolveOperand(); if (g<0) g=0; if (g>63) g=63; - b=ResolveOperand(); if (b<0) b=0; if (b>63) b=63; - percent=100-ResolveOperand(); - intensity=ResolveOperand(); - - for (i=0; i<256; i++) - { - wr=pal[(i*3)]; - wg=pal[(i*3)+1]; - wb=pal[(i*3)+2]; - - wr=((wr*percent)+(r*(100-percent)))/100; - wg=((wg*percent)+(g*(100-percent)))/100; - wb=((wb*percent)+(b*(100-percent)))/100; - - pal2[(i*3)]=wr*intensity/63; - pal2[(i*3)+1]=wg*intensity/63; - pal2[(i*3)+2]=wb*intensity/63; - } - SetPalette(pal2); -} - -void EnforceNoDirectories(char *s) -{ - char y[256], *p; - - strcpy(y, s); - p=(char *) (int) y + (int) strlen(y); - while (p>y && *p != '/' && *p != '\\') - p--; - if (*p == '/' || *p == '\\') p++; - strcpy(s, p); -} - -void vc_OpenFile() -{ - VFILE *f; - char fname[256]; - - ResolveString(fname); - EnforceNoDirectories(fname); - - f=vopen(fname); - vcreturn=(quad) f; - - Log(" --> VC opened file %s, ptr %u", fname, (quad) f); -} - -void vc_CloseFile() -{ - VFILE *f; - - f=(VFILE *) ResolveOperand(); - vclose(f); - - Log(" --> VC closed file at ptr %u", (quad) f); -} - -void vc_QuickRead() -{ - char fname[256], c, *p; - int d=0, l, i; - VFILE *f; - word w=0; - - ResolveString(fname); - EnforceNoDirectories(fname); - c=GrabC(); - if (c==op_STRING) - { - w=GrabW(); - d=0; - } - if (c==op_SARRAY) - { - w=GrabW(); - d=ResolveOperand(); - } - l=ResolveOperand(); - l=l ? l : 1; - if (!(f=vopen(fname))) err("QuickRead() - could not open %s",fname); - - p=(char *) (quad) stringbuf + ((w+d)*256); - for (i=0; i=entities) err("AddFollower(): Not a valid entity index. (%d)",i); - follower[(int)numfollowers]=i; - numfollowers++; -// ResetFollowers(); -} - -void vc_FlatPoly() -{ - int a, b, c, d, e, f, g; - - a=ResolveOperand(); - b=ResolveOperand(); - c=ResolveOperand(); - d=ResolveOperand(); - e=ResolveOperand(); - f=ResolveOperand(); - g=ResolveOperand(); - FlatPoly(a,b,c,d,e,f,g); -} - -void vc_TMapPoly() -{ - int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o; - - a=ResolveOperand(); - b=ResolveOperand(); - c=ResolveOperand(); - d=ResolveOperand(); - e=ResolveOperand(); - f=ResolveOperand(); - g=ResolveOperand(); - h=ResolveOperand(); - i=ResolveOperand(); - j=ResolveOperand(); - k=ResolveOperand(); - l=ResolveOperand(); - m=ResolveOperand(); - n=ResolveOperand(); - o=ResolveOperand(); - TMapPoly(a,b,c,d,e,f,g,h,i,j,k,l,m,n,(char *) o); -} - -void vc_CacheSound() -{ - char fname[256]; - - ResolveString(fname); - vcreturn=CacheSound(fname); - -} - -void vc_PlaySound() -{ - int a, b, c; - - a=ResolveOperand(); - b=ResolveOperand(); - c=ResolveOperand(); - PlaySound(a, b, c); -} - -void vc_RotScale() -{ - int a, b, c, d, e, f, g; - - a=ResolveOperand(); - b=ResolveOperand(); - c=ResolveOperand(); - d=ResolveOperand(); - e=ResolveOperand(); - f=ResolveOperand(); - g=ResolveOperand(); - - RotScale(a, b, c, d, e*3.14159 / 180, (float) f/1000, (byte *) g); -} - -void vc_MapLine() -{ - int x, y, sy, l; - int xtc, ytc, xofs, yofs; - - x=ResolveOperand(); - y=ResolveOperand(); - sy=ResolveOperand(); - l=ResolveOperand(); - - xtc=x >> 4; - ytc=y >> 4; - xofs= -(x&15); - yofs= (y&15); - - MapLine(xofs, sy, yofs, (word *) (layers[l]+((ytc*layer[l].sizex)+xtc))); -} - -void vc_TMapLine() -{ - int x, y, sy, l; - int xtc, ytc, xofs, yofs; - - x=ResolveOperand(); - y=ResolveOperand(); - sy=ResolveOperand(); - l=ResolveOperand(); - - xtc=x >> 4; - ytc=y >> 4; - xofs= -(x&15); - yofs= (y&15); - - TMapLine(xofs, sy, yofs, (word *) (layers[l]+((ytc*layer[l].sizex)+xtc))); -} - -void vc_val() -{ - char s[256]; - - ResolveString(s); - vcreturn=atoi(s); -} - -void vc_TScaleSprite() -{ - int x,y,iw,ih,dw,dh,image; - - x=ResolveOperand(); - y=ResolveOperand(); - iw=ResolveOperand(); - ih=ResolveOperand(); - dw=ResolveOperand(); - dh=ResolveOperand(); - image=ResolveOperand(); - if (!LucentOn) TCopySpriteZoomClip(x,y,iw,ih,dw,dh,(byte *) image); - if ( LucentOn) TCopySpriteZoomLucentClip(x,y,iw,ih,dw,dh,(byte *) image); -} - -void vc_GrabRegion() -{ - int x1, y1, x2, y2; - int i, j, w, h; - char *ptr; - - x1=ResolveOperand(); - y1=ResolveOperand(); - x2=ResolveOperand()+1; - y2=ResolveOperand()+1; - ptr=(char *) ResolveOperand(); - - if (x2>sx-1) x2=sx-1; - if (y2>sy-1) y2=sy-1; - if (x1<0) x1=0; - if (y1<0) y1=0; - - w=x2 - x1; - h=y2 - y1; - - for (j=y1; j VC renamed %s to %s.", s1, s2); -} - -void vc_fdelete() -{ - char s[256]; - - ResolveString(s); - EnforceNoDirectories(s); - remove(s); - - Log(" --> VC deleted %s.", s); -} - -void vc_fwopen() -{ - char s[256]; - - ResolveString(s); - EnforceNoDirectories(s); - vcreturn=(int) fopen(s,"wb"); - - Log(" --> VC opened %s for writing, ptr %u.", s, vcreturn); -} - -void vc_fwclose() -{ - FILE *f; - - f=(FILE *) ResolveOperand(); - fclose(f); - - Log(" --> VC close file opened for writing, ptr %u.", (int) f); -} - -void vc_memcpy() -{ - int a, b, c; - - a=ResolveOperand(); - b=ResolveOperand(); - c=ResolveOperand(); - memcpy((char *) a, (char *) b, c); -} - -void vc_memset() -{ - int a, b, c; - - a=ResolveOperand(); - b=ResolveOperand(); - c=ResolveOperand(); - memset((char *) a, (byte) b, c); -} - -void vc_Silhouette() -{ - int x=ResolveOperand(); - int y=ResolveOperand(); - int w=ResolveOperand(); - int h=ResolveOperand(); - byte *img=(byte *) ResolveOperand(); - byte c=(byte) ResolveOperand(); - - if (ClipOn) - { - LucentOn ? SilhouetteLucentClip(x,y,w,h,c,img) - : SilhouetteClip(x,y,w,h,c,img); - } - else - { - LucentOn ? SilhouetteLucent(x,y,w,h,c,img) - : Silhouette(x,y,w,h,c,img); - } -} - -void vc_SilhouetteScale() -{ - int x=ResolveOperand(); - int y=ResolveOperand(); - int sw=ResolveOperand(); - int sh=ResolveOperand(); - int dw=ResolveOperand(); - int dh=ResolveOperand(); - byte *img=(byte *) ResolveOperand(); - byte c=(byte) ResolveOperand(); - - if (ClipOn) - { - LucentOn ? SilhouetteZoomLucentClip(x,y,sw,sh,dw,dh,c,img) - : SilhouetteZoomClip(x,y,sw,sh,dw,dh,c,img); - } - else - { - LucentOn ? SilhouetteZoomLucent(x,y,sw,sh,dw,dh,c,img) - : SilhouetteZoom(x,y,sw,sh,dw,dh,c,img); - } -} - -void vc_Tint() -{ - int x=ResolveOperand(); - int y=ResolveOperand(); - int w=ResolveOperand(); - int h=ResolveOperand(); - byte *img=(byte *)ResolveOperand(); - byte c=(byte)ResolveOperand(); - - ClipOn ? TintClip(x,y,w,h,c,img) - : Tint(x,y,w,h,c,img); -} - -void vc_TintScale() -{ - int x=ResolveOperand(); - int y=ResolveOperand(); - int sw=ResolveOperand(); - int sh=ResolveOperand(); - int dw=ResolveOperand(); - int dh=ResolveOperand(); - byte *img=(byte *) ResolveOperand(); - byte c=(byte) ResolveOperand(); - - ClipOn ? TintZoomClip(x,y,sw,sh,dw,dh,c,img) - : TintZoom(x,y,sw,sh,dw,dh,c,img); -} - -void vc_Mosaic() -{ - int a,b,c,d,e,f,g; - - a=ResolveOperand(); - b=ResolveOperand(); - c=ResolveOperand(); - d=ResolveOperand(); - e=ResolveOperand(); - f=ResolveOperand(); - g=ResolveOperand(); - Mosaic(a,b,(byte *) c,d,e,f,g); -} - -void vc_WriteVars() -{ - FILE *f; - - f=(FILE *) ResolveOperand(); - fwrite(globalint, 4, maxint, f); - fwrite(stringbuf, 256, stralloc, f); -} - -void vc_ReadVars() -{ - VFILE *f; - - f=(VFILE *) ResolveOperand(); - vread(globalint, 4*maxint, f); - vread(stringbuf, 256*stralloc, f); -} - -void vc_Asc() -{ - char s[256]; - - ResolveString(s); - vcreturn=(int) s[0]; -} - -void vc_NumForScript() -{ - vcreturn=GrabD(); -} - -void vc_Filesize() -{ - char s[256]; - VFILE *f; - - ResolveString(s); - f=vopen(s); - vcreturn=filesize(f); - vclose(f); -} - -void vc_FTell() -{ - VFILE *f=(VFILE *)ResolveOperand(); - vcreturn=vtell(f); -} - -void vc_CheckCorrupt() -{ - Log("checking for corruption..."); - CheckCorruption(); -} - -void HandleStdLib() -{ - int x=0; - byte c=0; - - c=GrabC(); - switch (c) - { - case 1: vc_Exit_(); break; - case 2: vc_Message(); break; - case 3: vc_Malloc(); break; - case 4: vc_Free(); break; - case 5: vc_pow(); break; - case 6: vc_loadimage(); break; - case 7: vc_copysprite(); break; - case 8: vc_tcopysprite(); break; - case 9: Render(); break; - case 10: ShowPage(); break; - case 11: vc_EntitySpawn(); break; - case 12: vc_SetPlayer(); break; - case 13: vc_Map(); break; - case 14: vc_LoadFont(); break; - case 15: vc_PlayFLI(); break; - case 16: curx=ResolveOperand(); cury=ResolveOperand(); break; - case 17: vc_PrintString(); break; - case 18: vc_LoadRaw(); break; - case 19: vc_SetTile(); break; - case 20: allowconsole=ResolveOperand(); break; - case 21: vc_ScaleSprite(); break; - case 22: ProcessEntities(); break; - case 23: UpdateControls(); break; - case 24: UnPress(ResolveOperand()); break; - case 25: vc_EntityMove(); break; - case 26: vc_HLine(); break; - case 27: vc_VLine(); break; - case 28: vc_Line(); break; - case 29: vc_Circle(); break; - case 30: vc_CircleFill(); break; - case 31: vc_Rect(); break; - case 32: vc_RectFill(); break; - case 33: vc_strlen(); break; - case 34: vc_strcmp(); break; - case 35: break; //CD_Stop(); break; - case 36: ResolveOperand(); break; //CD_Play(ResolveOperand()); break; - case 37: vc_FontWidth(); break; - case 38: vc_FontHeight(); break; - case 39: vc_SetPixel(); break; - case 40: vc_GetPixel(); break; - case 41: vc_EntityOnScreen(); break; - case 42: vcreturn=0; - if ((x=ResolveOperand())) - vcreturn=rand()%x; - break; - case 43: vc_GetTile(); break; - case 44: vc_HookRetrace(); break; - case 45: vc_HookTimer(); break; - case 46: vc_SetResolution(); break; - case 47: vc_SetRString(); break; - case 48: vc_SetClipRect(); break; - case 49: vc_SetRenderDest(); break; - case 50: vc_RestoreRenderSettings(); break; - case 51: vc_PartyMove(); break; - case 52: vcreturn=sintbl[ResolveOperand()]; break; - case 53: vcreturn=costbl[ResolveOperand()]; break; - case 54: vcreturn=tantbl[ResolveOperand()]; break; - case 55: ReadMouse(); break; - case 56: ClipOn=ResolveOperand(); break; - case 57: LucentOn=ResolveOperand(); break; - case 58: vc_WrapBlit(); break; - case 59: vc_TWrapBlit(); break; - case 60: vc_SetMousePos(); break; - case 61: vc_HookKey(); break; - case 62: vc_PlayMusic(); break; - case 63: StopMusic(); break; - case 64: vc_PaletteMorph(); break; - case 65: vc_OpenFile(); break; - case 66: vc_CloseFile(); break; - case 67: vc_QuickRead(); break; - case 68: vc_AddFollower(); break; -// case 69: vc_KillFollower(); break; -// case 70: vc_KillAllFollowers(); break; -// case 71: ResetFollowers(); - case 72: vc_FlatPoly(); break; - case 73: vc_TMapPoly(); break; - case 74: vc_CacheSound(); break; - case 75: FreeAllSounds(); break; - case 76: vc_PlaySound(); break; - case 77: vc_RotScale(); break; - case 78: vc_MapLine(); break; - case 79: vc_TMapLine(); break; - case 80: vc_val(); break; - case 81: vc_TScaleSprite(); break; - case 82: vc_GrabRegion(); break; - case 83: vc_Log(); break; - case 84: vc_fseekline(); break; - case 85: vc_fseekpos(); break; - case 86: vc_fread(); break; - case 87: vc_fgetbyte(); break; - case 88: vc_fgetword(); break; - case 89: vc_fgetquad(); break; - case 90: vc_fgetline(); break; - case 91: vc_fgettoken(); break; - case 92: vc_fwritestring(); break; - case 93: vc_fwrite(); break; - case 94: vc_frename(); break; - case 95: vc_fdelete(); break; - case 96: vc_fwopen(); break; - case 97: vc_fwclose(); break; - case 98: vc_memcpy(); break; - case 99: vc_memset(); break; - case 100: vc_Silhouette(); break; - case 101: vcreturn=(int) InitMosaicTable(); break; - case 102: vc_Mosaic(); break; - case 103: vc_WriteVars(); break; - case 104: vc_ReadVars(); break; - case 105: ExecuteEvent(ResolveOperand()); break; - case 106: vc_Asc(); break; - case 107: ExecuteUserFunc(ResolveOperand()); break; - case 108: vc_NumForScript(); break; - case 109: vc_Filesize(); break; - case 110: vc_FTell(); break; - case 111: vc_CheckCorrupt(); break; - default: err("VC Execution error: Invalid STDLIB index. (%d)",(int) c); - } -} - -// ========================== VC Interpretation Core ========================== - -int ProcessIf() -{ - byte exec, c; - - exec=ProcessIfOperand(); // Get base value; - - while (1) - { - c=GrabC(); - switch (c) - { - case i_AND: exec=exec & ProcessIfOperand(); continue; - case i_OR: exec=exec | ProcessIfOperand(); continue; - case i_UNGROUP: break; - } - break; - } - return exec; -} - -int ProcessIfOperand() -{ - byte op_desc; - int eval; - - eval=ResolveOperand(); - op_desc=GrabC(); - switch (op_desc) - { - case i_ZERO: if (!eval) return 1; else return 0; - case i_NONZERO: if (eval) return 1; else return 0; - case i_EQUALTO: if (eval == ResolveOperand()) return 1; else return 0; - case i_NOTEQUAL: if (eval != ResolveOperand()) return 1; else return 0; - case i_GREATERTHAN: if (eval > ResolveOperand()) return 1; else return 0; - case i_GREATERTHANOREQUAL: if (eval >= ResolveOperand()) return 1; else return 0; - case i_LESSTHAN: if (eval < ResolveOperand()) return 1; else return 0; - case i_LESSTHANOREQUAL: if (eval <= ResolveOperand()) return 1; else return 0; - case i_GROUP: if (ProcessIf()) return 1; else return 0; - } - return 0; -} - -void HandleIf() -{ - char *d; - - if (ProcessIf()) - { - GrabD(); - return; - } - d=(char *) GrabD(); - code=(char *) (int) basevc + (int) d; - - return; -} - -void HandleExternFunc() -{ - word i, j, k; - //lvars *ob = NULL; - //lvars *save = NULL; - lvars temp; - lvars ob; - - // save lvar - memcpy(&temp, &lvar, sizeof(lvars)); - - memset(&ob, 0, sizeof(lvars)); - //ob = (lvars *)valloc(sizeof(lvars)); //2640); //sizeof(lvars)); //2640); - //MSS_CHECK_POINTER_VALIDITY(ob); - //MSS_SET_BLOCK_LABEL(ob, "ob"); - - k = 0; - i = GrabW(); - for (j=0; j Entering user func %s, codeofs %d", - funcs[i].fname, funcs[i].syscodeofs); - } - - ExecuteBlock(); - basevc = (char *)vcpop(); - - // restore lvar - memcpy(&lvar, &temp, sizeof(lvars)); - //memcpy(lvar, &temp, sizeof(lvars)); - //vfree(lvar); - //lvar = ob; - - if (vctrack) - { - Log(" --> Returned from %s", funcs[i].fname); - } - -// MSS_CHECK_ALL_BLOCKS; -} - -void HandleAssign() -{ - byte c, d; - word w; - quad location=0, value, ofs=0; - - c=GrabC(); - if (c==op_STRING) - { - w=GrabW(); - c=GrabC(); - if (c!=a_SET) err("VC execution error: Corrupt string assignment"); - location=(quad) stringbuf + (w*256); - ResolveString((char *) location); - return; - } - if (c==op_SARRAY) - { - w=GrabW(); - w+=ResolveOperand(); - c=GrabC(); - if (c!=a_SET) err("VC execution error: Corrupt string assignment"); - location=(quad) stringbuf + (w*256); - ResolveString((char *) location); - return; - } - if (c==op_SLOCAL) - { - w=GrabW(); - c=GrabC(); - if (c!=a_SET) err("VC execution error: Corrupt string assignment"); - location=(quad) &lvar.s[w*256]; - ResolveString((char *) location); - return; - } - switch (c) - { - case op_UVAR: location=GrabD(); break; - case op_UVARRAY: location=GrabD(); location+=ResolveOperand(); break; - case op_HVAR0: location=(int) GrabC(); break; - case op_HVAR1: location=(int) GrabC(); ofs=ResolveOperand(); break; - case op_LVAR: location=(int) GrabC(); break; - default: err("VC Execution error: Unknown assignment category."); - } - value=ReadInt(c, location, ofs); - d=GrabC(); - switch(d) - { - case a_SET: value=ResolveOperand(); break; - case a_INC: value++; break; - case a_DEC: value--; break; - case a_INCSET: value+=ResolveOperand(); break; - case a_DECSET: value-=ResolveOperand(); break; - default: - err("VC Execution error: Invalid assignment operator %d.", (int) d); - } - WriteInt(c, location, ofs, value); -} - -void HandleSwitch() -{ - int realvalue=0; - int compvalue=0; - byte c=0; - byte *next=0; - - realvalue=ResolveOperand(); - c=GrabC(); - while (c!=opRETURN) - { - compvalue=ResolveOperand(); - next=(byte *) GrabD(); - if (compvalue!=realvalue) - { - code=(char *) (int) basevc+(int) next; - c=GrabC(); - continue; - } - ExecuteSection(); - c=GrabC(); - } -} - -void ExecuteVC() -{ - byte c=0; - - while (1) - { - if (kill) break; - c=GrabC(); - switch (c) - { - case opEXEC_STDLIB: HandleStdLib(); break; - case opEXEC_LOCALFUNC: break; - case opEXEC_EXTERNFUNC: HandleExternFunc(); break; - case opIF: HandleIf(); break; - case opELSE: break; - case opGOTO: code=basevc+GrabD(); break; - case opSWITCH: HandleSwitch(); break; - case opASSIGN: HandleAssign(); break; - case opRETURN: code=(char *) vcpop(); break; - case opSETRETVAL: vcreturn=ResolveOperand(); break; - default: - err("Internal VC execution error. (%d)",(int) code - (int) basevc); - } - if ((int) code != -1) continue; else break; - } -} - -void ExecuteBlock() -{ - byte c=0; - - while (1) - { - if (kill) break; - c=GrabC(); - switch (c) - { - case opEXEC_STDLIB: HandleStdLib(); break; - case opEXEC_LOCALFUNC: break; - case opEXEC_EXTERNFUNC: HandleExternFunc(); break; - case opIF: HandleIf(); break; - case opELSE: break; - case opGOTO: code=basevc+GrabD(); break; - case opSWITCH: HandleSwitch(); break; - case opASSIGN: HandleAssign(); break; - case opRETURN: code=(char *) vcpop(); break; - case opSETRETVAL: vcreturn=ResolveOperand(); break; - default: - err("Internal VC execution error. (%d)",(int) code - (int) basevc); - } - if (c != opRETURN) continue; else break; - } -} - -void ExecuteSection() -{ - byte c=0; - - while (1) - { - if (kill) break; - c=GrabC(); - switch (c) - { - case opEXEC_STDLIB: HandleStdLib(); break; - case opEXEC_LOCALFUNC: break; - case opEXEC_EXTERNFUNC: HandleExternFunc(); break; - case opIF: HandleIf(); break; - case opELSE: break; - case opGOTO: code=basevc+GrabD(); break; - case opSWITCH: HandleSwitch(); break; - case opASSIGN: HandleAssign(); break; - case opRETURN: break; - case opSETRETVAL: vcreturn=ResolveOperand(); break; - default: - err("Internal VC execution error. (%d)", (int) code - (int) basevc); - } - if (c != opRETURN) continue; else break; - } -} - -void ExecuteEvent(int i) -{ - invc++; - vcpush((quad) code); - vcpush((quad) basevc); - if (i>mapevents) err("VC event out of bounds (%d)",i); - basevc=mapvc; - code=(char *) (int) mapvc + (int) mapvctbl[i]; - vcpush(-1); - ExecuteVC(); - basevc=(char *) vcpop(); - code=(char *) vcpop(); - invc--; -} - -void ExecuteUserFunc(int i) -{ - //lvars *ob=0; - lvars temp; - - // save lvar - memcpy(&temp, &lvar, sizeof(lvars)); - - vcpush((quad) code); - vcpush((quad) basevc); - - if (i > numfuncs) - err("VC event out of bounds"); - - basevc = sysvc; - code = (char *)(sysvc + funcs[i].syscodeofs); - - vcpush(-1); - - memset(&lvar, 0, sizeof(lvar)); - //ob = lvar; - //lvar = (lvars *)valloc(sizeof(lvars)); //2640); - //MSS_SET_BLOCK_LABEL(lvar, "lvar"); - - ExecuteVC(); - basevc = (char *) vcpop(); - code = (char *) vcpop(); - - //free(lvar); - //lvar = ob; - - // restore lvar - memcpy(&lvar, &temp, sizeof(lvars)); -} - -void HookRetrace() -{ - if (!hookretrace) return; - if (hookretrace=USERFUNC_MARKER) ExecuteUserFunc(hookretrace-USERFUNC_MARKER); -} - -void HookTimer() -{ - if (!hooktimer) return; - if (hooktimer=USERFUNC_MARKER) ExecuteUserFunc(hooktimer-USERFUNC_MARKER); -} - -void HookKey(int script) -{ - if (!script) return; - if (script=USERFUNC_MARKER) ExecuteUserFunc(script-USERFUNC_MARKER); -} diff --git a/16/v2/source/verge/ENGINE/VC.H b/16/v2/source/verge/ENGINE/VC.H deleted file mode 100755 index 00906ceb..00000000 --- a/16/v2/source/verge/ENGINE/VC.H +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef VC_H -#define VC_H - -typedef struct -{ - char fname[40]; - char argtype[12]; - int numargs; - int returntype; - int syscodeofs; -} funcdecl; - -extern funcdecl funcs[100]; -extern int numfuncs, mapevents; -extern int hookretrace, hooktimer; - -typedef struct -{ - char vname[40]; - int varstartofs; - int arraylen; -} vardecl; - -extern vardecl vars[100]; -extern int numvars, invc; -extern char *mapvc, kill; -extern char *vcsp, *vcstack; - -void LoadSystemVC(); -void LoadMapVC(VFILE *f); -void ReadVCVar(); -void WriteVCVar(); -void ExecuteEvent(int); -void ExecuteUserFunc(int); - -void HookRetrace(); -void HookTimer(); -void HookKey(int script); - -#endif diff --git a/16/v2/source/verge/ENGINE/VCCODE.H b/16/v2/source/verge/ENGINE/VCCODE.H deleted file mode 100755 index 74495139..00000000 --- a/16/v2/source/verge/ENGINE/VCCODE.H +++ /dev/null @@ -1,111 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// We never use zero as a tag. This makes it easier to track down misbehaving -// VC code, since zero is commonly come-by when going off into uncharted -// depths of memory. - -#define ERROR 0 - -// Opcode values. - -#define opEXEC_STDLIB 1 -#define opEXEC_LOCALFUNC 2 -#define opEXEC_EXTERNFUNC 3 -#define opIF 4 -#define opELSE 5 -#define opGOTO 6 -#define opSWITCH 7 -#define opCASE 8 -#define opRETURN 9 -#define opASSIGN 10 -#define opSETRETVAL 11 -#define opSETLOCALSTACK 12 - -// Operand types. - -#define op_IMMEDIATE 1 -#define op_HVAR0 2 -#define op_HVAR1 3 -#define op_UVAR 4 -#define op_UVARRAY 5 -#define op_LVAR 6 -#define op_BFUNC 7 -#define op_UFUNC 8 -#define op_GROUP 9 -#define op_STRING 10 -#define op_SARRAY 11 -#define op_SLOCAL 12 - -// Variable types. - -#define v_IMMEDIATE 1 // is this necessary? -#define v_CHAR 2 -#define v_PTR 3 -#define v_INT 4 - -// IF relational operators. - -#define i_ZERO 1 -#define i_NONZERO 2 -#define i_EQUALTO 3 -#define i_NOTEQUAL 4 -#define i_GREATERTHAN 5 -#define i_LESSTHAN 6 -#define i_GREATERTHANOREQUAL 7 -#define i_LESSTHANOREQUAL 8 -#define i_GROUP 9 -#define i_UNGROUP 10 -#define i_AND 11 -#define i_OR 12 - -// Assignment operators. - -#define a_SET 1 -#define a_INC 2 -#define a_DEC 3 -#define a_INCSET 4 -#define a_DECSET 5 -#define a_MULTSET 6 -#define a_DIVSET 7 - -// Operand combination operators. - -#define op_ADD 1 -#define op_SUB 2 -#define op_MULT 3 -#define op_DIV 4 -#define op_MOD 5 -#define op_SHL 6 -#define op_SHR 7 -#define op_AND 8 -#define op_OR 9 -#define op_XOR 10 -#define op_END 11 - -// String components - -#define s_IMMEDIATE 1 -#define s_GLOBAL 2 -#define s_ARRAY 3 -#define s_NUMSTR 4 -#define s_LEFT 5 -#define s_RIGHT 6 -#define s_MID 7 -#define s_LOCAL 8 -#define s_ADD 9 -#define s_CHR 10 -#define s_END 11 diff --git a/16/v2/source/verge/ENGINE/VDRIVER.C b/16/v2/source/verge/ENGINE/VDRIVER.C deleted file mode 100755 index 69008c64..00000000 --- a/16/v2/source/verge/ENGINE/VDRIVER.C +++ /dev/null @@ -1,2814 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#define VDRIVER_H - -#include -#include -#include -#include -#include "verge.h" - -#define SWAP(a,b) { a-=b; b+=a; a=b-a; } - -// ================================= Data ==================================== - -char *DriverDesc; - -byte *screen,*video,*vscreen; -byte pal[768], pal2[768]; -byte *translucency_table; - -int sx, sy; -int tx, ty; -int tsx, tsy; -int cx1=0,cy1=0,cx2=319,cy2=199; - -// Driver function-pointers. -int (*ShutdownVideo) (int i); -int (*ShowPage) (void); - -// ================================= Code ==================================== - -void SetPalette(byte *pall) -{ quad i; - - outp(0x03c8, 0); - for (i=0; i<768; i++) - outp(0x03c9, pall[i]); -} - -void GetPalette() -{ quad i; - - outp(0x03c7, 0); - for (i=0; i<768; i++) - pal[i]=inp(0x03c9); -} - -void set_intensity(quad n) -{ quad i; - - for (i=0; i<768; i++) - pal2[i] = (pal[i] * n) >> 6; - - SetPalette(pal2); -} - -int LFB_ShowPage(void) -{ - if (key[SCAN_ALT] && key[SCAN_X]) err("Exiting: ALT-X pressed."); - RenderGUI(); - cpubyte=PFLIP; - memcpy(video,screen,sx*sy); - cpubyte=ETC; - return 0; -} - -void CopySprite(int x, int y, int width, int height, byte *src) -{ - byte *d; - - cpubyte=RENDER; - d=screen+(y*sx)+x; - for (; height; height--) - { - memcpy(d,src,width); - src+=width; - d+=sx; - } - cpubyte=ETC; -} - -void TCopySprite(int x, int y, int width, int height, byte *src) -{ - byte *d, c; - - cpubyte=RENDER; - d=screen+(y*sx)+x; - for (; height; height--) - { - for (x=0; x>16)]; - xerr+=xadj; - } - d+=sx; - yerr+=yadj; - src+=(yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void TCopySpriteZoom(int x, int y, int sw, int sh, int dw, int dh, byte *src) -{ - int i,j; - int xerr,yerr; - int xadj,yadj; - byte *d; - byte c; - - cpubyte=RENDER; - if (dw<1 || dh<1) return; - xadj = (sw<<16)/dw; - yadj = (sh<<16)/dh; - d = screen+(y*sx)+x; - yerr=0; - for (i=0; i>16)]; - if (c) - d[j]=c; - xerr+=xadj; - } - d+=sx; - yerr+=yadj; - src+=(yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void CopySpriteZoomLucent(int x, int y, int sw, int sh, int dw, int dh, byte *src) -{ - int i,j; - int xerr,yerr; - int xadj,yadj; - byte *d; - - cpubyte=RENDER; - if (dw<1 || dh<1) return; - xadj = (sw<<16)/dw; - yadj = (sh<<16)/dh; - d = screen+(y*sx)+x; - yerr=0; - - for (i=0; i>16)]<<8)]; - xerr+=xadj; - } - d+=sx; - yerr+=yadj; - src+=(yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void TCopySpriteZoomLucent(int x, int y, int sw, int sh, int dw, int dh, byte *src) -{ - int i,j; - int xerr,yerr; - int xadj,yadj; - byte *d; - byte c; - - cpubyte=RENDER; - if (dw<1 || dh<1) return; - xadj = (sw<<16)/dw; - yadj = (sh<<16)/dh; - d = screen+(y*sx)+x; - yerr=0; - - for (i=0; i>16)]; - if (c) - d[j]=c; - xerr+=xadj; - } - d+=sx; - yerr+=yadj; - src+=(yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void Silhouette(int x, int y, int width, int height, int color, byte *src) -{ - byte *d=0; - - cpubyte=RENDER; - if (height<1 || width<1) return; - d=screen+(y*sx)+x; - do { - for (x=0; x>16)]) - d[x]=color; - xerr+=xadj; - } - d+=sx; - yerr+=yadj; - src+=(yerr>>16)*sw; - yerr &= 0xffff; - } while (--dh); - cpubyte=ETC; -} - -void SilhouetteLucent(int x, int y, int width, int height, int color, byte *src) -{ - byte *d=0; - byte *range=0; - - cpubyte=RENDER; - if (width<1 || height<1) return; - d=screen+(y*sx)+x; - range=translucency_table+(color<<8); - do { - for (x=0; x>16)]) - d[x]=range[d[x]]; - xerr+=xadj; - } - d+=sx; - yerr+=yadj; - src+=(yerr>>16)*sw; - yerr &= 0xffff; - } while (--dh); - cpubyte=ETC; -} - -// aen -void Tint(int x, int y, int width, int height, int color, byte *src) -{ - byte *d=0; - byte *range=0; - byte c=0; - - cpubyte=RENDER; - if (width<1 || height<1) return; - d=screen+(y*sx)+x; - range=translucency_table+(color<<8); - do { - for (x=0; x>16)]; - if (c) - d[x]=range[c]; - xerr+=xadj; - } - d+=sx; - yerr+=yadj; - src+=(yerr>>16)*sw; - yerr &= 0xffff; - } while (--dh); - cpubyte=ETC; -} - -void CopySpriteClip(int x, int y, int width, int height, byte *src) -{ - byte *s,*d; - int xl,yl,xs,ys; - - cpubyte=RENDER; - xl=width; - yl=height; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x>16)*sw); - d = screen+(y*sx)+x; - yerr = yerr_start & 0xffff; - for (i=0; i>16)]; - xerr+=xadj; - } - d+=sx; - yerr += yadj; - src += (yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void TCopySpriteZoomClip(int x, int y, int sw, int sh, int dw, int dh, byte *src) -{ - int i,j; - int xerr,yerr; - int xerr_start, yerr_start; - int xadj,yadj; - byte *d; - byte c; - int xl,yl,xs,ys; - - cpubyte=RENDER; - if (dw<1 || dh<1) return; - - xl=dw; - yl=dh; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x>16)*sw); - d = screen+(y*sx)+x; - yerr = yerr_start & 0xffff; - for (i=0; i>16)]; - if (c) - d[j]=c; - xerr+=xadj; - } - d+=sx; - yerr += yadj; - src += (yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void CopySpriteZoomLucentClip(int x, int y, int sw, int sh, int dw, int dh, byte *src) -{ - int i,j; - int xerr,yerr; - int xerr_start, yerr_start; - int xadj,yadj; - byte *d; - int xl,yl,xs,ys; - - cpubyte=RENDER; - if (dw<1 || dh<1) return; - xl=dw; - yl=dh; - xs=ys=0; - - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x>16)*sw); - d = screen+(y*sx)+x; - yerr = yerr_start & 0xffff; - for (i=0; i>16)]<<8)]; - xerr+=xadj; - } - d+=sx; - yerr += yadj; - src += (yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void TCopySpriteZoomLucentClip(int x, int y, int sw, int sh, int dw, int dh, byte *src) -{ - int i,j; - int xerr,yerr; - int xerr_start, yerr_start; - int xadj,yadj; - byte *d; - int c; - int xl,yl,xs,ys; - - cpubyte=RENDER; - if (dw<1 || dh<1) return; - xl=dw; - yl=dh; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x>16)*sw); - d = screen+(y*sx)+x; - yerr = yerr_start & 0xffff; - for (i=0; i>16)]; - if (c) - d[j]=translucency_table[d[j]|(c<<8)]; - xerr+=xadj; - } - d+=sx; - yerr += yadj; - src += (yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void SilhouetteClip(int x, int y, int width, int height, int color, byte *src) -{ - byte *s=0,*d=0; - int xl=0,yl=0,xs=0,ys=0; - - cpubyte=RENDER; - xl=width; - yl=height; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x>16)*sw); - d = screen+(y*sx)+x; - yerr = yerr_start & 0xffff; - for (y=0; y>16)]) - d[x]=color; - xerr+=xadj; - } - d+=sx; - yerr += yadj; - src += (yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void SilhouetteLucentClip(int x, int y, int width, int height, int color, byte *src) -{ - byte *s=0,*d=0; - int xl=0,yl=0,xs=0,ys=0; - byte *range=0; - - cpubyte=RENDER; - xl=width; - yl=height; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x>16)*sw); - d = screen+(y*sx)+x; - range=translucency_table+(color<<8); - yerr = yerr_start & 0xffff; - for (y=0; y>16)]) - d[x]=range[d[x]]; - xerr+=xadj; - } - d+=sx; - yerr += yadj; - src += (yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -// aen -void TintClip(int x, int y, int width, int height, int color, byte *src) -{ - byte *s=0,*d=0; - int xl=0,yl=0,xs=0,ys=0; - byte *range=0; - byte c=0; - - cpubyte=RENDER; - xl=width; - yl=height; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x>16)*sw); - d = screen+(y*sx)+x; - range=translucency_table+(color<<8); - yerr = yerr_start & 0xffff; - for (y=0; y>16)]; - if (c) - d[x]=range[c]; - xerr+=xadj; - } - d+=sx; - yerr += yadj; - src += (yerr>>16)*sw; - yerr &= 0xffff; - } - cpubyte=ETC; -} - -void CopyTile(int x, int y, byte *src) -{ - CopySpriteClip(x,y,16,16,src); -} - -void TCopyTile(int x, int y, byte *src, byte *matte) -{ - matte=matte; - TCopySpriteClip(x,y,16,16,src); -} - -void CopyTileLucent(int x, int y, byte *src) -{ - CopySpriteLucentClip(x,y,16,16,src); -} - -void TCopyTileLucent(int x, int y, byte *src) -{ - TCopySpriteLucentClip(x,y,16,16,src); -} - -void CopyTileClip(int x, int y, byte *src) -{ - CopySpriteClip(x,y,16,16,src); -} - -void TCopyTileClip(int x, int y, byte *src, byte *matte) -{ - matte=matte; - TCopySpriteClip(x,y,16,16,src); -} - -void CopyTileLucentClip(int x, int y, byte *src) -{ - CopySpriteLucentClip(x,y,16,16,src); -} - -void TCopyTileLucentClip(int x, int y, byte *src) -{ - TCopySpriteLucentClip(x,y,16,16,src); -} - -// aen -void MapLine(int x, int y, int yofs, word *map) -{ - byte *d; - int tilesx,startx; - int counter; - int span, s; - - cpubyte=RENDER; - - // y clipping - if (y<0 || y>=tsy) return; - // x clipping - startx=0; - if (x<0) { startx=-x; x=0; } - - d=screen+(y*sx)+x; - tilesx=(tsx/16); - - // do clipped left tile - counter=0; - s=tileidx[*map]; - memcpy(d, vsp+((s16) span=16; - s=tileidx[*map]; - memcpy(d, vsp+((s=tsy) return; - // x clipping - startx=0; - if (x<0) { startx=-x; x=0; } - - d=screen+(y*sx)+x; - tilesx=(tsx/16); - - // do clipped left tile - counter=0; - s=vsp+(256*tileidx[*map])+(16*yofs)+startx; - for (x=0; x<16-startx; x++) - { - c=s[x]; - if (c) - d[x]=c; - } - d+=16-startx; - counter+=16-startx; - map++; - // do midsection of line - for (y=1; y16) span=16; - s=vsp+(256*tileidx[*map])+(16*yofs); - for (x=0; xcx2 || y>cy2) return; - screen[(y*sx)+x]=color; -} - -void SetPixelLucentClip(int x, int y, int color) -{ - byte *d; - - if (xcx2 || y>cy2) return; - d=screen+(y*sx)+x; - *d=translucency_table[*d|(color<<8)]; -} - -int GetPixel(int x, int y) -{ - return screen[(y*sx)+x]; -} - -int GetPixelClip(int x, int y) -{ - if (xcx2 || y>cy2) return 0; - return screen[(y*sx)+x]; -} - -void ColorField(int x, int y, char c) -{ - int i; - - cpubyte=RENDER; - i=0; - do - { - SetPixelClip(x+0, y+i, 0); - SetPixelClip(x+2, y+i, 0); - SetPixelClip(x+4, y+i, 0); - SetPixelClip(x+6, y+i, 0); - SetPixelClip(x+8, y+i, 0); - SetPixelClip(x+10, y+i, 0); - SetPixelClip(x+12, y+i, 0); - SetPixelClip(x+14, y+i, 0); - i++; - - SetPixelClip(x+0 +1, y+i, 0); - SetPixelClip(x+2 +1, y+i, 0); - SetPixelClip(x+4 +1, y+i, 0); - SetPixelClip(x+6 +1, y+i, 0); - SetPixelClip(x+8 +1, y+i, 0); - SetPixelClip(x+10 +1, y+i, 0); - SetPixelClip(x+12 +1, y+i, 0); - SetPixelClip(x+14 +1, y+i, 0); - i++; - } while (i<16); - cpubyte=ETC; -} - -void HLine(int x, int y, int x2, int color) -{ - cpubyte=RENDER; - if (x2cx2 || y>cy2 || x+width cx2) width=cx2-x+1; - if (xcx2 || y>cy2 || x+width cx2) width=cx2-x+1; - if (xcx2 || y>cy2 || x cy2) height=cy2-y+1; - if (ycx2 || y>cy2 || x cy2) height=cy2-y+1; - if (yx2) - { - SWAP(x1,x2); - SWAP(y1,y2); - } - - if (y1>y2) - { - SWAP(x1,x2); - SWAP(y1,y2); - } - // assume y1<=y2 from above swap operation - yi=y2; yc=y1; - - dcx=x1; dcy=y1; - xc=(x2-x1); yc=(y2-y1); - if (xc<0) xi=-1; else xi=1; - if (yc<0) yi=-1; else yi=1; - n=abs(xc); m=abs(yc); - ycyi=abs(2*yc*xi); - er=0; - - if (n>m) - { - xcxi=abs(2*xc*xi); - for (i=0;i<=n;i++) - { - screen[(dcy*sx)+dcx]=color; - if (er>0) - { dcy+=yi; - er-=xcxi; - } - er+=ycyi; - dcx+=xi; - } - } - else - { - xcyi=abs(2*xc*yi); - for (i=0;i<=m;i++) - { - screen[(dcy*sx)+dcx]=color; - if (er>0) - { dcx+=xi; - er-=ycyi; - } - er+=xcyi; - dcy+=yi; - } - } - cpubyte=ETC; -} - -// grabbed/modded from Abuse source -void LineClip(int x1, int y1, int x2, int y2, int color) -{ - short i,xc,yc,er,n,m,xi,yi,xcxi,ycyi,xcyi; - unsigned dcy,dcx; - - cpubyte=RENDER; - // check to see if the line is completly clipped off - if ((x1cx2 && x2>cx2) - || (y1cy2 && y2>cy2)) - { - cpubyte=ETC; - return; - } - - if (x1>x2) - { - SWAP(x1,x2); - SWAP(y1,y2); - } - - // clip the left side - if (x1cx2) - { int myy=(y2-y1); - int mxx=(x2-x1),b; - if (!mxx) - { - cpubyte=ETC; - return; - } - if (myy) - { - b=y1-(y2-y1)*x1/mxx; - y2=myy*cx2/mxx+b; - x2=cx2; - } - else x2=cx2; - } - - if (y1>y2) - { - SWAP(x1,x2); - SWAP(y1,y2); - } - - // clip the bottom - if (y2>cy2) - { int mxx=(x2-x1); - int myy=(y2-y1),b; - if (!myy) - { - cpubyte=ETC; - return; - } - if (mxx) - { - b=y1-(y2-y1)*x1/mxx; - x2=(cy2-b)*mxx/myy; - y2=cy2; - } - else y2=cy2; - } - - // clip the top - if (y1cx2 || x2>cx2 || y1cy2 || y2>cy2) - { - cpubyte=ETC; - return; - } - - if (x1>x2) - { xc=x2; xi=x1; } - else { xi=x2; xc=x1; } - - // assume y1<=y2 from above swap operation - yi=y2; yc=y1; - - dcx=x1; dcy=y1; - xc=(x2-x1); yc=(y2-y1); - if (xc<0) xi=-1; else xi=1; - if (yc<0) yi=-1; else yi=1; - n=abs(xc); m=abs(yc); - ycyi=abs(2*yc*xi); - er=0; - - if (n>m) - { - xcxi=abs(2*xc*xi); - for (i=0;i<=n;i++) - { - screen[(dcy*sx)+dcx]=color; - if (er>0) - { dcy+=yi; - er-=xcxi; - } - er+=ycyi; - dcx+=xi; - } - } - else - { - xcyi=abs(2*xc*yi); - for (i=0;i<=m;i++) - { - screen[(dcy*sx)+dcx]=color; - if (er>0) - { dcx+=xi; - er-=ycyi; - } - er+=xcyi; - dcy+=yi; - } - } - cpubyte=ETC; - return; -} - -void LineLucent(int x1, int y1, int x2, int y2, int color) -{ - short i,xc,yc,er,n,m,xi,yi,xcxi,ycyi,xcyi; - unsigned dcy,dcx; - byte *d; - int c; - - cpubyte=RENDER; - if (x1>x2) - { - SWAP(x1,x2); - SWAP(y1,y2); - } - if (y1>y2) - { - SWAP(x1,x2); - SWAP(y1,y2); - } - - // assume y1<=y2 from above swap operation - yi=y2; yc=y1; - dcx=x1; dcy=y1; - xc=(x2-x1); yc=(y2-y1); - if (xc<0) xi=-1; else xi=1; - if (yc<0) yi=-1; else yi=1; - n=abs(xc); m=abs(yc); - ycyi=abs(2*yc*xi); - er=0; - - c=color<<8; // for translucency - if (n>m) - { - xcxi=abs(2*xc*xi); - for (i=0;i<=n;i++) - { - d=screen+(dcy*sx)+dcx; - *d=translucency_table[c|*d]; - //screen[(dcy*sx)+dcx]=color; - if (er>0) - { dcy+=yi; - er-=xcxi; - } - er+=ycyi; - dcx+=xi; - } - } - else - { - xcyi=abs(2*xc*yi); - for (i=0;i<=m;i++) - { - d=screen+(dcy*sx)+dcx; - *d=translucency_table[c|*d]; - //screen[(dcy*sx)+dcx]=color; - if (er>0) - { dcx+=xi; - er-=ycyi; - } - er+=xcyi; - dcy+=yi; - } - } - cpubyte=ETC; -} - -void LineLucentClip(int x1, int y1, int x2, int y2, int color) -{ - short i,xc,yc,er,n,m,xi,yi,xcxi,ycyi,xcyi; - unsigned dcy,dcx; - byte *d; - int c; - - cpubyte=RENDER; - // check to see if the line is completly clipped off - if ((x1cx2 && x2>cx2) - || (y1cy2 && y2>cy2)) - { - cpubyte=ETC; - return; - } - - if (x1>x2) - { - SWAP(x1,x2); - SWAP(y1,y2); - } - - // clip the left side - if (x1cx2) - { int myy=(y2-y1); - int mxx=(x2-x1),b; - if (!mxx) - { - cpubyte=ETC; - return; - } - if (myy) - { - b=y1-(y2-y1)*x1/mxx; - y2=myy*cx2/mxx+b; - x2=cx2; - } - else x2=cx2; - } - - if (y1>y2) - { - SWAP(x1,x2); - SWAP(y1,y2); - } - - // clip the bottom - if (y2>cy2) - { int mxx=(x2-x1); - int myy=(y2-y1),b; - if (!myy) - { - cpubyte=ETC; - return; - } - if (mxx) - { - b=y1-(y2-y1)*x1/mxx; - x2=(cy2-b)*mxx/myy; - y2=cy2; - } - else y2=cy2; - } - - // clip the top - if (y1cx2 || x2>cx2 || y1cy2 || y2>cy2) - { - cpubyte=ETC; - return; - } - - if (x1>x2) - { xc=x2; xi=x1; } - else { xi=x2; xc=x1; } - - // assume y1<=y2 from above swap operation - yi=y2; yc=y1; - - dcx=x1; dcy=y1; - xc=(x2-x1); yc=(y2-y1); - if (xc<0) xi=-1; else xi=1; - if (yc<0) yi=-1; else yi=1; - n=abs(xc); m=abs(yc); - ycyi=abs(2*yc*xi); - er=0; - - c=color<<8; // for translucency - if (n>m) - { - xcxi=abs(2*xc*xi); - for (i=0;i<=n;i++) - { - d=screen+(dcy*sx)+dcx; - *d=translucency_table[c|*d]; - //screen[(dcy*sx)+dcx]=color; - if (er>0) - { dcy+=yi; - er-=xcxi; - } - er+=ycyi; - dcx+=xi; - } - } - else - { - xcyi=abs(2*xc*yi); - for (i=0;i<=m;i++) - { - d=screen+(dcy*sx)+dcx; - *d=translucency_table[c|*d]; - //screen[(dcy*sx)+dcx]=color; - if (er>0) - { dcx+=xi; - er-=ycyi; - } - er+=xcyi; - dcy+=yi; - } - } - cpubyte=ETC; -} - -// All the Circle* routines were grabbed/modded from Allegro source - -void Circle(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - do - { - SetPixel(x+cx,y+cy,color); - if (cx) SetPixel(x-cx,y+cy,color); - if (cy) SetPixel(x+cx,y-cy,color); - if ((cx) && (cy)) SetPixel(x-cx,y-cy,color); - - if (cx != cy) - { - SetPixel(x+cy,y+cx,color); - if (cx) SetPixel(x+cy,y-cx,color); - if (cy) SetPixel(x-cy,y+cx,color); - if (cx && cy) SetPixel(x-cy,y-cx,color); - } - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - cx++; - } while (cx <= cy); - cpubyte=ETC; -} - -void CircleClip(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - do { - SetPixelClip(x+cx,y+cy,color); - if (cx) SetPixelClip(x-cx,y+cy,color); - if (cy) SetPixelClip(x+cx,y-cy,color); - if ((cx) && (cy)) SetPixelClip(x-cx,y-cy,color); - - if (cx != cy) - { - SetPixelClip(x+cy,y+cx,color); - if (cx) SetPixelClip(x+cy,y-cx,color); - if (cy) SetPixelClip(x-cy,y+cx,color); - if (cx && cy) SetPixelClip(x-cy,y-cx,color); - } - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - cx++; - } while (cx <= cy); - cpubyte=ETC; -} - -void CircleLucent(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - - do - { - SetPixelLucent(x+cx,y+cy,color); - if (cx) SetPixelLucent(x-cx,y+cy,color); - if (cy) SetPixelLucent(x+cx,y-cy,color); - if ((cx) && (cy)) SetPixelLucent(x-cx,y-cy,color); - - if (cx != cy) - { - SetPixelLucent(x+cy,y+cx,color); - if (cx) SetPixelLucent(x+cy,y-cx,color); - if (cy) SetPixelLucent(x-cy,y+cx,color); - if (cx && cy) SetPixelLucent(x-cy,y-cx,color); - } - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - cx++; - } while (cx <= cy); - cpubyte=ETC; -} - -void CircleLucentClip(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - do - { - SetPixelLucentClip(x+cx,y+cy,color); - if (cx) SetPixelLucentClip(x-cx,y+cy,color); - if (cy) SetPixelLucentClip(x+cx,y-cy,color); - if ((cx) && (cy)) SetPixelLucentClip(x-cx,y-cy,color); - - if (cx != cy) - { - SetPixelLucentClip(x+cy,y+cx,color); - if (cx) SetPixelLucentClip(x+cy,y-cx,color); - if (cy) SetPixelLucentClip(x-cy,y+cx,color); - if (cx && cy) SetPixelLucentClip(x-cy,y-cx,color); - } - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - cx++; - } while (cx <= cy); - cpubyte=ETC; -} - -void CircleFill(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - - do - { - HLine(x-cy,y-cx,x+cy,color); - if (cx) HLine(x-cy,y+cx,x+cy,color); - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - if (cx != cy) - { - HLine(x-cx,y-cy,x+cx,color); - if (cy) HLine(x-cx,y+cy,x+cx,color); - } - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - cx++; - } while (cx <= cy); - cpubyte=ETC; -} - -void CircleFillClip(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - do - { - HLineClip(x-cy,y-cx,x+cy,color); - if (cx) HLineClip(x-cy,y+cx,x+cy,color); - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - if (cx != cy) - { - HLineClip(x-cx,y-cy,x+cx,color); - if (cy) HLineClip(x-cx,y+cy,x+cx,color); - } - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - cx++; - } while (cx <= cy); - cpubyte=ETC; -} - -void CircleFillLucent(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - do - { - HLineLucent(x-cy,y-cx,x+cy,color); - if (cx) HLineLucent(x-cy,y+cx,x+cy,color); - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - if (cx != cy) - { - HLineLucent(x-cx,y-cy,x+cx,color); - if (cy) HLineLucent(x-cx,y+cy,x+cx,color); - } - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - cx++; - } while (cx <= cy); - cpubyte=ETC; -} - -void CircleFillLucentClip(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - do - { - HLineLucentClip(x-cy,y-cx,x+cy,color); - if (cx) HLineLucentClip(x-cy,y+cx,x+cy,color); - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - if (cx != cy) - { - HLineLucentClip(x-cx,y-cy,x+cx,color); - if (cy) HLineLucentClip(x-cx,y+cy,x+cx,color); - } - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - cx++; - } while (cx <= cy); - cpubyte=ETC; -} - -void Rect(int x, int y, int x2, int y2, int color) -{ - HLine(x,y,x2,color); - HLine(x,y2,x2,color); - VLine(x,y+1,y2-1,color); - VLine(x2,y+1,y2-1,color); -} - -void RectClip(int x, int y, int x2, int y2, int color) -{ - HLineClip(x,y,x2,color); - HLineClip(x,y2,x2,color); - VLineClip(x,y+1,y2-1,color); - VLineClip(x2,y+1,y2-1,color); -} - -void RectLucent(int x, int y, int x2, int y2, int color) -{ - HLineLucent(x,y,x2,color); - HLineLucent(x,y2,x2,color); - VLineLucent(x,y+1,y2-1,color); - VLineLucent(x2,y+1,y2-1,color); -} - -void RectLucentClip(int x, int y, int x2, int y2, int color) -{ - HLineLucentClip(x,y,x2,color); - HLineLucentClip(x,y2,x2,color); - VLineLucentClip(x,y+1,y2-1,color); - VLineLucentClip(x2,y+1,y2-1,color); -} - -void RectFill(int x, int y, int x2, int y2, int color) -{ - cpubyte=RENDER; - if (y2=clipw) - spanx=clipw-curx; - source=src+(y*wide)+x; - dest=screen+(cy1*sx)+cx1+curx; - cury=0; - - do - { - spany=high-(cury?0:y); - if (cury+spany>=cliph) - spany=cliph-cury; - - for (i=0; i=clipw) - spanx=clipw-curx; - source=src+(y*wide)+x; - dest=screen+(cy1*sx)+cx1+curx; - cury=0; - - do - { - spany=high-(cury?0:y); - if (cury+spany>=cliph) - spany=cliph-cury; - for (i=0; i=clipw) - spanx=clipw-curx; - source=src+(y*wide)+x; - dest=screen+(cy1*sx)+cx1+curx; - cury=0; - - do - { - spany=high-(cury?0:y); - if (cury+spany>=cliph) - spany=cliph-cury; - for (i=0; i=clipw) - spanx=clipw-curx; - source=src+(y*wide)+x; - dest=screen+(cy1*sx)+cx1+curx; - cury=0; - - do - { - spany=high-(cury?0:y); - if (cury+spany>=cliph) - spany=cliph-cury; - for (i=0; i>1; - T_HEIGHT_CENTER=height>>1; - W_WIDTH=((float)width/scale*sin(ft) + (float)height/scale*cos(ft)); - W_HEIGHT=W_WIDTH; - W_HEIGHT_CENTER=W_HEIGHT>>1; - W_WIDTH_CENTER=W_HEIGHT_CENTER; //W_WIDTH/2; - - sinas=sin(-angle)*65536*scale; - cosas=cos(-angle)*65536*scale; - - xc=T_WIDTH_CENTER*65536 - (W_HEIGHT_CENTER*(cosas+sinas)); - yc=T_HEIGHT_CENTER*65536 - (W_WIDTH_CENTER*(cosas-sinas)); - posx-=W_WIDTH_CENTER; - posy-=W_HEIGHT_CENTER; - - // clipping - if (W_WIDTH<2 || W_HEIGHT<2) return; - xl=W_WIDTH; - yl=W_HEIGHT; - xs=ys=0; - if (posx>cx2 || posy>cy2 || posx+xl cx2) xl=cx2-posx+1; - if (posy+yl > cy2) yl=cy2-posy+1; - if (posx>16); - tempy=(srcy>>16); - - if (tempx>=0 && tempx=0 && tempy y3) - { - swaptemp=x1; x1=x3; x3=swaptemp; - swaptemp=y1; y1=y3; y3=swaptemp; - } - if (y2 > y3) - { - swaptemp=x2; x2=x3; x3=swaptemp; - swaptemp=y2; y2=y3; y3=swaptemp; - } - if (y1 > y2) - { - swaptemp=x1; x1=x2; x2=swaptemp; - swaptemp=y1; y1=y2; y2=swaptemp; - } - - xstep2=((x3-x1) << 16) / (y3-y1); - xval2=x1 << 16; - - if (y1 != y2) - { - xstep = ((x2-x1) << 16) / (y2-y1); - xval = x1 << 16; - for (yon=y1;yon < y2; yon++) - { - if ((yon > -1) && (yon < 200)) - { - HLineClip(xval>>16,yon,xval2>>16,color); - } - xval+=xstep; - xval2+=xstep2; - } - } - if (y2 != y3) - { - xstep = ((x3-x2) << 16) / (y3-y2); - xval = x2 << 16; - for (yon=y2;yon < y3; yon++) - { - if ((yon > -1) && (yon < 200)) - { - HLineClip(xval>>16,yon,xval2>>16,color); - } - xval+=xstep; - xval2+=xstep2; - } - } -} - -char *image; -int texw,texh; // those damn bastards want EVERYTHING! - -void tmaphline(int x1, int x2, int y, int tx1, int tx2, int ty1, int ty2) -{ - int i; - int txstep,txval; - int tystep,tyval; - - if (x1 != x2) - { - if (x2 < x1) - { - i=x1; x1=x2; x2=i; - i=tx1; tx1=tx2; tx2=i; - i=ty1; ty1=ty2; ty2=i; - } - if ((x1 > sx) || (x2 < 0)) return; - txstep=((tx2-tx1)<<16)/(x2-x1); - tystep=((ty2-ty1)<<16)/(x2-x1); - txval=tx1<<16; - tyval=ty1<<16; - - for (i=x1;i>16)*texw+(txval>>16)]; - txval+=txstep; - tyval+=tystep; - } - } -} - -void TMapPoly(int x1, int y1, int x2, int y2, int x3, int y3, - int tx1, int ty1, int tx2, int ty2, int tx3, int ty3, - int tw, int th, char *img) -{ - int xstep,xstep2; - int xval,xval2; - int txstep,txstep2; - int tystep,tystep2; - int txval,txval2; - int tyval,tyval2; - int yon; - int swaptemp; - - image=img; texw=tw; texh=th; - if (y1 > y3) - { - swaptemp=x1; x1=x3; x3=swaptemp; - swaptemp=y1; y1=y3; y3=swaptemp; - swaptemp=tx1; tx1=tx3; tx3=swaptemp; - swaptemp=ty1; ty1=ty3; ty3=swaptemp; - } - if (y2 > y3) - { - swaptemp=x2; x2=x3; x3=swaptemp; - swaptemp=y2; y2=y3; y3=swaptemp; - swaptemp=tx2; tx2=tx3; tx3=swaptemp; - swaptemp=ty2; ty2=ty3; ty3=swaptemp; - } - if (y1 > y2) - { - swaptemp=x1; x1=x2; x2=swaptemp; - swaptemp=y1; y1=y2; y2=swaptemp; - swaptemp=tx1; tx1=tx2; tx2=swaptemp; - swaptemp=ty1; ty1=ty2; ty2=swaptemp; - } - xstep2=((x3-x1) << 16) / (y3-y1); - xval2=x1 << 16; - txstep2=((tx3-tx1) << 16) / (y3-y1); - txval2=tx1 << 16; - tystep2=((ty3-ty1) << 16) / (y3-y1); - tyval2=ty1 << 16; - - if (y1 != y2) - { - xstep = ((x2-x1) << 16) / (y2-y1); - xval = x1 << 16; - txstep = ((tx2-tx1) << 16) / (y2-y1); - txval = tx1 << 16; - tystep = ((ty2-ty1) << 16) / (y2-y1); - tyval = ty1 << 16; - - for (yon=y1;yon < y2; yon++) - { - if ((yon > -1) && (yon < 200)) - { - tmaphline(xval>>16,xval2>>16,yon,txval>>16,txval2>>16, - tyval>>16,tyval2>>16); - } - xval+=xstep; - xval2+=xstep2; - txval+=txstep; - txval2+=txstep2; - tyval+=tystep; - tyval2+=tystep2; - } - } - if (y2 != y3) - { - xstep = ((x3-x2) << 16) / (y3-y2); - xval = x2 << 16; - txstep = ((tx3-tx2) << 16) / (y3-y2); - txval = tx2 << 16; - tystep = ((ty3-ty2) << 16) / (y3-y2); - tyval = ty2 << 16; - - for (yon=y2;yon < y3; yon++) - { - if ((yon > -1) && (yon < 200)) - { - tmaphline(xval>>16,xval2>>16,yon,txval>>16,txval2>>16, - tyval>>16,tyval2>>16); - } - xval+=xstep; - xval2+=xstep2; - txval+=txstep; - txval2+=txstep2; - tyval+=tystep; - tyval2+=tystep2; - } - } -} - -/* -// ============================================================================ -// = aen's ripple-blitter = -// ============================================================================ - -int thresh; -int dispx[64],dispy[64]; - -void InitDisplaceStuff(float xmag, float ymag) -{ - int x, y, *d; - - xmag=4.0,d=dispx; - for (y=0; y<32; y++) - *d++=sin(y * (360.0/32) * (3.14/180))*xmag; - - ymag=3.9,d=dispy; - for (x=0; x<32; x++) - *d++=cos(x * (360.0/32) * (3.14/180))*ymag; - - thresh=14; -} - -void CopyTileDisplace(int x, int y, unsigned char *spr) -{ - int i, j; - int xx, yy, xt, yt; - int xin, yin; - byte *dest; - - xin = ((x+xwin)&31)<16 ? 0 : 16; - yin = ((y+ywin)&31)<16 ? 0 : 16; - dest=screen+(y*sx)+x; - - // in the yy and xx calcs, +y and +x keep the start position correct - // within the 32 element lookup tables (ie. so they flow continuously - // across the 16x16 images). - - for (j=0; j<16; j++) - { - yy = (j+yin+thresh) & 31; - for (i=0; i<16; i++) - { - xx = (i+xin+thresh) & 31; - xt = (i+dispx[yy]) & 15; - yt = (j+dispy[xx]) & 15; - - dest[i]=spr[(yt*16)+xt]; - } - dest+=sx; - } -} - -void CopyTileDisplaceClip(int x, int y, unsigned char *spr) -{ - byte *s,*d; - int xl,yl,xs,ys; - int i, j; - int xx, yy, xt, yt; - int xin, yin; - - cpubyte=RENDER; - xl=16; - yl=16; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x // va_* - -#include "verge.h" - -// ================================= Data ==================================== - -// declared in VDRIVER.C -extern byte* translucency_table; - -char *strbuf=0; // Universal temporary string buffer. :) -char joyflag=0; -int vidxres=0,vidyres=0; // Joystick on/off | Video mode to use -char logoutput=0; // Verbose debugging startup mode -char nocdaudio=0; // do not use CD audio -char startmap[80]; // startup map -FILE *logf=0; // logfile file handle - -// ================================= Code ==================================== - -void InitializeDefaults() -{ - kb1=28; kb2=56; kb3=1; kb4=57; // default keyboard controls - jb1=1; jb2=2; jb3=3; jb4=4; // default joystick controls - joyflag=0; // joystick defaults to disabled - vidxres=320; vidyres=200; - logoutput=0; // Don't be annoyingly verbose - strbuf=(char *) valloc(2000, "strbuf", OID_TEMP); - memcpy(startmap,"test.map\0",9); - - md_mixfreq=44100; - md_dmabufsize=2000; - md_mode=DMODE_16BITS|DMODE_STEREO; - md_device=0; -} - -static VFILE *user_cfg_file=0; -static char parse_str[256]; - -static char *parse_cfg_token() -{ - vscanf(user_cfg_file, "%s", parse_str); - return parse_str; -} - -// compares string against parse_str (grabbed by parse_cfg_token) -// 0=mismatch, 1=match -static int parse_match(char *str) -{ - return !strcmp(parse_str, str); -} - -void ParseStartupFiles() -{ - user_cfg_file = vopen("user.cfg"); - if (!user_cfg_file) - { - printf("Could not open user.cfg. \n"); - exit(-1); - } - - while (1) - { - parse_cfg_token(); - - // mounts a pack file; up to 3? (perhaps gaurd against more?) - if (parse_match("mount")) - { MountVFile(parse_cfg_token()); continue; } - // set video resolution - else if (parse_match("vidmode")) - { - vidxres = atoi(parse_cfg_token()); - vidyres = atoi(parse_cfg_token()); - - // check validity - if (vidxres != 256 && vidxres != 320 - && vidxres != 360 && vidxres != 640) - { - Log("user.cfg: invalid resolution width %i passed to vidmode", - vidxres); - } - if (vidyres != 200 && vidyres != 240 - && vidyres != 256 && vidyres != 480) - { - Log("user.cfg: invalid resolution height %i passed to vidmode", - vidyres); - } - - continue; - } - // log to VERGE.LOG - else if (parse_match("log")) - { - logoutput=1; - continue; - } - // disable CD playing - else if (parse_match("nocdaudio")) - { - nocdaudio=1; - continue; - } - // map VERGE.EXE will run first when executed - else if (parse_match("startmap")) - { - strcpy(startmap, parse_cfg_token()); - continue; - } - // 0=auto detect, 1=???, 2=???, 3=nosound - else if (parse_match("sound_device")) - { - md_device = atoi(parse_cfg_token()); - continue; - } - // sound lib setting - else if (parse_match("mixrate")) - { - md_mixfreq = atoi(parse_cfg_token()); - continue; - } - // sound lib setting - else if (parse_match("dmabufsize")) - { - md_dmabufsize = atoi(parse_cfg_token()); - continue; - } - // sound lib setting - else if (parse_match("force8bit")) - { - continue; - } - // sound lib setting - else if (parse_match("forcemono")) - { - continue; - } - - // unknown command, assume end - break; - } - - // done parsing config - vclose(user_cfg_file); -} - -void ParseAutoCFG() -{ VFILE *f; - int i; - - if (!(f=vopen("auto.cfg"))) return; - - while (1) - { - vgets((char *) cmd, 40, f); - for (i=0; i<(signed) strlen((char *) cmd); i++) - if (cmd[i]==10 || cmd[i]==13) cmd[i]=0; - if (strlen((char*) cmd)<2) break; - ProcessCommand(); - } - vclose(f); -} - -void InitLog() -{ - if (logoutput) - { - remove("verge.log"); - } -} - -void Log(char *message, ...) -{ - char tempbuf[256]; - va_list lst; - - if (!logoutput) return; - - va_start(lst, message); - vsprintf(tempbuf, message, lst); - va_end(lst); - - logf = fopen("verge.log", "aw"); - if (!logf) err("unable to log to verge.log"); - - fprintf(logf, "%s \n", tempbuf); - fflush(logf); - - fclose(logf); -} - -// used in conjunction with LogDone() -void Logp(char *message, ...) -{ - char tempbuf[256]; - va_list lst; - - if (!logoutput) return; - - va_start(lst, message); - vsprintf(tempbuf, message, lst); - va_end(lst); - - logf = fopen("verge.log", "aw"); - if (!logf) err("unable to log to verge.log"); - - fprintf(logf, "%s", tempbuf); - fflush(logf); - - fclose(logf); -} - -void LogDone() -{ - if (!logoutput) return; - - logf = fopen("verge.log", "aw"); - if (!logf) err("unable to log to verge.log"); - - fprintf(logf, "... OK \n"); - fflush(logf); - - fclose(logf); -} - -void InitSystems() -{ - InitLog(); - Log("V2 startup. Logfile initialized."); - Logp("Sys: Initializing keyboard handler."); - InitKeyboard(); - LogDone(); -#ifdef __DJGPP__ - keyboard_chain(0); -#endif - Logp("Sys: Initializing timer. Set 100hz."); - InitTimer(); - LogDone(); - - /* - Logp("Sys: Initializing CD Audio."); - CD_Init(); - LogDone(); - */ - - Logp("Sys: Initializing music system."); - InitMusicSystem(); - LogDone(); - - InitVideo(vidxres, vidyres); -} - -void LoadTransTable() -{ - FILE *fp=0; - - if (translucency_table) - { free(translucency_table); translucency_table=0; } - translucency_table=(byte *)valloc(65536, "translucency_table", OID_MISC); - - fp = fopen("trans.tbl", "rb"); - if (!fp) err("Could not open trans.tbl."); - - fread(translucency_table, 65536, 1, fp); - - fclose(fp); -} - -void vmain(int argc, char *argv[]) -{ - char temp[256]; - - InitializeDefaults(); - ParseStartupFiles(); - InitSystems(); - if (argc==2) - { - memcpy(startmap, argv[1], strlen(argv[1])); - } - - InitConsole(); - sprintf(temp,"VERGE System Version %s", VERSION); - Con_Printf(temp); - Con_Printf("Copyright (C)1998 vecna"); - - ParseAutoCFG(); - LoadTransTable(); - LoadSystemVC(); - LoadMAP(startmap); - - while (1) - { - while (timer_count!=0) - { - timer_count--; - GameTick(); - } - Render(); - - ShowPage(); - if (kill) - { - FreeVSP(); - FreeMAP(); - FreeCHRList(); - vcsp=vcstack; - kill=0; - LoadMAP(startmap); - } - } -} diff --git a/16/v2/source/verge/ENGINE/VERGE.H b/16/v2/source/verge/ENGINE/VERGE.H deleted file mode 100755 index 3d782c32..00000000 --- a/16/v2/source/verge/ENGINE/VERGE.H +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// Wee. A generic #include. I feel so warm and fuzzy inside. :) - -#define VERSION "2.01b" - -#include - -#include -#include -#include - -#define byte unsigned char -#define word unsigned short int -#define quad unsigned int - -#define TRUE 1 -#define FALSE 0 - -#include "inter.h" -#include "a_memory.h" -#include "vfile.h" -#include "conlib.h" -#include "console.h" -#include "controls.h" -#include "engine.h" -#include "entity.h" -#include "fli.h" -#include "font.h" -#include "image.h" -#include "keyboard.h" -#include "main.h" -#include "message.h" -#include "mikmod.h" -#include "render.h" -#include "sound.h" -#include "timer.h" -#include "vc.h" -#include "vdriver.h" - -extern char *strbuf; \ No newline at end of file diff --git a/16/v2/source/verge/ENGINE/VESA.C b/16/v2/source/verge/ENGINE/VESA.C deleted file mode 100755 index a97fbe6a..00000000 --- a/16/v2/source/verge/ENGINE/VESA.C +++ /dev/null @@ -1,776 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include - -#include -#include -#include "verge.h" - -// ================================= Data ==================================== - -byte *vesascreen, *vesascreenx; // virscr | realscr - -// ================================= Code ==================================== - -void VESASetMode(int mode) -{ - REGISTERS r; - SET_AX(r, mode); - INTERRUPT(0x10, r); -} - -int VESAShutdown(void) -{ - VESASetMode(0x3); - free(vesascreen); - return 0; -} - -void VESASetBank(int bank) -{ - REGISTERS r; - SET_AX(r, 0x4f05); - SET_BX(r, 0); - SET_DX(r, bank); - INTERRUPT(0x10, r); -} - -int VESAShowPage(void) -{ byte *s,*d; - int y,bytes,bank; - int span; - - RenderGUI(); - cpubyte=PFLIP; - - s=vesascreen+(16*tsx)+16; - d=vesascreenx; - - bank=0; - bytes=65536; - VESASetBank(bank++); - - for (y=sy; y; y--) - { - if (bytes >= sx) - { memcpy(d,s,sx); - bytes-=sx; - s+=sx; - d+=sx; - } - else - { memcpy(d,s,bytes); - s+=bytes; - span=sx-bytes; - - VESASetBank(bank++); - d=vesascreenx; - bytes=65536; - - memcpy(d,s,span); - bytes-=span; - s+=span; - d+=span; - } - s+=32; - } - - cpubyte=ETC; - return 0; -} - -int VESACopySprite(int x, int y, int width, int height, byte *src) -{ - cpubyte=RENDER; - - asm("movl %3, %%edx \n\t" - "movl %4, %%esi \n\t" -"csl0: \n\t" - "movl %1, %%eax \n\t" - "imul $672, %%eax \n\t" - "addl %0, %%eax \n\t" - "addl _vesascreen, %%eax \n\t" - "movl %%eax, %%edi \n\t" - "movl %2, %%ecx \n\t" - "shrl $2, %%ecx \n\t" - "repz \n\t" - "movsl \n\t" - "incl %1 \n\t" - "decl %%edx \n\t" - "jnz csl0 \n\t" - : - : "m" (x), "m" (y), "m" (width), "m" (height), "m" (src) - : "eax","edx","esi","edi","ecx","cc" ); - cpubyte=ETC; - return 0; -} - -int VESACCopySprite(int x,int y,int width,int height,byte *src) -{ - byte *s,*d; - int xl,yl,xs,ys; - int cx1=0, cy1=0, cx2=tsx-1, cy2=tsy-1; - - cpubyte=RENDER; - - xl=width; - yl=height; - xs=ys=0; - - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (x0 && th>0) dys=tsx-xm; - else if (tw>0 && th<0) dys=(0-tsx)-xm; - else if (tw<0 && th>0) dys=tsx+xm; - else if (tw<0 && th<0) dys=(0-tsx)+xm; - - d = vesascreen+(y*tsx)+x; - for (i=0;i>16)]; - d+=xd; - sx+=xs; - } - d+=dys; - sy+=ys; - s+=(sy>>16)*w; - sy&=0xffff; - } - cpubyte=ETC; - return 0; -} - -int VESARenderMAPLine(int x, int y, int yofs, word *map) -{ - cpubyte=RENDER; - // ... - cpubyte=ETC; - return 0; -} - -int VESATRenderMAPLine(int x, int y, int yofs, word *map) -{ - cpubyte=RENDER; - // ... - cpubyte=ETC; - return 0; -} - -int VESAColorField(int x, int y, byte c) -{ - cpubyte=RENDER; - // ... - cpubyte=ETC; - return 0; -} - -int VESAClearScreen() -{ - cpubyte=RENDER; - memset(vesascreen+(672*16)+16,0,(672*480)); - cpubyte=ETC; - return 0; -} - -int VESAPutPixel(int x, int y, int color) -{ - cpubyte=RENDER; - - if (xcx2 || y>cy2) - { - cpubyte=ETC; - return 0; - } - - x+=16; - y+=16; - - vesascreen[(y*tsx)+x]=color; - - cpubyte=ETC; - return 0; -} - -int VESAGetPixel(int x, int y) -{ - cpubyte=RENDER; - - if (xcx2 || y>cy2) - { - cpubyte=ETC; - return 0; - } - - x+=16; - y+=16; - - cpubyte=ETC; - return vesascreen[(y*tsx)+x]; - return 0; -} - -int VESAHLine(int x, int y, int x2, int color) -{ - byte *d; - int width; - - cpubyte=RENDER; - - // swap? - if (x2cx2 || y>cy2 || x+width cx2) width=cx2-x+1; - if (xcx2 || y>cy2 || x cy2) height=cy2-y+1; - if (ycx2 && x2>cx2) - || (y1cy2 && y2>cy2)) - { - cpubyte=ETC; - return 0; - } - - if (x1>x2) - { - i=x1; x1=x2; x2=i; - i=y1; y1=y2; y2=i; - } - - // clip the left side - if (x1cx2) - { int myy=(y2-y1); - int mxx=(x2-x1),b; - if (!mxx) - { - cpubyte=ETC; - return 0; - } - if (myy) - { - b=y1-(y2-y1)*x1/mxx; - y2=myy*cx2/mxx+b; - x2=cx2; - } - else x2=cx2; - } - - if (y1>y2) - { - i=x1; x1=x2; x2=i; - i=y1; y1=y2; y2=i; - } - - // clip the bottom - if (y2>cy2) - { int mxx=(x2-x1); - int myy=(y2-y1),b; - if (!myy) - { - cpubyte=ETC; - return 0; - } - if (mxx) - { - b=y1-(y2-y1)*x1/mxx; - x2=(cy2-b)*mxx/myy; - y2=cy2; - } - else y2=cy2; - } - - // clip the top - if (y1cx2 || x2>cx2 || y1cy2 || y2>cy2) - { - cpubyte=ETC; - return 0; - } - - if (x1>x2) - { xc=x2; xi=x1; } - else { xi=x2; xc=x1; } - - x1+=16;y1+=16; // aen; adjust these here?? - x2+=16;y2+=16; - - // assume y1<=y2 from above swap operation - yi=y2; yc=y1; - - dcx=x1; dcy=y1; - xc=(x2-x1); yc=(y2-y1); - if (xc<0) xi=-1; else xi=1; - if (yc<0) yi=-1; else yi=1; - n=abs(xc); m=abs(yc); - ycyi=abs(2*yc*xi); - er=0; - - if (n>m) - { - xcxi=abs(2*xc*xi); - for (i=0;i<=n;i++) - { - vesascreen[(dcy*tsx)+dcx]=color; - if (er>0) - { dcy+=yi; - er-=xcxi; - } - er+=ycyi; - dcx+=xi; - } - } - else - { - xcyi=abs(2*xc*yi); - for (i=0;i<=m;i++) - { - vesascreen[(dcy*tsx)+dcx]=color; - if (er>0) - { dcx+=xi; - er-=ycyi; - } - er+=xcyi; - dcy+=yi; - } - } - - cpubyte=ETC; - return 0; -} - -int VESACircle(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - - do { - VESAPutPixel(x+cx,y+cy,color); - if (cx) VESAPutPixel(x-cx,y+cy,color); - if (cy) VESAPutPixel(x+cx,y-cy,color); - if ((cx) && (cy)) VESAPutPixel(x-cx,y-cy,color); - - if (cx != cy) - { - VESAPutPixel(x+cy,y+cx,color); - if (cx) VESAPutPixel(x+cy,y-cx,color); - if (cy) VESAPutPixel(x-cy,y+cx,color); - if (cx && cy) VESAPutPixel(x-cy,y-cx,color); - } - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - - cx++; - - } while (cx <= cy); - - cpubyte=ETC; - return 0; -} - -int VESACircleFill(int x, int y, int radius, int color) -{ - int cx=0; - int cy=radius; - int df=1-radius; - int d_e=3; - int d_se=-2*radius+5; - - cpubyte=RENDER; - - do { - VESAHLine(x-cy,y-cx,x+cy,color); - if (cx) VESAHLine(x-cy,y+cx,x+cy,color); - - if (df<0) - { - df+=d_e; - d_e+=2; - d_se+=2; - } - else - { - if (cx != cy) - { - VESAHLine(x-cx,y-cy,x+cx,color); - if (cy) VESAHLine(x-cx,y+cy,x+cx,color); - } - - df+=d_se; - d_e+=2; - d_se+=4; - cy--; - } - - cx++; - - } while (cx <= cy); - - cpubyte=ETC; - return 0; -} - -int VESARect(int x, int y, int x2, int y2, int color) -{ - VESAHLine(x,y,x2,color); - VESAHLine(x,y2,x2,color); - VESAVLine(x,y+1,y2-1,color); - VESAVLine(x2,y+1,y2-1,color); - return 0; -} - -int VESARectFill(int x, int y, int x2, int y2, int color) -{ - cpubyte=RENDER; - - if (y2=0; i--) - { - for (j=0; jfp=pack[i].vhandle; - tmp->s=1; - tmp->v=i; - tmp->i=j; - pack[i].files[j].curofs=0; - fseek(tmp->fp, pack[i].files[j].packofs, 0); - pack[i].curofs=pack[i].files[j].packofs; - return tmp; - } - - tmp->fp=fopen(fname,"rb"); - tmp->s=0; tmp->v=0; tmp->i=0; - return tmp; -} - -void vread(char *dest, int len, VFILE *f) -{ - // This is fairly simple.. Just make sure our filepointer is at the right - // place, then do a straight fread. - - if (f->s) - { - if (pack[f->v].curofs != (pack[f->v].files[f->i].packofs + pack[f->v].files[f->i].curofs)) - fseek(f->fp, pack[f->v].files[f->i].curofs+pack[f->v].files[f->i].packofs, 0); - pack[f->v].files[f->i].curofs+=len; - pack[f->v].curofs+=len; - } - fread(dest, 1, len, f->fp); -} - -void vclose(VFILE *f) -{ - if (!f) return; - if (!f->s) fclose(f->fp); - f->fp=0; - vfree(f); -} - -int filesize(VFILE *f) -{ - int oldpos, tmp; - - // Filesize for Vfiles is real simple. - if (f->s) return pack[f->v].files[f->i].size; - - // It's a bit more complex for external files. - oldpos=ftell(f->fp); - fseek(f->fp, 0, 2); - tmp=ftell(f->fp); - fseek(f->fp, oldpos, 0); - return tmp; -} - -int vtell(VFILE *f) -{ - if (!f->s) - { - return ftell(f->fp); - } - - return pack[f->v].files[f->i].curofs; -} - -void vseek(VFILE *f, int offset, int origin) -{ - if (!f->s) - { - fseek(f->fp, offset, origin); - return; - } - - switch(origin) - { - case 0: pack[f->v].files[f->i].curofs=offset; - fseek(f->fp, offset+pack[f->v].files[f->i].packofs, 0); - return; - case 1: pack[f->v].files[f->i].curofs+=offset; - fseek(f->fp, offset, 1); - return; - case 2: pack[f->v].files[f->i].curofs=pack[f->v].files[f->i].size-offset; - fseek(f->fp, pack[f->v].files[f->i].curofs+pack[f->v].files[f->i].packofs, 0); - return; - } -} - -void _vscanf(VFILE *f, char *format, char *dest) -{ - fscanf(f->fp, format, dest); - if (f->s) - pack[f->v].files[f->i].curofs=ftell(f->fp)-pack[f->v].files[f->i].packofs; -} - -char vgetc(VFILE *f) -{ char c=0; - - vread(&c, 1, f); - return c; -} - -word vgetw(VFILE *f) -{ word c=0; - - vread((char *) &c, 2, f); - return c; -} - -void vgets(char *str, int len, VFILE *f) -{ - if (f->s) - { - if (pack[f->v].curofs != (pack[f->v].files[f->i].packofs + pack[f->v].files[f->i].curofs)) - fseek(f->fp, pack[f->v].files[f->i].curofs+pack[f->v].files[f->i].packofs, 0); - pack[f->v].files[f->i].curofs+=len; - pack[f->v].curofs+=len; - } - fgets(str, len, f->fp); -} diff --git a/16/v2/source/verge/ENGINE/VFILE.H b/16/v2/source/verge/ENGINE/VFILE.H deleted file mode 100755 index b6beb802..00000000 --- a/16/v2/source/verge/ENGINE/VFILE.H +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef VFILE_H -#define VFILE_H - -#define vscanf _vscanf - -typedef struct -{ - FILE *fp; // real file pointer. - byte s; // 0=real file 1=vfile; - byte v; // if vfile, which vfile index - byte i; // which file index in vfile is it? - byte p; // data alignment pad. :) -} VFILE; - -struct filestruct -{ - unsigned char fname[84]; // pathname thingo - int size; // size of the file - int packofs; // where the file can be found in PACK - int curofs; // current file offset. - char extractable; // irrelevant to runtime, but... - char override; // should we override? -}; - -struct mountstruct -{ - char mountname[80]; // name of VRG packfile. - FILE *vhandle; // Real file-handle of packfile. - struct filestruct *files; // File record array. - int numfiles; // number of files in pack. - int curofs; // Current filepointer. -}; - -extern struct mountstruct pack[3]; -extern char filesmounted; - -int Exist(char *fname); -VFILE *vopen(char *fname); -void MountVFile(char *fname); -void vread(void *dest, int len, VFILE *f); -void vclose(VFILE *f); -int filesize(VFILE *f); -int vtell(VFILE *f); -void vseek(VFILE *f, int offset, int origin); -void vscanf(VFILE *f, char *format, char *dest); -char vgetc(VFILE *f); -word vgetw(VFILE *f); -void vgets(char *str, int len, VFILE *f); -#endif diff --git a/16/v2/source/verge/MAPED/A_MEMORY.C b/16/v2/source/verge/MAPED/A_MEMORY.C deleted file mode 100755 index c8f1598b6..00000000 --- a/16/v2/source/verge/MAPED/A_MEMORY.C +++ /dev/null @@ -1,211 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include - -void err(char *str, ...); -void Log(char *str, ...); - -// ***** -// TODO: Move the chunk list from an array to a linked list? -// Would eliminate hardcoded chunk limit, but would make -// general operation slower. Probably not The Right Thing, -// sides the chunk limit can be interesting sometimes. If -// it becomes problematic, consider a Binary Tree. -// ***** - -// ***************************** Data ***************************** - -#define MAXCHUNKS 200 -#define PARANOID 1 -#define PADFILLVALUE 254 -#define PADSIZE 256 - -void MemReport(void); - -#define errm MemReport(), err - -typedef struct -{ - void *pointer; - int size; - int owner; - char desc[20]; -} memblockType; - -memblockType chunks[MAXCHUNKS+1]; -int numchunks=0; - -// ***************************** Code ***************************** - -void *valloc(int amount, char *desc, int owner) -{ - if (numchunks == MAXCHUNKS) - err("Failed allocated %d bytes (%s), reason: Out of chunks.", - amount, desc); - -#ifdef PARANOID - CheckCorruption(); - chunks[numchunks].pointer = (void *) ((int) malloc(amount + (PADSIZE * 2)) + PADSIZE); - chunks[numchunks].size = amount; - memset((char *) chunks[numchunks].pointer - PADSIZE, PADFILLVALUE, PADSIZE); - memset((char *) chunks[numchunks].pointer + - chunks[numchunks].size, PADFILLVALUE, PADSIZE); -#else - chunks[numchunks].pointer = malloc(amount); - chunks[numchunks].size = amount; -#endif - chunks[numchunks].owner = owner; - strncpy(chunks[numchunks].desc, desc, 19); - memset(chunks[numchunks].pointer, 0, chunks[numchunks].size); - return chunks[numchunks++].pointer; -} - -void *qvalloc(int amount) -{ - void *ptr; - - // Quick and dirty memory allocation. Should be used ONLY - // for temporary blocks in speed-critical loops. - - ptr = malloc(amount); - if (!ptr) errm("qvalloc: Failed allocating %d bytes.", amount); - return ptr; -} - -void qvfree(void *ptr) -{ - free(ptr); -} - -int TotalBytesAllocated(void) -{ - int i, tally=0; - - for (i=0; i -#include -#include -#include -#include - -#include "config.h" -#include "keyboard.h" -#include "timer.h" -#include "vdriver.h" - -#include "colbak.h" -#include "colstuff.h" - -#include "smalfont.h" -#include "gui.h" - -#include "tilesel.h" - -#define byte unsigned char -#define word unsigned short - -// ================================= Data ==================================== - -char *field, *destruct; -char *background, *sprites; -int startofs=16; -int turnlength, turnctr; -int destructed, difficulty=4; -int blocks, score, scoremultiplier; -int level; - -// Current piece falling - -char piece[3], tempspot; -int xpos, ypos, ypofs; -char newpiece; -char nextpiece[3]; - -// ================================= Code ==================================== - -void BlitPlayField() -{ - int i, j; - char c; - - for (i=0; i<12; i++) - for (j=0; j<6; j++) - { - c=field[(i*6)+j]; - if (c) TCopySprite(128+(j*16), startofs+4+(i*16), 16, 16, sprites+((c+1)*256)); - } -} - -void BlitPlayFieldwDestruct(char flash) -{ - int i, j; - char c; - - for (i=0; i<12; i++) - for (j=0; j<6; j++) - { - c=field[(i*6)+j]; - if (c && !destruct[(i*6)+j]) - TCopySprite(128+(j*16), startofs+4+(i*16), 16, 16, sprites+((c+1)*256)); - if (destruct[(i*6)+j]) - TCopySprite(128+(j*16), startofs+4+(i*16), 16, 16, sprites+(flash*256)); - } -} - -void BlitPiece() -{ - ypofs=((100 * turnctr) / turnlength) * 16 / 100; - - TCopySprite(128+(xpos*16), startofs+4+(ypos*16)+ypofs, 16, 16, sprites+((piece[0]+1)*256)); - TCopySprite(128+(xpos*16), startofs+20+(ypos*16)+ypofs, 16, 16, sprites+((piece[1]+1)*256)); - TCopySprite(128+(xpos*16), startofs+36+(ypos*16)+ypofs, 16, 16, sprites+((piece[2]+1)*256)); - - TCopySprite(276, startofs+70, 16, 16, sprites+((nextpiece[0]+1)*256)); - TCopySprite(276, startofs+90, 16, 16, sprites+((nextpiece[1]+1)*256)); - TCopySprite(276, startofs+110, 16, 16, sprites+((nextpiece[2]+1)*256)); -} - -void GenerateNewPiece() -{ - newpiece=0; - xpos=2; - ypos=0; - if (field[2]) key[SCAN_ESC]=1; - if (field[8]) key[SCAN_ESC]=1; - if (field[14]) key[SCAN_ESC]=1; - if (field[20]) key[SCAN_ESC]=1; - - if (key[SCAN_ESC]) - { - if (difficulty==4 && blocks<240) Message("You really suck at columns, man.",300); - if (difficulty==5 && blocks<80) Message("You really suck at columns, man.",300); - if (score>3200 && score<=6400) Message("Not bad.",300); - if (score>6400) Message("Behold, the Columns God walks among us.",500); - } - - memcpy(&piece, &nextpiece, 3); - nextpiece[0]=random(1,difficulty); - nextpiece[1]=random(1,difficulty); - nextpiece[2]=random(1,difficulty); -} - -void DestroyBlock(int x, int y) -{ - int i; - - for (i=y; i>0; i--) - { - field[(i*6)+x]=field[((i-1)*6)+x]; - } - blocks++; - score+=scoremultiplier; -} - -void ClearConsecutiveColumns() -{ - int x, y; - char c; - - // Scan for things to destroy, but don't destroy them, just mark - // them in the Destroy field. - - destructed=0; - memset(destruct, 0, (6*13)); - - for (y=0; y<12; y++) - for (x=0; x<6; x++) - { - c=field[(y*6)+x]; - - // Test vertical match - if (y<10) - { - if ((field[((y+1)*6)+x]==c) && (field[((y+2)*6)+x]==c) && c) - { - // vertical match. Set destruct field. - destruct[((y+0)*6)+x]=1; - destruct[((y+1)*6)+x]=1; - destruct[((y+2)*6)+x]=1; - destructed=1; - } - } - // Test horizontal match - if (x<4) - { - if ((field[(y*6)+x+1]==c) && (field[(y*6)+x+2]==c) && c) - { - // horizontal match. Set destruct field. - destruct[(y*6)+x+0]=1; - destruct[(y*6)+x+1]=1; - destruct[(y*6)+x+2]=1; - destructed=1; - } - } - // Test negative diagonal match - if (x<4 && y<10) - { - if ((field[((y+1)*6)+x+1]==c) && (field[((y+2)*6)+x+2]==c) && c) - { - // negative diagonal match. set destruct field. - destruct[((y+0)*6)+x+0]=1; - destruct[((y+1)*6)+x+1]=1; - destruct[((y+2)*6)+x+2]=1; - destructed=1; - } - } - // Test positive diagonal match - if (x>=2 && y<10) - { - if ((field[((y+1)*6)+x-1]==c) && (field[((y+2)*6)+x-2]==c) && c) - { - // positive diagonal match. set destruct field. - destruct[((y+0)*6)+x-0]=1; - destruct[((y+1)*6)+x-1]=1; - destruct[((y+2)*6)+x-2]=1; - destructed=1; - } - } - } - - // Show which tiles are being destroyed before clearing out for increase - // visual coolishness. - - if (destructed) - { - timer_count=0; - while (timer_count<50) - { - if (timer_count<10 || (timer_count>20 && timer_count<30) || - (timer_count>40 && timer_count<50)) c=1; - else c=0; - - CopySprite(16,16,320,200,background); - BlitPlayFieldwDestruct(c); - TCopySprite(276, startofs+70, 16, 16, sprites+((nextpiece[0]+1)*256)); - TCopySprite(276, startofs+90, 16, 16, sprites+((nextpiece[1]+1)*256)); - TCopySprite(276, startofs+110, 16, 16, sprites+((nextpiece[2]+1)*256)); - -GotoXY(55,130); -sprintf(strbuf,"Blocks: %d", blocks); -printstring(strbuf); -GotoXY(55,140); -sprintf(strbuf,"Score: %d", score); -printstring(strbuf); -GotoXY(55,150); -sprintf(strbuf,"Level: %d", level); -printstring(strbuf); - - ShowPage(); - } - } - - // Apply destruct-o patch to the field. - - for (y=0; y<12; y++) - for (x=0; x<6; x++) - if (destruct[(y*6)+x]) DestroyBlock(x,y); -} - -void NextTurn() -{ - ypos++; - if (field[((ypos+3)*6)+xpos]) - { - if (ypos<3) key[SCAN_ESC]=1; - // Hit something; set piece here. - field[(ypos*6)+xpos]=piece[0]; - field[((ypos+1)*6)+xpos]=piece[1]; - field[((ypos+2)*6)+xpos]=piece[2]; - newpiece=1; - - // Scan for consecutive things to delete. - do - { - ClearConsecutiveColumns(); - scoremultiplier*=2; - } while (destructed); - } -} - -int CanGoLeft() -{ - if (!xpos) return 0; - if (field[((ypos+1)*6)+xpos-1]) return 0; - if (field[((ypos+2)*6)+xpos-1]) return 0; - if (field[((ypos+3)*6)+xpos-1]) return 0; - return 1; -} - -int CanGoRight() -{ - if (xpos==5) return 0; - if (field[((ypos+1)*6)+xpos+1]) return 0; - if (field[((ypos+2)*6)+xpos+1]) return 0; - if (field[((ypos+3)*6)+xpos+1]) return 0; - return 1; -} - -void RotatePiece() -{ - tempspot=piece[0]; - piece[0]=piece[1]; - piece[1]=piece[2]; - piece[2]=tempspot; -} - -void ProcessLevels() -{ - if (blocks>80) { level=2; turnlength=90; } - if (blocks>160) { level=3; turnlength=80; } - if (blocks>240) { level=4; turnlength=70; } - if (blocks>320) { level=5; turnlength=60; } - if (blocks>400) { level=6; turnlength=50; } - if (blocks>480) { level=7; turnlength=40; } - if (blocks>560) { level=8; turnlength=30; } - if (blocks>640) { level=9; turnlength=20; } -} - -extern FILE *pcxf; -extern int width, depth; -extern int bytes; -extern int vidoffset; - -void LoadBackground() -{ - int i; - - if (!(pcxf=fopen("colback.pcx","rb"))) - { - background=background_; - } - else - { - fclose(pcxf); - background=(char *) valloc(64000,"col bakg",0); - LoadPCXHeaderNP("colback.pcx"); - for (i=0; i=turnlength) - { - NextTurn(); - turnctr-=turnlength; - } - if (newpiece) GenerateNewPiece(); - BlitPlayField(); - BlitPiece(); - -GotoXY(55,130); -sprintf(strbuf,"Blocks: %d", blocks); -printstring(strbuf); -GotoXY(55,140); -sprintf(strbuf,"Score: %d", score); -printstring(strbuf); -GotoXY(55,150); -sprintf(strbuf,"Level: %d", level); -printstring(strbuf); - - ShowPage(); - } - vfree(sprites); - vfree(background); - vfree(field); - vfree(destruct); -} diff --git a/16/v2/source/verge/MAPED/COLUMNS.H b/16/v2/source/verge/MAPED/COLUMNS.H deleted file mode 100755 index 2c1b4c1e..00000000 --- a/16/v2/source/verge/MAPED/COLUMNS.H +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef COLUMNS_INC -#define COLUMNS_INC - -extern void BlitPlayField(); -extern void BlitPlayFieldwDestruct(char flash); -extern void BlitPiece(); -extern void GenerateNewPiece(); -extern void DestroyBlock(int x, int y); -extern void ClearConsecutiveColumns(); -extern void NextTurn(); -extern int CanGoLeft(); -extern int CanGoRight(); -extern void RotatePiece(); -extern void ProcessLevels(); -extern void LoadBackground(); -extern void Columns(); - -#endif // COLUMNS_INC diff --git a/16/v2/source/verge/MAPED/CONFIG.C b/16/v2/source/verge/MAPED/CONFIG.C deleted file mode 100755 index 0e3f10ec..00000000 --- a/16/v2/source/verge/MAPED/CONFIG.C +++ /dev/null @@ -1,200 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include - -#include "gui.h" -#include "mikmod.h" -#include "maped.h" - -#include "smalfont.h" - -// ================================= Data ==================================== - -FILE *cfg; -char *strbuf; - -char vm=0; // Video mode -char white=0, black=0; // Color definitions -char pad=0; // Padding mode in tile selector. -char th=0, mh=0; // tile-highlight, map highlight - -// GUI default colors - -char winbg=23; -char titlebg=125; -char brightw=31; -char darkw=13; -char darkred=44; - -// ------------------ - -extern char scrollmode, vcedprog[80]; -extern int difficulty; - -// ================================= Code ==================================== - -void InitializeDefaults() -{ - vm=0; - white=31; - black=1; - pad=1; - th=1; - mh=1; - mouse_scroll=1; - scrollmode=1; - memcpy(vcedprog,"edit",5); -} - -void GetConfig(char *fname) -{ - strbuf=(char *) valloc(2000,"strbuf!",0); - InitializeDefaults(); - if (!(cfg=fopen(fname,"r"))) - { - printf("Unable to open config file. Using defaults... \n"); - return; - } - - while (1) - { - fscanf(cfg,"%s",strbuf); - - if (!strcmp(strbuf,"difficulty")) - { fscanf(cfg,"%s",strbuf); - difficulty=atoi(strbuf); continue; } - if (!strcmp(strbuf,"nocdaudio")) - { - //nocdaudio=1; - continue; - } - if (!strcmp(strbuf,"vidmode")) - { fscanf(cfg,"%s",strbuf); - vm=atoi(strbuf); continue; } - if (!strcmp(strbuf,"white")) - { fscanf(cfg,"%s",strbuf); - white=atoi(strbuf); brightw=atoi(strbuf); - TextColor(atoi(strbuf)); continue; } - if (!strcmp(strbuf,"black")) - { fscanf(cfg,"%s",strbuf); - black=atoi(strbuf); continue; } - if (!strcmp(strbuf,"winbg")) - { fscanf(cfg,"%s",strbuf); - winbg=atoi(strbuf); continue; } - if (!strcmp(strbuf,"shadow")) - { fscanf(cfg,"%s",strbuf); - darkw=atoi(strbuf); continue; } - if (!strcmp(strbuf,"darkred")) - { fscanf(cfg,"%s",strbuf); - darkred=atoi(strbuf); continue; } - if (!strcmp(strbuf,"titlebg")) - { fscanf(cfg,"%s",strbuf); - titlebg=atoi(strbuf); continue; } - if (!strcmp(strbuf,"pad")) - { fscanf(cfg,"%s",strbuf); - pad=atoi(strbuf); continue; } - if (!strcmp(strbuf, "scrollmode")) - { fscanf(cfg,"%s",strbuf); - scrollmode=atoi(strbuf); continue; } - // aen - if (!strcmp(strbuf, "mouse_scroll")) - { fscanf(cfg,"%s",strbuf); - mouse_scroll=atoi(strbuf)&1; continue; } - if (!strcmp(strbuf, "md_device")) - { fscanf(cfg, "%s", strbuf); - md_device=atoi(strbuf); continue; } - if (!strcmp(strbuf, "th")) - { fscanf(cfg,"%s",strbuf); - th=atoi(strbuf); continue; } - if (!strcmp(strbuf, "mh")) - { fscanf(cfg,"%s",strbuf); - mh=atoi(strbuf); continue; } - if (!strcmp(strbuf, "amxofs")) - { fscanf(cfg,"%s",strbuf); - amxofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "amyofs")) - { fscanf(cfg,"%s",strbuf); - amyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "mmxofs")) - { fscanf(cfg,"%s",strbuf); - mmxofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "mmyofs")) - { fscanf(cfg,"%s",strbuf); - mmyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "cnxofs")) - { fscanf(cfg,"%s",strbuf); - cnxofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "cnyofs")) - { fscanf(cfg,"%s",strbuf); - cnyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "lmxofs")) - { fscanf(cfg,"%s",strbuf); - lmyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "lmyofs")) - { fscanf(cfg,"%s",strbuf); - lmyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "lvxofs")) - { fscanf(cfg,"%s",strbuf); - lvxofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "lvyofs")) - { fscanf(cfg,"%s",strbuf); - lvyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "mpxofs")) - { fscanf(cfg,"%s",strbuf); - mpxofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "mpyofs")) - { fscanf(cfg,"%s",strbuf); - mpyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "vaxofs")) - { fscanf(cfg,"%s",strbuf); - vaxofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "vayofs")) - { fscanf(cfg,"%s",strbuf); - vayofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "zexofs")) - { fscanf(cfg,"%s",strbuf); - zexofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "zeyofs")) - { fscanf(cfg,"%s",strbuf); - zeyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "exofs")) - { fscanf(cfg,"%s",strbuf); - exofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "eyofs")) - { fscanf(cfg,"%s",strbuf); - eyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "prxofs")) - { fscanf(cfg,"%s",strbuf); - prxofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "pryofs")) - { fscanf(cfg,"%s",strbuf); - pryofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "rsxofs")) - { fscanf(cfg,"%s",strbuf); - rsxofs=atoi(strbuf); continue; } - if (!strcmp(strbuf, "rsyofs")) - { fscanf(cfg,"%s",strbuf); - rsyofs=atoi(strbuf); continue; } - if (!strcmp(strbuf,"vcedprog")) - { fscanf(cfg,"%s",vcedprog); - continue; } - break; - } - fclose(cfg); -} diff --git a/16/v2/source/verge/MAPED/CONFIG.H b/16/v2/source/verge/MAPED/CONFIG.H deleted file mode 100755 index d026fcda..00000000 --- a/16/v2/source/verge/MAPED/CONFIG.H +++ /dev/null @@ -1,28 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef CONFIG_INC -#define CONFIG_INC - -extern char vm; -extern char *strbuf; -extern char white,black,darkred,pad,th,mh; -extern char winbg,titlebg,brightw,darkw; - -extern void InitializeDefaults(); -extern void GetConfig(char *fname); - -#endif // CONFIG_INC diff --git a/16/v2/source/verge/MAPED/CONTROLS.C b/16/v2/source/verge/MAPED/CONTROLS.C deleted file mode 100755 index be58e951..00000000 --- a/16/v2/source/verge/MAPED/CONTROLS.C +++ /dev/null @@ -1,837 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -// CHANGELOG: -// -// + fixed ScreenShot() to properly save screenshots with -// the sequential filenames. -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -// ================================= Data ==================================== - -// ================================= Code ==================================== - -int CheckMouseTabs() -{ int i; - - for (i=0; i<10; i++) - { - if (i<6 && i>=numlayers) continue; - if (mb==1 && mx>17+(i*10) && mx<26+(i*10) && my>(tsy-7) && my17+(i*10) && mx<26+(i*10) && my>(tsy-7) && my1 || (byt & 0xC0) != 0) - { - repcode=0xC0 | samect; - fwrite(&repcode,1,1,pcxf); - } - fwrite(&byt,1,1,pcxf); - } while (i> 2; -} - -void OutputVSPpcx() -{ int i,j,_x,_y; - unsigned char *ptr; - char b1; - short int w1,w2; - - // First figure out the filename - - i=0; - ptr=&vspname; - while (*ptr != '.') - { - strbuf[i]=*ptr; - ptr++; - i++; - } - strbuf[i++]='.'; - strbuf[i++]='P'; - strbuf[i++]='C'; - strbuf[i++]='X'; - strbuf[i++]=0; - - pcxf=fopen(strbuf,"wb"); - -// Write PCX header - - b1=10; fwrite(&b1, 1, 1, pcxf); // manufacturer always = 10 - b1=5; fwrite(&b1, 1, 1, pcxf); // version = 3.0, >16 colors - b1=1; fwrite(&b1, 1, 1, pcxf); // encoding always = 1 - b1=8; fwrite(&b1, 1, 1, pcxf); // 8 bits per pixel, for 256 colors - w1=0; fwrite(&w1, 1, 2, pcxf); // xmin = 0; - w1=0; fwrite(&w1, 1, 2, pcxf); // ymin = 0; - w1=319; fwrite(&w1, 1, 2, pcxf); // xmax = 319; - - // At this point we need to figure out how many vertical rows tall the - // PCX needs to be in order to accomidate the number of tiles in the VSP. - - w2=numtiles/18; w2++; - w2=(w2*17); fwrite(&w2, 1, 2, pcxf); // ymax = ?; - w1=320; fwrite(&w1, 1, 2, pcxf); // hres = 320; - w2++; fwrite(&w2, 1, 2, pcxf); // vres = ?; - - fwrite(screen, 1, 48, pcxf); // 16-color palette data. Who knows what's - // actually in here. It doesn't matter since - // the 256-color palette is stored elsewhere. - - b1=0; fwrite(&b1, 1, 1, pcxf); // reserved always = 0. - b1=1; fwrite(&b1, 1, 1, pcxf); // number of color planes. Just 1 for 8bit. - w1=320; fwrite(&w1, 1, 2, pcxf); // number of bytes per line - - w1=0; fwrite(&w1, 1, 1, pcxf); - fwrite(screen, 1, 59, pcxf); // filler - - // The header is written. Now we need to generate a large buffer where we'll - // "draw" the PCX, and then encode the data and save the PCX. - - ptr=(char *) malloc(320*w2); - memset(ptr,255,(320*w2)); // Give the PCX a white background - - // Now we "draw" the tiles into the buffer. - - for (i=0; i16 colors - b1=1; fwrite(&b1, 1, 1, pcxf); // encoding always = 1 - b1=8; fwrite(&b1, 1, 1, pcxf); // 8 bits per pixel, for 256 colors - w1=0; fwrite(&w1, 1, 2, pcxf); // xmin = 0; - w1=0; fwrite(&w1, 1, 2, pcxf); // ymin = 0; - w1=sx-1; fwrite(&w1, 1, 2, pcxf); // xmax = 319; - w1=sy-1; fwrite(&w1, 1, 2, pcxf); // ymax = 199; - w1=sx; fwrite(&w1, 1, 2, pcxf); // hres = 320; - w1=sy; fwrite(&w1, 1, 2, pcxf); // vres = 200; - - fwrite(screen,1,48,pcxf); - - b1=0; fwrite(&b1, 1, 1, pcxf); // reserved always = 0. - b1=1; fwrite(&b1, 1, 1, pcxf); // number of color planes. Just 1 for 8bit. - w1=sx; fwrite(&w1, 1, 2, pcxf); // number of bytes per line - - w1=0; fwrite(&w1, 1, 1, pcxf); - fwrite(screen, 1, 59, pcxf); // filler - - for (w1=0; w1(tsy-2)) ms_down=1; - if (mx>334) ms_right=1; - if (mx<18) ms_left=1; - } - - if (key[SCAN_UP] || ms_up) - { - if (scrollmode) - { - ywin -= map_scroll_y; - if (ywin < 0) ywin = 0; - } - else - { - if (key[SCAN_UP] || (!(systemtime%10))) - { - key[SCAN_UP]=0; - ywin -= 16; - if (ywin < 0) ywin = 0; - systemtime++; - } - } - } - if (key[SCAN_DOWN] || ms_down) - { - if (scrollmode) - { - ywin += map_scroll_y; - if (ywin > ymax) - ywin = ymax; - } - else - { - if (key[SCAN_DOWN] || (!(systemtime%10))) - { - key[SCAN_DOWN]=0; - ywin += 16; - if (ywin > ymax) - ywin = ymax; - systemtime++; - } - } - } - if (key[SCAN_RIGHT] || ms_right) - { - if (scrollmode) - { - xwin += map_scroll_x; - if (xwin > xmax) - xwin = xmax; - } - else - { - if (key[SCAN_RIGHT] || (!(systemtime%10))) - { - key[SCAN_RIGHT]=0; - xwin += 16; - if (xwin > xmax) - xwin = xmax; - systemtime++; - } - } - } - if (key[SCAN_LEFT] || ms_left) - { - if (scrollmode) - { - xwin -= map_scroll_x; - if (xwin < 0) xwin=0; - } - else - { - if (key[SCAN_LEFT] || (!(systemtime%10))) - { - key[SCAN_LEFT]=0; - xwin -= 16; - if (xwin < 0) xwin = 0; - systemtime++; - } - } - } -} - -ProcessControls() -{ - int xmax, ymax; - - xmax = (layer[0].sizex * 16) - sx; - ymax = (layer[0].sizey * 16) - sy; - - if (key[SCAN_F5]) { key[SCAN_F5]=0; ShellMAP(); } - if (key[SCAN_F6]) { key[SCAN_F6]=0; CompileAll(); } - if (key[SCAN_F8]) { key[SCAN_F8]=0; ShellVERGE(); } - if (key[SCAN_ALT] && key[SCAN_D]) { key[SCAN_D]=0; ShellToDOS(); } - if (key[SCAN_ALT] && key[SCAN_L]) LoadMAPDialog(); - if (key[SCAN_ALT] && key[SCAN_V]) ShellEditMAP(); - if (key[SCAN_ALT] && key[SCAN_S]) ShellEditSystem(); - if (key[SCAN_ALT] && key[SCAN_N]) NewMAP(); - if (key[SCAN_ALT] && key[SCAN_P]) MPDialog(); - if (!key[SCAN_ALT] && key[SCAN_P]) { pasting^=1; key[SCAN_P]=0; } // aen - - if (key[SCAN_A] && el<6) - { - lt++; - if (lt==numtiles) lt=0; - key[SCAN_A]=0; - } - if (key[SCAN_Z] && el<6) - { - if (lt) lt--; - else lt=numtiles-1; - key[SCAN_Z]=0; - } - if (key[SCAN_A] && el==7) - { - curzone++; - key[SCAN_A]=0; - } - if (key[SCAN_Z] && el==7) - { - curzone--; - key[SCAN_Z]=0; - } - if (key[SCAN_S]) - { - rt++; - if (rt==numtiles) rt=0; - key[SCAN_S]=0; - } - if (key[SCAN_X]) - { - if (rt) rt--; - else rt=numtiles-1; - key[SCAN_X]=0; - } - if (key[SCAN_F10]) - { - key[SCAN_F10]=0; - if (random(0,255)<15) HAL(); - SaveMAP(mapname); - SaveVSP(vspname); - CompileMAP(); - Message("MAP/VSP saved.",100); - modified=0; - } - if (key[SCAN_C]) - { - key[SCAN_C]=0; - sprintf(strbuf,"Left: %d Right: %d", lt, rt); - Message(strbuf, 300); - } - if (key[SCAN_M]) - { - key[SCAN_M]=0; - GenerateMiniVSP(); - MiniMAP(); - } - if (key[SCAN_H]) - { - key[SCAN_H]=0; - mh=mh^1; - if (mh) Message("MAP Tile Highlight enabled.",100); - else Message("MAP Tile Highlight disabled.",100); - } - - // *** - // movement code moved to PollMovement() - // *** - - if (key[SCAN_PGUP]) - { - key[SCAN_PGUP]=0; - ywin -= sy; - if (ywin < 0) - ywin = 0; - } - if (key[SCAN_HOME]) - { - key[SCAN_HOME]=0; - xwin -= sx; - if (xwin < 0) - xwin = 0; - } - if (key[SCAN_END]) - { - key[SCAN_END]=0; - xwin += sx; - if (xwin > xmax) - xwin = xmax; - } - if (key[SCAN_PGDN]) - { - key[SCAN_PGDN]=0; - ywin += sy; - if (ywin > ymax) - ywin = ymax; - } - - if (key[SCAN_CTRL] && el<6) - { - key[SCAN_CTRL]=0; - TileSelector(); - } - if (key[SCAN_CTRL] && el==7) - { - key[SCAN_CTRL]=0; - ZoneEdDialog(); - } - - if (key[SCAN_TAB]) - { - key[SCAN_TAB]=0; - if (scrollmode) - { - scrollmode=0; - xwin=xwin/16; xwin=xwin*16; - ywin=ywin/16; ywin=ywin*16; - Message("Tile scroll.",150); - } - else - { - scrollmode=1; - Message("Pixel scroll.",150); - } - } - - if (key[SCAN_1]) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) - { - layertoggle[0]=0; - return; - } - layertoggle[0]=1; - layertoggle[6]=0; layertoggle[7]=0; - layertoggle[8]=0; layertoggle[9]=0; - el=0; - key[SCAN_1]=0; - } - if (key[SCAN_2]) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) - { - layertoggle[1]=0; - return; - } - key[SCAN_2]=0; - layertoggle[6]=0; layertoggle[7]=0; - layertoggle[8]=0; layertoggle[9]=0; - if (numlayers>1) - { layertoggle[1]=1; - el=1; } - } - if (key[SCAN_3]) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) - { - layertoggle[2]=0; - return; - } - key[SCAN_3]=0; - layertoggle[6]=0; layertoggle[7]=0; - layertoggle[8]=0; layertoggle[9]=0; - if (numlayers>2) - { layertoggle[2]=1; - el=2; } - } - if (key[SCAN_4]) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) - { - layertoggle[3]=0; - return; - } - key[SCAN_4]=0; - layertoggle[6]=0; layertoggle[7]=0; - layertoggle[8]=0; layertoggle[9]=0; - if (numlayers>3) - { layertoggle[3]=1; - el=3; } - } - if (key[SCAN_5]) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) - { - layertoggle[4]=0; - return; - } - key[SCAN_5]=0; - layertoggle[6]=0; layertoggle[7]=0; - layertoggle[8]=0; layertoggle[9]=0; - if (numlayers>4) - { layertoggle[4]=1; - el=4; } - } - if (key[SCAN_6]) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) - { - layertoggle[5]=0; - return; - } - key[SCAN_6]=0; - layertoggle[6]=0; layertoggle[7]=0; - layertoggle[8]=0; layertoggle[9]=0; - if (numlayers>5) - { layertoggle[5]=1; - el=5; } - } - if (key[SCAN_O]) - { - key[SCAN_O]=0; - layertoggle[6]=1; layertoggle[7]=0; - layertoggle[8]=0; layertoggle[9]=0; - el=6; - } - if (key[SCAN_N]) - { - key[SCAN_N]=0; - layertoggle[6]=0; layertoggle[7]=1; - layertoggle[8]=0; layertoggle[9]=0; - el=7; - } - if (key[SCAN_E]) - { - key[SCAN_E]=0; - layertoggle[6]=0; layertoggle[7]=0; - layertoggle[8]=1; layertoggle[9]=0; - el=8; - } - if (key[SCAN_T]) - { - key[SCAN_T]=0; - layertoggle[6]=0; layertoggle[7]=0; - layertoggle[8]=0; layertoggle[9]=1; - el=9; - } - if (key[SCAN_F9]) - { // aen - key[SCAN_F9]=0; - mouse_scroll^=1; - sprintf(strbuf,"Mouse scroll %sabled.", mouse_scroll ? "en" : "dis"); - Message(strbuf, 100); - } - if (key[SCAN_F11]) - { - key[SCAN_F11]=0; - ScreenShot(); - Message("Screen capture saved.",300); - } - if (key[SCAN_F12]) - { - key[SCAN_F12]=0; - OutputVSPpcx(); - Message("PCX file exported.",300); - } - if (key[SCAN_LANGLE]) - { - key[SCAN_LANGLE]=0; - ShutdownVideo(); - vm=0; - InitVideo(0); - set_intensity(63); - InitMouse(); - - // aen -- gotta recalc this if you're in a lower res at the bottom of - // the map and jump to a higher res. - xmax = (layer[0].sizex * 16) - sx; - ymax = (layer[0].sizey * 16) - sy; - if (xwin > xmax) xwin=xmax; - if (ywin > ymax) ywin=ymax; - } - if (key[SCAN_RANGLE]) - { - key[SCAN_RANGLE]=0; - ShutdownVideo(); - vm=1; - InitVideo(1); - set_intensity(63); - InitMouse(); - - // aen -- gotta recalc this if you're in a lower res at the bottom of - // the map and jump to a higher res. - xmax = (layer[0].sizex * 16) - sx; - ymax = (layer[0].sizey * 16) - sy; - if (xwin > xmax) xwin=xmax; - if (ywin > ymax) ywin=ymax; - } - - if (CheckMouseTabs()) return; - - if (mb>=3) MainMenu(mx-4,my-5); - if (key[SCAN_ESC]) DoMainMenu(); - - if (mb==1 && key[SCAN_SLASH] && el<6) - { - lt=layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * - layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16)]; - - return; - } - - if (mb==2 && key[SCAN_SLASH] && el<6) - { - rt=layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * - layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16)]; - return; - } - - // aen; these must come before the tile plotting code just below - // to work correctly. - if (mb && el<6 && key[SCAN_LSHIFT] && !shifted) - { - selx1=(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16); - sely1=(((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16); - selx2=selx1; - sely2=sely1; - shifted=mb; - return; - } - if (mb && el<6 && shifted) - { - selx2=(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16); - sely2=(((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16); - return; - } - if (!mb && el<6 && shifted) - { int i,j; - int x1,y1,x2,y2; - - x1=selx1; - y1=sely1; - x2=selx2; - y2=sely2; - - if (x2335) mx=334; - modified=1; - layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * - layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16) - /16)]=lt; - } - if (mb==2 && el<6 && !shifted) - { - if (mx>335) mx=334; - modified=1; - layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * - layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16) - /16)]=rt; - } - - if (mb==1 && el==6) - { - modified=1; - obstruct[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * - layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) - /16)]=1; - } - if (mb==2 && el==6) - { - modified=1; - obstruct[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * - layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) - /16)]=0; - } - if (mb==1 && el==7 && (key[SCAN_LSHIFT] || key[SCAN_RSHIFT])) - { - curzone=zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * - layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) - /16)]; - WaitRelease(); - ZoneEdDialog(); - return; - } - if (mb==1 && el==7) - { - modified=1; - zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * - layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) - /16)]=curzone; - } - if (mb==2 && el==7) - { - modified=1; - zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * - layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) - /16)]=0; - } - if (mb==1 && el==8) - { - WaitRelease(); - ProcessEntity((xwin+(mx-16))/16,(ywin+(my-16))/16); - modified=1; - } - if (el==8 && EntityThere((mx-16+xwin)/16,(my+ywin-16)/16) && - key[SCAN_DEL]) - { - WaitRelease(); - DeleteEntity((mx-16+xwin)/16,(my-16+ywin)/16); - modified=1; - } -} diff --git a/16/v2/source/verge/MAPED/GUI.C b/16/v2/source/verge/MAPED/GUI.C deleted file mode 100755 index 49bdc469..00000000 --- a/16/v2/source/verge/MAPED/GUI.C +++ /dev/null @@ -1,5062 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include -#include - -#include "config.h" -#include "guicomp.h" -#include "maped.h" -#include "mouse.h" -#include "render.h" -#include "timer.h" -#include "vdriver.h" -#include "keyboard.h" - -#include "smalfont.h" -#include "columns.h" -#include "tilesel.h" - -// ================================= Data ==================================== - -struct message -{ - char text[44]; // message text - int exptime; // message expire time -}; - -struct message messages[6]; // 5-message buffer -char num_msgs=0; // number of active messages -char playingmod[80]; // currently playing mod. -extern char scrollmode; - -// ================================= Code ==================================== - -void CheckMessageExpirations() -{ int i; - - for (i=0; imessages[i].exptime) - { - memcpy(messages[i].text, messages[i+1].text, (48*(num_msgs-i+1))); - num_msgs--; - } -} - -void Message(char *text, int duration) -{ - if (num_msgs<5) - { - memcpy(messages[num_msgs].text, text, strlen(text)); - messages[num_msgs].exptime=systemtime+duration; - num_msgs++; - return; - } - - memcpy(&messages[0].text, &messages[1].text, 192); - memcpy(messages[4].text, text, strlen(text)+1); - messages[num_msgs].exptime=systemtime+duration; -} - -void DrawScreenControls() -{ int i; - byte c; - - if (el<6) - { - if (pasting) - { - GotoXY(298-5,tsy-19+13); - printstring("P"); - } - } - - // Put current-tile boxes if applicable. - if (el<6) - { - FilledBox(298,tsy-19,18,18,white); - FilledBox(317,tsy-19,18,18,white); - CopySprite(299,tsy-18,16,16,vsp+(256*lt)); - CopySprite(318,tsy-18,16,16,vsp+(256*rt)); - } - - if (el==7) - { - sprintf(strbuf,"Zone %d",curzone); - GotoXY(280,tsy-16); - printstring(strbuf); - GotoXY(280,tsy-10); - printstring(zones[curzone].name); - - c=zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * - layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16)/16)]; - - if (c) - { - sprintf(strbuf,"zone %d",c); - GotoXY(280,17); - printstring(strbuf); - GotoXY(280,23); - printstring(zones[c].name); - } - } - - if (el==8) - { - sprintf(strbuf,"%d entities",entities); - GotoXY(285,17); printstring(strbuf); - - if (c=EntityThere((mx+xwin-16)/16,(my+ywin-16)/16)) - { - c--; - GotoXY(285,tsy-10); - printstring(entity[c].desc); - } - } - - // Put the current-tile mouse thingy. - GotoXY(17,17); - dec_to_asciiz((xwin+mx-16)/16,strbuf); - printstring(strbuf); printstring(", "); - dec_to_asciiz((ywin+my-16)/16,strbuf); - printstring(strbuf); - - // Put the layer editor/selector. - - for (i=0; i<6; i++) - { - if (el==i) c=white; else c=darkw; - FilledBox(17+(i*10),tsy-7,9,7,c); - if (layertoggle[i]) c=darkred; else c=0; - FilledBox(18+(i*10),tsy-6,7,6,c); - GotoXY(20+(i*10),tsy-5); dec_to_asciiz(i+1,strbuf); - if (i335) dx=336-80; - if (dy+89>sy+16) dy=(sy+16)-89; - - RenderMap(); - RenderGUI(); - stdwindow(dx, dy, dx+80, dy+89); - - if (mx>dx && mxdy+2 && mydy+8 && mydy+14 && mydy+20 && mydy+29 && mydy+35 && mydy+41 && mydy+47 && mydy+53 && mydy+59 && mydy+65 && mydy+71 && mydy+80 && my"); - GotoXY(dx+3, dy+42); printstring("Options"); - GotoXY(dx+3, dy+48); printstring("MOD Player"); - GotoXY(dx+3, dy+54); printstring("CD Player"); - GotoXY(dx+3, dy+60); printstring("Columns"); - GotoXY(dx+3, dy+66); printstring("Execute"); GotoXY(dx+73, dy+66); printstring(">"); - GotoXY(dx+3, dy+72); printstring("Exit to DOS"); - HLine(dx+2, dy+79, 76, white); - GotoXY(dx+3, dy+81); printstring("About MapEd"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - if (mb==1 && mx>dx && mxdy+2 && mydy+8 && mydy+14 && mydy+20 && mydy+29 && mydy+35 && mydy+41 && mydy+47 && mydy+53 && mydy+59 && mydy+65 && mydy+71 && mydy+80 && my= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - ilxofs = (mx-mxo); - ilyofs = (my-myo); - if (!mb) moving=0; - if (ilxofs<16) ilxofs = 16; - if (ilyofs<16) ilyofs = 16; - if (ilxofs+ilxsize>335) ilxofs = 336-ilxsize; - if (ilyofs+ilysize>sy+16) ilyofs = (sy+16)-ilysize; - } - - Window(ilxofs, ilyofs, ilxofs+ilxsize, ilyofs+ilysize, "Import Image As Layer"); - Button(ilxofs+109, ilyofs+12, "Browse"); - Button(ilxofs+109, ilyofs+30, "OK"); - GotoXY(ilxofs+5, ilyofs+25); printstring("Layer:"); - // layer select radio buttons - for (i=0; i<6; i++) - { - CheckBox(ilxofs+29+(i*10), ilyofs+33, chk_layer & (1<ilxofs+109 && mxilyofs+12 && myilxofs+109 && mxilyofs+30 && mynumlayers) - { - numlayers++; - sprintf(rstring, "%s%i", rstring, ly+1); // update render-order - } - - vfree(t); - vfree(ovsp); - } - // ... - WaitRelease(); continue; - } - - if (mb==1 && mx>ilxofs+29 && mxilyofs+33 && myilxofs+39 && mxilyofs+33 && my= 2) - { - chk_layer ^= 2; - chk_layer &= 2; - //chk_2 ^= 1; - //chk_1=0,chk_3=0,chk_4=0,chk_5=0,chk_6=0; - WaitRelease(); continue; - } - } - - if (mb==1 && mx>ilxofs+49 && mxilyofs+33 && my= 3) - { - chk_layer ^= 4; - chk_layer &= 4; - //chk_3 ^= 1; - //chk_1=0,chk_2=0,chk_4=0,chk_5=0,chk_6=0; - WaitRelease(); continue; - } - } - - if (mb==1 && mx>ilxofs+59 && mxilyofs+33 && my= 4) - { - chk_layer ^= 8; - chk_layer &= 8; - //chk_4 ^= 1; - //chk_1=0,chk_2=0,chk_3=0,chk_5=0,chk_6=0; - WaitRelease(); continue; - } - } - - if (mb==1 && mx>ilxofs+69 && mxilyofs+33 && my= 5) - { - chk_layer ^= 16; - chk_layer &= 16; - //chk_5 ^= 1; - //chk_1=0,chk_2=0,chk_3=0,chk_4=0,chk_6=0; - WaitRelease(); continue; - } - } - - if (mb==1 && mx>ilxofs+79 && mxilyofs+33 && my= 6) - { - chk_layer ^= 32; - chk_layer &= 32; - //chk_6 ^= 1; - //chk_1=0,chk_2=0,chk_3=0,chk_4=0,chk_5=0; - WaitRelease(); continue; - } - } - - // if no checkboxes are marked, mark the first. - //if (!(chk_1+chk_2+chk_3+chk_4+chk_5+chk_6)) chk_1=1; - if (!chk_layer) chk_layer=1; - -// if (mb==1 && mx>ilxofs+29 && mxilyofs+12 && myilxofs+74 && mxilyofs+58 && myilxofs+74 && mxilyofs+69 && myilxofs+5 && mxilyofs+101 && my - if (excessx+excessy) - { - if (chk_grabexcess) - { - if (excessx) tilesx++; - if (excessy) tilesy++; - } - else - { - if (excessx) tilesx--; - if (excessy) tilesy--; - } - if (tilesxilxofs+5 && mxilyofs+110 && myilxofs+5 && mxilyofs+119 && my(ilxofs+ilxsize-9) && (mx(ilyofs+1) && (myilxofs && mxilyofs && my<(ilyofs+9) && !moving) - { - moving=1; - mxo=mx-ilxofs; - myo=my-ilyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - - // keep minimally required padding - if (ctf==1) - { - if (atoi(str)= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - dtxofs = (mx-mxo); - dtyofs = (my-myo); - if (!mb) moving=0; - if (dtxofs<16) dtxofs = 16; - if (dtyofs<16) dtyofs = 16; - if (dtxofs+dtxsize>335) dtxofs = 336-dtxsize; - if (dtyofs+dtysize>sy+16) dtyofs = (sy+16)-dtysize; - } - - Window(dtxofs, dtyofs, dtxofs+dtxsize, dtyofs+dtysize, "Destroyer"); - CheckBox(dtxofs+4, dtyofs+11, zn_check); - CheckBox(dtxofs+4, dtyofs+31, ob_check); - CheckBox(dtxofs+4, dtyofs+21, zd_check); - GotoXY(dtxofs+15, dtyofs+12); printstring("Zones"); - GotoXY(dtxofs+15, dtyofs+32); printstring("Obstructions"); - GotoXY(dtxofs+15, dtyofs+22); printstring("Zone Data"); - Button(dtxofs+68, dtyofs+11, "ok"); - Button(dtxofs+68, dtyofs+24, "cancel"); - CheckBox(dtxofs+4, dtyofs+41, ent_check); - GotoXY(dtxofs+15, dtyofs+42); printstring("Entities"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>dtxofs+4 && mxdtyofs+11 && mydtxofs+4 && mxdtyofs+21 && mydtxofs+4 && mxdtyofs+31 && mydtxofs+4 && mxdtyofs+41 && mydtxofs+68 && mxdtyofs+11 && mydtxofs+68 && mxdtyofs+24 && my(dtxofs+dtxsize-9) && (mx(dtyofs+1) && (mydtxofs && mxdtyofs && my<(dtyofs+9) && !moving) - { - moving=1; - mxo=mx-dtxofs; - myo=my-dtyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} - -void LayersSubMenu(int dx, int dy) -{ char done=0; - //int mxo, myo, cursorblink; - - do - { - if (dx<16) dx=16; - if (dy<16) dy=16; - if (dx+80>335) dx=336-80; - if (dy+89>sy+16) dy=(sy+16)-89; - - RenderMap(); - RenderGUI(); - stdwindow(dx, dy, dx+80, dy+29); - - if (mx>dx && mxdy+2 && mydy+8 && mydy+14 && mydy+20 && mydx && mxdy+2 && mydy+8 && mydy+14 && mydy+20 && my335) dx=336-80; - if (dy+89>sy+16) dy=(sy+16)-89; - - RenderMap(); - RenderGUI(); - stdwindow(dx, dy, dx+80, dy+23); - - if (mx>dx && mxdy+2 && mydy+8 && mydy+14 && mydx && mxdy+2 && mydy+8 && mydy+14 && my5) i=0; - if (i>=numlayers) i=0; - - sprintf(nstr1, "%d", layer[i].pmultx); - sprintf(nstr2, "%d", layer[i].pdivx); - sprintf(nstr3, "%d", layer[i].pmulty); - sprintf(nstr4, "%d", layer[i].pdivy); - sprintf(nstr5, "%d", layer[i].trans); - sprintf(nstr6, "%d", layer[i].hline); - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - lpxofs = (mx-mxo); - lpyofs = (my-myo); - if (!mb) moving=0; - if (lpxofs<16) lpxofs = 16; - if (lpyofs<16) lpyofs = 16; - if (lpxofs+lpxsize>335) lpxofs = 336-lpxsize; - if (lpyofs+lpysize>sy+16) lpyofs = (sy+16)-lpysize; - } - - Window(lpxofs, lpyofs, lpxofs+lpxsize, lpyofs+lpysize, "Edit Layer Properties"); - GotoXY(lpxofs+3, lpyofs+10); printstring("Parallax controls:"); - GotoXY(lpxofs+4, lpyofs+21); printstring("MultX:"); - GotoXY(lpxofs+12, lpyofs+31); printstring("DivX:"); - GotoXY(lpxofs+93, lpyofs+21); printstring("MultY:"); - GotoXY(lpxofs+101, lpyofs+31); printstring("DivY:"); - TextField(lpxofs+29, lpyofs+19, 60, nstr1, ctf == 1 ? cb : 0); - TextField(lpxofs+29, lpyofs+29, 60, nstr2, ctf == 2 ? cb : 0); - TextField(lpxofs+118, lpyofs+19, 60, nstr3, ctf == 3 ? cb : 0); - TextField(lpxofs+118, lpyofs+29, 60, nstr4, ctf == 4 ? cb : 0); - HLine(lpxofs+1, lpyofs+43, 188, white); - GotoXY(lpxofs+9, lpyofs+48); printstring("Transparent"); - GotoXY(lpxofs+36, lpyofs+58); printstring("HLine"); - TextField(lpxofs+56, lpyofs+46, 60, nstr5, ctf == 5 ? cb : 0); - TextField(lpxofs+56, lpyofs+56, 60, nstr6, ctf == 6 ? cb : 0); - Button(lpxofs+156, lpyofs+55, "OK"); - GotoXY(lpxofs+144, lpyofs+47); printstring("Layer"); - sprintf(strbuf,"%d",i); GotoXY(lpxofs+168, lpyofs+47); printstring(strbuf); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>lpxofs+29 && mxlpyofs+19 && mylpxofs+29 && mxlpyofs+29 && mylpxofs+118 && mxlpyofs+19 && mylpxofs+118 && mxlpyofs+29 && mylpxofs+56 && mxlpyofs+46 && mylpxofs+56 && mxlpyofs+56 && mylpxofs+156 && mxlpyofs+55 && my(lpxofs+lpxsize-9) && (mx(lpyofs+1) && (mylpxofs && mxlpyofs && my<(lpyofs+9) && !moving) - { - moving=1; - mxo=mx-lpxofs; - myo=my-lpyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_UP) - { - layer[i].pmultx=atoi(nstr1); - layer[i].pdivx=atoi(nstr2); - layer[i].pmulty=atoi(nstr3); - layer[i].pdivy=atoi(nstr4); - layer[i].trans=atoi(nstr5); - layer[i].hline=atoi(nstr6); - last_pressed=0; key[SCAN_UP]=0; - if (i) i--; else i=numlayers-1; - sprintf(nstr1, "%d", layer[i].pmultx); - sprintf(nstr2, "%d", layer[i].pdivx); - sprintf(nstr3, "%d", layer[i].pmulty); - sprintf(nstr4, "%d", layer[i].pdivy); - sprintf(nstr5, "%d", layer[i].trans); - sprintf(nstr6, "%d", layer[i].hline); - } - if (last_pressed==SCAN_DOWN) - { - layer[i].pmultx=atoi(nstr1); - layer[i].pdivx=atoi(nstr2); - layer[i].pmulty=atoi(nstr3); - layer[i].pdivy=atoi(nstr4); - layer[i].trans=atoi(nstr5); - layer[i].hline=atoi(nstr6); - last_pressed=0; key[SCAN_DOWN]=0; - if (i5) i=0; - if (i>=numlayers) i=0; - - sprintf(nstr1, "%d", layer[i].pmultx); - sprintf(nstr2, "%d", layer[i].pdivx); - sprintf(nstr3, "%d", layer[i].pmulty); - sprintf(nstr4, "%d", layer[i].pdivy); - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - lpxofs = (mx-mxo); - lpyofs = (my-myo); - if (!mb) moving=0; - if (lpxofs<16) lpxofs = 16; - if (lpyofs<16) lpyofs = 16; - if (lpxofs+lpxsize>335) lpxofs = 336-lpxsize; - if (lpyofs+lpysize>sy+16) lpyofs = (sy+16)-lpysize; - } - - Window(lpxofs, lpyofs, lpxofs+lpxsize, lpyofs+lpysize, "Edit Layer Properties"); - GotoXY(lpxofs+3, lpyofs+10); printstring("Parallax controls:"); - GotoXY(lpxofs+4, lpyofs+21); printstring("MultX:"); - GotoXY(lpxofs+12, lpyofs+31); printstring("DivX:"); - GotoXY(lpxofs+93, lpyofs+21); printstring("MultY:"); - GotoXY(lpxofs+101, lpyofs+31); printstring("DivY:"); - TextField(lpxofs+29, lpyofs+19, 60, nstr1, ctf == 1 ? cb : 0); - TextField(lpxofs+29, lpyofs+29, 60, nstr2, ctf == 2 ? cb : 0); - TextField(lpxofs+118, lpyofs+19, 60, nstr3, ctf == 3 ? cb : 0); - TextField(lpxofs+118, lpyofs+29, 60, nstr4, ctf == 4 ? cb : 0); - HLine(lpxofs+1, lpyofs+43, 188, white); - GotoXY(lpxofs+6, lpyofs+49); printstring("Transparent"); - GotoXY(lpxofs+32, lpyofs+56); printstring("HLine"); - CheckBox(lpxofs+56, lpyofs+48, layer[i].trans); - CheckBox(lpxofs+56, lpyofs+56, layer[i].hline); - Button(lpxofs+156, lpyofs+55, "OK"); - GotoXY(lpxofs+144, lpyofs+47); printstring("Layer"); - sprintf(strbuf,"%d",i); GotoXY(lpxofs+168, lpyofs+47); printstring(strbuf); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>lpxofs+29 && mxlpyofs+19 && mylpxofs+29 && mxlpyofs+29 && mylpxofs+118 && mxlpyofs+19 && mylpxofs+118 && mxlpyofs+29 && mylpxofs+56 && mxlpyofs+48 && mylpxofs+56 && mxlpyofs+56 && mylpxofs+156 && mxlpyofs+55 && my(lpxofs+lpxsize-9) && (mx(lpyofs+1) && (mylpxofs && mxlpyofs && my<(lpyofs+9) && !moving) - { - moving=1; - mxo=mx-lpxofs; - myo=my-lpyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_UP) - { - layer[i].pmultx=atoi(nstr1); - layer[i].pdivx=atoi(nstr2); - layer[i].pmulty=atoi(nstr3); - layer[i].pdivy=atoi(nstr4); - last_pressed=0; key[SCAN_UP]=0; - if (i) i--; else i=numlayers-1; - sprintf(nstr1, "%d", layer[i].pmultx); - sprintf(nstr2, "%d", layer[i].pdivx); - sprintf(nstr3, "%d", layer[i].pmulty); - sprintf(nstr4, "%d", layer[i].pdivy); - } - if (last_pressed==SCAN_DOWN) - { - layer[i].pmultx=atoi(nstr1); - layer[i].pdivx=atoi(nstr2); - layer[i].pmulty=atoi(nstr3); - layer[i].pdivy=atoi(nstr4); - last_pressed=0; key[SCAN_DOWN]=0; - if (i= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - amxofs = (mx-mxo); - amyofs = (my-myo); - if (!mb) moving=0; - if (amxofs<16) amxofs = 16; - if (amyofs<16) amyofs = 16; - if (amxofs+amxsize>335) amxofs = 336-amxsize; - if (amyofs+amysize>sy+16) amyofs = (sy+16)-amysize; - } - - sprintf(strbuf, "About MapEd %s", ME2_VERSION); - Window(amxofs, amyofs, amxofs+amxsize, amyofs+amysize, strbuf); - sprintf(strbuf, "MapEd v.%s", ME2_VERSION); - GotoXY(amxofs+52, amyofs+16); printstring(strbuf); - GotoXY(amxofs+31, amyofs+22); printstring("Copyright (C) 1998 vecna"); - GotoXY(amxofs+40, amyofs+28); printstring("All Rights Reserved"); - GotoXY(amxofs+(75-pixels("Additional code by Ric")/2), amyofs+41); - printstring("Additional code by Ric"); - GotoXY(amxofs+(75-pixels("Additional code by aen")/2), amyofs+47); - printstring("Additional code by aen"); - GotoXY(amxofs+(75-pixels("Additional code by zeromus")/2), amyofs+53); - printstring("Additional code by zeromus"); - Button(amxofs+60, amyofs+68, "OK"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if ((mb==1 && mx>amxofs+66 && mxamyofs+68 && my(amxofs+amxsize-9) && (mx(amyofs+1) && (myamxofs && mxamyofs && my<(amyofs+9) && !moving) - { - moving=1; - mxo=mx-amxofs; - myo=my-amyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB) - { - switch (ctf) - { - case 0: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - - } while (!done); -} - -int cnxsize=125, cnysize=50; -int cnxofs=114, cnyofs=70; - -int Confirm(char *message) -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - - last_pressed=0; - WaitRelease(); - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - cnxofs = (mx-mxo); - cnyofs = (my-myo); - if (!mb) moving=0; - if (cnxofs<16) cnxofs = 16; - if (cnyofs<16) cnyofs = 16; - if (cnxofs+cnxsize>335) cnxofs = 336-cnxsize; - if (cnyofs+cnysize>sy+16) cnyofs = (sy+16)-cnysize; - } - - Window(cnxofs, cnyofs, cnxofs+cnxsize, cnyofs+cnysize, "Confirm? (Y/N)"); - GotoXY(cnxofs+125/2-(pixels(message)/2), cnyofs+15); printstring(message); - - Button(cnxofs+24, cnyofs+30, "Yes"); - Button(cnxofs+69, cnyofs+30, "No"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>cnxofs+24 && mxcnyofs+30 && mycnxofs+69 && mxcnyofs+30 && my(cnxofs+cnxsize-9) && (mx(cnyofs+1) && (mycnxofs && mxcnyofs && my<(cnyofs+9) && !moving) - { - moving=1; - mxo=mx-cnxofs; - myo=my-cnyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - if (last_pressed==SCAN_N) - { - key[SCAN_N]=0; - done=1; - break; - } - if (last_pressed==SCAN_Y) - { - key[SCAN_Y]=0; - return 1; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB) - { - switch (ctf) - { - case 0: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - - } while (!done); - return 0; -} - -int lmxsize=145, lmysize=36; -int lmxofs=80, lmyofs=50; - -void LoadMAPDialog() -{ char lmapname[80]; - char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - - memset(lmapname, 0, 80); - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - lmxofs = (mx-mxo); - lmyofs = (my-myo); - if (!mb) moving=0; - if (lmxofs<16) lmxofs = 16; - if (lmyofs<16) lmyofs = 16; - if (lmxofs+lmxsize>335) lmxofs = 336-lmxsize; - if (lmyofs+lmysize>sy+16) lmyofs = (sy+16)-lmysize; - } - - Window(lmxofs, lmyofs, lmxofs+lmxsize, lmyofs+lmysize, "Load MAP"); - GotoXY(lmxofs+2, lmyofs+13); printstring("Load MAP:"); - TextField(lmxofs+38, lmyofs+11, 70, lmapname, ctf == 1 ? cb : 0); - Button(lmxofs+79, lmyofs+22, "OK"); - Button(lmxofs+111, lmyofs+22, "Cancel"); - Button(lmxofs+111, lmyofs+11, "Browse"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>lmxofs+38 && mxlmyofs+11 && mylmxofs+79 && mxlmyofs+22 && mylmxofs+111 && mxlmyofs+22 && mylmxofs+111 && mxlmyofs+11 && my(lmxofs+lmxsize-9) && (mx(lmyofs+1) && (mylmxofs && mxlmyofs && my<(lmyofs+9) && !moving) - { - moving=1; - mxo=mx-lmxofs; - myo=my-lmyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB) - { - switch (ctf) - { - case 0: ctf=1; str=lmapname; break; - case 1: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - - } while (!done); -} - -int lvxsize=145, lvysize=35; -int lvxofs=80, lvyofs=50; - -void LoadVSPDialog() -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - char lvspname[80]; - - last_pressed=0; - memset(lvspname,0,80); - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - lvxofs = (mx-mxo); - lvyofs = (my-myo); - if (!mb) moving=0; - if (lvxofs<16) lvxofs = 16; - if (lvyofs<16) lvyofs = 16; - if (lvxofs+lvxsize>335) lvxofs = 336-lvxsize; - if (lvyofs+lvysize>sy+16) lvyofs = (sy+16)-lvysize; - } - - Window(lvxofs, lvyofs, lvxofs+lvxsize, lvyofs+lvysize, "Load VSP"); - GotoXY(lvxofs+2, lvyofs+13); printstring("Load VSP:"); - TextField(lvxofs+38, lvyofs+11, 70, lvspname, ctf == 1 ? cb : 0); - Button(lvxofs+79, lvyofs+21, "OK"); - Button(lvxofs+111, lvyofs+21, "Cancel"); - Button(lvxofs+111, lvyofs+10, "Browse"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>lvxofs+38 && mxlvyofs+11 && mylvxofs+79 && mxlvyofs+21 && mylvxofs+111 && mxlvyofs+21 && mylvxofs+111 && mxlvyofs+10 && my(lvxofs+lvxsize-9) && (mx(lvyofs+1) && (mylvxofs && mxlvyofs && my<(lvyofs+9) && !moving) - { - moving=1; - mxo=mx-lvxofs; - myo=my-lvyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=lvspname; break; - case 1: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=lvspname; break; - case 1: ctf=0; str=lvspname; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} -int mpxsize=175, mpysize=37; -int mpxofs=60, mpyofs=60; - -void MPDialog() -{ char done=0, moving=0, playmod[80]; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - - last_pressed=0; - memset(playmod, 0, 80); - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - mpxofs = (mx-mxo); - mpyofs = (my-myo); - if (!mb) moving=0; - if (mpxofs<16) mpxofs = 16; - if (mpyofs<16) mpyofs = 16; - if (mpxofs+mpxsize>335) mpxofs = 336-mpxsize; - if (mpyofs+mpysize>sy+16) mpyofs = (sy+16)-mpysize; - } - - Window(mpxofs, mpyofs, mpxofs+mpxsize, mpyofs+mpysize, "MOD Player Controls"); - GotoXY(mpxofs+2, mpyofs+15); printstring("MOD Playing:"); - TextField(mpxofs+49, mpyofs+13, 90, playmod, ctf == 1 ? cb : 0); - Button(mpxofs+110, mpyofs+24, "Play"); - Button(mpxofs+142, mpyofs+24, "Stop"); - Button(mpxofs+78, mpyofs+24, "OK"); - Button(mpxofs+142, mpyofs+12, "Browse"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>mpxofs+49 && mxmpyofs+13 && mympxofs+110 && mxmpyofs+24 && mympxofs+142 && mxmpyofs+24 && mympxofs+78 && mxmpyofs+24 && mympxofs+142 && mxmpyofs+12 && my(mpxofs+mpxsize-9) && (mx(mpyofs+1) && (mympxofs && mxmpyofs && my<(mpyofs+9) && !moving) - { - moving=1; - mxo=mx-mpxofs; - myo=my-mpyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=playmod; break; - case 1: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=playmod; break; - case 1: ctf=0; str=playmod; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} - -int zexsize=135, zeysize=86; -int zexofs=80, zeyofs=40; - -void ZoneEdDialog() -{ char done=0, moving=0; - int mxo, myo, cursorblink, i=0; - char ctf=0, cb=0, c, t, *str; - char nstr1[80], nstr2[80], nstr3[80], nstr4[80]; - - i=curzone; - sprintf(nstr1, "%d", zones[i].script); - sprintf(nstr2, "%d", zones[i].percent); - sprintf(nstr3, "%d", zones[i].delay); - sprintf(nstr4, "%d", zones[i].entityscript); - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - zexofs = (mx-mxo); - zeyofs = (my-myo); - if (!mb) moving=0; - if (zexofs<16) zexofs = 16; - if (zeyofs<16) zeyofs = 16; - if (zexofs+zexsize>335) zexofs = 336-zexsize; - if (zeyofs+zeysize>sy+16) zeyofs = (sy+16)-zeysize; - } - - Window(zexofs, zeyofs, zexofs+zexsize, zeyofs+zeysize, "Zone Editor"); - GotoXY(zexofs+8, zeyofs+12); printstring("Name:"); - TextField(zexofs+30, zeyofs+10, 100, zones[i].name, ctf == 1 ? cb : 0); - GotoXY(zexofs+5, zeyofs+22); printstring("Script:"); - TextField(zexofs+30, zeyofs+20, 100, nstr1, ctf == 2 ? cb : 0); - GotoXY(zexofs+2, zeyofs+32); printstring("Chance:"); - TextField(zexofs+30, zeyofs+30, 100, nstr2, ctf == 3 ? cb : 0); - GotoXY(zexofs+7, zeyofs+42); printstring("Delay:"); - TextField(zexofs+30, zeyofs+40, 100, nstr3, ctf == 4 ? cb : 0); - GotoXY(zexofs+4, zeyofs+52); printstring("Entity:"); - TextField(zexofs+30, zeyofs+50, 100, nstr4, ctf == 5 ? cb : 0); - CheckBox(zexofs+20, zeyofs+61, zones[i].aaa); - GotoXY(zexofs+31, zeyofs+62); printstring("Allow Adjacent Activation"); - Button(zexofs+99, zeyofs+71, "OK"); - GotoXY(zexofs+12, zeyofs+73); printstring("Zone"); - GotoXY(zexofs+30, zeyofs+73); - sprintf(strbuf,"%d",i); printstring(strbuf); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>zexofs+30 && mxzeyofs+10 && myzexofs+30 && mxzeyofs+20 && myzexofs+30 && mxzeyofs+30 && myzexofs+30 && mxzeyofs+40 && myzexofs+30 && mxzeyofs+50 && myzexofs+20 && mxzeyofs+61 && myzexofs+99 && mxzeyofs+71 && my(zexofs+zexsize-9) && (mx(zeyofs+1) && (myzexofs && mxzeyofs && my<(zeyofs+9) && !moving) - { - moving=1; - mxo=mx-zexofs; - myo=my-zeyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - if (last_pressed==SCAN_UP) - { - zones[i].script=atoi(nstr1); - zones[i].percent=atoi(nstr2); - zones[i].delay=atoi(nstr3); - zones[i].entityscript=atoi(nstr4); - if (i<255) i++; else i=0; - last_pressed=0; key[SCAN_UP]=0; - sprintf(nstr1, "%d", zones[i].script); - sprintf(nstr2, "%d", zones[i].percent); - sprintf(nstr3, "%d", zones[i].delay); - sprintf(nstr4, "%d", zones[i].entityscript); - continue; - } - if (last_pressed==SCAN_DOWN) - { - zones[i].script=atoi(nstr1); - zones[i].percent=atoi(nstr2); - zones[i].delay=atoi(nstr3); - zones[i].entityscript=atoi(nstr4); - if (i) i--; else i=255; - last_pressed=0; key[SCAN_DOWN]=0; - sprintf(nstr1, "%d", zones[i].script); - sprintf(nstr2, "%d", zones[i].percent); - sprintf(nstr3, "%d", zones[i].delay); - sprintf(nstr4, "%d", zones[i].entityscript); - continue; - } - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=zones[i].name; break; - case 1: ctf=2; str=nstr1; break; - case 2: ctf=3; str=nstr2; break; - case 3: ctf=4; str=nstr3; break; - case 4: ctf=5; str=nstr4; break; - case 5: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=5; str=nstr4; break; - case 1: ctf=0; str=0; break; - case 2: ctf=1; str=zones[i].name; break; - case 3: ctf=2; str=nstr1; break; - case 4: ctf=3; str=nstr2; break; - case 5: ctf=4; str=nstr3; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - - } while (!done); - curzone=i; - zones[i].script=atoi(nstr1); - zones[i].percent=atoi(nstr2); - zones[i].delay=atoi(nstr3); - zones[i].entityscript=atoi(nstr4); -} - -int exsize=180, eysize=175; -int exofs=70, eyofs=30; - -void EntityEditor(int i) -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - char nstr1[80], nstr2[80], nstr3[80], nstr4[80], nstr5[80], nstr6[80], nstr7[80], nstr8[80], nstr9[80], nstr10[80], nstr11[80], nstr12[80], nstr13[80]; - - sprintf(nstr1, "%d", entity[i].x); - sprintf(nstr2, "%d", entity[i].y); - sprintf(nstr3, "%d", entity[i].chrindex); - sprintf(nstr4, "%d", entity[i].speed); - sprintf(nstr5, "%d", entity[i].actscript); - sprintf(nstr6, "%d", entity[i].movecode); - sprintf(nstr7, "%d", entity[i].step); - sprintf(nstr8, "%d", entity[i].data2); - sprintf(nstr9, "%d", entity[i].data3); - sprintf(nstr10, "%d", entity[i].delay); - sprintf(nstr11, "%d", entity[i].data5); - sprintf(nstr12, "%d", entity[i].data6); - sprintf(nstr13, "%d", entity[i].movescript); - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - exofs = (mx-mxo); - eyofs = (my-myo); - if (!mb) moving=0; - if (exofs<16) exofs = 16; - if (eyofs<16) eyofs = 16; - if (exofs+exsize>335) exofs = 336-exsize; - if (eyofs+eysize>sy+16) eyofs = (sy+16)-eysize; - } - - Window(exofs, eyofs, exofs+exsize, eyofs+eysize, "Entity Editor"); - GotoXY(exofs+7, eyofs+13); printstring("Desc:"); - TextField(exofs+26, eyofs+11, 80, entity[i].desc, ctf == 1 ? cb : 0); - GotoXY(exofs+19, eyofs+23); printstring("X:"); - TextField(exofs+26, eyofs+21, 80, nstr1, ctf == 2 ? cb : 0); - GotoXY(exofs+19, eyofs+33); printstring("Y:"); - TextField(exofs+26, eyofs+31, 80, nstr2, ctf == 3 ? cb : 0); - GotoXY(exofs+11, eyofs+43); printstring("CHR:"); - TextField(exofs+26, eyofs+41, 80, nstr3, ctf == 4 ? cb : 0); - - // *** - // entity image goes here (just above chr list button) - // *** - - BigButton(exofs+116, eyofs+61, "CHR List"); - BigButton(exofs+115, eyofs+153, "Scripts"); - GotoXY(exofs+2, eyofs+155); printstring("Movescript:"); - HLine(exofs+1, eyofs+73, 178, white); - GotoXY(exofs+3, eyofs+53); printstring("Speed:"); - TextField(exofs+26, eyofs+51, 80, nstr4, ctf == 5 ? cb : 0); - TextField(exofs+26, eyofs+61, 80, nstr5, ctf == 6 ? cb : 0); - GotoXY(exofs+107, eyofs+79); printstring("Is Obstruction"); - CheckBox(exofs+161, eyofs+87, entity[i].obsmode1); - GotoXY(exofs+102, eyofs+88); printstring("Is Obstructable"); - CheckBox(exofs+161, eyofs+78, entity[i].obsmode2); - GotoXY(exofs+24, eyofs+79); printstring("Auto Face"); - CheckBox(exofs+61, eyofs+78, entity[i].face); - GotoXY(exofs+10, eyofs+88); printstring("Activ. Method"); - CheckBox(exofs+61, eyofs+87, entity[i].actm); - HLine(exofs+1, eyofs+98, 178, white); - GotoXY(exofs+126, eyofs+166); printstring("Entity"); - GotoXY(exofs+6, eyofs+104); printstring("Move Code:"); - TextField(exofs+47, eyofs+103, 80, nstr6, ctf == 7 ? cb : 0); - TextField(exofs+30, eyofs+115, 40, nstr7, ctf == 8 ? cb : 0); - TextField(exofs+30, eyofs+125, 40, nstr8, ctf == 9 ? cb : 0); - TextField(exofs+30, eyofs+135, 40, nstr9, ctf == 10 ? cb : 0); - TextField(exofs+113, eyofs+115, 40, nstr10, ctf == 11 ? cb : 0); - TextField(exofs+113, eyofs+125, 40, nstr11, ctf == 12 ? cb : 0); - TextField(exofs+113, eyofs+135, 40, nstr12, ctf == 13 ? cb : 0); - HLine(exofs+1, eyofs+148, 178, white); - TextField(exofs+46, eyofs+153, 60, nstr13, ctf == 14 ? cb : 0); - GotoXY(exofs+5, eyofs+63); printstring("Activ:"); - GotoXY(exofs+152, eyofs+166); - sprintf(strbuf, "%d/%d", i, entities-1); printstring(strbuf); - entity[i].movecode=atoi(nstr6); - if (ctf!=4) entity[i].chrindex=atoi(nstr3); - - switch (entity[i].movecode) - { - case 0: GotoXY(exofs+131, eyofs+104); printstring("Stopped"); break; - case 1: GotoXY(exofs+131, eyofs+104); printstring("Wander"); - GotoXY(exofs+11, eyofs+116); printstring("Step:"); - GotoXY(exofs+90, eyofs+116); printstring("Delay:"); break; - case 2: GotoXY(exofs+131, eyofs+104); printstring("Wander Zone"); - GotoXY(exofs+11, eyofs+116); printstring("Step:"); - GotoXY(exofs+90, eyofs+116); printstring("Delay:"); - GotoXY(exofs+10, eyofs+126); printstring("Zone:"); break; - case 3: GotoXY(exofs+131, eyofs+104); printstring("Wander Box"); - GotoXY(exofs+11, eyofs+116); printstring("Step:"); - GotoXY(exofs+90, eyofs+116); printstring("Delay:"); - GotoXY(exofs+21, eyofs+126); printstring("X1:"); - GotoXY(exofs+21, eyofs+136); printstring("Y1:"); - GotoXY(exofs+102, eyofs+126); printstring("X2:"); - GotoXY(exofs+102, eyofs+136); printstring("Y2:"); break; - case 4: GotoXY(exofs+131, eyofs+104); printstring("Scripted"); break; - } - switch (entity[i].actm) - { - case 0: GotoXY(exofs+72, eyofs+88); printstring("Actv"); break; - case 1: GotoXY(exofs+72, eyofs+88); printstring("Adjc"); break; - } - - if (chrs[entity[i].chrindex].frame) - TCopySprite(exofs+143-(chrs[entity[i].chrindex].fx/2), - eyofs+31-(chrs[entity[i].chrindex].fy/2), - chrs[entity[i].chrindex].fx, chrs[entity[i].chrindex].fy, - chrs[entity[i].chrindex].frame); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>exofs+26 && mxeyofs+11 && myexofs+26 && mxeyofs+21 && myexofs+26 && mxeyofs+31 && myexofs+26 && mxeyofs+41 && myexofs+116 && mxeyofs+61 && myexofs+26 && mxeyofs+51 && myexofs+26 && mxeyofs+61 && myexofs+115 && mxeyofs+153 && myexofs+161 && mxeyofs+87 && myexofs+161 && mxeyofs+78 && myexofs+61 && mxeyofs+78 && myexofs+61 && mxeyofs+87 && myexofs+47 && mxeyofs+103 && myexofs+30 && mxeyofs+115 && myexofs+30 && mxeyofs+125 && myexofs+30 && mxeyofs+135 && myexofs+113 && mxeyofs+115 && myexofs+113 && mxeyofs+125 && myexofs+113 && mxeyofs+135 && myexofs+46 && mxeyofs+153 && my(exofs+exsize-9) && (mx(eyofs+1) && (myexofs && mxeyofs && my<(eyofs+9) && !moving) - { - moving=1; - mxo=mx-exofs; - myo=my-eyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_UP) - { - entity[i].x=atoi(nstr1); - entity[i].y=atoi(nstr2); - entity[i].chrindex=atoi(nstr3); - entity[i].speed=atoi(nstr4); - entity[i].actscript=atoi(nstr5); - entity[i].movecode=atoi(nstr6); - entity[i].step=atoi(nstr7); - entity[i].data2=atoi(nstr8); - entity[i].data3=atoi(nstr9); - entity[i].delay=atoi(nstr10); - entity[i].data5=atoi(nstr11); - entity[i].data6=atoi(nstr12); - entity[i].movescript=atoi(nstr13); - - if (i= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - clxofs = (mx-mxo); - clyofs = (my-myo); - if (!mb) moving=0; - if (clxofs<16) clxofs = 16; - if (clyofs<16) clyofs = 16; - if (clxofs+clxsize>335) clxofs = 336-clxsize; - if (clyofs+clysize>sy+16) clyofs = (sy+16)-clysize; - } - - Window(clxofs, clyofs, clxofs+clxsize, clyofs+clysize, "Entity CHR Reference Index"); - TextField(clxofs+14, clyofs+11, 120, chrlist[base].t, ctf == 1 ? cb : 0); - TextField(clxofs+14, clyofs+22, 120, chrlist[base+1].t, ctf == 2 ? cb : 0); - TextField(clxofs+14, clyofs+33, 120, chrlist[base+2].t, ctf == 3 ? cb : 0); - TextField(clxofs+14, clyofs+44, 120, chrlist[base+3].t, ctf == 4 ? cb : 0); - TextField(clxofs+14, clyofs+55, 120, chrlist[base+4].t, ctf == 5 ? cb : 0); - Button(clxofs+137, clyofs+65, "OK"); - Button(clxofs+137, clyofs+10, "Browse"); - Button(clxofs+137, clyofs+21, "Browse"); - Button(clxofs+137, clyofs+32, "Browse"); - Button(clxofs+137, clyofs+43, "Browse"); - Button(clxofs+137, clyofs+54, "Browse"); - GotoXY(clxofs+3, clyofs+11); sprintf(strbuf,"%d:", base); printstring(strbuf); - GotoXY(clxofs+3, clyofs+22); sprintf(strbuf,"%d:", base+1); printstring(strbuf); - GotoXY(clxofs+3, clyofs+33); sprintf(strbuf,"%d:", base+2); printstring(strbuf); - GotoXY(clxofs+3, clyofs+44); sprintf(strbuf,"%d:", base+3); printstring(strbuf); - GotoXY(clxofs+3, clyofs+55); sprintf(strbuf,"%d:", base+4); printstring(strbuf); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>clxofs+14 && mxclyofs+11 && myclxofs+14 && mxclyofs+22 && myclxofs+14 && mxclyofs+33 && myclxofs+14 && mxclyofs+44 && myclxofs+14 && mxclyofs+55 && myclxofs+137 && mxclyofs+65 && myclxofs+137 && mxclyofs+10 && myclxofs+137 && mxclyofs+21 && myclxofs+137 && mxclyofs+32 && myclxofs+137 && mxclyofs+43 && myclxofs+137 && mxclyofs+54 && my(clxofs+clxsize-9) && (mx(clyofs+1) && (myclxofs && mxclyofs && my<(clyofs+9) && !moving) - { - moving=1; - mxo=mx-clxofs; - myo=my-clyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - if (key[SCAN_UP]) - { - key[SCAN_UP]=0; - if (base) base--; - last_pressed=0; - continue; - } - if (key[SCAN_DOWN]) - { - key[SCAN_DOWN]=0; - if (base<95) base++; - last_pressed=0; - continue; - } - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=chrlist[base].t; break; - case 1: ctf=2; str=chrlist[base+1].t; break; - case 2: ctf=3; str=chrlist[base+2].t; break; - case 3: ctf=4; str=chrlist[base+3].t; break; - case 4: ctf=5; str=chrlist[base+4].t; break; - case 5: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=5; str=chrlist[base].t; break; - case 1: ctf=0; str=chrlist[base].t; break; - case 2: ctf=1; str=chrlist[base+1].t; break; - case 3: ctf=2; str=chrlist[base+2].t; break; - case 4: ctf=3; str=chrlist[base+3].t; break; - case 5: ctf=4; str=chrlist[base+4].t; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} - -int msxsize=181, msysize=77; -int msxofs=70, msyofs=50; -char base1=0; - -void MoveScriptDialog() -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - msxofs = (mx-mxo); - msyofs = (my-myo); - if (!mb) moving=0; - if (msxofs<16) msxofs = 16; - if (msyofs<16) msyofs = 16; - if (msxofs+msxsize>335) msxofs = 336-msxsize; - if (msyofs+msysize>sy+16) msyofs = (sy+16)-msysize; - } - - Window(msxofs, msyofs, msxofs+msxsize, msyofs+msysize, "Movement Script Editor"); - TextField(msxofs+15, msyofs+12, 160, ms[base1].t, ctf == 1 ? cb : 0); - TextField(msxofs+15, msyofs+22, 160, ms[base1+1].t, ctf == 2 ? cb : 0); - TextField(msxofs+15, msyofs+32, 160, ms[base1+2].t, ctf == 3 ? cb : 0); - TextField(msxofs+15, msyofs+42, 160, ms[base1+3].t, ctf == 4 ? cb : 0); - TextField(msxofs+15, msyofs+52, 160, ms[base1+4].t, ctf == 5 ? cb : 0); - Button(msxofs+146, msyofs+63, "OK"); - GotoXY(msxofs+3, msyofs+11); sprintf(strbuf,"%d:", base1); printstring(strbuf); - GotoXY(msxofs+3, msyofs+22); sprintf(strbuf,"%d:", base1+1); printstring(strbuf); - GotoXY(msxofs+3, msyofs+33); sprintf(strbuf,"%d:", base1+2); printstring(strbuf); - GotoXY(msxofs+3, msyofs+44); sprintf(strbuf,"%d:", base1+3); printstring(strbuf); - GotoXY(msxofs+3, msyofs+55); sprintf(strbuf,"%d:", base1+4); printstring(strbuf); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>msxofs+15 && mxmsyofs+12 && mymsxofs+15 && mxmsyofs+22 && mymsxofs+15 && mxmsyofs+32 && mymsxofs+15 && mxmsyofs+42 && mymsxofs+15 && mxmsyofs+52 && mymsxofs+146 && mxmsyofs+63 && my(msxofs+msxsize-9) && (mx(msyofs+1) && (mymsxofs && mxmsyofs && my<(msyofs+9) && !moving) - { - moving=1; - mxo=mx-msxofs; - myo=my-msyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - if (key[SCAN_UP]) - { - key[SCAN_UP]=0; - if (base1) base1--; - last_pressed=0; - continue; - } - if (key[SCAN_DOWN]) - { - key[SCAN_DOWN]=0; - if (base1<95) base1++; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=ms[base1].t; break; - case 1: ctf=2; str=ms[base1+1].t; break; - case 2: ctf=3; str=ms[base1+2].t; break; - case 3: ctf=4; str=ms[base1+3].t; break; - case 4: ctf=5; str=ms[base1+4].t; break; - case 5: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=5; str=ms[base1+4].t; break; - case 1: ctf=0; str=0; break; - case 2: ctf=1; str=ms[base1].t; break; - case 3: ctf=2; str=ms[base1+1].t; break; - case 4: ctf=3; str=ms[base1+2].t; break; - case 5: ctf=4; str=ms[base1+3].t; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} - -int prxsize=150, prysize=80; -int prxofs=50, pryofs=60; - -void MapPropertiesDialog() -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - prxofs = (mx-mxo); - pryofs = (my-myo); - if (!mb) moving=0; - if (prxofs<16) prxofs = 16; - if (pryofs<16) pryofs = 16; - if (prxofs+prxsize>335) prxofs = 336-prxsize; - if (pryofs+prysize>sy+16) pryofs = (sy+16)-prysize; - } - - Window(prxofs, pryofs, prxofs+prxsize, pryofs+prysize, "MAP Properties"); - GotoXY(prxofs+10, pryofs+23); printstring("Music:"); - TextField(prxofs+33, pryofs+11, 112, mapname, ctf == 1 ? cb : 0); - TextField(prxofs+33, pryofs+21, 112, musname, ctf == 2 ? cb : 0); - GotoXY(prxofs+18, pryofs+33); printstring("VSP:"); - TextField(prxofs+33, pryofs+31, 112, vspname, ctf == 3 ? cb : 0); - GotoXY(prxofs+3, pryofs+43); printstring("rstring:"); - TextField(prxofs+33, pryofs+41, 112, rstring, ctf == 4 ? cb : 0); - BigButton(prxofs+97, pryofs+56, "Resize MAP"); - HLine(prxofs+1, pryofs+53, 148, white); - GotoXY(prxofs+3, pryofs+58); printstring("xsize:"); - sprintf(strbuf,"%d",layer[0].sizex); printstring(strbuf); - GotoXY(prxofs+49, pryofs+58); printstring("ysize:"); - sprintf(strbuf,"%d",layer[0].sizey); printstring(strbuf); - Button(prxofs+117, pryofs+67, "OK"); - GotoXY(prxofs+16, pryofs+13); printstring("MAP:"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>prxofs+33 && mxpryofs+11 && myprxofs+33 && mxpryofs+21 && myprxofs+33 && mxpryofs+31 && myprxofs+33 && mxpryofs+41 && myprxofs+97 && mxpryofs+56 && myprxofs+117 && mxpryofs+67 && my(prxofs+prxsize-9) && (mx(pryofs+1) && (myprxofs && mxpryofs && my<(pryofs+9) && !moving) - { - moving=1; - mxo=mx-prxofs; - myo=my-pryofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=mapname; break; - case 1: ctf=2; str=musname; break; - case 2: ctf=3; str=vspname; break; - case 3: ctf=4; str=rstring; break; - case 4: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=4; str=rstring; break; - case 1: ctf=0; str=0; break; - case 2: ctf=1; str=mapname; break; - case 3: ctf=2; str=musname; break; - case 4: ctf=3; str=vspname; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - - } while (!done); - -} - -int rsxsize=134, rsysize=44; -int rsxofs=20, rsyofs=20; - -static void PutByte(byte *to, byte v, int x, int y, int w, int h) -{ - if (x<0 || x>=w || y<0 || y>=h) - return; - - to[(y*w)+x]=v; -} - -static byte GetByte(byte *from, int x, int y, int w, int h) -{ - if (x<0 || x>=w || y<0 || y>=h) - return 0; - - return from[(y*w)+x]; -} - -static void PutWord(word *to, word v, int x, int y, int w, int h) -{ - if (x<0 || x>=w || y<0 || y>=h) - return; - - to[(y*w)+x]=v; -} - -static word GetWord(word *from, int x, int y, int w, int h) -{ - if (x<0 || x>=w || y<0 || y>=h) - return 0; - - return from[(y*w)+x]; -} - -void ResizeMapDialog() -{ char done=0, moving=0; - int mxo, myo, cursorblink, basex, basey, i; //, xl, yl; - char ctf=0, cb=0, c, t; - char *str, *tb; //, *s1, *d1; - char nstr1[80], nstr2[80]; - word *tbw; //, *s=NULL,*d=NULL; - //int temp_width; - int a,b; - - basex=layer[0].sizex; - basey=layer[0].sizey; - sprintf(nstr1, "%d", basex); - sprintf(nstr2, "%d", basey); - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - rsxofs = (mx-mxo); - rsyofs = (my-myo); - if (!mb) moving=0; - if (rsxofs<16) rsxofs = 16; - if (rsyofs<16) rsyofs = 16; - if (rsxofs+rsxsize>335) rsxofs = 336-rsxsize; - if (rsyofs+rsysize>sy+16) rsyofs = (sy+16)-rsysize; - } - - Window(rsxofs, rsyofs, rsxofs+rsxsize, rsyofs+rsysize, "Resize MAP"); - GotoXY(rsxofs+4, rsyofs+12); printstring("Base X:"); - GotoXY(rsxofs+4, rsyofs+22); printstring("Base Y:"); - TextField(rsxofs+30, rsyofs+10, 100, nstr1, ctf == 1 ? cb : 0); - TextField(rsxofs+30, rsyofs+20, 100, nstr2, ctf == 2 ? cb : 0); - Button(rsxofs+69, rsyofs+31, "Resize"); - Button(rsxofs+101, rsyofs+31, "Cancel"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>rsxofs+30 && mxrsyofs+10 && myrsxofs+30 && mxrsyofs+20 && myrsxofs+69 && mxrsyofs+31 && myrsxofs+101 && mxrsyofs+31 && my(rsxofs+rsxsize-9) && (mx(rsyofs+1) && (myrsxofs && mxrsyofs && my<(rsyofs+9) && !moving) - { - moving=1; - mxo=mx-rsxofs; - myo=my-rsyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=nstr1; break; - case 1: ctf=2; str=nstr2; break; - case 2: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=2; str=nstr2; break; - case 1: ctf=0; str=0; break; - case 2: ctf=1; str=nstr1; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); - basex=atoi(nstr1); - basey=atoi(nstr2); -} - -int cdxsize=150, cdysize=45; -int cdxofs=110, cdyofs=70; -char curtrack=1; - -void CDDialog() -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - cdxofs = (mx-mxo); - cdyofs = (my-myo); - if (!mb) moving=0; - if (cdxofs<16) cdxofs = 16; - if (cdyofs<16) cdyofs = 16; - if (cdxofs+cdxsize>335) cdxofs = 336-cdxsize; - if (cdyofs+cdysize>sy+16) cdyofs = (sy+16)-cdysize; - } - - Window(cdxofs, cdyofs, cdxofs+cdxsize, cdyofs+cdysize, "CD Player"); - Button(cdxofs+53, cdyofs+10, "Play"); - Button(cdxofs+53, cdyofs+21, "Stop"); - Button(cdxofs+85, cdyofs+10, "Eject"); - Button(cdxofs+85, cdyofs+21, "Close"); - Button(cdxofs+117, cdyofs+10, "Next"); - Button(cdxofs+117, cdyofs+21, "Prev"); - Button(cdxofs+117, cdyofs+32, "OK"); - GotoXY(cdxofs+4, cdyofs+18); printstring("Track "); - sprintf(strbuf,"%d",curtrack); printstring(strbuf); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>cdxofs+53 && mxcdyofs+10 && mycdxofs+53 && mxcdyofs+21 && mycdxofs+85 && mxcdyofs+10 && mycdxofs+85 && mxcdyofs+21 && mycdxofs+117 && mxcdyofs+10 && mycdxofs+117 && mxcdyofs+21 && my1) curtrack--; - while (mb) - { - ReadMouse(); - ShowPage(); - ReadMouse(); - } - WaitRelease(); continue; - } - - if ((mb==1 && mx>cdxofs+117 && mxcdyofs+32 && my(cdxofs+cdxsize-9) && (mx(cdyofs+1) && (mycdxofs && mxcdyofs && my<(cdyofs+9) && !moving) - { - moving=1; - mxo=mx-cdxofs; - myo=my-cdyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} - -int ntxsize=130, nytsize=51; -int ntxofs=110, ntyofs=70; - -void NoticeDialog() -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - ntxofs = (mx-mxo); - ntyofs = (my-myo); - if (!mb) moving=0; - if (ntxofs<16) ntxofs = 16; - if (ntyofs<16) ntyofs = 16; - if (ntxofs+ntxsize>335) ntxofs = 336-ntxsize; - if (ntyofs+nytsize>sy+16) ntyofs = (sy+16)-nytsize; - } - - Window(ntxofs, ntyofs, ntxofs+ntxsize, ntyofs+nytsize, "Notice!"); - GotoXY(ntxofs+20, ntyofs+20); printstring("Don't forget to add this"); - GotoXY(ntxofs+14, ntyofs+26); printstring("layer to the Render String!"); - Button(ntxofs+50, ntyofs+36, "OK"); - GotoXY(ntxofs+25, ntyofs+14); printstring("Layer has been added."); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if ((mb==1 && mx>ntxofs+50 && mxntyofs+36 && my(ntxofs+ntxsize-9) && (mx(ntyofs+1) && (myntxofs && mxntyofs && my<(ntyofs+9) && !moving) - { - moving=1; - mxo=mx-ntxofs; - myo=my-ntyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} - -int oxsize=150, oysize=98; -int oxofs=120, oyofs=70; -extern char vcedprog[80]; - -void OptionsDialog() -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - char nstr1[80], nstr2[80], nstr3[80], nstr4[80]; - - sprintf(nstr1, "%d", winbg); - sprintf(nstr2, "%d", titlebg); - sprintf(nstr3, "%d", brightw); - sprintf(nstr4, "%d", darkw); - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - oxofs = (mx-mxo); - oyofs = (my-myo); - if (!mb) moving=0; - if (oxofs<16) oxofs = 16; - if (oyofs<16) oyofs = 16; - if (oxofs+oxsize>335) oxofs = 336-oxsize; - if (oyofs+oysize>sy+16) oyofs = (sy+16)-oysize; - } - - Window(oxofs, oyofs, oxofs+oxsize, oyofs+oysize, "MapEd Options"); - GotoXY(oxofs+16, oyofs+12); printstring("Smooth Scroll"); - CheckBox(oxofs+5, oyofs+11, scrollmode); - GotoXY(oxofs+16, oyofs+20); printstring("Tile Highlight"); - CheckBox(oxofs+5, oyofs+19, mh); - GotoXY(oxofs+38, oyofs+31); printstring("Window Background"); - TextField(oxofs+5, oyofs+29, 30, nstr1, ctf == 1 ? cb : 0); - TextField(oxofs+5, oyofs+39, 30, nstr2, ctf == 2 ? cb : 0); - GotoXY(oxofs+38, oyofs+41); printstring("Titlebar Background"); - CheckBox(oxofs+74, oyofs+11, vm); - GotoXY(oxofs+84, oyofs+12); printstring("320x240 driver"); - CheckBox(oxofs+74, oyofs+19, mouse_scroll); - GotoXY(oxofs+84, oyofs+20); printstring("Mouse Scrolling"); - TextField(oxofs+5, oyofs+49, 30, nstr3, ctf == 3 ? cb : 0); - TextField(oxofs+5, oyofs+59, 30, nstr4, ctf == 4 ? cb : 0); - GotoXY(oxofs+38, oyofs+51); printstring("White"); - GotoXY(oxofs+38, oyofs+61); printstring("Shadow"); - Button(oxofs+60, oyofs+85, "OK"); - HLine(oxofs+1, oyofs+71, 148, white); - GotoXY(oxofs+3, oyofs+76); printstring("Editor:"); - TextField(oxofs+28, oyofs+74, 118, vcedprog, ctf == 5 ? cb : 0); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>oxofs+5 && mxoyofs+11 && my>4; xwin=xwin<<4; - ywin=ywin>>4; ywin=ywin<<4; - scrollmode ^= 1; WaitRelease(); continue; - } - - if (mb==1 && mx>oxofs+5 && mxoyofs+19 && myoxofs+5 && mxoyofs+29 && myoxofs+5 && mxoyofs+39 && myoxofs+74 && mxoyofs+11 && myoxofs+74 && mxoyofs+19 && myoxofs+5 && mxoyofs+49 && myoxofs+5 && mxoyofs+59 && myoxofs+60 && mxoyofs+85 && myoxofs+28 && mxoyofs+74 && my(oxofs+oxsize-9) && (mx(oyofs+1) && (myoxofs && mxoyofs && my<(oyofs+9) && !moving) - { - moving=1; - mxo=mx-oxofs; - myo=my-oyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=nstr1; break; - case 1: ctf=2; str=nstr2; break; - case 2: ctf=3; str=nstr3; break; - case 3: ctf=4; str=nstr4; break; - case 4: ctf=5; str=vcedprog; break; - case 5: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=5; str=vcedprog; break; - case 1: ctf=0; str=0; break; - case 2: ctf=1; str=nstr1; break; - case 3: ctf=2; str=nstr2; break; - case 4: ctf=3; str=nstr3; break; - case 5: ctf=4; str=nstr4; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); - winbg=atoi(nstr1); - titlebg=atoi(nstr2); - brightw=atoi(nstr3); - darkw=atoi(nstr4); -} - -int vcexsize=200, vceysize=60; -int vcexofs=76, vceyofs=70; - -void VCNotify(char *msg) -{ char done=0, moving=0; - int mxo, myo, cursorblink; - char ctf=0, cb=0, c, t, *str; - - last_pressed=0; - do - { - RenderMap(); - RenderGUI(); - - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - vcexofs = (mx-mxo); - vceyofs = (my-myo); - if (!mb) moving=0; - if (vcexofs<16) vcexofs = 16; - if (vceyofs<16) vceyofs = 16; - if (vcexofs+vcexsize>335) vcexofs = 336-vcexsize; - if (vceyofs+vceysize>sy+16) vceyofs = (sy+16)-vceysize; - } - - Window(vcexofs, vceyofs, vcexofs+vcexsize, vceyofs+vceysize, "VergeC Error Report"); - Button(vcexofs+85, vceyofs+41, "OK"); - GotoXY(vcexofs+29, vceyofs+17); printstring("VCC has reported the following error:"); - GotoXY(vcexofs+100-(pixels(msg)/2), vceyofs+23); printstring(msg); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if ((mb==1 && mx>vcexofs+85 && mxvceyofs+41 && my(vcexofs+vcexsize-9) && (mx(vceyofs+1) && (myvcexofs && mxvceyofs && my<(vceyofs+9) && !moving) - { - moving=1; - mxo=mx-vcexofs; - myo=my-vceyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} diff --git a/16/v2/source/verge/MAPED/GUI.H b/16/v2/source/verge/MAPED/GUI.H deleted file mode 100755 index 1662db7f..00000000 --- a/16/v2/source/verge/MAPED/GUI.H +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef GUI_INC -#define GUI_INC - -extern int amxofs, amyofs; -extern int mmxofs, mmyofs; -extern int cnxofs, cnyofs; -extern int lmxofs, lmyofs; -extern int lvxofs, lvyofs; -extern int vaxofs, vayofs; -extern int mpxofs, mpyofs; -extern int zexofs, zeyofs; -extern int exofs, eyofs; -extern int prxofs, pryofs; -extern int rsxofs, rsyofs; - -extern void CheckMessageExpirations(); -extern void Message(char *text, int duration); -extern void DrawScreenControls(); -extern void RenderMessages(); -extern void RenderGUI(); -extern void DoMainMenu(); -extern void MainMenu(int dx, int dy); -#define byte unsigned char -extern byte TileCmp(byte *one, byte *two); -extern void ImageToLayer(); -extern void Destroyer(); -extern void LayersSubMenu(int dx, int dy); -extern void ExecuteSubMenu(int dx, int dy); -extern void AddLayer(); -extern void EditLayerProperties(); -extern void NewMAP(); -extern void About(); -extern int Confirm(char *message); -extern void LoadMAPDialog(); -extern void LoadVSPDialog(); -extern void MPDialog(); -extern void ZoneEdDialog(); -extern void EntityEditor(int i); -extern void CHRList(); -extern void MoveScriptDialog(); -extern void MapPropertiesDialog(); -extern void ResizeMapDialog(); -extern void CDDialog(); -extern void NoticeDialog(); -extern void OptionsDialog(); -extern void VCNotify(char *msg); - -#endif // GUI_INC diff --git a/16/v2/source/verge/MAPED/GUICOMP.C b/16/v2/source/verge/MAPED/GUICOMP.C deleted file mode 100755 index e9f87795..00000000 --- a/16/v2/source/verge/MAPED/GUICOMP.C +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// Additional code by Richard Lau (aka Ric) - -#include "config.h" // Colour definitions -#include "vdriver.h" // Video driver functions -#include "smalfont.h" - -// ================================= Code ==================================== - -void stdwindow(int x1, int y1, int x2, int y2) -{ - FilledBox(x1, y1, x2-x1, y2-y1, winbg); - HLine(x1, y1, x2-x1, black); /* -- ric: 13/Jun/98 -- */ - VLine(x1, y1, y2-y1, black); /* Outline window in black */ - HLine(x1+1, y2-1, x2-x1-1, black); - VLine(x2-1, y1+1, y2-y1-1, black); - - HLine(x1+1, y1+1, x2-x1-2, brightw); - VLine(x1+1, y1+1, y2-y1-2, brightw); - HLine(x1+2, y2-2, x2-x1-3, darkw); - VLine(x2-2, y1+2, y2-y1-3, darkw); -} - -void Window(int x1, int y1, int x2, int y2, char *title) -{ - FilledBox(x1, y1, x2-x1, y2-y1, winbg); - FilledBox(x1, y1, x2-x1, 8, titlebg); - HLine(x1, y1, x2-x1, brightw); - VLine(x1, y1, y2-y1, brightw); - HLine(x1+1, y2-1, x2-x1-1, darkw); - VLine(x2-1, y1+1, y2-y1-1, darkw); - FilledBox(x2-8, y1+2, 5, 5, winbg); - HLine(x2-8, y1+2, 6, brightw); - VLine(x2-8, y1+2, 5, brightw); - HLine(x2-7, y1+6, 4, darkw); - VLine(x2-3, y1+3, 4, darkw); - - GotoXY(x1+2, y1+2); - printstring(title); -} - -void CheckBox(int x, int y, char checked) -{ - FilledBox(x, y, 7, 6, 0); - HLine(x, y, 8, darkw); - VLine(x, y, 7, darkw); - HLine(x+1, y+6, 7, brightw); - VLine(x+7, y+1, 5, brightw); - if (checked) - { - GotoXY(x+2, y+2); - printstring("*"); - } -} - -void Button(int x, int y, char *str) -{ - stdwindow(x,y,x+30,y+10); -// HLine(x, y, 30, black); /* -- ric: 13/Jun/98 -- */ -// VLine(x, y, 10, black); /* Outline buttons in black */ -/* HLine(x+1, y+9, 29, black); - VLine(x+29, y+1, 9, black); - - HLine(x+1, y+1, 28, white); - VLine(x+1, y+1, 8, white); - HLine(x+2, y+8, 27, darkw); - VLine(x+28, y+2, 7, darkw); */ - GotoXY(x+(15-(pixels(str)/2)), y+2); - printstring(str); -} - -void BigButton(int x, int y, char *str) -{ - stdwindow(x,y,x+50,y+10); -// HLine(x, y, 50, black); /* -- ric: 13/Jun/98 -- */ -// VLine(x, y, 10, black); /* Outline buttons in black */ -/* HLine(x+1, y+9, 49, black); - VLine(x+49, y+1, 9, black); - - HLine(x+1, y+1, 48, white); - VLine(x+1, y+1, 8, white); - HLine(x+2, y+8, 47, darkw); - VLine(x+48, y+2, 7, darkw); */ - GotoXY(x+(25-(pixels(str)/2)), y+2); - printstring(str); -} - -void ButtonPressed(int x, int y, char *str) -/* -- ric: 13/Jun/98 -- */ -/* Draws a depressed button */ -{ - stdwindow(x,y,x+30,y+10); - HLine(x+1, y+1, 28, darkw); - VLine(x+1, y+1, 8, darkw); - HLine(x+2, y+8, 27, winbg); - VLine(x+28, y+2, 7, winbg); - GotoXY(x+1+(15-(pixels(str)/2)), y+3); - printstring(str); -} - -void BigButtonPressed(int x, int y, char *str) -{ - stdwindow(x,y,x+50,y+10); - HLine(x+1, y+1, 48, darkw); - VLine(x+1, y+1, 8, darkw); - HLine(x+2, y+8, 47, winbg); - VLine(x+48, y+2, 7, winbg); - GotoXY(x+1+(25-(pixels(str)/2)), y+3); - printstring(str); -} - -void TextField(int x, int y, int width, char *str, char blink) -{ - FilledBox(x, y, width, 9, 0); - HLine(x, y, width+1, darkw); - VLine(x, y, 9, darkw); - HLine(x+1, y+8, width-1, brightw); - VLine(x+width, y+1, 8, brightw); - GotoXY(x+2, y+2); - printstring(str); - if (blink) printstring("_"); -} diff --git a/16/v2/source/verge/MAPED/GUICOMP.H b/16/v2/source/verge/MAPED/GUICOMP.H deleted file mode 100755 index 1df18b69..00000000 --- a/16/v2/source/verge/MAPED/GUICOMP.H +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef GUICOMP_INC -#define GUICOMP_INC - -extern void stdwindow(int x1, int y1, int x2, int y2); -extern void Window(int x1, int y1, int x2, int y2, char *title); -extern void CheckBox(int x, int y, char checked); -extern void Button(int x, int y, char *str); -extern void BigButton(int x, int y, char *str); -extern void ButtonPressed(int x, int y, char *str); -extern void BigButtonPressed(int x, int y, char *str); -extern void TextField(int x, int y, int width, char *str, char blink); - -#endif // GUICOMP_INC diff --git a/16/v2/source/verge/MAPED/INTER.H b/16/v2/source/verge/MAPED/INTER.H deleted file mode 100755 index 9c50ae70..00000000 --- a/16/v2/source/verge/MAPED/INTER.H +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if !defined(INTERINC) -#define INTERINC - -#ifdef __WATCOMC__ - #include - #define REGISTERS union REGS - #define SET_AX(r,v) (r).w.ax=(short)(v) - #define SET_BX(r,v) (r).w.bx=(short)(v) - #define SET_CX(r,v) (r).w.cx=(short)(v) - #define SET_DX(r,v) (r).w.dx=(short)(v) - #define INTERRUPT(i,r) int386((i),&(r),&(r)) -#elif defined(__DJGPP__) - #include - #define REGISTERS __dpmi_regs - #define SET_AX(r,v) (r).x.ax=(short)(v) - #define SET_BX(r,v) (r).x.bx=(short)(v) - #define SET_CX(r,v) (r).x.cx=(short)(v) - #define SET_DX(r,v) (r).x.dx=(short)(v) - #define INTERRUPT(i,r) __dpmi_int((i),&(r)) -#endif // watcom | djgpp - -#endif // INTERINC diff --git a/16/v2/source/verge/MAPED/KEYBOARD.C b/16/v2/source/verge/MAPED/KEYBOARD.C deleted file mode 100755 index 246db5f0..00000000 --- a/16/v2/source/verge/MAPED/KEYBOARD.C +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include "timer.h" - -// ================================= Data ==================================== - -char key[128]; -char keycode,last_pressed=0; -char codeBuffer[16]; -void (__interrupt __far *biosKeyboardHandler)(); -char handlerinstalled=0; - -unsigned char key_ascii_tbl[128] = -{ - 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, 9, - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 13, 0, 'a', 's', - 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 39, 0, 0, 92, 'z', 'x', 'c', 'v', - 'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ', 0, 3, 3, 3, 3, 8, - 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, - 0, 0, 0, 127, 0, 0, 92, 3, 3, 0, 0, 0, 0, 0, 0, 0, - 13, 0, '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', 0, 0, 0, 0, 0 -}; - -unsigned char key_shift_tbl[128] = -{ - 0, 0, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 126, 126, - 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 126, 0, 'A', 'S', - 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', 34, 0, 0, '|', 'Z', 'X', 'C', 'V', - 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, 1, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, - 0, 0, 1, 127, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 13, 0, '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '/', 0, 0, 0, 0, 0 -}; - -// ================================= Data ==================================== - -void __interrupt __far KeyboardHandler() -{ - keycode=inp(0x60); - if (keycode>128) - key[keycode-128]=0; - else - { - key[keycode]=1; - last_pressed=keycode; - } - idlect=0; - outp(0x20,0x20); -} - -void InitKeyboard() -{ - if (handlerinstalled) return; - - biosKeyboardHandler=_dos_getvect(0x09); - _dos_setvect(0x09, KeyboardHandler); - handlerinstalled=1; -} - -void ShutdownKeyboard() -{ - if (handlerinstalled) - _dos_setvect(0x09, biosKeyboardHandler); - handlerinstalled=0; -} diff --git a/16/v2/source/verge/MAPED/KEYBOARD.H b/16/v2/source/verge/MAPED/KEYBOARD.H deleted file mode 100755 index 5a2d2948..00000000 --- a/16/v2/source/verge/MAPED/KEYBOARD.H +++ /dev/null @@ -1,115 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef KEYBOARD_INC -#define KEYBOARD_INC - -extern char key[128],last_pressed; -extern unsigned char key_ascii_tbl[128]; -extern unsigned char key_shift_tbl[128]; - -extern void InitKeyboard(); -extern void ShutdownKeyboard(); - -/* Constants for keyboard scan-codes */ - -#define SCAN_ESC 0x01 -#define SCAN_1 0x02 -#define SCAN_2 0x03 -#define SCAN_3 0x04 -#define SCAN_4 0x05 -#define SCAN_5 0x06 -#define SCAN_6 0x07 -#define SCAN_7 0x08 -#define SCAN_8 0x09 -#define SCAN_9 0x0a -#define SCAN_0 0x0b -#define SCAN_MINUS 0x0c -#define SCAN_EQUALS 0x0d -#define SCAN_BACKSP 0x0e -#define SCAN_TAB 0x0f -#define SCAN_Q 0x10 -#define SCAN_W 0x11 -#define SCAN_E 0x12 -#define SCAN_R 0x13 -#define SCAN_T 0x14 -#define SCAN_Y 0x15 -#define SCAN_U 0x16 -#define SCAN_I 0x17 -#define SCAN_O 0x18 -#define SCAN_P 0x19 -#define SCAN_LANGLE 0x1a -#define SCAN_RANGLE 0x1b -#define SCAN_ENTER 0x1c -#define SCAN_CTRL 0x1d -#define SCAN_A 0x1e -#define SCAN_S 0x1f -#define SCAN_D 0x20 -#define SCAN_F 0x21 -#define SCAN_G 0x22 -#define SCAN_H 0x23 -#define SCAN_J 0x24 -#define SCAN_K 0x25 -#define SCAN_L 0x26 -#define SCAN_SCOLON 0x27 -#define SCAN_QUOTA 0x28 -#define SCAN_RQUOTA 0x29 -#define SCAN_LSHIFT 0x2a -#define SCAN_BSLASH 0x2b -#define SCAN_Z 0x2c -#define SCAN_X 0x2d -#define SCAN_C 0x2e -#define SCAN_V 0x2f -#define SCAN_B 0x30 -#define SCAN_N 0x31 -#define SCAN_M 0x32 -#define SCAN_COMA 0x33 -#define SCAN_DOT 0x34 -#define SCAN_SLASH 0x35 -#define SCAN_RSHIFT 0x36 -#define SCAN_GREY_STAR 0x37 -#define SCAN_ALT 0x38 -#define SCAN_SPACE 0x39 -#define SCAN_CAPS 0x3a -#define SCAN_F1 0x3b -#define SCAN_F2 0x3c -#define SCAN_F3 0x3d -#define SCAN_F4 0x3e -#define SCAN_F5 0x3f -#define SCAN_F6 0x40 -#define SCAN_F7 0x41 -#define SCAN_F8 0x42 -#define SCAN_F9 0x43 -#define SCAN_F10 0x44 -#define SCAN_NUMLOCK 0x45 -#define SCAN_SCRLOCK 0x46 -#define SCAN_HOME 0x47 -#define SCAN_UP 0x48 -#define SCAN_PGUP 0x49 -#define SCAN_GREY_MINUS 0x4a -#define SCAN_LEFT 0x4b -#define SCAN_PAD_5 0x4c -#define SCAN_RIGHT 0x4d -#define SCAN_GREY_PLUS 0x4e -#define SCAN_END 0x4f -#define SCAN_DOWN 0x50 -#define SCAN_PGDN 0x51 -#define SCAN_INSERT 0x52 -#define SCAN_DEL 0x53 -#define SCAN_F11 0x57 -#define SCAN_F12 0x58 - -#endif // KEYBOARD_INC diff --git a/16/v2/source/verge/MAPED/MAKEFILE b/16/v2/source/verge/MAPED/MAKEFILE deleted file mode 100755 index d627200b..00000000 --- a/16/v2/source/verge/MAPED/MAKEFILE +++ /dev/null @@ -1,32 +0,0 @@ -# Use the C or C++ compiler -Compiler = wcc386 - -# compiler options -#comp = /oneatx /zp4 /5 /d0 -comp = /bt=dos /oneatx /5 /fp5 /wx /d0 - -Linker_options = option stack=60000 - -# Compile using dos4g or pmodew -#System = dos4g -System = pmodew - -Exe_file = maped.exe - -Objs = maped.obj config.obj gui.obj guicomp.obj mode13h.obj modex.obj keyboard.obj & - minimap.obj mouse.obj render.obj smalfont.obj ssaver.obj tileed.obj & - tilesel.obj timer.obj vdriver.obj columns.obj a_memory.obj mikmod.lib - -#################### - -maped.exe : $(Objs) - - *wlink system $(System) $(Linker_Options) name maped.exe & - file {$<} -# *pmwlite -c4 maped.exe - -.c.obj: - $(Compiler) $(comp) $< - -.asm.obj: - wasm -3pr $< diff --git a/16/v2/source/verge/MAPED/MAPED.C b/16/v2/source/verge/MAPED/MAPED.C deleted file mode 100755 index 9e172742..00000000 --- a/16/v2/source/verge/MAPED/MAPED.C +++ /dev/null @@ -1,1624 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -const char *const ME2_VERSION = "2.01a"; - -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -// CHANGELOG: -// -// + erased valloc(), replaced with a_memory.c -// + added Log() -- output to MAPED.LOG -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -#include -#include - -#include -#include -#include -#include - -#include "config.h" -#include "gui.h" -#include "keyboard.h" -#include "mikmod.h" -#include "mouse.h" -#include "render.h" -#include "timer.h" -#include "vdriver.h" - -#include "ssaver.h" -#include "smalfont.h" -#include "tilesel.h" -#include "minimap.h" -#include "guicomp.h" -#include "config.h" - -#define byte unsigned char -#define word unsigned short - -// Includes for a_memory.c - -void *valloc(int amount, char *desc, int owner); -void *qvalloc(int amount); -int vfree(void *pointer); -void qvfree(void *pointer); -void FreeByOwner(int owner); -void MemReport(void); -void CheckCorruption(void); - -// ================================= Data ==================================== - -typedef struct -{ - unsigned short start; // strand start - unsigned short finish; // strand end - unsigned short delay; // tile-switch delay - unsigned short mode; // tile-animation mode -} vspanim_r; - -typedef struct -{ - char pmultx,pdivx; // parallax multiplier/divisor for X - char pmulty,pdivy; // parallax multiplier/divisor for Y - unsigned short sizex, sizey; // layer dimensions. - unsigned char trans, hline; // transparency flag | hline (raster fx) -} layer_r; - -typedef struct -{ - char name[40]; // zone name/desc - unsigned short script; // script to call thingy - unsigned short percent; // chance of executing - unsigned short delay; // step-delay - unsigned short aaa; // Accept Adjacent Activation - unsigned short entityscript; // script to call for entities -} zoneinfo; - -typedef struct -{ - char zonename[16]; // zone description - unsigned short int callevent; // event number to call - unsigned char percent; // chance (in 255) of event occurance - unsigned char delay; // step-delay before last occurance - unsigned char aaa; // accept adjacent activation - char savedesc[31]; // savegame description -} oldzone; - -typedef struct -{ - int x, y; // xwc, ywx position - word tx, ty; // xtc, ytc position - byte facing; // direction entity is facing - byte moving, movecnt; // direction entity is moving - byte frame; // bottom-line frame to display - byte specframe; // special-frame set thingo - byte chrindex, reset; // CHR index | Reset animation - byte obsmode1, obsmode2; // can be obstructed | Is an obstruction - byte speed, speedct; // entity speed, speedcount :) - byte delayct; // animation frame-delay - char *animofs, *moveofs; // anim script | move script - byte face, actm; // auto-face | activation mode - byte movecode, movescript; // movement type | movement script - byte ctr, mode; // sub-tile move ctr, mode flag (internal) - word step, delay; // step, delay - word stepctr, delayctr; // internal use counters - word data1, data2, data3; // - word data4, data5, data6; // - int actscript; // activation script - int expand1, expand2; // - int expand3, expand4; // - char desc[20]; // Entity description. -} entity_r; - -typedef struct -{ - char t[60]; -} chrlist_r; - -typedef struct -{ - char t[200]; -} movescript; - -typedef struct -{ - unsigned short x; // xwc position - unsigned short y; // ywc position - unsigned char facing; // direction entity is facing - unsigned char moving; // direction entity is moving - unsigned char movcnt; // how far left to move in this tile - unsigned char framectr; // frame sequence counter - unsigned char specframe; // special-frame set thingo - unsigned char chrindex, movecode; // CHR index / movement pattern code - unsigned char activmode, obsmode; // activation mode, obstruction mode - unsigned char v1,v2,v3; // packing stuff. - unsigned int actscript, movescript; // script references - unsigned char speed, speedct; // entity speed, speedcount :) - unsigned short step, delay, // Misc data entries - data1, data2, // More misc data - data3, data4, // yet more crappy misc data. - delayct,adjactv; // yet more internal crap - unsigned short x1,y1,x2,y2; // bounding box coordinates - unsigned char curcmd, cmdarg; // Script commands/arguments - unsigned char *scriptofs; // offset in script parsing - unsigned char face,chasing, // face player when activated | chasing - chasespeed, chasedist; // chasing variables - unsigned short cx,cy; // current-tile pos (moving adjusted) - int expand1; // always room for improvement - char entitydesc[20]; // Editing description -} oldent_r; - -zoneinfo zones[256]; // zone stuff. -layer_r layer[6]; // Array of layer data -vspanim_r vspanim[100]; // tile animation data -unsigned short vadelay[100]; // Tile animation delay ctr -oldzone tzone; // zone for oldmap-to-v2 converting -entity_r entity[256]; // Entity records. -oldent_r oldent; // entity for oldmap-to-v2 converting -byte entities=0; // number of allocated entities. -chrlist_r chrlist[100]; // Max. 100 CHRs per map. -movescript ms[100]; // move scripts arrays -byte nmchr=0; // number of active/loaded CHRs. -byte nms=0; // number of movement scripts - -char mapname[60]; // MAP filename -char vspname[60]; // VSP filemap -char rstring[20]; // render-order string -char musname[60]; // MAP default music -char numlayers; // number of layers in map -short xstart, ystart; // MAP start locations -char *obstruct, *zone; // obstruction and zone buffers -int numzones=0; // Number of active zones. -unsigned short *layers[6]; // Raw layer data -char wrap, soundokay=0; - -// -- vsp related data -- - -unsigned short numtiles; // number of allocated tiles in VSP -unsigned char *vsp; // VSP ptr -char vsp_locked=0; -char vsp_pw[8]; - -// -- map compression - -char *cb,*csrc; // compression workspace buffer -int bufsize; // how many bytes need to be written - -// -- editing related data -- - -int xwin=0, ywin=0; // Editing viewplane -short lt=0, rt=0; // left-button tile, right-button tile -char curzone=0; // current zone. -char scrollmode=0; // tile or pixel scroll modes. -char mouse_scroll=1; -char layertoggle[10]; // layer visible toggles -char el=0; // current editing layer. -char modified=0; // Current buffer modified or not. - -// -- music stuff -- - -char is_playing=0; -char cmname[60]; -UNIMOD *mf=0; - -// -- copy/paste & block fill -- - -word *copybuf=0; -int copybuf_wide=0,copybuf_deep=0; -int selx1=0, sely1=0, selx2=0, sely2=0; -int shifted=0, pasting=0; -extern char curtrack; - -char vcedprog[80]; -byte* translucency_table; //zero - -int moving_up=0,moving_down=0,moving_left=0,moving_right=0; // aen - -// ================================= Code ==================================== - -//added by zero -void LoadTransTable() -{ - FILE *fp; - - if (!translucency_table) - translucency_table=(byte *) valloc(65536,"trans tbl",0); - - fp=fopen("trans.tbl","rb"); - if (!fp) - { - vfree(translucency_table); - translucency_table=0; - return; - } - - fread(translucency_table, 65536, 1, fp); - fclose(fp); -} - -int Exist(char *fname) -{ FILE *tempf; - - tempf=fopen(fname,"rb"); - if (tempf) - { - fclose(tempf); - return 1; - } - else return 0; -} - -void err(char *str, ...) -{ - va_list argptr; - char msg[256]; - - va_start(argptr, str); - vsprintf(msg, str, argptr); - va_end(argptr); - - ShutdownVideo(); - ShutdownTimer(); - ShutdownKeyboard(); - //CD_DeInit(); // wasn't even valid! CD_Deinit() was incorrect - // Actually, Wat is by default case insensitive, so nyeh.;) - //if (curtrack != 1) //CD_Stop(); - - printf("%s \n",msg); - exit(-1); -} - -void errf(char *str, char *str1) -{ - sprintf(strbuf,str,str1); - err(strbuf); -} - -void errn(char *str, int n) -{ - sprintf(strbuf,str,n); - err(strbuf); -} - -int random(int lo, int hi) -{ - int range=hi-lo+1; - int i=rand() % range; - return i+lo; -} - -void PlayMusic(char *fname) -{ - if (!soundokay) return; - if (is_playing) - { - MD_PlayStop(); - ML_Free(mf); - is_playing=0; - } - mf=ML_LoadFN(fname); - if (!mf) - { - Message("Could not load specified music.",500); - return; - } - MP_Init(mf); - md_numchn=mf->numchn; mp_loop=1; - MD_PlayStart(); - is_playing=1; -} - -void StopMusic() -{ - if (!soundokay) return; - MD_PlayStop(); - ML_Free(mf); - is_playing=0; -} - -void LoadVSP(char *fname) -{ FILE *f; - short ver; - - if (!(f=fopen(fname,"rb"))) - errf("VSP file %s not found.",fname); - - fread(&ver, 1, 2, f); - if (ver!=2 && ver!=3) - errf("VSP file %s is not the correct VSP format.",fname); - if (ver==2) - { - fread(&pal, 1, 768, f); - set_intensity(63); - fread(&numtiles, 1, 2, f); - vsp=(char *) valloc(256*numtiles, "vsp data", 0); - fread(vsp, 256, numtiles, f); - fread(&vspanim, 8, 100, f); - fclose(f); - } - if (ver==3) - { - fread(&pal, 1, 768, f); - set_intensity(63); - fread(&numtiles, 1, 2, f); - vsp=(char *) valloc(256*numtiles, "vsp data", 0); - fread(&bufsize, 1, 4, f); - ReadCompressedLayer1(vsp, 256*numtiles, f); - fread(&vspanim, 8, 100, f); - fclose(f); - } -} - -void SaveVSP(char *fname) -{ FILE *f; - short ver; - - f=fopen(fname,"wb"); - ver=3; - fwrite(&ver, 1, 2, f); - fwrite(&pal, 1, 768, f); - fwrite(&numtiles, 1, 2, f); - cb=(char *) valloc(numtiles*256, "vsp tempbuf", 0); - bufsize=0; - WriteCompressedLayer1(vsp, numtiles*256); - fwrite(&bufsize, 1, 4, f); - fwrite(cb, 1, bufsize, f); - //free(bufsize); // what the hell??? @_@ - fwrite(&vspanim, 8, 100, f); - fclose(f); -} - -void EmitC (char c) -{ - *csrc=c; - csrc++; - bufsize++; -} - -void EmitW (short int w) -{ - char *ptr; - - ptr=(char *)&w; - *csrc=*ptr; - csrc++; - ptr++; - *csrc=*ptr; - csrc++; - bufsize+=2; -} - -void WriteCompressedLayer1(unsigned char *p, int len) -{ int i; - unsigned char byt,samect; - unsigned char repcode; - - csrc=cb; - i=0; bufsize=0; - do - { byt=p[i++]; - samect=1; - while (samect<254 && i3 || byt == 0xFF) - { - repcode=0xFF; - EmitC(repcode); - repcode=(char) samect; - EmitC(repcode); - } - EmitC(byt); - } while (i1) - { - repcode=(char) samect; - EmitC(repcode); - repcode=0xFF; - EmitC(repcode); - } - EmitW(byt); - } while (i> 1; - zone[(j*layer[0].sizex)+i]=c; - } - vfree(cb); - - // Load and convert zone data records. - - for (i=0; i<128; i++) - { - fread(&tzone, 1, sizeof tzone, f); - zones[i].script=tzone.callevent; - zones[i].percent=tzone.percent; - zones[i].delay=tzone.delay; - zones[i].aaa=tzone.aaa; - zones[i].entityscript=0; - memcpy(zones[i].name, tzone.zonename, 16); - } - - for (i=0; i<100; i++) // Load and convert CHR list - fread(&chrlist[i].t, 1, 13, f); -// DoCHRdealy(); - - fread(&entities, 1, 1, f); fseek(f, 3, 1); - memset(&entity, 0, sizeof entity); - for (i=0; i30000) - { - Message("Generating Auto-backup",150); - SaveMAP("$$BACKUP.MAP"); - SaveVSP("$$BACKUP.VSP"); - backupct=0; - } - if (idlect>8000 && !inss) - { - inss=1; - ScreenSaver(); - idlect=0; - inss=0; - } -} - -extern int difficulty; - -void SaveNewCFG() -{ FILE *f; - - f=fopen("maped.cfg","w"); - //if (nocdaudio) fprintf(f,"nocdaudio\n"); - fprintf(f,"vidmode %d \n", vm); - fprintf(f,"pad %d \n", pad); - fprintf(f,"scrollmode %d \n",scrollmode); - fprintf(f,"mouse_scroll %d \n",mouse_scroll&1); // aen - fprintf(f,"black %d \n",black); - fprintf(f,"white %d \n",brightw); - fprintf(f,"winbg %d \n",winbg); - fprintf(f,"shadow %d \n",darkw); - fprintf(f,"darkred %d \n",darkred); - fprintf(f,"titlebg %d \n",titlebg); - fprintf(f,"th %d \n", th); - fprintf(f,"mh %d \n", mh); - fprintf(f,"md_device %d \n", md_device==3?3:0); - fprintf(f,"amxofs %d \n",amxofs); - fprintf(f,"amyofs %d \n",amyofs); - fprintf(f,"mmxofs %d \n",mmxofs); - fprintf(f,"mmyofs %d \n",mmyofs); - fprintf(f,"cnxofs %d \n",cnxofs); - fprintf(f,"cnyofs %d \n",cnyofs); - fprintf(f,"lmxofs %d \n",lmxofs); - fprintf(f,"lmyofs %d \n",lmyofs); - fprintf(f,"lvxofs %d \n",lvxofs); - fprintf(f,"lvyofs %d \n",lvyofs); - fprintf(f,"mpxofs %d \n",mpxofs); - fprintf(f,"mpyofs %d \n",mpyofs); - fprintf(f,"vaxofs %d \n",vaxofs); - fprintf(f,"vayofs %d \n",vayofs); - fprintf(f,"zexofs %d \n",zexofs); - fprintf(f,"zeyofs %d \n",zeyofs); - fprintf(f,"exofs %d \n",exofs); - fprintf(f,"eyofs %d \n",eyofs); - fprintf(f,"prxofs %d \n",prxofs); - fprintf(f,"pryofs %d \n",pryofs); - fprintf(f,"rsxofs %d \n",rsxofs); - fprintf(f,"rsyofs %d \n",rsyofs); - fprintf(f,"vced %s \n",vcedprog); - fprintf(f,"difficulty %d \n",difficulty); - fclose(f); -} - -#include "controls.c" - -void ShellToDOS() -{ - ShutdownVideo(); - ShutdownKeyboard(); - ShutdownTimer(); - MD_PlayStop(); - MD_Exit(); - - system("COMMAND.COM"); - - if (!MD_Init()) - { - printf("Couldn't initialize sound: %s.\n", myerr); - delay(500); - soundokay=0; - } - if (strlen(musname)) PlayMusic(musname); - InitVideo(vm); - set_intensity(63); - InitMouse(); - InitKeyboard(); - InitTimer(); -} - -void ShellVERGE() -{ - ShutdownVideo(); - ShutdownKeyboard(); - ShutdownTimer(); - MD_PlayStop(); - MD_Exit(); - - system("VERGE"); - - if (!MD_Init()) - { - printf("Couldn't initialize sound: %s.\n", myerr); - delay(500); - soundokay=0; - } - if (strlen(musname)) PlayMusic(musname); - InitVideo(vm); - set_intensity(63); - InitMouse(); - InitKeyboard(); - InitTimer(); -} - -void ShellMAP() -{ - ShutdownVideo(); - ShutdownKeyboard(); - ShutdownTimer(); - MD_PlayStop(); - MD_Exit(); - - sprintf(strbuf,"verge %s",mapname); - system(strbuf); - - if (!MD_Init()) - { - printf("Couldn't initialize sound: %s.\n", myerr); - delay(500); - soundokay=0; - } - if (strlen(musname)) PlayMusic(musname); - InitVideo(vm); - set_intensity(63); - InitMouse(); - InitKeyboard(); - InitTimer(); -} - -void ShellEditMAP() -{ - char fn[80],*p; - - key[SCAN_ALT]=0; - key[SCAN_V]=0; - ShutdownVideo(); - ShutdownKeyboard(); - ShutdownTimer(); - MD_PlayStop(); - MD_Exit(); - - sprintf(fn,"%s",mapname); - p=fn; - while (*p) - { - if (*p=='.') *p=0; - p++; - } - sprintf(strbuf,"%s %s.vc", vcedprog, fn); - system(strbuf); - - if (!MD_Init()) - { - printf("Couldn't initialize sound: %s.\n", myerr); - delay(500); - soundokay=0; - } - if (strlen(musname)) PlayMusic(musname); - InitVideo(vm); - set_intensity(63); - InitMouse(); - InitKeyboard(); - InitTimer(); -} - -void ShellEditSystem() -{ - key[SCAN_ALT]=0; - key[SCAN_S]=0; - ShutdownVideo(); - ShutdownKeyboard(); - ShutdownTimer(); - MD_PlayStop(); - MD_Exit(); - - sprintf(strbuf,"%s system.vc", vcedprog); - system(strbuf); - - if (!MD_Init()) - { - printf("Couldn't initialize sound: %s.\n", myerr); - delay(500); - soundokay=0; - } - if (strlen(musname)) PlayMusic(musname); - InitVideo(vm); - set_intensity(63); - InitMouse(); - InitKeyboard(); - InitTimer(); -} - -char s[256]; - -void CompileAll() -{ - FILE *f; - char *p; - - MD_PlayStop(); - MD_Exit(); - - sprintf(strbuf,"vcc all q",mapname); - system(strbuf); - - if (!MD_Init()) - { - printf("Couldn't initialize sound: %s.\n", myerr); - delay(500); - soundokay=0; - } - if (strlen(musname)) PlayMusic(musname); - - if (!(f=fopen("error.txt","r"))) - { - Message("All VC scripts sucessfully compiled.",300); - return; - } - - fgets(s,99,f); - fclose(f); - p=s; - while (*p) - { - if (*p==13 || *p==10) *p=0; - p++; - } - VCNotify(s); -} - -void CompileMAP() -{ - FILE *f; - char *p; - - MD_PlayStop(); - MD_Exit(); - - sprintf(strbuf,"vcc %s q",mapname); - system(strbuf); - - if (!MD_Init()) - { - printf("Couldn't initialize sound: %s.\n", myerr); - delay(500); - soundokay=0; - } - if (strlen(musname)) PlayMusic(musname); - - if (!(f=fopen("error.txt","r"))) return; - - fgets(s,99,f); - fclose(f); - p=s; - while (*p) - { - if (*p==13 || *p==10) *p=0; - p++; - } - VCNotify(s); -} - -void tickhandler(void) -{ - MP_HandleTick(); - MD_SetBPM(mp_bpm); -} - -void RenderHighlight() -{ int zx, zy; - int xw, yw; - - if (mh) - { - xw=xwin&15; - yw=ywin&15; - zx=((mx+xw)&~15)-xw; - zy=((my+yw)&~15)-yw; - - DrawHighlight(zx-1, zy-1); - } -} - -int EntityThere(int xw, int yw) -{ int i; - - for (i=0; i - mb=0; - return; - } - EntityEditor(a-1); -} - -void DeleteEntity(int xw, int yw) -{ int i,a; - char t[60]; - - a=EntityThere(xw,yw)-1; - sprintf(t,"Delete entity %d?",a); - if (!Confirm(t)) return; - for (i=a; iname, 13); fc++; - while (!_dos_findnext(f)) - { - memcpy(blah+(fc*13), f->name, 13); fc++; - } - } - vfree(f); - last_pressed=0; - a=fc<22?117:2574/fc; -// errn("%d",fc); - do - { - if (!bmode) - { - RenderMap(); - RenderGUI(); - } - else - { - RenderSelector(); - RenderMessages(); - } - if (ctf && systemtime >= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - bxofs = (mx-mxo); - byofs = (my-myo); - if (!mb) moving=0; - if (bxofs<16) bxofs = 16; - if (byofs<16) byofs = 16; - if (bxofs+bxsize>335) bxofs = 336-bxsize; - if (byofs+bysize>sy+16) byofs = (sy+16)-bysize; - } - - Window(bxofs, byofs, bxofs+bxsize, byofs+bysize, "Browse"); - Button(bxofs+65, byofs+157, "OK"); - Button(bxofs+96, byofs+157, "Cancel"); - FilledBox(bxofs+20, byofs+15, 80, 135, black); - FilledBox(bxofs+100, byofs+15, 10, 135, 2); - HLine(bxofs+20, byofs+15, 90, darkw); - VLine(bxofs+20, byofs+15, 135, darkw); - VLine(bxofs+99, byofs+16, 134, white); - VLine(bxofs+109, byofs+16, 134, white); - HLine(bxofs+21, byofs+149, 89, white); - stdwindow(bxofs+100, byofs+16, bxofs+109, byofs+25); - stdwindow(bxofs+100, byofs+140, bxofs+109, byofs+149); - b=byofs+24+(fc != 22 ? ((117-a)*ofs)/(fc-22) : 0); - - //draws the drag box - stdwindow(bxofs+100, b, bxofs+109, b+a); - - FilledBox(bxofs+21, byofs+((cfs-ofs)*6)+16, 78, 6, darkw); - - // Render actual filename thingies - i=0; - while (1) - { - if (i+ofsbxofs+100&&mxbyofs+25&&myb&&myb+a) - { - if (ofs+45>fc) ofs=fc-22; - else ofs+=22; - cfs=ofs; - } - } - } - if(!dragging) - { - if (mb==1 && mx>bxofs+20 && mxbyofs+15 && mybxofs+100 && mxbyofs+15 && mybxofs+100 && mxbyofs+139 && mybxofs+65 && mxbyofs+157 && mybxofs+96 && mxbyofs+157 && my(bxofs+bxsize-9) && (mx(byofs+1) && (mybxofs && mxbyofs && my<(byofs+9) && !moving) - { - moving=1; - mxo=mx-bxofs; - myo=my-byofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - if (key[SCAN_PGUP]) - { - if (ofs<22) ofs=0; - else ofs-=22; - cfs=ofs; - key[SCAN_PGUP]=0; - continue; - } - if (key[SCAN_PGDN]) - { - if (ofs+45>fc) ofs=fc-22; - else ofs+=22; - if (fc<22) ofs=0; - cfs=ofs; - key[SCAN_PGDN]=0; - continue; - } - if (key[SCAN_UP]) - { - if (cfs) cfs--; - if (ofs>cfs) ofs--; - key[SCAN_UP]=0; - last_pressed=0; - continue; - } - if (key[SCAN_DOWN]) - { - if (cfs21) ofs++; - key[SCAN_DOWN]=0; - last_pressed=0; - continue; - } - if (last_pressed==SCAN_ENTER) - { - memcpy(dest,blah+(cfs*13),13); - key[SCAN_ENTER]=0; - done=1; - ctf=0; - str=0; - last_pressed=0; - break; - } - - if (last_pressed==SCAN_TAB) - { - switch (ctf) - { - case 0: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } - } while (!done); - vfree(blah); -} - -#include "vergepal.h" -#define LOGFILE "maped.log" - -void Log(char *text, ...) -{ - va_list argptr; - char msg[256]; - FILE *logf; - - va_start(argptr, text); - vsprintf(msg, text, argptr); - va_end(argptr); - - logf=fopen(LOGFILE,"aw"); - fprintf(logf,"%s\n",msg); - fflush(logf); - fclose(logf); -} - -int main(int argc, char *argv[]) -{ - - remove(LOGFILE); - md_mixfreq=44100; - md_dmabufsize=5000; - md_mode=DMODE_16BITS|DMODE_STEREO; - md_device=0; - memset(&chrs, 0, sizeof chrs); - - Log("GetConfig"); - GetConfig("maped.cfg"); - Log("LoadTransTbl"); - translucency_table=0; //zero - LoadTransTable(); //zero - - Log("RegisterModLoaders"); - ML_RegisterLoader(&load_mod); - ML_RegisterLoader(&load_s3m); - ML_RegisterLoader(&load_xm); - ML_RegisterLoader(&load_uni); - - Log("RegisterSndDrivers"); - MD_RegisterDriver(&drv_nos); - MD_RegisterDriver(&drv_sb); - MD_RegisterDriver(&drv_gus); - MD_RegisterPlayer(tickhandler); - soundokay=1; - Log("Initialize snd lib"); - if (!MD_Init()) - { - printf("Couldn't initialize sound: %s.\n", myerr); - delay(500); - soundokay=0; - } - - //Log("Initialize CD audio"); - //CD_Init(); - - Log("Initialize timer"); - InitTimer(); - Log("Initialize video"); - InitVideo(vm); - Log("Initialize mouse"); - InitMouse(); - Log("Initialize keyboard IRQ handler"); - InitKeyboard(); - - Log("Initializing map data"); - if (argc==1 && !Exist("untitled.map")) - { - SetPalette(vergepal); - memcpy(pal, vergepal, 768); - memcpy(mapname,"UNTITLED.MAP",13); - memcpy(vspname,"UNTITLED.VSP",13); - memcpy(rstring,"1E",2); - numlayers=1; - - // aen: default newmap dimensions set to 100x100 - layer[0].pmultx=1; layer[0].pmulty=1; - layer[0].pdivx=1; layer[0].pdivy=1; - layer[0].sizex=100; layer[0].sizey=100; - layer[0].trans=0; layer[0].hline=0; - - layers[0]=(unsigned short *) valloc((layer[0].sizex*layer[0].sizey*2)+4,"layer data",0); - //memset(layers[0],0,(layer[0].sizex*layer[0].sizey)*2); - obstruct=(char *) valloc((layer[0].sizex*layer[0].sizey)+4,"obstruct map",0); - zone=(char *) valloc((layer[0].sizex*layer[0].sizey)+4,"zone map", 0); - - // aen: default number of tiles set to 100 - numtiles=100; - vsp=(char *) valloc(256 * numtiles,"vsp data", 0); - wrap=0; el=0; layertoggle[0]=1; - InitTileIDX(); - } - else - { - if (argc==1) memcpy(mapname, "untitled.map",13); - else memcpy(mapname, argv[1], strlen(argv[1])); - LoadMAP(mapname); - InitTileIDX(); - } -Log("Entering main loop"); -thingy: - while (!(key[SCAN_ALT] && key[SCAN_X])) - { - ProcessControls(); - while (tick) - { - tick--; - PollMovement(); - } - RenderMap(); - RenderHighlight(); - RenderGUI(); - ShowPage(); - } - if (modified) - if (!Confirm("Lose unsaved changes?")) - { - key[SCAN_ALT]=0; - key[SCAN_X]=0; - goto thingy; - } - - ShutdownVideo(); - ShutdownKeyboard(); - ShutdownTimer(); - SaveNewCFG(); - remove("$$BACKUP.MAP"); - remove("$$BACKUP.VSP"); - - //if (curtrack != 1) CD_Stop(); - //CD_DeInit(); // wasn't even valid! CD_Deinit() was incorrect - MD_PlayStop(); // Mordred - ML_Free(mf); - - MD_Exit(); - if (translucency_table) - vfree(translucency_table); //zero - return 0; -} diff --git a/16/v2/source/verge/MAPED/MAPED.H b/16/v2/source/verge/MAPED/MAPED.H deleted file mode 100755 index 431bcd27..00000000 --- a/16/v2/source/verge/MAPED/MAPED.H +++ /dev/null @@ -1,180 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef MAPED_INC -#define MAPED_INC - -extern const char *const ME2_VERSION; - -#include - -#define byte unsigned char -#define word unsigned short - -typedef struct -{ - unsigned short start; // strand start - unsigned short finish; // strand end - unsigned short delay; // tile-switch delay - unsigned short mode; // tile-animation mode -} vspanim_r; - -typedef struct -{ - char pmultx,pdivx; // parallax multiplier/divisor for X - char pmulty,pdivy; // parallax multiplier/divisor for Y - unsigned short sizex, sizey; // layer dimensions. - unsigned char trans, hline; // transparency flag | hline (raster fx) -} layer_r; - -typedef struct -{ - char name[40]; // zone name/desc - unsigned short script; // script to call thingy - unsigned short percent; // chance of executing - unsigned short delay; // step-delay - unsigned short aaa; // Accept Adjacent Activation - unsigned short entityscript; // script to call for entities -} zoneinfo; - -typedef struct -{ - int x, y; // xwc, ywx position - word tx, ty; // xtc, ytc position - byte facing; // direction entity is facing - byte moving, movecnt; // direction entity is moving - byte frame; // bottom-line frame to display - byte specframe; // special-frame set thingo - byte chrindex, reset; // CHR index | Reset animation - byte obsmode1, obsmode2; // can be obstructed | Is an obstruction - byte speed, speedct; // entity speed, speedcount :) - byte delayct; // animation frame-delay - char *animofs, *moveofs; // anim script | move script - byte face, actm; // auto-face | activation mode - byte movecode, movescript; // movement type | movement script - byte ctr, mode; // sub-tile move ctr, mode flag (internal) - word step, delay; // step, delay - word stepctr, delayctr; // internal use counters - word data1, data2, data3; // - word data4, data5, data6; // - int actscript; // activation script - int expand1, expand2; // - int expand3, expand4; // - char desc[20]; // Entity description. -} entity_r; - -typedef struct -{ - char t[60]; -} chrlist_r; - -typedef struct { - char t[200]; -} movescript; - -extern layer_r layer[4]; -extern vspanim_r vspanim[100]; -extern zoneinfo zones[256]; -extern unsigned short vadelay[100]; -extern entity_r entity[256]; // Entity records. -extern byte entities; // number of allocated entities. -extern chrlist_r chrlist[100]; -extern byte nmchr; -extern movescript ms[100]; // move scripts arrays -extern byte nms; // number of movement scripts - -extern char *obstruct, *zone, curzone; -extern char numlayers, wrap; -extern unsigned short *layers[6]; -extern char rstring[20]; -extern char mapname[60], vspname[60]; -extern char musname[60]; -extern short xstart, ystart; - -// -- vsp related data -- - -extern unsigned short numtiles; -extern unsigned char *vsp; - -// -- editing related data -- - -extern int xwin, ywin, bmode; -extern char mouse_scroll; -extern short lt, rt; -extern char layertoggle[10], el, modified; - -extern word *copybuf; -extern int copybuf_wide,copybuf_deep; -extern int selx1, sely1, selx2, sely2; -extern int shifted, pasting; - -extern int numzones; // Number of active zones. - -extern int moving_up,moving_down,moving_left,moving_right; - -extern void LoadTransTable(); -extern int Exist(char *fname); -extern void err(char *str, ...); -extern void errf(char *str, char *str1); -extern void errn(char *str, int n); -extern int random(int min, int max); -extern void PlayMusic(char *fname); -extern void StopMusic(); -extern void LoadVSP(char *fname); -extern void SaveVSP(char *fname); -extern void EmitC (char c); -extern void EmitW (short int w); -extern void WriteCompressedLayer1(unsigned char *p, int len); -extern void ReadCompressedLayer1(unsigned char *dest, int len, FILE *f); -extern void WriteCompressedLayer2(unsigned short *p,int len); -extern void ReadCompressedLayer2(unsigned short *dest, int len, FILE *f); -extern void CountUsedZones(); -extern void CountMoveScripts(); -extern void CountCHRs(); -extern void SaveMAP(char *fname); -extern void LoadOldMAP(FILE *f); -extern void LoadMAP(char *fname); -extern void InitTileIDX(); -extern void CheckTimerStuff(); -extern void SaveNewCFG(); -extern void ShellToDOS(); -extern void ShellVERGE(); -extern void ShellMAP(); -extern void ShellEditMAP(); -extern void ShellEditSystem(); -extern void CompileAll(); -extern void CompileMAP(); -extern void tickhandler(void); -extern void RenderHighlight(); -extern int EntityThere(int xw, int yw); -extern void AllocateEntity(int xw, int yw); -extern void ProcessEntity(int xw, int yw); -extern void DeleteEntity(int xw, int yw); -extern void Browse(char n, char *m1, char *m2, char *m3, char *m4, char *dest); - -// Includes for a_memory.c - -void *valloc(int amount, char *desc, int owner); -void *qvalloc(int amount); -int vfree(void *pointer); -void qvfree(void *pointer); -void FreeByOwner(int owner); -void MemReport(void); -void CheckCorruption(void); - -#define free ERROR_YEAH_REPLACE_THIS_WITH_VFREE - -#endif // MAPED_INC diff --git a/16/v2/source/verge/MAPED/MIKMOD.C b/16/v2/source/verge/MAPED/MIKMOD.C deleted file mode 100755 index 2ab62d2a..00000000 --- a/16/v2/source/verge/MAPED/MIKMOD.C +++ /dev/null @@ -1,311 +0,0 @@ -/* - -Name: -MIKMOD.C - -Description: -Modplaying example of mikmod. - -MSDOS: BC(y) Watcom(y) DJGPP(y) -Win95: BC(y*) -Os2: y -Linux: n - -* console mode only -(y) - yes -(n) - no (not possible or not useful) -(?) - may be possible, but not tested - -*/ -#ifdef __WIN32__ -#include -#endif - -#include -#include -#include -#include - -#ifndef __OS2__ -#include -#endif - -#include "wildfile.h" -#include "mikmod.h" - -char helptext[]= - -"Available switches (CaSe SeNsItIvE!):\n" -"\n" -" /d x use device-driver #x for output (0 is autodetect). Default=0\n" -" /ld List all available device-drivers\n" -" /ll List all available loaders\n" -" /x disables protracker extended speed\n" -" /p disables panning effects (9fingers.mod)\n" -" /v xx Sets volume from 0 (silence) to 100. Default=100\n" -" /f xxxx Sets mixing frequency. Default=44100\n" -" /m Force mono output (so sb-pro can mix at 44100)\n" -" /8 Force 8 bit output\n" -" /i Use interpolated mixing\n" -" /r Restart a module when it's done playing"; - - -/* - declarations for boring old sys-v style getopt *yawn*: -*/ -int getopt(int argc, char *argv[], char *optionS); -extern char *optarg; -extern int optind; -extern int opterr; - - -void tickhandler(void) -{ - MP_HandleTick(); /* play 1 tick of the module */ - MD_SetBPM(mp_bpm); -} - - -int main(int argc,char *argv[]) -{ - UNIMOD *mf; - int cmderr=0; /* error in commandline flag */ - int morehelp=0; /* set if user wants more help */ - int quit; - int t; - static int nargc; - static char **nargv; - - puts(mikbanner); - - /* Expand wildcards on commandline */ - - nargc=argc; nargv=argv; -#ifndef __DJGPP__ - MyGlob(&nargc,&nargv,0); -#else - setvbuf(stdout, NULL, _IONBF, 0); - __djgpp_set_ctrl_c(0); -#endif - - /* - Initialize soundcard parameters.. you _have_ to do this - before calling MD_Init(), and it's illegal to change them - after you've called MD_Init() - */ - - md_mixfreq =44100; /* standard mixing freq */ - md_dmabufsize =20000; /* standard dma buf size */ - md_mode =DMODE_16BITS|DMODE_STEREO; /* standard mixing mode */ - md_device =0; /* standard device: autodetect */ - - /* - Register the loaders we want to use.. - */ - - ML_RegisterLoader(&load_m15); /* if you use m15load, register it as first! */ - ML_RegisterLoader(&load_mod); - ML_RegisterLoader(&load_mtm); - ML_RegisterLoader(&load_s3m); - ML_RegisterLoader(&load_stm); - ML_RegisterLoader(&load_ult); - ML_RegisterLoader(&load_uni); - ML_RegisterLoader(&load_xm); - - /* - Register the drivers we want to use: - */ - - MD_RegisterDriver(&drv_nos); -#ifdef __OS2__ - MD_RegisterDriver(&drv_os2); -#elif defined(__WIN32__) - MD_RegisterDriver(&drv_w95); -#else - MD_RegisterDriver(&drv_ss); - MD_RegisterDriver(&drv_sb); - MD_RegisterDriver(&drv_gus); -#endif - - MD_RegisterPlayer(tickhandler); - - /* Parse option switches using standard getopt function: */ - - opterr=0; - - while( !cmderr && - (t=getopt(nargc,nargv,"ohxpm8irv:f:l:d:")) != EOF ){ - - switch(t){ - - case 'd': - md_device=atoi(optarg); - break; - - case 'l': - if(optarg[0]=='d') MD_InfoDriver(); - else if(optarg[0]=='l') ML_InfoLoader(); - else{ - cmderr=1; - break; - } - exit(0); - - case 'r': - mp_loop=1; - break; - - case 'm': - md_mode&=~DMODE_STEREO; - break; - - case '8': - md_mode&=~DMODE_16BITS; - break; - - case 'i': - md_mode|=DMODE_INTERP; - break; - - case 'x': - mp_extspd=0; - break; - - case 'p': - mp_panning=0; - break; - - case 'v': - if((mp_volume=atoi(optarg))>100) mp_volume=100; - break; - - case 'f': - md_mixfreq=atol(optarg); - break; - - case 'h': - morehelp=1; - cmderr=1; - break; - - case '?': - puts("\07Invalid switch or option needs an argument\n"); - cmderr=1; - break; - } - } - - if(cmderr || optind>=nargc){ - - /* - there was an error in the commandline, or there were no true - arguments, so display a usage message - */ - - puts("Usage: MIKMOD [switches] ... \n"); - - if(morehelp) - puts(helptext); - else - puts("Type MIKMOD /h for more help."); - - exit(-1); - } - - /* initialize soundcard */ - - if(!MD_Init()){ - printf("Driver error: %s.\n",myerr); - return 0; - } - - printf("Using %s for %d bit %s %s sound at %u Hz\n\n", - md_driver->Name, - (md_mode&DMODE_16BITS) ? 16:8, - (md_mode&DMODE_INTERP) ? "interpolated":"normal", - (md_mode&DMODE_STEREO) ? "stereo":"mono", - md_mixfreq); - -#ifdef __OS2__ - DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, 5L, 0UL ); -#endif - - for(quit=0; !quit && optind exit with errormsg. */ - - if(mf==NULL){ - printf("MikMod Error: %s\n",myerr); - break; - } - - /* initialize modplayer to play this module */ - - MP_Init(mf); - - printf( "Songname: %s\n" - "Modtype : %s\n" - "Periods : %s,%s\n", - mf->songname, - mf->modtype, - (mf->flags&UF_XMPERIODS) ? "XM type" : "mod type", - (mf->flags&UF_LINEAR) ? "Linear" : "Log"); - - /* - set the number of voices to use.. you - could add extra channels here (e.g. md_numchn=mf->numchn+4; ) - to use for your own soundeffects: - */ - - md_numchn=mf->numchn; - - /* start playing the module: */ - - MD_PlayStart(); - - while(!MP_Ready()){ - - char c; - - c=kbhit() ? getch() : 0; - - if(c=='+') - MP_NextPosition(); - else if(c=='-') - MP_PrevPosition(); - else if(c==0x1b){ - quit=1; - break; - } - else if(c==' ') break; - - MD_Update(); - - /* wait a bit */ - -#if defined(__OS2__) - DosSleep(40); /* hmmmm */ -#elif defined(__WIN32__) - Sleep(10); -#elif defined(__DJGPP__) - /* no wait for djgpp ? */ -#else - delay(10); -#endif - printf("\rsngpos:%d patpos:%d sngspd %d bpm %d ",mp_sngpos,mp_patpos,mp_sngspd,mp_bpm); - } - - MD_PlayStop(); /* stop playing */ - ML_Free(mf); /* and free the module */ - puts("\n"); - } - - MD_Exit(); - return 0; -} diff --git a/16/v2/source/verge/MAPED/MIKMOD.H b/16/v2/source/verge/MAPED/MIKMOD.H deleted file mode 100755 index 0111ccb3..00000000 --- a/16/v2/source/verge/MAPED/MIKMOD.H +++ /dev/null @@ -1,580 +0,0 @@ -#ifndef MIKMOD_H -#define MIKMOD_H - -#include -#include "mtypes.h" /* include atomic mikmod types */ - - -#define mikbanner \ -"=======================================================================\n" \ -"MIKMOD v2.10 - Portable version - Programmed by MikMak of HaRDCoDE '95\n" \ -"=======================================================================\n" \ -"This program is SHAREWARE - Read MIKMOD.TXT for more info\n" \ -"E-Mail : mikmak@stack.urc.tue.nl\n" - - -/* - error variables: - =============== -*/ - -extern char *ERROR_ALLOC_STRUCT; -extern char *ERROR_LOADING_PATTERN; -extern char *ERROR_LOADING_TRACK; -extern char *ERROR_LOADING_HEADER; -extern char *ERROR_NOT_A_MODULE; -extern char *ERROR_LOADING_SAMPLEINFO; -extern char *ERROR_OUT_OF_HANDLES; -extern char *ERROR_SAMPLE_TOO_BIG; -extern char *myerr; - - - -#define _mm_rewind(x) _mm_fseek(x,0,SEEK_SET) -int _mm_fseek(FILE *stream,long offset,int whence); -void _mm_setiobase(long iobase); -long _mm_ftell(FILE *stream); - - -extern SBYTE _mm_read_SBYTE (FILE *fp); -extern UBYTE _mm_read_UBYTE (FILE *fp); - -extern SWORD _mm_read_M_SWORD (FILE *fp); -extern SWORD _mm_read_I_SWORD (FILE *fp); - -extern UWORD _mm_read_M_UWORD(FILE *fp); -extern UWORD _mm_read_I_UWORD(FILE *fp); - -extern SLONG _mm_read_M_SLONG (FILE *fp); -extern SLONG _mm_read_I_SLONG (FILE *fp); - -extern ULONG _mm_read_M_ULONG(FILE *fp); -extern ULONG _mm_read_I_ULONG(FILE *fp); - -extern int _mm_read_str(char *str, int size, FILE *fp); - -extern int _mm_read_SBYTES (SBYTE *buffer, int number, FILE *fp); -extern int _mm_read_UBYTES (UBYTE *buffer, int number, FILE *fp); - -extern int _mm_read_M_SWORDS (SWORD *buffer, int number, FILE *fp); -extern int _mm_read_I_SWORDS (SWORD *buffer, int number, FILE *fp); - -extern int _mm_read_M_UWORDS (UWORD *buffer, int number, FILE *fp); -extern int _mm_read_I_UWORDS (UWORD *buffer, int number, FILE *fp); - -extern int _mm_read_M_SLONGS (SLONG *buffer, int number, FILE *fp); -extern int _mm_read_I_SLONGS (SLONG *buffer, int number, FILE *fp); - -extern int _mm_read_M_ULONGS (ULONG *buffer, int number, FILE *fp); -extern int _mm_read_I_ULONGS (ULONG *buffer, int number, FILE *fp); - - -extern void _mm_write_SBYTE (SBYTE data,FILE *fp); -extern void _mm_write_UBYTE (UBYTE data,FILE *fp); - -extern void _mm_write_M_SWORD (SWORD data,FILE *fp); -extern void _mm_write_I_SWORD (SWORD data,FILE *fp); - -extern void _mm_write_M_UWORD (UWORD data,FILE *fp); -extern void _mm_write_I_UWORD (UWORD data,FILE *fp); - -extern void _mm_write_M_SLONG (SLONG data,FILE *fp); -extern void _mm_write_I_SLONG (SLONG data,FILE *fp); - -extern void _mm_write_M_ULONG (ULONG data,FILE *fp); -extern void _mm_write_I_ULONG (ULONG data,FILE *fp); - -extern void _mm_write_SBYTES (SBYTE *data, int number,FILE *fp); -extern void _mm_write_UBYTES (UBYTE *data, int number,FILE *fp); - -extern void _mm_write_M_SWORDS (SWORD *data, int number,FILE *fp); -extern void _mm_write_I_SWORDS (SWORD *data, int number,FILE *fp); - -extern void _mm_write_M_UWORDS (UWORD *data, int number,FILE *fp); -extern void _mm_write_I_UWORDS (UWORD *data, int number,FILE *fp); - -extern void _mm_write_M_SLONGS (SLONG *data, int number,FILE *fp); -extern void _mm_write_I_SLONGS (SLONG *data, int number,FILE *fp); - -extern void _mm_write_M_ULONGS (ULONG *data, int number,FILE *fp); -extern void _mm_write_I_ULONGS (ULONG *data, int number,FILE *fp); - - -/************************************************************************** -****** Unitrack stuff: **************************************************** -**************************************************************************/ - -/* - prototypes: -*/ - -void UniSetRow(UBYTE *t); -UBYTE UniGetByte(void); -UBYTE *UniFindRow(UBYTE *t,UWORD row); -void UniReset(void); -void UniWrite(UBYTE data); -void UniNewline(void); -void UniInstrument(UBYTE ins); -void UniNote(UBYTE note); -void UniPTEffect(UBYTE eff,UBYTE dat); -UBYTE *UniDup(void); -void UniSkipOpcode(UBYTE op); -BOOL UniInit(void); -void UniCleanup(void); -UWORD TrkLen(UBYTE *t); -BOOL MyCmp(UBYTE *a,UBYTE *b,UWORD l); - -/* - all known effects: -*/ - -enum { - UNI_NOTE=1, - UNI_INSTRUMENT, - UNI_PTEFFECT0, - UNI_PTEFFECT1, - UNI_PTEFFECT2, - UNI_PTEFFECT3, - UNI_PTEFFECT4, - UNI_PTEFFECT5, - UNI_PTEFFECT6, - UNI_PTEFFECT7, - UNI_PTEFFECT8, - UNI_PTEFFECT9, - UNI_PTEFFECTA, - UNI_PTEFFECTB, - UNI_PTEFFECTC, - UNI_PTEFFECTD, - UNI_PTEFFECTE, - UNI_PTEFFECTF, - UNI_S3MEFFECTA, - UNI_S3MEFFECTD, - UNI_S3MEFFECTE, - UNI_S3MEFFECTF, - UNI_S3MEFFECTI, - UNI_S3MEFFECTQ, - UNI_S3MEFFECTT, - UNI_XMEFFECTA, - UNI_XMEFFECTG, - UNI_XMEFFECTH, - UNI_XMEFFECTP -}; - - -/************************************************************************** -****** mikmod types: ****************************************************** -**************************************************************************/ - - -/* - Sample format flags: -*/ - -#define SF_16BITS 1 -#define SF_SIGNED 2 -#define SF_DELTA 4 -#define SF_BIG_ENDIAN 8 -#define SF_LOOP 16 -#define SF_BIDI 32 -#define SF_OWNPAN 64 -#define SF_REVERSE 128 - - -/* - Envelope flags: -*/ - -#define EF_ON 1 -#define EF_SUSTAIN 2 -#define EF_LOOP 4 - - -/* - Unimod flags -*/ - -#define UF_XMPERIODS 1 /* if set use XM periods/finetuning */ -#define UF_LINEAR 2 /* if set use LINEAR periods */ - - -typedef struct ENVPT{ - SWORD pos; - SWORD val; -} ENVPT; - - -typedef struct SAMPLE{ - UWORD c2spd; /* finetune frequency */ - SBYTE transpose; /* transpose value */ - UBYTE volume; /* volume 0-64 */ - UBYTE panning; /* panning */ - ULONG length; /* length of sample (in samples!) */ - ULONG loopstart; /* repeat position (relative to start, in samples) */ - ULONG loopend; /* repeat end */ - UWORD flags; /* sample format */ - ULONG seekpos; /* seek position in file */ - char *samplename; /* name of the sample */ - SWORD handle; /* sample handle */ -} SAMPLE; - - -typedef struct INSTRUMENT{ - UBYTE numsmp; - UBYTE samplenumber[96]; - - UBYTE volflg; /* bit 0: on 1: sustain 2: loop */ - UBYTE volpts; - UBYTE volsus; - UBYTE volbeg; - UBYTE volend; - ENVPT volenv[12]; - - UBYTE panflg; /* bit 0: on 1: sustain 2: loop */ - UBYTE panpts; - UBYTE pansus; - UBYTE panbeg; - UBYTE panend; - ENVPT panenv[12]; - - UBYTE vibtype; - UBYTE vibsweep; - UBYTE vibdepth; - UBYTE vibrate; - - UWORD volfade; - char *insname; - SAMPLE *samples; -} INSTRUMENT; - - -/* - MikMod UNImod types: - ==================== -*/ - -typedef struct UNIMOD{ - UBYTE numchn; /* number of channels */ - UWORD numpos; /* number of positions in this song */ - UWORD reppos; /* restart position */ - UWORD numpat; /* number of patterns in this song */ - UWORD numtrk; /* number of tracks */ - UWORD numins; /* number of samples */ - UBYTE initspeed; /* */ - UBYTE inittempo; /* */ - UBYTE positions[256]; /* all positions */ - UBYTE panning[32]; /* 32 panning positions */ - UBYTE flags; /* */ - char *songname; /* name of the song */ - char *modtype; /* string type of module */ - char *comment; /* module comments */ - INSTRUMENT *instruments; /* all samples */ - UWORD *patterns; /* array of PATTERN */ - UWORD *pattrows; /* array of number of rows for each pattern */ - UBYTE **tracks; /* array of pointers to tracks */ -} UNIMOD; - - -/************************************************************************** -****** Loader stuff: ****************************************************** -**************************************************************************/ - -/* - loader structure: -*/ - -typedef struct LOADER{ - struct LOADER *next; - char *type; - char *version; - BOOL (*Init)(void); - BOOL (*Test)(void); - BOOL (*Load)(void); - void (*Cleanup)(void); -} LOADER; - - -/* - public loader variables: -*/ - -extern UNIMOD of; -extern FILE *modfp; -extern UWORD finetune[16]; - - -/* - main loader prototypes: -*/ - -void ML_InfoLoader(void); -void ML_RegisterLoader(LOADER *ldr); -UNIMOD *ML_LoadFP(FILE *fp); -UNIMOD *ML_LoadFN(char *filename); -void ML_Free(UNIMOD *mf); - - -/* - other loader prototypes: (used by the loader modules) -*/ - -BOOL InitTracks(void); -void AddTrack(UBYTE *tr); -BOOL ReadComment(UWORD len); -BOOL AllocPatterns(void); -BOOL AllocTracks(void); -BOOL AllocInstruments(void); -BOOL AllocSamples(INSTRUMENT *i); -char *DupStr(char *s,UWORD len); -void *MyMalloc(size_t size); -void *MyCalloc(size_t nitems,size_t size); - - -/* - Declare external loaders: -*/ -extern LOADER load_uni; -extern LOADER load_mod; -extern LOADER load_m15; -extern LOADER load_mtm; -extern LOADER load_s3m; -extern LOADER load_stm; -extern LOADER load_ult; -extern LOADER load_xm; - - -/************************************************************************** -****** Wavload stuff: ***************************************************** -**************************************************************************/ - -SAMPLE *MW_LoadWavFP(FILE *fp); -SAMPLE *MW_LoadWavFN(char *filename); -void MW_FreeWav(SAMPLE *si); - - -/************************************************************************** -****** Driver stuff: ****************************************************** -**************************************************************************/ - -/* - max. number of handles a driver has to provide. (not strict) -*/ - -#define MAXSAMPLEHANDLES 128 - - -/* - possible mixing mode bits: -*/ - -#define DMODE_STEREO 1 -#define DMODE_16BITS 2 -#define DMODE_INTERP 4 - - -/* - driver structure: -*/ - -typedef struct DRIVER{ - struct DRIVER *next; - char *Name; - char *Version; - BOOL (*IsPresent) (void); - SWORD (*SampleLoad) (FILE *fp,ULONG size,ULONG reppos,ULONG repend,UWORD flags); - void (*SampleUnLoad) (SWORD handle); - BOOL (*Init) (void); - void (*Exit) (void); - void (*PlayStart) (void); - void (*PlayStop) (void); - void (*Update) (void); - void (*VoiceSetVolume) (UBYTE voice,UBYTE vol); - void (*VoiceSetFrequency) (UBYTE voice,ULONG frq); - void (*VoiceSetPanning) (UBYTE voice,UBYTE pan); - void (*VoicePlay) (UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); -} DRIVER; - - -/* - public driver variables: -*/ - -extern DRIVER *md_driver; -extern UWORD md_device; -extern UWORD md_mixfreq; -extern UWORD md_dmabufsize; -extern UWORD md_mode; -extern UBYTE md_numchn; -extern UBYTE md_bpm; -extern void (*md_player)(void); - -/* - main driver prototypes: -*/ - -void MD_InfoDriver(void); -void MD_RegisterDriver(DRIVER *drv); -void MD_RegisterPlayer(void (*plr)(void)); -SWORD MD_SampleLoad(FILE *fp,ULONG size,ULONG reppos,ULONG repend,UWORD flags); -void MD_SampleUnLoad(SWORD handle); -BOOL MD_Init(void); -void MD_Exit(void); -void MD_PlayStart(void); -void MD_PlayStop(void); -void MD_SetBPM(UBYTE bpm); -void MD_Update(void); -void MD_VoiceSetVolume(UBYTE voice,UBYTE ivol); -void MD_VoiceSetFrequency(UBYTE voice,ULONG frq); -void MD_VoiceSetPanning(UBYTE voice,ULONG pan); -void MD_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); -void SL_Init(FILE *fp,UWORD infmt,UWORD outfmt); -void SL_Load(void *buffer,ULONG length); - -/* - Declare external drivers: -*/ - -extern DRIVER drv_gus; /* gravis ultrasound driver */ -extern DRIVER drv_sb; /* soundblaster DSP driver */ -extern DRIVER drv_ss; /* ensoniq soundscape driver */ -extern DRIVER drv_nos; /* nosound driver */ -extern DRIVER drv_raw; /* file output driver */ -extern DRIVER drv_w95; /* win95 driver */ -extern DRIVER drv_awe; /* experimental SB-AWE driver */ -extern DRIVER drv_vox; /* linux voxware driver */ -extern DRIVER drv_af; /* Dec Alpha AudioFile driver */ -extern DRIVER drv_sun; /* Sun driver */ -extern DRIVER drv_os2; /* Os2 driver */ -extern DRIVER drv_tim; /* timing driver */ - -/************************************************************************** -****** Player stuff: ****************************************************** -**************************************************************************/ - - -typedef struct ENVPR{ - UBYTE flg; /* envelope flag */ - UBYTE pts; /* number of envelope points */ - UBYTE sus; /* envelope sustain index */ - UBYTE beg; /* envelope loop begin */ - UBYTE end; /* envelope loop end */ - SWORD p; /* current envelope counter */ - UWORD a; /* envelope index a */ - UWORD b; /* envelope index b */ - ENVPT *env; /* envelope points */ -} ENVPR; - - -typedef struct AUDTMP{ - INSTRUMENT *i; - SAMPLE *s; - - UWORD fadevol; /* fading volume */ - - ENVPR venv; - ENVPR penv; - - UBYTE keyon; /* if true=key is pressed. */ - UBYTE kick; /* if true=sample has to be restarted */ - UBYTE sample; /* which sample number (0-31) */ - SWORD handle; /* which sample-handle */ - - ULONG start; /* The start byte index in the sample */ - - UBYTE panning; /* panning position */ - UBYTE pansspd; /* panslide speed */ - - SBYTE volume; /* amiga volume (0 t/m 64) to play the sample at */ - UWORD period; /* period to play the sample at */ - - /* You should not have to use the values - below in the player routine */ - - SBYTE transpose; - - UBYTE note; /* */ - - SWORD ownper; - SWORD ownvol; - - UBYTE *row; /* row currently playing on this channel */ - - SBYTE retrig; /* retrig value (0 means don't retrig) */ - UWORD c2spd; /* what finetune to use */ - - SBYTE tmpvolume; /* tmp volume */ - - UWORD tmpperiod; /* tmp period */ - UWORD wantedperiod; /* period to slide to (with effect 3 or 5) */ - - UWORD slidespeed; /* */ - UWORD portspeed; /* noteslide speed (toneportamento) */ - - UBYTE s3mtremor; /* s3m tremor (effect I) counter */ - UBYTE s3mtronof; /* s3m tremor ontime/offtime */ - - UBYTE s3mvolslide; /* last used volslide */ - - UBYTE s3mrtgspeed; /* last used retrig speed */ - UBYTE s3mrtgslide; /* last used retrig slide */ - - UBYTE glissando; /* glissando (0 means off) */ - UBYTE wavecontrol; /* */ - - SBYTE vibpos; /* current vibrato position */ - UBYTE vibspd; /* "" speed */ - UBYTE vibdepth; /* "" depth */ - - SBYTE trmpos; /* current tremolo position */ - UBYTE trmspd; /* "" speed */ - UBYTE trmdepth; /* "" depth */ - - UWORD soffset; /* last used sample-offset (effect 9) */ -} AUDTMP; - - -extern AUDTMP mp_audio[32]; /* max eight channels */ -extern UBYTE mp_bpm; /* beats-per-minute speed */ -extern UWORD mp_patpos; /* current row number (0-63) */ -extern SWORD mp_sngpos; /* current song position */ -extern UWORD mp_sngspd; /* current songspeed */ - -extern BOOL mp_loop; -extern BOOL mp_panning; -extern BOOL mp_extspd; -extern UBYTE mp_volume; - -/* - player prototypes: -*/ - -int MP_Ready(void); -void MP_NextPosition(void); -void MP_PrevPosition(void); -void MP_SetPosition(UWORD pos); -void MP_HandleTick(void); -void MP_Init(UNIMOD *m); - - -/************************************************************************** -****** Virtual channel stuff: ********************************************* -**************************************************************************/ - -BOOL VC_Init(void); -void VC_Exit(void); - -void VC_PlayStart(void); -void VC_PlayStop(void); - -SWORD VC_SampleLoad(FILE *fp,ULONG size,ULONG reppos,ULONG repend,UWORD flags); -void VC_SampleUnload(SWORD handle); - -void VC_WriteSamples(SBYTE *buf,UWORD todo); -UWORD VC_WriteBytes(SBYTE *buf,UWORD todo); -void VC_SilenceBytes(SBYTE *buf,UWORD todo); - -void VC_VoiceSetVolume(UBYTE voice,UBYTE vol); -void VC_VoiceSetFrequency(UBYTE voice,ULONG frq); -void VC_VoiceSetPanning(UBYTE voice,UBYTE pan); -void VC_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); - -#endif diff --git a/16/v2/source/verge/MAPED/MIKMOD.LIB b/16/v2/source/verge/MAPED/MIKMOD.LIB deleted file mode 100755 index 0f55de95..00000000 Binary files a/16/v2/source/verge/MAPED/MIKMOD.LIB and /dev/null differ diff --git a/16/v2/source/verge/MAPED/MINIMAP.C b/16/v2/source/verge/MAPED/MINIMAP.C deleted file mode 100755 index 9da05b68..00000000 --- a/16/v2/source/verge/MAPED/MINIMAP.C +++ /dev/null @@ -1,151 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include - -#include "config.h" -#include "keyboard.h" -#include "maped.h" -#include "mouse.h" -#include "vdriver.h" - -// ============================ Data ============================ - -unsigned char mvsp[2048]; // mini-VSP dominant color -int xoff=0, yoff=0; // x-offset, y-offset - -// ============================ Code ============================ -/* -FindDominantColor(int i) -{ unsigned char *src; - int j,tally=0; - - // This is a cheap-ass method. I have a more proper method in mind, but - // I'm going to do this for now b/c I'm lazy. Actually, the real reason is - // speed. - - src=vsp+(i*256); - - for (j=0; j<256; j++) - { - tally+=*src; - src++; - } - tally=tally/256; - mvsp[i]=(unsigned char) tally; -} -*/ - -void FindDominantColor(int i) -{ unsigned char *src, tally[256], tab; - int j; - - src=vsp+(i*256); - memset(&tally, 0, 256); - - for (j=0; j<256; j++) - { - tally[*src]++; - src++; - } - tab=0; - for (j=0; j<256; j++) - { - if (tally[j] > tab) tab=j; - } - mvsp[i]=(unsigned char) tab; -} - -void GenerateMiniVSP() -{ int i; - - for (i=0; i 0) xoff-=16; - key[SCAN_LEFT]=0; - } - if (key[SCAN_UP] && yoff) - { - if (yoff > 0) yoff-=16; - key[SCAN_UP]=0; - } - if (key[SCAN_DOWN]) - { - if (yoff < layer[0].sizey) - yoff+=16; - key[SCAN_DOWN]=0; - } - if (key[SCAN_RIGHT]) - { - if (xoff < layer[0].sizex) - xoff+=16; - key[SCAN_RIGHT]=0; - } - if (mb) - { - xwin=(xoff+mx-16)*16; - ywin=(yoff+my-16)*16; - if (xwin>=(layer[0].sizex*16)-320) xwin=(layer[0].sizex*16)-320; - if (ywin>=(layer[0].sizey*16)-tsy-15) ywin=(layer[0].sizey*16)-tsy-15; - WaitRelease(); - break; - } - } - key[SCAN_ESC]=0; - vfree(ptr); -} diff --git a/16/v2/source/verge/MAPED/MINIMAP.H b/16/v2/source/verge/MAPED/MINIMAP.H deleted file mode 100755 index 254b13bd..00000000 --- a/16/v2/source/verge/MAPED/MINIMAP.H +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef MINIMAP_INC -#define MINIMAP_INC - -extern void FindDominantColor(int i); -extern void GenerateMiniVSP(); -extern void MiniMAP(); - -#endif // MINIMAP_INC diff --git a/16/v2/source/verge/MAPED/MODE13H.C b/16/v2/source/verge/MAPED/MODE13H.C deleted file mode 100755 index 38336e14..00000000 --- a/16/v2/source/verge/MAPED/MODE13H.C +++ /dev/null @@ -1,350 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include - -#include "mode13h.h" -#include "vdriver.h" - -// ================================= Data ==================================== - -char *screenr; // realscr -char startline=16; // virtual scroll around 240 vert. pixels -extern unsigned char* translucency_table; //zero - -extern void *valloc(int amount, char*, int); -extern int vfree(void *); -extern void CheckTimerStuff(); // in maped.c - -// ================================= Code ==================================== - - -void SetMode(int mode) -{ - REGISTERS r; - SET_AX(r, mode); - INTERRUPT(0x10, r); -} - -int Mode13hShutdown() -{ - SetMode(0x3); - vfree(screen); - screen=0; - return 0; -} - -int Mode13hShowPage() -{ int rows; - char *s,*d; - - CheckTimerStuff(); - - s=screen+(16*tsx)+16; - d=screenr; - rows=sy; - - for (; rows; rows--) - { - memcpy(d,s,sx); - s+=tsx; - d+=sx; - } - - return 0; -} - -int Mode13hCopySprite(int x, int y, int width, int height, char *src) -{ char *d; - - d=screen+(y*tsx)+x; - for (; height; height--) - { - memcpy(d,src,width); - src+=width; - d+=tsx; - } - - return 0; -} - -int Mode13hCCopySprite(int x,int y,int width,int height,char *src) -{ int cx1,cy1,cx2,cy2; - char *s,*d; - int xl,yl,xs,ys; - - xl=width; - yl=height; - xs=ys=0; - - cx1=0; - cy1=0; - cx2=tsx-1; - cy2=tsy-1; - - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (xcx2 || y>cy2 || x cy2) length=cy2-y+1; - if (ycx2 || y>cy2 || x+width cx2) width=cx2-x+1; - if (x336 || y<0 || y>256) return 0; - d=screen+(y*tsx)+x; - for (y=0; y<8; y++) - { - d[0]=c; d[2]=c; d[4]=c; d[6]=c; - d[8]=c; d[10]=c; d[12]=c; d[14]=c; - - d+=(tsx+1); - - d[0]=c; d[2]=c; d[4]=c; d[6]=c; - d[8]=c; d[10]=c; d[12]=c; d[14]=c; - - d+=(tsx-1); - } - - return 0; -} - -int Mode13hClearScreen() -{ - memset(screen,0,76032); - return 0; -} - -int Mode13hCopySpriteLucentClip(int x, int y, int width, int height, unsigned char *src) -{ - int cx1,cy1,cx2,cy2; - unsigned char *s,*d,c; - int xl,yl,xs,ys; - - cx1=0; - cy1=0; - cx2=tsx-1; - cy2=tsy-1; - - xl=width; - yl=height; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x -#include -#include - -#include "mode13h.h" // SetMode() -#include "modex.h" -#include "vdriver.h" - -// ================================= Data ==================================== - -#define SEQU_ADDR 0x3c4 -#define CRTC_ADDR 0x3d4 -#define MISC_OUTPUT 0x3c2 - -char *screen1, *screen2; // page banks; -char *screenx, curscr; // ptr to active page | page flip ctr -char *screenbase; // ptr to A000:0000 - -extern unsigned char* translucency_table; //zero - -extern void CheckTimerStuff(); -extern void *valloc(int amount,char*,int); -extern int vfree(void *); - -// ================================= Code ==================================== - -static void plane(char p) -{ - int hi=1<>2); - - while (d>2); - } - - s+=tsx; - d+=(sx>>2); - } - return 0; -} - -int ModeXCopySprite(int x, int y, int width, int height, char *src) -{ char *d; - - d=screen+(y*tsx)+x; - for (; height; height--) - { - memcpy(d,src,width); - src+=width; - d+=tsx; - } - - return 0; -} - -int ModeXCCopySprite(int x,int y,int width,int height,char *src) -{ int cx1,cy1,cx2,cy2; - char *s,*d; - int xl,yl,xs,ys; - - xl=width; - yl=height; - xs=ys=0; - - cx1=0; - cy1=0; - cx2=tsx-1; - cy2=tsy-1; - - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (xcx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - - if (xcx2 || y>cy2 || x cy2) length=cy2-y+1; - if (ycx2 || y>cy2 || x+width cx2) width=cx2-x+1; - if (x336 || y<0 || y>256) return 0; - d=screen+(y*tsx)+x; - for (y=0; y<8; y++) - { - d[0]=c; d[2]=c; d[4]=c; d[6]=c; - d[8]=c; d[10]=c; d[12]=c; d[14]=c; - - d+=(tsx+1); - - d[0]=c; d[2]=c; d[4]=c; d[6]=c; - d[8]=c; d[10]=c; d[12]=c; d[14]=c; - - d+=(tsx-1); - } - - return 0; -} - -int ModeXClearScreen() -{ - memset(screen,0,90117); - return 0; -} - -int ModeXCopySpriteLucentClip(int x, int y, int width, int height, unsigned char *src) -{ - int cx1,cy1,cx2,cy2; - unsigned char *s,*d,c; - int xl,yl,xs,ys; - - cx1=0; - cy1=0; - cx2=tsx-1; - cy2=tsy-1; - - xl=width; - yl=height; - xs=ys=0; - if (x>cx2 || y>cy2 || x+xl cx2) xl=cx2-x+1; - if (y+yl > cy2) yl=cy2-y+1; - if (x -#include -#include - -#include "timer.h" -#include "vdriver.h" - -// ================================= Data ==================================== - -extern char mousepic[]; // blah - -static union REGS regs; - -int mx=0,my=0,mb=0; -int rb=0,wb=0; -int lmx=0,lmy=0,lmb=0; - -// ================================= Code ==================================== - -void PutMouse(int x, int y) -{ - lmx=mx; lmy=my; lmb=mb; - memset(®s, 0, sizeof regs); - regs.w.ax=4; - regs.w.cx=x*2; - regs.w.dx=y*2; - int386(0x33,®s,®s); - - mx=x; my=y; -} - -void InitMouse() -{ - memset(®s, 0, sizeof regs); - int386(0x33,®s,®s); - - regs.w.ax=7; - regs.w.cx=0; - regs.w.dx=640; /*320;*/ /* -- ric:13/Jun/98 - fix horizontal jumps -- */ - int386(0x33,®s,®s); - - regs.w.ax=8; - regs.w.cx=0; - regs.w.dx=sy; // aen - int386(0x33,®s,®s); - - PutMouse(sx/2,(sy/2) /2); // aen -} - -void ReadMouse() -{ - lmx=mx; lmy=my; lmb=mb; - memset(®s, 0, sizeof regs); - regs.w.ax=3; - int386(0x33,®s,®s); - - mx=((regs.w.cx)>>1)+16; /* -- ric:13/Jun/98 - fix horizontal jumps -- */ - my=(regs.w.dx)+16; - rb=regs.w.bx; - - if (rb && wb) { mb=0; return; } - if (wb && !rb) wb=0; - mb=rb; - - if ((lmx!=mx) || (lmy!=my) || (lmb!=mb)) idlect=0; -} - -void DrawMouse() -{ - ReadMouse(); - TCopySprite(mx,my,4,5,mousepic); -} - -void WaitRelease() -{ - wb=1; - mb=0; -} diff --git a/16/v2/source/verge/MAPED/MOUSE.H b/16/v2/source/verge/MAPED/MOUSE.H deleted file mode 100755 index d0e9a1d2..00000000 --- a/16/v2/source/verge/MAPED/MOUSE.H +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef MOUSE_INC -#define MOUSE_INC - -extern int mx,my,mb; -extern int rb,wb; -extern int lmx,lmy,lmb; - -extern void PutMouse(int x, int y); -extern void InitMouse(); -extern void ReadMouse(); -extern void DrawMouse(); -extern void WaitRelease(); - -#endif // MOUSE_INC diff --git a/16/v2/source/verge/MAPED/MTYPES.H b/16/v2/source/verge/MAPED/MTYPES.H deleted file mode 100755 index a57d0879..00000000 --- a/16/v2/source/verge/MAPED/MTYPES.H +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef MTYPES_H -#define MTYPES_H - -/* - MikMod atomic types: - ==================== -*/ - - -#ifdef __OS2__ - -typedef signed char SBYTE; /* has to be 1 byte signed */ -typedef unsigned char UBYTE; /* has to be 1 byte unsigned */ -typedef short SWORD; /* has to be 2 bytes signed */ -typedef unsigned short UWORD; /* has to be 2 bytes unsigned */ -typedef long SLONG; /* has to be 4 bytes signed */ -/* ULONG and BOOL are already defined in OS2.H */ - -#elif defined(__alpha) - -typedef char SBYTE; /* has to be 1 byte signed */ -typedef unsigned char UBYTE; /* has to be 1 byte unsigned */ -typedef short SWORD; /* has to be 2 bytes signed */ -typedef unsigned short UWORD; /* has to be 2 bytes unsigned */ -/* long is 8 bytes on dec alpha - RCA */ -typedef int SLONG; /* has to be 4 bytes signed */ -typedef unsigned int ULONG; /* has to be 4 bytes unsigned */ -typedef int BOOL; /* doesn't matter.. 0=FALSE, <>0 true */ - -#else - -typedef char SBYTE; /* has to be 1 byte signed */ -typedef unsigned char UBYTE; /* has to be 1 byte unsigned */ -typedef short SWORD; /* has to be 2 bytes signed */ -typedef unsigned short UWORD; /* has to be 2 bytes unsigned */ -typedef long SLONG; /* has to be 4 bytes signed */ -typedef unsigned long ULONG; /* has to be 4 bytes unsigned */ -typedef int BOOL; /* doesn't matter.. 0=FALSE, <>0 true */ - -#endif - - -#ifdef __OS2__ -#define INCL_DOS -#define INCL_MCIOS2 -#define INCL_MMIOOS2 -#include -#include -#include -#endif - - -#ifdef __WATCOMC__ -#define inportb(x) inp(x) -#define outportb(x,y) outp(x,y) -#define inport(x) inpw(x) -#define outport(x,y) outpw(x,y) -#define disable() _disable() -#define enable() _enable() -#endif - - -#ifdef __DJGPP__ -#include -#include -#include -#define inp inportw -#define outport outportw -#define inport inportw -#define interrupt -#endif - -#endif diff --git a/16/v2/source/verge/MAPED/PCX.C b/16/v2/source/verge/MAPED/PCX.C deleted file mode 100755 index 5ab55f66..00000000 --- a/16/v2/source/verge/MAPED/PCX.C +++ /dev/null @@ -1,210 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include "timer.h" -#include "vga.h" - -char manufacturer; // pcx header -char version; -char encoding; -char bits_per_pixel; -short int xmin,ymin; -short int xmax,ymax; -short int hres; -short int vres; -char palette[48]; -char reserved; -char color_planes; -short int bytes_per_line; -short int palette_type; -char filler[58]; - -unsigned short int width,depth; -unsigned short int bytes, i; -unsigned char c, run, ss=0; -unsigned int vidoffset, n=0; -FILE *pcxf; - -void ReadPCXLine(unsigned char *dest) -{ int j; - n=0; - - do { - c=fgetc(pcxf) & 0xff; - if ((c & 0xc0)==0xc0) { - run=c & 0x3f; - c=fgetc(pcxf); - for (j=0; j> 2; - set_intensity(63); -} - -void LoadPCXHeaderNP(char *fname) -{ - if (!(pcxf=fopen(fname,"rb"))) err("Could not open specified PCX file."); - fread(&manufacturer,1,1,pcxf); - fread(&version,1,1,pcxf); - fread(&encoding,1,1,pcxf); - fread(&bits_per_pixel,1,1,pcxf); - fread(&xmin,1,2,pcxf); - fread(&ymin,1,2,pcxf); - fread(&xmax,1,2,pcxf); - fread(&ymax,1,2,pcxf); - fread(&hres,1,2,pcxf); - fread(&vres,1,2,pcxf); - fread(&palette,1,48,pcxf); - fread(&reserved,1,1,pcxf); - fread(&color_planes,1,1,pcxf); - fread(&bytes_per_line,1,2,pcxf); - fread(&palette_type,1,2,pcxf); - fread(&filler,1,58,pcxf); - width=xmax-xmin+1; - depth=ymax-ymin+1; - bytes=bytes_per_line; -} - -void loadpcx(char *fname, char *dest) -{ - LoadPCXHeader(fname); - - for (i=0; i1 || (byte & 0xC0) != 0) - { - repcode=0xC0 | samect; - fwrite(&repcode,1,1,pcxf); - } - fwrite(&byte,1,1,pcxf); - } while (i<320); -} - -void WritePalette() -{ char b; - int i; - - for (i=0; i<768; i++) - pal[i]=pal[i] << 2; - - b=12; fwrite(&b, 1, 1, pcxf); - fwrite(pal, 1, 768, pcxf); - - for (i=0; i<768; i++) - pal[i]=pal[i] >> 2; -} - -void ScreenShot() -{ unsigned char b1; - unsigned short int w1; - char fnamestr[13]; - - // Takes a snapshot of the current screen. - - dec_to_asciiz(ss,&fnamestr); - b1=strlen(&fnamestr); - fnamestr[b1++]='.'; - fnamestr[b1++]='P'; - fnamestr[b1++]='C'; - fnamestr[b1++]='X'; - fnamestr[b1++]=0; - - pcxf=fopen(&fnamestr,"wb"); - ss++; - -// Write PCX header - - b1=10; fwrite(&b1, 1, 1, pcxf); // manufacturer always = 10 - b1=5; fwrite(&b1, 1, 1, pcxf); // version = 3.0, >16 colors - b1=1; fwrite(&b1, 1, 1, pcxf); // encoding always = 1 - b1=8; fwrite(&b1, 1, 1, pcxf); // 8 bits per pixel, for 256 colors - w1=0; fwrite(&w1, 1, 2, pcxf); // xmin = 0; - w1=0; fwrite(&w1, 1, 2, pcxf); // ymin = 0; - w1=319; fwrite(&w1, 1, 2, pcxf); // xmax = 319; - w1=199; fwrite(&w1, 1, 2, pcxf); // ymax = 199; - w1=320; fwrite(&w1, 1, 2, pcxf); // hres = 320; - w1=200; fwrite(&w1, 1, 2, pcxf); // vres = 200; - - fwrite(virscr,1,48,pcxf); // 16-color palette data. Who knows what's - // actually in here. It doesn't matter since - // the 256-color palette is stored elsewhere. - - b1=0; fwrite(&b1, 1, 1, pcxf); // reserved always = 0. - b1=1; fwrite(&b1, 1, 1, pcxf); // number of color planes. Just 1 for 8bit. - w1=320; fwrite(&w1, 1, 2, pcxf); // number of bytes per line - - w1=0; fwrite(&w1, 1, 1, pcxf); - fwrite(virscr, 1, 59, pcxf); // filler - - for (w1=0; w1<200; w1++) - WritePCXLine(screen+(w1*320)); - - WritePalette(); - fclose(pcxf); - timer_count=0; -} diff --git a/16/v2/source/verge/MAPED/RENDER.C b/16/v2/source/verge/MAPED/RENDER.C deleted file mode 100755 index e1067755..00000000 --- a/16/v2/source/verge/MAPED/RENDER.C +++ /dev/null @@ -1,475 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include - -#include "config.h" -#include "maped.h" -#include "vdriver.h" - -#include "render.h" // MAXTILES - -// ================================= Data ==================================== - -extern char stipple[256]; - -int oxw=0, oyw=0; -int xofs=0, yofs=0; -int xtc=0, ytc=0; - -char curlayer=0; -short tileidx[MAXTILES]; -char flipped[MAXTILES]; - -// ------ - -chri chrs[100]; - -// ================================= Code ==================================== - -void DoCHR(int i) // hee hee! -{ - FILE *f; - char b; - int q; - short numframes; - -// free(chrs[i].frame); -// chrs[i].frame=0; -// return; - - if (!strlen(chrlist[i].t)) - { - if (chrs[i].frame) vfree(chrs[i].frame); - chrs[i].frame=0; - chrs[i].fx=chrs[i].fy=0; - chrs[i].hx=chrs[i].hy=0; - return; - } - if (!(f=fopen(chrlist[i].t,"rb"))) - { - if (chrs[i].frame) vfree(chrs[i].frame); - chrs[i].frame=0; - chrs[i].fx=chrs[i].fy=0; - chrs[i].hx=chrs[i].hy=0; - return; - } - if (chrs[i].frame) vfree(chrs[i].frame); - fread(&b, 1, 1, f); - if (b!=2) - { - // This should really not work with V1 CHRs, but.. - chrs[i].frame=(char *) malloc(512); - fseek(f, 0, 0); - fread(chrs[i].frame, 1, 512, f); - fclose(f); - chrs[i].fx=16; chrs[i].fy=32; - chrs[i].hx=0; chrs[i].hy=16; - return; - } - chrs[i].fx=0; fread(&chrs[i].fx, 1, 2, f); - chrs[i].fy=0; fread(&chrs[i].fy, 1, 2, f); - chrs[i].hx=0; fread(&chrs[i].hx, 1, 2, f); - chrs[i].hy=0; fread(&chrs[i].hy, 1, 2, f); - fread(strbuf, 2, 2, f); - fread(&numframes, 1, 2, f); - chrs[i].frame=(char *) valloc(chrs[i].fx*chrs[i].fy*numframes,"chr preview",i); - fread(&q, 1, 4, f); - - ReadCompressedLayer1(chrs[i].frame, chrs[i].fx*chrs[i].fy*numframes,f); - - fclose(f); -} - -void DoCHRdealy() -{ - int i; - - for (i=0; i<100; i++) - DoCHR(i); -} - -void BlitBackLayer(char l) -{ - int i,j; - //int a; - char *img; - //char *d; - unsigned short *lay; - //int v; - int mapx,mapy; - int x,y; - unsigned int tile; - - if (!layertoggle[l]) return; - - mapx = layer[l].sizex; - mapy = layer[l].sizey; - lay = layers[l]; - - // Adjust view - oxw = xwin * layer[l].pmultx / layer[l].pdivx; - oyw = ywin * layer[l].pmulty / layer[l].pdivy; - xofs = 16 - (oxw & 15); - yofs = 16 - (oyw & 15); - xtc = oxw / 16; - ytc = oyw / 16; - - // Draw it, bitch! - for (i=0; i <= ty; i++) - { - for (j=0; j <= tx; j++) - { - x = xtc+j; - y = ytc+i; - - // write better clipping sometime - if (y >= 0 || y < mapy || x >=0 || x < mapx) - { - // what the HELL @_@ - tile = lay[(y * mapx) + x]; - if (tile >= numtiles) tile = numtiles-1; - tile = tileidx[tile]; - if (tile >= numtiles) tile = numtiles-1; - - img = &vsp[tile * 256]; - - x = (j * 16) + xofs; - y = (i * 16) + yofs; - - //CopyTile(x, y, img); - CCopySprite(x, y, 16, 16, img); - } - } - } - - curlayer++; -} - -//zero -extern char* translucency_table; -void LucentBlitLayer(char l) -{ - int i,j; - //int a,b; - char *img; - //char *d; - unsigned short *lay; - //int v; - int mapx,mapy; - int x,y; - unsigned int tile; - - if (!layertoggle[l]) return; - if(!translucency_table) - { - TransBlitlayer(l); - return; - } - - mapx = layer[l].sizex; - mapy = layer[l].sizey; - lay = layers[l]; - - // Adjust view - oxw = xwin * layer[l].pmultx / layer[l].pdivx; - oyw = ywin * layer[l].pmulty / layer[l].pdivy; - xofs = 16 - (oxw & 15); - yofs = 16 - (oyw & 15); - xtc = oxw / 16; - ytc = oyw / 16; - - // Draw it, bitch! - for (i=0; i <= ty; i++) - { - for (j=0; j <= tx; j++) - { - x = xtc+j; - y = ytc+i; - - // write better clipping sometime - if (y >= 0 || y < mapy || x >=0 || x < mapx) - { - // what the HELL @_@ - tile = lay[(y * mapx) + x]; - if (tile >= numtiles) tile = numtiles-1; - tile = tileidx[tile]; - if (tile >= numtiles) tile = numtiles-1; - - img = &vsp[tile * 256]; - if (img != vsp) - { - x = (j * 16) + xofs; - y = (i * 16) + yofs; - CopySpriteLucentClip(x, y, 16, 16, img); - } - } - } - } - curlayer++; -} - - -void TransBlitlayer(char l) -{ - int i,j; - //int a,b; - char *img; - //char *d; - unsigned short *lay; - //int v; - int mapx,mapy; - int x,y; - unsigned int tile; - - if (!layertoggle[l]) return; - - lay = layers[l]; - - mapx = layer[l].sizex; - mapy = layer[l].sizey; - - // Adjust view - oxw = xwin * layer[l].pmultx / layer[l].pdivx; - oyw = ywin * layer[l].pmulty / layer[l].pdivy; - xofs = 16 - (oxw & 15); - yofs = 16 - (oyw & 15); - xtc = oxw / 16; - ytc = oyw / 16; - - // Draw it, bitch! - for (i=0; i <= ty; i++) - { - for (j=0; j <= tx; j++) - { - x = xtc+j; - y = ytc+i; - - // write better clipping sometime - if (y >= 0 || y < mapy || x >=0 || x < mapx) - { - // what the HELL @_@ - tile = lay[(y * mapx) + x]; - if (tile >= numtiles) tile = numtiles-1; - tile = tileidx[tile]; - if (tile >= numtiles) tile = numtiles-1; - - img = &vsp[tile * 256]; - if (img != vsp) - { - x = (j * 16) + xofs; - y = (i * 16) + yofs; - //TCopySprite(x, y, 16, 16, img); - TCCopySprite(x, y, 16, 16, img); - } - } - } - } - - curlayer++; -} - -void BlitLayer(char c) -{ - if(layer[c].trans) { LucentBlitLayer(c); return; } //zero - if (curlayer) TransBlitLayer(c); - else BlitBackLayer(c); -} - -void DrawObstructions() -{ int i,j; - int mapx; - - mapx = layer[0].sizex; - - oxw=xwin*layer[0].pmultx/layer[0].pdivx; - oyw=ywin*layer[0].pmulty/layer[0].pdivy; - xofs=16-(oxw&15); - yofs=16-(oyw&15); - xtc=oxw>>4; - ytc=oyw>>4; - - for (i=0; i>4; - ytc=oyw>>4; - - for (i=0; i=(xwin/16)) && (entity[m].x<(xwin/16)+22) && - (entity[m].y>=(ywin/16)) && (entity[m].y<(ywin/16)+ty+2)) - { - if (chrs[entity[m].chrindex].frame) - TCCopySprite((entity[m].x*16)-xwin+16-chrs[entity[m].chrindex].hx, - (entity[m].y*16)-ywin+16-chrs[entity[m].chrindex].hy, - chrs[entity[m].chrindex].fx, - chrs[entity[m].chrindex].fy, - chrs[entity[m].chrindex].frame); - else - { - TCCopySprite( - (entity[m].x*16)-xwin+16,(entity[m].y*16)-ywin+16,16,16,stipple); - //ColorGrid((entity[m].x*16)-xwin+16, - // (entity[m].y*16)-ywin+16, 0); - } - } -} - -// aen -void DrawSelection() -{ int i,j; - int x1,y1,x2,y2; - - oxw=xwin*layer[el].pmultx/layer[el].pdivx; - oyw=ywin*layer[el].pmulty/layer[el].pdivy; - xofs=16-(oxw&15); - yofs=16-(oyw&15); - xtc=oxw>>4; - ytc=oyw>>4; - - x1=selx1; - y1=sely1; - x2=selx2; - y2=sely2; - - if (x2= x1 && xtc+j <= x2 - && ytc+i >= y1 && ytc+i <= y2) - { - TCCopySprite((j*16)+xofs, (i*16)+yofs, 16,16, stipple); - //ColorGrid((j*16)+xofs,(i*16)+yofs,7); - } - } -} - -void RenderMap() -{ char *src; - //char rs[2]; - - curlayer=0; - src=rstring; - - /* - rs[1]=0; // aen - for (; *src; ++src) - { - rs[0]=*src; - BlitLayer(atoi(rs) -1); - } - */ - while (*src) - { - switch (*src) - { - case '1': BlitLayer(0); break; - case '2': BlitLayer(1); break; - case '3': BlitLayer(2); break; - case '4': BlitLayer(3); break; - case '5': BlitLayer(4); break; - case '6': BlitLayer(5); break; - } - src++; - } - - if (!curlayer) memset(screen+5648,0,84480); - if (layertoggle[6]) DrawObstructions(); - if (layertoggle[7]) DrawZones(); - if (layertoggle[8]) DrawEntities(); - if (shifted) DrawSelection(); -} - -void AnimateTile(char i, int l) -{ - switch (vspanim[i].mode) - { - case 0: if (tileidx[l]vspanim[i].start) tileidx[l]--; - else tileidx[l]=vspanim[i].finish; - break; - case 2: tileidx[l]=random(vspanim[i].start,vspanim[i].finish); - break; - case 3: if (flipped[l]) - { - if (tileidx[l]!=vspanim[i].start) tileidx[l]--; - else { tileidx[l]++; flipped[l]=0; } - } - else - { - if (tileidx[l]!=vspanim[i].finish) tileidx[l]++; - else { tileidx[l]--; flipped[l]=1; } - } - } -} - -void Animate(char i) -{ static int l; - - vadelay[i]=0; - for (l=vspanim[i].start; l<=vspanim[i].finish; l++) - AnimateTile(i,l); -} - -void CheckTileAnimation() -{ static char i; - - for (i=0; i<100; i++) - { if ((vspanim[i].delay) && (vspanim[i].delay - -#include "vdriver.h" - -#define xx 31 - -int fontx=0; -int fonty=0; - -char sbA[]={3, - 00,xx,00, - xx,00,xx, - xx,xx,xx, - xx,00,xx, - xx,00,xx}; - -char ssA[]={3, - 00,00,00, - 00,xx,00, - xx,00,xx, - xx,xx,xx, - xx,00,xx}; - -char sbB[]={3, - xx,xx,00, - xx,00,xx, - xx,xx,00, - xx,00,xx, - xx,xx,00}; - -char ssB[]={3, - 00,00,00, - xx,xx,00, - xx,xx,00, - xx,00,xx, - xx,xx,xx}; - -char sbC[]={3, - 00,xx,xx, - xx,00,00, - xx,00,00, - xx,00,00, - 00,xx,xx}; - -char ssC[]={3, - 00,00,00, - 00,xx,xx, - xx,00,00, - xx,00,00, - 00,xx,xx}; - -char sbD[]={3, - xx,xx,00, - xx,00,xx, - xx,00,xx, - xx,00,xx, - xx,xx,00}; - -char ssD[]={3, - 00,00,00, - xx,xx,00, - xx,00,xx, - xx,00,xx, - xx,xx,00}; - -char sbE[]={3, - xx,xx,xx, - xx,00,00, - xx,xx,00, - xx,00,00, - xx,xx,xx}; - -char ssE[]={3, - 00,00,00, - xx,xx,xx, - xx,xx,00, - xx,00,00, - xx,xx,xx}; - -char sbF[]={3, - xx,xx,xx, - xx,00,00, - xx,xx,00, - xx,00,00, - xx,00,00}; - -char ssF[]={3, - 00,00,00, - xx,xx,xx, - xx,00,00, - xx,xx,00, - xx,00,00}; - -char sbG[]={3, - 00,xx,xx, - xx,00,00, - xx,00,xx, - xx,00,xx, - 00,xx,xx}; - -char ssG[]={3, - 00,00,00, - 00,xx,xx, - xx,00,00, - xx,00,xx, - 00,xx,xx}; - -char sbH[]={3, - xx,00,xx, - xx,00,xx, - xx,xx,xx, - xx,00,xx, - xx,00,xx}; - -char ssH[]={3, - 00,00,00, - xx,00,xx, - xx,00,xx, - xx,xx,xx, - xx,00,xx}; - -char sbI[]={1, - xx, - xx, - xx, - xx, - xx}; - -char ssI[]={1, - 00, - xx, - xx, - xx, - xx}; - -char sbJ[]={3, - 00,00,xx, - 00,00,xx, - 00,00,xx, - xx,00,xx, - 00,xx,00}; - -char ssJ[]={3, - 00,00,00, - 00,00,xx, - 00,00,xx, - xx,00,xx, - 00,xx,00}; - -char sbK[]={3, - xx,00,xx, - xx,00,xx, - xx,xx,00, - xx,00,xx, - xx,00,xx}; - -char ssK[]={3, - 00,00,00, - xx,00,xx, - xx,xx,00, - xx,00,xx, - xx,00,xx}; - -char sbL[]={3, - xx,00,00, - xx,00,00, - xx,00,00, - xx,00,00, - xx,xx,xx}; - -char ssL[]={3, - 00,00,00, - xx,00,00, - xx,00,00, - xx,00,00, - xx,xx,xx}; - -char sbM[]={5, - xx,00,00,00,xx, - xx,xx,00,xx,xx, - xx,00,xx,00,xx, - xx,00,00,00,xx, - xx,00,00,00,xx}; - -char ssM[]={5, - 00,00,00,00,00, - xx,00,00,00,xx, - xx,xx,00,xx,xx, - xx,00,xx,00,xx, - xx,00,00,00,xx}; - -char sbN[]={4, - xx,00,00,xx, - xx,xx,00,xx, - xx,00,xx,xx, - xx,00,00,xx, - xx,00,00,xx}; - -char ssN[]={4, - 00,00,00,00, - xx,00,00,xx, - xx,xx,00,xx, - xx,00,xx,xx, - xx,00,00,xx}; - -char sbO[]={3, - 00,xx,00, - xx,00,xx, - xx,00,xx, - xx,00,xx, - 00,xx,00}; - -char ssO[]={3, - 00,00,00, - 00,xx,00, - xx,00,xx, - xx,00,xx, - 00,xx,00}; - -char sbP[]={3, - xx,xx,00, - xx,00,xx, - xx,xx,00, - xx,00,00, - xx,00,00}; - -char ssP[]={3, - 00,00,00, - xx,xx,00, - xx,00,xx, - xx,xx,00, - xx,00,00}; - -char sbQ[]={4, - 00,xx,xx,00, - xx,00,00,xx, - xx,00,00,xx, - xx,00,xx,00, - 00,xx,00,xx}; - -char ssQ[]={3, - 00,00,00, - xx,xx,00, - xx,00,xx, - xx,xx,00, - 00,xx,xx}; - -char sbR[]={3, - xx,xx,00, - xx,00,xx, - xx,xx,00, - xx,00,xx, - xx,00,xx}; - -char ssR[]={3, - 00,00,00, - xx,xx,00, - xx,00,xx, - xx,xx,00, - xx,00,xx}; - -char sbS[]={3, - 00,xx,xx, - xx,00,00, - 00,xx,00, - 00,00,xx, - xx,xx,00}; - -char ssS[]={3, - 00,00,00, - 00,xx,xx, - xx,00,00, - 00,xx,xx, - xx,xx,00}; - -char sbT[]={3, - xx,xx,xx, - 00,xx,00, - 00,xx,00, - 00,xx,00, - 00,xx,00}; - -char ssT[]={3, - 00,00,00, - xx,xx,xx, - 00,xx,00, - 00,xx,00, - 00,xx,00}; - -char sbU[]={3, - xx,00,xx, - xx,00,xx, - xx,00,xx, - xx,00,xx, - xx,xx,xx}; - -char ssU[]={3, - 00,00,00, - xx,00,xx, - xx,00,xx, - xx,00,xx, - xx,xx,xx}; - -char sbV[]={3, - xx,00,xx, - xx,00,xx, - xx,00,xx, - xx,00,xx, - 00,xx,00}; - -char ssV[]={3, - 00,00,00, - xx,00,xx, - xx,00,xx, - xx,00,xx, - 00,xx,00}; - -char sbW[]={5, - xx,00,00,00,xx, - xx,00,00,00,xx, - xx,00,xx,00,xx, - xx,xx,00,xx,xx, - xx,00,00,00,xx}; - -char ssW[]={5, - 00,00,00,00,00, - xx,00,00,00,xx, - xx,00,xx,00,xx, - xx,xx,00,xx,xx, - xx,00,00,00,xx}; - -char sbX[]={3, - xx,00,xx, - xx,00,xx, - 00,xx,00, - xx,00,xx, - xx,00,xx}; - -char ssX[]={3, - 00,00,00, - xx,00,xx, - 00,xx,00, - xx,00,xx, - xx,00,xx}; - -char sbY[]={3, - xx,00,xx, - xx,00,xx, - 00,xx,00, - 00,xx,00, - 00,xx,00}; - -char ssY[]={3, - 00,00,00, - xx,00,xx, - xx,00,xx, - 00,xx,00, - 00,xx,00}; - -char sbZ[]={3, - xx,xx,xx, - 00,00,xx, - 00,xx,00, - xx,00,00, - xx,xx,xx}; - -char ssZ[]={2, - 00,00, - xx,xx, - 00,xx, - xx,00, - xx,xx}; - -char s1[]={1, - xx, - xx, - xx, - xx, - xx}; - -char s2[]={3, - xx,xx,xx, - 00,00,xx, - xx,xx,xx, - xx,00,00, - xx,xx,xx}; - -char s3[]={3, - xx,xx,xx, - 00,00,xx, - 00,xx,xx, - 00,00,xx, - xx,xx,xx}; - -char s4[]={3, - xx,00,xx, - xx,00,xx, - xx,xx,xx, - 00,00,xx, - 00,00,xx}; - -char s5[]={3, - xx,xx,xx, - xx,00,00, - xx,xx,xx, - 00,00,xx, - xx,xx,xx}; - -char s6[]={3, - xx,xx,xx, - xx,00,00, - xx,xx,xx, - xx,00,xx, - xx,xx,xx}; - -char s7[]={3, - xx,xx,xx, - 00,00,xx, - 00,00,xx, - 00,00,xx, - 00,00,xx}; - -char s8[]={3, - xx,xx,xx, - xx,00,xx, - xx,xx,xx, - xx,00,xx, - xx,xx,xx}; - -char s9[]={3, - xx,xx,xx, - xx,00,xx, - xx,xx,xx, - 00,00,xx, - xx,xx,xx}; - -char s0[]={3, - xx,xx,xx, - xx,00,xx, - xx,00,xx, - xx,00,xx, - xx,xx,xx}; - -char sQuote[]={3, - xx,00,xx, - xx,00,xx, - 00,00,00, - 00,00,00, - 00,00,00}; - -char sYow[]={1, - xx, - xx, - xx, - 00, - xx}; - -char sQuotes[]={1, - xx, - xx, - 00, - 00, - 00}; - - -char sComma[]={2, - 00,00, - 00,00, - 00,00, - 00,xx, - xx,00}; -char sPeriod[]={1, - 00, - 00, - 00, - 00, - xx}; - -char sMinus[]={2, - 00,00, - 00,00, - xx,xx, - 00,00, - 00,00}; - -char sQuest[]={3, - xx,xx,xx, - 00,00,xx, - 00,xx,xx, - 00,00,00, - 00,xx,00}; - -char sColon[]={1, - 00, - xx, - 00, - xx, - 00}; - -char sch[]={3, - 00,xx,00, - xx,xx,xx, - xx,xx,xx, - xx,xx,xx, - 00,xx,00}; - -char usc[]={2, - 00,00, - 00,00, - 00,00, - 00,00, - xx,xx}; - -char star[]={4, - 00,00,00,xx, - xx,00,xx,00, - 00,xx,00,00, - 00,00,00,00, - 00,00,00,00}; - -char ss[]={2, - xx,xx, - xx,xx, - xx,xx, - xx,xx, - xx,xx}; - -char sra[]={3, - xx,00,00, - xx,xx,00, - xx,xx,xx, - xx,xx,00, - xx,00,00}; - -char slParen[]={2, - 00,xx, - xx,00, - xx,00, - xx,00, - 00,xx}; - -char srParen[]={2, - xx,00, - 00,xx, - 00,xx, - 00,xx, - xx,00}; - -char ssemic[]={2, - xx,xx, - 00,00, - xx,xx, - 00,xx, - xx,00}; - -char sSlash[]={3, - 00,00,xx, - 00,00,xx, - 00,xx,00, - xx,00,00, - xx,00,00}; - -char sBlank[]={2, - 00,00, - 00,00, - 00,00, - 00,00, - 00,00}; - -// ... -char mousepic[] = { xx,00,00,00, - xx,xx,00,00, - xx,xx,xx,00, - xx,xx,xx,xx, - 00,00,xx,00, - 00,00,xx,00}; - -char *smal_tbl[]= -{ sBlank, - sYow, sQuote, ss, ss, ss, ss, sQuotes, slParen, // 40 - srParen, star, ss, sComma, sMinus,sPeriod, sSlash, s0, // 48 - s1, s2, s3, s4, s5, s6, s7, s8, // 56 - s9, sColon, ssemic, ss, ss, sra, sQuest, ss, // 64 - sbA, sbB, sbC, sbD, sbE, sbF, sbG, sbH, // 72 - sbI, sbJ, sbK, sbL, sbM, sbN, sbO, sbP, // 80 - sbQ, sbR, sbS, sbT, sbU, sbV, sbW, sbX, // 88 - sbY, sbZ, ss, ss, ss, ss, usc, sch, // 96 - ssA, ssB, ssC, ssD, ssE, ssF, ssG, ssH, // 102 - ssI, ssJ, ssK, ssL, ssM, ssN, ssO, ssP, // 110 - ssQ, ssR, ssS, ssT, ssU, ssV, ssW, ssX, // 118 - ssY, ssZ }; // 120 - -unsigned char lastcol=31; - -void GotoXY(int x1, int y1) -{ - fontx=x1; - fonty=y1; -} - -void print_char(char c) -{ char* img; - - c-=32; - if (c>90) c=2; - img=smal_tbl[c]; - TCopySprite(fontx,fonty,img[0],5,img+1); - fontx+=img[0]+1; -} - -void printstring(char *str) -{ - for (; *str; ++str) - print_char(*str); -} - -int pixels(char *str) -{ int pix; - - for (pix=0; *str; ++str) - pix += *smal_tbl[*str-32]+1; - return pix; -} - -void dec_to_asciiz(int num, char *buf) -{ - sprintf(buf,"%d",num); -} - -void TextColor(unsigned char newc) -{ char *src; - - src=sbA; - while ((int)src < (int) smal_tbl) - { - if (*src==lastcol) *src=newc; - src++; - } -} diff --git a/16/v2/source/verge/MAPED/SMALFONT.H b/16/v2/source/verge/MAPED/SMALFONT.H deleted file mode 100755 index 77688538..00000000 --- a/16/v2/source/verge/MAPED/SMALFONT.H +++ /dev/null @@ -1,30 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SMALFONT_INC -#define SMALFONT_INC - -extern int fontx; -extern int fonty; - -extern void GotoXY(int x1, int y1); -extern void print_char(char c); -extern void printstring(char *str); -extern int pixels(char *str); -extern void dec_to_asciiz(int num, char *buf); -extern void TextColor(unsigned char newc); - -#endif // SMALFONT_INC diff --git a/16/v2/source/verge/MAPED/SSAVER.C b/16/v2/source/verge/MAPED/SSAVER.C deleted file mode 100755 index b2ce0a55..00000000 --- a/16/v2/source/verge/MAPED/SSAVER.C +++ /dev/null @@ -1,136 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include - -#include "maped.h" -#include "timer.h" -#include "vdriver.h" - -#include "mouse.h" - -// ================================= Data ==================================== - -static int *dmapx = NULL; -static int *dmapy = NULL; -static unsigned char *dscr = NULL; -static int recalc_distort = 1; -static long build = 0; - -// ================================= Code ==================================== - -// aen -static void init_distort(void) - { - int x = 0; - int y = 0; - int *dx = NULL; - int *dy = NULL; - - if (dmapx) vfree(dmapx); dmapx=NULL; - if (dmapy) vfree(dmapy); dmapy=NULL; - if (dscr) vfree(dscr); dscr=NULL; - - // allocate distort lookups - dmapx = (int *) valloc(tsx*tsy*4,"ssaver X",0); - dmapy = (int *) valloc(tsx*tsy*4,"ssaver Y",0); - - // allocate distort image buffer - dscr = (unsigned char *) valloc(tsx*tsy,"ssaver scrn",0); - - // copy viewport into distort buffer - memcpy(dscr, screen, tsx*tsy); - - dx = dmapx; - dy = dmapy; - - // generate distort lookups - for (y=0; y= tsy) yy -= tsy; - xt += (dmapx[(yy*tsx)+x] * build) >> 16; - - xx = (x+((thresh*tsx)/tsy)); - if (xx >= tsx) xx -= tsx; - yt += (dmapy[(yy*tsx)+xx] * build) >> 16; - - if (xt < 0) xt += tsx; - if (yt < 0) yt += tsy; - if (xt >= tsx) xt -= tsx; - if (yt >= tsy) yt -= tsy; - - *ds++ = dscr[(yt*tsx)+xt]; - - ++x; - if (x >= tsx) { - x = 0; - ++y; - //ds+=32; - } - - xt = x; - yt = y; - - } while (y < tsy); - - thresh += 2; - if (thresh >= tsy) - thresh -= tsy; - - if (build < 85196) //1.5 - build += 3276; - } - -void ScreenSaver(void) - { - while (idlect > 750) - { - ReadMouse(); - do_distort(); - ShowPage(); - } - recalc_distort=1; - build = 0; - } diff --git a/16/v2/source/verge/MAPED/SSAVER.H b/16/v2/source/verge/MAPED/SSAVER.H deleted file mode 100755 index 1a6a5296..00000000 --- a/16/v2/source/verge/MAPED/SSAVER.H +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef SSAVER_INC -#define SSAVER_INC - -extern void ScreenSaver(void); - -#endif // SSAVER_INC diff --git a/16/v2/source/verge/MAPED/SSAVER1.C b/16/v2/source/verge/MAPED/SSAVER1.C deleted file mode 100755 index 2e1846c1..00000000 --- a/16/v2/source/verge/MAPED/SSAVER1.C +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "timer.h" -#include "vdriver.h" - -// ================================= Data ==================================== - -// ================================= Code ==================================== - -void ScreenSaver() -{ - while (idlect>750) - { - ReadMouse(); - ClearScreen(); - ShowPage(); - } -} diff --git a/16/v2/source/verge/MAPED/TILEED.C b/16/v2/source/verge/MAPED/TILEED.C deleted file mode 100755 index 807f67cc..00000000 --- a/16/v2/source/verge/MAPED/TILEED.C +++ /dev/null @@ -1,2164 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// Additional code by Richard Lau (aka Ric) - -/* Date started: 08/Jul/98 */ -/* -- 29/Jul/98 -- - * Heh, I've actually done quite a lot of work on this even though I intend - * to replace it. Oh well :) - * - * I've now made clicking on the mask indicator button (labelled with a small - * "m") drop back to draw mode if you're in select mode (since it makes no - * sense to select an area with the mask turned off). Holding down shift - * and dragging the mouse when you're in select mode will allow you to select - * a rectangle. The PgUp/PgDn colour shifters will now work in paste mode - * (affecting the image in the copy buffer). - * - * The fill routine is now in place and I've put a button in for the pick - * colour/eyedropper tool so that I don't get asked to put in a function for - * like I continuously did with ACE. Due to the extra buttons I've had to - * shift some of the other buttons around to make them all fit onto the - * screen. It's probably not the best arrangement but if anyone comes up with - * a better layout I'm open to suggestions. - * - * The wierd button labelling problem I had last time has been corrected - the - * problem was traced back to the pixels routine in SMALFONT.C. Aen pointed - * out that I wasn't allocating space for the NULL terminator for all the - * strings so that has now been fixed (by adding 1 to strlen). - * - * - Ric - */ -/* - * Keys: - * CTRL/S + mouse click - (over edit window) Pick up colour under mouse - * SHIFT+mb down+drag mouse - select rectangle (select mode only) - * SPACEBAR - toggle between draw mode and select mode - * CTRL+Z or U - one level undo - * CTRL+A - select all - * CTRL+U - unselect all - * CTRL+C - copy selected area - * CTRL+X - cut selected area - * CTRL+V - paste - * DEL - clears selected area - * CTRL+R - reverts the tile to the original (like undo in maped 1) - * (self note: modify to ask for confirmation) - * G - toggles grid on/off - * H - toggles hilight on/off - * M - toggles mask on/off - * I - inverts mask - * X - mirrors image - * Y - flips image - * L/R - Rotates tile 90 degrees anti-clockwise/clockwise - * Q/W - Steps through animation (in tile edit mode) if any - * A/Z and S/X - changes the left or right drawing colours - * PGUP/PGDN - Colour shift up/down - * [ and ] - toggle screen resolutions - * ALT+X - quits to DOS - */ -/* -- 26/Jul/98 -- - * I've actually decided to start the editor over in a new file so that the - * code is a bit more elegant. As it stands some bits of this are messy but - * it currently works ;). Anyway I've decided that what I'll do is to in - * effect write two tile editors - continuing work on this one and working - * on the rewrite as a "side project". The eventual aim will be to replace - * this editor with the rewrite but if factors intervene preventing me from - * completing the rewrite then there'll always be this editor to fall back on. - * - * New in this release is a copy/cut/paste system. New buttons have been added. - * For some reason I haven't figured out yet I can't call the two rotate - * buttons "Rotate ACW" and "Rotate CW" (it causes MapEd to crash) so I've had - * to resort to calling them "Turn_L" and "Turn_R". - * - Ric - */ - -#include -#include - -#include "config.h" -#include "guicomp.h" -#include "keyboard.h" -#include "maped.h" -#include "mouse.h" -#include "render.h" -#include "vdriver.h" - -#include "smalfont.h" - -#undef free - -#define TRUE 1 -#define FALSE 0 -// #define NULL ((void *)0) - -#define MOUSENONE 0 // No mouse buttons pressed -#define MOUSERELEASE 1 // Mouse button released -#define MOUSEPRESSED 2 // Mouse button held down -#define MOUSECLICKED 4 // Mouse button pressed - -// Setup some defines for the regions/areas/windows where everything goes -#define MAX_REGIONS 29 // Number of regions -#define BASEREG 0 // Window coords + title -#define HELPBAR 1 // Helpbar - put helpful messages here :) -#define PALETTE 2 // The palette -#define EDITREG 3 // Main edit window -#define PREVIEW 4 // Preview of image being edited -#define SCOLBOX 5 // Selected colour box -#define SCTXTBX 6 // Text box to show info on the selected colours -#define QUITBUT 7 // Quit button -#define DRAWBUT 8 // Draw mode indicator -#define FILLBUT 9 // Fill mode indicator -#define PICKBUT 10 // Pick mode indicator -#define MASKBUT 11 // Mask mode indicator -#define PSTEBUT 12 // Paste mode indicator -#define EDMDFRM 13 // Frame for edit mode radio buttons -#define MASKIND 14 // Indicator showing if mask is shown -#define GRIDIND 15 // Indicator showing if grid is shown -#define ANIMIND 16 // Indicator showing if animations are shown -#define PXHLIND 17 // Indicator showing if pixel highlight shown -#define IND_FRM 18 // Frame for indicators (push buttons) -#define BUT_FRM 19 // Frame for buttons -#define UNDOBUT 20 // Undo button -#define COPYBUT 21 // Copy button -#define CUT_BUT 22 // Cut button -#define CLR_BUT 23 // Clear button -#define TOOLFRM 24 // Frame for tools -#define FLIPBUT 25 // Flip image button -#define MIRRBUT 26 // Mirror image button -#define RIACBUT 27 // Rotate anticlockwise button -#define RIC_BUT 28 // Rotate clockwise button - -// Define TEbitflags values -#define TEQUITCUR 1 -#define TEANIMATE 2 -#define TEGRID 4 -#define TEHILIGHT 8 -#define TESHOWMSK 16 - -// Define TEREGION->bitflags values -#define REGVISIBLE 1 -#define REGACTIVE 2 -#define REGNOCLICK 4 -#define REGTWOCLICK 8 // wait for a second click - -// TEeditmode defs -#define EDDRAW 1 -#define EDFILL 2 -#define EDPICK 4 -#define EDMASK 8 -#define EDPASTE 16 - -// TEtype defs -#define TEUNKNOWN 0 -#define TETILE 1 - -// DATABUTTON buttontypes: -#define CLICKBUTTON 1 // normal button -#define PUSHBUTTON 2 // can be pushed in/out (toggle bit bitvalue) -#define RADIOBUTTON 4 // for button banks (set *bitflag=bitvalue) - -// DATABASEREGION windowtypes: -#define DBRSTDWINDOW 0 // window and title bar -#define DBRPANEL 1 // no title bar - -// INFOTYPEs: -#define DITREGION 1 -#define DITBASEREGION 2 -#define DITBUTTON 4 -#define DITEDITREG 8 - -// Button flag action - has this button been clicked? -#define BFANONE 0 -#define BFAUNDO 1 -#define BFACOPY 2 -#define BFACUT 4 -#define BFACLEAR 8 -#define BFARIAC 16 -#define BFARIC 32 -#define BFAMIRROR 64 -#define BFAFLIP 128 - -// Variables -typedef struct TEREGION - { - int infotype; // type of struct - unsigned int x1, x2, y1, y2; // bounding coordinates - char *caption; // helpbar text - int bitflags; // see defines above - void (*drawproc)(struct TEREGION *); // region's draw procedure - // - allows nice and short RenderTileEdit proc ;) - void *data; // extended information - } TEREGION; -typedef struct DATABASEREGION - { - int infotype; // type of struct - int numofregs; // total number of regions (including base) - int windowtype; // type of window to draw - } DATABASEREGION; -typedef struct DATABUTTON - { - int infotype; // type of struct - int *bitflag; // address of bitflag - char *text; // addition text (eg helptext) - int bitvalue; // 1st bit/value - int buttontype; // type - } DATABUTTON; -typedef struct DATAEDITREG - { - int infotype; // type of struct - int firstx, firsty; // first coords for two-click operation - } DATAEDITREG; - - -static TEREGION *TEregs=NULL; // pointer to the regions -static unsigned char lcolor=255; // left mouse colour -static unsigned char rcolor=0; // right mouse colour -static TEREGION *TEOldReg=NULL; -static unsigned int MBStatus[3]={MOUSENONE,MOUSENONE,MOUSENONE}; -static int TEanimstrand=0; // Animation strand -static int TEbitflags=TEANIMATE; // Set default bitflags -static int TEbfa=BFANONE; // Set default button action flags -static int TEeditmode=EDDRAW; // Default edit region mode -static int TExoffs=16; // X offset for region "windows" -static int TEyoffs=16; // Y offset for region "windows" -unsigned int TEtype=TEUNKNOWN; // type of graphic being edited -unsigned int TEtile; // tile to edit - may possibly expand this to an array for simultaneous editing -unsigned int TExsize=0; // width of graphic being edited -unsigned int TEysize=0; // height of graphic being edited -unsigned int TEcopyxsize=0; // width of copy buffer -unsigned int TEcopyysize=0; // height of copy buffer -unsigned char *TEsource=NULL; // pointer to original image being edited -static unsigned char *TEimage=NULL; // pointer to image being edited -static unsigned char *TEmask=NULL; // pointer to image mask -static unsigned char *TEundo=NULL; // pointer to undo buffer -static unsigned char *TEcopy=NULL; // pointer to copy buffer -static unsigned char *TEcmsk=NULL; // pointer to copy mask -static char TEtempstr[256]; // Temporary string buffer - -// Function prototypes -static void *TEAlloc(unsigned long amount, char *whatfor); - -#define TEFree(ptr) if (ptr) free(ptr); ptr=NULL; -#define TEFreeReg(ptr) DestroyRegions(&ptr); if (ptr) free(ptr); ptr=NULL; -#define TENewText(text, whatfor) (char *) strcpy(TEAlloc(strlen(text)+1, whatfor), text); -//static void TEFree(void *TETmpBuf); -static void MBClickHandler(TEREGION *TEBaseReg); -static void AboutTE(void); -static void DestroyRegions(TEREGION **TEBaseReg); -static void SetupRegions(void); -static void InitTEImage(void); -static void DeinitTEImage(void); -static int MouseOverTEreg(TEREGION *TEr); -static void RenderTileEdit(TEREGION *TEBaseReg); -static void RestartTileEditor(void); -static void SetCaption(TEREGION *TEr, char *helptext); -static void TEDrawHilight(int x1, int y1, int width, int height, unsigned char colour); -static void TEDrawCheckeredBox(int x1, int y1, int width, int height, unsigned char colour); -static void TERegFill(TEREGION *TEr, int colour); -static void TERegText(TEREGION *TEr, char *message); -static void TEClearImage(void); -static void TECopyImage(void); -static void TEFlipImage(unsigned char *TERILsrc, int TERILxsize, int TERILysize); -static void TEMirrorImage(unsigned char *TERILsrc, int TERILxsize, int TERILysize); -static void TERotateImageAntiClockwise(unsigned char *TERILsrc, int TERILxsize, int TERILysize); -static void TERotateImageClockwise(unsigned char *TERILsrc, int TERILxsize, int TERILysize); -static void TEFillImage(char *TEFIimage, char *TEFImask, int TEFIxsize, int TEFIysize, int TEFIx, int TEFIy, char TEFIcolour); -static void TERFillImage(char *TERFIimage, char *TERFImask, int TERFIxsize, int TERFIysize, int TERFIx, int TERFIy); -static void TEShiftColours(char *TESCimage, char *TESCmask, int TESCxsize, int TESCysize, int amount); -static void TEUndo(void); -static void DrawButton(TEREGION *TEr); -static void DrawEditReg(TEREGION *TEr); -static void DrawHelpBar(TEREGION *TEr); -static void DrawPalette(TEREGION *TEr); -static void DrawPreview(TEREGION *TEr); -static void DrawSColBox(TEREGION *TEr); -static void DrawSCTxtBx(TEREGION *TEr); -static void DrawSunkRegion(TEREGION *TEr); -void TileEdit(void); - - -static int MouseOverTEreg(TEREGION *TEr) - { - unsigned int testx=mx-TExoffs; - unsigned int testy=my-TEyoffs; - unsigned int width=(TEr->x2)-(TEr->x1); - unsigned int height=(TEr->y2)-(TEr->y1); - testx-=(TEr->x1); - testy-=(TEr->y1); - - if (testx >= width || testy >= height) return FALSE; - return TRUE; - } - -static void DrawButton(TEREGION *TEr) -// -- ric: 20/Jul/98 - generic button routine - { - unsigned int x=TEr->x1+TExoffs; - unsigned int y=TEr->y1+TEyoffs; - unsigned int width=(TEr->x2)-(TEr->x1); - unsigned int height=(TEr->y2)-(TEr->y1); - - strcpy(TEtempstr,"Button data not declared."); - if (!TEr->data) - err(TEtempstr); - if (((struct DATABUTTON *)(TEr->data))->infotype!=DITBUTTON) - err(TEtempstr); - - // draw raised button - stdwindow(x-1, y-1, x+width+1, y+height+1); - if (TEr->caption) - { - GotoXY(x+(width-(pixels(TEr->caption)))/2, y+(height-6)/2); - printstring(TEr->caption); - } - switch (((struct DATABUTTON *)(TEr->data))->buttontype) - { - case CLICKBUTTON: - if (MouseOverTEreg(TEr) && TEr->bitflags®ACTIVE) - { - if (((struct DATABUTTON *)(TEr->data))->text) - SetCaption(&TEregs[HELPBAR], (((struct DATABUTTON *)(TEr->data))->text)); - - // Handle mouse clicks - if (TEOldReg==TEr) - { - if ((MBStatus[0]|MBStatus[1])==MOUSEPRESSED) - { - // draw button down - FilledBox(x, y, width, height, winbg); - HLine(x, y, width, darkw); - VLine(x, y, height, darkw); - if (TEr->caption) - { - GotoXY(x+1+(width-(pixels(TEr->caption)))/2, y+1+(height-6)/2); - printstring(TEr->caption); - } - } - if ((MBStatus[0]|MBStatus[1])==MOUSERELEASE) - { - *(((struct DATABUTTON *)(TEr->data))->bitflag)^=((struct DATABUTTON *)(TEr->data))->bitvalue; - } - } - } - break; - case PUSHBUTTON: - if (*(((struct DATABUTTON *)(TEr->data))->bitflag)&(((struct DATABUTTON *)(TEr->data))->bitvalue)) - { - // draw button down - FilledBox(x, y, width, height, winbg); - HLine(x, y, width, darkw); - VLine(x, y, height, darkw); - if (TEr->caption) - { - GotoXY(x+1+(width-(pixels(TEr->caption)))/2, y+1+(height-6)/2); - printstring(TEr->caption); - } - } - if (MouseOverTEreg(TEr) && TEr->bitflags®ACTIVE) - { - if (((struct DATABUTTON *)(TEr->data))->text) - { - sprintf(TEtempstr, "Toggle %s on/off", ((struct DATABUTTON *)(TEr->data))->text); - SetCaption(&TEregs[HELPBAR], TEtempstr); - } - - // Handle mouse clicks - if (TEOldReg==TEr) - { - if ((MBStatus[0]|MBStatus[1])==MOUSECLICKED) - { - *(((struct DATABUTTON *)(TEr->data))->bitflag)^=((struct DATABUTTON *)(TEr->data))->bitvalue; - } - } - } - break; - case RADIOBUTTON: - if (*(((struct DATABUTTON *)(TEr->data))->bitflag)==((struct DATABUTTON *)(TEr->data))->bitvalue) - { - // draw button down - FilledBox(x, y, width, height, winbg); - HLine(x, y, width, darkw); - VLine(x, y, height, darkw); - if (TEr->caption) - { - GotoXY(x+1+(width-(pixels(TEr->caption)))/2, y+1+(height-6)/2); - printstring(TEr->caption); - } - } - if (MouseOverTEreg(TEr) && TEr->bitflags®ACTIVE) - { - if (((struct DATABUTTON *)(TEr->data))->text) - SetCaption(&TEregs[HELPBAR], (((struct DATABUTTON *)(TEr->data))->text)); - - // Handle mouse clicks - if (TEOldReg==TEr) - { - if ((MBStatus[0]|MBStatus[1])==MOUSECLICKED) - { - *(((struct DATABUTTON *)(TEr->data))->bitflag)=((struct DATABUTTON *)(TEr->data))->bitvalue; - } - } - } - break; - } - } - -static void DrawSunkRegion(TEREGION *TEr) - { - unsigned int x=TEr->x1+TExoffs; - unsigned int y=TEr->y1+TEyoffs; - unsigned int width=(TEr->x2)-(TEr->x1); - unsigned int height=(TEr->y2)-(TEr->y1); - -// FilledBox(x, y, width, height, black); - HLine(x, y, width, darkw); - VLine(x, y, height, darkw); - HLine(x+1, y+height-1, width-1, brightw); - VLine(x+width-1, y+1, height-1, brightw); - } - -static void DrawEditReg(TEREGION *TEr) - { - int i,j,i2,j2,c; - int minx,miny,maxx,maxy; - int blocksize=8; - int visblocksize=blocksize; - char *img; - TEREGION tempr; - tempr.x1=TEr->x1+2; - tempr.x2=TEr->x2-2; - tempr.y1=TEr->y1+2; - tempr.y2=TEr->y2-2; - - img=TEimage; //vsp+(256*TEtile); - - TERegFill(TEr, black); - DrawSunkRegion(TEr); - FilledBox(TEr->x1+TExoffs+2, TEr->y1+TEyoffs+2, (blocksize<<4), (blocksize<<4), titlebg); - - if (TEbitflags&TEGRID) visblocksize-=1; - - for (j=0; jx1+TExoffs+2+i*blocksize, TEr->y1+TEyoffs+2+j*blocksize, visblocksize, visblocksize, *img++); - if (TEbitflags&TESHOWMSK && !TEmask[j*TExsize+i]) - TEDrawCheckeredBox(TEr->x1+TExoffs+2+i*blocksize, TEr->y1+TEyoffs+2+j*blocksize, visblocksize, visblocksize, titlebg); - } - - img=TEimage; - if (TEr->bitflags®ACTIVE && !(MouseOverTEreg(&tempr)) && (MBStatus[0]|MBStatus[1])==MOUSERELEASE) - if (TEr->bitflags®TWOCLICK) TEr->bitflags^=REGTWOCLICK; - if (MouseOverTEreg(&tempr) && TEr->bitflags®ACTIVE) - { - i=(mx-TExoffs-(tempr.x1))/blocksize; - j=(my-TEyoffs-(tempr.y1))/blocksize; - c=img[(j*TExsize)+i]; - sprintf(TEtempstr, "Tile: %d, (%02d, %02d), Color: %03d (rgb: %03d/%03d/%03d)", TEtile, i, j, c, pal[(c*3)], pal[(c*3)+1], pal[(c*3)+2]); - SetCaption(&TEregs[HELPBAR], TEtempstr); - if (TEbitflags&TEHILIGHT) - TEDrawHilight(TExoffs+i*blocksize+tempr.x1, TEyoffs+j*blocksize+tempr.y1, visblocksize, visblocksize, white); - - // if pasting draw the image being pasted - if (TEeditmode==EDPASTE) - { - for (j2=0; j2x1+TExoffs+2+(i+i2)*blocksize, TEr->y1+TEyoffs+2+(j+j2)*blocksize, visblocksize, visblocksize, TEcopy[j2*TEcopyxsize+i2]); - else - if (TEmask[(j+j2)*TExsize+i+i2]) - FilledBox(TEr->x1+TExoffs+2+(i+i2)*blocksize, TEr->y1+TEyoffs+2+(j+j2)*blocksize, visblocksize, visblocksize, TEcopy[j2*TEcopyxsize+i2]); - } - if (TEeditmode==EDMASK) - { - // draw reg - if (TEr->bitflags®TWOCLICK) - for (j2=0; j2=j && j2<=((struct DATAEDITREG *)(TEr->data))->firsty) || - (j2>=((struct DATAEDITREG *)(TEr->data))->firsty && j2<=j)) && - ((i2>=i && i2<=((struct DATAEDITREG *)(TEr->data))->firstx) || - (i2>=((struct DATAEDITREG *)(TEr->data))->firstx && i2<=i))) - TEDrawCheckeredBox(TEr->x1+TExoffs+2+i2*blocksize, TEr->y1+TEyoffs+2+j2*blocksize, visblocksize, visblocksize, darkred); - - if ((MBStatus[0]|MBStatus[1])==MOUSECLICKED && (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) && !(TEr->bitflags®TWOCLICK)) - { - ((struct DATAEDITREG *)(TEr->data))->firstx=i; - ((struct DATAEDITREG *)(TEr->data))->firsty=j; - TEr->bitflags^=REGTWOCLICK; - } - if ((MBStatus[0]|MBStatus[1])==MOUSERELEASE && TEr->bitflags®TWOCLICK) - { - if (MBStatus[1]==MOUSERELEASE) c=0x0; - else c=0xf; - miny=j; - maxy=((struct DATAEDITREG *)(TEr->data))->firsty; - minx=i; - maxx=((struct DATAEDITREG *)(TEr->data))->firstx; - if (j>((struct DATAEDITREG *)(TEr->data))->firsty) - { - maxy=j; - miny=((struct DATAEDITREG *)(TEr->data))->firsty; - } - if (i>((struct DATAEDITREG *)(TEr->data))->firstx) - { - maxx=i; - minx=((struct DATAEDITREG *)(TEr->data))->firstx; - } - for (j2=miny; j2<=maxy; j2++) - for (i2=minx; i2<=maxx; i2++) - TEmask[j2*TExsize+i2]=(char)c; - TEr->bitflags^=REGTWOCLICK; - } - } - // Handle mouse clicks - -#ifdef JUNK - if ((MBStatus[0]|MBStatus[1])==MOUSECLICKED && (key[SCAN_CTRL]||key[SCAN_S])) - { - // put code to lock out draw mode here - } -#endif - if (TEOldReg==TEr) - { - // Update undo buffer - if ((MBStatus[0]|MBStatus[1])==MOUSECLICKED && TEeditmode!=EDMASK && TEeditmode!=EDPICK && !(key[SCAN_CTRL]||key[SCAN_S])) - memcpy(TEundo, TEimage, TExsize*TEysize); - if (MBStatus[0]==MOUSECLICKED && TEeditmode==EDFILL) - TEFillImage(TEimage, (TEbitflags&TESHOWMSK ? TEmask : NULL), TExsize, TEysize, i, j, lcolor); - if (MBStatus[1]==MOUSECLICKED && TEeditmode==EDFILL) - TEFillImage(TEimage, (TEbitflags&TESHOWMSK ? TEmask : NULL), TExsize, TEysize, i, j, rcolor); - - // Draw - if ((MBStatus[0]|MBStatus[1])==MOUSEPRESSED) - { - if (TEeditmode==EDPASTE) - { - for (j2=0; j2bitflags®TWOCLICK)) - TEmask[(j*TExsize)+i]=0xf; - if (MBStatus[1]==MOUSEPRESSED) - if (key[SCAN_CTRL]||key[SCAN_S]||(TEeditmode==EDPICK)) - rcolor=TEimage[(j*TExsize)+i]; - else - if ((TEeditmode==EDDRAW)&&!(TEbitflags&TESHOWMSK && !TEmask[j*TExsize+i])) - TEimage[(j*TExsize)+i]=rcolor; - else - if (TEeditmode==EDMASK && !(TEr->bitflags®TWOCLICK)) - TEmask[(j*TExsize)+i]=0x0; - } - } - } - -static void DrawHelpBar(TEREGION *TEr) - { - //int i, htext=0; - TERegFill(TEr, black); - DrawSunkRegion(TEr); - if (TEr->caption) TERegText(TEr, TEr->caption); - TEFree(TEr->caption); // Blank caption - //TEr->caption=NULL; // why doesn't this work in TEFree? -#ifdef JUNK - i=MAX_REGIONS; - do - { - i--; - if (MouseOverTEreg(&TEregs[i])) htext=i; - } while (i>0); - if (htext && TEregs[htext].helptext) TERegText(TEr, TEr->caption); -#endif - } - -static void DrawPalette(TEREGION *TEr) - { - int i,j; - unsigned int width=(TEr->x2)-(TEr->x1); - unsigned int height=(TEr->y2)-(TEr->y1); - int xscale=(width-4)>>6; - int yscale=(height-4)>>2; - int x=(TEr->x1)+TExoffs; - int y=(TEr->y1)+TEyoffs; - TEREGION tempr; - tempr.x1=TEr->x1+2; - tempr.x2=TEr->x2-2; - tempr.y1=TEr->y1+2; - tempr.y2=TEr->y2-2; - - x+=2; - y+=2; - TERegFill(TEr, black); - DrawSunkRegion(TEr); - i=64; - do - { - i--; - FilledBox(x+(i*xscale), y, xscale, yscale, i); - FilledBox(x+(i*xscale), y+yscale, xscale, yscale, i+64); - FilledBox(x+(i*xscale), y+yscale*2, xscale, yscale, i+128); - FilledBox(x+(i*xscale), y+yscale*3, xscale, yscale, i+192); - } while (i>0); - - i=lcolor&63; - j=lcolor>>6; - TEDrawHilight(x+i*xscale, y+j*yscale, xscale, yscale, titlebg); - - i=rcolor&63; - j=rcolor>>6; - TEDrawHilight(x+i*xscale, y+j*yscale, xscale, yscale, titlebg); - - if (MouseOverTEreg(&tempr) && TEr->bitflags®ACTIVE) - { - i=(mx-TExoffs-(tempr.x1))/xscale; - j=(my-TExoffs-(tempr.y1))/yscale; - i+=(j<<6); - j=i*3; - sprintf(TEtempstr, "Color: %03d (rgb: %03d/%03d/%03d)", i, pal[j], pal[j+1], pal[j+2]); - SetCaption(&TEregs[HELPBAR], TEtempstr); - // Handle mouse clicks - if (TEOldReg==TEr) - { - if (MBStatus[0]==MOUSEPRESSED) lcolor=i; - if (MBStatus[1]==MOUSEPRESSED) rcolor=i; - } - } - } - -static void DrawPreview(TEREGION *TEr) - { - char *img; - int i; - TERegFill(TEr, black); - DrawSunkRegion(TEr); -// img=vsp+(256*TEtile); - img=TEimage; - i=tileidx[TEtile]; - if ((TEbitflags&TEANIMATE) && i!=TEtile) img=vsp+(256*i); - CopyTile(TEr->x1+TExoffs+2, TEr->y1+TEyoffs+2, img); - - if (MouseOverTEreg(TEr) && TEr->bitflags®ACTIVE) - { - strcpy(TEtempstr, (TEbitflags&TEANIMATE ? "Click to halt animation" : "Click to animate tile")); - SetCaption(&TEregs[HELPBAR], TEtempstr); - - // Handle mouse clicks - if (TEOldReg==TEr) - if ((MBStatus[0]|MBStatus[1])==MOUSECLICKED && MouseOverTEreg(TEr)) - TEbitflags^=TEANIMATE; - } - } - -static void DrawSColBox(TEREGION *TEr) -// -- ric: 15/Jul/98 - Draw selected colour box - { - int halfwidth=TEr->x2-TEr->x1-4; - int height=TEr->y2-TEr->y1-4; - char DSCBtempcolor; - TERegFill(TEr, black); - DrawSunkRegion(TEr); - FilledBox(TExoffs+2+TEr->x1, TEyoffs+2+TEr->y1, halfwidth, height, titlebg); - height-=2; - halfwidth-=2; - halfwidth>>=1; - FilledBox(TExoffs+3+TEr->x1, TEyoffs+3+TEr->y1, halfwidth, height, lcolor); - FilledBox(TExoffs+3+TEr->x1+halfwidth, TEyoffs+3+TEr->y1, halfwidth, height, rcolor); - - if (MouseOverTEreg(TEr) && TEr->bitflags®ACTIVE) - { - strcpy(TEtempstr, "Click to swap colors"); - SetCaption(&TEregs[HELPBAR], TEtempstr); - - // Handle mouse clicks - if (TEOldReg==TEr) - if ((MBStatus[0]|MBStatus[1])==MOUSECLICKED && MouseOverTEreg(TEr)) - { - DSCBtempcolor=lcolor; - lcolor=rcolor; - rcolor=DSCBtempcolor; - } - } - } - -static void DrawSCTxtBx(TEREGION *TEr) -// -- ric: 15/Jul/98 - Draw selected colour text box - { -// char DSCTBTextBuf[256]; - int i; - int DSCTBx=TEr->x1+TExoffs+2; - int DSCTBy=TEr->y1+TEyoffs+2; - TERegFill(TEr, black); - DrawSunkRegion(TEr); - i=lcolor*3; - sprintf(TEtempstr, "Left: %03d (rgb: %03d/%03d/%03d)", lcolor, pal[i], pal[i+1], pal[i+2]); - GotoXY(DSCTBx, DSCTBy); - printstring(TEtempstr); - i=rcolor*3; - sprintf(TEtempstr, "Right: %03d (rgb: %03d/%03d/%03d)", rcolor, pal[i], pal[i+1], pal[i+2]); - GotoXY(DSCTBx, DSCTBy+7); - printstring(TEtempstr); - } - -static void SetCaption(TEREGION *TEr, char *helptext) - { - TEFree(TEr->caption); - TEr->caption=(char *)strcpy((char *)TEAlloc(strlen(helptext)+1,helptext), helptext); - } - -static void TEDrawHilight(int x1, int y1, int width, int height, unsigned char colour) -// -- ric: 15/Jul/98 - Draws hilight around given rectangle - { - VLine(x1-1, y1, height, colour); - VLine(x1+width, y1, height, colour); - HLine(x1-1, y1-1, width+2, colour); - HLine(x1-1, y1+height, width+2, colour); - } - -static void TEDrawCheckeredBox(int x1, int y1, int width, int height, unsigned char colour) -// -- ric: 17/Jul/98 - Draws a checkered box - { - int i,j; - unsigned char c; - for (j=0; j-1) - FilledBox(TEr->x1+TExoffs, TEr->y1+TEyoffs, (TEr->x2)-(TEr->x1), (TEr->y2)-(TEr->y1), colour); - } - -static void TERegText(TEREGION *TEr, char *message) -// Prints given message in the specified region - { - int tempx, tempy; - tempx=(TEr->x1)+TExoffs+2; - - tempy=(TEr->y2)-(TEr->y1); - tempy>>=1; - tempy+=(TEr->y1)-3; - - GotoXY(tempx,tempy+TEyoffs); - printstring(message); - - } - -static void TEClearImage(void) -// -- ric: 26/Jul/98 - clear selected image - { - int j; - if (TEbitflags&TESHOWMSK) - { - j=TEysize*TExsize; - memcpy(TEundo, TEimage, j); // backup image to undo buffer - do - { - j--; - if (*(TEmask+j)) *(TEimage+j)=rcolor; - } while (j>0); - } - } - -static void TECopyImage(void) -// -- ric: 26/Jul/98 - copy selected image to copy buffer - { - int i, j, TECIxstart, TECIystart, TECIxsize, TECIysize; - if (TEbitflags&TESHOWMSK) // only makes sense if selected region is shown - { - TECIxstart=TExsize; - TECIystart=TEysize; - TECIxsize=-1; - TECIysize=-1; - // loop through image to find the starting and ending x and y coords - // of the image to copy - for (j=0; jTECIxsize) TECIxsize=i; - if (jTECIysize) TECIysize=j; - } - } - - TECIxsize-=TECIxstart-1; - TECIysize-=TECIystart-1; - - if (TECIxsize>0 && TECIysize>0) - { - // free and create TEcopy and TEcmsk buffers - TEFree(TEcopy); - TEFree(TEcmsk); - - // make copy buffer square (allows for rotation) - TEcopyxsize=TECIysize; - TEcopyysize=TECIysize; - if (TECIxsize>TECIysize) - { - TEcopyxsize=TECIxsize; - TEcopyysize=TECIxsize; - } - TEcopy=(char *)TEAlloc(TEcopyxsize*TEcopyysize, "copy buffer"); - TEcmsk=(char *)TEAlloc(TEcopyxsize*TEcopyysize, "copy mask"); - - // copy image into buffer - for (j=0; j0); - } while (j>0); - TEFree(TERILimg); - } - } - -static void TERotateImageClockwise(unsigned char *TERILsrc, int TERILxsize, int TERILysize) -// -- ric: 16/Jul/98 - rotates image (must be square) 90 degrees clockwise - { - unsigned char *TERILimg=NULL; - int i, j, amount; - if (TERILxsize==TERILysize) - { - amount=TERILxsize*TERILysize; - TERILimg=(char *) TEAlloc(amount, "temporary image buffer for TERotateImageClockwise"); - memcpy(TERILimg, TERILsrc, amount); - j=TERILysize; - do - { - j--; - i=TERILxsize; - do - { - i--; - TERILsrc[(j*TERILxsize)+i]=TERILimg[((TERILxsize-1-i)*TERILxsize)+(j)]; - } while (i>0); - } while (j>0); - TEFree(TERILimg); - } - } - -static void TEFlipImage(unsigned char *TERILsrc, int TERILxsize, int TERILysize) -// -- ric: 15/Jul/98 - flips image - { - unsigned char *TERILimg=NULL; - int i, j, amount; - amount=TERILxsize*TERILysize; - TERILimg=(char *) TEAlloc(amount, "temporary image buffer for TEFlipImage"); - memcpy(TERILimg, TERILsrc, amount); - j=TERILysize; - do - { - j--; - i=TERILxsize; - do - { - i--; - TERILsrc[(j*TERILxsize)+i]=TERILimg[((TERILysize-1-j)*TERILxsize)+i]; - } while (i>0); - } while (j>0); - TEFree(TERILimg); - } - -static void TEMirrorImage(unsigned char *TERILsrc, int TERILxsize, int TERILysize) -// -- ric: 15/Jul/98 - mirrors image - { - unsigned char *TERILimg=NULL; - int i, j, amount; - amount=TERILxsize*TERILysize; - TERILimg=(char *) TEAlloc(amount, "temporary image buffer for TEMirrorImage"); - memcpy(TERILimg, TERILsrc, amount); - j=TERILysize; - do - { - j--; - i=TERILxsize; - do - { - i--; - TERILsrc[(j*TERILxsize)+i]=TERILimg[(j*TERILxsize)+(TERILxsize-1-i)]; - } while (i>0); - } while (j>0); - TEFree(TERILimg); - } - -static void TEFillImage(char *TEFIimage, char *TEFImask, int TEFIxsize, int TEFIysize, int TEFIx, int TEFIy, char TEFIcolour) -// -- ric: 29/Jul/98 - Fill procedure - sets up and calls recursive procedure below - { - int i,j; - unsigned char *TEFIfillmask=NULL; // will eventually contain 0 for ignore and 1 for fill - TEFIfillmask=(char *) TEAlloc(TEFIxsize*TEFIysize, "temporary fill buffer for TEFillImage"); - TERFillImage(TEFIimage, TEFIfillmask, TEFIxsize, TEFIysize, TEFIx, TEFIy); - - if (TEFImask) - for (j=0; j=0 && x=0 && y=0 && x=0 && y=0 && x=0 && y=0 && x=0 && y0); - } while (j>0); - } - - -static void TEUndo (void) - { - unsigned char *tempimg=TEimage; - TEimage=TEundo; - TEundo=tempimg; - } - -static void *TEAlloc(unsigned long amount, char *whatfor) -// -- ric: 14/Jul/98 - TE's custom, error-handling memory allocation routine - { - char *TETmpBuf=NULL; - - amount += 3; // aen - amount &= ~3; - -// static char DebugBuf[256]; - TETmpBuf=(char *) malloc(amount); - if (!TETmpBuf) - { - sprintf(TEtempstr, "Unable to allocate %ld bytes for %s.", amount, whatfor); - err(TEtempstr); - } - memset(TETmpBuf,0, amount); // Clear allocated mem - /* - __asm { // aen - mov edi,TETmpBuf - mov ecx,amount - shr ecx,2 - xor eax,eax - cld - rep stosd - } ; - */ - return TETmpBuf; - } - -#ifdef JUNK -static void TEFree(void *TETmpBuf) -// -- ric: 14/Jul/98 - TE's custom memory freeing routine - { - if (TETmpBuf) free(TETmpBuf); // Only free memory if previously allocated - TETmpBuf=NULL; // Set freed memory to point to NULL - } -#endif - -static void MBClickHandler(TEREGION *TEBaseReg) -// -- ric: 20/Jul/98 - Mouse button click handler - { - int i,j; - ReadMouse(); - if (TEBaseReg) - { - if (!TEBaseReg->data) err("No region data defined."); - if (((struct DATABASEREGION *)TEBaseReg->data)->infotype!=DITBASEREGION) - err("MBClickHandler called with invalid base region."); - } - - for (i=0; i<3; ++i) - { - if (mb & (i+1)) - { - if (MBStatus[i] == MOUSECLICKED) - MBStatus[i]=MOUSEPRESSED; - else if (MBStatus[i] == MOUSENONE) - { - MBStatus[i] = MOUSECLICKED; - if (TEBaseReg) - { - TEOldReg = NULL; - for (j=0; j<((struct DATABASEREGION *)TEBaseReg->data)->numofregs; ++j) - if (MouseOverTEreg(TEBaseReg+j)&&!((TEBaseReg+j)->bitflags®NOCLICK)) - TEOldReg = TEBaseReg+j; - } - } - } - else - { - if (MBStatus[i] <= MOUSERELEASE) - MBStatus[i] = MOUSENONE; - else if (MBStatus[i]>MOUSERELEASE) - MBStatus[i] = MOUSERELEASE; - } - } - } - -static void AboutTE (void) -// Just here to test the mouse input loop - remove this later - { - TEREGION *TEr=NULL; - TEREGION *TEaboutwin=NULL; -// int amxsize=150, amysize=82; - int amxofs=60, amyofs=60; - int i,i2,j,j2; - int QuitAW=FALSE; - int moving=FALSE; - - // Allocate memory - TEaboutwin=(struct TEREGION *) TEAlloc((sizeof (struct TEREGION))*4,"about window regions"); - TEr=TEaboutwin; - TEr->infotype=DITREGION; - TEr->x1=amxofs; - TEr->x2=TEr->x1+150; - TEr->y1=amyofs; - TEr->y2=TEr->y1+82; - TEr->bitflags=REGACTIVE|REGVISIBLE|REGNOCLICK; -// TEr->drawproc=NULL; - sprintf(strbuf, "About MapEd %s Tile Editor", ME2_VERSION); - TEr->caption=TENewText(strbuf, "About window"); - TEr->data=(struct DATABASEREGION *) TEAlloc(sizeof (struct DATABASEREGION), "base region data"); - ((struct DATABASEREGION *)(TEr->data))->infotype=DITBASEREGION; - ((struct DATABASEREGION *)(TEr->data))->numofregs=4; - ((struct DATABASEREGION *)(TEr->data))->windowtype=DBRSTDWINDOW; - - TEr+=1; - TEr->infotype=DITREGION; - TEr->x1=0; - TEr->x2=TEaboutwin->x2-TEaboutwin->x1-9; - TEr->y1=0; - TEr->y2=8; - TEr->bitflags=REGACTIVE; -// TEr->drawproc=NULL; -// TEr->caption=NULL; - - TEr+=1; - TEr->infotype=DITREGION; - TEr->x1=TEaboutwin->x2-TEaboutwin->x1-9; - TEr->x2=TEaboutwin->x2-TEaboutwin->x1-3; - TEr->y1=3; - TEr->y2=6; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; -// TEr->caption=NULL; - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "quit button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=NULL; - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&QuitAW; - ((struct DATABUTTON *)(TEr->data))->bitvalue=TRUE; - - TEr+=1; - TEr->infotype=DITREGION; - TEr->x1=60; - TEr->x2=90; - TEr->y1=62; - TEr->y2=72; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=TENewText("ok","ok button caption"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "quit button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=NULL; - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&QuitAW; - ((struct DATABUTTON *)(TEr->data))->bitvalue=TRUE; - TEr=TEaboutwin+1; // point to title bar area - - while (!QuitAW) - { - // Mouse button click handler routines - MBClickHandler(TEaboutwin); - - amxofs=TEaboutwin->x1; - amyofs=TEaboutwin->y1; - if ((MBStatus[0]|MBStatus[1])==MOUSERELEASE) - moving=FALSE; - - // Draw loop - RenderTileEdit(TEregs); - RenderTileEdit(TEaboutwin); - - sprintf(strbuf, "MapEd v.%s", ME2_VERSION); - GotoXY(amxofs+52, amyofs+16); printstring(strbuf); - GotoXY(amxofs+31, amyofs+22); printstring("Copyright (C) 1998 vecna"); - GotoXY(amxofs+40, amyofs+28); printstring("All Rights Reserved"); - sprintf(strbuf, "MapEd v.%s Tile Editor", ME2_VERSION); - GotoXY(amxofs+29, amyofs+41); printstring(strbuf); - GotoXY(amxofs+20, amyofs+47); printstring("Additional code by Richard Lau"); - DrawMouse(); - ShowPage(); - - // Move window? - if (MouseOverTEreg(TEr) && TEOldReg==TEr) - { - if ((MBStatus[0]|MBStatus[1])==MOUSECLICKED) - { - i2=TEaboutwin->x2-TEaboutwin->x1; - j2=TEaboutwin->y2-TEaboutwin->y1; - i=mx-TEaboutwin->x1; - j=my-TEaboutwin->y1; - moving=TRUE; - } - } - if ((MBStatus[0]|MBStatus[1])==MOUSEPRESSED && moving) - { - if (((mx-i)<16)) TEaboutwin->x1=16; - else if (((mx-i+i2)>=(16+sx))) TEaboutwin->x1=16+(sx-i2); - else TEaboutwin->x1=mx-i; - if (((my-j)<16)) TEaboutwin->y1=16; - else if (((my-j+j2)>=(16+sy))) TEaboutwin->y1=16+(sy-j2); - else TEaboutwin->y1=my-j; - TEaboutwin->x2=TEaboutwin->x1+i2; - TEaboutwin->y2=TEaboutwin->y1+j2; - } - - if (key[SCAN_ESC]) - { - key[SCAN_ESC]=0; - QuitAW=TRUE; - } - - } - // free TEaboutwin - TEFreeReg(TEaboutwin); - } - -static void RestartTileEditor(void) -// -- ric: 17/Jul/98 - reinit the tile editor - { - int i,j, amount; - unsigned char *TERTEmask=NULL; - - switch (TEtype) - { - case TETILE: // edit tile TEtile - i=TExsize; - j=TEysize; - amount=i*j; - TERTEmask=(unsigned char *) TEAlloc(amount, "tile editor mask backup buffer"); - - // backup mask - memcpy(TERTEmask, TEmask, amount); - - // Restart editor - DeinitTEImage(); - TEFreeReg(TEregs); - TEtype=TETILE; - TExsize=i; - TEysize=j; - TEsource=vsp+(256*TEtile); - InitTEImage(); - SetupRegions(); - - // Restore mask - memcpy(TEmask, TERTEmask, amount); - TEFree(TERTEmask); - break; - } - } - -static void InitTEImage (void) -// Copy the image data being edited and allocate memory for the image buffers - { - int i; - int amount=TExsize*TEysize; - if (TEtype==TEUNKNOWN) err("Unrecognised tile editor graphics type."); - if (!TEsource) err("Invalid input image."); - TEimage=(unsigned char *) TEAlloc(amount, "tile editor image buffer"); - TEmask=(unsigned char *) TEAlloc(amount, "tile editor mask buffer"); - TEundo=(unsigned char *) TEAlloc(amount, "tile editor undo buffer"); -// if (!TEimage || !TEundo) err("Cannot allocate memory for tile editor image buffers."); - memcpy(TEimage, TEsource, amount); // copy original image into edit buffer - memcpy(TEundo, TEimage, amount); // copy original image into undo buffer - - // if editing tile find the animation strand (if any) tile belongs to - TEanimstrand=0; // Does not belong to an animation strand - if (TEtype==TETILE) - { - i=100; - do - { - i--; - if (vspanim[i].delay && TEtile<=vspanim[i].finish && TEtile>=vspanim[i].start) - TEanimstrand=i+1; - } while (i>0); - } - } - -static void DeinitTEImage(void) -// Unallocate allocated image buffers - copy edited buffer into original - { - memcpy(TEsource, TEimage, (TExsize*TEysize)); - TEFree(TEimage); - TEFree(TEmask); - TEFree(TEundo); - TEtype=TEUNKNOWN; // Clear type info for error checking purposes - TExsize=0; - TEysize=0; - } - -static void SetupRegions (void) - { - int temp; - TEREGION *TEr=NULL; - - // Allocate memory - TEregs=(struct TEREGION *) TEAlloc((sizeof (struct TEREGION))*MAX_REGIONS,"tile edit regions"); - - TEr=TEregs+BASEREG; - TEr->infotype=DITREGION; - TEr->x1=16; - TEr->x2=TEr->x1+sx; - TEr->y1=16; - TEr->y2=TEr->y1+sy; - TEr->bitflags=REGACTIVE|REGVISIBLE|REGNOCLICK; - TEr->drawproc=NULL; - TEr->caption=NULL; - switch (TEtype) - { - case TETILE: - sprintf(TEtempstr, "MapEd %s Tile Editor - Tile: %d", ME2_VERSION, TEtile); - if (TEanimstrand) - sprintf(TEtempstr, "MapEd %s Tile Editor - Tile: %d (anim strand: %d, frame: %d/%d)", - ME2_VERSION, - TEtile, TEanimstrand-1, TEtile-vspanim[TEanimstrand-1].start+1, - vspanim[TEanimstrand-1].finish-vspanim[TEanimstrand-1].start+1); - SetCaption(TEr, TEtempstr); - break; - } - TEr->data=(struct DATABASEREGION *) TEAlloc(sizeof (struct DATABASEREGION), "base region data"); - ((struct DATABASEREGION *)(TEr->data))->infotype=DITBASEREGION; - ((struct DATABASEREGION *)(TEr->data))->numofregs=MAX_REGIONS; - ((struct DATABASEREGION *)(TEr->data))->windowtype=DBRSTDWINDOW; - - TEr=TEregs+HELPBAR; - TEr->infotype=DITREGION; - TEr->x1=3; - TEr->x2=TEregs->x2-TEregs->x1-3; - TEr->y1=TEregs->y2-TEregs->y1-13; - TEr->y2=TEregs->y2-TEregs->y1-3; - TEr->bitflags=REGACTIVE|REGVISIBLE|REGNOCLICK; - TEr->drawproc=&DrawHelpBar; - TEr->caption=NULL; - TEr->data=NULL; - - temp=(((TEregs->x2-TEregs->x1-8)>>6)<<5)+2; - TEr=TEregs+PALETTE; - TEr->infotype=DITREGION; - TEr->x1=((TEregs->x2-TEregs->x1)>>1)-temp; - TEr->x2=((TEregs->x2-TEregs->x1)>>1)+temp; - TEr->y1=TEregs->y2-TEregs->y1-36; - TEr->y2=TEregs->y2-TEregs->y1-16; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawPalette; - TEr->caption=NULL; - TEr->data=NULL; - - TEr=TEregs+EDITREG; - TEr->infotype=DITREGION; - TEr->x1=3; - TEr->x2=3+128+4; - TEr->y1=10; - TEr->y2=10+128+4; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawEditReg; - TEr->caption=NULL; - TEr->data=(struct DATAEDITREG *) TEAlloc(sizeof (struct DATAEDITREG), "edit region data"); - ((struct DATAEDITREG *)(TEr->data))->infotype=DITEDITREG; - - TEr=TEregs+PREVIEW; - TEr->infotype=DITREGION; - TEr->x1=TEregs->x2-TEregs->x1-23; - TEr->x2=TEregs->x2-TEregs->x1-3; - TEr->y1=10; - TEr->y2=10+20; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawPreview; - TEr->caption=NULL; - TEr->data=NULL; - - TEr=TEregs+SCOLBOX; - TEr->infotype=DITREGION; - TEr->x1=TEregs[EDITREG].x1; - TEr->x2=TEr->x1+20; - TEr->y1=TEregs[EDITREG].y2+2; - TEr->y2=TEr->y1+16; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawSColBox; - TEr->caption=NULL; - TEr->data=NULL; - - TEr=TEregs+SCTXTBX; - TEr->infotype=DITREGION; - TEr->x1=TEregs[SCOLBOX].x2+2; - TEr->x2=TEregs[EDITREG].x2; - TEr->y1=TEregs[SCOLBOX].y1; - TEr->y2=TEregs[SCOLBOX].y2; - TEr->bitflags=REGACTIVE|REGVISIBLE|REGNOCLICK; - TEr->drawproc=&DrawSCTxtBx; - TEr->caption=NULL; - TEr->data=NULL; - - TEr=TEregs+QUITBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs->x2-TEregs->x1-9; - TEr->x2=TEregs->x2-TEregs->x1-3; - TEr->y1=3; - TEr->y2=6; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "quit button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Exit", "quit button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbitflags; - ((struct DATABUTTON *)(TEr->data))->bitvalue=TEQUITCUR; - - TEr=TEregs+EDMDFRM; - TEr->infotype=DITREGION; - TEr->x1=TEregs[EDITREG].x2+3; - TEr->x2=TEr->x1+34; - TEr->y1=TEregs[EDITREG].y1; - TEr->y2=TEr->y1+11*5+3; // 10*number of buttons - TEr->bitflags=REGACTIVE|REGVISIBLE|REGNOCLICK; - TEr->drawproc=&DrawSunkRegion; - TEr->caption=NULL; - TEr->data=NULL; - - TEr=TEregs+DRAWBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[EDMDFRM].x1+2; - TEr->x2=TEregs[EDMDFRM].x2-2; - TEr->y1=TEregs[EDMDFRM].y1+2; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"Draw"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "draw button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Draw mode", "draw button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=RADIOBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEeditmode; - ((struct DATABUTTON *)(TEr->data))->bitvalue=EDDRAW; - - TEr=TEregs+FILLBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[EDMDFRM].x1+2; - TEr->x2=TEregs[EDMDFRM].x2-2; - TEr->y1=TEregs[EDMDFRM].y1+2+11; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"Fill"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "fill button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Fill mode", "fill button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=RADIOBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEeditmode; - ((struct DATABUTTON *)(TEr->data))->bitvalue=EDFILL; - - TEr=TEregs+PICKBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[EDMDFRM].x1+2; - TEr->x2=TEregs[EDMDFRM].x2-2; - TEr->y1=TEregs[EDMDFRM].y1+2+22; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"Pick"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "pick button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Pick color mode", "pick button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=RADIOBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEeditmode; - ((struct DATABUTTON *)(TEr->data))->bitvalue=EDPICK; - - TEr=TEregs+MASKBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[EDMDFRM].x1+2; - TEr->x2=TEregs[EDMDFRM].x2-2; - TEr->y1=TEregs[EDMDFRM].y1+2+33; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"Select"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "select button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Select mode", "select button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=RADIOBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEeditmode; - ((struct DATABUTTON *)(TEr->data))->bitvalue=EDMASK; - - TEr=TEregs+PSTEBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[EDMDFRM].x1+2; - TEr->x2=TEregs[EDMDFRM].x2-2; - TEr->y1=TEregs[EDMDFRM].y1+2+44; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"Paste"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "paste button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Paste mode", "paste button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=RADIOBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEeditmode; - ((struct DATABUTTON *)(TEr->data))->bitvalue=EDPASTE; - - TEr=TEregs+IND_FRM; - TEr->infotype=DITREGION; - TEr->x1=TEregs[SCTXTBX].x2+2; - TEr->x2=TEr->x1+12*4-1; // 10*number of buttons - TEr->y1=TEregs[SCTXTBX].y1; - TEr->y2=TEr->y1+13; - TEr->bitflags=REGACTIVE|REGVISIBLE|REGNOCLICK; - TEr->drawproc=&DrawSunkRegion; - TEr->caption=NULL; - TEr->data=NULL; - - TEr=TEregs+MASKIND; - TEr->infotype=DITREGION; - TEr->x1=TEregs[IND_FRM].x1+2; - TEr->x2=TEr->x1+10; - TEr->y1=TEregs[IND_FRM].y1+2; - TEr->y2=TEregs[IND_FRM].y2-2; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"m"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "mask indicator data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("mask", "mask indicator text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=PUSHBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbitflags; - ((struct DATABUTTON *)(TEr->data))->bitvalue=TESHOWMSK; - - TEr=TEregs+GRIDIND; - TEr->infotype=DITREGION; - TEr->x1=TEregs[MASKIND].x2+1; - TEr->x2=TEr->x1+10; - TEr->y1=TEregs[IND_FRM].y1+2; - TEr->y2=TEregs[IND_FRM].y2-2; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"g"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "grid button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("grid", "grid indicator text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=PUSHBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbitflags; - ((struct DATABUTTON *)(TEr->data))->bitvalue=TEGRID; - - TEr=TEregs+ANIMIND; - TEr->infotype=DITREGION; - TEr->x1=TEregs[GRIDIND].x2+1; - TEr->x2=TEr->x1+10; - TEr->y1=TEregs[IND_FRM].y1+2; - TEr->y2=TEregs[IND_FRM].y2-2; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"a"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "animation button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("animation", "animation indicator text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=PUSHBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbitflags; - ((struct DATABUTTON *)(TEr->data))->bitvalue=TEANIMATE; - - TEr=TEregs+PXHLIND; - TEr->infotype=DITREGION; - TEr->x1=TEregs[ANIMIND].x2+1; - TEr->x2=TEr->x1+10; - TEr->y1=TEregs[IND_FRM].y1+2; - TEr->y2=TEregs[IND_FRM].y2-2; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr,"h"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "highlight button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("pixel highlight", "highlight indicator text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=PUSHBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbitflags; - ((struct DATABUTTON *)(TEr->data))->bitvalue=TEHILIGHT; - - TEr=TEregs+BUT_FRM; - TEr->infotype=DITREGION; - TEr->x1=TEregs[EDMDFRM].x1; - TEr->x2=TEregs[EDMDFRM].x2; - TEr->y1=TEregs[EDMDFRM].y2+2; - TEr->y2=TEr->y1+11*4+3; // 10*number of buttons - TEr->bitflags=REGACTIVE|REGVISIBLE|REGNOCLICK; - TEr->drawproc=&DrawSunkRegion; - TEr->caption=NULL; - TEr->data=NULL; - - TEr=TEregs+UNDOBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[BUT_FRM].x1+2; - TEr->x2=TEregs[BUT_FRM].x2-2; - TEr->y1=TEregs[BUT_FRM].y1+2; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr, "Undo"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "undo button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Undo last action", "undo button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbfa; - ((struct DATABUTTON *)(TEr->data))->bitvalue=BFAUNDO; - - TEr=TEregs+COPYBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[BUT_FRM].x1+2; - TEr->x2=TEregs[BUT_FRM].x2-2; - TEr->y1=TEregs[BUT_FRM].y1+2+11; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr, "Copy"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "copy button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Copy selected area", "copy button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbfa; - ((struct DATABUTTON *)(TEr->data))->bitvalue=BFACOPY; - - TEr=TEregs+CUT_BUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[BUT_FRM].x1+2; - TEr->x2=TEregs[BUT_FRM].x2-2; - TEr->y1=TEregs[BUT_FRM].y1+2+22; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr, "Cut"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "cut button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Cut selected area", "cut button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbfa; - ((struct DATABUTTON *)(TEr->data))->bitvalue=BFACUT; - - TEr=TEregs+CLR_BUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[BUT_FRM].x1+2; - TEr->x2=TEregs[BUT_FRM].x2-2; - TEr->y1=TEregs[BUT_FRM].y1+2+33; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr, "Clear"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "clear button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Clear selected area", "clear button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbfa; - ((struct DATABUTTON *)(TEr->data))->bitvalue=BFACLEAR; - - TEr=TEregs+TOOLFRM; - TEr->infotype=DITREGION; - TEr->x1=TEregs[BUT_FRM].x2+2; - TEr->x2=TEr->x1+34; - TEr->y1=TEregs[BUT_FRM].y1; - TEr->y2=TEr->y1+11*4+3; // 10*number of buttons - TEr->bitflags=REGACTIVE|REGVISIBLE|REGNOCLICK; - TEr->drawproc=&DrawSunkRegion; - TEr->caption=NULL; - TEr->data=NULL; - - TEr=TEregs+RIACBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[TOOLFRM].x1+2; - TEr->x2=TEregs[TOOLFRM].x2-2; - TEr->y1=TEregs[TOOLFRM].y1+2; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr, "Turn L"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "rotate button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Rotate anticlockwise", "rotate button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbfa; - ((struct DATABUTTON *)(TEr->data))->bitvalue=BFARIAC; - - TEr=TEregs+RIC_BUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[TOOLFRM].x1+2; - TEr->x2=TEregs[TOOLFRM].x2-2; - TEr->y1=TEregs[TOOLFRM].y1+2+11; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr, "Turn R"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "rotate button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Rotate clockwise", "rotate button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbfa; - ((struct DATABUTTON *)(TEr->data))->bitvalue=BFARIC; - - TEr=TEregs+FLIPBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[TOOLFRM].x1+2; - TEr->x2=TEregs[TOOLFRM].x2-2; - TEr->y1=TEregs[TOOLFRM].y1+2+22; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr, "Flip"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "flip button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Flip", "flip button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbfa; - ((struct DATABUTTON *)(TEr->data))->bitvalue=BFAFLIP; - - TEr=TEregs+MIRRBUT; - TEr->infotype=DITREGION; - TEr->x1=TEregs[TOOLFRM].x1+2; - TEr->x2=TEregs[TOOLFRM].x2-2; - TEr->y1=TEregs[TOOLFRM].y1+2+33; - TEr->y2=TEr->y1+10; - TEr->bitflags=REGACTIVE|REGVISIBLE; - TEr->drawproc=&DrawButton; - TEr->caption=NULL; - SetCaption(TEr, "Mirror"); - TEr->data=(struct DATABUTTON *) TEAlloc(sizeof (struct DATABUTTON), "mirror button data"); - ((struct DATABUTTON *)(TEr->data))->infotype=DITBUTTON; - ((struct DATABUTTON *)(TEr->data))->text=TENewText("Mirror", "mirror button text"); - ((struct DATABUTTON *)(TEr->data))->buttontype=CLICKBUTTON; - ((struct DATABUTTON *)(TEr->data))->bitflag=&TEbfa; - ((struct DATABUTTON *)(TEr->data))->bitvalue=BFAMIRROR; - - } - -static void DestroyRegions (TEREGION **TEBaseReg) - { - TEREGION *TEr=NULL; - int i; - if (!(*TEBaseReg)->data) err("No region data defined."); - if (((struct DATABASEREGION *)(*TEBaseReg)->data)->infotype!=DITBASEREGION) - err("DestroyRegions called with invalid base region."); - - i=((struct DATABASEREGION *)(*TEBaseReg)->data)->numofregs; - do - { - i--; - TEr=(*TEBaseReg)+i; - TEFree(TEr->caption); - if (TEr->data) - { - switch (((struct DATABASEREGION *)(TEr->data))->infotype) - { - case DITBASEREGION: - break; - case DITBUTTON: - TEFree(((struct DATABUTTON *)TEr->data)->text); - break; - } - } - TEFree(TEr->data); - } while (i>0); - TEFree(*TEBaseReg); -// if (*TEBaseReg) err("Not freed"); - } - -static void RenderTileEdit (TEREGION *TEBaseReg) -// -- ric: 20/Jul/98 - updatedt to be a little more generic ;) - { - int i; - TExoffs=TEBaseReg->x1; - TEyoffs=TEBaseReg->y1; - if (!TEBaseReg->data) err("No region data defined."); - if (((struct DATABASEREGION *)TEBaseReg->data)->infotype!=DITBASEREGION) - err("RenderTileEdit called with invalid base region."); - switch (((struct DATABASEREGION *)TEBaseReg->data)->windowtype) - { - case DBRSTDWINDOW: - Window(TExoffs,TEyoffs,TEBaseReg->x2,TEBaseReg->y2, ((TEBaseReg->caption) ? TEBaseReg->caption : "")); - break; - case DBRPANEL: - stdwindow(TExoffs,TEyoffs,TEBaseReg->x2,TEBaseReg->y2); - break; - } - - i=((struct DATABASEREGION *)TEBaseReg->data)->numofregs; - do - { - i--; - if ((TEBaseReg+i)->bitflags®VISIBLE) (TEBaseReg+i)->drawproc(TEBaseReg+i); - } while (i>1); - } - -void TileEdit (void) - { - int i,j; - int TEoldeditmode=EDDRAW; - if (TEbitflags&TEQUITCUR) TEbitflags^=TEQUITCUR; - - InitTEImage(); - SetupRegions(); - TEeditmode=EDDRAW; // Default to drawing mode - if (TEbitflags&TESHOWMSK) TEbitflags^=TESHOWMSK; - - while (!(TEbitflags&TEQUITCUR)) - { - // Mouse button click handler routines - MBClickHandler(TEregs); - - TEbfa=BFANONE; // Reset button action flag - if (TEeditmode==EDMASK && TEoldeditmode!=EDMASK) TEbitflags|=TESHOWMSK; - if (TEeditmode==EDMASK && TEoldeditmode==EDMASK && !(TEbitflags&TESHOWMSK)) - TEeditmode=EDDRAW; - TEoldeditmode=TEeditmode; - - // Draw loop - RenderTileEdit(TEregs); - DrawMouse(); - ShowPage(); - - if (key[SCAN_ESC]) - { - key[SCAN_ESC]=0; - TEbitflags|=TEQUITCUR; - } - if ((key[SCAN_CTRL] && key[SCAN_Z]) || (TEbfa&BFAUNDO) || (key[SCAN_U] && !(key[SCAN_CTRL])) && ((MBStatus[0]|MBStatus[1])==MOUSENONE)) - { - key[SCAN_U]=0; - key[SCAN_Z]=0; - TEUndo(); - } - if (key[SCAN_CTRL] && key[SCAN_R]) - { - key[SCAN_R]=0; - memcpy(TEundo, TEimage, TExsize*TEysize); // copy image into undo buffer - memcpy(TEimage, TEsource, TExsize*TEysize); // copy original image into edit buffer - } - if (key[SCAN_CTRL] && key[SCAN_A]) - { - key[SCAN_A]=0; - j=TEysize*TExsize; - memset(TEmask, 0xf, j); - } - if (key[SCAN_CTRL] && key[SCAN_U]) - { - key[SCAN_U]=0; - j=TEysize*TExsize; - memset(TEmask, 0x0, j); - } - if ((TEbfa&BFACOPY) || (key[SCAN_CTRL] && key[SCAN_C]) && ((MBStatus[0]|MBStatus[1])==MOUSENONE)) - { - key[SCAN_C]=0; - TECopyImage(); - } - if ((TEbfa&BFACUT) || (key[SCAN_CTRL] && key[SCAN_X]) && ((MBStatus[0]|MBStatus[1])==MOUSENONE)) - { - key[SCAN_X]=0; - TECopyImage(); - TEClearImage(); - } - if (key[SCAN_CTRL] && key[SCAN_V] && ((MBStatus[0]|MBStatus[1])==MOUSENONE)) - { - key[SCAN_V]=0; - TEeditmode=EDPASTE; - } - if ((TEbfa&BFACLEAR) || key[SCAN_DEL] && ((MBStatus[0]|MBStatus[1])==MOUSENONE)) - { - key[SCAN_DEL]=0; - TEClearImage(); - } - if (key[SCAN_Q] && ((MBStatus[0]|MBStatus[1])==MOUSENONE)) - { - key[SCAN_Q]=0; - if (TEtype==TETILE && TEanimstrand) - { - if (TEtile>vspanim[TEanimstrand-1].start) - { - // Change tile index - TEtile-=1; - i=TExsize; - j=TEysize; - - // Restart editor - RestartTileEditor(); - } - } - } - if (key[SCAN_W] && ((MBStatus[0]|MBStatus[1])==MOUSENONE)) - { - key[SCAN_W]=0; - if (TEtype==TETILE && TEanimstrand) - { - if (TEtile0); - } - if (key[SCAN_M]) - { - key[SCAN_M]=0; - if (TEeditmode==EDMASK) - TEeditmode=EDDRAW; - TEbitflags^=TESHOWMSK; - } - if (key[SCAN_SPACE]) - { - key[SCAN_SPACE]=0; - if (TEeditmode==EDDRAW) - { - TEeditmode=EDMASK; - TEbitflags|=TESHOWMSK; - } - else - TEeditmode=EDDRAW; - } - if (key[SCAN_PGUP]) - { - key[SCAN_PGUP]=0; - switch (TEeditmode) - { - case EDDRAW: - case EDMASK: - memcpy(TEundo, TEimage, TExsize*TEysize); - if (TEbitflags&TESHOWMSK) - TEShiftColours(TEimage, TEmask, TExsize, TEysize, 1); - else - TEShiftColours(TEimage, NULL, TExsize, TEysize, 1); - break; - case EDPASTE: - if (TEcopy) - TEShiftColours(TEcopy, TEcmsk, TEcopyxsize, TEcopyysize, 1); - break; - } - } - if (key[SCAN_PGDN]) - { - key[SCAN_PGDN]=0; - switch (TEeditmode) - { - case EDDRAW: - case EDMASK: - memcpy(TEundo, TEimage, TExsize*TEysize); - if (TEbitflags&TESHOWMSK) - TEShiftColours(TEimage, TEmask, TExsize, TEysize, -1); - else - TEShiftColours(TEimage, NULL, TExsize, TEysize, -1); - break; - case EDPASTE: - if (TEcopy) - TEShiftColours(TEcopy, TEcmsk, TEcopyxsize, TEcopyysize, -1); - break; - } - } - - if (key[SCAN_LANGLE]) - { - key[SCAN_LANGLE]=0; - ShutdownVideo(); - TEFreeReg(TEregs); - vm=0; - InitVideo(0); - SetupRegions(); - set_intensity(63); - InitMouse(); - } - if (key[SCAN_RANGLE]) - { - key[SCAN_RANGLE]=0; - ShutdownVideo(); - TEFreeReg(TEregs); - vm=1; - InitVideo(1); - SetupRegions(); - set_intensity(63); - InitMouse(); - } - } - DeinitTEImage(); - TEFreeReg(TEregs); - } diff --git a/16/v2/source/verge/MAPED/TILEED.H b/16/v2/source/verge/MAPED/TILEED.H deleted file mode 100755 index 11419f6a..00000000 --- a/16/v2/source/verge/MAPED/TILEED.H +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef TILEED_INC -#define TILEED_INC - -// TEtype defs -#define TEUNKNOWN 0 -#define TETILE 1 - -// external functions -extern void TileEdit(void); - -// external variables -extern unsigned int TEtype; // type of graphic being edited -extern unsigned int TEtile; // tile to edit - may possibly expand this to an array for simultaneous editing -extern unsigned int TExsize; // width of graphic being edited -extern unsigned int TEysize; // height of graphic being edited -extern unsigned char *TEsource; // pointer to original image being edited - -#endif diff --git a/16/v2/source/verge/MAPED/TILESEL.C b/16/v2/source/verge/MAPED/TILESEL.C deleted file mode 100755 index 834ad9d7..00000000 --- a/16/v2/source/verge/MAPED/TILESEL.C +++ /dev/null @@ -1,1448 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include "config.h" -#include "keyboard.h" -#include "maped.h" -#include "mouse.h" -#include "render.h" -#include "tileed.h" -#include "timer.h" -#include "vdriver.h" - -#include "smalfont.h" -#include "guicomp.h" -#include "gui.h" - -extern byte TileCmp(byte *one, byte *two); //zero - -// ================================= Data ==================================== - -int selofs=0; -char ttile[256], ttile2[256]; -char curastd=0; -char curmode=0; - -// ================================= Code ==================================== - -int curtileptr(int row) -{ - int jumper,wide; - int x,y; - - jumper=16+pad; - wide=320/jumper; - - x=(mx-16)/jumper; - y=((my-16)/jumper)*wide; - - return x+y+row; -} - -void NormalButton(int x1, int y1, int x2, int y2, char *str) -{ - FilledBox(x1, y1, x2, y2, winbg); - HLine(x1, y1, x2, black); - VLine(x1, y1, y2, black); - HLine(x1+1, y1+y2-1, x2-1, black); - VLine(x1+x2-1, y1+1, y2-1, black); - - HLine(x1+1, y1+1, x2-2, brightw); - VLine(x1+1, y1+1, y2-2, brightw); - HLine(x1+2, y1+y2-2, x2-3, darkw); - VLine(x1+x2-2, y1+2, y2-3, darkw); - GotoXY(x1+((x2-pixels(str))/2), y1+3); - printstring(str); -} - -void PressdButton(int x1, int y1, int x2, int y2, char *str) -{ - FilledBox(x1, y1, x2, y2, winbg); - HLine(x1, y1, x2, black); - VLine(x1, y1, y2, black); - HLine(x1+1, y1+y2-1, x2-1, black); - VLine(x1+x2-1, y1+1, y2-1, black); - - HLine(x1+1, y1+1, x2-2, darkw); - VLine(x1+1, y1+1, y2-2, darkw); - GotoXY(x1+((x2-pixels(str))/2)+1, y1+4); - printstring(str); -} - -void RenderSelector() -{ unsigned char *img,i,j; - int z; - int tskip=16+pad; - int twide=320/tskip; - int tdeep=((200+15)&~15)/tskip; - - ClearScreen(); - - for (i=0; i=numtiles) img=vsp; - CopyTile((j*tskip)+16,(i*tskip)+16,img); - } - if (th) - { - if (my<(tsy-40)) - DrawHighlight( ((mx/tskip)*tskip)-(1+pad), - ((my/tskip)*tskip)-(1+pad)); - } - z=tsy-40; - sprintf(strbuf,"MapEd %s Tile Selector - Tile %d/%d",ME2_VERSION,curtileptr(selofs),numtiles); - Window(16,z,336,z+40,strbuf); - HLine(278, z+11, 53, darkw); - VLine(278, z+11, 25, darkw); - VLine(330, z+12, 24, brightw); - HLine(279, z+35, 51, brightw); - if (curmode==0) PressdButton(290, z+12, 40, 12, "Select"); - else NormalButton(290, z+12, 40, 12, "Select"); - if (curmode==1) PressdButton(290, z+23, 40, 12, "Edit"); - else NormalButton(290, z+23, 40, 12, "Edit"); - if (th) PressdButton(279, z+12, 12, 12, "H"); - else NormalButton(279, z+12, 12, 12, "H"); - if (pad) PressdButton(279, z+23, 12, 12, "P"); - else NormalButton(279, z+23, 12, 12, "P"); - - HLine(219, z+11, 52, darkw); - VLine(219, z+11, 25, darkw); - VLine(270, z+12, 24, brightw); - HLine(220, z+35, 50, brightw); - NormalButton(220, z+12, 50, 12, "Import VSP"); - NormalButton(220, z+23, 50, 12, "Import PCX"); - - HLine(160, z+11, 52, darkw); - VLine(160, z+11, 25, darkw); - VLine(211, z+12, 24, brightw); - HLine(161, z+35, 50, brightw); - NormalButton(161, z+12, 50, 12, "Add Tiles"); - NormalButton(161, z+23, 50, 12, "Animation"); - - HLine(26, z+10, 20, darkw); - VLine(26, z+10, 20, darkw); - HLine(27, z+29, 19, brightw); - VLine(45, z+11, 19, brightw); - FilledBox(27, z+11, 18, 18, black); - CopyTile(28, z+12, ttile2); - GotoXY(20, z+32); printstring("Clipboard"); -} - -void FlipX(unsigned short edtile) -{ int i,j; - - key[SCAN_X]=0; - if (edtile>=numtiles) return; - memcpy(ttile,&vsp[edtile*256],256); - modified=1; - - for (i=0;i<16;i++) - for (j=0;j<16;j++) - vsp[((edtile)*256)+(j*16)+i]=ttile[(j*16)+(15-i)]; -} - -void FlipY(unsigned short edtile) -{ int i,j; - - key[SCAN_Y]=0; - if (edtile>=numtiles) return; - memcpy(ttile,&vsp[edtile*256],256); - modified=1; - - for (i=0;i<16;i++) - for (j=0;j<16;j++) - vsp[((edtile)*256)+(j*16)+i]=ttile[((15-j)*16)+i]; -} - -void FlipZ(unsigned short edtile) -{ int i,j; - - key[SCAN_Z]=0; - if (edtile>=numtiles) return; - memcpy(ttile,&vsp[edtile*256],256); - modified=1; - - for (i=0;i<16;i++) - for (j=0;j<16;j++) - vsp[((edtile)*256)+(j*16)+i]=ttile[(i*16)+j]; -} - -void DrawHighlight(int x, int y) -{ - if (x<10 || y<10 || x>330 || y>sy+10) return; - HLine(x, y, 18, white); - HLine(x, y+17, 18, white); - VLine(x, y, 18, white); - VLine(x+17, y, 18, white); -} - -void TileSelector() -{ int z, ct, k,j,m; - char *s, *d; - - int ms_down=0; // aen - int ms_up=0; - - while (!key[SCAN_ESC]) - { - RenderSelector(); - RenderMessages(); - DrawMouse(); - ShowPage(); - - ms_down=0; - ms_up=0; - if (mouse_scroll) - { - if (my>tsy-2) ms_down=1; - if (my<18) ms_up=1; - } - - if ((key[SCAN_DOWN] || (ms_down && (!(systemtime%10)))) && selofs<65319) - { - if (!pad) selofs=selofs+20; - else selofs+=18; - key[SCAN_DOWN]=0; - systemtime++; - } - if ((key[SCAN_UP] || (ms_up && (!(systemtime%10)))) && selofs>17) - { - if (!pad) selofs-=20; - else selofs-=18; - key[SCAN_UP]=0; - systemtime++; - } - if (key[SCAN_P]) - { - key[SCAN_P]=0; - pad=pad ^ 1; - selofs=0; - if (pad) Message("Tile padding enabled.",100); - else Message("Tile padding disabled.",100); - } - if (key[SCAN_H]) - { - key[SCAN_H]=0; - th=th ^ 1; - if (th) Message("Tile Highlight enabled.",100); - else Message("Tile Highlight disabled.",100); - } - - if (key[SCAN_X]) FlipX(curtileptr(selofs)); - if (key[SCAN_Y]) FlipY(curtileptr(selofs)); - if (key[SCAN_Z]) FlipZ(curtileptr(selofs)); - if (key[SCAN_V]) VSPAnimDialog(); - if (key[SCAN_CTRL] && key[SCAN_C]) - { - memcpy(ttile2, (char *) (vsp+(256*curtileptr(selofs))), 256); - key[SCAN_C]=0; - } - if (key[SCAN_CTRL] && key[SCAN_S]) - { - if (curtileptr(selofs) >= numtiles) return; - memcpy((char *) (vsp+(256*curtileptr(selofs))), ttile2, 256); - modified=1; - key[SCAN_S]=0; - } - if (key[SCAN_CTRL] && key[SCAN_T]) - { - if (curtileptr(selofs) >= numtiles) return; - modified=1; - s=ttile2; - d=(char *) (vsp+(256*curtileptr(selofs))); - for (z=0; z<256; z++) - { - if (*s) *d=*s; - d++; - s++; - } - key[SCAN_T]=0; - } - if (key[SCAN_CTRL] && key[SCAN_D] && !key[SCAN_ALT]) - { - key[SCAN_D]=0; - modified=1; - z=curtileptr(selofs); - if (zz) layers[k][j*layer[k].sizex+m]--; - } - } - } - } - } - } -// zero: Super Insert Mode! -// wimpy insert irks me. - if (key[SCAN_CTRL] && key[SCAN_I] && key[SCAN_ALT]) - { - key[SCAN_I]=0; - ct=curtileptr(selofs); - if (ct <= numtiles) - { - modified=1; - s=(char *) valloc((numtiles+1)*256, "s_ins",0); - memcpy(s, vsp, (numtiles*256)); - vfree(vsp); vsp=s; s=0; - for (z=numtiles-1; z>=ct; z--) - memcpy(vsp+((z+1)*256),vsp+(z*256),256); - memset(vsp+(ct*256), 0, 256); - numtiles++; - } - for(k=0;k=ct) layers[k][j*layer[k].sizex+m]++; - } - } - } - } - - if (key[SCAN_CTRL] && key[SCAN_I] && !key[SCAN_ALT]) - { - key[SCAN_I]=0; - ct=curtileptr(selofs); - if (ct <= numtiles) - { - modified=1; - s=(char *)valloc((numtiles+1)*256,"s_ins",0); - memcpy(s, vsp, (numtiles*256)); - vfree(vsp); vsp=s; s=0; - for (z=numtiles-1; z>=ct; z--) - memcpy(vsp+((z+1)*256),vsp+(z*256),256); - memset(vsp+(ct*256), 0, 256); - numtiles++; - } - } - if (key[SCAN_E]) - { - modified=1; - TEtile=curtileptr(selofs); // middle tile initially - if (TEtile290 && mx<330 && my>z+12 && my290 && mx<330 && my>z+23 && my278 && mx<289 && my>z+12 && my278 && mx<289 && my>z+23 && my161 && mx<210 && my>z+12 && my161 && mx<210 && my>z+23 && my220 && mx<270 && my>z+12 && my220 && mx<270 && my>z+23 && my= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - vaxofs = (mx-mxo); - vayofs = (my-myo); - if (!mb) moving=0; - if (vaxofs<16) vaxofs = 16; - if (vayofs<16) vayofs = 16; - if (vaxofs+vaxsize>335) vaxofs = 336-vaxsize; - if (vayofs+vaysize>sy+16) vayofs = (sy+16)-vaysize; - } - - Window(vaxofs, vayofs, vaxofs+vaxsize, vayofs+vaysize, "VSP Animation Editor"); - CopyTile(vaxofs+110, vayofs+16, (char *) (vsp+(256*tileidx[vspanim[i].start]))); - GotoXY(vaxofs+4, vayofs+12); printstring("Start"); - TextField(vaxofs+25, vayofs+11, 60, nstr1, ctf == 1 ? cb : 0); - GotoXY(vaxofs+11, vayofs+22); printstring("End"); - TextField(vaxofs+25, vayofs+21, 60, nstr2, ctf == 2 ? cb : 0); - GotoXY(vaxofs+4, vayofs+32); printstring("Delay"); - TextField(vaxofs+25, vayofs+31, 60, nstr3, ctf == 3 ? cb : 0); - GotoXY(vaxofs+6, vayofs+42); printstring("Mode"); - TextField(vaxofs+25, vayofs+41, 60, nstr4, ctf == 4 ? cb : 0); - GotoXY(vaxofs+2, vayofs+56); printstring("Strand"); - GotoXY(vaxofs+104, vayofs+33); printstring("Preview"); - HLine(vaxofs+1, vayofs+51, 148, white); - Button(vaxofs+85, vayofs+54, "OK"); - Button(vaxofs+117, vayofs+54, "Update"); - GotoXY(vaxofs+30, vayofs+56); - sprintf(strbuf, "%d", i); printstring(strbuf); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>vaxofs+25 && mxvayofs+11 && myvaxofs+25 && mxvayofs+21 && myvaxofs+25 && mxvayofs+31 && myvaxofs+25 && mxvayofs+41 && myvaxofs+85 && mxvayofs+54 && myvaxofs+117 && mxvayofs+54 && my(vaxofs+vaxsize-9) && (mx(vayofs+1) && (myvaxofs && mxvayofs && my<(vayofs+9) && !moving) - { - moving=1; - mxo=mx-vaxofs; - myo=my-vayofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_UP) - { - vspanim[i].start=atoi(nstr1); - vspanim[i].finish=atoi(nstr2); - vspanim[i].delay=atoi(nstr3); - vspanim[i].mode=atoi(nstr4); - if (i<99) i++; else i=0; - last_pressed=0; key[SCAN_UP]=0; - sprintf(nstr1, "%d", vspanim[i].start); - sprintf(nstr2, "%d", vspanim[i].finish); - sprintf(nstr3, "%d", vspanim[i].delay); - sprintf(nstr4, "%d", vspanim[i].mode); - continue; - } - if (last_pressed==SCAN_DOWN) - { - vspanim[i].start=atoi(nstr1); - vspanim[i].finish=atoi(nstr2); - vspanim[i].delay=atoi(nstr3); - vspanim[i].mode=atoi(nstr4); - if (i) i--; else i=99; - last_pressed=0; key[SCAN_DOWN]=0; - sprintf(nstr1, "%d", vspanim[i].start); - sprintf(nstr2, "%d", vspanim[i].finish); - sprintf(nstr3, "%d", vspanim[i].delay); - sprintf(nstr4, "%d", vspanim[i].mode); - continue; - } - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=nstr1; break; - case 1: ctf=2; str=nstr2; break; - case 2: ctf=3; str=nstr3; break; - case 3: ctf=4; str=nstr4; break; - case 4: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=4; str=nstr4; break; - case 1: ctf=0; str=0; break; - case 2: ctf=1; str=nstr1; break; - case 3: ctf=2; str=nstr2; break; - case 4: ctf=3; str=nstr3; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -// memset(&vadelay, 0, 100); -// for (i=0; i= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - atxofs = (mx-mxo); - atyofs = (my-myo); - if (!mb) moving=0; - if (atxofs<16) atxofs = 16; - if (atyofs<16) atyofs = 16; - if (atxofs+atxsize>335) atxofs = 336-atxsize; - if (atyofs+atysize>sy+16) atyofs = (sy+16)-atysize; - } - - Window(atxofs, atyofs, atxofs+atxsize, atyofs+atysize, "Allocate Additional Tiles"); - GotoXY(atxofs+12, atyofs+15); printstring("Alloc Tiles:"); - TextField(atxofs+56, atyofs+13, 80, nstr1, ctf == 1 ? cb : 0); - Button(atxofs+85, atyofs+26, "OK"); - Button(atxofs+117, atyofs+26, "Cancel"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>atxofs+56 && mxatyofs+13 && myatxofs+85 && mxatyofs+26 && myatxofs+117 && mxatyofs+26 && my(atxofs+atxsize-9) && (mx(atyofs+1) && (myatxofs && mxatyofs && my<(atyofs+9) && !moving) - { - moving=1; - mxo=mx-atxofs; - myo=my-atyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (last_pressed==SCAN_TAB && !key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=nstr1; break; - case 1: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (last_pressed==SCAN_TAB && key[SCAN_LSHIFT]) - { - switch (ctf) - { - case 0: ctf=1; str=nstr1; break; - case 1: ctf=0; str=0; break; - } - key[SCAN_TAB]=0; - last_pressed=0; - cb=1; cursorblink=systemtime+40; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); - at=atoi(nstr1); - th=bleh; -// memset(&vadelay, 0, 100); -// for (i=0; i=ontiles) img=ovsp; - CopyTile((j*jumper)+16,(i*jumper)+16,img); - if(at17) - { - if (!pad) sofs-=20; - else sofs-=18; - key[SCAN_UP]=0; - } -/*all by zero here in this scan_b thing*/ - if (key[SCAN_B]) - { - key[SCAN_B]=0; - Message("Building duplicate import list",200); - for(bloop1=0; bloop1= cursorblink) - { - cb ^= 1; - cursorblink = systemtime+40; - } - if (moving) - { - OPxofs = (mx-mxo); - OPyofs = (my-myo); - if (!mb) moving=0; - if (OPxofs<16) OPxofs = 16; - if (OPyofs<16) OPyofs = 16; - if (OPxofs+OPxsize>335) OPxofs = 336-OPxsize; - if (OPyofs+OPysize>sy+16) OPyofs = (sy+16)-OPysize; - } - - Window(OPxofs, OPyofs, OPxofs+OPxsize, OPyofs+OPysize, "Open PCX As"); - Button(OPxofs+21, OPyofs+18, "Tileset"); - Button(OPxofs+50, OPyofs+18, "Image"); - - DrawMouse(); - ShowPage(); - CheckTimerStuff(); - - // input phase - if (mb==1 && mx>OPxofs+21 && mxOPyofs+18 && myOPxofs+50 && mxOPyofs+18 && my(OPxofs+OPxsize-9) && (mx(OPyofs+1) && (myOPxofs && mxOPyofs && my<(OPyofs+9) && !moving) - { - moving=1; - mxo=mx-OPxofs; - myo=my-OPyofs; - continue; - } - - if (mb==1 && !moving) - { - ctf=0; - cb=0; - str=0; - WaitRelease(); - } - - if (last_pressed) - { - if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) c=key_shift_tbl[last_pressed]; - else c=key_ascii_tbl[last_pressed]; - - if (last_pressed==SCAN_ESC) - { - key[SCAN_ESC]=0; - done=1; - break; - } - - if (last_pressed==SCAN_ENTER) - { - key[SCAN_ENTER]=0; - ctf=0; - str=0; - last_pressed=0; - continue; - } - - if (!ctf) - continue; - - if (last_pressed==SCAN_BACKSP && strlen(str)) - { - str[strlen(str)-1]=0; - key[SCAN_BACKSP]=0; - last_pressed=0; - continue; - } - else if (last_pressed==SCAN_BACKSP) - { - last_pressed=0; - continue; - } - - t=strlen(str); - str[t]=c; - str[t+1]=0; - last_pressed=0; - } - } while (!done); -} - -char manufacturer; -char version; -char encoding; -char bits_per_pixel; -short xmin,ymin; -short xmax,ymax; -short hres; -short vres; -char palette[48]; -char reserved; -char color_planes; -short bytes_per_line; -short palette_type; -char filler[58]; -char *t; - -int width,depth; -int bytes; -int vidoffset; -FILE *pcxf; - -void ReadPCXLine(unsigned char *dest) -{ int i, n; - char c, run; - - n=0; - do { - c=fgetc(pcxf) & 0xff; - - if ((c & 0xc0)==0xc0) - { run=c & 0x3f; - c=fgetc(pcxf); - for (i=0; i> 2; - set_intensity(63); -} - -void LoadPCXHeaderNP(char *fname) -{ - pcxf=fopen(fname,"rb"); - if (!pcxf) err("Could not open specified PCX file."); - fread(&manufacturer,1,1,pcxf); - fread(&version,1,1,pcxf); - fread(&encoding,1,1,pcxf); - fread(&bits_per_pixel,1,1,pcxf); - fread(&xmin,1,2,pcxf); - fread(&ymin,1,2,pcxf); - fread(&xmax,1,2,pcxf); - fread(&ymax,1,2,pcxf); - fread(&hres,1,2,pcxf); - fread(&vres,1,2,pcxf); - fread(&palette,1,48,pcxf); - fread(&reserved,1,1,pcxf); - fread(&color_planes,1,1,pcxf); - fread(&bytes_per_line,1,2,pcxf); - fread(&palette_type,1,2,pcxf); - fread(&filler,1,58,pcxf); - width=xmax-xmin+1; - depth=ymax-ymin+1; - bytes=bytes_per_line; -} - -// grabs a tile from the ovsp buffer (transit tile bay) -int GrabTileAt(int x, int y, int z, int check_dup) -{ int a; - char tvsp[256]; - char *s; - - s=t+(y*width)+x; - - for (a=0; a<16; a++) - { - memcpy(tvsp+(a*16), s, 16); - s+=width; - } - - if (check_dup) - { - for (a=0; a -#include -#include - -#include "mikmod.h" - -#include "render.h" - -#define PIT0 0x40 -#define PIT1 0x41 -#define PIT2 0x42 -#define PITMODE 0x43 -#define PITCONST 1193180L - -#define OCR1 0x20 -#define IMR1 0x21 - -#define OCR2 0xA0 -#define IMR2 0xA1 - -// ================================= Data ==================================== - -void (__interrupt __far *biosTimerHandler)(); -char timerinstalled=0; -extern char soundokay; - -volatile unsigned int systemtime=0, timer_count=0, tick=0; -volatile int backupct=0, idlect=0; - -// ================================= Code ==================================== - -#pragma aux disable =\ - "cli"; - -#pragma aux enable =\ - "sti"; - -static void SendEOI (unsigned char irqno) -{ - static unsigned char ocr; - static unsigned char eoi; - - ocr=(irqno>7) ? OCR2 : OCR1; - eoi=0x60|(irqno&7); - outp(ocr,eoi); - if (irqno>7) outp(OCR1,0x20); -} - -void __interrupt __far newhandler(void) -{ - systemtime++; - timer_count++; - tick++; - backupct++; - idlect++; - CheckTileAnimation(); - if (soundokay) MD_Update(); - SendEOI(0); -} - -void SetHZ(unsigned int hz) -{ unsigned int pit0_set, pit0_value; - - disable(); - - outp(PITMODE, 0x34); - pit0_value=PITCONST / hz; - pit0_set=(pit0_value & 0x00ff); - outp(PIT0, pit0_set); - pit0_set=(pit0_value >> 8); - outp(PIT0, pit0_set); - - enable(); -} - -void RestoreHZ() -{ - disable(); - outp(PITMODE, 0x34); - outp(PIT0, 0x00); - outp(PIT0, 0x00); - enable(); -} - -void InitTimer() -{ - if (timerinstalled) return; - - biosTimerHandler=_dos_getvect(0x08); - _dos_setvect(0x08, newhandler); - timerinstalled=1; - SetHZ(100); -} - -void ShutdownTimer() -{ - if (!timerinstalled) return; - - _dos_setvect(0x08, biosTimerHandler); - RestoreHZ(); - timerinstalled=0; -} diff --git a/16/v2/source/verge/MAPED/TIMER.H b/16/v2/source/verge/MAPED/TIMER.H deleted file mode 100755 index 9a74f633..00000000 --- a/16/v2/source/verge/MAPED/TIMER.H +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef TIMER_INC -#define TIMER_INC - -extern unsigned int systemtime, timer_count, tick; -extern int backupct, idlect; -//extern int (*callback) (void); // ??? - -extern void SetHZ(unsigned int hz); -extern void RestoreHZ(); -extern void InitTimer(); -extern void ShutdownTimer(); - -#endif // TIMER_INC diff --git a/16/v2/source/verge/MAPED/VDRIVER.C b/16/v2/source/verge/MAPED/VDRIVER.C deleted file mode 100755 index 14ca28fe..00000000 --- a/16/v2/source/verge/MAPED/VDRIVER.C +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include - -#include "mode13h.h" -#include "modex.h" - -// ================================= Data ==================================== - -// Driver function-pointers. -int (*ShutdownVideo) (void); -int (*ShowPage) (void); -int (*CopySprite) (int x, int y, int width, int height, char *src); -int (*CCopySprite) (int x, int y, int width, int height, char *src); -int (*TCCopySprite) (int x, int y, int width, int height, char *src); -int (*TCopySprite) (int x, int y, int width, int height, char *src); -int (*CopyTile) (int x, int y, char *src); -int (*FilledBox) (int x, int y, int width, int height, char c); -int (*VLine) (int x, int y, int height, char color); -int (*HLine) (int x, int y, int width, char color); -int (*ColorGrid) (int x, int y, char c); -int (*ClearScreen) (void); -int (*CopySpriteLucentClip) (int x, int y, int width, int height, unsigned char *src); - -unsigned char pal[768], pal2[768]; -unsigned char *screen=0; - -int sx=0, sy=0; -int tx=0, ty=0; -int tsx=0, tsy=0; -int map_scroll_x=1; -int map_scroll_y=1; - -// ================================= Code ==================================== - -void InitVideo(int mode) -{ - switch (mode) - { - case 0: InitMode13h(); break; - case 1: InitModeX(); // 320x240 - break; - } -} - -void SetPalette(unsigned char *pall) -{ unsigned int i; - - outp(0x03c8,0); - for (i=0; i<768; i++) - outp(0x03c9,pall[i]); -} - -void GetPalette(void) -{ unsigned int i; - - outp(0x03c7,0); - for (i=0; i<768; i++) - pal[i]=inp(0x03c9); -} - -void set_intensity(unsigned int n) -{ unsigned int i; - - for (i=0; i<768; i++) - pal2[i]=(pal[i]*n)>>6; - - SetPalette(pal2); -} - -#define byte unsigned char -int cx1=16, cy1=16, cx2=336, cy2=256; - -char stipple[256]={ - 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, -}; diff --git a/16/v2/source/verge/MAPED/VDRIVER.H b/16/v2/source/verge/MAPED/VDRIVER.H deleted file mode 100755 index b04b194b..00000000 --- a/16/v2/source/verge/MAPED/VDRIVER.H +++ /dev/null @@ -1,49 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef VDRIVER_INC -#define VDRIVER_INC - -#include "inter.h" - -extern int (*ShutdownVideo) (void); -extern int (*ShowPage) (void); -extern int (*CopySprite) (int x, int y, int width, int height, char *src); -extern int (*CCopySprite) (int x, int y, int width, int height, char *src); -extern int (*TCCopySprite) (int x, int y, int width, int height, char *src); -extern int (*TCopySprite) (int x, int y, int width, int height, char *src); -extern int (*CopySpriteLucentClip) (int x, int y, int width, int height, unsigned char *src); -extern int (*CopyTile) (int x, int y, char *src); -extern int (*FilledBox) (int x, int y, int width, int height, char c); -extern int (*VLine) (int x, int y, int height, char color); -extern int (*HLine) (int x, int y, int width, char color); -extern int (*ColorGrid) (int x, int y, char c); -extern int (*ClearScreen) (void); - -extern unsigned char pal[768], pal2[768]; -extern unsigned char *screen; - -extern int sx, sy, tx, ty, tsx, tsy; -extern int map_scroll_x, map_scroll_y; - -extern void InitVideo(int mode); -extern void SetPalette(unsigned char *pall); -extern void GetPalette(void); -extern void set_intensity(unsigned int n); - -extern int cx1, cy1, cx2, cy2; - -#endif // VDRIVER_INC diff --git a/16/v2/source/verge/MAPED/VERGEPAL.H b/16/v2/source/verge/MAPED/VERGEPAL.H deleted file mode 100755 index 75adcd68..00000000 --- a/16/v2/source/verge/MAPED/VERGEPAL.H +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#define VERGEPAL_LEN 768 - - static unsigned char vergepal[]= - { - 0x00,0x00,0x00,0x02,0x02,0x02,0x03,0x03,0x03,0x05,0x05,0x05,0x07, - 0x07,0x07,0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0c,0x0c,0x0c,0x0e,0x0e, - 0x0e,0x0f,0x0f,0x0f,0x11,0x11,0x11,0x13,0x13,0x13,0x15,0x15,0x15, - 0x16,0x16,0x16,0x18,0x18,0x18,0x1a,0x1a,0x1a,0x1c,0x1c,0x1c,0x1d, - 0x1d,0x1d,0x1f,0x1f,0x1f,0x21,0x21,0x21,0x22,0x22,0x22,0x24,0x24, - 0x24,0x26,0x26,0x26,0x28,0x28,0x28,0x29,0x29,0x29,0x2b,0x2b,0x2b, - 0x2e,0x2e,0x2e,0x31,0x31,0x31,0x34,0x34,0x34,0x36,0x36,0x36,0x39, - 0x39,0x39,0x3c,0x3c,0x3c,0x3f,0x00,0x00,0x3b,0x00,0x00,0x38,0x00, - 0x00,0x35,0x00,0x00,0x32,0x00,0x00,0x2f,0x00,0x00,0x2c,0x00,0x00, - 0x29,0x00,0x00,0x26,0x00,0x00,0x22,0x00,0x00,0x1f,0x00,0x00,0x1c, - 0x00,0x00,0x19,0x00,0x00,0x16,0x00,0x00,0x13,0x00,0x00,0x10,0x00, - 0x00,0x3f,0x36,0x36,0x3f,0x2e,0x2e,0x3f,0x27,0x27,0x3f,0x1f,0x1f, - 0x3f,0x17,0x17,0x3f,0x10,0x10,0x3f,0x08,0x08,0x3f,0x00,0x00,0x11, - 0x0b,0x06,0x13,0x0d,0x07,0x15,0x0f,0x09,0x17,0x11,0x0a,0x18,0x13, - 0x0b,0x1a,0x15,0x0c,0x1c,0x17,0x0e,0x1e,0x19,0x0f,0x3f,0x3f,0x36, - 0x3f,0x3f,0x2e,0x3f,0x3f,0x27,0x3f,0x3f,0x1f,0x3f,0x3e,0x17,0x3f, - 0x3d,0x10,0x3f,0x3d,0x08,0x3f,0x3d,0x00,0x39,0x36,0x00,0x33,0x31, - 0x00,0x2d,0x2b,0x00,0x27,0x27,0x00,0x21,0x21,0x00,0x1c,0x1b,0x00, - 0x16,0x15,0x00,0x10,0x10,0x00,0x34,0x3f,0x17,0x31,0x3f,0x10,0x2d, - 0x3f,0x08,0x28,0x3f,0x00,0x24,0x39,0x00,0x20,0x33,0x00,0x1d,0x2d, - 0x00,0x18,0x27,0x00,0x36,0x3f,0x36,0x2e,0x3d,0x2e,0x27,0x3b,0x27, - 0x1f,0x39,0x1f,0x17,0x36,0x17,0x0f,0x34,0x0f,0x08,0x32,0x08,0x00, - 0x30,0x00,0x00,0x2d,0x00,0x00,0x2b,0x00,0x00,0x28,0x00,0x00,0x26, - 0x00,0x00,0x23,0x00,0x00,0x21,0x00,0x00,0x1e,0x00,0x00,0x1c,0x00, - 0x00,0x19,0x00,0x00,0x17,0x00,0x00,0x14,0x00,0x00,0x12,0x00,0x00, - 0x0f,0x00,0x02,0x0d,0x02,0x03,0x0a,0x03,0x05,0x08,0x05,0x36,0x3f, - 0x3f,0x2e,0x3f,0x3f,0x27,0x3f,0x3f,0x1f,0x3f,0x3f,0x17,0x3f,0x3f, - 0x0f,0x3f,0x3f,0x08,0x3f,0x3f,0x00,0x3f,0x3f,0x00,0x39,0x39,0x00, - 0x33,0x33,0x00,0x2d,0x2d,0x00,0x27,0x27,0x00,0x22,0x22,0x00,0x1c, - 0x1c,0x00,0x16,0x16,0x00,0x10,0x10,0x17,0x2f,0x3f,0x10,0x2c,0x3f, - 0x08,0x2a,0x3f,0x00,0x27,0x3f,0x00,0x23,0x39,0x00,0x1f,0x33,0x00, - 0x1b,0x2d,0x00,0x17,0x27,0x36,0x36,0x3f,0x2e,0x2f,0x3f,0x27,0x27, - 0x3f,0x1f,0x20,0x3f,0x17,0x18,0x3f,0x10,0x10,0x3f,0x08,0x09,0x3f, - 0x00,0x01,0x3f,0x00,0x00,0x3f,0x00,0x00,0x3b,0x00,0x00,0x38,0x00, - 0x00,0x35,0x00,0x00,0x32,0x00,0x00,0x2f,0x00,0x00,0x2c,0x00,0x00, - 0x29,0x00,0x00,0x26,0x00,0x00,0x22,0x00,0x00,0x1f,0x00,0x00,0x1c, - 0x00,0x00,0x19,0x00,0x00,0x16,0x00,0x00,0x13,0x00,0x00,0x10,0x0d, - 0x08,0x00,0x0f,0x09,0x00,0x12,0x0a,0x00,0x14,0x0b,0x00,0x16,0x0c, - 0x00,0x19,0x0d,0x00,0x1b,0x0e,0x00,0x1e,0x0f,0x00,0x20,0x10,0x00, - 0x22,0x11,0x00,0x25,0x12,0x00,0x28,0x15,0x03,0x2c,0x18,0x06,0x2f, - 0x1b,0x09,0x32,0x1e,0x0c,0x35,0x21,0x0e,0x39,0x24,0x11,0x3c,0x27, - 0x14,0x3f,0x2a,0x17,0x3f,0x2e,0x1c,0x3f,0x31,0x22,0x3f,0x35,0x27, - 0x3f,0x38,0x2c,0x22,0x1c,0x12,0x25,0x1f,0x14,0x29,0x22,0x17,0x2c, - 0x25,0x19,0x2f,0x28,0x1c,0x32,0x2a,0x1e,0x36,0x2d,0x20,0x39,0x30, - 0x23,0x3c,0x33,0x25,0x3f,0x3a,0x37,0x3f,0x38,0x34,0x3f,0x36,0x31, - 0x3f,0x35,0x2f,0x3f,0x33,0x2c,0x3f,0x31,0x29,0x3f,0x2f,0x27,0x3f, - 0x2e,0x24,0x3f,0x2c,0x20,0x3f,0x29,0x1c,0x3f,0x27,0x18,0x3c,0x25, - 0x17,0x3a,0x23,0x16,0x37,0x22,0x15,0x34,0x20,0x14,0x32,0x1f,0x13, - 0x2f,0x1e,0x12,0x2d,0x1c,0x11,0x2a,0x1a,0x10,0x28,0x19,0x0f,0x27, - 0x18,0x0e,0x24,0x17,0x0d,0x22,0x16,0x0c,0x20,0x14,0x0b,0x1d,0x13, - 0x0a,0x1b,0x12,0x09,0x17,0x10,0x08,0x15,0x0f,0x07,0x12,0x0e,0x06, - 0x10,0x0c,0x06,0x0e,0x0b,0x05,0x0a,0x08,0x03,0x3f,0x00,0x00,0x3f, - 0x04,0x00,0x3f,0x08,0x00,0x3f,0x0d,0x00,0x3f,0x11,0x00,0x3f,0x15, - 0x00,0x3f,0x19,0x00,0x3f,0x1d,0x00,0x3f,0x22,0x00,0x3f,0x26,0x00, - 0x3f,0x2a,0x00,0x3f,0x2e,0x00,0x3f,0x32,0x00,0x3f,0x37,0x00,0x3f, - 0x3b,0x00,0x3f,0x3f,0x00,0x3f,0x2f,0x00,0x36,0x28,0x00,0x2d,0x22, - 0x00,0x24,0x1b,0x00,0x1b,0x14,0x00,0x12,0x0d,0x00,0x09,0x07,0x00, - 0x00,0x00,0x00,0x29,0x00,0x28,0x23,0x00,0x2b,0x1d,0x00,0x2f,0x17, - 0x00,0x32,0x12,0x00,0x35,0x0c,0x00,0x38,0x06,0x00,0x3c,0x3f,0x3f, - 0x3f,0x3f - }; - diff --git a/16/v2/source/verge/README.TXT b/16/v2/source/verge/README.TXT deleted file mode 100755 index 84e756b6..00000000 --- a/16/v2/source/verge/README.TXT +++ /dev/null @@ -1,40 +0,0 @@ - -VERGE version 2.01a, Copyright (C) 1998 BJ Eirich (aka vecna) -VERGE comes with ABSOLUTELY NO WARRANTY. This is free software, -and you are welcome to redistribute it under certain conditions. -For details refer to GNU.TXT. - --=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - ->Jan 1, 2000< - -Hey Guys, - -This is the old source for V2 (DJGPP), along with the sources for the utils (mostly DJGPP), the VCC compiler (DJGPP; though it should compiler under Watcom), and MapEd 2 (Watcom). Just getting this out the door. The new source will be released and updated regularly a week or so from now, so you can futz around with this until that time. - -I'm not sure the main engine even runs in this build, as all I got from compiling and running it was a fistful of page faults. Sorry, I don't feel like trying to make it work. It's old and stinky (enjoy! ^_^). It may be VC incompatibilities with newer stuff, it may be some minor oversight on my part from tweaking it at some point, it could by anything. - -The utils and MapEd 2 seemed to be in working order, however. Didn't include all the util sources, because they're hidden somewhere on my hard drive. I'll find them later (like when I clean this cluttered mess of a hard drive). - -I removed the CD audio code, because of GPL issues and it was a shoddy interface to begin with. I didn't take the FLI code out, though I can't remember where I got it from. It's likely I nabbed it up from X2FTP or some similar archive. If you can figure out where it's from and if I'm violating the GPL by including it (though I hacked it up a bit), just send me some proof of its origin and license and I'll remove it. - -Otherwise, wham. There ya go. If you have any questions about it, just drop me a line and I'll see what I can do. Happy New Year, and have fun with it... Or possibly heaping gobs of frustration. :-) - -- aen - --=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -Pertaining to MikMod: - -Parts of the library (in playercode/mdulaw.c) are derived from the files -libst.h and raw.c from an old version of the sox (SOund eXchange) package -written by Lance Norskog and Jef Poskanzer. The following copyright notice -applies to these parts: - -Copyright (C) 1989 by Jef Poskanzer. -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. This software is provided "as is" without express or -implied warranty. diff --git a/16/v2/source/verge/UTIL/CHRCONV/CHRCONV.C b/16/v2/source/verge/UTIL/CHRCONV/CHRCONV.C deleted file mode 100755 index 91ac6ac1..00000000 --- a/16/v2/source/verge/UTIL/CHRCONV/CHRCONV.C +++ /dev/null @@ -1,125 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include - -char c[100]; -FILE *f; -char *jalblkasd; -char byte, *t; -short word; -int quad; - -int bufsize=0; -unsigned char *csrc, *cb; - -void EmitC (unsigned char c) -{ - *csrc++=c; - bufsize++; -} - -void Compress(unsigned char *p, int len) -{ - int i; - unsigned char byt,samect; - unsigned char repcode; - - csrc=cb; - i=0; bufsize=0; - do - { byt=p[i++]; - samect=1; - while (samect<254 && i3 || byt == 0xFF) - { - repcode=0xFF; - EmitC(repcode); - repcode=(char) samect; - EmitC(repcode); - } - EmitC(byt); - } while (i v2 chr ---- -Chrconv is a remarkably simple utility, and that is a shame, because eventually you won't use it much at all. But initially it will be of great value to everyone, because it converts from old v1 chrs to new v2 chrs. - -The v2 chr it creates will emulate the animation behavior of a v1 exactly, so it should look and operate like you're used to. This is useful, because writing animation strings and handling odd-shaped chrs may not be something that appeals to you just yet. For example, the default animation string used by chrconv for walking north is:F16W10F17W10F16W10F15W10F18W10F19W10F18W10F15W10. - -To use chrconv, simply execute it. It will ask for the filename of the source v1 chr, and will convert it to v2 format. NOTE: it will overwrite the old chr, so you may want to back it up first. - -enjoy! \ No newline at end of file diff --git a/16/v2/source/verge/UTIL/CHRCONV/DARIN.CHR b/16/v2/source/verge/UTIL/CHRCONV/DARIN.CHR deleted file mode 100755 index 15b6debb..00000000 Binary files a/16/v2/source/verge/UTIL/CHRCONV/DARIN.CHR and /dev/null differ diff --git a/16/v2/source/verge/UTIL/CHRCONV/MAKEDJ.BAT b/16/v2/source/verge/UTIL/CHRCONV/MAKEDJ.BAT deleted file mode 100755 index 5ad2d1f3..00000000 --- a/16/v2/source/verge/UTIL/CHRCONV/MAKEDJ.BAT +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -gcc -s -Wall -Werror -m486 -O3 chrconv.c -o chrconv.exe diff --git a/16/v2/source/verge/UTIL/CHRMAK/CHRMAK.CC b/16/v2/source/verge/UTIL/CHRMAK/CHRMAK.CC deleted file mode 100755 index d3ebd7ee..00000000 --- a/16/v2/source/verge/UTIL/CHRMAK/CHRMAK.CC +++ /dev/null @@ -1,653 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// CHRMAK.CC -// V2 PCX to CHR converter w/ makefiles -// -// coded by aen -// aen@verge-rpg.com - -#include -#include -#include -#include -#include -#include - -#include - -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// - -typedef unsigned char byte; -typedef unsigned short word; -typedef unsigned long quad; - -static void fputw(word w, FILE *fp) { fwrite(&w,1,2,fp); } -static void fputd(quad d, FILE *fp) { fwrite(&d,1,4,fp); } -static word fgetw(FILE *fp) { word w; fread(&w,1,2,fp); return w; } -quad fgetd(FILE *fp) { quad d; fread(&d,1,4,fp); return d; } - -// skips the number of bytes in the file; just seeks past them -static void fskip(int bytes, FILE *fp) - { fseek(fp,bytes,SEEK_CUR); } - -static void fputraw(char *raw, int bytes, FILE *fp) - { fwrite(raw, 1,bytes, fp); } - -// writes a null-terminated string to the file -void fputstrz(char *str, FILE *fp) - { fputraw(str, strlen(str)+1, fp); } - -// writes a string to the file (without the null-terminator), preceeded by -// a quad length marker -static void fputstrn(char *str, FILE *fp) - { int n=strlen(str)+1; fputd(n,fp); fputraw(str,n,fp); } - -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// - -#define CHRMAK_VER_MAJ 0 -#define CHRMAK_VER_MIN 1 -#define CHRMAK_VER_STR "0.1b" -#define CHRMAK_AUTHORS "aen" - -// parsing vars -static char *mak_base=0; -static char *makp=0; -static int mak_bytes=0; -static char mak_tok_ident[256]; -static char mak_tok_val[256]; -static int mak_tok_valn=0; // numeric val of mak_tok -static int mak_line=0; - -// makefile vars -static char chrmak_makefile[256]; - -static char pcx_name[256]; static int got_pcx_name=0; -static char chr_name[256]; static int got_chr_name=0; -static int frame_w=0; static int got_frame_w=0; -static int frame_h=0; static int got_frame_h=0; -static int hot_x=0; static int got_hot_x=0; -static int hot_y=0; static int got_hot_y=0; -static int hot_w=0; static int got_hot_w=0; -static int hot_h=0; static int got_hot_h=0; -static int per_row=0; static int got_per_row=0; -static int total_frames=0; static int got_total_frames=0; -static int lidle=0; static int got_lidle=0; -static int ridle=0; static int got_ridle=0; -static int uidle=0; static int got_uidle=0; -static int didle=0; static int got_didle=0; -static char lscript[256]; static int got_lscript=0; -static char rscript[256]; static int got_rscript=0; -static char uscript[256]; static int got_uscript=0; -static char dscript[256]; static int got_dscript=0; - -void warning(char *message, ...) -{ - static char buffer[256]; - va_list args; - - va_start(args, message); - vsprintf(buffer, message, args); - va_end(args); - - printf("%s \n", buffer); -} - -static void fatal(char *message, ...) -{ - static char buffer[256]; - va_list args; - - va_start(args, message); - vsprintf(buffer, message, args); - va_end(args); - - printf("%s \n", buffer); - - exit(0); -} - -//#ifdef __DJGPP__ -// Watcom has one of these -static int filelength(int handle) -{ - struct stat fileinfo; - if (-1 == fstat(handle, &fileinfo)) - fatal("error fstating"); - return fileinfo.st_size; -} -//#endif - -static int streq(char *a, char *b) -{ - while (*a) - { - if (*a++ != *b++) - return 0; - } - return !*b; -} - -static void usage() -{ - printf("usage: chrmak \n"); - exit(0); -} - -static void banner() -{ - printf("chrmak v%s  by %s \n", CHRMAK_VER_STR, CHRMAK_AUTHORS); -} - -static void parse_args(int argc, char *argv[]) -{ - if (argc != 2) - usage(); - - strcpy(chrmak_makefile, argv[1]); -} - -static void skip_cpp_comment() -{ - makp+=2; - while (*makp && '\n'!=*makp) - makp++; - if (*makp) - makp++; -} - -static void skip_c_comment() -{ - makp+=2; - while (*makp && ('*'!=makp[0] || '/'!=makp[1])) - { - if ('\n'==*makp) - mak_line++; - if ('/'==makp[0] && '*'==makp[1]) - skip_c_comment(); - else makp++; - } - if (*makp) - makp+=2; -} - -static void parse_whitespace() -{ - do { - if (!*makp) - return; - if (isspace(*makp)) - { - while (*makp && isspace(*makp)) - { - if ('\n'==*makp) - mak_line++; - makp++; - } - continue; - } - if ('/'==makp[0] && '/'==makp[1]) - { skip_cpp_comment(); continue; } - if ('/'==makp[0] && '*'==makp[1]) - { skip_c_comment(); continue; } - break; - } while (1); -} - -static void grab_ident() -{ - char *t=mak_tok_ident; - while (isalnum(*makp) || '_'==*makp) - *t++=*makp++; - *t=0; - strlwr(mak_tok_ident); -} - -static void grab_val() -{ - char *t=mak_tok_val; - while (isalnum(*makp) || '_'==*makp) - *t++=*makp++; - *t=0; - mak_tok_valn=atoi(mak_tok_val); -} - -static int ident_is(char *id) { return streq(mak_tok_ident,id); } - -static void do_assign() -{ - if (ident_is("pcx_name")) - { strcpy(pcx_name, mak_tok_val); got_pcx_name=1; return; } - else if (ident_is("chr_name")) - { strcpy(chr_name, mak_tok_val); got_chr_name=1; return; } - else if (ident_is("frame_w")) - { frame_w=mak_tok_valn; got_frame_w=1; return; } - else if (ident_is("frame_h")) - { frame_h=mak_tok_valn; got_frame_h=1; return; } - else if (ident_is("hot_x")) - { hot_x=mak_tok_valn; got_hot_x=1; return; } - else if (ident_is("hot_y")) - { hot_y=mak_tok_valn; got_hot_y=1; return; } - else if (ident_is("hot_w")) - { hot_w=mak_tok_valn; got_hot_w=1; return; } - else if (ident_is("hot_h")) - { hot_h=mak_tok_valn; got_hot_h=1; return; } - else if (ident_is("per_row")) - { per_row=mak_tok_valn; got_per_row=1; return; } - else if (ident_is("total_frames")) - { total_frames=mak_tok_valn; got_total_frames=1; return; } - else if (ident_is("lidle")) - { lidle=mak_tok_valn; got_lidle=1; return; } - else if (ident_is("ridle")) - { ridle=mak_tok_valn; got_ridle=1; return; } - else if (ident_is("uidle")) - { uidle=mak_tok_valn; got_uidle=1; return; } - else if (ident_is("didle")) - { didle=mak_tok_valn; got_didle=1; return; } - else if (ident_is("lscript")) - { strcpy(lscript, mak_tok_val); got_lscript=1; return; } - else if (ident_is("rscript")) - { strcpy(rscript, mak_tok_val); got_rscript=1; return; } - else if (ident_is("uscript")) - { strcpy(uscript, mak_tok_val); got_uscript=1; return; } - else if (ident_is("dscript")) - { strcpy(dscript, mak_tok_val); got_dscript=1; return; } - - fatal("%s: unknown ident '%s' on line %i", - chrmak_makefile, mak_tok_ident, mak_line); -} - -static int parse_assign() -{ - int last_line=0; // helper for error detection - - parse_whitespace(); - if (!*makp) - return 1; - else if (isalpha(*makp)) - { - grab_ident(); // get ident - last_line=mak_line; - - parse_whitespace(); // expect - if ('=' != *makp++) - fatal("%s: expected = on line %i", chrmak_makefile, last_line); - - parse_whitespace(); // get val - grab_val(); - last_line=mak_line; - - do_assign(); - - parse_whitespace(); // expect - if (';' != *makp++) - fatal("%s: expected ; on line %i", chrmak_makefile, last_line); - else while (';'==*makp) makp++; - - return 0; - } - fatal("%s: expected ident, got '%c' on line %i", - chrmak_makefile, *makp, mak_line); - return 1; -} - -static void check_needs() -{ - if (!got_pcx_name) fatal("%s: pcx_name missing", chrmak_makefile); - if (!got_chr_name) fatal("%s: chr_name missing", chrmak_makefile); - if (!got_frame_w) fatal("%s: frame_w missing", chrmak_makefile); - if (!got_frame_h) fatal("%s: frame_h missing", chrmak_makefile); - if (!got_hot_x) fatal("%s: hot_x missing", chrmak_makefile); - if (!got_hot_y) fatal("%s: hot_y missing", chrmak_makefile); - if (!got_hot_w) fatal("%s: hot_w missing", chrmak_makefile); - if (!got_hot_h) fatal("%s: hot_h missing", chrmak_makefile); - if (!got_per_row) fatal("%s: per_row missing", chrmak_makefile); - if (!got_total_frames) fatal("%s: total_frames missing", chrmak_makefile); - if (!got_lidle) fatal("%s: lidle missing", chrmak_makefile); - if (!got_ridle) fatal("%s: ridle missing", chrmak_makefile); - if (!got_uidle) fatal("%s: uidle missing", chrmak_makefile); - if (!got_didle) fatal("%s: didle missing", chrmak_makefile); - if (!got_lscript) fatal("%s: lscript missing", chrmak_makefile); - if (!got_rscript) fatal("%s: rscript missing", chrmak_makefile); - if (!got_uscript) fatal("%s: uscript missing", chrmak_makefile); - if (!got_dscript) fatal("%s: dscript missing", chrmak_makefile); -} - -static void parse_makefile() -{ - FILE *fp=0; - - printf("ú parsing %s \r", chrmak_makefile); - fflush(stdout); - - fp=fopen(chrmak_makefile, "rb"); - if (!fp) fatal("unable to open %s", chrmak_makefile); - - mak_bytes=filelength(fileno(fp)); // calc bytes - mak_base=new char [mak_bytes+1]; // alloc room - fread(mak_base,1,mak_bytes,fp); // read bytes - mak_base[mak_bytes]=0; // null-term - makp=mak_base; // setup cur byte ptr - mak_line=1; - - while (!parse_assign()) - ; - - // got everything we need? - check_needs(); - - delete[]mak_base; mak_base=0; - makp=0; - - fclose(fp); - - printf("û \n"); - fflush(stdout); -} - -//////////////////////////////////////////////////////////////////////////// -// PCX & COMPRESS STUFF //////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// - -static FILE *chrfp=0; -static FILE *pcxfp=0; -static byte *virscr=0; - -int manufacturer=0; // pcx header -int version=0; -int encoding=0; -int bpp=0; -int xmin=0,ymin=0; -int xmax=0,ymax=0; -int hres=0,vres=0; -char palette[48]; -int reserved=0; -int color_planes=0; -int bpl=0; -int palette_type=0; -char filler[58]; -byte pal[768]; - -int image_width=0,image_depth=0; -quad vidoffset=0; - -void LoadPCXHeader() -{ - manufacturer = fgetc(pcxfp); // always 10 - version = fgetc(pcxfp); // should be 5? - encoding = fgetc(pcxfp); // always 1 - bpp = fgetc(pcxfp); // bits per pixel - - xmin = fgetw(pcxfp); // grab window - ymin = fgetw(pcxfp); - xmax = fgetw(pcxfp); - ymax = fgetw(pcxfp); - image_width = xmax-xmin+1; // calc dims - image_depth = ymax-ymin+1; - - hres = fgetw(pcxfp); - vres = fgetw(pcxfp); - - fread(palette,1,48,pcxfp); // ega color map - - reserved = fgetc(pcxfp); - color_planes = fgetc(pcxfp); // should be 1 - - bpl = fgetw(pcxfp); // bytes per line - palette_type = fgetw(pcxfp); - - fread(filler,1,58,pcxfp); // nothing important here -} - -void ReadPCXLine(byte *dest) -{ - int i=0,c=0,n=0,run=0; - - // decode a row - for (n=0; n3 || byt == 0xFF) - { - emitc(0xFF); - emitc(samect); - } - emitc(byt); - - } while (i dumping %s \n", chr_name); - fflush(stdout); - - chrfp=fopen(chr_name, "wb"); - if (!chrfp) fatal("unable to open %s", chr_name); - - WriteInfo(chrfp); - WriteFrames(pcx_name,chrfp); - WriteScripts(chrfp); - - fclose(chrfp); - - printf("complete! \n"); - fflush(stdout); -} - -int main(int argc, char *argv[]) -{ - banner(); - - parse_args(argc, argv); - parse_makefile(); - - write_chr(); - - return 0; -} diff --git a/16/v2/source/verge/UTIL/CHRMAK/CHRMAK.TXT b/16/v2/source/verge/UTIL/CHRMAK/CHRMAK.TXT deleted file mode 100755 index b8767f13..00000000 --- a/16/v2/source/verge/UTIL/CHRMAK/CHRMAK.TXT +++ /dev/null @@ -1,118 +0,0 @@ -chrmak.exe -the utility with bloated code perpetrated by aen (aen@verge-rpg.com for hate mail) -documentation -by zeromus 5.8.99 -zermous@verge-rpg.com -(be sure word wrap is on) ---- -USE: creates v2 chr from pcx file ---- -You'll use this bad boy a lot, unless you have one of those newfangled graphical chr editors. What we do here is have a character ready in the standard pcx-graphics format (that is, with a one-pixel buffer between frames), and give it to chrmak, along with a text file describing what characteristics the output v2 chr should have. - -to run chrmak, simply execute chrmak with the makefile, with extension (ex: vecna.mak) as the first and only argument. (ex: "chrmak vecna.mak") - -The characteristics file is technically called a make file, or .mak. it containst several variables, and what they should be. for example: - -/* comment */ -pcx_name=rath; //comment -chr_name=rath; - -these variables can be scattered around anywhere in the mak file, so long as they have a semicolon after each command. you can stick comments anywhere like a c or vc file. here is a list of all the variables you need to set in the make file, what they are, and their typical values. In most cases, however, you should be able to just replace the values found in the samples rath.mak and vecna.mak with your own. - ---- - -**pcx_name** the file name of the source pcx file, sans extension. note in the above examples or in the sampel .mak files it is not pcx_name = rath.pcx, only rath. -**chr_name** the filename, sans extension, of the chr file to output. same as above in all other respects. - -**frame_w** the width of each frame of the chr (DEFAULT 16) -**frame_h** the height of each frame (DEFAULT 32) - -**hot_x** the x-coord of the chr's hotspot. See appendix A for info on chr hotspots. (DEFAULT 0) -**hot_y** the same, but y-coord (DEFAULT 16) -**hot_w** the width of the obstructing region of the hotspot. (DEFAULT 16) -**hot_h** the height of the obstructing region of the hotspot. (DEFAULT 16) - -**per_row** the number of frames per row in the pcx file. in old v1 chr/pcx files, this was 5. (DEFAULT 5) -**total frames** total number of frames in the pcx file. (DEFAULT 20) - -**lidle** the frame to show when the chr is idling, facing the left (DEFAULT 10) -**ridle** the frame to show when the chr is idling, facing the right (DEFAULT 15) -**uidle** the frame to show when the chr is idling, facing up (DEFAULT 5) -**didle** the frame to show when the chr is idling, facing down (DEFAULT 0) - -**lscript** the animation script for when the chr moves to the left. See appendix B for discussion of animation scripts. (DEFAULT F10W10F11W10F12W10F11W10F10W10F13W10F14W10F13W10) -**rscript** the animation script for when the chr moves to the right. (DEFAULT F15W10F16W10F17W10F16W10F15W10F18W10F19W10F18W10) -**uscript** the animation script for when the chr moves up (DEFAULT F5W10F6W10F7W10F6W10F5W10F8W10F9W10F8W10) -**dscript** the animation script for when the chr moves down (DEFAULT F0W10F1W10F2W10F2W10F0W10F3W10F4W10F3W10) - ---- - -APPENDIX A: Hotspots - -If a chr is located at coordinates (x,y) on the screen, then the pixel under the hotspot on the chr will be drawn at (x,y). - -You may think--"I tell a chr to go to (5,4) on the screen... but where exactly does it go? (4,4) from the middle, the left edge, or what?" -Imagine three scenarios: a 4x4 sprite with the hotspot at top left, bottom left, and middle left, respectively: - - Top Left Bottom Left Middle Left -0123456789ABCDEF 0123456789ABCDEF 0123456789ABCEDEF -1 1 **** 1 -2 +---hotspot 2 **** 2 **** -3 \|/ 3 **** 3 \**** -4 @*** 4 @*** 4 +--@*** -5 **** 5 /|\ 5 | /**** -6 **** 6 +---hotspot 6 | -7 **** 7 7 +---hotspot -8 8 8 - -So you can see how the hotspot determines how the sprite is oriented, relative to its current screen position. - -The default hotspot, (and its equivalent in v1) is at (0,16). That is, 0 to the right and 16 down from the upper-left corner of the sprite. Remember, default chr size is 16x32, and on computer, the (+,+) quadrant is quadrant IV. In other words - - -32 - -24 - -16 - -8 --16 -12 -8 -4 0 4 8 12 16 - 8 * * * * - 16 * * * * <--- sprite goes there. - 24 @ * * * @ is where hotspot would be - 32 * * * * - -Hotspots also have an obstruction width and height. This is the area of the chr that touches the ground, and cannot walk over things. In your game, you may want your head to be drawn on top of a wall, if your feet are against the bottom of the wall, right? But you don't want your feet drawn on top of the wall. - -+----------------------+ -| | -| | -| | -| | -| +---+ | -| |***| | -+------|@@@|-----------+ - +---+ - -The messy area is the chr; the @@@, and the --- beneath it, would be OBSTRUCTIVE. If the player tried to walk up, he couldnt--you would be walking into the wall. The *** and the --- above it would not be obstructive. - -Obstructive areas are defined by declaring their width and height, based from the chr's hotspot. the default values, a width and height of 16, would count over 16 and down 16 from the hotspot, effectively making the bottom 16x16 square of the 16x32 chr obstructive. - -Final example: -A 32x64 giant might be defined like this: - -... -hot_x=8; -hot_y=48; -hot_w=16; -hot_h=16; -... - ---- - -APPENDIX B: Animation scripts - -Animation scripts are made of a string of no more than 255 characters. This string can contain any combination of COMMAND CODES, of which there are two. - -The two COMMAND CODES are F and W. - -**F** sets the current frame that should be shown. So, if you want your animation, when walking to go from frame 12 to 15, you would make the script: "F12F13F14F15F14F13F12". The F can have any number of digits after it, so you don't have to do F03F05, etc.. you can just do F3F5. - -**W** makes the animation string wait the specified number of milliseconds. If you peek at the default animation strings mentioned a ways up, you'll see that there is a Wxx between each frame. This pauses the frame so you can see it, effectively slowing the animation down. In fact, the animation we just maed an example of, "F12F13F14F15F14F13F12", would g oby *waaay* too fast. Now that we know the W command we can fix it: "F12W10F13W10F14W10F15W10F14W10F13W10F12W10". \ No newline at end of file diff --git a/16/v2/source/verge/UTIL/CHRMAK/MAKEDJ.BAT b/16/v2/source/verge/UTIL/CHRMAK/MAKEDJ.BAT deleted file mode 100755 index 6283a1f4..00000000 --- a/16/v2/source/verge/UTIL/CHRMAK/MAKEDJ.BAT +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -gxx -s -Wall -Werror -m486 -O3 chrmak.cc -o chrmak.exe diff --git a/16/v2/source/verge/UTIL/CHRMAK/MAKEWAT.BAT b/16/v2/source/verge/UTIL/CHRMAK/MAKEWAT.BAT deleted file mode 100755 index 21b58471..00000000 --- a/16/v2/source/verge/UTIL/CHRMAK/MAKEWAT.BAT +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -wcl386 /bt=dos /l=pmodew /mf /os /5r /fp5 /wx /we chrmak.cc diff --git a/16/v2/source/verge/UTIL/CHRMAK/VECNA.MAK b/16/v2/source/verge/UTIL/CHRMAK/VECNA.MAK deleted file mode 100755 index baa4a9c4..00000000 --- a/16/v2/source/verge/UTIL/CHRMAK/VECNA.MAK +++ /dev/null @@ -1,21 +0,0 @@ - -/* CHRMAK makefile - û aen */ - -pcx_name=vecna; // image source -chr_name=vecna; // output .CHR name - -frame_w=16; frame_h=32; // frame dims - -hot_x=0; hot_y=16; // hotspot coord -hot_w=16; hot_h=16; // hotspot dims - -per_row=5; total_frames=20; // frames per row, total - -lidle=10; ridle=15;; // left/right idle frames -uidle=5; didle=0; // up/down idle frames - -lscript=F10W10F11W10F12W10F11W10F10W10F13W10F14W10F13W10; // movement scripts -rscript=F15W10F16W10F17W10F16W10F15W10F18W10F19W10F18W10; -uscript=F5W10F6W10F7W10F6W10F5W10F8W10F9W10F8W10; -dscript=F0W10F1W10F2W10F2W10F0W10F3W10F4W10F3W10; diff --git a/16/v2/source/verge/UTIL/CHRMAK/VECNA.PCX b/16/v2/source/verge/UTIL/CHRMAK/VECNA.PCX deleted file mode 100755 index 2e82dcb2..00000000 Binary files a/16/v2/source/verge/UTIL/CHRMAK/VECNA.PCX and /dev/null differ diff --git a/16/v2/source/verge/UTIL/CHRMAK/VER b/16/v2/source/verge/UTIL/CHRMAK/VER deleted file mode 100755 index 12088dab..00000000 --- a/16/v2/source/verge/UTIL/CHRMAK/VER +++ /dev/null @@ -1,4 +0,0 @@ - - current version - - chrmak.exe 0.1b diff --git a/16/v2/source/verge/UTIL/PACK/MAKEDJ.BAT b/16/v2/source/verge/UTIL/PACK/MAKEDJ.BAT deleted file mode 100755 index dcc8a93a..00000000 --- a/16/v2/source/verge/UTIL/PACK/MAKEDJ.BAT +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -gcc -s -Wall -Werror -m486 -O3 pack.c -o pack.exe diff --git a/16/v2/source/verge/UTIL/PACK/PACK.C b/16/v2/source/verge/UTIL/PACK/PACK.C deleted file mode 100755 index f349ab0d..00000000 --- a/16/v2/source/verge/UTIL/PACK/PACK.C +++ /dev/null @@ -1,166 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include - -#define byte unsigned char - -// ================================= Data ==================================== - -FILE *pack; -FILE *list; -FILE *src; -char *strbuf,*filebuf; -int numfiles,curofs; -char headertag[]="VRGPACK"; - -typedef struct -{ - unsigned char fname[84]; // pathname thingo - int size; // size of the file - int packofs; // where the file can be found in PACK - int count; // internal (engine-runtime) use - char extractable; // can UNPACK .. unpack it? - char override; // should the engine override it w/ - // local files? -} filestruct; - -filestruct filetbl[512]; -byte *ptr; - -// ================================= Code ==================================== - -void CreatePackHeader() -{ char a; - - fwrite(&headertag, 1, 7, pack); - a=1; fwrite(&a, 1, 1, pack); // pack version 1 - fwrite(&numfiles, 1, 4, pack); // number of files in archive - - // Hmm.. that's it. What a boring header. :) -} - -void EncryptHeader() -{ byte lastvalue; //, precodebyte; - - ptr=(byte *) filetbl; - lastvalue=*ptr; - ptr++; - - while (ptr < (byte *) (int) filetbl + (int) 5120) - { - (*ptr)+=lastvalue; - lastvalue=*ptr; - ptr++; - } -} - -void DecryptHeader() -{ byte lastvalue, precodebyte; - - ptr=(byte *) filetbl; - lastvalue=*ptr; - ptr++; - - while (ptr < (byte *) (int) filetbl + (int) 5120) - { - precodebyte=*ptr; - (*ptr)-=lastvalue; - lastvalue=precodebyte; - ptr++; - } -} - -void BuildFileTable() -{ int i; - - curofs=12+(numfiles*100); - memset(filetbl, 0, sizeof filetbl); - - for (i=0; i \n"); - exit(-1); - } - - if (!(list=fopen(argv[1],"r"))) - { - printf("Unable to open file %s. \n",argv[1]); - exit(-1); - } - - strbuf=(char *) malloc(100); - fscanf(list,"%s",strbuf); - - if (!(pack=fopen(strbuf,"wb"))) - { - printf("Unable to create file %s. \n",strbuf); - exit(0); - } - fscanf(list,"%d",&numfiles); - - CreatePackHeader(); - BuildFileTable(); - DumpFiles(); - - fclose(list); - fclose(pack); - - return 0; -} diff --git a/16/v2/source/verge/UTIL/PACK/PACK.TXT b/16/v2/source/verge/UTIL/PACK/PACK.TXT deleted file mode 100755 index b3f565b1..00000000 --- a/16/v2/source/verge/UTIL/PACK/PACK.TXT +++ /dev/null @@ -1,36 +0,0 @@ -pack.exe -documentation -by zeromus 5.8.99 -zeromus@verge-rpg.com -(be sure word wrap is on) ---- -USE: creates v2 pakfile ---- -v2 enjoys its own built-in pakfile system. v2 can use files in any number of pakfiles at the same time it can read files from your computer's regular directory structure. This allows for simplified distribution and management of v2 games, as well as adding a small measure of security to the data you worked so hard to create for your game--it will be a pain for losers to remove (read: rip) data from pakfiles, although we make no gurantees that your data is safe. This should help the situation some. - -To create a packfile, pack.exe takes a makefile of the following format: - ---- <--cut below this line :) -pakfile_to_create.vrg -number_of_files -file_name_1 flag_extrractable flag_overrideable -file_name_2 flag_extrractable flag_overrideable -file_name_3 flag_extrractable flag_overrideable ---- - -Here it is with sample data. - ---- -test.vrg -3 -pack.c 0 0 -test.mak 1 0 -test.obj 0 1 ---- - -This would create test.vrg with three files: pack.c, neither overrideable nor extractable, test.mak, extractable, but not overrideable, and test.obj, only overrideable. - -Extractable means that the file will be extracted by unpack.exe. Files you want to keep secret should have a 0 for this. - -Overrideable files will be overridden by a file of the same name in the game directory. That means, if there is a file in the game directory, it will use that one instead of the one in the pakfile. Otherwise, the copy in the pakfile will always be used. You'll usually want this set to 1, as it facilitates patches, etc. For example, if battle.map had a bug in it, you could just distribute a copy of the corrected battle.map for users to chunk in the game directory, and v2 would use the corrected copy instead. - diff --git a/16/v2/source/verge/UTIL/PACK/TEST b/16/v2/source/verge/UTIL/PACK/TEST deleted file mode 100755 index 7de7a6ca..00000000 --- a/16/v2/source/verge/UTIL/PACK/TEST +++ /dev/null @@ -1,5 +0,0 @@ -test.vrg -3 -pack.c 1 1 -pack.exe 1 1 -todo 1 1 diff --git a/16/v2/source/verge/UTIL/PACK/TODO b/16/v2/source/verge/UTIL/PACK/TODO deleted file mode 100755 index f873c218..00000000 --- a/16/v2/source/verge/UTIL/PACK/TODO +++ /dev/null @@ -1,3 +0,0 @@ -entity/entity, point makes contact w/entity, entity/bbox,b -box/bbox,and a line intersect/entity and line intersect/bbox. -sin,cos and tan() functions. diff --git a/16/v2/source/verge/UTIL/PCX2FNT/FONT0.PCX b/16/v2/source/verge/UTIL/PCX2FNT/FONT0.PCX deleted file mode 100755 index a8eee682..00000000 Binary files a/16/v2/source/verge/UTIL/PCX2FNT/FONT0.PCX and /dev/null differ diff --git a/16/v2/source/verge/UTIL/PCX2FNT/FONT02B.PCX b/16/v2/source/verge/UTIL/PCX2FNT/FONT02B.PCX deleted file mode 100755 index 26f4cd95..00000000 Binary files a/16/v2/source/verge/UTIL/PCX2FNT/FONT02B.PCX and /dev/null differ diff --git a/16/v2/source/verge/UTIL/PCX2FNT/MAKEDJ.BAT b/16/v2/source/verge/UTIL/PCX2FNT/MAKEDJ.BAT deleted file mode 100755 index 4ffdb97e..00000000 --- a/16/v2/source/verge/UTIL/PCX2FNT/MAKEDJ.BAT +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -gcc -s -Wall -Werror -m486 -O3 pcx2fnt.c -o pcx2fnt.exe diff --git a/16/v2/source/verge/UTIL/PCX2FNT/PCX2FNT.C b/16/v2/source/verge/UTIL/PCX2FNT/PCX2FNT.C deleted file mode 100755 index 497f183c..00000000 --- a/16/v2/source/verge/UTIL/PCX2FNT/PCX2FNT.C +++ /dev/null @@ -1,147 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include -#include - -char fname1[100], fname2[100]; -int xs, ys, ns; -FILE *fnt,*pcxf; -char *virscr; - -char manufacturer; // pcx header -char version; -char encoding; -char bits_per_pixel; -short int xmin,ymin; -short int xmax,ymax; -short int hres; -short int vres; -char palette[48]; -char reserved; -char color_planes; -short int bytes_per_line; -short int palette_type; -char filler[58]; -unsigned char pal[768]; - -unsigned short int width,depth; -unsigned short int bytes; -unsigned char c, run, ss=0; -unsigned int vidoffset, n=0; - -void ReadPCXLine(unsigned char *dest) -{ - int j; - n=0; - - do { - c=fgetc(pcxf) & 0xff; - if ((c & 0xc0)==0xc0) { - run=c & 0x3f; - c=fgetc(pcxf); - for (j=0; j -#include -#include - -// ================================= Data ==================================== - -struct span -{ - int begin, end; // begin & end location of span - int len, inverse; // lenth of span and inverse on/off -}; - -struct span spans[32]; // maximum of 32 spans. -char numspans; // number of active spans in PDF - -unsigned char *transparencytbl; // full transparency table (64k) -char outname[100]; // output filename -char paldefname[100]; // palette definition filename -char *strbuf; // generic string buffer - -char spanidx[256]; // Color -> Span xlat table - -// ================================= Code ==================================== - -void ParsePaletteDefinition(FILE *f) -{ int i; - - fscanf(f,"%s",strbuf); - if (stricmp("gradients",strbuf)) - { - printf("Not a valid PDF file. \n"); - exit(-1); - } - fscanf(f,"%s",strbuf); - numspans=atoi(strbuf); - - for (i=0; i -#include - -#define byte unsigned char -// ================================= Data ==================================== - -FILE *pack; -FILE *src; -char strbuf[2048],*filebuf; -int numfiles; -char headertag[]={ 'V','R','G','P','A','C','K',0 }; - -struct filestruct -{ - unsigned char fname[84]; // pathname thingo - int size; // size of the file - int packofs; // where the file can be found in PACK - int count; // internal (engine-runtime) use - char extractable; // can UNPACK .. unpack it? - char override; // should the engine override it w/ - // local files? -}; - -struct filestruct filetbl[512]; - -// ================================= Code ==================================== - -void DecryptHeader() -{ byte lastvalue, precodebyte, *ptr; - - ptr=(byte *) filetbl; - lastvalue=*ptr; - ptr++; - - while (ptr < (byte *) (int) filetbl + (int) 5120) - { - precodebyte=*ptr; - (*ptr)-=lastvalue; - lastvalue=precodebyte; - ptr++; - } -} - -void CheckPackHeader() -{ char a; - - fread(strbuf, 1, 7, pack); - strbuf[8]=0; - if (strcmp(strbuf,headertag)) - { - printf("*error* Not a valid VRG packfile. \n"); - exit(-1); - } - fread(&a, 1, 1, pack); - if (a!=1) - { - printf("*error* Incorrect VRG packfile version. \n"); - exit(-1); - } - fread(&numfiles, 1, 4, pack); - fread(&filetbl, 100, numfiles, pack); - DecryptHeader(); -} - -void DumpFiles() -{ int i; - - printf("UNPACK v.0.1 Copyright (C)1997 BJ Eirich\n"); - for (i=0; i \n"); - exit(-1); - } - - if (!(pack=fopen(argv[1],"rb"))) - { - printf("Unable to open file %s. \n",argv[1]); - exit(-1); - } - - CheckPackHeader(); - DumpFiles(); - - fclose(pack); - - return 0; -} diff --git a/16/v2/source/verge/UTIL/UNPACK/UNPACK.TXT b/16/v2/source/verge/UTIL/UNPACK/UNPACK.TXT deleted file mode 100755 index e75838d9..00000000 --- a/16/v2/source/verge/UTIL/UNPACK/UNPACK.TXT +++ /dev/null @@ -1,13 +0,0 @@ -unpack.exe -documentation -by zeromus 5.8.99 -zeromus@verge-rpg.com -(be sure word wrap is on) ---- -USE: extracts files from v2 pakfile ---- -It doesnt get any better than this. type unpack followed by the name of the packfile you want to unpack. if you can't get that right, unpack.exe will give you even more explicit instructions. unpack.exe will then dump all the files contained in the pakfile with their extractable flags set into the directory you ran unpack.exe from. - -Use this only if the author of a demo/game gives you permission to use his stuff, or else we'll hunt you down and break your legs. - -That is all. \ No newline at end of file diff --git a/16/v2/source/verge/VCC/CLEAN.BAT b/16/v2/source/verge/VCC/CLEAN.BAT deleted file mode 100755 index c30021ab..00000000 --- a/16/v2/source/verge/VCC/CLEAN.BAT +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -if exist *.obj del *.obj -if exist *.o del *.o -if exist *.err del *.err diff --git a/16/v2/source/verge/VCC/CODE.H b/16/v2/source/verge/VCC/CODE.H deleted file mode 100755 index bbcfca2c..00000000 --- a/16/v2/source/verge/VCC/CODE.H +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if !defined(__CODE_INC) -#define __CODE_INC - -// Single-byte opcode descriptors - -#define EXEC 1 -#define VAR0_ASSIGN 2 -#define VAR1_ASSIGN 3 -#define VAR2_ASSIGN 4 -#define GENERAL_IF 5 -#define ELSE 6 -#define GOTO 7 -#define FOR_LOOP0 8 -#define FOR_LOOP1 9 -#define SWITCH 10 -#define CASE 11 -#define ENDSCRIPT 255 - -// Single-byte operand descriptors - -#define OP_IMMEDIATE 1 -#define OP_VAR0 2 -#define OP_VAR1 3 -#define OP_VAR2 4 -#define OP_GROUP 5 - -// Single-byte IF handler parameters - -#define ZERO 0 -#define NONZERO 1 -#define EQUALTO 2 -#define NOTEQUAL 3 -#define GREATERTHAN 4 -#define GREATERTHANOREQUAL 5 -#define LESSTHAN 6 -#define LESSTHANOREQUAL 7 - -// Single byte assignment descriptors - -#define SET 1 -#define INCREMENT 2 -#define DECREMENT 3 -#define INCSET 4 -#define DECSET 5 - -// Operand combination descriptors -#define ADD 1 -#define SUB 2 -#define MULT 3 -#define DIV 4 -#define MOD 5 -#define OP_END 255 - -#endif // __CODE_INC diff --git a/16/v2/source/verge/VCC/COMPILE.C b/16/v2/source/verge/VCC/COMPILE.C deleted file mode 100755 index 2de7ce56..00000000 --- a/16/v2/source/verge/VCC/COMPILE.C +++ /dev/null @@ -1,1256 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -// ³ The VergeC Compiler version 2.01 ³ -// ³ Copyright (C)1998 BJ Eirich (aka vecna) ³ -// ³ Code Generation module ³ -// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -#include -#include -#include - -#include "funclib.h" -#include "vcc.h" -#include "vccode.h" -#include "lexical.h" -#include "preproc.h" - -// ================================= Data ==================================== - -#define LETTER 1 -#define SPECIAL 3 - -// -- Function arguements type defs - -#define VOID 1 -#define INT 1 -#define CHARPTR 2 -#define STRING 3 - -unsigned char *source, *src; -unsigned char *outbuf, *code; -unsigned char inevent=0; - -typedef struct -{ - char fname[40]; - char argtype[20]; - int numargs, numlocals; - int returntype; - int syscodeofs; -} funcdecl; - -funcdecl funcs[700]; -int numfuncs=0; - -typedef struct -{ - char vname[40]; - int varstartofs; - int arraylen; -} vardecl; - -vardecl vars[500]; -int curstartofs=0; -int numvars=0; -int varidx; - -typedef struct -{ - char vname[40]; - int vsofs; - int arraylen; -} strdecl; - -strdecl str[300]; -int sstartofs=0; -int numstr=0; - -int vctype; // 0 / 1 :: map / system - -// -- local function parameters -- - -char larg[20][40]; - -// -- MAP vc stuff -- - -char *functbl[512]; -int mfuncs=0; - -// ================================= Code ==================================== - -void HandleString(); -void HandleFunction(); -void HandleUserFunction(); -void HandleFunctionType(); -void EmitOperand(); - -void EmitC (char c) -{ - if (locate && locate == (int)(code - outbuf)) - vcerr("Located."); - - *code++ = c; -} - -void EmitW (short w) -{ - short *c=(short *)code; - - if (locate && locate == (int)(code - outbuf)) - vcerr("Located."); - - *c=w; code+=2; -} - -void EmitD (int d) -{ - long *c=(long *)code; - - if (locate && locate == (int)(code - outbuf)) - vcerr("Located."); - - *c=d; code+=4; -} - -void EmitString(char *str) - { while ((*code++ = *str++)) ; } - -void HandleStringOperand() -{ - if (NextIs("\"")) - { - EmitC(s_IMMEDIATE); - GetString(); - EmitString(token); - return; - } - GetToken(); - if (token_type==IDENTIFIER && varcategory==op_STRING) - { - EmitC(s_GLOBAL); - EmitW(str[varidx].vsofs); - return; - } - if (token_type==IDENTIFIER && varcategory==op_SARRAY) - { - EmitC(s_ARRAY); - EmitW(str[varidx].vsofs); - Expect("["); - EmitOperand(); - Expect("]"); - return; - } - if (token_type==IDENTIFIER && varcategory==op_SLOCAL) - { - EmitC(s_LOCAL); - EmitC((char) varidx); - return; - } - if (TokenIs("str")) - { - EmitC(s_NUMSTR); - Expect("("); - EmitOperand(); - Expect(")"); - return; - } - if (TokenIs("left")) - { - EmitC(s_LEFT); - Expect("("); - HandleString(); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - if (TokenIs("right")) - { - EmitC(s_RIGHT); - Expect("("); - HandleString(); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - if (TokenIs("mid")) - { - EmitC(s_MID); - Expect("("); - HandleString(); - Expect(","); - EmitOperand(); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - if (TokenIs("chr")) - { - EmitC(s_CHR); - Expect("("); - EmitOperand(); - Expect(")"); - return; - } - else vcerr("Unknown string operand. "); -} - -void HandleString() -{ - while (1) - { - HandleStringOperand(); - if (NextIs("+")) - { - EmitC(s_ADD); - GetToken(); - continue; - } - else - { - EmitC(s_END); - break; - } - } -} - -void EmitOperand(); -void DoSomething(); - -void HandleOperand() -{ - GetToken(); - if (token_type==DIGIT) - { - EmitC(op_IMMEDIATE); - EmitD(token_nvalue); - return; - } - if (token_type==IDENTIFIER) - { - if (varcategory==op_UVAR) - { - EmitC(op_UVAR); - EmitD(vars[varidx].varstartofs); - return; - } - if (varcategory==op_UVARRAY) - { - EmitC(op_UVARRAY); - EmitD(vars[varidx].varstartofs); - Expect("["); - EmitOperand(); - Expect("]"); - return; - } - if (varcategory==op_LVAR) - { - EmitC(op_LVAR); - EmitC((char) varidx); - return; - } - if (varcategory==op_HVAR0) - { - EmitC(op_HVAR0); - EmitC((char) varidx); - return; - } - if (varcategory==op_HVAR1) - { - EmitC(op_HVAR1); - EmitC((char) varidx); - Expect("["); - EmitOperand(); - Expect("]"); - return; - } - } - if (token_type==FUNCTION && token_subtype==op_BFUNC) - { - if (!returntypes[funcidx]) - { - vcerr("%s() does not return a vlue.", token); - } - EmitC(op_BFUNC); - HandleFunction(); - return; - } - if (token_type==FUNCTION && token_subtype==op_UFUNC) - { - if (!funcs[funcidx].returntype) - { - vcerr("%s() does not return a vlue.", token); - } - EmitC(op_UFUNC); - HandleUserFunction(); - return; - } - vcerr("Unknown token."); -} - -void EmitOperand() -{ - while (1) // Modifier-process loop. - { - if (NextIs("(")) - { - EmitC(op_GROUP); - GetToken(); - EmitOperand(); - Expect(")"); - } - else HandleOperand(); - - if (NextIs("+")) - { - EmitC(op_ADD); - GetToken(); - continue; - } - else if (NextIs("-")) - { - EmitC(op_SUB); - GetToken(); - continue; - } - else if (NextIs("/")) - { - EmitC(op_DIV); - GetToken(); - continue; - } - else if (NextIs("*")) - { - EmitC(op_MULT); - GetToken(); - continue; - } - else if (NextIs("%")) - { - EmitC(op_MOD); - GetToken(); - continue; - } - else if (NextIs(">>")) - { - EmitC(op_SHR); - GetToken(); - continue; - } - else if (NextIs("<<")) - { - EmitC(op_SHL); - GetToken(); - continue; - } - else if (NextIs("&")) - { - EmitC(op_AND); - GetToken(); - continue; - } - else if (NextIs("|")) - { - EmitC(op_OR); - GetToken(); - continue; - } - else if (NextIs("^")) - { - EmitC(op_XOR); - GetToken(); - continue; - } - else - { - EmitC(op_END); - break; - } - } -} - -void HandleFunction() -{ - switch (funcidx) - { - case 0: vcfunc_Exit(); break; - case 1: Message(); break; - case 2: GenericFunc(3,1); break; - case 3: GenericFunc(4,1); break; - case 4: GenericFunc(5,1); break; - case 5: vc_loadimage(); break; - case 6: GenericFunc(7,5); break; - case 7: GenericFunc(8,5); break; - case 8: GenericFunc(9,0); break; - case 9: GenericFunc(10,0); break; - case 10: vc_AllocateEntity(); break; - case 11: GenericFunc(12,1); break; - case 12: vc_Map(); break; - case 13: vc_LoadFont(); break; - case 14: vc_PlayFLI(); break; - case 15: GenericFunc(16,2); break; - case 16: vc_PrintString(); break; - case 17: vc_LoadRaw(); break; - case 18: GenericFunc(19,4); break; - case 19: GenericFunc(20,1); break; - case 20: GenericFunc(21,7); break; - case 21: GenericFunc(22,0); break; - case 22: GenericFunc(23,0); break; - case 23: GenericFunc(24,1); break; - case 24: vc_EntityMove(); break; - case 25: GenericFunc(26,4); break; - case 26: GenericFunc(27,4); break; - case 27: GenericFunc(28,5); break; - case 28: GenericFunc(29,4); break; - case 29: GenericFunc(30,4); break; - case 30: GenericFunc(31,5); break; - case 31: GenericFunc(32,5); break; - case 32: vc_strlen(); break; - case 33: vc_strcmp(); break; - case 34: GenericFunc(35,0); break; - case 35: GenericFunc(36,1); break; - case 36: GenericFunc(37,1); break; - case 37: GenericFunc(38,1); break; - case 38: GenericFunc(39,3); break; - case 39: GenericFunc(40,2); break; - case 40: GenericFunc(41,1); break; - case 41: GenericFunc(42,1); break; - case 42: GenericFunc(43,3); break; - case 43: vc_HookRetrace(); break; - case 44: vc_HookTimer(); break; - case 45: GenericFunc(46,2); break; - case 46: vc_SetRString(); break; - case 47: GenericFunc(48,4); break; - case 48: GenericFunc(49,3); break; - case 49: GenericFunc(50,0); break; - case 50: vc_PartyMove(); break; - case 51: GenericFunc(52,1); break; - case 52: GenericFunc(53,1); break; - case 53: GenericFunc(54,1); break; - case 54: GenericFunc(55,0); break; - case 55: GenericFunc(56,1); break; - case 56: GenericFunc(57,1); break; - case 57: GenericFunc(58,5); break; - case 58: GenericFunc(59,5); break; - case 59: GenericFunc(60,2); break; - case 60: vc_HookKey(); break; - case 61: vc_PlayMusic(); break; - case 62: GenericFunc(63,0); break; - case 63: GenericFunc(64,5); break; - case 64: vc_OpenFile(); break; - case 65: GenericFunc(66,1); break; - case 66: vc_QuickRead(); break; - case 67: GenericFunc(68,1); break; - case 68: GenericFunc(69,1); break; - case 69: GenericFunc(70,0); break; - case 70: GenericFunc(71,0); break; - case 71: GenericFunc(72,7); break; - case 72: GenericFunc(73,15); break; - case 73: vc_CacheSound(); break; - case 74: GenericFunc(75,0); break; - case 75: GenericFunc(76,3); break; - case 76: GenericFunc(77,7); break; - case 77: GenericFunc(78,4); break; - case 78: GenericFunc(79,4); break; - case 79: vc_val(); break; - case 80: GenericFunc(81,7); break; - case 81: GenericFunc(82,5); break; - case 82: vc_Log(); break; - case 83: GenericFunc(84,2); break; - case 84: GenericFunc(85,2); break; - case 85: GenericFunc(86,3); break; - case 86: GenericFunc(87,1); break; - case 87: GenericFunc(88,1); break; - case 88: GenericFunc(89,1); break; - case 89: vc_fgetline(); break; - case 90: vc_fgettoken(); break; - case 91: vc_fwritestring(); break; - case 92: GenericFunc(93, 3); break; - case 93: vc_frename(); break; - case 94: vc_fdelete(); break; - case 95: vc_fwopen(); break; - case 96: GenericFunc(97, 1); break; - case 97: GenericFunc(98, 3); break; - case 98: GenericFunc(99, 3); break; - case 99: GenericFunc(100, 6); break; - case 100: GenericFunc(101, 0); break; - case 101: GenericFunc(102, 7); break; - case 102: GenericFunc(103, 1); break; - case 103: GenericFunc(104, 1); break; - case 104: GenericFunc(105, 1); break; - case 105: vc_asc(); break; - case 106: GenericFunc(107, 1); break; - case 107: vc_NumForScript(); break; - case 108: vc_FileSize(); break; - case 109: GenericFunc(110, 1); break; - case 110: GenericFunc(111, 0); break; - default: vcerr("Internal error. Unknown standard function."); - } -} - -void HandleUserFunction() -{ - int i, idx; - - idx=funcidx; - EmitW((short) idx); - Expect("("); - for (i=0; i")) { ot=i_GREATERTHAN; GetToken(); } - if (NextIs(">=")) { ot=i_GREATERTHANOREQUAL; GetToken(); } - if (NextIs("<")) { ot=i_LESSTHAN; GetToken(); } - if (NextIs("<=")) { ot=i_LESSTHANOREQUAL; GetToken(); } - - if (!ot) EmitC(i_NONZERO); - else if (ot==i_ZERO) EmitC(i_ZERO); - else - { - EmitC(ot); - EmitOperand(); - } -} - -void HandleIfGroup() -{ - while (1) - { - HandleIfComponent(); - - if (NextIs("&&")) - { - EmitC(i_AND); - GetToken(); - continue; - } - else if (NextIs("||")) - { - EmitC(i_OR); - GetToken(); - continue; - } - else - { - GetToken(); - if (!TokenIs(")") && !TokenIs(";")) - vcerr("Syntax error."); - EmitC(i_UNGROUP); - break; - } - } -} - -void ProcessIf() -{ - char *falseofs = 0; - char *elseofs = 0; - char *b = 0; - - EmitC(opIF); - Expect("("); - HandleIfGroup(); - - falseofs=code; - EmitD(0); // We'll come back to this and fix it up. - - if (!NextIs("{")) - { - DoSomething(); - if (NextIs("else")) - { - EmitC(opGOTO); - elseofs=code; - EmitD(0); - } - } - else - { - Expect("{"); - while (!NextIs("}")) DoSomething(); - Expect("}"); - if (NextIs("else")) - { - EmitC(opGOTO); - elseofs=code; - EmitD(0); - } - } - - b=code; // Put correct false-execution offset thingy. - code=falseofs; - EmitD((int) b - (int) outbuf); - code=b; - - if (NextIs("else")) - { - GetToken(); - if (!NextIs("{")) - { - DoSomething(); - } - else - { - Expect("{"); - while (!NextIs("}")) DoSomething(); - Expect("}"); - } - b=code; // Put correct else-execution offset thingy. - code=elseofs; - EmitD((int) b - (int) outbuf); - code=b; - } -} - -void ProcessWhile() -{ char *falseofs, *top, *b; - - top=code; - EmitC(opIF); - Expect("("); - HandleIfGroup(); - - falseofs=code; - EmitD(0); // We'll come back to this and fix it up. - - if (!NextIs("{")) - { - DoSomething(); - EmitC(opGOTO); - EmitD((int) top - (int) outbuf); - } - else - { - Expect("{"); - while (!NextIs("}")) DoSomething(); - Expect("}"); - EmitC(opGOTO); - EmitD((int) top - (int) outbuf); - } - - b=code; // Put correct false-execution offset thingy. - code=falseofs; - EmitD((int) b - (int) outbuf); - code=b; -} - -void ProcessFor() -{ char *src1, *src2, *loopstartpos, *srctmp; - - Expect("("); - while (!TokenIs(";")) - DoSomething(); // Emit initialization code. - - src1=src; // Store position of loop conditional - while (!NextIs(";")) GetToken(); GetToken(); - src2=src; // Store position of end-of-loop code - - while (!NextIs(")")) GetToken(); GetToken(); - loopstartpos=(char *) (int) code - (int) outbuf; - - if (!NextIs("{")) - { - DoSomething(); - } - else - { - Expect("{"); - while (!NextIs("}")) DoSomething(); - Expect("}"); - } - srctmp=src; - src=src2; - while (!TokenIs(")")) - DoSomething(); - src=src1; - EmitC(opIF); - HandleIfGroup(); - EmitD((int) code - (int) outbuf +9); - EmitC(opGOTO); - EmitD((int) loopstartpos); - - src=srctmp; -} - -void HandleAssign() -{ - int vc; - - vc=varcategory; - EmitC(opASSIGN); - if (vc==op_UVAR) - { - EmitC(op_UVAR); - EmitD(vars[varidx].varstartofs); - } - else if (vc==op_UVARRAY) - { - EmitC(op_UVARRAY); - EmitD(vars[varidx].varstartofs); - Expect("["); - EmitOperand(); - Expect("]"); - } - else if (vc==op_LVAR) - { - EmitC(op_LVAR); - EmitC((char) varidx); - } - else if (vc==op_HVAR0) - { - EmitC(op_HVAR0); - EmitC((char) varidx); - } - else if (vc==op_HVAR1) - { - EmitC(op_HVAR1); - EmitC((char) varidx); - Expect("["); - EmitOperand(); - Expect("]"); - } - else if (vc==op_STRING) - { - EmitC(op_STRING); - EmitW((short) str[varidx].vsofs); - } - else if (vc==op_SARRAY) - { - EmitC(op_SARRAY); - EmitW((short) str[varidx].vsofs); - Expect("["); - EmitOperand(); - Expect("]"); - } - else if (vc==op_SLOCAL) - { - EmitC(op_SLOCAL); - EmitW((short) varidx); - } - GetToken(); - if (TokenIs("++")) { EmitC(a_INC); GetToken(); return; } else - if (TokenIs("--")) { EmitC(a_DEC); GetToken(); return; } else - if (TokenIs("+=")) { EmitC(a_INCSET); } else - if (TokenIs("-=")) { EmitC(a_DECSET); } else - if (TokenIs("=")) { EmitC(a_SET); } else - vcerr("Invalid assignment operator."); - if (vc==op_STRING) HandleString(); - else if (vc==op_SARRAY) HandleString(); - else if (vc==op_SLOCAL) HandleString(); - else EmitOperand(); - GetToken(); -} - -int c=0; - -void HandleReturn() -{ - if (!vctype) - { - Expect(";"); - EmitC(opRETURN); - return; - } - if (!funcs[c].returntype) - { - Expect(";"); - EmitC(opRETURN); - return; - } - if (funcs[c].returntype==1) - { - EmitC(opSETRETVAL); - EmitOperand(); - Expect(";"); - EmitC(opRETURN); - return; - } -} - -void ProcessSwitch() -{ char *buf,*retrptr; - - EmitC(opSWITCH); - Expect("("); - EmitOperand(); - Expect(")"); - Expect("{"); - - // case .. option loop - - while (!NextIs("}")) - { - Expect("case"); - EmitC(opCASE); - EmitOperand(); - Expect(":"); - retrptr=code; - EmitD(0); - while (!NextIs("case") && !NextIs("}")) DoSomething(); - EmitC(opRETURN); - buf=code; - code=retrptr; - EmitD((int) buf - (int) outbuf); - code=buf; - } - Expect("}"); - EmitC(opRETURN); -} - -void DoSomething(void) -{ - GetToken(); - if (TokenIs("return")) { HandleReturn(); return; } - if (token_type==FUNCTION) { HandleFunctionType(); Expect(";"); return; } - if (token_type==IDENTIFIER) { HandleAssign(); return; } - if (TokenIs("if")) { ProcessIf(); return; } - if (TokenIs("while")) { ProcessWhile(); return; } - if (TokenIs("for")) { ProcessFor(); return; } - if (TokenIs("switch")) { ProcessSwitch(); return; } - vcerr("Unknown token."); -} - -void DumpSystemIdx() -{ FILE *f; - - vprint("Dumping system.idx index file."); - f=fopen("system.idx","wb"); - - fwrite(&numvars, 1, 4, f); - fwrite(&vars, sizeof vars / 500, numvars, f); - fwrite(&numfuncs, 1, 4, f); - fwrite(&funcs, sizeof funcs / 700, numfuncs, f); - fwrite(&numstr, 1, 4, f); - fwrite(&str, sizeof str / 300, numstr, f); - fclose(f); -} - -void ReadSystemIdx() -{ FILE *f; - - if (!(f=fopen("system.idx","rb"))) - err("Could not access system.idx."); - - fread(&numvars, 1, 4, f); - fread(&vars, sizeof vars / 500, numvars, f); - fread(&numfuncs, 1, 4, f); - fread(&funcs, sizeof funcs / 700, numfuncs, f); - fread(&numstr, 1, 4, f); - fread(&str, sizeof str / 300, numstr, f); - fclose(f); -} - -void DoLocalVariables(int c) -{ - int na; - - na=funcs[c].numargs; - while (NextIs("int") || NextIs("string")) - { - GetToken(); - if (TokenIs("int")) - { - funcs[c].argtype[na]=INT; - GetToken(); - memcpy(larg[na++], token, 40); - while (!NextIs(";")) - { - Expect(","); - funcs[c].argtype[na]=INT; - GetToken(); - memcpy(larg[na++], token, 40); - } - Expect(";"); - } - if (TokenIs("string")) - { - funcs[c].argtype[na]=STRING; - GetToken(); - memcpy(larg[na++], token, 40); - while (!NextIs(";")) - { - Expect(","); - funcs[c].argtype[na]=STRING; - GetToken(); - memcpy(larg[na++], token, 40); - } - Expect(";"); - } - } - funcs[c].numlocals=na; -} - -void CompileMAP(char *fname) -{ FILE *f; - int i; - - // Compiles a map-based VC. - i=strlen(fname); - memcpy(strbuf, fname, i); - strbuf[i]='.'; - strbuf[i+1]='V'; - strbuf[i+2]='C'; - strbuf[i+3]=0; - - PreProcess(strbuf); - - source=(char *) malloc(1000000); - memset(source, 0, 1000000); - outbuf=(char *) malloc(1000000); - memset(outbuf, 0, 1000000); - if (!(f=fopen("vcctemp.$$$","rb"))) - err("Could not open source file."); - fread(source, 1, 1000000, f); - fclose(f); - - ReadSystemIdx(); - - src=source; - code=outbuf; - vctype=0; - - while (*src) - { - functbl[mfuncs]=(char *) (int) code - (int) outbuf; - mfuncs++; - Expect("event"); - Expect("{"); - while (!NextIs("}")) DoSomething(); - Expect("}"); - EmitC(opRETURN); - ParseWhitespace(); - } - dprint("%s.vc (%i lines)", fname, lines); -} - -void SkipBrackets() -{ - while (!NextIs("}")) - { - if (!*src) - err("No matching bracket."); - GetToken(); - if (TokenIs("{")) SkipBrackets(); - } - GetToken(); -} - -void CheckDup() -{ - int i=0; // bitch! - - while (i -#include -#include -#include "compile.h" -#include "funclib.h" -#include "vcc.h" -#include "vccode.h" -#include "lexical.h" - -// ================================= Data ==================================== - -// ================================= Code ==================================== - -void vcfunc_Exit() -{ - EmitC(1); - Expect("("); - HandleString(); - Expect(")"); -} - -void Message() -{ - EmitC(2); - Expect("("); - HandleString(); - Expect(","); - EmitOperand(); - Expect(")"); -} - -void vc_loadimage() -{ - EmitC(6); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_AllocateEntity() -{ - EmitC(11); - Expect("("); - EmitOperand(); - Expect(","); - EmitOperand(); - Expect(","); - HandleString(); - Expect(")"); -} - -void vc_Map() -{ - EmitC(13); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_LoadFont() -{ - EmitC(14); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_PlayFLI() -{ - EmitC(15); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_PrintString() -{ - EmitC(17); - Expect("("); - EmitOperand(); - Expect(","); - HandleString(); - Expect(")"); -} - -void vc_LoadRaw() -{ - EmitC(18); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_EntityMove() -{ - EmitC(25); - Expect("("); - EmitOperand(); - Expect(","); - HandleString(); - Expect(")"); -} - -void vc_strlen() -{ - EmitC(33); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_strcmp() -{ - EmitC(34); - Expect("("); - HandleString(); - Expect(","); - HandleString(); - Expect(")"); -} - -void vc_SetRString() -{ - EmitC(47); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_PartyMove() -{ - EmitC(51); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_PlayMusic() -{ - EmitC(62); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_OpenFile() -{ - EmitC(65); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_HookRetrace() -{ - char *na; - - EmitC(44); - Expect("("); - na=src; - GetToken(); - if (token_subtype == op_UFUNC) - { - EmitC(2); - EmitD(funcidx); - } - else - { - src=na; - EmitC(1); - EmitOperand(); - } - Expect(")"); -} - -void vc_HookTimer() -{ - char *na; - - EmitC(45); - Expect("("); - na=src; - GetToken(); - if (token_subtype == op_UFUNC) - { - EmitC(2); - EmitD(funcidx); - } - else - { - src=na; - EmitC(1); - EmitOperand(); - } - Expect(")"); -} - -void vc_HookKey() -{ - char *na; - - EmitC(61); - Expect("("); - EmitOperand(); - Expect(","); - na=src; - GetToken(); - if (token_subtype == op_UFUNC) - { - EmitC(2); - EmitD(funcidx); - } - else - { - src=na; - EmitC(1); - EmitOperand(); - } - Expect(")"); -} - -void vc_QuickRead() -{ - EmitC(67); - Expect("("); - HandleString(); - Expect(","); - GetToken(); - if (varcategory == op_STRING) - { - EmitC(op_STRING); - EmitW(str[varidx].vsofs); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - if (varcategory == op_SARRAY) - { - EmitC(op_SARRAY); - EmitW(str[varidx].vsofs); - Expect("["); - EmitOperand(); - Expect("]"); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - vcerr("String variable expected."); -} - -void vc_CacheSound() -{ - EmitC(74); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_val() -{ - EmitC(80); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_Log() -{ - EmitC(83); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_fgetline() -{ - EmitC(90); - Expect("("); - GetToken(); - if (varcategory == op_STRING) - { - EmitC(op_STRING); - EmitW(str[varidx].vsofs); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - if (varcategory == op_SARRAY) - { - EmitC(op_SARRAY); - EmitW(str[varidx].vsofs); - Expect("["); - EmitOperand(); - Expect("]"); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - vcerr("String variable expected."); -} - -void vc_fgettoken() -{ - EmitC(91); - Expect("("); - GetToken(); - if (varcategory == op_STRING) - { - EmitC(op_STRING); - EmitW(str[varidx].vsofs); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - if (varcategory == op_SARRAY) - { - EmitC(op_SARRAY); - EmitW(str[varidx].vsofs); - Expect("["); - EmitOperand(); - Expect("]"); - Expect(","); - EmitOperand(); - Expect(")"); - return; - } - vcerr("String variable expected."); -} - -void vc_fwritestring() -{ - EmitC(92); - Expect("("); - HandleString(); - Expect(","); - EmitOperand(); - Expect(")"); -} - -void vc_frename() -{ - EmitC(94); - Expect("("); - HandleString(); - Expect(","); - HandleString(); - Expect(")"); -} - -void vc_fdelete() -{ - EmitC(95); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_fwopen() -{ - EmitC(96); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_asc() -{ - EmitC(106); - Expect("("); - HandleString(); - Expect(")"); -} - -void vc_NumForScript() -{ - EmitC(108); - Expect("("); - GetToken(); - if (token_subtype == op_UFUNC) - EmitD(funcidx); - else vcerr("system script expected."); - Expect(")"); -} - -void vc_FileSize() -{ - EmitC(109); - Expect("("); - HandleString(); - Expect(")"); -} - -void GenericFunc(unsigned char idcode, int numargs) -{ char i; - - EmitC(idcode); - if (!numargs) - { - Expect("("); - Expect(")"); - return; - } - if (numargs==1) - { - Expect("("); - EmitOperand(); - Expect(")"); - return; - } - Expect("("); - for (i=1; i -// + ConvHexToDec() was severely screwed (would not return correct values at -// *all*; own fault)--fixed -// -// + fixed some problems with tick mark parsing. didn't like certain chars. -// -// + fixed floating point exception crash in ConvHexToDec(), which occured -// when using very large hex numbers (i think; like $ffffffff). was due to -// use of pow() -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -#include -#include -#include -#include -#include "compile.h" -#include "vcc.h" -#include "vccode.h" - -// ================================= Data ==================================== - -// Character types - -#define LETTER 1 -#define DIGIT 2 -#define SPECIAL 3 - -// --------------- - -char token[2000]; // Token buffer -int token_nvalue; // int value of token if it's type DIGIT -char token_type; // type of current token. -char token_subtype; // This is just crap. -unsigned char chr_table[256]; // Character type table. - -int lines, tlines; // current line number being processed in -char *source_file; // the current source file - -// ---------------- - -char *hardfuncs[]= -{ - // A - "exit", "message", "malloc", - "free", "pow", "loadimage", - "copysprite", "tcopysprite", "render", - "showpage", "entityspawn", "setplayer", - "map", "loadfont", "playfli", - - // B - "gotoxy", "printstring", "loadraw", - "settile", "allowconsole", "scalesprite", - "processentities", "updatecontrols", "unpress", - "entitymove", "hline", "vline", - "line", "circle", "circlefill", // 30 - - // C - "rect", "rectfill", "strlen", - "strcmp", "cd_stop", "cd_play", - "fontwidth", "fontheight", "setpixel", - "getpixel", "entityonscreen", "random", - "gettile", "hookretrace", "hooktimer", - - // D - "setresolution", "setrstring", "setcliprect", - "setrenderdest", "restorerendersettings","partymove", - "sin", "cos", "tan", - "readmouse", "setclip", "setlucent", - "wrapblit", "twrapblit", "setmousepos", // 60 - - // E - "hookkey", "playmusic", "stopmusic", - "palettemorph", "fopen", "fclose", - "quickread", "addfollower", "killfollower", - "killallfollowers", "resetfollowers", "flatpoly", - "tmappoly", "cachesound", "freeallsounds", - - // F - "playsound", "rotscale", "mapline", - "tmapline", "val", "tscalesprite", - "grabregion", "log", "fseekline", - "fseekpos", "fread", "fgetbyte", - "fgetword", "fgetquad", "fgetline", // 90 - - // G - "fgettoken", "fwritestring", "fwrite", - "frename", "fdelete", "fwopen", - "fwclose", "memcpy", "memset", - "silhouette", "initmosaictable", "mosaic", - "writevars", "readvars", "callevent", // 105 - - // H - "asc", "callscript", "numforscript", - "filesize", "ftell", "checkcorrupt" - }; - -char returntypes[]= -{ - // A - 0, 0, 1, - 0, 1, 1, - 0, 0, 0, - 0, 1, 0, - 0, 1, 0, - - // B - 0, 0, 1, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - - // C - 0, 0, 1, - 1, 0, 0, - 1, 1, 0, - 1, 1, 1, - 1, 0, 0, - - // D - 0, 0, 0, - 0, 0, 0, - 1, 1, 1, - 0, 0, 0, - 0, 0, 0, - - // E - 0, 0, 0, - 0, 1, 0, - 0, 0, 0, - 0, 0, 0, - 0, 1, 0, - - // F - 0, 0, 0, - 0, 1, 0, - 0, 0, 0, - 0, 0, 1, - 1, 1, 0, - - // G - 0, 0, 0, - 0, 0, 1, - 0, 0, 0, - 0, 1, 0, - 0, 0, 0, - - // H - 1, 0, 1, - 1, 1, 0 -}; - -char *hardvar0[]= -{ - "xwin", "ywin", "cameratracking", - "timer", "up", "down", - "left", "right", "b1", - "b2", "b3", "b4", - "screenx", "screeny", "player", // 15 - - "numentsonscreen", "tracker", "mx", - "my", "mb", "vctrace", - "image_width", "image_height", "music_volume", // 24 - "vsp", "lastent", "last_pressed" -}; - -char *hardvar1[]= -{ - "screen", "entity.x", "entity.y", - "entity.tx", "entity.ty", "entity.facing", - "entity.moving", "entity.specframe", "entity.speed", - "entity.movecode", "entsonscreen", "key", - "layer.hline", "byte", "word", // 15 - - "quad", "pal", "sbyte", - "sword", "squad" -}; - -int funcidx = 0; -int varcategory = 0; - -int numhardfuncs = 111; -int numhardvar0 = 27; -int numhardvar1 = 20; - -// ================================= Code ==================================== - -int streq(char *a, char *b) -{ - while (*a) - { - if (*a++ != *b++) - return 0; - } - return (*b==0); -} - -char TokenIs(char *str) - { return streq(str,token); } - -void ParseWhitespace(void) -{ - while (1) - { - while (*src<=' ' && *src>2) - if (!*src++) - return; - - if (src[0]=='/' && src[1]=='/') - { - while (*src && (*src != '\n')) - src++; - continue; - } - - if (src[0]=='/' && src[1]=='*') - { - while (!(src[0]=='*' && src[1]=='/')) - { - src++; - if (!*src) - return; - if (*src == 1) - { - src++; - source_file = src; - while (*src++); - tlines++; - continue; - } - if (*src==2) - { - src++; - lines = (int) *(int *)src; - src += 4; - continue; - } - } - src+=2; - continue; - } - - if (*src == 1) - { - src++; - source_file = src; - while (*src++); - continue; - } - if (*src==2) - { - src++; - lines = (int) *(int *)src; - src += 4; - tlines++; - continue; - } - break; - } -} - -int GetStringIdx(char i) -{ - int j, k=0; - - for (j=0; j1) varcategory=op_UVARRAY; - } - i=0; - while (i1) varcategory=op_SARRAY; - } -} - -void GetIdentifier(void) -{ - int i; - - i=0; - while ((chr_table[*src] == LETTER) || (chr_table[*src] == DIGIT)) - token[i++] = *src++; - token[i]=0; - strlwr(token); - CheckLibFunc(); -} - -void ConvHexToDec() -{ - static const char *const hextbl="0123456789abcdef\0"; - static int pow_lut[]={1,16,256,4096,65536,1048576,16777216,268435456}; - int i=0, pos=0, z=0; - unsigned int j=0; - - if (strlen(token)>9) - vcerr("Hex number exceeds 8 digit maximum."); - - strlwr(token); - i=strlen(token)-1; - token_nvalue=0; - for (pos=0; i>0; pos++,i--) - { - z=token[i]; - for (j=0; j<16; j++) - if (hextbl[j]==z) break; - if (j>=16) - vcerr("Invalid hex number."); - token_nvalue += (j * pow_lut[pos]); - } -} - -void DoTickMarks() -{ - token_nvalue=token[1]; -} - -void GetNumber() -{ - int i; - - if ('\'' == *src) - { - token[0]=*src++; - token[1]=*src++; - token[2]=*src++; - token[3]=0; - } - else - { - i=0; - while (chr_table[*src] != SPECIAL) - token[i++]=*src++; - token[i]=0; - } - if (token[0]=='$') ConvHexToDec(); - else if (token[0]=='\'') DoTickMarks(); - else token_nvalue=atoi(token); -} - -void GetPunctuation() -{ char c; - - c=*src; - switch (c) - { - case '(': token[0]='('; token[1]=0; src++; break; - case ')': token[0]=')'; token[1]=0; src++; break; - case '{': token[0]='{'; token[1]=0; src++; break; - case '}': token[0]='}'; token[1]=0; src++; break; - case '[': token[0]='['; token[1]=0; src++; break; - case ']': token[0]=']'; token[1]=0; src++; break; - case ',': token[0]=','; token[1]=0; src++; break; - case ':': token[0]=':'; token[1]=0; src++; break; - case ';': token[0]=';'; token[1]=0; src++; break; - case '/': token[0]='/'; token[1]=0; src++; break; - case '*': token[0]='*'; token[1]=0; src++; break; - case '^': token[0]='^'; token[1]=0; src++; break; - case '%': token[0]='%'; token[1]=0; src++; break; - case '\"': token[0]='\"'; token[1]=0; src++; break; - case '+' : token[0]='+'; - src++; - if (*src=='+') - { token[1]='+'; - src++; } - else if (*src=='=') - { token[1]='='; - src++; } - else token[1]=0; - token[2]=0; - break; - case '-' : token[0]='-'; - src++; - if (*src=='-') - { token[1]='-'; - src++; } - else if (*src=='=') - { token[1]='='; - src++; } - else token[1]=0; - token[2]=0; - break; - case '>' : token[0]='>'; - src++; - if (*src=='=') - { token[1]='='; - token[2]=0; - src++; break; } - if (*src=='>') - { token[1]='>'; - token[2]=0; - src++; break; } - token[1]=0; - break; - case '<': token[0]='<'; - src++; - if (*src=='=') - { token[1]='='; - token[2] = 0; - src++; break; } - if (*src=='<') - { token[1]='<'; - token[2] = 0; - src++; break; } - token[1]=0; - break; - case '!': token[0]='!'; - src++; - if (*src=='=') - { token[1]='='; - token[2]=0; - src++; break; } - token[1]=0; - break; - case '=': token[0]='='; - src++; - if (*src=='=') - { token[1]=0; - src++; } - else token[1]=0; - break; - case '&': token[0]='&'; - src++; - if (*src=='&') - { token[1]='&'; - token[2]=0; - src++; break; } - token[1]=0; - break; - case '|': token[0]='|'; - src++; - if (*src=='|') - { token[1]='|'; - token[2]=0; - src++; break; } - token[1]=0; - break; - default: src++; // This should be an error. - } -} - -void GetString(void) -{ - int i; - - // Expects a "quoted" string. Places the contents of the string in - // token[] but does not include the quotes. - - Expect("\""); - i=0; - while (*src!='\"') - { - token[i++]=*src++; - if (i>250) - vcerr("String exceeds 250 character maximum."); - } - src++; - token[i]=0; -} - -void GetToken(void) -{ - int i; - - // Simply reads in the next statement and places it in the - // token buffer. - - ParseWhitespace(); - i=0; - - switch (chr_table[*src]) - { - case LETTER: { token_type = IDENTIFIER; GetIdentifier(); break; } - case DIGIT: { token_type = DIGIT; GetNumber(); break; } - case SPECIAL: { token_type = CONTROL; GetPunctuation(); break; } - } - - if (!*src && inevent) - err("Unexpected end of file"); -} - -void Expect(char *str) -{ - GetToken(); - if (TokenIs(str)) return; - vcerr("error: %s expected, %s got", str, token); -} - -int ExpectNumber() -{ - GetToken(); - if (token_type!=DIGIT) err("error: Numerical value expected"); - return token_nvalue; -} - -void InitCompileSystem() -{ int i; - - vprint("Building chr_table[]."); - for (i=0; i<256; i++) chr_table[i]=SPECIAL; - for (i='0'; i<='9'; i++) chr_table[i]=DIGIT; - for (i='A'; i<='Z'; i++) chr_table[i]=LETTER; - for (i='a'; i<='z'; i++) chr_table[i]=LETTER; - - chr_table[10]=0; - chr_table[13]=0; - chr_table[' ']=0; - chr_table['_']=LETTER; - chr_table['.']=LETTER; - chr_table['$']=DIGIT; - chr_table[39]=DIGIT; -} - -char lasttoken[2048]; - -int NextIs(char *str) -{ char *ptr,tt,tst; - int i,nv; - - ptr=src; - tt=token_type; - tst=token_subtype; - nv=token_nvalue; - memcpy(lasttoken, token, 2048); - GetToken(); - src=ptr; - token_nvalue=nv; - tst=token_subtype; - tt=token_type; - //if (!strcmp(str,token)) i=1; else i=0; - i=streq(str,token); - memcpy(token, lasttoken, 2048); - return i; -} diff --git a/16/v2/source/verge/VCC/LEXICAL.H b/16/v2/source/verge/VCC/LEXICAL.H deleted file mode 100755 index 7f9d02bb..00000000 --- a/16/v2/source/verge/VCC/LEXICAL.H +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if !defined(__LEXICAL_INC) -#define __LEXICAL_INC - -extern void ParseWhitespace(); -extern void GetNumber(); -extern void GetToken(); -extern void InitCompileSystem(); -extern int NextIs(char *str); - -extern void GetString(void); - -extern char token[2000]; // Token buffer -extern unsigned int token_nvalue; // int value of token if it's type DIGIT -extern char token_type; // type of current token. -extern char token_subtype; // This is just crap. -extern unsigned char chr_table[256]; // Character type table. -extern char returntypes[]; -extern int lines, tlines; -extern char *source_file; - -extern char TokenIs(char *str); -extern void Expect(char *str); - -extern int numhardfuncs, funcidx; -extern int varcategory, numhardvar0; -extern int numhardvar1; -extern char *hardfuncs[]; -extern char *hardvar0[]; -extern char *hardvar1[]; - -#endif // __LEXICAL_INC diff --git a/16/v2/source/verge/VCC/MAKEDJ.BAT b/16/v2/source/verge/VCC/MAKEDJ.BAT deleted file mode 100755 index 1804dc67..00000000 --- a/16/v2/source/verge/VCC/MAKEDJ.BAT +++ /dev/null @@ -1,7 +0,0 @@ -@echo off -if exist vcc.exe del vcc.exe -gcc -s -Wall -Werror -m486 -O3 vcc.c preproc.c lexical.c compile.c funclib.c -o dj\vcc.exe -rem gcc -Wall -Werror -pg vcc.c preproc.c lexical.c compile.c funclib.c -o dj\vcc -if not exist dj\vcc.exe goto end -if exist ..\djp.exe djp dj\vcc.exe -:end diff --git a/16/v2/source/verge/VCC/PREPROC.C b/16/v2/source/verge/VCC/PREPROC.C deleted file mode 100755 index f930e857..00000000 --- a/16/v2/source/verge/VCC/PREPROC.C +++ /dev/null @@ -1,799 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -// ³ The VergeC Compiler version 2.01 ³ -// ³ Copyright (C)1998 BJ Eirich (aka vecna) ³ -// ³ Pre Processor module ³ -// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -// CHANGELOG: -// -// + fixed incorrect file markers and last character omission. -// + one more incorrect file marker fix; was not restoring correctly after -// #included files. -// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -#ifdef __WATCOMC__ -#include -#endif - -#include -#include -#include -#include -#include - -#include "vcc.h" -#include "lexical.h" - -int pp_dump; -int pp_nomark; -static int pp_tempct = 0; - -typedef struct - { - char *sym; - int sym_len; - - char *resolve; - int resolve_len; - - } pp_def; - -typedef struct - { - char *filename; - char *data; - - } pp_include; - -void Process(char *filename); -char *pp_token(char *p); - -//////////////////////////////////////////////////////////////////////////// -// DATA //////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// - -pp_def *pp_defarr = NULL; - -int pp_num_defs = 0; -int pp_defs_allocated = 0; -int PP_DEFS_BLOCK = 25; - -pp_include pp_incarr[100]; -//pp_include *pp_icur = NULL; // get rid of this -char *cur_filename=0; -char *last_filename=0; - -int pp_num_includes = 0; - -int pp_line = 0; -int pp_total_lines = 0; - -const int EOF_CHAR = 0x00; - -char pp_chr_table[256]; - -enum - { - PP_ERROR, - PP_WHITE, - PP_PUNC, - PP_DIGIT, - PP_LETTER, - PP_QUOTE, - PP_DIRECTIVE, - PP_NEWLINE, - PP_EOF - }; - -FILE *pp_out = NULL; - -char pp_tok[1024]; -int pp_toktype = 0; - -int pp_last_delim = 1; - -//////////////////////////////////////////////////////////////////////////// -// CODE //////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// - -int logging=1; -void log(char *str) -{ - if (logging) - { - FILE *fp = fopen("error.log", "a"); - fprintf(fp, str); - fflush(fp); - fclose(fp); - } -} - -void init_pp_chr_table() -{ - int x; - - memset(pp_chr_table, PP_ERROR, 256); - - pp_chr_table[EOF_CHAR] = PP_EOF; - - for (x='A'; x<='Z'; x++) pp_chr_table[x] = PP_LETTER; - for (x='a'; x<='z'; x++) pp_chr_table[x] = PP_LETTER; - pp_chr_table['_'] = PP_LETTER; - pp_chr_table['.'] = PP_LETTER; - - for (x='0'; x<='9'; x++) pp_chr_table[x] = PP_DIGIT; - pp_chr_table['$'] = PP_DIGIT; - pp_chr_table['\''] = PP_DIGIT; - - pp_chr_table['+'] = pp_chr_table['-'] = PP_PUNC; - pp_chr_table['*'] = pp_chr_table['/'] = PP_PUNC; - pp_chr_table['%'] = PP_PUNC; - pp_chr_table['|'] = pp_chr_table['&'] = PP_PUNC; - pp_chr_table['='] = pp_chr_table['^'] = PP_PUNC; - pp_chr_table[','] = PP_PUNC; - pp_chr_table['<'] = pp_chr_table['>'] = PP_PUNC; - pp_chr_table['('] = pp_chr_table[')'] = PP_PUNC; - pp_chr_table['['] = pp_chr_table[']'] = PP_PUNC; - pp_chr_table['{'] = pp_chr_table['}'] = PP_PUNC; - pp_chr_table[':'] = pp_chr_table[';'] = PP_PUNC; - pp_chr_table['\\'] = pp_chr_table['!'] = PP_PUNC; - - pp_chr_table[' '] = pp_chr_table['\t'] = PP_WHITE; - pp_chr_table['\r'] = PP_WHITE; - - pp_chr_table['\n'] = PP_NEWLINE; - - pp_chr_table['\"'] = PP_QUOTE; - - pp_chr_table['#'] = PP_DIRECTIVE; -} - -void pp_line_marker() -{ - if (pp_nomark) return; - - fputc(2, pp_out); - fwrite(&pp_line, 1, 4, pp_out); -} - -void pp_file_marker() -{ - if (pp_nomark) return; - - fputc(1, pp_out); - fwrite(cur_filename, 1, strlen(cur_filename)+1, pp_out); -} - -void pp_error(const char *error, ...) -{ - va_list lst; - char string[1024]; - - va_start (lst, error); - vsprintf (string, error, lst); - va_end (lst); - - printf ("*preproc error* "); - err (string); -} - -void pp_line_error(const char *error, ...) -{ - va_list lst; - char string[1024]; - - va_start (lst, error); - vsprintf (string, error, lst); - va_end (lst); - - printf ("%s(%d) ", cur_filename, pp_line); - pp_error (string); -} - -int pp_is_punc(int c) - { return (PP_PUNC == pp_chr_table[c]); } - -int pp_is_letter(int c) - { return (PP_LETTER == pp_chr_table[c]); } - -int pp_is_digit(int c) - { return (PP_DIGIT == pp_chr_table[c]); } - -int pp_is_ident(int c) - { return (pp_is_letter(c) || pp_is_digit(c)); } - -int pp_is_white(int c) - { return (PP_WHITE == pp_chr_table[c]); } - -int pp_is_directive(int c) - { return (PP_DIRECTIVE == pp_chr_table[c]); } - -int pp_is_eof(int c) - { return (PP_EOF == pp_chr_table[c]); } - -pp_def *pp_def_add(char *sym, char *resolve) -{ - pp_def *pp = NULL; - pp_def *p = NULL; - - if (!(pp_defs_allocated % PP_DEFS_BLOCK)) - { - pp_defs_allocated += PP_DEFS_BLOCK; - - p = (pp_def *)realloc( - pp_defarr, pp_defs_allocated * sizeof(pp_def)); - if (!p) pp_error("unable to grow #define list"); - - pp_defarr = p; - } - - pp = &pp_defarr[pp_num_defs]; - ++pp_num_defs; - - pp->sym = (char *)malloc(strlen(sym) +1); - if (!pp->sym) - pp_error("memory exhausted"); - strcpy(pp->sym, sym); - pp->sym_len = strlen(sym); - - pp->resolve = (char *)malloc(strlen(resolve) +1); - if (!pp->resolve) - pp_error("memory exhausted"); - strcpy(pp->resolve, resolve); - pp->resolve_len = strlen(resolve); - - return pp; -} - -pp_include *pp_include_add(char *filename) -{ - FILE *in = NULL; - pp_include *pp = NULL; - int z = 0; - - if (pp_num_includes) - { - int i; - for (i=0; idata = (char *)malloc((z +2) * sizeof(char)); - if (!pp->data) pp_error("memory exhausted"); - fread(pp->data, 1, z, in); - fclose(in); - - pp->data[z++] = 32; // - pp->data[z] = EOF_CHAR; - - pp->filename = (char *)malloc(strlen(filename) +1); - if (!pp->filename) pp_error("memory exhausted"); - strcpy(pp->filename, filename); - cur_filename=pp->filename; - - return pp; -} - -char *pp_skip_c_comment(char *p) -{ - p += 2; - while (*p && ('*' != *p || '/' != p[1])) - { - if ('\n' == *p) - { - ++pp_line; - pp_line_marker(); - } - if ('/' == *p && '*' == p[1]) - p = pp_skip_c_comment(p); - else ++p; - } - if (*p) p += 2; - - return p; -} - -char *pp_skip_cpp_comment(char *p) -{ - p += 2; - while (*p && '\n' != *p) - ++p; - if (*p) - { - ++p; - - ++pp_line; - pp_line_marker(); - } - - return p; -} - -char *pp_skipwhite(char *p) -{ - for (;;) - { - while (*p && PP_WHITE == pp_chr_table[(int) *p]) - ++p; - - if ('\n' == *p) - { - ++p; - - ++pp_line; - pp_line_marker(); - continue; - } - - // skip comments - if ('/' == *p) - { - switch (p[1]) - { - case '/': p = pp_skip_cpp_comment(p); continue; - case '*': p = pp_skip_c_comment(p); continue; - } - } - - break; - } - - return p; -} - -char *pp_token_punc(char *p) -{ - char *s = pp_tok; - - do { - *s++ = *p++; - } while (*p && pp_is_punc(*p)); - *s = 0; - - return p; -} - -/* -int is_hex(int c) -{ - return ( - (c >= '0' && c <= '9') - || (c >= 'A' && c <= 'F') - || (c >= 'a' && c <= 'f')); -} -*/ - -char *pp_token_digit(char *p) -{ - char *s = pp_tok; - - if ('\'' == *p) - { - *s++ = *p++; - if (!*p) return NULL; - *s++ = *p++; - if (!*p) return NULL; - *s++ = *p++; - if (!*p) return NULL; - *s = 0; - } - else - { - do { - *s++ = *p++; - } while (*p && pp_is_digit(*p)); - if (*p) *s = 0; - } - - return p; -} - -char *pp_token_letter(char *p) -{ - char *s = pp_tok; - - do { - *s++ = *p++; - } while (*p && pp_is_ident(*p)); - if (*p) *s = 0; - - return p; -} - -char *pp_token_directive(char *p) -{ - char *s = pp_tok; - - ++p; // skip # - - // directive name - do { - *s++ = *p++; - } while (pp_is_ident(*p)); - *s = 0; - - // #include - if (!strcmp(pp_tok, "include")) - { - // boogly boogly boogly! - int l = 0; - char *e = NULL; - - //printf("#include detected \n"); - - // any whitespace after 'include' - p = pp_skipwhite(p); - - // skip, but don't expect, a " - if ('\"' == *p) ++p; - - // grab the filename - e = pp_tok; - while (*p && '\"' != *p) - *e++ = *p++; - // if we didn't hit eof...? - if (*p) - { - // zero term filename - *e = 0; - // skip closing " - ++p; - - last_filename=cur_filename; // - l = pp_line; // save - Process(pp_tok); - pp_line = l; // restore - cur_filename=last_filename; // - // reset file marker - pp_file_marker(); - - // disregard rest of line - while (*p && '\n' != *p) - ++p; - // if we didn't hit eof...? - if (*p) - { - // skip newline char - ++p; - - // update line - ++pp_line; - pp_line_marker(); - - // dump null token... writes nothing i think... - pp_tok[0]='\0'; - } - //else pp_error("screw you!"); - } - } - // #define - else if (!strcmp(pp_tok, "define")) - { - char *e = NULL; - char sym[256]; - char resolve[1024]; - - // find start of symbol - while (' ' == *p || '\t' == *p) - ++p; - - // parse symbol - e = sym; - while (pp_is_ident(*p)) - { *e++ = *p++; } - *e = 0; - - // check for duplicate #defines - if (pp_num_defs) - { - int i; - int z = strlen(sym); - for (i=0; i", *p, *p); - } - - return p; -} - -void Process(char *filename) -{ - char *s = NULL; - pp_include *ppi = NULL; - - // starts fresh for each #include file - pp_line = 1; - //pp_line_marker(); // hmm... did this kill the wat ver? i forget.. - - // push file - ppi = pp_include_add(filename); - s = ppi->data; - - pp_file_marker(); - - pp_last_delim = 1; - s = pp_token(s); - - // loop until we hit an EOF token - while (*s && PP_EOF != pp_toktype) - { - // for compactor; this is absolutely required for the parsing to - // work correctly for hex numbers - if (PP_LETTER == pp_toktype || PP_DIGIT == pp_toktype) - { - if (!pp_last_delim) - fputc(' ', pp_out); - } - - if (pp_num_defs) - { - // #define replacement - if (PP_LETTER == pp_toktype) - { - pp_def *ppd = NULL; - int pp_token_len = strlen(pp_tok); - int i = 0; - - for (i=0; isym_len == pp_token_len) - { - // lengths match, compare bytes - if (!stricmp(pp_tok, ppd->sym)) - { - // match! overwrite token with resolve - memcpy(pp_tok, ppd->resolve, strlen(ppd->resolve)+1); - break; - } - } - } - } - } - - // write whatever we got - fwrite(pp_tok, 1, strlen(pp_tok), pp_out); - - pp_last_delim = (PP_LETTER != pp_toktype); - s = pp_token(s); - } - - // pop file - free(ppi->data); - free(ppi->filename); - --pp_num_includes; - //pp_icur = &pp_incarr[pp_num_includes]; // oops! :-) - - pp_total_lines += pp_line; -} - -void pp_dump_output() -{ - char strx[1024]; - - sprintf(strx, "copy vcctemp.$$$ vcc%i.$$$", pp_tempct); - ++pp_tempct; - - system(strx); -} - -void PreProcess(char *filename) -{ - pp_num_includes = 0; - init_pp_chr_table(); - - pp_out = fopen("VCCTEMP.$$$", "wb"); - if (!pp_out) pp_error("unable to open VCCTEMP.$$$"); - - Process(filename); - - fclose(pp_out); - - // dump preproc output? - if (0 != pp_dump) - pp_dump_output(); -} diff --git a/16/v2/source/verge/VCC/PREPROC.H b/16/v2/source/verge/VCC/PREPROC.H deleted file mode 100755 index e5f8784d..00000000 --- a/16/v2/source/verge/VCC/PREPROC.H +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if !defined(__PREPROC_INC) -#define __PREPROC_INC - -extern void PreProcess(char *fname); -extern void Process(char *fname); - -#endif // __PREPROC_INC diff --git a/16/v2/source/verge/VCC/VCC.C b/16/v2/source/verge/VCC/VCC.C deleted file mode 100755 index 0a8a5c33..00000000 --- a/16/v2/source/verge/VCC/VCC.C +++ /dev/null @@ -1,342 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -// ³ The VergeC Compiler ³ -// ³ Copyright (C)1998 BJ Eirich (aka vecna) ³ -// ³ Main module ³ -// ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ - -#define VERSION "2.01c" - -#ifdef __DJGPP__ -#define BUILD_TAG "DJGPP V2\0" -#endif - -#ifdef __WATCOMC__ -#define BUILD_TAG "Watcom 11.0\0" -#endif - -#include -#include -#include -#include -#include - -#include "compile.h" -#include "lexical.h" - -extern int pp_dump; -extern int pp_nomark; - -// ================================= Data ==================================== - -char outmode, cmode; -char fname[80]; -char quiet, verbose; -char *strbuf; -int locate=0; - -// -- locals -- - -//FILE *f; -//int i; -//struct find_t *ft; - -// ================================= Code ==================================== - -void dprint(char *message, ...) -{ - va_list lst; - char string[1024]; - - if (quiet) return; - - // compose message - va_start (lst, message); - vsprintf (string, message, lst); - va_end (lst); - - printf ("%s \n", string); -} - -void vprint(char *message, ...) -{ - va_list lst; - char string[1024]; - - if (!verbose) return; - - // compose message - va_start (lst, message); - vsprintf (string, message, lst); - va_end (lst); - - printf ("%s \n", string); -} - -void err(char *message, ...) -{ - va_list lst; - char string[1024]; - - // compose message - va_start (lst, message); - vsprintf (string, message, lst); - va_end (lst); - - if (quiet) - { - FILE *efile = fopen("ERROR.TXT", "w"); - - fprintf(efile, "%s \n", string); - fclose(efile); - } - else - { - printf("%s \n", string); - } - - remove("vcctemp.$$$"); - exit(-1); -} - -void vcerr(char *message, ...) -{ - va_list lst; - char string[1024]; - - // compose message - va_start (lst, message); - vsprintf (string, message, lst); - va_end (lst); - - err("%s(%d) %s", source_file, lines, string); -} - -void vcc_compile_mode_map(char *filename) -{ - FILE *o=0; - FILE *f=0; - char *x=0; - int z=0; - - x = filename; - while ('.' != *x) ++x; - *x = 0; - - CompileMAP(filename); - - sprintf(strbuf, "%s.map", filename); - f = fopen(strbuf, "rb+"); - if (!f) - err("unable to open %s.", strbuf); - - fread(strbuf, 1, 6, f); - fread(&z, 1, 4, f); - fseek(f, 0, 0); - - o = fopen("outtemp.$$$", "wb"); - if (!o) - err("unable to open outtemp.$$$"); - x = (char *) malloc(z); - fread(x, 1, z, f); - fwrite(x, 1, z, o); - fclose(f); - - fwrite(&mfuncs, 1, 4, o); - fwrite(&functbl, 4, mfuncs, o); - mfuncs = (int) code - (int) outbuf; - fwrite(&mfuncs, 1, 4, o); - fwrite(outbuf, 1, code-outbuf, o); - fclose(o); - - // remove existing map file - sprintf(strbuf,"%s.map", filename); remove(strbuf); - // rename temp file to map file name - rename("outtemp.$$$", strbuf); -} - -void vcc_compile_mode_system() -{ - FILE *dump=0; - - CompileSystem(); - - dump = fopen("system.vcs", "wb"); - if (!dump) err("unable to open system.vcs"); - - fwrite(&numfuncs, 1, 4, dump); - fwrite(&curstartofs, 1, 4, dump); - fwrite(&sstartofs, 1, 4, dump); - fwrite(outbuf, 1, code-outbuf, dump); - fputc(255, dump); - - fclose(dump); -} - -void vcc_compile_mode_all() -{ - FILE *o=0; - FILE *f=0; - char *x=0; - int z=0; - struct find_t fileinfo; - - CompileSystem(); - f=fopen("system.vcs","wb"); - fwrite(&numfuncs, 1, 4, f); - fwrite(&curstartofs, 1, 4, f); - fwrite(&sstartofs, 1, 4, f); - fwrite(outbuf, 1, code-outbuf, f); - fputc(255, f); - fclose(f); - free(source); - free(outbuf); - - if (_dos_findfirst("*.MAP", _A_NORMAL, &fileinfo)) - err("No mapfiles found."); - - while (1) - { - int i; - memcpy(fname, fileinfo.name, 13); - - i=0; - while (fname[i]!='.') i++; - fname[i]=0; - - strlwr(fname); - mfuncs=0; - - CompileMAP(fname); - - sprintf(strbuf,"%s.map", fname); - f=fopen(strbuf,"rb+"); - fread(strbuf, 1, 6, f); - fread(&z, 1, 4, f); - fseek(f, 0, 0); - - o=fopen("outtemp.$$$","wb"); - x=(char *) malloc(z); - fread(x, 1, z, f); - fwrite(x, 1, z, o); - fclose(f); - free(x); - - fwrite(&mfuncs, 1, 4, o); - fwrite(&functbl, 4, mfuncs, o); - mfuncs=(int) code - (int) outbuf; - fwrite(&mfuncs, 1, 4, o); - fwrite(outbuf, 1, code-outbuf, o); - fclose(o); - - sprintf(strbuf,"%s.map", fname); - remove(strbuf); - rename("outtemp.$$$",strbuf); - - free(source); - free(outbuf); - - if (!_dos_findnext(&fileinfo)) - continue; - - break; - } - - dprint("%i total VC lines compiled.", tlines); -} - -int main(int argc, char *argv[]) -{ - int loop = 0; - char c = 0; - char *argstr = 0; - - strbuf= (char *) malloc(2000); - - cmode = 0; - pp_dump = 0; - pp_nomark = 0; - - for (loop = 1; loop < argc; loop++) - { - // point to argument string - argstr = &loop[argv][0]; - - c = *argstr; - // skip leading punctuators, if any - if ('-' == c || '+' == c || '/' == c) - ++argstr; - - if (!stricmp(argstr, "v")) - { verbose = 1; continue; } - - if (!stricmp(argstr, "q")) - { quiet = 1; continue; } - - // compile SYSTEM.VC only - if (!stricmp(argstr, "system")) - { cmode = 2; continue; } - - // compile all available .VC files - if (!stricmp(argstr, "all")) - { cmode = 3; continue; } - - // disable line/#include markers - if (!stricmp(argstr, "ppnomark")) - { pp_nomark = 1; continue; } - - // dump preprocessor output to temp files - if (!stricmp(argstr, "ppdump")) - { pp_dump = 1; continue; } - - // debug locator option - if ('.' == *argstr) - { locate = atoi(argstr+1); continue; } - - // at this point, the argument is assumed to be a file - - if (strlen(argstr) > 79) - { printf("filename '%s' too long!", argstr); argstr[79] = 0; } - memcpy(fname, argstr, strlen(argstr)+1); - - cmode = 1; - continue; - } - - dprint("vcc v.%s Copyright (C)1998 Benjamin Eirich. All rights reserved.", VERSION); - vprint("%s build %s on %s %s", BUILD_TAG, __FILE__, __DATE__, __TIME__); - - if (!cmode) - err("No input files."); - - InitCompileSystem(); - - switch (cmode) - { - case 1: vcc_compile_mode_map(fname); break; - case 2: vcc_compile_mode_system(); break; - case 3: vcc_compile_mode_all(); break; - - default: err("you have now entered the twilight zone."); - } - - remove("vcctemp.$$$"); - remove("ERROR.TXT"); - - return 0; -} diff --git a/16/v2/source/verge/VCC/VCC.H b/16/v2/source/verge/VCC/VCC.H deleted file mode 100755 index 99a91f72..00000000 --- a/16/v2/source/verge/VCC/VCC.H +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if !defined(__VCC_INC) -#define __VCC_INC - -#define QUIET 0 -#define DEFAULT 1 -#define VERBOSE 2 - -#define CONTROL 1 -#define DIGIT 2 -#define IDENTIFIER 3 -#define RESERVED 4 -#define FUNCTION 5 - -extern char *strbuf; -extern int locate; - -extern void err(char *message, ...); -extern void vcerr(char *message, ...); -extern void dprint(char *message, ...); -extern void vprint(char *message, ...); - -#endif // __VCC_INC diff --git a/16/v2/source/verge/VCC/VCCODE.H b/16/v2/source/verge/VCC/VCCODE.H deleted file mode 100755 index 74495139..00000000 --- a/16/v2/source/verge/VCC/VCCODE.H +++ /dev/null @@ -1,111 +0,0 @@ -/* -Copyright (C) 1998 BJ Eirich (aka vecna) -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 Lic -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -// We never use zero as a tag. This makes it easier to track down misbehaving -// VC code, since zero is commonly come-by when going off into uncharted -// depths of memory. - -#define ERROR 0 - -// Opcode values. - -#define opEXEC_STDLIB 1 -#define opEXEC_LOCALFUNC 2 -#define opEXEC_EXTERNFUNC 3 -#define opIF 4 -#define opELSE 5 -#define opGOTO 6 -#define opSWITCH 7 -#define opCASE 8 -#define opRETURN 9 -#define opASSIGN 10 -#define opSETRETVAL 11 -#define opSETLOCALSTACK 12 - -// Operand types. - -#define op_IMMEDIATE 1 -#define op_HVAR0 2 -#define op_HVAR1 3 -#define op_UVAR 4 -#define op_UVARRAY 5 -#define op_LVAR 6 -#define op_BFUNC 7 -#define op_UFUNC 8 -#define op_GROUP 9 -#define op_STRING 10 -#define op_SARRAY 11 -#define op_SLOCAL 12 - -// Variable types. - -#define v_IMMEDIATE 1 // is this necessary? -#define v_CHAR 2 -#define v_PTR 3 -#define v_INT 4 - -// IF relational operators. - -#define i_ZERO 1 -#define i_NONZERO 2 -#define i_EQUALTO 3 -#define i_NOTEQUAL 4 -#define i_GREATERTHAN 5 -#define i_LESSTHAN 6 -#define i_GREATERTHANOREQUAL 7 -#define i_LESSTHANOREQUAL 8 -#define i_GROUP 9 -#define i_UNGROUP 10 -#define i_AND 11 -#define i_OR 12 - -// Assignment operators. - -#define a_SET 1 -#define a_INC 2 -#define a_DEC 3 -#define a_INCSET 4 -#define a_DECSET 5 -#define a_MULTSET 6 -#define a_DIVSET 7 - -// Operand combination operators. - -#define op_ADD 1 -#define op_SUB 2 -#define op_MULT 3 -#define op_DIV 4 -#define op_MOD 5 -#define op_SHL 6 -#define op_SHR 7 -#define op_AND 8 -#define op_OR 9 -#define op_XOR 10 -#define op_END 11 - -// String components - -#define s_IMMEDIATE 1 -#define s_GLOBAL 2 -#define s_ARRAY 3 -#define s_NUMSTR 4 -#define s_LEFT 5 -#define s_RIGHT 6 -#define s_MID 7 -#define s_LOCAL 8 -#define s_ADD 9 -#define s_CHR 10 -#define s_END 11 diff --git a/16/v2/source/verge/gnu.txt b/16/v2/source/verge/gnu.txt deleted file mode 100755 index 358ef6fb..00000000 --- a/16/v2/source/verge/gnu.txt +++ /dev/null @@ -1,87 +0,0 @@ -GNU GENERAL PUBLIC LICENSE -Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -Preamble -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. - -For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - -We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. - -Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. - -Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and modification follow. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - - -a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. - -b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. - -c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: - -a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - -b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, - -c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) -The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. -If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. - -7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. - -10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - -END OF TERMS AND CONDITIONS