[Scummvm-cvs-logs] CVS: tools descumm.cpp,1.4,1.5 descumm6.cpp,1.90,1.91
Max Horn
fingolfin at users.sourceforge.net
Sun May 4 06:28:37 CEST 2003
Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1:/tmp/cvs-serv7438
Modified Files:
descumm.cpp descumm6.cpp
Log Message:
some unification work
Index: descumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- descumm.cpp 4 May 2003 13:11:33 -0000 1.4
+++ descumm.cpp 4 May 2003 13:19:42 -0000 1.5
@@ -20,19 +20,51 @@
*
*/
-#include <string.h>
-#include <stdio.h>
-
-//#ifdef UNIX
+#include <assert.h>
#include <ctype.h>
-//#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#ifdef WIN32
#include <io.h>
#include <process.h>
#endif
-#include <stdlib.h>
+
+
+typedef unsigned char byte;
+typedef unsigned char uint8;
+typedef unsigned short uint16;
+typedef unsigned int uint32;
+typedef unsigned int uint;
+typedef signed char int8;
+typedef signed short int16;
+typedef signed int int32;
+
+uint32 inline SWAP_32(uint32 a)
+{
+ return ((a >> 24) & 0xFF) + ((a >> 8) & 0xFF00) + ((a << 8) & 0xFF0000) +
+ ((a << 24) & 0xFF000000);
+}
+
+uint16 inline SWAP_16(uint16 a)
+{
+ return ((a >> 8) & 0xFF) + ((a << 8) & 0xFF00);
+}
+
+#if defined(SCUMM_BIG_ENDIAN)
+#define TO_BE_16(x) (x)
+#define TO_BE_32(x) (x)
+#define TO_LE_16(x) SWAP_16(x)
+#define TO_LE_32(x) SWAP_32(x)
+#else
+#define TO_BE_16(x) SWAP_16(x)
+#define TO_BE_32(x) SWAP_32(x)
+#define TO_LE_16(x) (x)
+#define TO_LE_32(x) (x)
+#endif
+
#define A1B (1<<0)
#define A1W (2<<0)
@@ -67,16 +99,12 @@
#define AVARSTORE (1<<27)
#define MKID(a) (((a&0xff) << 8) | ((a >> 8)&0xff))
-#define uchar unsigned char
-#define uint unsigned int
-#define ushort unsigned short
-typedef unsigned char byte;
void get_tok_V2(char *buf); // For V2 (and V1?)
void get_tok(char *buf); // For V3, V4, V5
-#define JUMP_OPCODE 0x18
+const int g_jump_opcode = 0x18;
byte *cur_pos, *org_pos;
int curoffs;
@@ -117,34 +145,6 @@
bool emit_if(char *before, char *after);
-unsigned long inline SWAP_32(unsigned long a)
-{
- return ((a >> 24) & 0xFF) + ((a >> 8) & 0xFF00) + ((a << 8) & 0xFF0000) +
- ((a << 24) & 0xFF000000);
-}
-
-unsigned short inline SWAP_16(unsigned short a)
-{
- return ((a >> 8) & 0xFF) + ((a << 8) & 0xFF00);
-}
-
-#if defined(SCUMM_BIG_ENDIAN)
-
-#define TO_LE_16(x) SWAP_16(x)
-#define TO_LE_32(x) SWAP_32(x)
-#define TO_BE_16(x) (x)
-#define TO_BE_32(x) (x)
-
-#else
-
-#define TO_LE_16(x) (x)
-#define TO_LE_32(x) (x)
-#define TO_BE_16(x) SWAP_16(x)
-#define TO_BE_32(x) SWAP_32(x)
-
-
-#endif
-
int get_byte()
{
return (byte)(*cur_pos++);
@@ -498,7 +498,7 @@
if (k < 0 || k >= size_of_code)
return 0; /* Invalid jump */
- if (org_pos[k] != JUMP_OPCODE)
+ if (org_pos[k] != g_jump_opcode)
return 0; /* Invalid jump */
k = to + *((short *)(org_pos + k + 1));
@@ -3181,9 +3181,9 @@
if (GF_UNBLOCKED) {
mem += 4;
} else if (ScriptVersion == 5) {
- switch (TO_BE_32(*((unsigned long *)mem))) {
+ switch (TO_BE_32(*((uint32 *)mem))) {
case 'LSCR':
- printf("Script# %d\n", (unsigned char)mem[8]);
+ printf("Script# %d\n", (byte)mem[8]);
mem += 9;
break; /* Local script */
case 'SCRP':
@@ -3203,9 +3203,9 @@
exit(0);
}
} else {
- switch (TO_LE_16(*((unsigned short *)mem + 2))) {
+ switch (TO_LE_16(*((uint16 *)mem + 2))) {
case MKID('LS'):
- printf("Script# %d\n", (unsigned char)mem[8]);
+ printf("Script# %d\n", (byte)mem[8]);
mem += 7;
break; /* Local script */
case MKID('SC'):
Index: descumm6.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm6.cpp,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- descumm6.cpp 28 Mar 2003 22:45:23 -0000 1.90
+++ descumm6.cpp 4 May 2003 13:19:42 -0000 1.91
@@ -1,6 +1,6 @@
-/* DeScumm - Scumm Script Disassembler (version 6 scripts)
+/* DeScumm - Scumm Script Disassembler (version 6-8 scripts)
* Copyright (C) 2001 Ludvig Strigeus
- * Copyright (C) 2002 The ScummVM Team
+ * Copyright (C) 2002, 2003 The ScummVM Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -20,18 +20,17 @@
*
*/
-#include <string.h>
-#include <stdio.h>
+#include <assert.h>
#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#ifdef WIN32
#include <io.h>
#include <process.h>
#endif
-#include <stdlib.h>
-#include <assert.h>
-
/*
switch/case statements have a pattern that look as follows (they were probably
generated by some Scumm script compiler):
@@ -76,8 +75,6 @@
typedef signed short int16;
typedef signed int int32;
-int g_jump_opcode = 0x66;
-
uint32 inline SWAP_32(uint32 a)
{
return ((a >> 24) & 0xFF) + ((a >> 8) & 0xFF00) + ((a << 8) & 0xFF0000) +
@@ -101,6 +98,10 @@
#define TO_LE_16(a) (a)
#endif
+
+
+int g_jump_opcode = 0x66;
+
struct StackEnt {
byte type;
long data;
@@ -2873,7 +2874,7 @@
output = buf = (char *)malloc(8192);
- switch (TO_BE_32(*((long *)mem))) {
+ switch (TO_BE_32(*((uint32 *)mem))) {
case 'LSCR':
if (scriptVersion == 8) {
printf("Script# %d\n", TO_LE_32(*((int32 *)(mem+8))));
@@ -2882,7 +2883,7 @@
printf("Script# %d\n", TO_LE_16(*((int16 *)(mem+8))));
mem += 10;
} else {
- printf("Script# %d\n", (unsigned char)mem[8]);
+ printf("Script# %d\n", (byte)mem[8]);
mem += 9;
}
break; /* Local script */
More information about the Scummvm-git-logs
mailing list