Initial put
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
copy *.c backup
|
||||
copy *.h backup
|
||||
copy *.asm backup
|
||||
copy *.prj backup
|
||||
copy *.dsk backup
|
||||
copy _*.obj backup
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
+12
@@ -0,0 +1,12 @@
|
||||
//////////////////////////////////////
|
||||
//
|
||||
// Graphics DEFINE file for .TED
|
||||
// FGRAB-ed on Thu Aug 08 17:33:46 1991
|
||||
//
|
||||
//////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Thank you for using FGRAB!
|
||||
//
|
||||
@@ -0,0 +1,97 @@
|
||||
TED 5.0 Features
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
__ Handles all current tile types with ease of expansion for future sizes.
|
||||
Current sizes are: 8x8,16x16,32x32. Only one tile size is permitted per
|
||||
map set.
|
||||
|
||||
__ Handles any amount of tiles that will fit in EMS memory. If EMS is not
|
||||
present, you can't use TED 5.0!
|
||||
|
||||
__ Handles masked and non-masked tiles.
|
||||
|
||||
__ Each map has 3 planes: background tiles, foreground tiles, and extra
|
||||
info. The extra info plane will blit icons for values 0-63 (?), higher
|
||||
values will be printed as hex. Planes will be selected upon project
|
||||
creation.
|
||||
|
||||
__ Must have ability to turn on/off each individual plane so all planes
|
||||
can be on or off at once.
|
||||
|
||||
__ Video modes supported will be CGA 320x200, EGA 320x200/640x480/800x600,
|
||||
VGA 320x200 256-color.
|
||||
|
||||
__ Map Morph feature will allow user to select a block area and make snap-
|
||||
shots of it, modify the area, make another snapshot, etc. until the
|
||||
morph process is completed. Full editing capabilities will include:
|
||||
DELETE FRAME, INSERT FRAME, MAKE SNAPSHOT.
|
||||
|
||||
__ TileInfo feature will allow user to edit tile attributes. Editing capa-
|
||||
bilities will include: ADD, DELETE, CHANGE NAME.
|
||||
|
||||
__ TED editing feature will include:
|
||||
|
||||
__ Flood Fill
|
||||
__ Block Fill
|
||||
__ Copy Block (from tile maps as well) with SparseTile handling
|
||||
__ Paste (with floating corners)
|
||||
__ Draw
|
||||
__ Line
|
||||
|
||||
__ Other features:
|
||||
|
||||
__ Info Bar (on/off)
|
||||
__ Tile Search
|
||||
__ Map Info
|
||||
__ ScrollKeys (SHIFT for full screen moves)
|
||||
__ Right-Button tile-pickup
|
||||
__ Map Resizing (with Edge Selection)
|
||||
__ X,Y coords in Hex & Dec
|
||||
__ All numeric input will support HEX,DEC,BIN
|
||||
|
||||
__ Map files will be saved as either MAPTEMP.ext for the RLEW-only
|
||||
(development) version, or GAMEMAPS.ext for the HUFF/RLEW version.
|
||||
|
||||
__ Dialogs will be implemented.
|
||||
|
||||
__ Project selection.
|
||||
|
||||
__ Map selection by name!
|
||||
|
||||
__ Create ApplePreferred or ILBM Map dumps
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Map Header Struct
|
||||
-------------------------------------------------------------------
|
||||
size what description
|
||||
-------------------------------------------------------------------
|
||||
unsigned HeaderSize size of the entire map header
|
||||
unsigned MapType how many planes the map has. If there
|
||||
are 3, you have back/foreground & info.
|
||||
If there are 2, you have back & info, If
|
||||
there is 1, you have background.
|
||||
unsigned TileSize size of tiles map is made for
|
||||
(1=8,2=16,3=32)
|
||||
long TileInfoOff offset to TILEINFO data
|
||||
long TileInfoMOff offset to MASKED TILEINFO data
|
||||
unsigned RLEWtag RLEW tag byte
|
||||
unsigned Dictionary offset to Huff dictionary. 0 if RLEW only.
|
||||
unsigned DataOffsets offset to MapOffset list
|
||||
...
|
||||
long MapOffsets offsets to Maps in map file
|
||||
|
||||
|
||||
|
||||
Map Structure
|
||||
-------------------------------------------------------------------
|
||||
size what description
|
||||
-------------------------------------------------------------------
|
||||
long Plane 0 offset to plane 0
|
||||
long Plane 1 offset to plane 1 (0 if none)
|
||||
long Plane 2 offset to plane 2 (0 if none)
|
||||
char Name Map name (16 chars)
|
||||
...
|
||||
unsigned MapData all map data is in WORDs
|
||||
@@ -0,0 +1,26 @@
|
||||
typedef struct
|
||||
{
|
||||
unsigned bit0,bit1; // 0-255 is a character, > is a pointer to a node
|
||||
} huffnode;
|
||||
|
||||
extern long counts[256];
|
||||
extern huffnode nodearray[256];
|
||||
|
||||
|
||||
void CountBytes (unsigned char huge *start, long length);
|
||||
void Huffmanize (void);
|
||||
void OptimizeNodes (huffnode *table);
|
||||
long HuffCompress (unsigned char huge *source, long length,
|
||||
unsigned char huge *dest);
|
||||
void HuffExpand (unsigned char huge *source, unsigned char huge *dest,
|
||||
long length,huffnode *hufftable);
|
||||
void RLEWExpand (unsigned huge *source, unsigned huge *dest,long length,
|
||||
unsigned rlewtag);
|
||||
long RLEWCompress (unsigned huge *source, long length, unsigned huge *dest,
|
||||
unsigned rlewtag);
|
||||
void RLEBExpand (unsigned char huge *source, unsigned char huge *dest,
|
||||
long length, unsigned char rlebtag);
|
||||
long RLEBCompress (unsigned char huge *source, long length,
|
||||
unsigned char huge *dest, unsigned char rlebtag);
|
||||
long CarmackCompress (unsigned far *source,long length,
|
||||
unsigned far *dest);
|
||||
@@ -0,0 +1,42 @@
|
||||
typedef enum {CGA,EGA1,EGA2,VGA,TEXT} video;
|
||||
#define ESCOUT 0xdeaf
|
||||
|
||||
void Quit(char *string);
|
||||
void WaitVBL(int times);
|
||||
int input(char *string,int max);
|
||||
void SetupKBD ();
|
||||
void ShutdownKBD ();
|
||||
void clearkeys (void);
|
||||
int MouseInit(void);
|
||||
void MouseHide(void);
|
||||
void MouseShow(void);
|
||||
int MouseButton(void);
|
||||
void MouseCoords(int *x,int *y);
|
||||
void printhex(unsigned value);
|
||||
void printbin(unsigned value);
|
||||
unsigned inputint(int numchars);
|
||||
int input(char *string,int max);
|
||||
void print (const char *str);
|
||||
void fprint (const char huge *str);
|
||||
void printhexb(unsigned char value);
|
||||
void printint(unsigned value);
|
||||
void bar (int xl, int yl, int xh, int yh, int ch);
|
||||
int get(void);
|
||||
void drawwindow (int xl, int yl, int xh, int yh);
|
||||
void erasewindow (void);
|
||||
void centerwindow (int width, int height);
|
||||
void expwin (int width, int height);
|
||||
void expwinh (int width, int height);
|
||||
void expwinv (int width, int height);
|
||||
void SaveFile(char *filename,char huge *buffer, long size,long offset);
|
||||
unsigned long LoadFile(char *filename,char huge *buffer,long offset,long size);
|
||||
void LoadIn(char *filename,void _seg **baseptr);
|
||||
|
||||
void MouseOrigin(int x,int y);
|
||||
void MouseLimits(int xmin,int xmax,int ymin,int ymax);
|
||||
|
||||
extern int win_xl,win_yl,win_xh,win_yh,screencenterx,screencentery;
|
||||
extern unsigned char keydown[256];
|
||||
extern unsigned sx,sy,xormask,MouseStatus,leftedge;
|
||||
|
||||
long filelen(char *filename);
|
||||
@@ -0,0 +1,259 @@
|
||||
;====================================================
|
||||
;
|
||||
; Library ASM code
|
||||
;
|
||||
;====================================================
|
||||
IDEAL
|
||||
P386N
|
||||
MODEL medium,C
|
||||
|
||||
extrn xormask:WORD,yshift:WORD,CGAfont:WORD,VGAfont:WORD
|
||||
|
||||
DATASEG
|
||||
|
||||
SCindex = 3c4h
|
||||
SCmapmask = 2
|
||||
GCindex = 3CEh
|
||||
GCreadmap = 4
|
||||
GCmode = 5
|
||||
|
||||
a = 0
|
||||
LABEL CGAlookup WORD
|
||||
PUBLIC CGAlookup
|
||||
REPT 100
|
||||
dw a,a XOR 2000h
|
||||
a = a+80
|
||||
ENDM
|
||||
|
||||
a = 0
|
||||
LABEL EGA1lookup WORD
|
||||
PUBLIC EGA1lookup
|
||||
REPT 200
|
||||
dw a
|
||||
a = a+40
|
||||
ENDM
|
||||
|
||||
a = 0
|
||||
LABEL EGA2lookup WORD
|
||||
PUBLIC EGA2lookup
|
||||
REPT 480
|
||||
dw a
|
||||
a = a+80
|
||||
ENDM
|
||||
|
||||
a = 0
|
||||
LABEL VGAlookup WORD
|
||||
PUBLIC VGAlookup
|
||||
REPT 200
|
||||
dw a
|
||||
a = a+320
|
||||
ENDM
|
||||
|
||||
|
||||
CODESEG
|
||||
|
||||
;====================================================
|
||||
;
|
||||
; Draw CGA chars
|
||||
;
|
||||
;====================================================
|
||||
PROC CGAcharout
|
||||
PUBLIC CGAcharout
|
||||
ARG x:WORD,y:WORD,chr:BYTE
|
||||
USES si,di,ds
|
||||
mov bx,[y]
|
||||
shl bx,1
|
||||
shl bx,1
|
||||
shl bx,1
|
||||
shl bx,1
|
||||
mov di,[CGAlookup+bx]
|
||||
mov ax,[x]
|
||||
shl ax,1
|
||||
add di,ax
|
||||
|
||||
mov al,[chr]
|
||||
xor ah,ah
|
||||
shl ax,1
|
||||
shl ax,1
|
||||
shl ax,1
|
||||
shl ax,1
|
||||
mov si,ax
|
||||
|
||||
mov ax,0b800h
|
||||
mov es,ax
|
||||
mov ds,[CGAfont]
|
||||
cld
|
||||
cmp [ss:xormask],0
|
||||
ja @@1
|
||||
|
||||
REPT 4
|
||||
movsw
|
||||
add di,2000h-2
|
||||
movsw
|
||||
sub di,2000h-78
|
||||
ENDM
|
||||
jmp @@exit
|
||||
@@1:
|
||||
REPT 4
|
||||
lodsw
|
||||
xor ax,0ffffh
|
||||
stosw
|
||||
add di,2000h-2
|
||||
lodsw
|
||||
xor ax,0ffffh
|
||||
stosw
|
||||
sub di,2000h-78
|
||||
ENDM
|
||||
@@exit:
|
||||
ret
|
||||
ENDP
|
||||
|
||||
;====================================================
|
||||
;
|
||||
; Draw EGA chars
|
||||
;
|
||||
;====================================================
|
||||
PROC EGAcharout
|
||||
PUBLIC EGAcharout
|
||||
ARG x:WORD,y:WORD,chr:BYTE,video:WORD
|
||||
USES si,di,ds,bp
|
||||
|
||||
mov dx,GCindex
|
||||
mov ax,GCmode
|
||||
out dx,ax
|
||||
|
||||
mov bx,[y]
|
||||
shl bx,1
|
||||
shl bx,1
|
||||
shl bx,1
|
||||
add bx,[yshift]
|
||||
shl bx,1
|
||||
|
||||
cmp [video],1
|
||||
jne @@0
|
||||
mov cx,39
|
||||
mov di,[EGA1lookup+bx]
|
||||
jmp @@1
|
||||
@@0:
|
||||
mov cx,79
|
||||
mov di,[EGA2lookup+bx]
|
||||
@@1:
|
||||
add di,[x]
|
||||
|
||||
mov ax,0a000h
|
||||
mov es,ax
|
||||
mov ds,ax
|
||||
|
||||
mov si,0f000h
|
||||
mov al,[chr]
|
||||
xor ah,ah
|
||||
shl ax,1
|
||||
shl ax,1
|
||||
shl ax,1
|
||||
add si,ax
|
||||
|
||||
cld
|
||||
cmp [ss:xormask],0
|
||||
ja @@2
|
||||
|
||||
mov dx,GCindex
|
||||
mov ax,GCmode OR 100h
|
||||
out dx,ax
|
||||
mov dx,SCindex
|
||||
mov ax,SCmapmask OR 0f00h
|
||||
out dx,ax
|
||||
|
||||
REPT 8
|
||||
movsb
|
||||
add di,cx
|
||||
ENDM
|
||||
jmp @@exit
|
||||
|
||||
@@2:
|
||||
ga = 100h
|
||||
gb = 0
|
||||
mov bp,si
|
||||
mov bx,di
|
||||
REPT 4
|
||||
mov dx,SCindex
|
||||
mov ax,SCmapmask OR ga
|
||||
out dx,ax
|
||||
mov dx,GCindex
|
||||
mov ax,GCreadmap OR gb
|
||||
out dx,ax
|
||||
REPT 8
|
||||
lodsb
|
||||
xor al,0ffh
|
||||
stosb
|
||||
add di,cx
|
||||
ENDM
|
||||
mov di,bx
|
||||
mov si,bp
|
||||
ga = ga*2
|
||||
gb = gb+100h
|
||||
ENDM
|
||||
@@exit:
|
||||
mov dx,GCindex
|
||||
mov ax,GCmode
|
||||
out dx,ax
|
||||
ret
|
||||
ENDP
|
||||
|
||||
;====================================================
|
||||
;
|
||||
; Draw VGA chars
|
||||
;
|
||||
;====================================================
|
||||
PROC VGAcharout
|
||||
PUBLIC VGAcharout
|
||||
ARG x:WORD,y:WORD,chr:BYTE
|
||||
USES si,di,ds
|
||||
|
||||
mov bx,[y]
|
||||
shl bx,1
|
||||
shl bx,1
|
||||
shl bx,1
|
||||
add bx,[yshift]
|
||||
shl bx,1
|
||||
mov di,[VGAlookup+bx]
|
||||
|
||||
mov ax,[x]
|
||||
shl ax,1
|
||||
shl ax,1
|
||||
shl ax,1
|
||||
add di,ax
|
||||
|
||||
mov ah,[chr]
|
||||
xor al,al
|
||||
shr ax,1
|
||||
shr ax,1 ;[chr]*64!
|
||||
mov si,ax
|
||||
|
||||
mov ax,0a000h
|
||||
mov es,ax
|
||||
mov ds,[VGAfont]
|
||||
|
||||
cmp [ss:xormask],0
|
||||
ja @@1
|
||||
|
||||
REPT 8
|
||||
REPT 4
|
||||
movsw
|
||||
ENDM
|
||||
add di,320-8
|
||||
ENDM
|
||||
jmp @@exit
|
||||
@@1:
|
||||
REPT 8
|
||||
REPT 4
|
||||
lodsw
|
||||
xor ax,0ffffh
|
||||
stosw
|
||||
ENDM
|
||||
add di,320-8
|
||||
ENDM
|
||||
@@exit:
|
||||
ret
|
||||
ENDP
|
||||
|
||||
END
|
||||
@@ -0,0 +1,781 @@
|
||||
#include "ted5.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#define EMSINT 0x67
|
||||
|
||||
#define SPACEFREE 0x2000 // how much mem to leave alone in farheap
|
||||
#define EXTRASTACKSIZE 0x2000
|
||||
#define MAXBLOCKS 1000
|
||||
#define LOCKBIT 0x8000 // if set in attributes, block cannot be moved
|
||||
#define PURGEBITS 3 // 0-3 level, 0= unpurgable, 3= purge first
|
||||
|
||||
#define BASEATTRIBUTES 0 // unlocked, non purgable
|
||||
|
||||
unsigned totalmem; // total paragraphs available with 64k EMS
|
||||
int EMSpresent,XMSpresent;
|
||||
|
||||
|
||||
long TTLMainMem;
|
||||
|
||||
void far *farheap;
|
||||
void *nearheap;
|
||||
|
||||
int numblocks;
|
||||
struct {
|
||||
unsigned start; // in paragraphs
|
||||
unsigned length;
|
||||
unsigned attributes;
|
||||
memptr *useptr;
|
||||
} blocks[MAXBLOCKS],tempblock;
|
||||
|
||||
//==========================================================================
|
||||
|
||||
//
|
||||
// local prototypes
|
||||
//
|
||||
void CheckForEMS (void);
|
||||
int FindBlock (memptr *ptr);
|
||||
void RemoveBlock (int block);
|
||||
void InsertBlock (int block);
|
||||
|
||||
|
||||
//
|
||||
// public prototypes
|
||||
//
|
||||
|
||||
void MMStartup (void);
|
||||
void MMShutdown (void);
|
||||
void MMMapEMS (void);
|
||||
void MMGetPtr (memptr *baseptr,unsigned size);
|
||||
void MMFreePtr (memptr *baseptr);
|
||||
void MMSetPurge (memptr *baseptr, int purge);
|
||||
void MMSortMem (void);
|
||||
void MMBlockDump (void);
|
||||
unsigned MMUnusedMemory (void);
|
||||
unsigned MMTotalFree (void);
|
||||
|
||||
//==========================================================================
|
||||
|
||||
|
||||
//
|
||||
// CheckForEMS
|
||||
//
|
||||
// Routine from p36 of Extending DOS
|
||||
//
|
||||
void CheckForEMS (void)
|
||||
{
|
||||
char emmname[9] = "EMMXXXX0";
|
||||
|
||||
asm mov dx,OFFSET emmname
|
||||
asm mov ax,0x3d00
|
||||
asm int 0x21 // try to open EMMXXXX0 device
|
||||
asm jc error
|
||||
|
||||
asm mov bx,ax
|
||||
asm mov ax,0x4400
|
||||
|
||||
asm int 0x21 // get device info
|
||||
asm jc error
|
||||
|
||||
asm and dx,0x80
|
||||
asm jz error
|
||||
|
||||
asm mov ax,0x4407
|
||||
|
||||
asm int 0x21 // get status
|
||||
asm jc error
|
||||
asm or al,al
|
||||
asm jz error
|
||||
|
||||
asm mov ah,0x3e
|
||||
asm int 0x21 // close handle
|
||||
asm jc error
|
||||
|
||||
//
|
||||
// EMS is good
|
||||
//
|
||||
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
//
|
||||
// EMS is bad
|
||||
//
|
||||
EMSpresent = 0;
|
||||
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
|
||||
//
|
||||
// FindBlock
|
||||
//
|
||||
int FindBlock (memptr *ptr)
|
||||
{
|
||||
int i;
|
||||
for (i=1;i<numblocks;i++)
|
||||
if (blocks[i].useptr == ptr)
|
||||
return i;
|
||||
|
||||
Quit ("Memory manager error: Block not found!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// RemoveBlock
|
||||
// 0 the pointer, close the block array down, and decrement numblocks
|
||||
//
|
||||
void RemoveBlock (int block)
|
||||
{
|
||||
void far *source, far *dest;
|
||||
unsigned length;
|
||||
|
||||
*blocks[block].useptr = NULL;
|
||||
if (block!=numblocks-1)
|
||||
{
|
||||
source = &blocks[block+1];
|
||||
dest = &blocks[block];
|
||||
length = (numblocks-1-block)*sizeof(blocks[0]);
|
||||
movedata (FP_SEG(source),FP_OFF(source),FP_SEG(dest),FP_OFF(dest),length);
|
||||
}
|
||||
numblocks--;
|
||||
}
|
||||
|
||||
//
|
||||
// InsertBlock
|
||||
// Inserts space in the block array AFTER parameter and increments numblocks
|
||||
//
|
||||
void InsertBlock (int block)
|
||||
{
|
||||
unsigned source,dest,length;
|
||||
|
||||
if (block!=numblocks-1)
|
||||
{
|
||||
source = ((unsigned)&blocks[numblocks])-2;
|
||||
dest = ((unsigned)&blocks[numblocks+1])-2;
|
||||
length = (numblocks-1-block)*sizeof(blocks[0])/2;
|
||||
asm mov cx,length
|
||||
asm mov si,source
|
||||
asm mov di,dest
|
||||
asm mov ax,ds
|
||||
asm mov es,ax
|
||||
asm std
|
||||
asm rep movsw
|
||||
asm cld
|
||||
}
|
||||
if (++numblocks>=MAXBLOCKS)
|
||||
Quit ("Memory manager error: Too many blocks!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// check numblocks<MAXBLOCKS
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
===================
|
||||
=
|
||||
= MMStartup
|
||||
=
|
||||
= Initializes the memory manager and returns the total
|
||||
= allocatable free space.
|
||||
=
|
||||
= Grabs all space from turbo with farmalloc
|
||||
=
|
||||
===================
|
||||
*/
|
||||
|
||||
void MMStartup (void)
|
||||
{
|
||||
unsigned long length;
|
||||
void far *start;
|
||||
unsigned nearstart,farstart,EMSstart,seg,i;
|
||||
unsigned nearlength,farlength,emslength,xmslength;
|
||||
|
||||
//
|
||||
// get all available near conventional memory
|
||||
//
|
||||
length=coreleft();
|
||||
start = (void far *)(nearheap = malloc(length-SPACEFREE));
|
||||
|
||||
//
|
||||
// paragraph align it and figure size
|
||||
//
|
||||
length -= 16-(FP_OFF(start)&15);
|
||||
length -= EXTRASTACKSIZE;
|
||||
nearlength = length / 16; // now in paragraphs
|
||||
nearstart = FP_SEG(start)+(FP_OFF(start)+15)/16;
|
||||
|
||||
//
|
||||
// get all available far conventional memory
|
||||
//
|
||||
length=farcoreleft();
|
||||
start = farheap = farmalloc(length);
|
||||
|
||||
//
|
||||
// paragraph align it and figure size
|
||||
//
|
||||
if (FP_OFF(start))
|
||||
{
|
||||
length -= 16-FP_OFF(start);
|
||||
start = (void far *)MK_FP(FP_SEG(start)+1,0);
|
||||
}
|
||||
farlength = length / 16; // now in paragraphs
|
||||
farstart = FP_SEG(start);
|
||||
|
||||
totalmem = nearlength + farlength;
|
||||
|
||||
//
|
||||
// detect EMS and allocate 64K at page frame
|
||||
//
|
||||
CheckForEMS();
|
||||
if (EMSpresent)
|
||||
{
|
||||
EMSstart = 0xffff;
|
||||
totalmem += 0x1000; // 64k of EMS
|
||||
MMMapEMS(); // map in used pages
|
||||
}
|
||||
else
|
||||
{
|
||||
EMSstart = 0xffff;
|
||||
}
|
||||
|
||||
//
|
||||
// set up locked blocks
|
||||
//
|
||||
numblocks = 0;
|
||||
|
||||
blocks[numblocks].start = 0;
|
||||
blocks[numblocks].length = nearstart;
|
||||
blocks[numblocks].attributes = LOCKBIT;
|
||||
|
||||
numblocks++;
|
||||
|
||||
blocks[numblocks].start = nearstart+nearlength;
|
||||
blocks[numblocks].length = farstart-(nearstart+nearlength);
|
||||
blocks[numblocks].attributes = LOCKBIT;
|
||||
|
||||
numblocks++;
|
||||
|
||||
blocks[numblocks].start = farstart+farlength;
|
||||
blocks[numblocks].length = EMSstart-(farstart+farlength);
|
||||
blocks[numblocks].attributes = LOCKBIT;
|
||||
|
||||
numblocks++;
|
||||
|
||||
TTLMainMem=16L*MMTotalFree();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= MMShutdown
|
||||
=
|
||||
= Frees all conventional, EMS, and XMS allocated
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
void MMShutdown (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
//
|
||||
// 0 the pointers (if any)
|
||||
//
|
||||
for (i=0;i<numblocks-1;i++)
|
||||
*blocks[i].useptr=NULL;
|
||||
|
||||
farfree (farheap);
|
||||
free (nearheap);
|
||||
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= MMMapEMS
|
||||
=
|
||||
= Maps the 64k of EMS used by memory manager into the page frame
|
||||
= for general use.
|
||||
=
|
||||
====================
|
||||
*/
|
||||
|
||||
void MMMapEMS (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
====================
|
||||
=
|
||||
= MMGetPtr
|
||||
=
|
||||
= Allocates an unlocked, unpurgable block
|
||||
= Start looking at the top of memory
|
||||
=
|
||||
====================
|
||||
*/
|
||||
void MMAllocate(memptr *baseptr,long size)
|
||||
{
|
||||
MMGetPtr(baseptr,(unsigned)((size+15)/16));
|
||||
TTLMainMem=16L*MMTotalFree();
|
||||
}
|
||||
|
||||
void MMGetPtr (memptr *baseptr,unsigned size)
|
||||
{
|
||||
int i,j,k,try;
|
||||
unsigned start,end;
|
||||
|
||||
//
|
||||
// try a normal scan, then compress if not found
|
||||
//
|
||||
for (try=0;try<2;try++)
|
||||
{
|
||||
for (i=0;i<numblocks-1;i++)
|
||||
{
|
||||
if (blocks[i].attributes & PURGEBITS )
|
||||
continue;
|
||||
//
|
||||
// blocks[i] cannot be written over, so try to allocate the
|
||||
// new block right after it
|
||||
//
|
||||
start = blocks[i].start + blocks[i].length;
|
||||
end = start + size;
|
||||
j=i+1;
|
||||
while (blocks[j].start < end)
|
||||
{
|
||||
if (!(blocks[j].attributes & PURGEBITS))
|
||||
{
|
||||
i = j-1;
|
||||
goto lookmore; // a non purgable block is in the way
|
||||
}
|
||||
j++;
|
||||
}
|
||||
//
|
||||
// purge the blocks in the way
|
||||
//
|
||||
for (k=i+1;k<j;j--)
|
||||
RemoveBlock(k);
|
||||
//
|
||||
// allocate the new block
|
||||
//
|
||||
InsertBlock(i);
|
||||
*(unsigned *)baseptr = start;
|
||||
blocks[i+1].start = start;
|
||||
blocks[i+1].length = size;
|
||||
blocks[i+1].useptr = baseptr;
|
||||
blocks[i+1].attributes = BASEATTRIBUTES;
|
||||
return;
|
||||
lookmore:;
|
||||
}
|
||||
//
|
||||
// didn't find any space, so compress and try again
|
||||
//
|
||||
if (try==0)
|
||||
MMSortMem();
|
||||
}
|
||||
|
||||
//puts("");
|
||||
//MMBlockDump(); // DEBUG
|
||||
Quit ("Memory manager error: Out of memory!");
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
=====================
|
||||
=
|
||||
= MMFreePtr
|
||||
=
|
||||
= Frees up a block and NULL's the pointer
|
||||
=
|
||||
=====================
|
||||
*/
|
||||
|
||||
void MMFreePtr (memptr *baseptr)
|
||||
{
|
||||
RemoveBlock(FindBlock (baseptr));
|
||||
TTLMainMem=16L*MMTotalFree();
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
=====================
|
||||
=
|
||||
= MMSetPurge
|
||||
=
|
||||
= Sets the purge level for a block
|
||||
=
|
||||
=====================
|
||||
*/
|
||||
|
||||
void MMSetPurge (memptr *baseptr, int purge)
|
||||
{
|
||||
int block;
|
||||
unsigned attr;
|
||||
|
||||
block = FindBlock (baseptr);
|
||||
|
||||
attr = blocks[block].attributes;
|
||||
attr &= 0xffff - PURGEBITS;
|
||||
attr |= purge; // set bits in attributes
|
||||
blocks[block].attributes = attr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
MMSortMem
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
//
|
||||
// MoveParas
|
||||
//
|
||||
void MoveParaBase (unsigned source, unsigned dest, unsigned words)
|
||||
{
|
||||
asm mov cx,words
|
||||
asm xor si,si
|
||||
asm xor di,di
|
||||
asm mov ax,source
|
||||
asm mov bx,dest
|
||||
asm mov ds,source
|
||||
asm mov es,dest
|
||||
asm rep movsw
|
||||
asm mov ax,ss
|
||||
asm mov ds,ax
|
||||
}
|
||||
|
||||
void MoveParaBaseUp (unsigned source, unsigned dest, unsigned words)
|
||||
{
|
||||
asm mov cx,words
|
||||
asm mov si,cx
|
||||
asm dec si
|
||||
asm shl si,1
|
||||
asm mov di,si
|
||||
asm mov ax,source
|
||||
asm mov bx,dest
|
||||
asm mov ds,source
|
||||
asm mov es,dest
|
||||
asm rep movsw
|
||||
asm mov ax,ss
|
||||
asm mov ds,ax
|
||||
}
|
||||
|
||||
|
||||
void MoveParas (unsigned source, unsigned dest, unsigned paragraphs)
|
||||
{
|
||||
if (source>dest)
|
||||
{
|
||||
asm cld
|
||||
while (paragraphs>0xfff)
|
||||
{
|
||||
MoveParaBase (source,dest,0xfff*8);
|
||||
source += 0xfff*8;
|
||||
dest += 0xfff*8;
|
||||
paragraphs -= 0xfff;
|
||||
}
|
||||
MoveParaBase (source,dest,paragraphs*8);
|
||||
}
|
||||
else
|
||||
{
|
||||
asm std
|
||||
source+=paragraphs;
|
||||
dest+=paragraphs;
|
||||
while (paragraphs>0xfff)
|
||||
{
|
||||
source-=0xfff;
|
||||
dest-=0xfff;
|
||||
MoveParaBaseUp (source,dest,0xfff*8);
|
||||
paragraphs -= 0xfff;
|
||||
}
|
||||
source-=paragraphs;
|
||||
dest-=paragraphs;
|
||||
MoveParaBaseUp (source,dest,paragraphs*8);
|
||||
asm cld
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
======================
|
||||
=
|
||||
= MMSortMem
|
||||
=
|
||||
= Sorts all non locked blocks so lower purge levels are lower in memory
|
||||
= and all free space is at the top
|
||||
=
|
||||
======================
|
||||
*/
|
||||
|
||||
int keyblock;
|
||||
|
||||
//
|
||||
// PushUp
|
||||
//
|
||||
// Pushes the block (purgeable) as high in memory as possible
|
||||
// must be BELOW keyblock
|
||||
// If it can't fit above keyblock it will be freed
|
||||
//
|
||||
void PushUp (int move)
|
||||
{
|
||||
unsigned source,dest,size;
|
||||
int i;
|
||||
|
||||
size = blocks[move].length;
|
||||
source = blocks[move].start;
|
||||
|
||||
for (i=numblocks-1;i>keyblock;i--)
|
||||
{
|
||||
//
|
||||
// if the block can fit under this block, move it
|
||||
//
|
||||
dest = blocks[i].start - size;
|
||||
if (blocks[i-1].start+blocks[i-1].length <= dest)
|
||||
{
|
||||
//
|
||||
// make a copy of block 'move' under block 'i'
|
||||
//
|
||||
InsertBlock (i-1);
|
||||
blocks[i] = blocks[move];
|
||||
blocks[i].start = dest;
|
||||
*(blocks[i].useptr) = (void _seg *)dest; // modify the pointer to the new spot
|
||||
MoveParas (source,dest,size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// erase original position
|
||||
//
|
||||
RemoveBlock (move);
|
||||
keyblock--; // because a block below it was removed
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// PushDown
|
||||
//
|
||||
// Push keyblock (unpurgable) as low in memory as possible
|
||||
//
|
||||
void PushDown (void)
|
||||
{
|
||||
unsigned source,dest,size,end,lowblock,checkblock,i;
|
||||
|
||||
size = blocks[keyblock].length;
|
||||
source = blocks[keyblock].start;
|
||||
|
||||
//
|
||||
// find the lowest space it can be moved into
|
||||
//
|
||||
for (lowblock = 0;lowblock<keyblock;lowblock++)
|
||||
if (!(blocks[lowblock].attributes & PURGEBITS) ||
|
||||
blocks[lowblock].attributes & LOCKBIT)
|
||||
{
|
||||
//
|
||||
// found a locked or nonpurgable block below keyblock
|
||||
//
|
||||
// see if there is enough space to move block
|
||||
//
|
||||
dest = blocks[lowblock].start + blocks[lowblock].length;
|
||||
end = dest+size;
|
||||
|
||||
//
|
||||
// see if any of the blocks in the middle can be moved away
|
||||
//
|
||||
checkblock = lowblock+1;
|
||||
while (checkblock < keyblock && blocks[checkblock].start<end)
|
||||
{
|
||||
if (!(blocks[checkblock].attributes & PURGEBITS) )
|
||||
goto nofit; // can't fit between two locked blocks
|
||||
//
|
||||
// push the block up or remove it, in either case dropping
|
||||
// keyblock and changing blocks[checkblock]
|
||||
//
|
||||
PushUp (checkblock);
|
||||
}
|
||||
//
|
||||
// move it!
|
||||
//
|
||||
if (dest != source)
|
||||
{
|
||||
MoveParas (source,dest,size);
|
||||
blocks[keyblock].start = dest;
|
||||
*(blocks[keyblock].useptr) = (void _seg *)dest; // modify the pointer to the new spot
|
||||
if (lowblock<keyblock-1)
|
||||
{
|
||||
//
|
||||
// reorder the block records
|
||||
//
|
||||
tempblock = blocks[keyblock];
|
||||
for (i=keyblock;i>lowblock+1;i--)
|
||||
blocks[i]=blocks[i-1];
|
||||
blocks[lowblock+1] = tempblock;
|
||||
}
|
||||
|
||||
//MMBlockDump(); // DEBUG
|
||||
}
|
||||
return;
|
||||
|
||||
nofit:; // keep looking...
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// MMSortMem
|
||||
//
|
||||
|
||||
void MMSortMem (void)
|
||||
{
|
||||
unsigned i,source,dest;
|
||||
|
||||
keyblock = 0;
|
||||
|
||||
do
|
||||
{
|
||||
keyblock++;
|
||||
|
||||
//
|
||||
// non-purgable, unlocked blocks will be pushed low in memory
|
||||
//
|
||||
if ( !(blocks[keyblock].attributes & PURGEBITS) &&
|
||||
!(blocks[keyblock].attributes & LOCKBIT) )
|
||||
PushDown ();
|
||||
|
||||
} while (keyblock<numblocks-1);
|
||||
|
||||
|
||||
for (i=numblocks-2;i>0;i--)
|
||||
{
|
||||
//
|
||||
// push all purgable blocks as high as possible
|
||||
// Currently they are NOT moved around locked blocks!
|
||||
//
|
||||
if ( blocks[i].attributes & PURGEBITS )
|
||||
{
|
||||
source= blocks[i].start;
|
||||
dest= blocks[i+1].start-blocks[i].length;
|
||||
if (source!=dest)
|
||||
{
|
||||
MoveParas (source,dest,blocks[i].length);
|
||||
blocks[i].start = dest;
|
||||
*(blocks[i].useptr) = (void _seg *)dest; // modify the pointer to the new spot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PatchPointers(); // let the main program fix up any
|
||||
// internal references
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
=======================
|
||||
=
|
||||
= MMBlockDump
|
||||
=
|
||||
= Dewbug tool
|
||||
=
|
||||
=======================
|
||||
*/
|
||||
|
||||
void MMBlockDump (void)
|
||||
{
|
||||
int i;
|
||||
unsigned free;
|
||||
|
||||
fprintf (stdprn,"-------------\n");
|
||||
for (i=0;i<numblocks;i++)
|
||||
{
|
||||
fprintf (stdprn,"Start:%4X\tLength:%4X\tAttr:%4X\tPtr:%p\n"
|
||||
,blocks[i].start,blocks[i].length,blocks[i].attributes,blocks[i].useptr);
|
||||
if (i<numblocks-1)
|
||||
{
|
||||
free = blocks[i+1].start - (blocks[i].start+blocks[i].length);
|
||||
if (free)
|
||||
fprintf (stdprn,"### Free:%X\n",free);
|
||||
}
|
||||
}
|
||||
puts("");
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
||||
/*
|
||||
======================
|
||||
=
|
||||
= MMUnusedMemory
|
||||
=
|
||||
= Returns the total free space without purging
|
||||
=
|
||||
======================
|
||||
*/
|
||||
|
||||
unsigned MMUnusedMemory (void)
|
||||
{
|
||||
int i;
|
||||
unsigned free;
|
||||
|
||||
free = 0;
|
||||
|
||||
for (i=0;i<numblocks;i++)
|
||||
{
|
||||
if (i<numblocks-1)
|
||||
free += blocks[i+1].start - (blocks[i].start+blocks[i].length);
|
||||
}
|
||||
|
||||
return free;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
|
||||
/*
|
||||
======================
|
||||
=
|
||||
= MMTotalFree
|
||||
=
|
||||
= Returns the total free space with purging
|
||||
=
|
||||
======================
|
||||
*/
|
||||
|
||||
unsigned MMTotalFree (void)
|
||||
{
|
||||
int i;
|
||||
unsigned free;
|
||||
|
||||
free = 0;
|
||||
|
||||
for (i=0;i<numblocks;i++)
|
||||
{
|
||||
if (blocks[i].attributes & PURGEBITS)
|
||||
free += blocks[i].length;
|
||||
if (i<numblocks-1)
|
||||
free += blocks[i+1].start - (blocks[i].start+blocks[i].length);
|
||||
}
|
||||
|
||||
return free;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
typedef void _seg * memptr;
|
||||
|
||||
extern long TTLMainMem;
|
||||
extern unsigned totalmem; // total paragraphs available with 64k EMS
|
||||
extern int EMSpresent,XMSpresent;
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
||||
//
|
||||
// public prototypes
|
||||
//
|
||||
|
||||
void MMStartup (void);
|
||||
void MMShutdown (void);
|
||||
void MMMapEMS (void);
|
||||
void MMAllocate(memptr *baseptr,long size);
|
||||
void MMGetPtr (memptr *baseptr,unsigned size);
|
||||
void MMFreePtr (memptr *baseptr);
|
||||
void MMSetPurge (memptr *baseptr, int purge);
|
||||
void MMSortMem (void);
|
||||
void MMBlockDump (void);
|
||||
unsigned MMUnusedMemory (void);
|
||||
unsigned MMTotalFree (void);
|
||||
|
||||
|
||||
void PatchPointers (void); // must be present in the main program
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,78 @@
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Pull-Down menu interface .H file
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////
|
||||
typedef struct { char *item_name;
|
||||
void (*routine)(void);
|
||||
char shiftflag;
|
||||
char hotkey;
|
||||
} MenuDef;
|
||||
|
||||
typedef struct { int num_items;
|
||||
MenuDef *menu_def;
|
||||
char *menu_name;
|
||||
} MBarDef;
|
||||
|
||||
typedef struct { int menux;
|
||||
int menunamelen;
|
||||
int menuwidth;
|
||||
} MInfoType;
|
||||
|
||||
typedef struct { char *text;
|
||||
int xoff,yoff,border;
|
||||
} btype;
|
||||
|
||||
typedef struct { char *text;
|
||||
int width,height,numbuttons;
|
||||
btype *buttons;
|
||||
void (*hook)(int x,int y);
|
||||
} DialogDef;
|
||||
|
||||
typedef struct { int x,y,w,h;
|
||||
void _seg *buffer;
|
||||
} BackSaveStr;
|
||||
|
||||
#define SCindex 0x3C4
|
||||
#define SCmapmask 2
|
||||
#define GCindex 0x3CE
|
||||
#define GCreadmap 4
|
||||
#define GCmode 5
|
||||
#define crtcaddr 0x3d4
|
||||
|
||||
#define NUMFLASHES 10
|
||||
#define ALT 0x38
|
||||
#define CTRL 0x1d
|
||||
|
||||
#define MAXFDNAMES 40
|
||||
extern struct ffblk f; // more info from GetPath
|
||||
|
||||
|
||||
void extern InitDesktop(MBarDef *menubar,int initmouse);
|
||||
void extern DeskEventLoop(void (*UserRoutine)(void),void (*ConstantRoutine)(void));
|
||||
void extern ClearScreen(void);
|
||||
void extern RedrawDesktop(void);
|
||||
void extern SaveBackground(int x,int y,int w,int h);
|
||||
void extern RestoreBackground(void);
|
||||
int extern DoDialog(DialogDef *TheDialog);
|
||||
void extern ErrDialog(char *string,char *bstring);
|
||||
void extern DrawBorder(int x,int y,int w,int h,int b);
|
||||
int extern CheckButtons(DialogDef *TheDialog);
|
||||
int extern CheckButtonsRet(DialogDef *TheDialog);
|
||||
void extern DrawDialog(DialogDef *TheDialog,int saveback);
|
||||
void extern GetButtonXY(DialogDef *TheDialog,int button,unsigned *x,unsigned *y);
|
||||
void extern GetDialogXY(DialogDef *TheDialog,unsigned *x,unsigned *y);
|
||||
int extern CheckList(int x,int y,int w,int h,void (*oncode)(),void (*offcode)(),int blink);
|
||||
int extern Message(char *mstring);
|
||||
|
||||
//
|
||||
// RETURNS 0=OK,-1=NO FILES MATCH FILTER,-2=CANCELED
|
||||
//
|
||||
extern char NameList[MAXFDNAMES][13];
|
||||
int GetPath(char *string,char *filter,char *path);
|
||||
int GetList(char *string,int numnames);
|
||||
|
||||
static void FDon(int x,int y,int w);
|
||||
static void FDoff(int x,int y,int w);
|
||||
static void CancelOn(int x,int y);
|
||||
static void CancelOff(int x,int y);
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
Ted 5.0
|
||||
=======
|
||||
|
||||
The Ted source code needs to be compiled with Borland C/C++ 3.1. It will
|
||||
probably compile with 4.0 but there are a few OBJ's that are linked in and
|
||||
not built (the vgapalette, the tedfont etc.).
|
||||
|
||||
This code was written by John Romero of Id Software Inc. A screen blanker
|
||||
was added and a scrolling bug was fixed by Mark Dochtermann of Apogee
|
||||
Software Ltd.
|
||||
|
||||
Do not contact Apogee or id regarding any questions on this software. It
|
||||
is provided "AS IS" with no warranty.
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,356 @@
|
||||
#define IDSTRING "TED5v1.0"
|
||||
#define TITLESTR "TED5 vD.IP"
|
||||
#define IDSTSTR " "TITLESTR
|
||||
|
||||
#include <stdio.h>
|
||||
#include <process.h>
|
||||
#include <io.h>
|
||||
#include <dos.h>
|
||||
#include <alloc.h>
|
||||
#include <dir.h>
|
||||
#include <mem.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <conio.h>
|
||||
#include <fcntl.h>
|
||||
#include "lib.h"
|
||||
#include "memmgr.h"
|
||||
#include "menu.h"
|
||||
#include "jhuff.h"
|
||||
#include "xms.h"
|
||||
|
||||
#define SGN(x) (x>0?1:x<0?-1:0)
|
||||
#define OFF3(m,i) (*(long huge *)((char huge *)m+(i)*3)&0xffffff)
|
||||
|
||||
|
||||
//
|
||||
// Defs for TED5
|
||||
//
|
||||
|
||||
typedef enum {TILES,MASKED,ICONS} screentype;
|
||||
typedef enum {DATA,CODE,FARDATA} segtype; // FOR MAKEOBJ ONLY
|
||||
|
||||
#define SCindex 0x3C4
|
||||
#define SCmapmask 2
|
||||
#define GCindex 0x3CE
|
||||
#define GCreadmap 4
|
||||
#define GCmode 5
|
||||
#define crtcaddr 0x3d4
|
||||
|
||||
//
|
||||
// STRUCTURE OF TED5 TEMPFILE WHILE LAUNCHING
|
||||
//
|
||||
typedef struct {
|
||||
video lastmode;
|
||||
char ext[4];
|
||||
} TempStruct;
|
||||
|
||||
//
|
||||
// STRUCTURE OF THE "TEDINFO.EXT" FILE THAT TED5 CREATES
|
||||
//
|
||||
typedef struct {
|
||||
int level,lastvid,lastx,lasty,tsize;
|
||||
int OldCgaXMS,OldEgaXMS,OldVgaXMS;
|
||||
long OldCgaXMSsize,OldEgaXMSsize,OldVgaXMSsize;
|
||||
int CgaXMSlook,EgaXMSlook,VgaXMSlook;
|
||||
char permicon,pflags;
|
||||
int oscrx,oscry;
|
||||
char parmstring[64],launchname[14];
|
||||
char BackgndColor;
|
||||
char ImportPath[64];
|
||||
} InfoStruct;
|
||||
|
||||
//
|
||||
// STRUCTURE OF THE "GFXINFO?.EXT" FILE THAT IGRAB CREATES
|
||||
//
|
||||
typedef struct {
|
||||
int num8,num8m,num16,num16m,num32,num32m;
|
||||
int off8,off8m,off16,off16m,off32,off32m;
|
||||
int numpics,numpicm,numsprites;
|
||||
int offpic,offpicm,offsprites;
|
||||
int offpicstr,offpicmstr,offsprstr;
|
||||
int numexterns,offexterns;
|
||||
} GfxStruct;
|
||||
|
||||
//
|
||||
// TED5 LOADS & SAVES THIS HEADER FOR INTERNAL MAPFILE USAGE
|
||||
//
|
||||
typedef struct { unsigned maptype; //bit 0=bkgnd/1=frgnd/2=info
|
||||
unsigned tsize; //1=8/2=16/3=32
|
||||
|
||||
unsigned numtplanes,oldtilenum;
|
||||
long tileinfooff[10];
|
||||
unsigned tileinfolen[10];
|
||||
char tnames[10][8];
|
||||
|
||||
unsigned numtmplanes,oldtilemnum;
|
||||
long tileinfomoff[10];
|
||||
unsigned tileinfomlen[10];
|
||||
char tmnames[10][8];
|
||||
|
||||
unsigned RLEWtag;
|
||||
long dataoffsets[100];
|
||||
long datalengths[100];
|
||||
|
||||
int NumIconRows;
|
||||
} MapFileHeaderStr;
|
||||
|
||||
//
|
||||
// TED5 SAVES THIS MAPFILE HEADER FOR THE GAME
|
||||
//
|
||||
typedef struct {
|
||||
unsigned RLEWtag;
|
||||
long dataoffsets[100];
|
||||
|
||||
} OutputHeadStr;
|
||||
|
||||
//
|
||||
// EACH AND EVERY MAP HAS THIS HEADER (IF THE MAP EXISTS)
|
||||
//
|
||||
typedef struct { long mapbkgndpl;
|
||||
long mapfrgndpl;
|
||||
long mapinfopl;
|
||||
unsigned mapbkgndlen;
|
||||
unsigned mapfrgndlen;
|
||||
unsigned mapinfolen;
|
||||
unsigned width,height;
|
||||
char name[16];
|
||||
} MapHeaderStr;
|
||||
|
||||
//
|
||||
// SPECIFY WHAT, WHEREFROM, AND HOW TO COPY A REGION
|
||||
//
|
||||
typedef struct {
|
||||
char PlanesCopied; // use BPLANE,FPLANE,IPLANE to mask
|
||||
int MapOrTileSelect; // 0:map,1:tileselect
|
||||
int x,y,w,h; // from map or tileselect
|
||||
} CopyStr;
|
||||
|
||||
//
|
||||
// UNDO REGION
|
||||
//
|
||||
typedef struct {
|
||||
int x,y,w,h;
|
||||
} UndoStr;
|
||||
|
||||
//
|
||||
// LAST-BUILT "VIEWMAP"
|
||||
//
|
||||
typedef struct {
|
||||
unsigned step,built_flag,EGAseg,maxpack;
|
||||
} VMapStr;
|
||||
|
||||
|
||||
//
|
||||
// HEADER FOR APPLE-PREFERRED FILES
|
||||
//
|
||||
typedef struct { long length;
|
||||
char Kind[5];
|
||||
int MasterMode;
|
||||
int PixelsPerLine;
|
||||
int NumColorTables;
|
||||
int ColorTable[16];
|
||||
int NumScanLines;
|
||||
} ApPrefStr;
|
||||
|
||||
#define CREATED 1
|
||||
#define NOTCREATED 2
|
||||
#define ANYLIST 3
|
||||
|
||||
#define BPLANE 1
|
||||
#define FPLANE 2
|
||||
#define IPLANE 4
|
||||
|
||||
#define O_FGNDBACK 4
|
||||
#define ICONBACK 3
|
||||
|
||||
#define TINFOWIDTH 3
|
||||
#define TINFOHEIGHT 7
|
||||
#define TINFOHEIGHTEGA2 25
|
||||
|
||||
extern MBarDef TED5MenuBar[];
|
||||
extern DialogDef DoCreated;
|
||||
|
||||
extern UndoStr UndoRegion;
|
||||
extern CopyStr TileCopy;
|
||||
extern MapFileHeaderStr _seg *MapFileHeader;
|
||||
extern char _seg *Tinfo[10],_seg *TMinfo[10],_seg *GraphHeader;
|
||||
extern long _seg *XMSlookup,_seg *CgaXMSlookup,_seg *EgaXMSlookup,_seg *VgaXMSlookup;
|
||||
extern int _seg *MapBkgnd,_seg *MapFrgnd,_seg *MapInfoPl,
|
||||
_seg *CutBkgnd,_seg *CutFrgnd,_seg *CutInfoPl;
|
||||
extern MapHeaderStr MapHeader;
|
||||
|
||||
#if 0
|
||||
extern char far TOM; // JOKE SHIT!
|
||||
#endif
|
||||
|
||||
extern TempStruct LaunchInfo;
|
||||
extern InfoStruct _seg *TEDInfo;
|
||||
extern GfxStruct _seg *GfxInfo;
|
||||
extern video lastvideo,videomode;
|
||||
extern screentype whichscreen;
|
||||
extern VMapStr VMapData;
|
||||
|
||||
extern char launchname[64],ext[4],format[2],projname[64],mapname[64],planes,
|
||||
infoname[64],mapheadname[64],tdata,MapNames[100][16],parmstring[64];
|
||||
extern char SM_name[64],SM_loadname[64],BkgndColor;
|
||||
|
||||
extern unsigned temp,whichmap,numtplanes,tilenum,tilemnum,numtmplanes,left,
|
||||
DirtyFlag,tilelen,tilemlen,whicht,whichtm,whichi,
|
||||
tsize,infoy,infomaxw,mapwidth,mapheight,screenw,usingbat,
|
||||
screenh,planeton,planemon,planeion,maxiconrows,lasticon,firsticon,
|
||||
viewton,viewmon,viewion,XMSundoB,XMSundoF,XMSundoI,XMSmaps,
|
||||
EgaXMS,CgaXMS,VgaXMS,xmshandle,GridMode,SnapMode,snapx,snapy,
|
||||
snapxsize,snapysize,writeH,F3_flag,NoAbout;
|
||||
extern int tilebase,tilembase,infobaron,xbase,ybase,scrnbot,scrnrgt,
|
||||
FillMode,PasteMode,SelectMode,SelX1,SelY1,PasteOK,SelX2,SelY2,pixelx,pixely,
|
||||
selectcols,px,py,lastmap,TIybase,TIymbase,TIxbase,TIxmbase,BfillMode,
|
||||
Plotting,TsearchMode;
|
||||
extern long CgaXMSsize,EgaXMSsize,VgaXMSsize;
|
||||
|
||||
extern void far *XMSdriver;
|
||||
|
||||
//
|
||||
// FUNCTION PROTOTYPES
|
||||
//
|
||||
|
||||
//
|
||||
// LIB_A.ASM
|
||||
//
|
||||
extern void CGAcharout(int x,int y,char ch);
|
||||
extern void EGAcharout(int x,int y,char ch,video vid);
|
||||
extern void VGAcharout(int x,int y,char ch);
|
||||
|
||||
//
|
||||
// TED5_A.ASM
|
||||
//
|
||||
extern unsigned EGA1lookup[200];
|
||||
extern unsigned EGA2lookup[200];
|
||||
extern void DrawTile(int x,int y,int tile);
|
||||
extern void CopyCGA(int srcx,int srcy,int width,int height,int destx,int desty);
|
||||
extern void CopyEGA(int srcx,int srcy,int width,int height,int destx,int desty);
|
||||
extern void CopyVGA(int srcx,int srcy,int width,int height,int destx,int desty);
|
||||
extern void Overlay(int tsize);
|
||||
|
||||
//
|
||||
// TED5
|
||||
//
|
||||
void FindGraphFile(void);
|
||||
void HandleEvent(void);
|
||||
void Continuous(void);
|
||||
void LoadInfoFile(void);
|
||||
int LoadGraphStuff(int rtn,video newvid);
|
||||
void LoadMapHeader(void);
|
||||
void ParseCmdline(void);
|
||||
void InitTed5(void);
|
||||
void CallDesktop(void);
|
||||
void SelectTiles(int screen);
|
||||
void STnot(int x,int y);
|
||||
void DrawProjBord(int x,int y);
|
||||
void DrawInfoBar(void);
|
||||
void PrintCoords(void);
|
||||
void FigureScreenEdges(void);
|
||||
void errsound(void);
|
||||
void DrawMap(void);
|
||||
void CheckSelectEdges(int x,int y,int i,int j);
|
||||
int InputIconAmount(void);
|
||||
|
||||
//
|
||||
// TED5-1
|
||||
//
|
||||
void Item_InputInfoplane(void);
|
||||
void Item_SelectTile(void);
|
||||
void Item_EditTinfoNames(void);
|
||||
void Item_BlockFill(void);
|
||||
void Item_TileSearch(void);
|
||||
void Item_Launch(void);
|
||||
void Item_Undo(void);
|
||||
void Item_TINFOCopy(void);
|
||||
|
||||
void CreateMap(int exitok);
|
||||
int SelectMap(int exitok,int createflg,char *title);
|
||||
int PickMorePlanes(void);
|
||||
void DoBlockFill(void);
|
||||
void RemoveUndoBuffers(void);
|
||||
void AllocateUndoBuffers(void);
|
||||
void RestoreUndo(void);
|
||||
void SaveUndo(int x,int y,int w,int h);
|
||||
void CopyUndoRegion(void);
|
||||
void SaveOutputHeader(void);
|
||||
void SaveTEDInfo(void);
|
||||
void BackupFile(char *filename);
|
||||
|
||||
void TInfoNon(int x,int y,int b);
|
||||
void TInfoNoff(int x,int y,int b);
|
||||
void TInfoMNon(int x,int y,int b);
|
||||
void TInfoMNoff(int x,int y,int b);
|
||||
void TIDoneOn(int x,int y);
|
||||
void TIDoneOff(int x,int y);
|
||||
|
||||
|
||||
//
|
||||
// TED5-2
|
||||
//
|
||||
void Item_About(void);
|
||||
void Item_ModeSwitch(void);
|
||||
void Item_DeleteMap(void);
|
||||
void Item_EditMap(void);
|
||||
void Item_SaveMap(void);
|
||||
void Item_CreateMap(void);
|
||||
void Item_Quit(void);
|
||||
void Item_MapStats(void);
|
||||
void Item_ToggleInfo(void);
|
||||
void Item_Amputate(void);
|
||||
void Item_SwitchMap(void);
|
||||
void Item_EditMapNames(void);
|
||||
void Item_Copy(void);
|
||||
void Item_Paste(void);
|
||||
void Item_LastVideo(void);
|
||||
void Item_FloodFill(void);
|
||||
void Item_LastMap(void);
|
||||
void Item_CountTiles(void);
|
||||
int CheckForMapSave(void);
|
||||
void DoFloodFill(int x,int y,int whichb);
|
||||
|
||||
void DrawTileSelect(int deltarows,int *numrows,int *numcols);
|
||||
void DrawUnused(int deltarow);
|
||||
void DrawCurrentTiles(void);
|
||||
void ZeroModes(void);
|
||||
|
||||
//
|
||||
// TED5-3
|
||||
//
|
||||
void Item_EditMapEdges(void);
|
||||
void Item_PrintMem(void);
|
||||
void Item_Huffman(void);
|
||||
void CheckInfoValues(int i,int j,int tilei);
|
||||
void PrintMem(int x,int y);
|
||||
void EraseFloatPaste(void);
|
||||
void DrawFloatPaste(void);
|
||||
void CopyScreen(int srcx,int srcy,int width,int height,int destx,int desty);
|
||||
void Item_LAUNCHname(void);
|
||||
void Item_PARMstring(void);
|
||||
void Item_ChangeIconRows(void);
|
||||
void Item_ChangeLaunchIcon(void);
|
||||
void Item_ChangeBkgndColor(void);
|
||||
|
||||
//
|
||||
// TED5-4
|
||||
//
|
||||
void SignalSound(void);
|
||||
void Item_GraphicDump(void);
|
||||
void Item_EditTinfoValues(void);
|
||||
void Item_ProjectReSelect(void);
|
||||
void Item_AddDelTinfo(void);
|
||||
void Item_GridMode(void);
|
||||
void Item_SnapTog(void);
|
||||
void Item_ViewMap(void);
|
||||
void Item_ReviewMap(void);
|
||||
void Item_ImportMaps(void);
|
||||
void Item_VisitDOS(void);
|
||||
void Item_POtog(void);
|
||||
void Do_ViewMap(int how);
|
||||
int MakeOBJ(char *filename,char *destfilename,char *public,segtype whichseg,char *farname);
|
||||
void DrawTinfoScreen(int thescreen,int deltax,int deltay);
|
||||
void EnterTinfoValue(int whichtinfo,int mx,int my,int H_or_V);
|
||||
void UseTinfoValue(int whichtinfo,int mx,int my,int PickupOrDrop);
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
Start Stop Length Name Class
|
||||
|
||||
00000H 03D85H 03D86H _TEXT CODE
|
||||
03D86H 075F3H 0386EH TED5_TEXT CODE
|
||||
075F4H 0AAB4H 034C1H TED5-1_TEXT CODE
|
||||
0AAB5H 0DF0EH 0345AH TED5-2_TEXT CODE
|
||||
0DF0FH 11A7EH 03B70H TED5-3_TEXT CODE
|
||||
11A7FH 155C6H 03B48H TED5-4_TEXT CODE
|
||||
155C8H 15F88H 009C1H TED5_A_TEXT CODE
|
||||
15F89H 18B31H 02BA9H MENU_TEXT CODE
|
||||
18B32H 1998FH 00E5EH LIB_TEXT CODE
|
||||
19990H 1A2B3H 00924H MEMMGR_TEXT CODE
|
||||
1A2B4H 1A55FH 002ACH XMS_TEXT CODE
|
||||
1A560H 1B034H 00AD5H JHUFF_TEXT CODE
|
||||
1B038H 1B3D8H 003A1H LIB_A_TEXT CODE
|
||||
1B3E0H 1DB46H 02767H EMU_PROG CODE
|
||||
1DB50H 1E117H 005C8H E87_PROG CODE
|
||||
1E120H 1E120H 00000H _FARDATA FAR_DATA
|
||||
1E120H 1F11FH 01000H TEDcharset FAR_DATA
|
||||
1F120H 1F120H 00000H _FARBSS FAR_BSS
|
||||
1F120H 1F120H 00000H _OVERLAY_ OVRINFO
|
||||
1F120H 1F120H 00000H _1STUB_ STUBSEG
|
||||
1F120H 25277H 06158H _DATA DATA
|
||||
25278H 25279H 00002H _CVTSEG DATA
|
||||
2527AH 2527AH 00000H _SCNSEG DATA
|
||||
2527AH 2527AH 00000H _CONST CONST
|
||||
2527AH 25291H 00018H _INIT_ INITDATA
|
||||
25292H 25292H 00000H _INITEND_ INITDATA
|
||||
25292H 25297H 00006H _EXIT_ EXITDATA
|
||||
25298H 25298H 00000H _EXITEND_ EXITDATA
|
||||
25298H 29B6BH 048D4H _BSS BSS
|
||||
29B6CH 29B6CH 00000H _BSSEND BSSEND
|
||||
29B70H 29BEFH 00080H _STACK STACK
|
||||
|
||||
Program entry point at 0000:0000
|
||||
|
||||
+1385
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
@@ -0,0 +1,200 @@
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// XMS routines - uses the MENU.C & LIB.C routines for output
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
#include "ted5.h"
|
||||
#pragma hdrstop
|
||||
|
||||
|
||||
long TTLxms;
|
||||
unsigned XMSavail;
|
||||
void far *XMSdriver;
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// CALL the XMSdriver with a function #
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
void CallXMS(char func)
|
||||
{
|
||||
asm mov ah,[func]
|
||||
asm call [DWORD PTR XMSdriver]
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// Initialize the XMS memory
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
void InitXMS(void)
|
||||
{
|
||||
//
|
||||
// See if XMS driver is present...
|
||||
//
|
||||
asm mov ax,0x4300
|
||||
asm int 0x2f
|
||||
asm cmp al,0x80 // installed?
|
||||
asm je Present
|
||||
|
||||
ErrDialog("You poor bastard! I refuse\n"
|
||||
"to work without Extended\n"
|
||||
"Memory! Goodbye!"," I Suck ");
|
||||
Quit("No Extended Memory Driver found!");
|
||||
|
||||
//
|
||||
// YES! We found an XMS driver! Now we
|
||||
// need to get the XMS driver's entry address...
|
||||
//
|
||||
Present:
|
||||
asm mov ax,0x4310
|
||||
asm int 0x2f
|
||||
asm mov WORD PTR XMSdriver,bx
|
||||
asm mov WORD PTR XMSdriver+2,es
|
||||
|
||||
XMSTotalFree();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// Report an XMS error, if any
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
void XMSerror(void)
|
||||
{
|
||||
if (_AX==0)
|
||||
switch(_BL)
|
||||
{
|
||||
case 0x80: Quit("Function not implemented!");
|
||||
case 0x81: Quit("VDISK device driver was detected!");
|
||||
case 0x82: Quit("A20 error occurred!");
|
||||
case 0x8e: Quit("General driver error!");
|
||||
case 0x8f: Quit("Unrecoverable driver error!");
|
||||
|
||||
case 0x90: Quit("High memory area does not exist!");
|
||||
case 0x91: Quit("High memory area already in use!");
|
||||
case 0x92: Quit("DX is less than /HMAMIN= parameter!");
|
||||
case 0x93: Quit("High memory area not allocated!");
|
||||
case 0x94: Quit("A20 line still enabled!");
|
||||
|
||||
case 0xa0: Quit("Not enough Extended Memory available!");
|
||||
case 0xa1: Quit("Extended memory handles exhausted!");
|
||||
case 0xa2: Quit("Invalid handle!");
|
||||
case 0xa3: Quit("Invalid source handle!");
|
||||
case 0xa4: Quit("Invalid source offset!");
|
||||
case 0xa5: Quit("Invalid destination handle!");
|
||||
case 0xa6: Quit("Invalid destination offset!");
|
||||
case 0xa7: Quit("Invalid length!");
|
||||
case 0xa8: Quit("Invalid overlap in move request!");
|
||||
case 0xa9: Quit("Parity error detected!");
|
||||
case 0xaa: Quit("Block is not locked!");
|
||||
case 0xab: Quit("Block is locked!");
|
||||
case 0xac: Quit("Lock count overflowed!");
|
||||
case 0xad: Quit("Lock failed!");
|
||||
|
||||
case 0xb0: Quit("Smaller UMB is available!");
|
||||
case 0xb1: Quit("No UMBs are available!");
|
||||
case 0xb2: Quit("Invalid UMB segment number!");
|
||||
|
||||
default: Quit("Unknown XMS Memory Error! I'm totally stumped!");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// Allocate XMS memory
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
int XMSAllocate(long size)
|
||||
{
|
||||
#if 0
|
||||
static int allocnum=0;
|
||||
|
||||
_MouseHide();
|
||||
sx=0;
|
||||
sy=1;
|
||||
print("XMS allocation #");
|
||||
printint(allocnum++);
|
||||
print(":");
|
||||
printint((1023L+size)/1024L);
|
||||
print("K");
|
||||
while(!keydown[0x1c]);
|
||||
clearkeys();
|
||||
_MouseShow();
|
||||
#endif
|
||||
|
||||
|
||||
_DX=(size+1023)/1024;
|
||||
CallXMS(9);
|
||||
XMSerror();
|
||||
asm push dx
|
||||
TTLxms=1024L*XMSTotalFree();
|
||||
asm pop dx
|
||||
return _DX;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// Free XMS memory
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
void XMSFreeMem(int handle)
|
||||
{
|
||||
_DX=handle;
|
||||
CallXMS(10);
|
||||
XMSerror();
|
||||
TTLxms=1024L*XMSTotalFree();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// Return XMS memory available
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
unsigned XMSTotalFree(void)
|
||||
{
|
||||
CallXMS(8);
|
||||
XMSerror();
|
||||
XMSavail=_DX;
|
||||
return XMSavail;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
// Move XMS memory
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
void XMSmove(int srchandle,long srcoff,int desthandle,long destoff,long size)
|
||||
{
|
||||
struct { long bsize;
|
||||
int shandle;
|
||||
long soff;
|
||||
int dhandle;
|
||||
long doff;
|
||||
} XMSparms;
|
||||
|
||||
unsigned DSreg,SIreg;
|
||||
|
||||
XMSparms.bsize=size+(size&1);
|
||||
XMSparms.shandle=srchandle;
|
||||
XMSparms.dhandle=desthandle;
|
||||
XMSparms.soff=srcoff;
|
||||
XMSparms.doff=destoff;
|
||||
|
||||
DSreg=FP_SEG(&XMSparms);
|
||||
SIreg=FP_OFF(&XMSparms);
|
||||
|
||||
asm push ds
|
||||
asm push si
|
||||
asm mov si,SIreg
|
||||
asm mov ds,DSreg
|
||||
|
||||
CallXMS(11);
|
||||
|
||||
asm pop si
|
||||
asm pop ds
|
||||
|
||||
XMSerror();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
void InitXMS(void);
|
||||
int XMSAllocate(long size);
|
||||
unsigned XMSTotalFree(void); // returns KB free
|
||||
void XMSFreeMem(int handle);
|
||||
void XMSmove(int srchandle,long srcoff,int desthandle,long destoff,long size);
|
||||
|
||||
extern unsigned XMSavail;
|
||||
extern long TTLxms;
|
||||
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user