Reformat all C files.

I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
This commit is contained in:
Sean Hunt
2015-05-09 13:43:16 -04:00
parent 167800afdf
commit 97d6fade74
270 changed files with 182649 additions and 173878 deletions
+162 -156
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 amidos.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 amidos.c $NHDT-Date: 1431192784 2015/05/09 17:33:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
/* NetHack 3.6 amidos.c $Date: 2009/05/06 10:48:29 $ $Revision: 1.6 $ */
/* SCCS Id: @(#)amidos.c 3.5 2000/01/12
/* Copyright (c) Olaf Seibert, Nijmegen, The Netherlands, 1988,1990. */
@@ -21,13 +21,13 @@
#undef COUNT
#if defined(__SASC_60) || defined(__GNUC__)
# include <proto/exec.h>
# include <proto/dos.h>
#include <proto/exec.h>
#include <proto/dos.h>
#endif
#ifdef AZTEC_50
# include <functions.h>
# undef strcmpi
#include <functions.h>
#undef strcmpi
#endif
/* Prototypes */
@@ -39,7 +39,7 @@ extern char Initialized;
extern struct window_procs amii_procs;
#ifndef __SASC_60
int Enable_Abort = 0; /* for stdio package */
int Enable_Abort = 0; /* for stdio package */
#endif
/* Initial path, so we can find NetHack.cnf */
@@ -73,7 +73,7 @@ int
abs(x)
int x;
{
return x < 0? -x: x;
return x < 0 ? -x : x;
}
#endif
@@ -82,31 +82,28 @@ int
dosh()
{
int i;
char buf[ BUFSZ ];
char buf[BUFSZ];
extern struct ExecBase *SysBase;
/* Only under 2.0 and later ROMs do we have System() */
if( SysBase->LibNode.lib_Version >= 37 && !amibbs)
{
getlin("Enter CLI Command...", buf );
if (buf[0] != '\033')
i = System( buf, NULL );
}
else
{
i = 0;
pline("No mysterious force prevented you from using multitasking.");
if (SysBase->LibNode.lib_Version >= 37 && !amibbs) {
getlin("Enter CLI Command...", buf);
if (buf[0] != '\033')
i = System(buf, NULL);
} else {
i = 0;
pline("No mysterious force prevented you from using multitasking.");
}
return i;
}
#endif /* SHELL */
#ifdef MFLOPPY
# include <ctype.h>
#include <ctype.h>
# define Sprintf (void) sprintf
#define Sprintf (void) sprintf
#define EXTENSION 72
#define EXTENSION 72
/*
* This routine uses an approximation of the free bytes on a disk.
@@ -122,10 +119,10 @@ freediskspace(path)
char *path;
{
#ifdef UNTESTED
/* these changes from Patric Mueller <bhaak@gmx.net> for AROS to
* handle larger disks. Also needs limits.h and aros/oldprograms.h
* for AROS. (keni)
*/
/* these changes from Patric Mueller <bhaak@gmx.net> for AROS to
* handle larger disks. Also needs limits.h and aros/oldprograms.h
* for AROS. (keni)
*/
unsigned long long freeBytes = 0;
#else
register long freeBytes = 0;
@@ -142,49 +139,51 @@ char *path;
* so must be on the current device, so "" is enough...
*/
{
register char *colon;
register char *colon;
strncpy(fileName, path, sizeof(fileName) - 1);
fileName[31] = 0;
if (colon = index(fileName, ':'))
colon[1] = '\0';
else
fileName[0] = '\0';
strncpy(fileName, path, sizeof(fileName) - 1);
fileName[31] = 0;
if (colon = index(fileName, ':'))
colon[1] = '\0';
else
fileName[0] = '\0';
}
{
BPTR fileLock;
infoData = (struct InfoData *) alloc(sizeof(struct InfoData));
if (fileLock = Lock(fileName, SHARED_LOCK)) {
if (Info(fileLock, infoData)) {
/* We got a kind of DOS volume, since we can Lock it. */
/* Calculate number of blocks available for new file */
/* Kludge for the ever-full VOID: (oops RAM:) device */
if (infoData->id_UnitNumber == -1 &&
infoData->id_NumBlocks == infoData->id_NumBlocksUsed) {
freeBytes = AvailMem(0L) - 64 * 1024L;
/* Just a stupid guess at the */
/* Ram-Handler overhead per block: */
freeBytes -= freeBytes/16;
} else {
/* Normal kind of DOS file system device/volume */
freeBytes = infoData->id_NumBlocks - infoData->id_NumBlocksUsed;
freeBytes -= (freeBytes + EXTENSION) / (EXTENSION + 1);
freeBytes *= infoData->id_BytesPerBlock;
BPTR fileLock;
infoData = (struct InfoData *) alloc(sizeof(struct InfoData));
if (fileLock = Lock(fileName, SHARED_LOCK)) {
if (Info(fileLock, infoData)) {
/* We got a kind of DOS volume, since we can Lock it. */
/* Calculate number of blocks available for new file */
/* Kludge for the ever-full VOID: (oops RAM:) device */
if (infoData->id_UnitNumber == -1
&& infoData->id_NumBlocks == infoData->id_NumBlocksUsed) {
freeBytes = AvailMem(0L) - 64 * 1024L;
/* Just a stupid guess at the */
/* Ram-Handler overhead per block: */
freeBytes -= freeBytes / 16;
} else {
/* Normal kind of DOS file system device/volume */
freeBytes =
infoData->id_NumBlocks - infoData->id_NumBlocksUsed;
freeBytes -= (freeBytes + EXTENSION) / (EXTENSION + 1);
freeBytes *= infoData->id_BytesPerBlock;
#ifdef UNTESTED
if (freeBytes > LONG_MAX) { freeBytes = LONG_MAX; }
if (freeBytes > LONG_MAX) {
freeBytes = LONG_MAX;
}
#endif
}
if (freeBytes < 0)
freeBytes = 0;
}
UnLock(fileLock);
}
free(infoData);
return freeBytes;
}
if (freeBytes < 0)
freeBytes = 0;
}
UnLock(fileLock);
}
free(infoData);
return freeBytes;
}
}
long
filesize(file)
char *file;
@@ -193,12 +192,13 @@ char *file;
register struct FileInfoBlock *fileInfoBlock;
register long size = 0;
fileInfoBlock = (struct FileInfoBlock *)alloc(sizeof(struct FileInfoBlock));
fileInfoBlock =
(struct FileInfoBlock *) alloc(sizeof(struct FileInfoBlock));
if (fileLock = Lock(file, SHARED_LOCK)) {
if (Examine(fileLock, fileInfoBlock)) {
size = fileInfoBlock->fib_Size;
}
UnLock(fileLock);
if (Examine(fileLock, fileInfoBlock)) {
size = fileInfoBlock->fib_Size;
}
UnLock(fileLock);
}
free(fileInfoBlock);
return size;
@@ -240,7 +240,7 @@ const char *path, *files;
/* This size makes that most files can be copied with two Read()/Write()s */
#if 0 /* Unused */
#define COPYSIZE 4096
#define COPYSIZE 4096
char *CopyFile(from, to)
const char *from, *to;
@@ -280,48 +280,50 @@ saveDiskPrompt(start)
char buf[BUFSIZ], *bp;
BPTR fileLock;
if (sysflags.asksavedisk) {
/* Don't prompt if you can find the save file */
if (fileLock = Lock(SAVEF, SHARED_LOCK)) {
UnLock(fileLock);
/* Don't prompt if you can find the save file */
if (fileLock = Lock(SAVEF, SHARED_LOCK)) {
UnLock(fileLock);
#if defined(TTY_GRAPHICS)
if(windowprocs.win_init_nhwindows!=amii_procs.win_init_nhwindows)
clear_nhwindow( WIN_MAP );
if (windowprocs.win_init_nhwindows
!= amii_procs.win_init_nhwindows)
clear_nhwindow(WIN_MAP);
#endif
#if defined(AMII_GRAPHICS)
if(windowprocs.win_init_nhwindows==amii_procs.win_init_nhwindows)
clear_nhwindow( WIN_BASE );
if (windowprocs.win_init_nhwindows
== amii_procs.win_init_nhwindows)
clear_nhwindow(WIN_BASE);
#endif
return 1;
}
pline( "If save file is on a SAVE disk, put that disk in now." );
if( strlen( SAVEF ) > QBUFSZ - 25 - 22 )
panic( "not enough buffer space for prompt" );
return 1;
}
pline("If save file is on a SAVE disk, put that disk in now.");
if (strlen(SAVEF) > QBUFSZ - 25 - 22)
panic("not enough buffer space for prompt");
/* THIS IS A HACK */
#if defined(TTY_GRAPHICS)
if(windowprocs.win_init_nhwindows!=amii_procs.win_init_nhwindows){
getlin("File name ?",buf);
clear_nhwindow( WIN_MAP );
}
if (windowprocs.win_init_nhwindows != amii_procs.win_init_nhwindows) {
getlin("File name ?", buf);
clear_nhwindow(WIN_MAP);
}
#endif
#if defined(AMII_GRAPHICS)
if(windowprocs.win_init_nhwindows==amii_procs.win_init_nhwindows){
getlind("File name ?", buf, SAVEF);
clear_nhwindow( WIN_BASE );
}
if (windowprocs.win_init_nhwindows == amii_procs.win_init_nhwindows) {
getlind("File name ?", buf, SAVEF);
clear_nhwindow(WIN_BASE);
}
#endif
clear_nhwindow( WIN_MESSAGE);
if (!start && *buf == '\033')
return 0;
clear_nhwindow(WIN_MESSAGE);
if (!start && *buf == '\033')
return 0;
/* Strip any whitespace. Also, if nothing was entered except
* whitespace, do not change the value of SAVEF.
*/
for (bp = buf; *bp; bp++) {
if (!isspace(*bp)) {
strncpy(SAVEF, bp, PATHLEN);
break;
}
}
/* Strip any whitespace. Also, if nothing was entered except
* whitespace, do not change the value of SAVEF.
*/
for (bp = buf; *bp; bp++) {
if (!isspace(*bp)) {
strncpy(SAVEF, bp, PATHLEN);
break;
}
}
}
return 1;
}
@@ -333,8 +335,8 @@ record_exists()
FILE *file;
if (file = fopenp(RECORD, "r")) {
fclose(file);
return TRUE;
fclose(file);
return TRUE;
}
return FALSE;
}
@@ -345,7 +347,9 @@ record_exists()
* For Amiga: do nothing, but called from restore.c
*/
void
gameDiskPrompt(){}
gameDiskPrompt()
{
}
#endif
/*
@@ -358,16 +362,16 @@ char *name;
{
char *ptr;
if (!*name)return;
if (!*name)
return;
ptr = eos(name) - 1;
if (*ptr != '/' && *ptr != ':') {
*++ptr = '/';
*++ptr = '\0';
*++ptr = '/';
*++ptr = '\0';
}
}
void
getreturn(str)
const char *str;
@@ -375,13 +379,13 @@ const char *str;
int ch;
raw_printf("Hit <RETURN> %s.", str);
while ((ch = nhgetch()) != '\n' && ch != '\r' )
continue;
while ((ch = nhgetch()) != '\n' && ch != '\r')
continue;
}
/* Follow the PATH, trying to fopen the file.
*/
#define PATHSEP ';'
#define PATHSEP ';'
FILE *
fopenp(name, mode)
@@ -394,30 +398,34 @@ register const char *name, *mode;
/* Try the default directory first. Then look along PATH.
*/
if (strlen(name) >= BUFSIZ) return( NULL );
if (strlen(name) >= BUFSIZ)
return (NULL);
strcpy(buf, name);
if (theLock = Lock(buf, SHARED_LOCK)) {
UnLock(theLock);
if (fp = fopen(buf, mode))
return fp;
UnLock(theLock);
if (fp = fopen(buf, mode))
return fp;
}
pp = PATH;
while (pp && *pp) {
bp = buf;
while (*pp && *pp != PATHSEP){
if( bp > buf + BUFSIZ - 1 ) return( NULL );
lastch = *bp++ = *pp++;
}
if (lastch != ':' && lastch != '/' && bp != buf)
*bp++ = '/';
if (bp + strlen(name) > buf + BUFSIZ - 1) return( NULL );
strcpy(bp, name);
if (theLock = Lock(buf, SHARED_LOCK)) {
UnLock(theLock);
if (fp = fopen(buf, mode)) return fp;
}
if (*pp)
pp++;
bp = buf;
while (*pp && *pp != PATHSEP) {
if (bp > buf + BUFSIZ - 1)
return (NULL);
lastch = *bp++ = *pp++;
}
if (lastch != ':' && lastch != '/' && bp != buf)
*bp++ = '/';
if (bp + strlen(name) > buf + BUFSIZ - 1)
return (NULL);
strcpy(bp, name);
if (theLock = Lock(buf, SHARED_LOCK)) {
UnLock(theLock);
if (fp = fopen(buf, mode))
return fp;
}
if (*pp)
pp++;
}
return NULL;
}
@@ -432,37 +440,36 @@ register const char *name, *mode;
* Assumes -1 is not a valid lock, since 0 is valid.
*/
#define NO_LOCK ((BPTR) -1)
#define NO_LOCK ((BPTR) -1)
static BPTR OrgDirLock = NO_LOCK;
chdir(dir)
char *dir;
chdir(dir) char *dir;
{
extern char orgdir[];
if (dir == orgdir) {
/* We want to go back to where we came from. */
if (OrgDirLock != NO_LOCK) {
UnLock(CurrentDir(OrgDirLock));
OrgDirLock = NO_LOCK;
}
/* We want to go back to where we came from. */
if (OrgDirLock != NO_LOCK) {
UnLock(CurrentDir(OrgDirLock));
OrgDirLock = NO_LOCK;
}
} else {
/*
* Go to some new place. If still at the original
* directory, save the FileLock.
*/
BPTR newDir;
/*
* Go to some new place. If still at the original
* directory, save the FileLock.
*/
BPTR newDir;
if (newDir = Lock( (char *)dir, SHARED_LOCK)) {
if (OrgDirLock == NO_LOCK) {
OrgDirLock = CurrentDir(newDir);
} else {
UnLock(CurrentDir(newDir));
}
} else {
return -1; /* Failed */
}
if (newDir = Lock((char *) dir, SHARED_LOCK)) {
if (OrgDirLock == NO_LOCK) {
OrgDirLock = CurrentDir(newDir);
} else {
UnLock(CurrentDir(newDir));
}
} else {
return -1; /* Failed */
}
}
/* CurrentDir always succeeds if you have a lock */
return 0;
@@ -481,22 +488,21 @@ nethack_exit(code)
#endif
#ifdef CHDIR
chdir(orgdir); /* chdir, not chdirx */
chdir(orgdir); /* chdir, not chdirx */
#endif
#ifdef AMII_GRAPHICS
if(windowprocs.win_init_nhwindows==amii_procs.win_init_nhwindows)
CleanUp();
if (windowprocs.win_init_nhwindows == amii_procs.win_init_nhwindows)
CleanUp();
#endif
exit(code);
}
void
regularize(s) /* normalize file name - we don't like :'s or /'s */
void regularize(s) /* normalize file name - we don't like :'s or /'s */
register char *s;
{
register char *lp;
while((lp = index(s, ':')) || (lp = index(s, '/')))
*lp = '_';
while ((lp = index(s, ':')) || (lp = index(s, '/')))
*lp = '_';
}
+3 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 amigst.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 amigst.c $NHDT-Date: 1431192783 2015/05/09 17:33:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 amigst.c $Date: 2009/05/06 10:48:29 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)amigst.c 3.5 1993/01/08
/* Copyright (c) Gregg Wonderly, Naperville, IL, 1992, 1993 */
@@ -15,12 +15,12 @@
#include <intuition/intuition.h>
#include <libraries/dosextens.h>
#include <ctype.h>
#undef strcmpi
#undef strcmpi
#include <string.h>
#include <errno.h>
#ifdef __SASC
#include <dos.h> /* for __emit */
#include <dos.h> /* for __emit */
#include <string.h>
#include <proto/dos.h>
#include <proto/exec.h>
+94 -82
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 amimenu.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 amimenu.c $NHDT-Date: 1431192784 2015/05/09 17:33:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 amimenu.c $Date: 2009/05/06 10:48:29 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)amimenu.c 3.5 1996/02/04 */
/* Copyright (c) Olaf 'Rhialto' Seibert, 1989 */
@@ -11,87 +11,99 @@
/* GadTools menus by jhsa */
struct NewMenu GTHackMenu[] = {
{ NM_TITLE, "Commands", 0, 0, 0, 0},
{ NM_ITEM, "? Display help menu", 0, 0, 0, (void *)'?'},
{ NM_ITEM, "& Explain a command", 0, 0, 0, (void *)'&'},
{ NM_ITEM, "O Set options", 0, 0, 0, (void *)'O'},
{ NM_ITEM, "! AmigaDos command", 0, 0, 0, (void *)'!'},
{ NM_ITEM, "v Version number", 0, 0, 0, (void *)'v'},
{ NM_ITEM, "V Long version and game history", 0, 0, 0, (void *)'V'},
{ NM_ITEM, "^R Redraw screen", 0, 0, 0, (void *)022},
{ NM_ITEM, "^P Repeat previous messages", 0, 0, 0, (void *)020},
{ NM_ITEM, "M-q #quit the game", 0, 0, 0, (void *)(128+'q')},
{ NM_ITEM, "S Save the game", 0, 0, 0, (void *)'S'},
{ NM_TITLE, "Inventory", 0, 0, 0, 0},
{ NM_ITEM, "i Inventory", 0, 0, 0, (void *)'i'},
{ NM_ITEM, "p Pay your bill", 0, 0, 0, (void *)'p'},
{ NM_ITEM, "d Drop an object", 0, 0, 0, (void *)'d'},
{ NM_ITEM, "D Drop several things", 0, 0, 0, (void *)'D'},
{ NM_ITEM, ", Pickup an object", 0, 0, 0, (void *)','},
{ NM_ITEM, "@ Toggle pickup", 0, 0, 0, (void *)'@'},
{ NM_ITEM, "/ Identify something", 0, 0, 0, (void *)'/'},
{ NM_ITEM, "C Christen a monster", 0, 0, 0, (void *)'C'},
{ NM_ITEM, "+ List known spells", 0, 0, 0, (void *)'+'},
{ NM_ITEM, "$ Your gold", 0, 0, 0, (void *)'$'},
{ NM_TITLE, "Actions", 0, 0, 0, 0},
{ NM_ITEM, "a Apply/use something", 0, 0, 0, (void *)'a'},
{ NM_ITEM, "e Eat something", 0, 0, 0, (void *)'e'},
{ NM_ITEM, "f Fire ammunition", 0, 0, 0, (void *)'f'},
{ NM_ITEM, "F Fight a monster", 0, 0, 0, (void *)'F'},
{ NM_ITEM, "q Quaff a monster", 0, 0, 0, (void *)'q'},
{ NM_ITEM, "r Read scroll/book", 0, 0, 0, (void *)'r'},
{ NM_ITEM, "t Throw something", 0, 0, 0, (void *)'t'},
{ NM_ITEM, "z Zap a wand", 0, 0, 0, (void *)'z'},
{ NM_ITEM, "Z Cast a spell", 0, 0, 0, (void *)'Z'},
{ NM_TITLE, "Preparations", 0, 0, 0, 0},
{ NM_ITEM, "A Remove all armor", 0, 0, 0, (void *)'A'},
{ NM_ITEM, "P Put on a ring", 0, 0, 0, (void *)'P'},
{ NM_ITEM, "R Remove ring", 0, 0, 0, (void *)'R'},
{ NM_ITEM, "Q Select ammunition for quiver", 0, 0, 0, (void *)'Q'},
{ NM_ITEM, "T Take off armor", 0, 0, 0, (void *)'T'},
{ NM_ITEM, "w Wield a weapon", 0, 0, 0, (void *)'w'},
{ NM_ITEM, "W Wear armor", 0, 0, 0, (void *)'W'},
{ NM_ITEM, "x Swap wielded and secondary weapons", 0, 0, 0, (void *)'x'},
{ NM_ITEM, ") Current weapon", 0, 0, 0, (void *)')'},
{ NM_ITEM, "[ Current armor", 0, 0, 0, (void *)'['},
{ NM_ITEM, "= Current rings", 0, 0, 0, (void *)'='},
{ NM_ITEM,"\" Current amulet", 0, 0, 0, (void *)'"'},
{ NM_ITEM, "( Current tools", 0, 0, 0, (void *)'('},
{ NM_ITEM, "* Current equipment", 0, 0, 0, (void *)'*'},
{ NM_TITLE, "Movement", 0, 0, 0, 0},
{ NM_ITEM, "o Open door", 0, 0, 0, (void *)'o'},
{ NM_ITEM, "c Close door", 0, 0, 0, (void *)'c'},
{ NM_ITEM, "^D Kick door", 0, 0, 0, (void *)004},
{ NM_ITEM, "s Search", 0, 0, 0, (void *)'s'},
{ NM_ITEM, "< Go up stairs", 0, 0, 0, (void *)'<'},
{ NM_ITEM, "> Go down stairs", 0, 0, 0, (void *)'>'},
{ NM_ITEM, "^T Teleport", 0, 0, 0, (void *)024},
{ NM_ITEM, ". Wait a moment", 0, 0, 0, (void *)'.'},
{ NM_ITEM, "E Engrave message on floor", 0, 0, 0, (void *)'E'},
{ NM_TITLE, "Extended", 0, 0, 0, 0},
{ NM_ITEM, "M-a #adjust inventory letters", 0, 0, 0, (void *)(128+'a')},
{ NM_ITEM, "M-c #chat with someone", 0, 0, 0, (void *)(128+'c')},
{ NM_ITEM, "M-d #dip an object into something", 0, 0, 0, (void *)(128+'d')},
{ NM_TITLE, "Commands", 0, 0, 0, 0 },
{ NM_ITEM, "? Display help menu", 0, 0, 0, (void *) '?' },
{ NM_ITEM, "& Explain a command", 0, 0, 0, (void *) '&' },
{ NM_ITEM, "O Set options", 0, 0, 0, (void *) 'O' },
{ NM_ITEM, "! AmigaDos command", 0, 0, 0, (void *) '!' },
{ NM_ITEM, "v Version number", 0, 0, 0, (void *) 'v' },
{ NM_ITEM, "V Long version and game history", 0, 0, 0, (void *) 'V' },
{ NM_ITEM, "^R Redraw screen", 0, 0, 0, (void *) 022 },
{ NM_ITEM, "^P Repeat previous messages", 0, 0, 0, (void *) 020 },
{ NM_ITEM, "M-q #quit the game", 0, 0, 0, (void *)(128 + 'q') },
{ NM_ITEM, "S Save the game", 0, 0, 0, (void *) 'S' },
{ NM_TITLE, "Inventory", 0, 0, 0, 0 },
{ NM_ITEM, "i Inventory", 0, 0, 0, (void *) 'i' },
{ NM_ITEM, "p Pay your bill", 0, 0, 0, (void *) 'p' },
{ NM_ITEM, "d Drop an object", 0, 0, 0, (void *) 'd' },
{ NM_ITEM, "D Drop several things", 0, 0, 0, (void *) 'D' },
{ NM_ITEM, ", Pickup an object", 0, 0, 0, (void *) ',' },
{ NM_ITEM, "@ Toggle pickup", 0, 0, 0, (void *) '@' },
{ NM_ITEM, "/ Identify something", 0, 0, 0, (void *) '/' },
{ NM_ITEM, "C Christen a monster", 0, 0, 0, (void *) 'C' },
{ NM_ITEM, "+ List known spells", 0, 0, 0, (void *) '+' },
{ NM_ITEM, "$ Your gold", 0, 0, 0, (void *) '$' },
{ NM_TITLE, "Actions", 0, 0, 0, 0 },
{ NM_ITEM, "a Apply/use something", 0, 0, 0, (void *) 'a' },
{ NM_ITEM, "e Eat something", 0, 0, 0, (void *) 'e' },
{ NM_ITEM, "f Fire ammunition", 0, 0, 0, (void *) 'f' },
{ NM_ITEM, "F Fight a monster", 0, 0, 0, (void *) 'F' },
{ NM_ITEM, "q Quaff a monster", 0, 0, 0, (void *) 'q' },
{ NM_ITEM, "r Read scroll/book", 0, 0, 0, (void *) 'r' },
{ NM_ITEM, "t Throw something", 0, 0, 0, (void *) 't' },
{ NM_ITEM, "z Zap a wand", 0, 0, 0, (void *) 'z' },
{ NM_ITEM, "Z Cast a spell", 0, 0, 0, (void *) 'Z' },
{ NM_TITLE, "Preparations", 0, 0, 0, 0 },
{ NM_ITEM, "A Remove all armor", 0, 0, 0, (void *) 'A' },
{ NM_ITEM, "P Put on a ring", 0, 0, 0, (void *) 'P' },
{ NM_ITEM, "R Remove ring", 0, 0, 0, (void *) 'R' },
{ NM_ITEM, "Q Select ammunition for quiver", 0, 0, 0, (void *) 'Q' },
{ NM_ITEM, "T Take off armor", 0, 0, 0, (void *) 'T' },
{ NM_ITEM, "w Wield a weapon", 0, 0, 0, (void *) 'w' },
{ NM_ITEM, "W Wear armor", 0, 0, 0, (void *) 'W' },
{ NM_ITEM, "x Swap wielded and secondary weapons", 0, 0, 0,
(void *) 'x' },
{ NM_ITEM, ") Current weapon", 0, 0, 0, (void *) ')' },
{ NM_ITEM, "[ Current armor", 0, 0, 0, (void *) '[' },
{ NM_ITEM, "= Current rings", 0, 0, 0, (void *) '=' },
{ NM_ITEM, "\" Current amulet", 0, 0, 0, (void *) '"' },
{ NM_ITEM, "( Current tools", 0, 0, 0, (void *) '(' },
{ NM_ITEM, "* Current equipment", 0, 0, 0, (void *) '*' },
{ NM_TITLE, "Movement", 0, 0, 0, 0 },
{ NM_ITEM, "o Open door", 0, 0, 0, (void *) 'o' },
{ NM_ITEM, "c Close door", 0, 0, 0, (void *) 'c' },
{ NM_ITEM, "^D Kick door", 0, 0, 0, (void *) 004 },
{ NM_ITEM, "s Search", 0, 0, 0, (void *) 's' },
{ NM_ITEM, "< Go up stairs", 0, 0, 0, (void *) '<' },
{ NM_ITEM, "> Go down stairs", 0, 0, 0, (void *) '>' },
{ NM_ITEM, "^T Teleport", 0, 0, 0, (void *) 024 },
{ NM_ITEM, ". Wait a moment", 0, 0, 0, (void *) '.' },
{ NM_ITEM, "E Engrave message on floor", 0, 0, 0, (void *) 'E' },
{ NM_TITLE, "Extended", 0, 0, 0, 0 },
{ NM_ITEM, "M-a #adjust inventory letters", 0, 0, 0,
(void *)(128 + 'a') },
{ NM_ITEM, "M-c #chat with someone", 0, 0, 0, (void *)(128 + 'c') },
{ NM_ITEM, "M-d #dip an object into something", 0, 0, 0,
(void *)(128 + 'd') },
#ifdef WEAPON_SKILLS
{ NM_ITEM, "M-e #enhance weapon skills", 0, 0, 0, (void *)(128+'e')},
{ NM_ITEM, "M-e #enhance weapon skills", 0, 0, 0, (void *)(128 + 'e') },
#endif
{ NM_ITEM, "M-f #force a lock", 0, 0, 0, (void *)(128+'f')},
{ NM_ITEM, "M-i #invoke an object's special powers", 0, 0, 0, (void *)(128+'i')},
{ NM_ITEM, "M-j #jump to another location", 0, 0, 0, (void *)(128+'j')},
{ NM_ITEM, "M-l #loot a box on the floor", 0, 0, 0, (void *)(128+'l')},
{ NM_ITEM, "M-m Use a #monster's special ability", 0, 0, 0, (void *)(128+'m')},
{ NM_ITEM, "M-n #name an item or type of object", 0, 0, 0, (void *)(128+'n')},
{ NM_ITEM, "M-o #offer a sacrifice to the gods", 0, 0, 0, (void *)(128+'o')},
{ NM_ITEM, "M-p #pray to the gods for help", 0, 0, 0, (void *)(128+'p')},
{ NM_ITEM, "M-q #quit the game", 0, 0, 0, (void *)(128+'q')},
{ NM_ITEM, "M-r #rub a lamp", 0, 0, 0, (void *)(128+'r')},
{ NM_ITEM, "M-s #sit down", 0, 0, 0, (void *)(128+'s')},
{ NM_ITEM, "M-t #turn undead", 0, 0, 0, (void *)(128+'t')},
{ NM_ITEM, "M-u #untrap something", 0, 0, 0, (void *)(128+'u')},
{ NM_ITEM, "M-v Long #version information", 0, 0, 0, (void *)(128+'v')},
{ NM_ITEM, "M-w #wipe off your face", 0, 0, 0, (void *)(128+'w')},
{ NM_ITEM, " Your #conduct", 0, 0, 0, (void *)'#'}, /* "#co\n" */
{ NM_ITEM, " #ride your steed", 0, 0, 0, (void *)'#'}, /* "#ri\n" */
{ NM_ITEM, "M-2 Switch #twoweapon mode on/off", 0, 0, 0, (void *)(128+'2')},
{ NM_END, NULL, 0, 0, 0, 0}
{ NM_ITEM, "M-f #force a lock", 0, 0, 0, (void *)(128 + 'f') },
{ NM_ITEM, "M-i #invoke an object's special powers", 0, 0, 0,
(void *)(128 + 'i') },
{ NM_ITEM, "M-j #jump to another location", 0, 0, 0,
(void *)(128 + 'j') },
{ NM_ITEM, "M-l #loot a box on the floor", 0, 0, 0,
(void *)(128 + 'l') },
{ NM_ITEM, "M-m Use a #monster's special ability", 0, 0, 0,
(void *)(128 + 'm') },
{ NM_ITEM, "M-n #name an item or type of object", 0, 0, 0,
(void *)(128 + 'n') },
{ NM_ITEM, "M-o #offer a sacrifice to the gods", 0, 0, 0,
(void *)(128 + 'o') },
{ NM_ITEM, "M-p #pray to the gods for help", 0, 0, 0,
(void *)(128 + 'p') },
{ NM_ITEM, "M-q #quit the game", 0, 0, 0, (void *)(128 + 'q') },
{ NM_ITEM, "M-r #rub a lamp", 0, 0, 0, (void *)(128 + 'r') },
{ NM_ITEM, "M-s #sit down", 0, 0, 0, (void *)(128 + 's') },
{ NM_ITEM, "M-t #turn undead", 0, 0, 0, (void *)(128 + 't') },
{ NM_ITEM, "M-u #untrap something", 0, 0, 0, (void *)(128 + 'u') },
{ NM_ITEM, "M-v Long #version information", 0, 0, 0,
(void *)(128 + 'v') },
{ NM_ITEM, "M-w #wipe off your face", 0, 0, 0, (void *)(128 + 'w') },
{ NM_ITEM, " Your #conduct", 0, 0, 0, (void *) '#' }, /* "#co\n" */
{ NM_ITEM, " #ride your steed", 0, 0, 0, (void *) '#' }, /* "#ri\n" */
{ NM_ITEM, "M-2 Switch #twoweapon mode on/off", 0, 0, 0,
(void *)(128 + '2') },
{ NM_END, NULL, 0, 0, 0, 0 }
};
+189 -188
View File
@@ -1,6 +1,7 @@
/* NetHack 3.6 amirip.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 amirip.c $NHDT-Date: 1431192783 2015/05/09 17:33:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $ */
/* NetHack 3.6 amirip.c $Date: 2012/01/24 04:26:20 $ $Revision: 1.7 $ */
/* Copyright (c) Kenneth Lorber, Bethesda, Maryland 1991,1992,1993,1995,1996. */
/* Copyright (c) Kenneth Lorber, Bethesda, Maryland 1991,1992,1993,1995,1996.
*/
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
@@ -25,59 +26,60 @@ static struct RastPort *rp;
#ifdef AMII_GRAPHICS
#undef NULL
#define NULL 0
#undef NULL
#define NULL 0
#ifdef AZTEC_C
# include <functions.h>
#include <functions.h>
#else
# ifdef _DCC
# include <clib/dos_protos.h>
# include <clib/exec_protos.h>
# include <clib/console_protos.h>
# include <clib/diskfont_protos.h>
# else
# include <proto/dos.h>
# include <proto/exec.h>
# include <proto/console.h>
# include <proto/diskfont.h>
# endif
#ifdef _DCC
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/console_protos.h>
#include <clib/diskfont_protos.h>
#else
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/console.h>
#include <proto/diskfont.h>
#endif
static char *load_list[]={"tomb.iff",0};
static char *load_list[] = { "tomb.iff", 0 };
static BitMapHeader tomb_bmhd;
static struct BitMap *tbmp[ 1 ] = {0};
static struct BitMap *tbmp[1] = { 0 };
static int cols[2]={154,319}; /* X location of center of columns */
static int cno = 0; /* current column */
#define TEXT_TOP (65+yoff)
static int cols[2] = { 154, 319 }; /* X location of center of columns */
static int cno = 0; /* current column */
#define TEXT_TOP (65 + yoff)
static xoff, yoff; /* image centering */
static xoff, yoff; /* image centering */
/* terrible kludge */
/* this is why prototypes should have ONLY types in them! */
# undef red
# undef green
# undef blue
# undef index
# ifdef _DCC
# include <clib/graphics_protos.h>
# include <clib/intuition_protos.h>
# else
# include <proto/graphics.h>
# include <proto/intuition.h>
# endif
#undef red
#undef green
#undef blue
#undef index
#ifdef _DCC
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#else
#include <proto/graphics.h>
#include <proto/intuition.h>
#endif
#endif /* AZTEC_C */
static struct Window *ripwin=0;
static void tomb_text(char*);
static void dofade(int,int,int);
static int search_cmap(int,int,int);
static struct Window *ripwin = 0;
static void tomb_text(char *);
static void dofade(int, int, int);
static int search_cmap(int, int, int);
#define STONE_LINE_LEN 13 /* # chars that fit on one line
* (note 1 ' ' border) */
#define STONE_LINE_LEN \
13 /* # chars that fit on one line \
* (note 1 ' ' border) */
#define DEATH_LINE 10
#define YEAR_LINE 15
#define DEATH_LINE 10
#define YEAR_LINE 15
static unsigned short tomb_line;
@@ -85,22 +87,22 @@ extern struct amii_DisplayDesc *amiIDisplay;
extern struct Screen *HackScreen;
extern int havelace;
static unsigned short transpalette[ AMII_MAXCOLORS ] = { 0x0000, };
static struct NewWindow newwin =
{
0,0,640,200,1,0,
MOUSEBUTTONS|VANILLAKEY|NOCAREREFRESH,
BORDERLESS|ACTIVATE|SMART_REFRESH,
NULL,NULL,(UBYTE*)NULL,NULL,NULL,-1,-1,0xffff,0xffff,CUSTOMSCREEN
static unsigned short transpalette[AMII_MAXCOLORS] = {
0x0000,
};
static struct NewWindow newwin = { 0, 0, 640, 200, 1, 0,
MOUSEBUTTONS | VANILLAKEY | NOCAREREFRESH,
BORDERLESS | ACTIVATE | SMART_REFRESH,
NULL, NULL, (UBYTE *) NULL, NULL, NULL, -1,
-1, 0xffff, 0xffff, CUSTOMSCREEN };
int wh; /* was local in outrip, but needed for SCALE macro */
int cmap_white, cmap_black;
void
amii_outrip( tmpwin, how, when )
amii_outrip(tmpwin, how, when)
winid tmpwin;
int how;
time_t when;
@@ -110,72 +112,79 @@ time_t when;
struct IntuiMessage *imsg;
int i;
register char *dpx;
char buf[ 200 ];
char buf[200];
int line, tw, ww;
char *errstr = NULL;
long year;
if(!WINVERS_AMIV || HackScreen->RastPort.BitMap->Depth < 4)goto cleanup;
if (!WINVERS_AMIV || HackScreen->RastPort.BitMap->Depth < 4)
goto cleanup;
/* Use the users display size */
newwin.Height = amiIDisplay->ypix - newwin.TopEdge;
newwin.Width = amiIDisplay->xpix;
newwin.Screen = HackScreen;
for( i = 0; i < amii_numcolors; ++i )
sysflags.amii_curmap[i] = GetRGB4( HackScreen->ViewPort.ColorMap, i );
for (i = 0; i < amii_numcolors; ++i)
sysflags.amii_curmap[i] = GetRGB4(HackScreen->ViewPort.ColorMap, i);
ripwin = OpenWindow( (void *)&newwin );
if( !ripwin ) goto cleanup;
ripwin = OpenWindow((void *) &newwin);
if (!ripwin)
goto cleanup;
LoadRGB4( &HackScreen->ViewPort, transpalette, amii_numcolors );
LoadRGB4(&HackScreen->ViewPort, transpalette, amii_numcolors);
rp= ripwin->RPort;
rp = ripwin->RPort;
wh = ripwin->Height;
ww = ripwin->Width;
#ifdef HACKFONT
if (HackFont)
SetFont(rp, HackFont);
SetFont(rp, HackFont);
#endif
tomb_bmhd = ReadImageFiles(load_list, tbmp, &errstr );
if(errstr)goto cleanup;
if(tomb_bmhd.w > ww || tomb_bmhd.h > wh)goto cleanup;
tomb_bmhd = ReadImageFiles(load_list, tbmp, &errstr);
if (errstr)
goto cleanup;
if (tomb_bmhd.w > ww || tomb_bmhd.h > wh)
goto cleanup;
#define GENOFF(full,used) ((((full)-(used))/2) & ~7)
xoff = GENOFF(ww,tomb_bmhd.w);
yoff = GENOFF(wh,tomb_bmhd.h);
for(i=0;i<SIZE(cols);i++)cols[i]+=xoff;
#define GENOFF(full, used) ((((full) - (used)) / 2) & ~7)
xoff = GENOFF(ww, tomb_bmhd.w);
yoff = GENOFF(wh, tomb_bmhd.h);
for (i = 0; i < SIZE(cols); i++)
cols[i] += xoff;
cmap_white = search_cmap(0,0,0);
cmap_black = search_cmap(15,15,15);
cmap_white = search_cmap(0, 0, 0);
cmap_black = search_cmap(15, 15, 15);
BltBitMap(*tbmp, 0, 0, rp->BitMap, xoff, yoff, tomb_bmhd.w, tomb_bmhd.h, 0xc0, 0xff, NULL);
BltBitMap(*tbmp, 0, 0, rp->BitMap, xoff, yoff, tomb_bmhd.w, tomb_bmhd.h,
0xc0, 0xff, NULL);
/* Put together death description */
formatkiller(buf, sizeof buf, how);
tw = TextLength(rp,buf,STONE_LINE_LEN) + 40;
tw = TextLength(rp, buf, STONE_LINE_LEN) + 40;
{
char *p=buf;
int x, tmp;
for(x=STONE_LINE_LEN;x;x--)*p++='W';
*p='\0';
tmp = TextLength(rp,buf,STONE_LINE_LEN) + 40;
tw = max( tw, tmp);
char *p = buf;
int x, tmp;
for (x = STONE_LINE_LEN; x; x--)
*p++ = 'W';
*p = '\0';
tmp = TextLength(rp, buf, STONE_LINE_LEN) + 40;
tw = max(tw, tmp);
}
/* There are 5 lines of text on the stone. */
rtxth = ripwin->RPort->TxHeight * 5;
SetAfPt( rp, (UWORD *)NULL, 0 );
SetDrPt( rp, 0xFFFF );
SetAfPt(rp, (UWORD *) NULL, 0);
SetDrPt(rp, 0xFFFF);
tomb_line=TEXT_TOP;
tomb_line = TEXT_TOP;
SetDrMd(rp,JAM1);
SetDrMd(rp, JAM1);
/* Put name on stone */
Sprintf(buf, "%s", plname);
@@ -191,35 +200,29 @@ time_t when;
formatkiller(buf, sizeof buf, how);
/* Put death type on stone */
for (line=DEATH_LINE, dpx = buf; line<YEAR_LINE; line++)
{
register int i,i0;
char tmpchar;
for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
register int i, i0;
char tmpchar;
if ( (i0=strlen(dpx)) > STONE_LINE_LEN)
{
for(i=STONE_LINE_LEN;((i0 > STONE_LINE_LEN) && i); i--)
{
if(dpx[i] == ' ')
i0 = i;
}
if(!i)
i0 = STONE_LINE_LEN;
}
if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--) {
if (dpx[i] == ' ')
i0 = i;
}
if (!i)
i0 = STONE_LINE_LEN;
}
tmpchar = dpx[i0];
dpx[i0] = 0;
tomb_text(dpx);
tmpchar = dpx[i0];
dpx[i0] = 0;
tomb_text(dpx);
if (tmpchar != ' ')
{
dpx[i0] = tmpchar;
dpx= &dpx[i0];
}
else
{
dpx= &dpx[i0+1];
}
if (tmpchar != ' ') {
dpx[i0] = tmpchar;
dpx = &dpx[i0];
} else {
dpx = &dpx[i0 + 1];
}
}
/* Put year on stone */
@@ -230,7 +233,7 @@ time_t when;
#ifdef NH320_DEDICATION
/* dedication */
cno = 1;
tomb_line=TEXT_TOP;
tomb_line = TEXT_TOP;
tomb_text("This release");
tomb_text("of NetHack");
tomb_text("is dedicated");
@@ -245,131 +248,129 @@ time_t when;
tomb_text("Ascended");
#endif
/* Fade from black to full color */
dofade(0,16,1);
dofade(0, 16, 1);
/* Flush all messages to avoid typeahead */
while( imsg = (struct IntuiMessage *)GetMsg( ripwin->UserPort ) )
ReplyMsg( (struct Message *) imsg );
while (imsg = (struct IntuiMessage *) GetMsg(ripwin->UserPort))
ReplyMsg((struct Message *) imsg);
done = 0;
while( !done )
{
WaitPort( ripwin->UserPort );
while( imsg = (struct IntuiMessage *)GetMsg(ripwin->UserPort) )
{
switch( imsg->Class )
{
case MOUSEBUTTONS:
case VANILLAKEY:
done = 1;
break;
}
ReplyMsg( (struct Message *)imsg );
}
while (!done) {
WaitPort(ripwin->UserPort);
while (imsg = (struct IntuiMessage *) GetMsg(ripwin->UserPort)) {
switch (imsg->Class) {
case MOUSEBUTTONS:
case VANILLAKEY:
done = 1;
break;
}
ReplyMsg((struct Message *) imsg);
}
}
/* Fade out */
dofade(16,0,-1);
dofade(16, 0, -1);
just_return = 1;
cleanup:
/* free everything */
if(ripwin){
Forbid();
while( imsg = (struct IntuiMessage *)GetMsg( ripwin->UserPort ) )
ReplyMsg( (struct Message *)imsg );
CloseWindow( ripwin );
Permit();
/* free everything */
if (ripwin) {
Forbid();
while (imsg = (struct IntuiMessage *) GetMsg(ripwin->UserPort))
ReplyMsg((struct Message *) imsg);
CloseWindow(ripwin);
Permit();
}
LoadRGB4( &HackScreen->ViewPort, sysflags.amii_curmap, amii_numcolors );
LoadRGB4(&HackScreen->ViewPort, sysflags.amii_curmap, amii_numcolors);
if(tbmp[0])FreeImageFiles(load_list, tbmp);
if(just_return) return;
/* fall back to the straight-ASCII version */
if (tbmp[0])
FreeImageFiles(load_list, tbmp);
if (just_return)
return;
/* fall back to the straight-ASCII version */
genl_outrip(tmpwin, how, when);
}
static void tomb_text(p)
static void
tomb_text(p)
char *p;
{
char buf[STONE_LINE_LEN*2];
char buf[STONE_LINE_LEN * 2];
int l;
tomb_line += rp->TxHeight;
if( !*p )
return;
sprintf(buf," %s ",p);
l=TextLength(rp,buf,strlen(buf));
if (!*p)
return;
sprintf(buf, " %s ", p);
l = TextLength(rp, buf, strlen(buf));
SetAPen(rp,cmap_white);
Move(rp,cols[cno]-(l/2)-1, tomb_line);
Text(rp,buf,strlen(buf));
SetAPen(rp, cmap_white);
Move(rp, cols[cno] - (l / 2) - 1, tomb_line);
Text(rp, buf, strlen(buf));
SetAPen(rp,cmap_white);
Move(rp,cols[cno]-(l/2)+1, tomb_line);
Text(rp,buf,strlen(buf));
SetAPen(rp, cmap_white);
Move(rp, cols[cno] - (l / 2) + 1, tomb_line);
Text(rp, buf, strlen(buf));
SetAPen(rp,cmap_white);
Move(rp,cols[cno]-(l/2), tomb_line-1);
Text(rp,buf,strlen(buf));
SetAPen(rp, cmap_white);
Move(rp, cols[cno] - (l / 2), tomb_line - 1);
Text(rp, buf, strlen(buf));
SetAPen(rp,cmap_white);
Move(rp,cols[cno]-(l/2), tomb_line+1);
Text(rp,buf,strlen(buf));
SetAPen(rp, cmap_white);
Move(rp, cols[cno] - (l / 2), tomb_line + 1);
Text(rp, buf, strlen(buf));
SetAPen(rp,cmap_black);
Move(rp,cols[cno]-(l/2), tomb_line);
Text(rp,buf,strlen(buf));
SetAPen(rp, cmap_black);
Move(rp, cols[cno] - (l / 2), tomb_line);
Text(rp, buf, strlen(buf));
}
/* search colormap for best match to given color */
static int
search_cmap(int r0, int g0, int b0){
search_cmap(int r0, int g0, int b0)
{
int best = 0;
int bdiff = 0x0fffffff;
int x;
for(x=0;x<amii_numcolors; x++){
int r = r0- ((amiv_init_map[x] >> 8) & 15);
int g = g0-((amiv_init_map[x] >> 4) & 15);
int b = b0-((amiv_init_map[x] ) & 15);
int diff = (r*r) + (g*g) + (b*b);
if(diff<bdiff){
bdiff = diff;
best = x;
}
for (x = 0; x < amii_numcolors; x++) {
int r = r0 - ((amiv_init_map[x] >> 8) & 15);
int g = g0 - ((amiv_init_map[x] >> 4) & 15);
int b = b0 - ((amiv_init_map[x]) & 15);
int diff = (r * r) + (g * g) + (b * b);
if (diff < bdiff) {
bdiff = diff;
best = x;
}
}
return best;
}
/* caution: this is NOT general! */
static void
dofade(int start, int stop, int inc){
int i,j;
for( i = start; (i*inc) <= stop; i+=inc )
{
for( j = 0; j < amii_numcolors; ++j )
{
int r, g, b;
dofade(int start, int stop, int inc)
{
int i, j;
for (i = start; (i * inc) <= stop; i += inc) {
for (j = 0; j < amii_numcolors; ++j) {
int r, g, b;
r = ( amiv_init_map[ j ] & 0xf00 ) >> 8;
g = ( amiv_init_map[ j ] & 0xf0 ) >> 4;
b = ( amiv_init_map[ j ] & 0xf );
r = ( r * i ) / 16;
g = ( g * i ) / 16;
b = ( b * i ) / 16;
transpalette[ j ] = ((r<<8)|(g<<4)|b);
}
LoadRGB4( &HackScreen->ViewPort, transpalette, amii_numcolors );
Delay( 1 );
r = (amiv_init_map[j] & 0xf00) >> 8;
g = (amiv_init_map[j] & 0xf0) >> 4;
b = (amiv_init_map[j] & 0xf);
r = (r * i) / 16;
g = (g * i) / 16;
b = (b * i) / 16;
transpalette[j] = ((r << 8) | (g << 4) | b);
}
LoadRGB4(&HackScreen->ViewPort, transpalette, amii_numcolors);
Delay(1);
}
}
#endif /* AMII_GRAPHICS */
/*
TODO:
memory leaks
fix ReadImageFiles to return error instead of panic on error
memory leaks
fix ReadImageFiles to return error instead of panic on error
*/
+230 -195
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 amisnd.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 amisnd.c $NHDT-Date: 1431192784 2015/05/09 17:33:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 amisnd.c $Date: 2009/05/06 10:48:30 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)amisnd.c 3.5 2000/01/12*/
/* Copyright (c) 1992, 1993, 1995 by Gregg Wonderly */
@@ -33,254 +33,289 @@
#include <stdio.h>
#include <stdlib.h>
#define AMII_AVERAGE_VOLUME 60
#define AMII_AVERAGE_VOLUME 60
int amii_volume = AMII_AVERAGE_VOLUME;
typedef struct VHDR
{
char name[4];
long len;
unsigned long oneshot, repeat, samples;
UWORD freq;
UBYTE n_octaves, compress;
LONG volume;
typedef struct VHDR {
char name[4];
long len;
unsigned long oneshot, repeat, samples;
UWORD freq;
UBYTE n_octaves, compress;
LONG volume;
} VHDR;
typedef struct IFFHEAD
{
char FORM[4];
long flen;
char _8SVX[4];
VHDR vhdr;
char NAME[4];
long namelen;
typedef struct IFFHEAD {
char FORM[4];
long flen;
char _8SVX[4];
VHDR vhdr;
char NAME[4];
long namelen;
} IFFHEAD;
extern struct GfxBase *GfxBase;
UBYTE whichannel[] = { 1, 2, 4, 8 };
void makesound( char *, char *, int vol);
void amii_speaker( struct obj *instr, char *melody, int vol );
void makesound(char *, char *, int vol);
void amii_speaker(struct obj *instr, char *melody, int vol);
/* A major scale in indexs to freqtab... */
int notetab[] = { 0, 2, 4, 5, 7, 9, 11, 12 };
/* Frequencies for a scale starting at one octave below 'middle C' */
long freqtab[] = {
220, /*A */
233, /*Bb*/
246, /*B */
261, /*C */
277, /*Db*/
293, /*D */
311, /*Eb*/
329, /*E */
349, /*F */
370, /*Gb*/
392, /*G */
415, /*Ab*/
440, /*A */
220, /*A */
233, /*Bb*/
246, /*B */
261, /*C */
277, /*Db*/
293, /*D */
311, /*Eb*/
329, /*E */
349, /*F */
370, /*Gb*/
392, /*G */
415, /*Ab*/
440, /*A */
};
#ifdef TESTING
main( argc, argv )
int argc;
char **argv;
#ifdef TESTING
main(argc, argv) int argc;
char **argv;
{
makesound( "wooden_flute", "AwBwCwDwEwFwGwawbwcwdwewfwgw", 60 );
makesound( "wooden_flute", "AhBhChDhEhFhGhahbhchdhehfhgh", 60 );
makesound( "wooden_flute", "AqBqCqDqEqFqGqaqbqcqdqeqfqgq", 60 );
makesound( "wooden_flute", "AeBeCeDeEeFeGeaebecedeeefege", 60 );
makesound( "wooden_flute", "AxBxCxDxExFxGxaxbxcxdxexfxgx", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound( "wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60 );
makesound("wooden_flute", "AwBwCwDwEwFwGwawbwcwdwewfwgw", 60);
makesound("wooden_flute", "AhBhChDhEhFhGhahbhchdhehfhgh", 60);
makesound("wooden_flute", "AqBqCqDqEqFqGqaqbqcqdqeqfqgq", 60);
makesound("wooden_flute", "AeBeCeDeEeFeGeaebecedeeefege", 60);
makesound("wooden_flute", "AxBxCxDxExFxGxaxbxcxdxexfxgx", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
makesound("wooden_flute", "AtBtCtDtEtFtGtatbtctdtetftgt", 60);
}
#else
void
amii_speaker( struct obj *instr, char *melody, int vol )
amii_speaker(struct obj *instr, char *melody, int vol)
{
int typ = instr->otyp;
char * actualn = (char *)OBJ_NAME( objects[typ] ) ;
int typ = instr->otyp;
char *actualn = (char *) OBJ_NAME(objects[typ]);
/* Make volume be relative to users volume level, with 60 being the
* average level that will be passed to us.
*/
vol = vol * amii_volume / AMII_AVERAGE_VOLUME;
/* Make volume be relative to users volume level, with 60 being the
* average level that will be passed to us.
*/
vol = vol * amii_volume / AMII_AVERAGE_VOLUME;
makesound( actualn, melody, vol );
makesound(actualn, melody, vol);
}
#endif
void
makesound ( char *actualn , char * melody, int vol )
makesound(char *actualn, char *melody, int vol)
{
char *t;
int c, cycles, dot, dlay;
dlb *stream = 0;
IFFHEAD iffhead;
struct IOAudio *AudioIO = 0;
struct MsgPort *AudioMP = 0;
struct Message *AudioMSG = 0;
ULONG device = -1;
BYTE *waveptr = 0;
LONG frequency=440, duration=1, clock, samp, samples, samcyc=1;
unsigned char name [ 100 ] ;
char *t;
int c, cycles, dot, dlay;
dlb *stream = 0;
IFFHEAD iffhead;
struct IOAudio *AudioIO = 0;
struct MsgPort *AudioMP = 0;
struct Message *AudioMSG = 0;
ULONG device = -1;
BYTE *waveptr = 0;
LONG frequency = 440, duration = 1, clock, samp, samples, samcyc = 1;
unsigned char name[100];
if ( flags.silent )
return;
if (flags.silent)
return;
if( GfxBase->DisplayFlags & PAL )
clock = 3546895;
else
clock = 3579545;
if (GfxBase->DisplayFlags & PAL)
clock = 3546895;
else
clock = 3579545;
/*
* Convert type to file name - if there's nothing to play we
* shouldn't be here in the first place.
*/
strncpy(name, actualn,sizeof(name) ) ;
for( t = strchr( name, ' ' ); t; t = strchr( name, ' ' ) )
*t = '_';
if( (stream = dlb_fopen( name, "r" )) == NULL )
{
perror( name );
return;
}
/*
* Convert type to file name - if there's nothing to play we
* shouldn't be here in the first place.
*/
strncpy(name, actualn, sizeof(name));
for (t = strchr(name, ' '); t; t = strchr(name, ' '))
*t = '_';
if ((stream = dlb_fopen(name, "r")) == NULL) {
perror(name);
return;
}
AudioIO = (struct IOAudio *)
AllocMem( sizeof( struct IOAudio ), MEMF_PUBLIC|MEMF_CLEAR );
if( AudioIO == 0 )
goto killaudio;
AudioIO = (struct IOAudio *) AllocMem(sizeof(struct IOAudio),
MEMF_PUBLIC | MEMF_CLEAR);
if (AudioIO == 0)
goto killaudio;
AudioMP = CreateMsgPort();
if( AudioMP == 0 )
goto killaudio;
AudioMP = CreateMsgPort();
if (AudioMP == 0)
goto killaudio;
AudioIO->ioa_Request.io_Message.mn_ReplyPort = AudioMP;
AudioIO->ioa_Request.io_Message.mn_Node.ln_Pri = 0;
AudioIO->ioa_Request.io_Command = ADCMD_ALLOCATE;
AudioIO->ioa_Request.io_Flags = ADIOF_NOWAIT;
AudioIO->ioa_AllocKey = 0;
AudioIO->ioa_Data = whichannel;
AudioIO->ioa_Length = sizeof( whichannel );
AudioIO->ioa_Request.io_Message.mn_ReplyPort = AudioMP;
AudioIO->ioa_Request.io_Message.mn_Node.ln_Pri = 0;
AudioIO->ioa_Request.io_Command = ADCMD_ALLOCATE;
AudioIO->ioa_Request.io_Flags = ADIOF_NOWAIT;
AudioIO->ioa_AllocKey = 0;
AudioIO->ioa_Data = whichannel;
AudioIO->ioa_Length = sizeof(whichannel);
device = OpenDevice( AUDIONAME, 0L, (struct IORequest *)AudioIO, 0L );
if( device != 0 )
goto killaudio;
device = OpenDevice(AUDIONAME, 0L, (struct IORequest *) AudioIO, 0L);
if (device != 0)
goto killaudio;
if( dlb_fread( (genericptr_t)&iffhead, sizeof( iffhead ), 1, stream ) != 1 )
goto killaudio;
if (dlb_fread((genericptr_t) &iffhead, sizeof(iffhead), 1, stream) != 1)
goto killaudio;
/* This is an even number of bytes long */
if( dlb_fread( name, (iffhead.namelen+1) & ~1, 1, stream ) != 1 )
goto killaudio;
/* This is an even number of bytes long */
if (dlb_fread(name, (iffhead.namelen + 1) & ~1, 1, stream) != 1)
goto killaudio;
if( dlb_fread( (genericptr_t)&samples, 4, 1, stream ) != 1 )
goto killaudio;
if (dlb_fread((genericptr_t) &samples, 4, 1, stream) != 1)
goto killaudio;
if( dlb_fread( (genericptr_t)&samples, 4, 1, stream ) != 1 )
goto killaudio;
if (dlb_fread((genericptr_t) &samples, 4, 1, stream) != 1)
goto killaudio;
waveptr = AllocMem( samples, MEMF_CHIP|MEMF_PUBLIC );
if( !waveptr )
goto killaudio;
waveptr = AllocMem(samples, MEMF_CHIP | MEMF_PUBLIC);
if (!waveptr)
goto killaudio;
if( dlb_fread( waveptr, samples, 1, stream ) != 1 )
goto killaudio;
if (dlb_fread(waveptr, samples, 1, stream) != 1)
goto killaudio;
while( melody[0] && melody[1] )
{
c = *melody++;
duration = *melody++;
dot = 0;
if( *melody == '.' )
{
dot = 1;
++melody;
}
switch( duration )
{
case 'w': dlay = 3; duration = 1; cycles = 1; break;
case 'h': dlay = 3; duration = 2; cycles = 1; break;
case 'q': dlay = 2; duration = 4; cycles = 1; break;
case 'e': dlay = 1; duration = 8; cycles = 1; break;
case 'x': dlay = 0; duration = 16; cycles = 1; break;
case 't': dlay = 0; duration = 32; cycles = 1; break;
default: goto killaudio; /* unrecognized duration */
}
while (melody[0] && melody[1]) {
c = *melody++;
duration = *melody++;
dot = 0;
if (*melody == '.') {
dot = 1;
++melody;
}
switch (duration) {
case 'w':
dlay = 3;
duration = 1;
cycles = 1;
break;
case 'h':
dlay = 3;
duration = 2;
cycles = 1;
break;
case 'q':
dlay = 2;
duration = 4;
cycles = 1;
break;
case 'e':
dlay = 1;
duration = 8;
cycles = 1;
break;
case 'x':
dlay = 0;
duration = 16;
cycles = 1;
break;
case 't':
dlay = 0;
duration = 32;
cycles = 1;
break;
default:
goto killaudio; /* unrecognized duration */
}
/* Lower case characters are one octave above upper case */
switch( c )
{
case 'a': case 'b': case 'c':
case 'd': case 'e': case 'f': case 'g':
c -= 'a' - 7;
break;
/* Lower case characters are one octave above upper case */
switch (c) {
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
c -= 'a' - 7;
break;
case 'A': case 'B': case 'C':
case 'D': case 'E': case 'F': case 'G':
c -= 'A';
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
c -= 'A';
break;
default:
continue;
}
default:
continue;
}
samcyc = samples;
samcyc = samples;
/* lowercase start at middle 'C', upper case are one octave below */
frequency = c > 7 ? freqtab[notetab[c%7]]*2 : freqtab[notetab[c]];
/* lowercase start at middle 'C', upper case are one octave below */
frequency = c > 7 ? freqtab[notetab[c % 7]] * 2 : freqtab[notetab[c]];
/* We can't actually do a dotted whole note unless we add code for a real
* 8SVX sample which includes sustain sample information to tell us how
* to hold the note steady... So when duration == 1, ignore 'dot'...
*/
if( dot && duration > 1 )
samp = ((samples / duration) * 3) / 2;
else
samp = samples / duration;
/* We can't actually do a dotted whole note unless we add code for a
* real
* 8SVX sample which includes sustain sample information to tell us
* how
* to hold the note steady... So when duration == 1, ignore 'dot'...
*/
if (dot && duration > 1)
samp = ((samples / duration) * 3) / 2;
else
samp = samples / duration;
/* Only use some of the samples based on frequency */
samp = frequency * samp / 880;
/* Only use some of the samples based on frequency */
samp = frequency * samp / 880;
/* The 22khz samples are middle C samples, so adjust the play
* back frequency accordingly
*/
frequency = (frequency * (iffhead.vhdr.freq*2)/3) / 440L;
/* The 22khz samples are middle C samples, so adjust the play
* back frequency accordingly
*/
frequency = (frequency * (iffhead.vhdr.freq * 2) / 3) / 440L;
AudioIO->ioa_Request.io_Message.mn_ReplyPort = AudioMP;
AudioIO->ioa_Request.io_Command = CMD_WRITE;
AudioIO->ioa_Request.io_Flags = ADIOF_PERVOL;
AudioIO->ioa_Data = (BYTE *)waveptr;
AudioIO->ioa_Length = samp;
AudioIO->ioa_Request.io_Message.mn_ReplyPort = AudioMP;
AudioIO->ioa_Request.io_Command = CMD_WRITE;
AudioIO->ioa_Request.io_Flags = ADIOF_PERVOL;
AudioIO->ioa_Data = (BYTE *) waveptr;
AudioIO->ioa_Length = samp;
/* The clock rate represents the unity rate, so dividing by
* the frequency gives us a period ratio...
*/
/*printf( "clock: %ld, freq: %ld, div: %ld\n", clock, frequency, clock/frequency );*/
AudioIO->ioa_Period = clock/frequency;
AudioIO->ioa_Volume = vol;
AudioIO->ioa_Cycles = cycles;
/* The clock rate represents the unity rate, so dividing by
* the frequency gives us a period ratio...
*/
/*printf( "clock: %ld, freq: %ld, div: %ld\n", clock, frequency,
* clock/frequency );*/
AudioIO->ioa_Period = clock / frequency;
AudioIO->ioa_Volume = vol;
AudioIO->ioa_Cycles = cycles;
BeginIO( (struct IORequest *)AudioIO );
WaitPort( AudioMP );
AudioMSG = GetMsg( AudioMP );
if( dlay )
Delay( dlay );
}
BeginIO((struct IORequest *) AudioIO);
WaitPort(AudioMP);
AudioMSG = GetMsg(AudioMP);
if (dlay)
Delay(dlay);
}
killaudio:
if( stream ) dlb_fclose( stream );
if( waveptr ) FreeMem( waveptr, samples );
if( device == 0 ) CloseDevice( (struct IORequest *)AudioIO );
if( AudioMP ) DeleteMsgPort( AudioMP );
if( AudioIO ) FreeMem( AudioIO, sizeof( *AudioIO ) );
killaudio:
if (stream)
dlb_fclose(stream);
if (waveptr)
FreeMem(waveptr, samples);
if (device == 0)
CloseDevice((struct IORequest *) AudioIO);
if (AudioMP)
DeleteMsgPort(AudioMP);
if (AudioIO)
FreeMem(AudioIO, sizeof(*AudioIO));
}
+3 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 amistack.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 amistack.c $NHDT-Date: 1431192783 2015/05/09 17:33:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
/* NetHack 3.6 amistack.c $Date: 2009/05/06 10:48:30 $ $Revision: 1.4 $ */
/* SCCS Id: @(#)amistack.c 3.5 2000/05/03 */
/* Copyright (c) Janne Salmijärvi, Tampere, Finland, 2000 */
@@ -6,7 +6,7 @@
/*
* Increase stack size to allow deep recursions.
*
*
* Note: This is SAS/C specific, using other compiler probably
* requires another method for increasing stack.
*
@@ -19,5 +19,5 @@
* At the moment 90*1024 would suffice, but just to be on the safe side ...
*/
long __stack = 128*1024;
long __stack = 128 * 1024;
#endif
+49 -32
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 amitty.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 amitty.c $NHDT-Date: 1431192784 2015/05/09 17:33:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 amitty.c $Date: 2009/05/06 10:48:30 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)amitty.c 3.5 2000/01/12
/* Copyright (c) Kenneth Lorber, Bethesda, Maryland 1993,1996 */
@@ -16,54 +16,71 @@
#include <proto/dos.h>
#ifdef _DCC
# define getch() getchar()
#define getch() getchar()
#endif
#ifdef __SASC_60
# include <clib/dos_protos.h>
#include <clib/dos_protos.h>
#endif
void NDECL( tty_change_color );
char *NDECL( tty_get_color_string );
void NDECL(tty_change_color);
char *NDECL(tty_get_color_string);
#ifdef TTY_GRAPHICS
int amibbs=0; /* BBS mode */
char bbs_id[80]=""; /* BBS uid equivalent */
long afh_in, afh_out; /* BBS mode Amiga filehandles */
int amibbs = 0; /* BBS mode */
char bbs_id[80] = ""; /* BBS uid equivalent */
long afh_in, afh_out; /* BBS mode Amiga filehandles */
void settty(const char *s){
end_screen();
if(s)raw_print(s);
iflags.cbreak=ON; /* this is too easy: probably wrong */
#if 1 /* should be version>=36 */
/* if(IsInteractive(afh_in)){ */
SetMode(afh_in,0); /* con mode */
void
settty(const char *s)
{
end_screen();
if (s)
raw_print(s);
iflags.cbreak = ON; /* this is too easy: probably wrong */
#if 1 /* should be version>=36 */
/* if(IsInteractive(afh_in)){ */
SetMode(afh_in, 0); /* con mode */
/* } */
#endif
}
void gettty(){
#if 1 /* should be VERSION >=36 */
/* if(IsInteractive(afh_in)){ */
SetMode(afh_in,1); /* raw mode */
void
gettty()
{
#if 1 /* should be VERSION >=36 */
/* if(IsInteractive(afh_in)){ */
SetMode(afh_in, 1); /* raw mode */
/* } */
#endif
}
void setftty(){
iflags.cbreak=ON; /* ditto */
void
setftty()
{
iflags.cbreak = ON; /* ditto */
}
char kill_char='X'-'@';
char erase_char='\b';
tgetch(){
char x;
Read(afh_in,&x,1);
return (x=='\r')?'\n':x;
char kill_char = 'X' - '@';
char erase_char = '\b';
tgetch()
{
char x;
Read(afh_in, &x, 1);
return (x == '\r') ? '\n' : x;
}
void get_scr_size(){
CO=80;
LI=24;
void
get_scr_size()
{
CO = 80;
LI = 24;
}
#endif
void tty_change_color() {}
char *tty_get_color_string() { return( "" ); }
void
tty_change_color()
{
}
char *
tty_get_color_string()
{
return ("");
}
+479 -528
View File
File diff suppressed because it is too large Load Diff
+180 -190
View File
@@ -1,268 +1,258 @@
static USHORT Palette[] = {
0x0AAA, /* color #0 */
0x0000, /* color #1 */
0x0FFF, /* color #2 */
0x058B, /* color #3 */
0x000F, /* color #4 */
0x0F0F, /* color #5 */
0x00FF, /* color #6 */
0x0FFF /* color #7 */
0x0AAA, /* color #0 */
0x0000, /* color #1 */
0x0FFF, /* color #2 */
0x058B, /* color #3 */
0x000F, /* color #4 */
0x0F0F, /* color #5 */
0x00FF, /* color #6 */
0x0FFF /* color #7 */
#define PaletteColorCount 8
};
#define PALETTE Palette
static SHORT ClipBorderVectors1[] = {
0,0,
76,0,
76,11,
0,11,
0,0
};
static SHORT ClipBorderVectors1[] = { 0, 0, 76, 0, 76, 11, 0, 11, 0, 0 };
static struct Border ClipBorder1 = {
-1,-1, /* XY origin relative to container TopLeft */
3,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
ClipBorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
-1, -1, /* XY origin relative to container TopLeft */
3, 0, JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
ClipBorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
};
static struct IntuiText ClipIText1 = {
4,0,JAM1, /* front and back text pens, drawmode and fill byte */
15,1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Cancel", /* pointer to text */
NULL /* next IntuiText structure */
4, 0, JAM1, /* front and back text pens, drawmode and fill byte */
15, 1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Cancel", /* pointer to text */
NULL /* next IntuiText structure */
};
static struct Gadget ClipCancel = {
NULL, /* next gadget */
240,59, /* origin XY of hit box relative to window TopLeft */
75,10, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&ClipBorder1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText1, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADCANCEL, /* user-definable data */
NULL /* pointer to user-definable data */
NULL, /* next gadget */
240, 59, /* origin XY of hit box relative to window TopLeft */
75, 10, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR) &ClipBorder1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText1, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADCANCEL, /* user-definable data */
NULL /* pointer to user-definable data */
};
static SHORT ClipBorderVectors2[] = {
0,0,
78,0,
78,11,
0,11,
0,0
};
static SHORT ClipBorderVectors2[] = { 0, 0, 78, 0, 78, 11, 0, 11, 0, 0 };
static struct Border ClipBorder2 = {
-1,-1, /* XY origin relative to container TopLeft */
3,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
ClipBorderVectors2, /* pointer to XY vectors */
NULL /* next border in list */
-1, -1, /* XY origin relative to container TopLeft */
3, 0, JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
ClipBorderVectors2, /* pointer to XY vectors */
NULL /* next border in list */
};
static struct IntuiText ClipIText2 = {
4,0,JAM1, /* front and back text pens, drawmode and fill byte */
24,1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Okay", /* pointer to text */
NULL /* next IntuiText structure */
4, 0, JAM1, /* front and back text pens, drawmode and fill byte */
24, 1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Okay", /* pointer to text */
NULL /* next IntuiText structure */
};
static struct Gadget ClipOkay = {
&ClipCancel, /* next gadget */
17,60, /* origin XY of hit box relative to window TopLeft */
77,10, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&ClipBorder2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText2, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADOKAY, /* user-definable data */
NULL /* pointer to user-definable data */
&ClipCancel, /* next gadget */
17, 60, /* origin XY of hit box relative to window TopLeft */
77, 10, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR) &ClipBorder2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText2, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADOKAY, /* user-definable data */
NULL /* pointer to user-definable data */
};
static struct PropInfo ClipClipXCLIPSInfo = {
AUTOKNOB+FREEHORIZ, /* PropInfo flags */
24504,-1, /* horizontal and vertical pot values */
10922,-1, /* horizontal and vertical body values */
AUTOKNOB + FREEHORIZ, /* PropInfo flags */
24504, -1, /* horizontal and vertical pot values */
10922, -1, /* horizontal and vertical body values */
};
static struct Image ClipImage1 = {
43,0, /* XY origin relative to container TopLeft */
24,3, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000,0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
43, 0, /* XY origin relative to container TopLeft */
24, 3, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000, 0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
};
static struct IntuiText ClipIText3 = {
3,0,JAM1, /* front and back text pens, drawmode and fill byte */
-116,-1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"X Clip Border:", /* pointer to text */
NULL /* next IntuiText structure */
3, 0, JAM1, /* front and back text pens, drawmode and fill byte */
-116, -1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"X Clip Border:", /* pointer to text */
NULL /* next IntuiText structure */
};
static struct Gadget ClipXCLIP = {
&ClipOkay, /* next gadget */
134,37, /* origin XY of hit box relative to window TopLeft */
-199,7, /* hit box width and height */
GRELWIDTH, /* gadget flags */
RELVERIFY+GADGIMMEDIATE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR)&ClipImage1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText3, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&ClipClipXCLIPSInfo, /* SpecialInfo structure */
XCLIP, /* user-definable data */
NULL /* pointer to user-definable data */
&ClipOkay, /* next gadget */
134, 37, /* origin XY of hit box relative to window TopLeft */
-199, 7, /* hit box width and height */
GRELWIDTH, /* gadget flags */
RELVERIFY + GADGIMMEDIATE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR) &ClipImage1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText3, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR) &ClipClipXCLIPSInfo, /* SpecialInfo structure */
XCLIP, /* user-definable data */
NULL /* pointer to user-definable data */
};
static struct PropInfo ClipClipYCLIPSInfo = {
AUTOKNOB+FREEHORIZ, /* PropInfo flags */
13106,-1, /* horizontal and vertical pot values */
10922,-1, /* horizontal and vertical body values */
AUTOKNOB + FREEHORIZ, /* PropInfo flags */
13106, -1, /* horizontal and vertical pot values */
10922, -1, /* horizontal and vertical body values */
};
static struct Image ClipImage2 = {
22,0, /* XY origin relative to container TopLeft */
24,3, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000,0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
22, 0, /* XY origin relative to container TopLeft */
24, 3, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000, 0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
};
static struct IntuiText ClipIText4 = {
3,0,JAM1, /* front and back text pens, drawmode and fill byte */
-116,-1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Y Clip Border:", /* pointer to text */
NULL /* next IntuiText structure */
3, 0, JAM1, /* front and back text pens, drawmode and fill byte */
-116, -1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Y Clip Border:", /* pointer to text */
NULL /* next IntuiText structure */
};
static struct Gadget ClipYCLIP = {
&ClipXCLIP, /* next gadget */
134,46, /* origin XY of hit box relative to window TopLeft */
-199,7, /* hit box width and height */
GRELWIDTH, /* gadget flags */
RELVERIFY+GADGIMMEDIATE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR)&ClipImage2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText4, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&ClipClipYCLIPSInfo, /* SpecialInfo structure */
YCLIP, /* user-definable data */
NULL /* pointer to user-definable data */
&ClipXCLIP, /* next gadget */
134, 46, /* origin XY of hit box relative to window TopLeft */
-199, 7, /* hit box width and height */
GRELWIDTH, /* gadget flags */
RELVERIFY + GADGIMMEDIATE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR) &ClipImage2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText4, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR) &ClipClipYCLIPSInfo, /* SpecialInfo structure */
YCLIP, /* user-definable data */
NULL /* pointer to user-definable data */
};
static struct PropInfo ClipClipXSIZESInfo = {
AUTOKNOB+FREEHORIZ, /* PropInfo flags */
26212,-1, /* horizontal and vertical pot values */
10922,-1, /* horizontal and vertical body values */
AUTOKNOB + FREEHORIZ, /* PropInfo flags */
26212, -1, /* horizontal and vertical pot values */
10922, -1, /* horizontal and vertical body values */
};
static struct Image ClipImage3 = {
45,0, /* XY origin relative to container TopLeft */
24,3, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000,0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
45, 0, /* XY origin relative to container TopLeft */
24, 3, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000, 0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
};
static struct IntuiText ClipIText5 = {
3,0,JAM1, /* front and back text pens, drawmode and fill byte */
-124,-1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"X Scale Factor:", /* pointer to text */
NULL /* next IntuiText structure */
3, 0, JAM1, /* front and back text pens, drawmode and fill byte */
-124, -1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"X Scale Factor:", /* pointer to text */
NULL /* next IntuiText structure */
};
static struct Gadget ClipXSIZE = {
&ClipYCLIP, /* next gadget */
134,15, /* origin XY of hit box relative to window TopLeft */
-199,7, /* hit box width and height */
GRELWIDTH, /* gadget flags */
RELVERIFY+GADGIMMEDIATE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR)&ClipImage3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText5, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&ClipClipXSIZESInfo, /* SpecialInfo structure */
XSIZE, /* user-definable data */
NULL /* pointer to user-definable data */
&ClipYCLIP, /* next gadget */
134, 15, /* origin XY of hit box relative to window TopLeft */
-199, 7, /* hit box width and height */
GRELWIDTH, /* gadget flags */
RELVERIFY + GADGIMMEDIATE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR) &ClipImage3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText5, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR) &ClipClipXSIZESInfo, /* SpecialInfo structure */
XSIZE, /* user-definable data */
NULL /* pointer to user-definable data */
};
static struct PropInfo ClipClipYSIZESInfo = {
AUTOKNOB+FREEHORIZ, /* PropInfo flags */
-25937,-1, /* horizontal and vertical pot values */
10922,-1, /* horizontal and vertical body values */
AUTOKNOB + FREEHORIZ, /* PropInfo flags */
-25937, -1, /* horizontal and vertical pot values */
10922, -1, /* horizontal and vertical body values */
};
static struct Image ClipImage4 = {
69,0, /* XY origin relative to container TopLeft */
24,3, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000,0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
69, 0, /* XY origin relative to container TopLeft */
24, 3, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000, 0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
};
static struct IntuiText ClipIText6 = {
3,0,JAM1, /* front and back text pens, drawmode and fill byte */
-124,-1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Y Scale Factor:", /* pointer to text */
NULL /* next IntuiText structure */
3, 0, JAM1, /* front and back text pens, drawmode and fill byte */
-124, -1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Y Scale Factor:", /* pointer to text */
NULL /* next IntuiText structure */
};
static struct Gadget ClipYSIZE = {
&ClipXSIZE, /* next gadget */
134,24, /* origin XY of hit box relative to window TopLeft */
-199,7, /* hit box width and height */
GRELWIDTH, /* gadget flags */
RELVERIFY+GADGIMMEDIATE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR)&ClipImage4, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText6, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&ClipClipYSIZESInfo, /* SpecialInfo structure */
YSIZE, /* user-definable data */
NULL /* pointer to user-definable data */
&ClipXSIZE, /* next gadget */
134, 24, /* origin XY of hit box relative to window TopLeft */
-199, 7, /* hit box width and height */
GRELWIDTH, /* gadget flags */
RELVERIFY + GADGIMMEDIATE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR) &ClipImage4, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&ClipIText6, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR) &ClipClipYSIZESInfo, /* SpecialInfo structure */
YSIZE, /* user-definable data */
NULL /* pointer to user-definable data */
};
#define ClipGadgetList1 ClipYSIZE
static struct NewWindow ClipNewWindowStructure1 = {
114,16, /* window XY origin relative to TopLeft of screen */
346,76, /* window width and height */
0,1, /* detail and block pens */
NEWSIZE+MOUSEMOVE+GADGETDOWN+GADGETUP+CLOSEWINDOW+ACTIVEWINDOW+VANILLAKEY+INTUITICKS, /* IDCMP flags */
WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH, /* other window flags */
&ClipYSIZE, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Edit Clipping Parameters", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
350,76, /* minimum width and height */
-1,-1, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
114, 16, /* window XY origin relative to TopLeft of screen */
346, 76, /* window width and height */
0, 1, /* detail and block pens */
NEWSIZE + MOUSEMOVE + GADGETDOWN + GADGETUP + CLOSEWINDOW + ACTIVEWINDOW
+ VANILLAKEY + INTUITICKS, /* IDCMP flags */
WINDOWSIZING + WINDOWDRAG + WINDOWDEPTH + WINDOWCLOSE + ACTIVATE
+ NOCAREREFRESH, /* other window flags */
&ClipYSIZE, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Edit Clipping Parameters", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
350,
76, /* minimum width and height */
-1, -1, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
/* end of PowerWindows source generation */
+171 -185
View File
@@ -1,256 +1,242 @@
SHORT Col_BorderVectors1[] = {
0,0,
59,0,
59,12,
0,12,
0,0
};
SHORT Col_BorderVectors1[] = { 0, 0, 59, 0, 59, 12, 0, 12, 0, 0 };
struct Border Col_Border1 = {
-1,-1, /* XY origin relative to container TopLeft */
3,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
Col_BorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
-1, -1, /* XY origin relative to container TopLeft */
3, 0, JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
Col_BorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText Col_IText1 = {
7,0,JAM1, /* front and back text pens, drawmode and fill byte */
13,1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Save", /* pointer to text */
NULL /* next IntuiText structure */
7, 0, JAM1, /* front and back text pens, drawmode and fill byte */
13, 1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Save", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget Col_Save = {
NULL, /* next gadget */
9,77, /* origin XY of hit box relative to window TopLeft */
58,11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&Col_Border1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&Col_IText1, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADCOLSAVE, /* user-definable data */
NULL /* pointer to user-definable data */
NULL, /* next gadget */
9, 77, /* origin XY of hit box relative to window TopLeft */
58, 11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR) &Col_Border1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&Col_IText1, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADCOLSAVE, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT Col_BorderVectors2[] = {
0,0,
59,0,
59,12,
0,12,
0,0
};
SHORT Col_BorderVectors2[] = { 0, 0, 59, 0, 59, 12, 0, 12, 0, 0 };
struct Border Col_Border2 = {
-1,-1, /* XY origin relative to container TopLeft */
3,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
Col_BorderVectors2, /* pointer to XY vectors */
NULL /* next border in list */
-1, -1, /* XY origin relative to container TopLeft */
3, 0, JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
Col_BorderVectors2, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText Col_IText2 = {
7,0,JAM1, /* front and back text pens, drawmode and fill byte */
17,1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Use", /* pointer to text */
NULL /* next IntuiText structure */
7, 0, JAM1, /* front and back text pens, drawmode and fill byte */
17, 1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Use", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget Col_Okay = {
&Col_Save, /* next gadget */
128,77, /* origin XY of hit box relative to window TopLeft */
58,11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&Col_Border2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&Col_IText2, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADCOLOKAY, /* user-definable data */
NULL /* pointer to user-definable data */
&Col_Save, /* next gadget */
128, 77, /* origin XY of hit box relative to window TopLeft */
58, 11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR) &Col_Border2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&Col_IText2, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADCOLOKAY, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT Col_BorderVectors3[] = {
0,0,
59,0,
59,12,
0,12,
0,0
};
SHORT Col_BorderVectors3[] = { 0, 0, 59, 0, 59, 12, 0, 12, 0, 0 };
struct Border Col_Border3 = {
-1,-1, /* XY origin relative to container TopLeft */
3,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
Col_BorderVectors3, /* pointer to XY vectors */
NULL /* next border in list */
-1, -1, /* XY origin relative to container TopLeft */
3, 0, JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
Col_BorderVectors3, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText Col_IText3 = {
7,0,JAM1, /* front and back text pens, drawmode and fill byte */
6,1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Cancel", /* pointer to text */
NULL /* next IntuiText structure */
7, 0, JAM1, /* front and back text pens, drawmode and fill byte */
6, 1, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Cancel", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget Col_Cancel = {
&Col_Okay, /* next gadget */
244,77, /* origin XY of hit box relative to window TopLeft */
58,11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&Col_Border3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&Col_IText3, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADCOLCANCEL, /* user-definable data */
NULL /* pointer to user-definable data */
&Col_Okay, /* next gadget */
244, 77, /* origin XY of hit box relative to window TopLeft */
58, 11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR) &Col_Border3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&Col_IText3, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
GADCOLCANCEL, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct PropInfo Col_Col_RedPenSInfo = {
AUTOKNOB+FREEHORIZ, /* PropInfo flags */
0,0, /* horizontal and vertical pot values */
-1,-1, /* horizontal and vertical body values */
AUTOKNOB + FREEHORIZ, /* PropInfo flags */
0, 0, /* horizontal and vertical pot values */
-1, -1, /* horizontal and vertical body values */
};
struct Image Col_Image1 = {
0,0, /* XY origin relative to container TopLeft */
263,7, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000,0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
0, 0, /* XY origin relative to container TopLeft */
263, 7, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000, 0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
};
struct Gadget Col_RedPen = {
&Col_Cancel, /* next gadget */
32,12, /* origin XY of hit box relative to window TopLeft */
271,11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY+GADGIMMEDIATE+FOLLOWMOUSE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR)&Col_Image1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Col_Col_RedPenSInfo, /* SpecialInfo structure */
GADREDPEN, /* user-definable data */
NULL /* pointer to user-definable data */
&Col_Cancel, /* next gadget */
32, 12, /* origin XY of hit box relative to window TopLeft */
271, 11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY + GADGIMMEDIATE + FOLLOWMOUSE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR) &Col_Image1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR) &Col_Col_RedPenSInfo, /* SpecialInfo structure */
GADREDPEN, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct PropInfo Col_Col_GreenPenSInfo = {
AUTOKNOB+FREEHORIZ, /* PropInfo flags */
0,0, /* horizontal and vertical pot values */
-1,-1, /* horizontal and vertical body values */
AUTOKNOB + FREEHORIZ, /* PropInfo flags */
0, 0, /* horizontal and vertical pot values */
-1, -1, /* horizontal and vertical body values */
};
struct Image Col_Image2 = {
0,0, /* XY origin relative to container TopLeft */
263,7, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000,0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
0, 0, /* XY origin relative to container TopLeft */
263, 7, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000, 0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
};
struct Gadget Col_GreenPen = {
&Col_RedPen, /* next gadget */
32,24, /* origin XY of hit box relative to window TopLeft */
271,11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY+GADGIMMEDIATE+FOLLOWMOUSE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR)&Col_Image2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Col_Col_GreenPenSInfo, /* SpecialInfo structure */
GADGREENPEN, /* user-definable data */
NULL /* pointer to user-definable data */
&Col_RedPen, /* next gadget */
32, 24, /* origin XY of hit box relative to window TopLeft */
271, 11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY + GADGIMMEDIATE + FOLLOWMOUSE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR) &Col_Image2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR) &Col_Col_GreenPenSInfo, /* SpecialInfo structure */
GADGREENPEN, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct PropInfo Col_Col_BluePenSInfo = {
AUTOKNOB+FREEHORIZ, /* PropInfo flags */
0,0, /* horizontal and vertical pot values */
-1,-1, /* horizontal and vertical body values */
AUTOKNOB + FREEHORIZ, /* PropInfo flags */
0, 0, /* horizontal and vertical pot values */
-1, -1, /* horizontal and vertical body values */
};
struct Image Col_Image3 = {
0,0, /* XY origin relative to container TopLeft */
263,7, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000,0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
0, 0, /* XY origin relative to container TopLeft */
263, 7, /* Image width and height in pixels */
0, /* number of bitplanes in Image */
NULL, /* pointer to ImageData */
0x0000, 0x0000, /* PlanePick and PlaneOnOff */
NULL /* next Image structure */
};
struct Gadget Col_BluePen = {
&Col_GreenPen, /* next gadget */
32,36, /* origin XY of hit box relative to window TopLeft */
271,11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY+GADGIMMEDIATE+FOLLOWMOUSE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR)&Col_Image3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Col_Col_BluePenSInfo, /* SpecialInfo structure */
GADBLUEPEN, /* user-definable data */
NULL /* pointer to user-definable data */
&Col_GreenPen, /* next gadget */
32, 36, /* origin XY of hit box relative to window TopLeft */
271, 11, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY + GADGIMMEDIATE + FOLLOWMOUSE, /* activation flags */
PROPGADGET, /* gadget type flags */
(APTR) &Col_Image3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR) &Col_Col_BluePenSInfo, /* SpecialInfo structure */
GADBLUEPEN, /* user-definable data */
NULL /* pointer to user-definable data */
};
#define Col_GadgetList1 Col_BluePen
struct IntuiText Col_IText6 = {
3,0,JAM1, /* front and back text pens, drawmode and fill byte */
17,38, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"B", /* pointer to text */
NULL /* next IntuiText structure */
3, 0, JAM1, /* front and back text pens, drawmode and fill byte */
17, 38, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"B", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText Col_IText5 = {
4,0,JAM1, /* front and back text pens, drawmode and fill byte */
16,26, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"G", /* pointer to text */
&Col_IText6 /* next IntuiText structure */
4, 0,
JAM1, /* front and back text pens, drawmode and fill byte */
16, 26, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"G", /* pointer to text */
&Col_IText6 /* next IntuiText structure */
};
struct IntuiText Col_IText4 = {
7,0,JAM1, /* front and back text pens, drawmode and fill byte */
16,14, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"R", /* pointer to text */
&Col_IText5 /* next IntuiText structure */
7, 0,
JAM1, /* front and back text pens, drawmode and fill byte */
16, 14, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"R", /* pointer to text */
&Col_IText5 /* next IntuiText structure */
};
#define Col_IntuiTextList1 Col_IText4
struct NewWindow Col_NewWindowStructure1 = {
175,45, /* window XY origin relative to TopLeft of screen */
312,93, /* window width and height */
0,1, /* detail and block pens */
MOUSEBUTTONS+MOUSEMOVE+GADGETDOWN+GADGETUP+CLOSEWINDOW+VANILLAKEY+INTUITICKS, /* IDCMP flags */
WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH, /* other window flags */
&Col_BluePen, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Edit Screen Colors", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
-1,-1, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
175, 45, /* window XY origin relative to TopLeft of screen */
312, 93, /* window width and height */
0, 1, /* detail and block pens */
MOUSEBUTTONS + MOUSEMOVE + GADGETDOWN + GADGETUP + CLOSEWINDOW
+ VANILLAKEY + INTUITICKS, /* IDCMP flags */
WINDOWDRAG + WINDOWDEPTH + WINDOWCLOSE + ACTIVATE
+ NOCAREREFRESH, /* other window flags */
&Col_BluePen, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Edit Screen Colors", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,
5, /* minimum width and height */
-1, -1, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
/* end of PowerWindows source generation */
+36 -35
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 cvtsnd.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 cvtsnd.c $NHDT-Date: 1431192783 2015/05/09 17:33:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 cvtsnd.c $Date: 2009/05/06 10:48:31 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)cvtsnd.c 3.5 1995/09/10 */
/* Copyright (c) 1995, Andrew Church, Olney, Maryland */
@@ -11,7 +11,7 @@
typedef struct {
short namelen;
char name[62];
char misc[64]; /* rest of MacBinary header */
char misc[64]; /* rest of MacBinary header */
long FORM;
long flen;
long AIFF;
@@ -26,19 +26,18 @@ typedef struct {
char VHDR[4];
long vhlen;
long oneshot, repeat;
long samples; /* 'samplesPerHiCycle' in the docs - usually 32, so
* we'll use that */
long samples; /* 'samplesPerHiCycle' in the docs - usually 32, so
* we'll use that */
short freq;
char octaves, compress;
long volume;
char NAME[4];
long nlen; /* should be 64; see name[] comment */
char name[64]; /* for simplicity, i.e. just fwrite() entiree header */
long nlen; /* should be 64; see name[] comment */
char name[64]; /* for simplicity, i.e. just fwrite() entiree header */
char BODY[4];
long blen;
} IFF;
main(int ac, char **av)
{
FILE *in, *out;
@@ -48,51 +47,53 @@ main(int ac, char **av)
long n, len;
if (ac != 3) {
fprintf(stderr, "Usage: %s input-file output-file\n", av[0]);
exit(20);
fprintf(stderr, "Usage: %s input-file output-file\n", av[0]);
exit(20);
}
if (!(in = fopen(av[1], "r"))) {
fprintf(stderr, "Can't open input file\n");
exit(20);
fprintf(stderr, "Can't open input file\n");
exit(20);
}
if (!(out = fopen(av[2], "w"))) {
fprintf(stderr, "Can't open output file\n");
exit(20);
fprintf(stderr, "Can't open output file\n");
exit(20);
}
fread(&aiff, sizeof(aiff), 1, in);
memcpy(iff.FORM, "FORM", 4);
iff.flen = sizeof(iff) + aiff.sndlen - 8;
iff.flen = sizeof(iff) + aiff.sndlen - 8;
memcpy(iff._8SVX, "8SVX", 4);
memcpy(iff.VHDR, "VHDR", 4);
iff.vhlen = 20;
iff.oneshot = aiff.sndlen;
iff.repeat = 0;
iff.samples = 32;
iff.freq = 22000;
iff.octaves = 1;
iff.compress= 0;
iff.volume = 0x10000;
iff.vhlen = 20;
iff.oneshot = aiff.sndlen;
iff.repeat = 0;
iff.samples = 32;
iff.freq = 22000;
iff.octaves = 1;
iff.compress = 0;
iff.volume = 0x10000;
memcpy(iff.NAME, "NAME", 4);
iff.nlen = 64;
strncpy(iff.name, aiff.name, 62); iff.name[aiff.namelen] = 0;
iff.nlen = 64;
strncpy(iff.name, aiff.name, 62);
iff.name[aiff.namelen] = 0;
memcpy(iff.BODY, "BODY", 4);
iff.blen = aiff.sndlen;
iff.blen = aiff.sndlen;
fwrite(&iff, sizeof(iff), 1, out);
len = aiff.sndlen;
do {
if (len >= sizeof(buf))
n = fread(buf, 1, sizeof(buf), in);
else
n = fread(buf, 1, len, in);
if (n) {
fwrite(buf, 1, n, out);
len -= n;
}
if (len >= sizeof(buf))
n = fread(buf, 1, sizeof(buf), in);
else
n = fread(buf, 1, len, in);
if (n) {
fwrite(buf, 1, n, out);
len -= n;
}
} while (len && n);
if (len)
fprintf(stderr, "Warning: %ld bytes of sample missing\n", len);
fclose(in); fclose(out);
fprintf(stderr, "Warning: %ld bytes of sample missing\n", len);
fclose(in);
fclose(out);
exit(0);
}
+212 -223
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 txt2iff.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 txt2iff.c $NHDT-Date: 1431192784 2015/05/09 17:33:04 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 txt2iff.c $Date: 2009/05/06 10:48:31 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)txt2iff.c 3.5 1995/07/28 */
/* Copyright (c) 1995 by Gregg Wonderly, Naperville, Illinois */
@@ -20,9 +20,9 @@
#include <clib/dos_protos.h>
#include <clib/iffparse_protos.h>
#ifndef _DCC
# include <proto/exec.h>
# include <proto/iffparse.h>
# include <proto/dos.h>
#include <proto/exec.h>
#include <proto/iffparse.h>
#include <proto/dos.h>
#endif
void panic(const char *);
@@ -39,36 +39,36 @@ extern int colorsinmap;
*/
struct {
int Height;
int Width;
int Height;
int Width;
} IFFScreen;
/*
* We are using a hybrid form of our own design which we call a BMAP (for
* bitmap) form. It is an ILBM with the bitmaps already deinterleaved,
* completely uncompressed.
* This speeds the loading of the images from the games point of view because it
* This speeds the loading of the images from the games point of view because
* it
* does not have to deinterleave and uncompress them.
*/
#define ID_BMAP MAKE_ID( 'B', 'M', 'A', 'P' ) /* instead of ILBM */
#define ID_BMHD MAKE_ID( 'B', 'M', 'H', 'D' ) /* Same as ILBM */
#define ID_CAMG MAKE_ID( 'C', 'A', 'M', 'G' ) /* Same as ILBM */
#define ID_CMAP MAKE_ID( 'C', 'M', 'A', 'P' ) /* Same as ILBM */
#define ID_PDAT MAKE_ID( 'P', 'D', 'A', 'T' ) /* Extra data describing plane
* size due to graphics.library
* rounding requirements.
*/
#define ID_PLNE MAKE_ID( 'P', 'L', 'N', 'E' ) /* The planes of the image */
#define ID_BMAP MAKE_ID('B', 'M', 'A', 'P') /* instead of ILBM */
#define ID_BMHD MAKE_ID('B', 'M', 'H', 'D') /* Same as ILBM */
#define ID_CAMG MAKE_ID('C', 'A', 'M', 'G') /* Same as ILBM */
#define ID_CMAP MAKE_ID('C', 'M', 'A', 'P') /* Same as ILBM */
#define ID_PDAT \
MAKE_ID('P', 'D', 'A', 'T') /* Extra data describing plane \
* size due to graphics.library \
* rounding requirements. \
*/
#define ID_PLNE MAKE_ID('P', 'L', 'N', 'E') /* The planes of the image */
#ifndef _DCC
extern
#endif
struct Library *IFFParseBase;
struct Library *IFFParseBase;
int nplanes;
/* BMHD from IFF documentation */
typedef struct {
UWORD w, h;
@@ -89,19 +89,18 @@ typedef struct {
pixel pixels[TILE_Y][TILE_X];
AmiColorMap *cmap;
int findcolor( register pixel *pix );
void packwritebody( pixel (*tile)[TILE_X], char **planes, int tileno );
int findcolor(register pixel *pix);
void packwritebody(pixel (*tile)[TILE_X], char **planes, int tileno);
void
error( char *str )
error(char *str)
{
fprintf( stderr, "ERROR: %s\n", str );
fprintf(stderr, "ERROR: %s\n", str);
}
/*
* This array maps the image colors to the amiga's first 16 colors. The colors
* This array maps the image colors to the amiga's first 16 colors. The
* colors
* are reordered to help with maintaining dripen settings.
*/
int colrmap[] = { 0, 6, 9, 15, 4, 10, 2, 3, 5, 11, 7, 13, 8, 1, 14, 12 };
@@ -109,65 +108,62 @@ int colrmap[] = { 0, 6, 9, 15, 4, 10, 2, 3, 5, 11, 7, 13, 8, 1, 14, 12 };
/* How many tiles fit across and down. */
#define COLS 20
#define ROWS ((tiles + COLS-1) / COLS)
#define ROWS ((tiles + COLS - 1) / COLS)
main( int argc, char **argv )
main(int argc, char **argv)
{
int colors;
struct {
long nplanes;
long pbytes;
long across;
long down;
long npics;
long xsize;
long ysize;
long nplanes;
long pbytes;
long across;
long down;
long npics;
long xsize;
long ysize;
} pdat;
long pbytes; /* Bytes of data in a plane */
long pbytes; /* Bytes of data in a plane */
int i, cnt;
BitMapHeader bmhd;
struct IFFHandle *iff;
long camg = HIRES|LACE;
int tiles=0;
long camg = HIRES | LACE;
int tiles = 0;
char **planes;
if(argc != 3){
fprintf(stderr, "Usage: %s source destination\n", argv[0]);
exit(1);
if (argc != 3) {
fprintf(stderr, "Usage: %s source destination\n", argv[0]);
exit(1);
}
#if defined(_DCC) || defined(__GNUC__)
IFFParseBase = OpenLibrary( "iffparse.library", 0 );
if( !IFFParseBase ) {
error( "unable to open iffparse.library" );
exit( 1 );
IFFParseBase = OpenLibrary("iffparse.library", 0);
if (!IFFParseBase) {
error("unable to open iffparse.library");
exit(1);
}
#endif
/* First, count the files in the file */
if( fopen_text_file( argv[1], "r" ) != TRUE )
{
perror( argv[1] );
return( 1 );
if (fopen_text_file(argv[1], "r") != TRUE) {
perror(argv[1]);
return (1);
}
nplanes = 0;
i = colorsinmap-1; /*IFFScreen.Colors - 1; */
while( i != 0 )
{
nplanes++;
i >>= 1;
i = colorsinmap - 1; /*IFFScreen.Colors - 1; */
while (i != 0) {
nplanes++;
i >>= 1;
}
planes = malloc( nplanes * sizeof( char * ) );
if( planes == 0 )
{
error( "can not allocate planes pointer" );
exit( 1 );
planes = malloc(nplanes * sizeof(char *));
if (planes == 0) {
error("can not allocate planes pointer");
exit(1);
}
while( read_text_tile( pixels ) == TRUE )
++tiles;
while (read_text_tile(pixels) == TRUE)
++tiles;
fclose_text_file();
IFFScreen.Width = COLS * TILE_X;
@@ -175,41 +171,36 @@ main( int argc, char **argv )
pbytes = (COLS * ROWS * TILE_X + 15) / 16 * 2 * TILE_Y;
for( i = 0; i < nplanes; ++i )
{
planes[ i ] = calloc( 1, pbytes );
if( planes[ i ] == 0 )
{
error( "can not allocate planes pointer" );
exit( 1 );
}
for (i = 0; i < nplanes; ++i) {
planes[i] = calloc(1, pbytes);
if (planes[i] == 0) {
error("can not allocate planes pointer");
exit(1);
}
}
/* Now, process it */
if( fopen_text_file( argv[1], "r" ) != TRUE )
{
perror( argv[1] );
return( 1 );
if (fopen_text_file(argv[1], "r") != TRUE) {
perror(argv[1]);
return (1);
}
iff = AllocIFF();
if( !iff )
{
error( "Can not allocate IFFHandle" );
return( 1 );
if (!iff) {
error("Can not allocate IFFHandle");
return (1);
}
iff->iff_Stream = Open( argv[2], MODE_NEWFILE );
if( !iff->iff_Stream )
{
error( "Can not open output file" );
return( 1 );
iff->iff_Stream = Open(argv[2], MODE_NEWFILE);
if (!iff->iff_Stream) {
error("Can not open output file");
return (1);
}
InitIFFasDOS( iff );
OpenIFF( iff, IFFF_WRITE );
InitIFFasDOS(iff);
OpenIFF(iff, IFFF_WRITE);
PushChunk( iff, ID_BMAP, ID_FORM, IFFSIZE_UNKNOWN );
PushChunk(iff, ID_BMAP, ID_FORM, IFFSIZE_UNKNOWN);
bmhd.w = IFFScreen.Width;
bmhd.h = IFFScreen.Height;
@@ -225,40 +216,38 @@ main( int argc, char **argv )
bmhd.pageWidth = TILE_X;
bmhd.pageHeight = TILE_Y;
PushChunk( iff, ID_BMAP, ID_BMHD, sizeof( bmhd ) );
WriteChunkBytes( iff, &bmhd, sizeof( bmhd ) );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_BMHD, sizeof(bmhd));
WriteChunkBytes(iff, &bmhd, sizeof(bmhd));
PopChunk(iff);
PushChunk( iff, ID_BMAP, ID_CAMG, sizeof( camg ) );
WriteChunkBytes( iff, &camg, sizeof( camg ) );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_CAMG, sizeof(camg));
WriteChunkBytes(iff, &camg, sizeof(camg));
PopChunk(iff);
/* We need to reorder the colors to get reasonable default pens but
* we also need to know where some of the colors are - so go find out.
*/
map_colors();
cmap = malloc( (colors = (1L<<nplanes)) * sizeof(AmiColorMap) );
for( i = 0; i < colors; ++i )
{
cmap[ colrmap[ i ] ].r = ColorMap[ CM_RED ][ i ];
cmap[ colrmap[ i ] ].g = ColorMap[ CM_GREEN ][ i ];
cmap[ colrmap[ i ] ].b = ColorMap[ CM_BLUE ][ i ];
cmap = malloc((colors = (1L << nplanes)) * sizeof(AmiColorMap));
for (i = 0; i < colors; ++i) {
cmap[colrmap[i]].r = ColorMap[CM_RED][i];
cmap[colrmap[i]].g = ColorMap[CM_GREEN][i];
cmap[colrmap[i]].b = ColorMap[CM_BLUE][i];
}
PushChunk( iff, ID_BMAP, ID_CMAP, IFFSIZE_UNKNOWN );
PushChunk(iff, ID_BMAP, ID_CMAP, IFFSIZE_UNKNOWN);
for (i = 0; i < colors; ++i)
WriteChunkBytes(iff, &cmap[i], 3);
PopChunk( iff );
WriteChunkBytes(iff, &cmap[i], 3);
PopChunk(iff);
cnt = 0;
while( read_text_tile( pixels ) == TRUE )
{
packwritebody( pixels, planes, cnt );
if( cnt % 20 == 0 )
printf( "%d..", cnt );
++cnt;
fflush( stdout );
while (read_text_tile(pixels) == TRUE) {
packwritebody(pixels, planes, cnt);
if (cnt % 20 == 0)
printf("%d..", cnt);
++cnt;
fflush(stdout);
}
pdat.nplanes = nplanes;
@@ -269,45 +258,43 @@ main( int argc, char **argv )
pdat.down = ROWS;
pdat.npics = cnt;
PushChunk( iff, ID_BMAP, ID_PDAT, IFFSIZE_UNKNOWN );
WriteChunkBytes( iff, &pdat, sizeof( pdat ) );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_PDAT, IFFSIZE_UNKNOWN);
WriteChunkBytes(iff, &pdat, sizeof(pdat));
PopChunk(iff);
PushChunk( iff, ID_BMAP, ID_PLNE, IFFSIZE_UNKNOWN );
for( i = 0; i < nplanes; ++i )
WriteChunkBytes( iff, planes[i], pbytes );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_PLNE, IFFSIZE_UNKNOWN);
for (i = 0; i < nplanes; ++i)
WriteChunkBytes(iff, planes[i], pbytes);
PopChunk(iff);
CloseIFF( iff );
Close( iff->iff_Stream );
FreeIFF( iff );
CloseIFF(iff);
Close(iff->iff_Stream);
FreeIFF(iff);
printf( "\n%d tiles converted\n", cnt );
printf("\n%d tiles converted\n", cnt);
#if defined(_DCC) || defined(__GNUC__)
CloseLibrary( IFFParseBase );
CloseLibrary(IFFParseBase);
#endif
exit( 0 );
exit(0);
}
findcolor( register pixel *pix )
findcolor(register pixel *pix)
{
register int i;
for( i = 0; i < MAXCOLORMAPSIZE; ++i )
{
if( (pix->r == ColorMap[ CM_RED ][i] ) &&
(pix->g == ColorMap[ CM_GREEN ][i] ) &&
(pix->b == ColorMap[ CM_BLUE ][i] ) )
{
return( i );
}
for (i = 0; i < MAXCOLORMAPSIZE; ++i) {
if ((pix->r == ColorMap[CM_RED][i])
&& (pix->g == ColorMap[CM_GREEN][i])
&& (pix->b == ColorMap[CM_BLUE][i])) {
return (i);
}
}
return( -1 );
return (-1);
}
void
packwritebody( pixel (*tile)[TILE_X], char **planes, int tileno )
packwritebody(pixel (*tile)[TILE_X], char **planes, int tileno)
{
register int i, j, k, col;
register char *buf;
@@ -317,46 +304,43 @@ packwritebody( pixel (*tile)[TILE_X], char **planes, int tileno )
across = COLS;
/* How many bytes per pixel row */
rowbytes = ((IFFScreen.Width + 15)/16)*2;
rowbytes = ((IFFScreen.Width + 15) / 16) * 2;
/* How many bytes to account for y distance in planes */
yoff = ((tileno / across) * TILE_Y) * rowbytes;
/* How many bytes to account for x distance in planes */
xoff = (tileno % across) * (TILE_X/8);
xoff = (tileno % across) * (TILE_X / 8);
/* For each row... */
for( i = 0; i < TILE_Y; ++i )
{
/* For each bitplane... */
for( k = 0; k < nplanes; ++k )
{
const int mask = 1l<<k;
for (i = 0; i < TILE_Y; ++i) {
/* For each bitplane... */
for (k = 0; k < nplanes; ++k) {
const int mask = 1l << k;
/* Go across the row */
for( j = 0; j < TILE_X; j++ )
{
col = findcolor( &tile[ i ][ j ] );
if( col == -1 )
{
error( "can not convert pixel color to colormap index" );
return;
}
/* Shift the colors around to have good complements and to
* know the dripen values.
*/
col = colrmap[ col ];
/* Go across the row */
for (j = 0; j < TILE_X; j++) {
col = findcolor(&tile[i][j]);
if (col == -1) {
error("can not convert pixel color to colormap index");
return;
}
/* Shift the colors around to have good complements and to
* know the dripen values.
*/
col = colrmap[col];
/* To top left corner of tile */
buf = planes[ k ] + yoff + xoff;
/* To top left corner of tile */
buf = planes[k] + yoff + xoff;
/*To i'th row of tile and the correct byte for the j'th pixel*/
buf += ( i * rowbytes ) + (j/8);
/*To i'th row of tile and the correct byte for the j'th
* pixel*/
buf += (i * rowbytes) + (j / 8);
/* Or in the bit for this color */
*buf |= (((col & mask)!=0)<<(7-(j%8)));
}
}
/* Or in the bit for this color */
*buf |= (((col & mask) != 0) << (7 - (j % 8)));
}
}
}
}
@@ -369,91 +353,96 @@ packwritebody( pixel (*tile)[TILE_X], char **planes, int tileno )
*/
/* What we are aiming for: */
/* XXX was 0-7 */
#define CX_BLACK 0
#define CX_WHITE 1
#define CX_BROWN 11
#define CX_CYAN 2
#define CX_GREEN 5
#define CX_MAGENTA 10
#define CX_BLUE 4
#define CX_RED 7
#define CX_BLACK 0
#define CX_WHITE 1
#define CX_BROWN 11
#define CX_CYAN 2
#define CX_GREEN 5
#define CX_MAGENTA 10
#define CX_BLUE 4
#define CX_RED 7
/* we don't care about the rest, at least now */
/* should get: black white blue red grey greyblue ltgrey */
void
map_colors(){
int x;
map_colors()
{
int x;
#if 1
int tmpmap[]={0,2,3,7,4,5,8,9,10,11,13,15,12,1,14,6};
int tmpmap[] = { 0, 2, 3, 7, 4, 5, 8, 9, 10, 11, 13, 15, 12, 1, 14, 6 };
/* still not right: gray green yellow lost somewhere? */
#else
int tmpmap[16];
int x,y;
for(x=0;x<16;x++)tmpmap[x]=-1; /* set not assigned yet */
int tmpmap[16];
int x, y;
for (x = 0; x < 16; x++)
tmpmap[x] = -1; /* set not assigned yet */
tmpmap[BestMatch(0,0,0)] = CX_BLACK;
tmpmap[BestMatch(255,255,255)] = CX_WHITE;
tmpmap[BestMatch(255,0,0)] = CX_RED;
tmpmap[BestMatch(0,255,0)] = CX_GREEN;
tmpmap[BestMatch(0,0,255)] = CX_BLUE;
tmpmap[BestMatch(0, 0, 0)] = CX_BLACK;
tmpmap[BestMatch(255, 255, 255)] = CX_WHITE;
tmpmap[BestMatch(255, 0, 0)] = CX_RED;
tmpmap[BestMatch(0, 255, 0)] = CX_GREEN;
tmpmap[BestMatch(0, 0, 255)] = CX_BLUE;
/* clean up the rest */
for(x=0;x<16;x++){
for(y=0;y<16;y++)
if(tmpmap[y]==x)goto outer_cont;
for(y=0;y<16;y++)
if(tmpmap[y]==-1){
tmpmap[y]=x;
break;
}
if(y==16)panic("too many colors?");
outer_cont: ;
}
for(x=0;x<16;x++)
if(tmpmap[y]==-1)panic("lost color?");
/* clean up the rest */
for (x = 0; x < 16; x++) {
for (y = 0; y < 16; y++)
if (tmpmap[y] == x)
goto outer_cont;
for (y = 0; y < 16; y++)
if (tmpmap[y] == -1) {
tmpmap[y] = x;
break;
}
if (y == 16)
panic("too many colors?");
outer_cont:
;
}
for (x = 0; x < 16; x++)
if (tmpmap[y] == -1)
panic("lost color?");
#endif
for(x=0;x<16;x++){
for (x = 0; x < 16; x++) {
#ifdef DBG
printf("final: c[%d]=%d (target: %d)\n",x,tmpmap[x],colrmap[x]);
printf("final: c[%d]=%d (target: %d)\n", x, tmpmap[x], colrmap[x]);
#endif
colrmap[x]=tmpmap[x];
}
colrmap[x] = tmpmap[x];
}
}
BestMatch(r,g,b)
int r,g,b;
BestMatch(r, g, b) int r, g, b;
{
int x;
int bestslot;
int bestrate=99999999L;
for(x=0;x<16;x++){
int rr = r-ColorMap[CM_RED][x];
int gg = g-ColorMap[CM_GREEN][x];
int bb = b-ColorMap[CM_BLUE][x];
int rate = rr*rr + gg*gg + bb*bb;
if(bestrate > rate){
bestrate = rate;
bestslot = x;
}
}
int x;
int bestslot;
int bestrate = 99999999L;
for (x = 0; x < 16; x++) {
int rr = r - ColorMap[CM_RED][x];
int gg = g - ColorMap[CM_GREEN][x];
int bb = b - ColorMap[CM_BLUE][x];
int rate = rr * rr + gg * gg + bb * bb;
if (bestrate > rate) {
bestrate = rate;
bestslot = x;
}
}
#ifdef DBG
printf("map (%d,%d,%d) -> %d (error=%d)\n",r,g,b,bestslot,bestrate);
printf("map (%d,%d,%d) -> %d (error=%d)\n", r, g, b, bestslot, bestrate);
#endif
return bestslot;
return bestslot;
}
long *
alloc( unsigned int n )
alloc(unsigned int n)
{
long *ret = malloc( n );
if(!ret){
error("Can't allocate memory");
exit(1);
long *ret = malloc(n);
if (!ret) {
error("Can't allocate memory");
exit(1);
}
return( ret );
return (ret);
}
void
panic(const char *msg){
fprintf(stderr,"PANIC: %s\n",msg);
panic(const char *msg)
{
fprintf(stderr, "PANIC: %s\n", msg);
exit(1);
}
+1062 -1138
View File
File diff suppressed because it is too large Load Diff
+651 -697
View File
File diff suppressed because it is too large Load Diff
+1473 -1587
View File
File diff suppressed because it is too large Load Diff
+44 -56
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 winkey.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 winkey.c $NHDT-Date: 1431192783 2015/05/09 17:33:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 winkey.c $Date: 2009/05/06 10:48:37 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)winkey.c 3.5 1993/04/02 */
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993. */
@@ -8,58 +8,49 @@
#include "NH:sys/amiga/winext.h"
#include "NH:sys/amiga/winproto.h"
amii_nh_poskey(x, y, mod)
int*x, *y, *mod;
amii_nh_poskey(x, y, mod) int *x, *y, *mod;
{
struct amii_WinDesc *cw;
WETYPE type;
struct RastPort *rp;
struct Window *w;
if( cw = amii_wins[WIN_MESSAGE] )
{
cw->wflags &= ~FLMAP_SKIP;
if( scrollmsg )
cw->wflags |= FLMSG_FIRST;
cw->disprows = 0;
if (cw = amii_wins[WIN_MESSAGE]) {
cw->wflags &= ~FLMAP_SKIP;
if (scrollmsg)
cw->wflags |= FLMSG_FIRST;
cw->disprows = 0;
}
if( WIN_MAP != WIN_ERR && (cw = amii_wins[ WIN_MAP ]) && ( w = cw->win ) )
{
cursor_on( WIN_MAP );
}
else
panic( "no MAP window opened for nh_poskey\n" );
if (WIN_MAP != WIN_ERR && (cw = amii_wins[WIN_MAP]) && (w = cw->win)) {
cursor_on(WIN_MAP);
} else
panic("no MAP window opened for nh_poskey\n");
rp = w->RPort;
while( 1 )
{
type = WindowGetevent( );
if( type == WEMOUSE )
{
*mod = CLICK_1;
if( lastevent.un.mouse.qual )
*mod = 0;
while (1) {
type = WindowGetevent();
if (type == WEMOUSE) {
*mod = CLICK_1;
if (lastevent.un.mouse.qual)
*mod = 0;
/* X coordinates are 1 based, Y are 1 based. */
*x = ( (lastevent.un.mouse.x - w->BorderLeft) / mxsize ) + 1;
*y = ( ( lastevent.un.mouse.y - w->BorderTop - MAPFTBASELN ) /
mysize ) + 1;
#ifdef CLIPPING
if( clipping )
{
*x += clipx;
*y += clipy;
}
/* X coordinates are 1 based, Y are 1 based. */
*x = ((lastevent.un.mouse.x - w->BorderLeft) / mxsize) + 1;
*y = ((lastevent.un.mouse.y - w->BorderTop - MAPFTBASELN)
/ mysize) + 1;
#ifdef CLIPPING
if (clipping) {
*x += clipx;
*y += clipy;
}
#endif
return( 0 );
}
else if( type == WEKEY )
{
lastevent.type = WEUNK;
return( lastevent.un.key );
}
return (0);
} else if (type == WEKEY) {
lastevent.type = WEUNK;
return (lastevent.un.key);
}
}
}
@@ -67,17 +58,16 @@ int
amii_nhgetch()
{
int ch;
struct amii_WinDesc *cw=amii_wins[WIN_MESSAGE];
struct amii_WinDesc *cw = amii_wins[WIN_MESSAGE];
if( WIN_MAP != WIN_ERR && amii_wins[ WIN_MAP ] )
{
cursor_on( WIN_MAP );
if (WIN_MAP != WIN_ERR && amii_wins[WIN_MAP]) {
cursor_on(WIN_MAP);
}
if(cw)
cw->wflags &= ~FLMAP_SKIP;
if (cw)
cw->wflags &= ~FLMAP_SKIP;
ch = WindowGetchar();
return( ch );
return (ch);
}
void
@@ -91,18 +81,16 @@ amii_getret()
{
register int c;
raw_print( "" );
raw_print( "Press Return..." );
raw_print("");
raw_print("Press Return...");
c = 0;
while( c != '\n' && c != '\r' )
{
if( HackPort )
c = WindowGetchar();
else
c = getchar();
while (c != '\n' && c != '\r') {
if (HackPort)
c = WindowGetchar();
else
c = getchar();
}
return;
}
+1102 -1241
View File
File diff suppressed because it is too large Load Diff
+734 -889
View File
File diff suppressed because it is too large Load Diff
+319 -349
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 winstr.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 winstr.c $NHDT-Date: 1431192783 2015/05/09 17:33:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 winstr.c $Date: 2009/05/06 10:48:42 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)winstr.c 3.5 1993/04/02 */
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993. */
@@ -11,10 +11,10 @@
/* Put a string into the indicated window using the indicated attribute */
void
amii_putstr(window,attr,str)
winid window;
int attr;
const char *str;
amii_putstr(window, attr, str)
winid window;
int attr;
const char *str;
{
int fudge;
int len;
@@ -25,131 +25,123 @@ amii_putstr(window,attr,str)
static int wrapping = 0;
/* Always try to avoid a panic when there is no window */
if( window == WIN_ERR )
{
window = WIN_BASE;
if( window == WIN_ERR )
window = WIN_BASE = amii_create_nhwindow( NHW_BASE );
if (window == WIN_ERR) {
window = WIN_BASE;
if (window == WIN_ERR)
window = WIN_BASE = amii_create_nhwindow(NHW_BASE);
}
if( window == WIN_ERR || ( cw = amii_wins[window] ) == NULL )
{
iflags.window_inited=0;
panic(winpanicstr,window, "putstr");
if (window == WIN_ERR || (cw = amii_wins[window]) == NULL) {
iflags.window_inited = 0;
panic(winpanicstr, window, "putstr");
}
w = cw->win;
if(!str) return;
amiIDisplay->lastwin = window; /* do we care??? */
if (!str)
return;
amiIDisplay->lastwin = window; /* do we care??? */
/* NHW_MENU windows are not opened immediately, so check if we
* have the window pointer yet
*/
if( w )
{
/* Set the drawing mode and pen colors */
SetDrMd( w->RPort, JAM2 );
amii_sethipens( w, cw->type, attr );
}
else if( cw->type != NHW_MENU && cw->type != NHW_TEXT )
{
panic( "NULL window pointer in putstr 2: %d", window );
if (w) {
/* Set the drawing mode and pen colors */
SetDrMd(w->RPort, JAM2);
amii_sethipens(w, cw->type, attr);
} else if (cw->type != NHW_MENU && cw->type != NHW_TEXT) {
panic("NULL window pointer in putstr 2: %d", window);
}
/* Okay now do the work for each type */
switch(cw->type)
{
switch (cw->type) {
case NHW_MESSAGE:
if( WINVERS_AMIV )
fudge = 2;
else
{
/* 8 for --more--, 1 for preceeding sp, 1 for putstr pad */
fudge = 10;
}
if (WINVERS_AMIV)
fudge = 2;
else {
/* 8 for --more--, 1 for preceeding sp, 1 for putstr pad */
fudge = 10;
}
/* There is a one pixel border at the borders, so subtract two */
bottom = amii_msgborder( w );
/* There is a one pixel border at the borders, so subtract two */
bottom = amii_msgborder(w);
wheight = ( w->Height - w->BorderTop -
w->BorderBottom - 3 ) / w->RPort->TxHeight;
if (scrollmsg || wheight > 1)
fudge = 0;
wheight = (w->Height - w->BorderTop - w->BorderBottom - 3)
/ w->RPort->TxHeight;
amii_scrollmsg( w, cw );
if (scrollmsg || wheight > 1)
fudge = 0;
while (isspace(*str)) str++;
strncpy( toplines, str, TBUFSZ );
toplines[ TBUFSZ - 1 ] = 0;
amii_scrollmsg(w, cw);
/* For initial message to be visible, we need to explicitly position the
* cursor. This flag, cw->curx == -1 is set elsewhere to force the
* cursor to be repositioned to the "bottom".
*/
if( cw->curx == -1 )
{
amii_curs( WIN_MESSAGE, 1, bottom );
cw->curx = 0;
}
while (isspace(*str))
str++;
strncpy(toplines, str, TBUFSZ);
toplines[TBUFSZ - 1] = 0;
/* If used all of history lines, move them down */
if( cw->maxrow >= iflags.msg_history )
{
if( cw->data[ 0 ] )
free( cw->data[ 0 ] );
memcpy( cw->data, &cw->data[ 1 ],
( iflags.msg_history - 1 ) * sizeof( char * ) );
cw->data[ iflags.msg_history - 1 ] =
(char *) alloc( strlen( toplines ) + 5 );
strcpy( cw->data[ i = iflags.msg_history - 1 ] +
SOFF + (scrollmsg!=0), toplines );
}
else
{
/* Otherwise, allocate a new one and copy the line in */
cw->data[ cw->maxrow ] = (char *)
alloc( strlen( toplines ) + 5 );
strcpy( cw->data[ i = cw->maxrow++ ] +
SOFF + (scrollmsg!=0), toplines );
}
cw->data[ i ][ SEL_ITEM ] = 1;
cw->data[ i ][ VATTR ] = attr+1;
/* For initial message to be visible, we need to explicitly position
* the
* cursor. This flag, cw->curx == -1 is set elsewhere to force the
* cursor to be repositioned to the "bottom".
*/
if (cw->curx == -1) {
amii_curs(WIN_MESSAGE, 1, bottom);
cw->curx = 0;
}
if( scrollmsg )
{
cw->curx = 0;
cw->data[ i ][2] = (cw->wflags & FLMSG_FIRST ) ? '>' : ' ';
}
/* If used all of history lines, move them down */
if (cw->maxrow >= iflags.msg_history) {
if (cw->data[0])
free(cw->data[0]);
memcpy(cw->data, &cw->data[1],
(iflags.msg_history - 1) * sizeof(char *));
cw->data[iflags.msg_history - 1] =
(char *) alloc(strlen(toplines) + 5);
strcpy(cw->data[i = iflags.msg_history - 1] + SOFF
+ (scrollmsg != 0),
toplines);
} else {
/* Otherwise, allocate a new one and copy the line in */
cw->data[cw->maxrow] = (char *) alloc(strlen(toplines) + 5);
strcpy(cw->data[i = cw->maxrow++] + SOFF + (scrollmsg != 0),
toplines);
}
cw->data[i][SEL_ITEM] = 1;
cw->data[i][VATTR] = attr + 1;
str = cw->data[i] + SOFF;
if( cw->curx + strlen(str) >= (cw->cols-fudge) )
{
int i;
char *ostr = (char *)str;
char *p;
if (scrollmsg) {
cw->curx = 0;
cw->data[i][2] = (cw->wflags & FLMSG_FIRST) ? '>' : ' ';
}
while( cw->curx + strlen( str ) >= (cw->cols-fudge) )
{
for(p=((char *)&str[ cw->cols-1 - cw->curx ])-fudge; !isspace(*p) && p > str;)
--p;
if (p < str) p = (char *)str;
str = cw->data[i] + SOFF;
if (cw->curx + strlen(str) >= (cw->cols - fudge)) {
int i;
char *ostr = (char *) str;
char *p;
if( p == str ) {
/* p = (char *)&str[ cw->cols ]; */
outmore(cw);
continue;
}
while (cw->curx + strlen(str) >= (cw->cols - fudge)) {
for (p = ((char *) &str[cw->cols - 1 - cw->curx]) - fudge;
!isspace(*p) && p > str;)
--p;
if (p < str)
p = (char *) str;
i = (long)p-(long)str;
outsubstr( cw, (char *)str, i, fudge );
cw->curx += i;
if (p == str) {
/* p = (char *)&str[ cw->cols ]; */
outmore(cw);
continue;
}
while(isspace(*p)) p++;
str = p;
i = (long) p - (long) str;
outsubstr(cw, (char *) str, i, fudge);
cw->curx += i;
while (isspace(*p))
p++;
str = p;
#if 0
if( str != ostr ) {
@@ -157,263 +149,247 @@ amii_putstr(window,attr,str)
cw->curx+=2;
}
#endif
if(*str)
amii_scrollmsg( w, cw );
amii_cl_end( cw, cw->curx );
}
if (*str)
amii_scrollmsg(w, cw);
amii_cl_end(cw, cw->curx);
}
if( *str )
{
if( str != ostr )
{
outsubstr( cw, "+", 1, fudge );
cw->curx+=2;
}
while ( isspace( *str ) )
++str;
outsubstr( cw, (char *)str, i = strlen( (char *)str ), fudge );
cw->curx += i;
amii_cl_end( cw, cw->curx );
}
}
else
{
outsubstr( cw, (char *)str, i = strlen( (char *)str ), fudge );
cw->curx += i;
amii_cl_end( cw, cw->curx );
}
cw->wflags &= ~FLMSG_FIRST;
len = 0;
if( scrollmsg )
{
totalvis = CountLines( window );
SetPropInfo( w, &MsgScroll,
( w->Height-w->BorderTop-w->BorderBottom ) / w->RPort->TxHeight,
totalvis, totalvis );
}
i = strlen( toplines + SOFF );
cw->maxcol = max( cw->maxcol, i );
cw->vwy = cw->maxrow;
break;
if (*str) {
if (str != ostr) {
outsubstr(cw, "+", 1, fudge);
cw->curx += 2;
}
while (isspace(*str))
++str;
outsubstr(cw, (char *) str, i = strlen((char *) str), fudge);
cw->curx += i;
amii_cl_end(cw, cw->curx);
}
} else {
outsubstr(cw, (char *) str, i = strlen((char *) str), fudge);
cw->curx += i;
amii_cl_end(cw, cw->curx);
}
cw->wflags &= ~FLMSG_FIRST;
len = 0;
if (scrollmsg) {
totalvis = CountLines(window);
SetPropInfo(w, &MsgScroll,
(w->Height - w->BorderTop - w->BorderBottom)
/ w->RPort->TxHeight,
totalvis, totalvis);
}
i = strlen(toplines + SOFF);
cw->maxcol = max(cw->maxcol, i);
cw->vwy = cw->maxrow;
break;
case NHW_STATUS:
if( cw->data[ cw->cury ] == NULL )
panic( "NULL pointer for status window" );
ob = &cw->data[cw->cury][j = cw->curx];
if(flags.botlx) *ob = 0;
if (cw->data[cw->cury] == NULL)
panic("NULL pointer for status window");
ob = &cw->data[cw->cury][j = cw->curx];
if (flags.botlx)
*ob = 0;
/* Display when beam at top to avoid flicker... */
WaitTOF();
Text(w->RPort,(char *)str,strlen((char *)str));
if( cw->cols > strlen( str ) )
TextSpaces( w->RPort, cw->cols - strlen( str ) );
/* Display when beam at top to avoid flicker... */
WaitTOF();
Text(w->RPort, (char *) str, strlen((char *) str));
if (cw->cols > strlen(str))
TextSpaces(w->RPort, cw->cols - strlen(str));
(void) strncpy(cw->data[cw->cury], str, cw->cols );
cw->data[cw->cury][cw->cols-1] = '\0'; /* null terminate */
cw->cury = (cw->cury+1) % 2;
cw->curx = 0;
break;
(void) strncpy(cw->data[cw->cury], str, cw->cols);
cw->data[cw->cury][cw->cols - 1] = '\0'; /* null terminate */
cw->cury = (cw->cury + 1) % 2;
cw->curx = 0;
break;
case NHW_MAP:
case NHW_BASE:
if (cw->type == NHW_BASE && wrapping) {
amii_curs(window, cw->curx+1, cw->cury);
TextSpaces(w->RPort, cw->cols);
if (cw->cury < cw->rows) {
amii_curs(window, cw->curx+1, cw->cury+1);
TextSpaces(w->RPort, cw->cols);
cw->cury--;
}
}
amii_curs(window, cw->curx+1, cw->cury);
Text(w->RPort,(char *)str,strlen((char *)str));
cw->curx = 0;
/* CR-LF is automatic in these windows */
cw->cury++;
if (cw->type == NHW_BASE && cw->cury >= cw->rows) {
cw->cury = 0;
wrapping = 1;
}
break;
if (cw->type == NHW_BASE && wrapping) {
amii_curs(window, cw->curx + 1, cw->cury);
TextSpaces(w->RPort, cw->cols);
if (cw->cury < cw->rows) {
amii_curs(window, cw->curx + 1, cw->cury + 1);
TextSpaces(w->RPort, cw->cols);
cw->cury--;
}
}
amii_curs(window, cw->curx + 1, cw->cury);
Text(w->RPort, (char *) str, strlen((char *) str));
cw->curx = 0;
/* CR-LF is automatic in these windows */
cw->cury++;
if (cw->type == NHW_BASE && cw->cury >= cw->rows) {
cw->cury = 0;
wrapping = 1;
}
break;
case NHW_MENU:
case NHW_TEXT:
/* always grows one at a time, but alloc 12 at a time */
/* always grows one at a time, but alloc 12 at a time */
if( cw->cury >= cw->rows || !cw->data )
{
char **tmp;
if (cw->cury >= cw->rows || !cw->data) {
char **tmp;
/* Allocate 12 more rows */
cw->rows += 12;
tmp = (char**) alloc(sizeof(char*) * cw->rows);
/* Allocate 12 more rows */
cw->rows += 12;
tmp = (char **) alloc(sizeof(char *) * cw->rows);
/* Copy the old lines */
for(i=0; i<cw->cury; i++)
tmp[i] = cw->data[i];
/* Copy the old lines */
for (i = 0; i < cw->cury; i++)
tmp[i] = cw->data[i];
if( cw->data ) {
free( cw->data );
cw->data = NULL;
}
if (cw->data) {
free(cw->data);
cw->data = NULL;
}
cw->data = tmp;
cw->data = tmp;
/* Null out the unused entries. */
for(i=cw->cury; i<cw->rows; i++)
cw->data[i] = 0;
}
/* Null out the unused entries. */
for (i = cw->cury; i < cw->rows; i++)
cw->data[i] = 0;
}
if( !cw->data )
panic("no data storage");
if (!cw->data)
panic("no data storage");
/* Shouldn't need to do this, but... */
/* Shouldn't need to do this, but... */
if( cw->data && cw->data[cw->cury] ) {
free( cw->data[cw->cury] );
cw->data[cw->cury] = NULL;
}
if (cw->data && cw->data[cw->cury]) {
free(cw->data[cw->cury]);
cw->data[cw->cury] = NULL;
}
n0 = strlen(str)+1;
cw->data[cw->cury] = (char*) alloc(n0+SOFF);
n0 = strlen(str) + 1;
cw->data[cw->cury] = (char *) alloc(n0 + SOFF);
/* avoid nuls, for convenience */
cw->data[cw->cury][VATTR] = attr+1;
cw->data[cw->cury][SEL_ITEM] = 0;
Strcpy( cw->data[cw->cury] + SOFF, str);
/* avoid nuls, for convenience */
cw->data[cw->cury][VATTR] = attr + 1;
cw->data[cw->cury][SEL_ITEM] = 0;
Strcpy(cw->data[cw->cury] + SOFF, str);
if(n0 > cw->maxcol) cw->maxcol = n0;
if(++cw->cury > cw->maxrow) cw->maxrow = cw->cury;
break;
if (n0 > cw->maxcol)
cw->maxcol = n0;
if (++cw->cury > cw->maxrow)
cw->maxrow = cw->cury;
break;
default:
panic("Invalid or unset window type in putstr()");
panic("Invalid or unset window type in putstr()");
}
}
void
amii_scrollmsg( w, cw )
register struct Window *w;
register struct amii_WinDesc *cw;
amii_scrollmsg(w, cw)
register struct Window *w;
register struct amii_WinDesc *cw;
{
int bottom, wheight;
bottom = amii_msgborder( w );
bottom = amii_msgborder(w);
wheight = ( w->Height - w->BorderTop -
w->BorderBottom - 3 ) / w->RPort->TxHeight;
if( scrollmsg )
{
if( ++cw->disprows > wheight )
{
outmore( cw );
cw->disprows = 1; /* count this line... */
}
else
{
ScrollRaster( w->RPort, 0, w->RPort->TxHeight,
w->BorderLeft, w->BorderTop + 1,
w->Width - w->BorderRight-1,
w->Height - w->BorderBottom - 1 );
}
amii_curs( WIN_MESSAGE, 1, bottom );
wheight =
(w->Height - w->BorderTop - w->BorderBottom - 3) / w->RPort->TxHeight;
if (scrollmsg) {
if (++cw->disprows > wheight) {
outmore(cw);
cw->disprows = 1; /* count this line... */
} else {
ScrollRaster(w->RPort, 0, w->RPort->TxHeight, w->BorderLeft,
w->BorderTop + 1, w->Width - w->BorderRight - 1,
w->Height - w->BorderBottom - 1);
}
amii_curs(WIN_MESSAGE, 1, bottom);
}
}
int
amii_msgborder( w )
struct Window *w;
amii_msgborder(w)
struct Window *w;
{
register int bottom;
/* There is a one pixel border at the borders, so subtract two */
bottom = w->Height - w->BorderTop - w->BorderBottom - 2;
bottom /= w->RPort->TxHeight;
if( bottom > 0 )
--bottom;
return( bottom );
if (bottom > 0)
--bottom;
return (bottom);
}
void
outmore( cw )
register struct amii_WinDesc *cw;
outmore(cw)
register struct amii_WinDesc *cw;
{
struct Window *w = cw->win;
if((cw->wflags & FLMAP_SKIP) == 0)
{
if( scrollmsg )
{
int bottom;
if ((cw->wflags & FLMAP_SKIP) == 0) {
if (scrollmsg) {
int bottom;
bottom = amii_msgborder( w );
bottom = amii_msgborder(w);
ScrollRaster( w->RPort, 0, w->RPort->TxHeight,
w->BorderLeft, w->BorderTop+1,
w->Width - w->BorderRight-1,
w->Height - w->BorderBottom - 1 );
amii_curs( WIN_MESSAGE, 1, bottom ); /* -1 for inner border */
Text( w->RPort, "--more--", 8 );
}
else
Text( w->RPort, " --more--", 9 );
ScrollRaster(w->RPort, 0, w->RPort->TxHeight, w->BorderLeft,
w->BorderTop + 1, w->Width - w->BorderRight - 1,
w->Height - w->BorderBottom - 1);
amii_curs(WIN_MESSAGE, 1, bottom); /* -1 for inner border */
Text(w->RPort, "--more--", 8);
} else
Text(w->RPort, " --more--", 9);
/* Make sure there are no events in the queue */
flushIDCMP( HackPort );
/* Make sure there are no events in the queue */
flushIDCMP(HackPort);
/* Allow mouse clicks to clear --more-- */
WindowGetchar();
if( lastevent.type == WEKEY && lastevent.un.key == '\33' )
cw->wflags |= FLMAP_SKIP;
/* Allow mouse clicks to clear --more-- */
WindowGetchar();
if (lastevent.type == WEKEY && lastevent.un.key == '\33')
cw->wflags |= FLMAP_SKIP;
}
if( !scrollmsg )
{
amii_curs( WIN_MESSAGE, 1, 0 );
amii_cl_end( cw, cw->curx );
if (!scrollmsg) {
amii_curs(WIN_MESSAGE, 1, 0);
amii_cl_end(cw, cw->curx);
}
}
void
outsubstr( cw, str, len, fudge )
register struct amii_WinDesc *cw;
char *str;
int len;
int fudge;
outsubstr(cw, str, len, fudge)
register struct amii_WinDesc *cw;
char *str;
int len;
int fudge;
{
struct Window *w = cw->win;
if( cw->curx )
{
/* Check if this string and --more-- fit, if not,
* then put out --more-- and wait for a key.
*/
if( (len + fudge ) + cw->curx >= cw->cols )
{
if( !scrollmsg )
outmore( cw );
}
else
{
/* Otherwise, move and put out a blank separator */
Text( w->RPort, spaces, 1 );
cw->curx += 1;
}
if (cw->curx) {
/* Check if this string and --more-- fit, if not,
* then put out --more-- and wait for a key.
*/
if ((len + fudge) + cw->curx >= cw->cols) {
if (!scrollmsg)
outmore(cw);
} else {
/* Otherwise, move and put out a blank separator */
Text(w->RPort, spaces, 1);
cw->curx += 1;
}
}
Text(w->RPort,str,len);
Text(w->RPort, str, len);
}
/* Put a graphics character onto the screen */
void
amii_putsym( st, i, y, c )
winid st;
int i, y;
CHAR_P c;
amii_putsym(st, i, y, c)
winid st;
int i, y;
CHAR_P c;
{
amii_curs( st, i, y );
amii_curs(st, i, y);
Text(amii_wins[st]->win->RPort, &c, 1);
}
@@ -421,33 +397,32 @@ amii_putsym( st, i, y, c )
void
amii_addtopl(s)
const char *s;
const char *s;
{
register struct amii_WinDesc *cw = amii_wins[WIN_MESSAGE];
while(*s) {
if(cw->curx == cw->cols - 1)
amii_putstr(WIN_MESSAGE, 0, "");
amii_putsym(WIN_MESSAGE, cw->curx + 1, amii_msgborder(cw->win), *s++);
cw->curx++;
while (*s) {
if (cw->curx == cw->cols - 1)
amii_putstr(WIN_MESSAGE, 0, "");
amii_putsym(WIN_MESSAGE, cw->curx + 1, amii_msgborder(cw->win), *s++);
cw->curx++;
}
}
void
TextSpaces( rp, nr )
struct RastPort *rp;
int nr;
TextSpaces(rp, nr)
struct RastPort *rp;
int nr;
{
if( nr < 1 )
return;
if (nr < 1)
return;
while (nr > sizeof(spaces) - 1)
{
Text(rp, spaces, (long)sizeof(spaces) - 1);
nr -= sizeof(spaces) - 1;
while (nr > sizeof(spaces) - 1) {
Text(rp, spaces, (long) sizeof(spaces) - 1);
nr -= sizeof(spaces) - 1;
}
if (nr > 0)
Text(rp, spaces, (long)nr);
Text(rp, spaces, (long) nr);
}
void
@@ -465,60 +440,55 @@ amii_doprev_message()
struct Window *w;
char *str;
if( WIN_MESSAGE == WIN_ERR ||
( cw = amii_wins[ WIN_MESSAGE ] ) == NULL || ( w = cw->win ) == NULL )
{
panic(winpanicstr,WIN_MESSAGE, "doprev_message");
if (WIN_MESSAGE == WIN_ERR || (cw = amii_wins[WIN_MESSAGE]) == NULL
|| (w = cw->win) == NULL) {
panic(winpanicstr, WIN_MESSAGE, "doprev_message");
}
/* When an interlaced/tall screen is in use, the scroll bar will be there */
/* When an interlaced/tall screen is in use, the scroll bar will be there
*/
/* Or in some other cases as well */
if( scrollmsg )
{
struct Gadget *gd;
struct PropInfo *pip;
int hidden, topidx, i, total, wheight;
if (scrollmsg) {
struct Gadget *gd;
struct PropInfo *pip;
int hidden, topidx, i, total, wheight;
for( gd = w->FirstGadget; gd && gd->GadgetID != 1; )
gd = gd->NextGadget;
for (gd = w->FirstGadget; gd && gd->GadgetID != 1;)
gd = gd->NextGadget;
if( gd )
{
pip = (struct PropInfo *)gd->SpecialInfo;
wheight = ( w->Height - w->BorderTop -
w->BorderBottom - 2 ) / w->RPort->TxHeight;
hidden = max( cw->maxrow - wheight, 0 );
topidx = (((ULONG)hidden * pip->VertPot) + (MAXPOT/2)) >> 16;
for( total = i = 0; i < cw->maxrow; ++i )
{
if( cw->data[i][1] != 0 )
++total;
}
if (gd) {
pip = (struct PropInfo *) gd->SpecialInfo;
wheight = (w->Height - w->BorderTop - w->BorderBottom - 2)
/ w->RPort->TxHeight;
hidden = max(cw->maxrow - wheight, 0);
topidx = (((ULONG) hidden * pip->VertPot) + (MAXPOT / 2)) >> 16;
for (total = i = 0; i < cw->maxrow; ++i) {
if (cw->data[i][1] != 0)
++total;
}
i = 0;
topidx -= wheight/4 + 1;
if (topidx < 0)
topidx = 0;
SetPropInfo( w, &MsgScroll, wheight, total, topidx );
DisplayData( WIN_MESSAGE, topidx );
}
return(0);
i = 0;
topidx -= wheight / 4 + 1;
if (topidx < 0)
topidx = 0;
SetPropInfo(w, &MsgScroll, wheight, total, topidx);
DisplayData(WIN_MESSAGE, topidx);
}
return (0);
}
if( --cw->vwy < 0 )
{
cw->maxcol = 0;
DisplayBeep( NULL );
str = "\0\0No more history saved...";
}
else
str = cw->data[ cw->vwy ];
if (--cw->vwy < 0) {
cw->maxcol = 0;
DisplayBeep(NULL);
str = "\0\0No more history saved...";
} else
str = cw->data[cw->vwy];
amii_cl_end(cw, 0);
amii_curs( WIN_MESSAGE, 1, 0 );
amii_setdrawpens( amii_wins[WIN_MESSAGE]->win, NHW_MESSAGE );
Text(w->RPort,str+SOFF,strlen(str+SOFF));
amii_curs(WIN_MESSAGE, 1, 0);
amii_setdrawpens(amii_wins[WIN_MESSAGE]->win, NHW_MESSAGE);
Text(w->RPort, str + SOFF, strlen(str + SOFF));
cw->curx = cw->cols + 1;
return( 0 );
return (0);
}
+207 -197
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 xpm2iff.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 xpm2iff.c $NHDT-Date: 1431192783 2015/05/09 17:33:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.6 xpm2iff.c $Date: 2009/05/06 10:48:44 $ $Revision: 1.3 $ */
/* SCCS Id: @(#)xpm2iff.c 3.5 1995/08/04 */
/* Copyright (c) 1995 by Gregg Wonderly, Naperville, Illinois */
@@ -18,28 +18,28 @@
#include <libraries/iffparse.h>
#include <libraries/dos.h>
#ifndef _DCC
# include <proto/iffparse.h>
# include <proto/dos.h>
# include <proto/exec.h>
#include <proto/iffparse.h>
#include <proto/dos.h>
#include <proto/exec.h>
#endif
struct xpmscreen {
int Width;
int Height;
int Colors;
int ColorResolution;
int Background;
int AspectRatio;
int Interlace;
int BytesPerRow;
int Width;
int Height;
int Colors;
int ColorResolution;
int Background;
int AspectRatio;
int Interlace;
int BytesPerRow;
} XpmScreen;
/* translation table from xpm characters to RGB and colormap slots */
struct Ttable {
char flag;
char r,g,b;
int slot; /* output colortable index */
}ttable[256];
char flag;
char r, g, b;
int slot; /* output colortable index */
} ttable[256];
pixval ColorMap[3][MAXCOLORMAPSIZE];
int colorsinmap;
@@ -48,18 +48,20 @@ int colorsinmap;
* We are using a hybrid form of our own design which we call a BMAP (for
* bitmap) form. It is an ILBM with the bitmaps already deinterleaved,
* completely uncompressed.
* This speeds the loading of the images from the games point of view because it
* This speeds the loading of the images from the games point of view because
* it
* does not have to deinterleave and uncompress them.
*/
#define ID_BMAP MAKE_ID( 'B', 'M', 'A', 'P' ) /* instead of ILBM */
#define ID_BMHD MAKE_ID( 'B', 'M', 'H', 'D' ) /* Same as ILBM */
#define ID_CAMG MAKE_ID( 'C', 'A', 'M', 'G' ) /* Same as ILBM */
#define ID_CMAP MAKE_ID( 'C', 'M', 'A', 'P' ) /* Same as ILBM */
#define ID_PDAT MAKE_ID( 'P', 'D', 'A', 'T' ) /* Extra data describing plane
* size due to graphics.library
* rounding requirements.
*/
#define ID_PLNE MAKE_ID( 'P', 'L', 'N', 'E' ) /* The planes of the image */
#define ID_BMAP MAKE_ID('B', 'M', 'A', 'P') /* instead of ILBM */
#define ID_BMHD MAKE_ID('B', 'M', 'H', 'D') /* Same as ILBM */
#define ID_CAMG MAKE_ID('C', 'A', 'M', 'G') /* Same as ILBM */
#define ID_CMAP MAKE_ID('C', 'M', 'A', 'P') /* Same as ILBM */
#define ID_PDAT \
MAKE_ID('P', 'D', 'A', 'T') /* Extra data describing plane \
* size due to graphics.library \
* rounding requirements. \
*/
#define ID_PLNE MAKE_ID('P', 'L', 'N', 'E') /* The planes of the image */
int nplanes;
@@ -84,93 +86,86 @@ pixel pixels[TILE_Y][TILE_X];
AmiColorMap *cmap;
void
error( char *str )
error(char *str)
{
fprintf( stderr, "ERROR: %s\n", str );
fprintf(stderr, "ERROR: %s\n", str);
}
char **planes;
main( int argc, char **argv )
main(int argc, char **argv)
{
int colors;
struct {
long nplanes;
long pbytes;
long across;
long down;
long npics;
long xsize;
long ysize;
long nplanes;
long pbytes;
long across;
long down;
long npics;
long xsize;
long ysize;
} pdat;
long pbytes; /* Bytes of data in a plane */
long pbytes; /* Bytes of data in a plane */
int i, cnt;
BitMapHeader bmhd;
struct IFFHandle *iff;
long camg = HIRES|LACE;
int tiles=0;
long camg = HIRES | LACE;
int tiles = 0;
int index;
#if defined(_DCC) || defined (__GNUC__)
IFFParseBase = OpenLibrary( "iffparse.library", 0 );
if( !IFFParseBase ) {
error( "unable to open iffparse.library" );
exit( 1 );
#if defined(_DCC) || defined(__GNUC__)
IFFParseBase = OpenLibrary("iffparse.library", 0);
if (!IFFParseBase) {
error("unable to open iffparse.library");
exit(1);
}
#endif
if( fopen_xpm_file( argv[1], "r" ) != TRUE )
{
perror( argv[1] );
return( 1 );
if (fopen_xpm_file(argv[1], "r") != TRUE) {
perror(argv[1]);
return (1);
}
nplanes = 0;
i = XpmScreen.Colors - 1;
while( i != 0 )
{
nplanes++;
i >>= 1;
while (i != 0) {
nplanes++;
i >>= 1;
}
planes = malloc( nplanes * sizeof( char * ) );
if( planes == 0 )
{
error( "can not allocate planes pointer" );
exit( 1 );
planes = malloc(nplanes * sizeof(char *));
if (planes == 0) {
error("can not allocate planes pointer");
exit(1);
}
XpmScreen.BytesPerRow = ((XpmScreen.Width + 15)/16)*2;
XpmScreen.BytesPerRow = ((XpmScreen.Width + 15) / 16) * 2;
pbytes = XpmScreen.BytesPerRow * XpmScreen.Height;
for( i = 0; i < nplanes; ++i )
{
planes[ i ] = malloc( pbytes );
if( planes[ i ] == 0 )
{
error( "can not allocate planes pointer" );
exit( 1 );
}
memset( planes[i], 0, pbytes );
for (i = 0; i < nplanes; ++i) {
planes[i] = malloc(pbytes);
if (planes[i] == 0) {
error("can not allocate planes pointer");
exit(1);
}
memset(planes[i], 0, pbytes);
}
iff = AllocIFF();
if( !iff )
{
error( "Can not allocate IFFHandle" );
return( 1 );
if (!iff) {
error("Can not allocate IFFHandle");
return (1);
}
iff->iff_Stream = Open( argv[2], MODE_NEWFILE );
if( !iff->iff_Stream )
{
error( "Can not open output file" );
return( 1 );
iff->iff_Stream = Open(argv[2], MODE_NEWFILE);
if (!iff->iff_Stream) {
error("Can not open output file");
return (1);
}
InitIFFasDOS( iff );
OpenIFF( iff, IFFF_WRITE );
InitIFFasDOS(iff);
OpenIFF(iff, IFFF_WRITE);
PushChunk( iff, ID_BMAP, ID_FORM, IFFSIZE_UNKNOWN );
PushChunk(iff, ID_BMAP, ID_FORM, IFFSIZE_UNKNOWN);
bmhd.w = XpmScreen.Width;
bmhd.h = XpmScreen.Height;
@@ -183,35 +178,35 @@ main( int argc, char **argv )
bmhd.transparentColor = 0;
bmhd.xAspect = 100;
bmhd.yAspect = 100;
bmhd.pageWidth = 0; /* not needed for this program */
bmhd.pageHeight = 0; /* not needed for this program */
bmhd.pageWidth = 0; /* not needed for this program */
bmhd.pageHeight = 0; /* not needed for this program */
PushChunk( iff, ID_BMAP, ID_BMHD, sizeof( bmhd ) );
WriteChunkBytes( iff, &bmhd, sizeof( bmhd ) );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_BMHD, sizeof(bmhd));
WriteChunkBytes(iff, &bmhd, sizeof(bmhd));
PopChunk(iff);
PushChunk( iff, ID_BMAP, ID_CAMG, sizeof( camg ) );
WriteChunkBytes( iff, &camg, sizeof( camg ) );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_CAMG, sizeof(camg));
WriteChunkBytes(iff, &camg, sizeof(camg));
PopChunk(iff);
#define SCALE(x) (x)
cmap = malloc( (colors = (1L<<nplanes)) * sizeof(AmiColorMap) );
if(cmap == 0){
error("Can't allocate color map");
exit(1);
cmap = malloc((colors = (1L << nplanes)) * sizeof(AmiColorMap));
if (cmap == 0) {
error("Can't allocate color map");
exit(1);
}
for(index = 0; index<256; index++){
if(ttable[index].flag){
cmap[ttable[index].slot].r = SCALE(ttable[index].r);
cmap[ttable[index].slot].g = SCALE(ttable[index].g);
cmap[ttable[index].slot].b = SCALE(ttable[index].b);
}
for (index = 0; index < 256; index++) {
if (ttable[index].flag) {
cmap[ttable[index].slot].r = SCALE(ttable[index].r);
cmap[ttable[index].slot].g = SCALE(ttable[index].g);
cmap[ttable[index].slot].b = SCALE(ttable[index].b);
}
}
#undef SCALE
PushChunk( iff, ID_BMAP, ID_CMAP, IFFSIZE_UNKNOWN );
WriteChunkBytes( iff, cmap, colors*sizeof(*cmap) );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_CMAP, IFFSIZE_UNKNOWN);
WriteChunkBytes(iff, cmap, colors * sizeof(*cmap));
PopChunk(iff);
conv_image();
@@ -223,61 +218,63 @@ main( int argc, char **argv )
pdat.down = 0;
pdat.npics = 1;
PushChunk( iff, ID_BMAP, ID_PDAT, IFFSIZE_UNKNOWN );
WriteChunkBytes( iff, &pdat, sizeof( pdat ) );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_PDAT, IFFSIZE_UNKNOWN);
WriteChunkBytes(iff, &pdat, sizeof(pdat));
PopChunk(iff);
PushChunk( iff, ID_BMAP, ID_PLNE, IFFSIZE_UNKNOWN );
for( i = 0; i < nplanes; ++i )
WriteChunkBytes( iff, planes[i], pbytes );
PopChunk( iff );
PushChunk(iff, ID_BMAP, ID_PLNE, IFFSIZE_UNKNOWN);
for (i = 0; i < nplanes; ++i)
WriteChunkBytes(iff, planes[i], pbytes);
PopChunk(iff);
CloseIFF( iff );
Close( iff->iff_Stream );
FreeIFF( iff );
CloseIFF(iff);
Close(iff->iff_Stream);
FreeIFF(iff);
#if defined(_DCC) || defined (__GNUC__)
CloseLibrary( IFFParseBase );
#if defined(_DCC) || defined(__GNUC__)
CloseLibrary(IFFParseBase);
#endif
exit( 0 );
exit(0);
}
#define SETBIT(Plane, Plane_offset, Col, Value) \
if(Value){ \
planes[Plane][Plane_offset + (Col/8)] |= 1<<(7-(Col & 7)); \
}
#define SETBIT(Plane, Plane_offset, Col, Value) \
if (Value) { \
planes[Plane][Plane_offset + (Col / 8)] |= 1 << (7 - (Col & 7)); \
}
conv_image(){
conv_image()
{
int row, col, planeno;
for(row = 0;row<XpmScreen.Height;row++){
char *xb = xpmgetline();
int plane_offset;
if(xb==0)return;
plane_offset = row*XpmScreen.BytesPerRow;
for(col = 0;col<XpmScreen.Width;col++){
int slot;
int color = xb[col];
if(!ttable[color].flag){
fprintf(stderr, "Bad image data\n");
}
slot = ttable[color].slot;
for(planeno = 0; planeno<nplanes; planeno++){
SETBIT(planeno, plane_offset, col, slot & (1<<planeno));
}
}
for (row = 0; row < XpmScreen.Height; row++) {
char *xb = xpmgetline();
int plane_offset;
if (xb == 0)
return;
plane_offset = row * XpmScreen.BytesPerRow;
for (col = 0; col < XpmScreen.Width; col++) {
int slot;
int color = xb[col];
if (!ttable[color].flag) {
fprintf(stderr, "Bad image data\n");
}
slot = ttable[color].slot;
for (planeno = 0; planeno < nplanes; planeno++) {
SETBIT(planeno, plane_offset, col, slot & (1 << planeno));
}
}
}
}
long *
alloc( unsigned int n )
alloc(unsigned int n)
{
long *ret = malloc( n );
if(!ret){
error("Can't allocate memory");
exit(1);
long *ret = malloc(n);
if (!ret) {
error("Can't allocate memory");
exit(1);
}
return( ret );
return (ret);
}
FILE *xpmfh = 0;
@@ -287,69 +284,82 @@ char *xpmbuf = initbuf;
/* version 1. Reads the raw xpm file, NOT the compiled version. This is
* not a particularly good idea but I don't have time to do the right thing
* at this point, even if I was absolutely sure what that was. */
fopen_xpm_file(const char *fn, const char *mode){
int temp;
char *xb;
if(strcmp(mode, "r"))return FALSE; /* no choice now */
if(xpmfh)return FALSE; /* one file at a time */
xpmfh = fopen(fn, mode);
if(!xpmfh)return FALSE; /* I'm hard to please */
fopen_xpm_file(const char *fn, const char *mode)
{
int temp;
char *xb;
if (strcmp(mode, "r"))
return FALSE; /* no choice now */
if (xpmfh)
return FALSE; /* one file at a time */
xpmfh = fopen(fn, mode);
if (!xpmfh)
return FALSE; /* I'm hard to please */
/* read the header */
xb = xpmgetline();
if(xb == 0)return FALSE;
if(4 != sscanf(xb,"%d %d %d %d",
&XpmScreen.Width, &XpmScreen.Height,
&XpmScreen.Colors, &temp))return FALSE; /* bad header */
/* replace the original buffer with one big enough for
* the real data
*/
/* XXX */
xpmbuf = malloc(XpmScreen.Width * 2);
if(!xpmbuf){
error("Can't allocate line buffer");
exit(1);
}
if(temp != 1)return FALSE; /* limitation of this code */
/* read the header */
xb = xpmgetline();
if (xb == 0)
return FALSE;
if (4 != sscanf(xb, "%d %d %d %d", &XpmScreen.Width, &XpmScreen.Height,
&XpmScreen.Colors, &temp))
return FALSE; /* bad header */
/* replace the original buffer with one big enough for
* the real data
*/
/* XXX */
xpmbuf = malloc(XpmScreen.Width * 2);
if (!xpmbuf) {
error("Can't allocate line buffer");
exit(1);
}
if (temp != 1)
return FALSE; /* limitation of this code */
{
/* read the colormap and translation table */
int ccount = -1;
while(ccount++ < (XpmScreen.Colors-1)){
char index;
int r, g, b;
xb = xpmgetline();
if(xb==0)return FALSE;
if(4 != sscanf(xb,"%c c #%2x%2x%2x",&index,&r,&g,&b)){
fprintf(stderr,"Bad color entry: %s\n",xb);
return FALSE;
}
ttable[index].flag = 1; /* this color is valid */
ttable[index].r = r;
ttable[index].g = g;
ttable[index].b = b;
ttable[index].slot = ccount;
}
}
return TRUE;
{
/* read the colormap and translation table */
int ccount = -1;
while (ccount++ < (XpmScreen.Colors - 1)) {
char index;
int r, g, b;
xb = xpmgetline();
if (xb == 0)
return FALSE;
if (4 != sscanf(xb, "%c c #%2x%2x%2x", &index, &r, &g, &b)) {
fprintf(stderr, "Bad color entry: %s\n", xb);
return FALSE;
}
ttable[index].flag = 1; /* this color is valid */
ttable[index].r = r;
ttable[index].g = g;
ttable[index].b = b;
ttable[index].slot = ccount;
}
}
return TRUE;
}
/* This deserves better. Don't read it too closely - you'll get ill. */
#define bufsz 2048
char buf[bufsz];
xpmgetline(){
char *bp;
do {
if(fgets(buf, bufsz, xpmfh) == 0)return 0;
} while(buf[0] != '"');
/* strip off the trailing <",> if any */
for(bp = buf;*bp;bp++);
bp--;
while(isspace(*bp))bp--;
if(*bp==',')bp--;
if(*bp=='"')bp--;
bp++;
*bp = '\0';
xpmgetline()
{
char *bp;
do {
if (fgets(buf, bufsz, xpmfh) == 0)
return 0;
} while (buf[0] != '"');
/* strip off the trailing <",> if any */
for (bp = buf; *bp; bp++)
;
bp--;
while (isspace(*bp))
bp--;
if (*bp == ',')
bp--;
if (*bp == '"')
bp--;
bp++;
*bp = '\0';
return &buf[1];
return &buf[1];
}