Oops.
[AROS-Contrib.git] / Games / Doom / m_cheat.c
blobffe58d6d5dac6219ae85322878fb37148d7d004a
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id$
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 //
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
15 // for more details.
17 // $Log$
18 // Revision 1.1 2000/02/29 18:21:04 stegerg
19 // Doom port based on ADoomPPC. Read README.AROS!
22 // DESCRIPTION:
23 // Cheat sequence checking.
25 //-----------------------------------------------------------------------------
28 static const char
29 rcsid[] = "$Id$";
31 #include "m_cheat.h"
34 // CHEAT SEQUENCE PACKAGE
37 static int firsttime = 1;
38 static unsigned char cheat_xlate_table[256];
42 // Called in st_stuff module, which handles the input.
43 // Returns a 1 if the cheat was successful, 0 if failed.
45 int
46 cht_CheckCheat
47 ( cheatseq_t* cht,
48 char key )
50 int i;
51 int rc = 0;
53 if (firsttime)
55 firsttime = 0;
56 for (i=0;i<256;i++) cheat_xlate_table[i] = SCRAMBLE(i);
59 if (!cht->p)
60 cht->p = cht->sequence; // initialize if first time
62 if (*cht->p == 0)
63 *(cht->p++) = key;
64 else if
65 (cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++;
66 else
67 cht->p = cht->sequence;
69 if (*cht->p == 1)
70 cht->p++;
71 else if (*cht->p == 0xff) // end of sequence character
73 cht->p = cht->sequence;
74 rc = 1;
77 return rc;
80 void
81 cht_GetParam
82 ( cheatseq_t* cht,
83 char* buffer )
86 unsigned char *p, c;
88 p = cht->sequence;
89 while (*(p++) != 1);
93 c = *p;
94 *(buffer++) = c;
95 *(p++) = 0;
97 while (c && *p!=0xff );
99 if (*p==0xff)
100 *buffer = 0;