diff --git a/cseries.lib/beta.h b/cseries.lib/beta.h new file mode 100644 index 0000000..dfa0804 --- /dev/null +++ b/cseries.lib/beta.h @@ -0,0 +1,5 @@ +#define DEBUG + +//#define ALPHA +#define BETA +//#define FINAL diff --git a/cseries.lib/buildprogram b/cseries.lib/buildprogram new file mode 100644 index 0000000..2e84172 --- /dev/null +++ b/cseries.lib/buildprogram @@ -0,0 +1,113 @@ +# BuildProgram - build the specified program +# +# Usage: +# BuildProgram program [options…] > log +# +# The BuildProgram script builds the specified program (or target). +# A simple transcript of the build is written to standard output. +# +# Make is used to generate the build commands. If file .make +# exists it is used as the makefile. If not, file MakeFile is used. +# +# The options specified are passed directly to Make, and control the +# generation of the build commands. +# +# +# Copyright Apple Computer, Inc. 1987 - 1992 +# All rights reserved. + +Set Exit 1 + +# Find the program parameter. + +Unset program +For i In {"Parameters"} + If "{i}" !~ /-≈/ + Set program "{i}" + Break + End +End + +if "{program}"=="cseries"||"{program}"=="cseries.lib"||"{program}"=="cseries.xcoff" + # final build for PPC + Set PPCCOptions "-i ∂"{CSeriesInterfaces}∂" -typecheck relaxed -opt speed" + Set ObjPPC :objects:ppc: + Set TargPPC cseries.xcoff + Set OptimizationsPPC "-opt size" + Set SymbolsPPC "-sym off" + + # final build for 68k + Set COptions "-opt full -b2 -r -mbg off -k ∂"{CSeriesLibraries}∂"" + Set Obj68k :Objects:68k: + Set Targ68k cseries.lib + +else if "{program}"=="cseries.debug"||"{program}"=="cseries.debug.lib"||"{program}"=="cseries.debug.xcoff" + # debug build for PPC + Set PPCCOptions "-i ∂"{CSeriesInterfaces}∂" -typecheck relaxed -sym on -d DEBUG" + Set ObjPPC :Objects:ppc.debug: + Set TargPPC cseries.debug.xcoff + Set OptimizationsPPC "-opt size" + Set SymbolsPPC "-sym off" + + # debug build for 68k + Set COptions "-opt full -b2 -r -mbg on -d DEBUG -k ∂"{CSeriesLibraries}∂"" + Set Obj68k :Objects:68k.debug: + Set Targ68k cseries.debug.lib + +else if "{program}"=="cseries.sym"||"{program}"=="cseries.sym.xcoff" + # debug build with symbols for PPC + Set PPCCOptions "-i {CSeriesInterfaces} -typecheck relaxed -sym on -d DEBUG" + Set ObjPPC :Objects:ppc.sym: + Set TargPPC cseries.sym.xcoff + Set OptimizationsPPC "-opt off" + Set SymbolsPPC "-sym on" + + # debug build for 68k + Set COptions "-opt full -b2 -r -mbg on -d DEBUG -k ∂"{CSeriesLibraries}∂"" + Set Obj68k :Objects:68k.debug: + Set Targ68k cseries.debug.lib +#else +# echo bad target +# exit 1 +end + +if ({MakeVulcan} == 1) && ({MakeModelFar} == 1) + set COptions "{COptions}"" -model far" +end + +#for PPC +Export PPCCOptions +Export ObjPPC +Export TargPPC +Export OptimizationsPPC +Export SymbolsPPC + +#for 68k +Export COptions +Export Obj68k +Export Targ68k + +Set makefile `(Files -t TEXT "{program}".make || ∂ + Files -t TEXT MakeFile || Echo '""') ≥ Dev:Null` +If "{makefile}" == "" + Echo "### {0} - No makefile exists for {program}." > Dev:StdErr + Exit 1 +End + +# Run Make, then execute its output. + +Echo "# `Date -t` ----- Build of {program}." +Echo "# `Date -t` ----- Analyzing dependencies." +Begin + Echo "Set Echo 1" + Make {"Parameters"} -f "{makefile}" +End > "{program}".makeout +Echo "# `Date -t` ----- Executing build commands." +"{program}".makeout +Delete "{program}".makeout +Echo "# `Date -t` ----- Done." +Set type "`files -i -n -x t "{program}" ≥ Dev:Null || Set Status 0`" +Set CaseSensitive True #filetype check for DA must be case sensitive +If "{type}" =~ /≈ APPL/ OR "{type}" =~ /≈ MPST/ # application or tool + Echo -n ∂t; Quote -n "{program}"; Echo -n " " +End diff --git a/cseries.lib/byte_swapping.c b/cseries.lib/byte_swapping.c new file mode 100644 index 0000000..76120b1 --- /dev/null +++ b/cseries.lib/byte_swapping.c @@ -0,0 +1,104 @@ +/* +BYTE_SWAPPING.C +Tuesday, August 22, 1995 8:58:12 AM (Jason) +*/ + +#include "cseries.h" + +#include "byte_swapping.h" + +/* ---------- code */ + +void byte_swap_memory( + void *data, + _bs_field type, + long nmemb) +{ + switch (type) + { + case _2byte: + { + word *ptr= data; + + for (; nmemb>0; --nmemb) + { + word q= *ptr; + *ptr++= SWAP2(q); + } + + break; + } + case _4byte: + { + unsigned long *ptr= data; + + for (; nmemb>0; --nmemb) + { + unsigned long q= *ptr; + *ptr++= SWAP4(q); + } + + break; + } + + default: + halt(); + } + + return; +} + +void byte_swap_data( + byte *data, + long size, + long nmemb, + _bs_field *fields) +{ + long i; + + for (i= 0; i>8) | (((q)<<8)&0xff00)) +#define SWAP4(q) (((q)>>24) | (((q)>>8)&0xff00) | (((q)<<8)&0x00ff00) | (((q)<<24)&0xff000000)) + +/* ---------- types */ + +typedef short _bs_field; + +/* ---------- prototypes/BYTE_SWAPPING.H */ + +#ifdef mac +#define byte_swap_data(data, size, nmemb, fields) +#define byte_swap_memory(data, type, nmemb) +#endif + +#ifdef win +void byte_swap_data(void *data, long size, long nmemb, _bs_field *fields); +void byte_swap_memory(void *data, _bs_field type, long nmemb); +#endif diff --git a/cseries.lib/checksum.c b/cseries.lib/checksum.c new file mode 100644 index 0000000..f2f0496 --- /dev/null +++ b/cseries.lib/checksum.c @@ -0,0 +1,112 @@ +/* +checksum.c +Thursday, March 10, 1994 8:21:23 PM + written by ajr +*/ + +#include /* for srand() and rand() */ +#include /* for clock() */ + +#include "cseries.h" + +#include "checksum.h" + +// private prototypes +void update_add_checksum(Checksum *check, word *src, long length); + +/********************************************************************************** + * + * Function: new_checksum + * Purpose: initialize the checksum data structure. + * + **********************************************************************************/ +void new_checksum(Checksum *check, word type) +{ + // set up bogus stuff in the checksum, so when it's saved, it's a + // bit obfuscated. + srand(clock()); + check->bogus1 = rand(); + check->bogus2 = rand(); + + assert(type == ADD_CHECKSUM); + + check->checksum_type = type; + + switch (check->checksum_type) + { + case ADD_CHECKSUM: + check->value.add_checksum = 0; + break; + case FLETCHER_CHECKSUM: + case CRC32_CHECKSUM: + default: + halt(); + break; + } +} + +/********************************************************************************** + * + * Function: update_checksum + * Purpose: takes the given checksum and updates it for the extra stuff. + * + **********************************************************************************/ +void update_checksum(Checksum *check, word *src, long length) +{ + switch (check->checksum_type) + { + case ADD_CHECKSUM: + update_add_checksum(check, src, length); + break; + case FLETCHER_CHECKSUM: + case CRC32_CHECKSUM: + default: + halt(); + break; + } +} + +/********************************************************************************** + * + * Function: update_add_checksum + * Purpose: called by update_checksum to take the given checksum and add all + * the stuff in src to it. + * + **********************************************************************************/ +void update_add_checksum(Checksum *check, word *src, long length) +{ + long i; + long real_length; + + if (length % 2) // is it odd? + length--; // make it even. ignore last byte. + + real_length = length / sizeof(word); // duh + + for (i = 0; i < real_length; i++) + { + check->value.add_checksum += *(src+i); + } +} + +/********************************************************************************** + * + * Function: equal_checksums + * Purpose: decide if 2 checksums are the same. wow. + * + **********************************************************************************/ +boolean equal_checksums(Checksum *check1, Checksum *check2) +{ + assert(check1->checksum_type == check2->checksum_type); + switch(check1->checksum_type) + { + case ADD_CHECKSUM: + return (check1->value.add_checksum == check2->value.add_checksum); + break; + case FLETCHER_CHECKSUM: + case CRC32_CHECKSUM: + default: + halt(); // not implemented yet. + break; + } +} \ No newline at end of file diff --git a/cseries.lib/checksum.h b/cseries.lib/checksum.h new file mode 100644 index 0000000..5f76382 --- /dev/null +++ b/cseries.lib/checksum.h @@ -0,0 +1,41 @@ +#ifndef __CHECKSUM_H +#define __CHECKSUM_H + +/* +checksum.h +Thursday, March 10, 1994 8:06:07 PM + written by ajr +*/ + +// To add extra checksum types, the following enum and struct need to be expanded. +enum +{ + ADD_CHECKSUM, + FLETCHER_CHECKSUM, + CRC32_CHECKSUM +}; + +#ifdef envppc +#pragma options align=mac68k +#endif +typedef struct +{ + long bogus1; // meant for obfuscating saved resource + word checksum_type; // one of enums above + union { // value of the checksum; which one depends on checksum_type + word add_checksum; + word fletcher_checksum; + long crc32_checksum; + } value; + long bogus2; // meant for obfuscating saved resource +} Checksum; +#ifdef envppc +#pragma options align=reset +#endif + +// function prototypes +void new_checksum(Checksum *check, word type); +void update_checksum(Checksum *check, word *src, long length); +boolean equal_checksums(Checksum *check1, Checksum *check2); + +#endif diff --git a/cseries.lib/cseries.a b/cseries.lib/cseries.a new file mode 100644 index 0000000..f16b4bd --- /dev/null +++ b/cseries.lib/cseries.a @@ -0,0 +1,61 @@ +* ------------- GENERATE DEBUGGER SYMBOL INFORMATION ------------- +* This Macro will generate information for the debugger to read and display +* as its module name. This aids in debugging Asm code while looking at it +* in the debugger. This macro can only work if called at the end of stack +* frame. The appearance of the Macro statement in the source code must occur +* immediately after the final "JMP (A0)" or "RTS" instruction following the UNLINK. +* Spaces may be included in the name, but no quotes are allowed. + +* {Form #1} DbgInfo ModName +* {Form #2} DbgInfo.New Really Long Module Name For MacsBug 6.0 + +* There are now two naming conventions used in MacsBug, Form #1 is the older MacsBug, +* or TMON, and Form #2 is the newer MacsBug 6.0. The older method would only +* allow for a fixed length of eight characters. If a shorter name is passed to +* this Macro, it will extend the length to 8 chars with trailing spaces. +* MacsBug 6.0 will now allow for a variable length C type string. This Macro will +* create the proper DC statements and takes into account word alignment issues. + + + MACRO + symbol &ModName#,&SizeOfLiterals#:INT + PRINT Push,NoMDir ; Only list generated code + LCLC &DbgName# ; name to generate for MacsBug + LCLC &DbgTemp ; temporary name variable + LCLC &S ; variable used to save PRINT state + + IF DEBUG THEN ; do we want debugging info? + IF &ModName# ≠ '' THEN ; did we get a module name? + +.* Create the new MacsBug naming convention +* ----------------------------------------------- + &DbgTemp: SETC &ModName# ; generate new type symbols + IF &Len(&ModName#) < 32 THEN ; if module name < 32 chars + IF &Len(&ModName#) // 2 = 0 THEN ; add space if even so that... + &DbgTemp: SETC &Concat(&ModName#,' ') ; string length plus length byte... + ENDIF ; will align to word boundary + &DbgName#: SETC &Concat(&Chr($80 + &Len(&ModName#)), &DbgTemp) + ELSE ; Length > 32 characters + IF &Len(&ModName#) // 2 = 1 THEN ; add space if length is odd + &DbgTemp: SETC &Concat(&ModName#,' ') + ENDIF + &DbgName#: SETC &Concat(&Chr($80), &Chr(&Len(&ModName#)), &DbgTemp) + ENDIF + +.* Create the DC.B with the debugger name, and include the NULs if new MacsBug option +* ----------------------------------------------- + &S: SETC &Setting('STRING') ; preserve STRING status + IF &S ≠ 'ASIS' THEN ; only change it if not already ASIS + STRING ASIS + DC.B '&DbgName#' + DC.W &SizeOfLiterals# + STRING &S + ELSE + DC.B '&DbgName#' + DC.W &SizeOfLiterals# + ENDIF + ENDIF + ENDIF + + PRINT Pop ; restore original print status + ENDM diff --git a/cseries.lib/cseries.h b/cseries.lib/cseries.h new file mode 100644 index 0000000..f16367f --- /dev/null +++ b/cseries.lib/cseries.h @@ -0,0 +1,194 @@ +#ifndef __CSERIES_H +#define __CSERIES_H + +/* +CSERIES.H +Wednesday, December 26, 1990 8:24:58 PM + +This is the new global header file for all code which does not rely specifically on +the Macintosh OS. + +Tuesday, June 25, 1991 1:53:12 AM + changes to assert() macro so that we can actually trap errors using assert (ie. + we differentiate between fatal and non-fatal asserts and provide information as + to the exact nature of the error). +Thursday, July 18, 1991 11:25:32 AM + that was a bad idea. We don’t do that anymore. +Friday, August 9, 1991 11:16:28 PM + removed random() prototype; this is up to the application (for Minotaur). +Friday, December 20, 1991 3:21:10 PM + error handling sucks; soon we need to perfect a better scheme. +Monday, May 18, 1992 7:52:19 PM + added portable memory primitives; pointers and handles. +Friday, August 21, 1992 8:11:56 PM + removed error codes, this will piss-off minotaur. +Tuesday, September 21, 1993 3:35:23 PM + MIN, MAX macros added. more fixed math definitions added. added rsprintf and getcstr. +Sunday, February 6, 1994 11:07:52 AM + we don't override malloc and free anymore (use new_pointer and new_handle for portability). +*/ + +#include +#include + +#ifdef powerc + #define envppc + #define mpwppc +#else + #define env68k + #define mpwc +#endif + +/* ---------- constants */ + +#ifndef TRUE /* For compatibility with PowerPlant's headers, we need the ifndef */ + #define TRUE 1 +#endif +#ifndef FALSE + #define FALSE 0 +#endif + +#define NONE -1 + +#define KILO 1024 +#define MEG (KILO*KILO) +#define GIG (KILO*MEG) + +#define MACHINE_TICKS_PER_SECOND 60 + +/* ---------- macros */ + +#ifdef DEBUG + #define halt() _assertion_failure((char *)NULL, __FILE__, __LINE__, TRUE) + #define vhalt(diag) _assertion_failure(diag, __FILE__, __LINE__, TRUE) + #define assert(expr) if (!(expr)) _assertion_failure(#expr, __FILE__, __LINE__, TRUE) + #define vassert(expr,diag) if (!(expr)) _assertion_failure(diag, __FILE__, __LINE__, TRUE) + #define warn(expr) if (!(expr)) _assertion_failure(#expr, __FILE__, __LINE__, FALSE) + #define vwarn(expr,diag) if (!(expr)) _assertion_failure(diag, __FILE__, __LINE__, FALSE) + #define pause() _assertion_failure((char *)NULL, __FILE__, __LINE__, FALSE) + #define vpause(diag) _assertion_failure(diag, __FILE__, __LINE__, FALSE) +#else + #define halt() + #define vhalt(diag) + #define assert(expr) + #define vassert(expr,diag) + #define warn(expr) + #define vwarn(expr,diag) + #define pause() + #define vpause(diag) +#endif + +#define SGN(x) ((x)?((x)<0?-1:1):0) + +#define SWAP(a,b) a^= b, b^= a, a^= b + +#define ABS(x) ((x>=0) ? (x) : -(x)) + +#define MIN(a,b) ((a)>(b)?(b):(a)) +#define MAX(a,b) ((a)>(b)?(a):(b)) + +#define FLOOR(n,floor) ((n)<(floor)?(floor):(n)) +#define CEILING(n,ceiling) ((n)>(ceiling)?(ceiling):(n)) +#define PIN(n,floor,ceiling) ((n)<(floor) ? (floor) : CEILING(n,ceiling)) + +#define compact_array(array, element, nmemb, size) if ((element)<(nmemb)-1) \ + memcpy(((byte*)(array))+(element)*(size), ((byte*)(array))+((element)+1)*(size), ((nmemb)-(element)-1)*(size)) + +#define FLAG(b) (1<<(b)) + +#define TEST_FLAG16(f, b) ((f)&(word)FLAG(b)) +#define SWAP_FLAG16(f, b) ((f)^=(word)FLAG(b)) +#define SET_FLAG16(f, b, v) ((v) ? ((f)|=(word)FLAG(b)) : ((f)&=(word)~FLAG(b))) + +#define TEST_FLAG32(f, b) ((f)&(unsigned long)FLAG(b)) +#define SWAP_FLAG32(f, b) ((f)^=(unsigned long)FLAG(b)) +#define SET_FLAG32(f, b, v) ((v) ? ((f)|=(unsigned long)FLAG(b)) : ((f)&=(unsigned long)~FLAG(b))) + +/* ---------- fixed math */ + +#define FIXED_FRACTIONAL_BITS 16 +#define FIXED_ONE ((fixed)(1<>FIXED_FRACTIONAL_BITS)) +#define FIXED_TO_INTEGER(f) FIXED_INTEGERAL_PART(f) +#define FIXED_TO_INTEGER_ROUND(f) FIXED_INTEGERAL_PART((f)+FIXED_ONE_HALF) +#define FIXED_FRACTIONAL_PART(f) (((fixed)(f))&(FIXED_ONE-1)) + +typedef long fixed; + +/* ---------- types */ + +typedef unsigned short word; +typedef unsigned char byte; +typedef byte boolean; + +typedef void *handle; // relocatable malloc + +/* ---------- limits */ + +enum +{ + UNSIGNED_LONG_MAX= 4294967295, + LONG_MAX= 2147483647L, + LONG_MIN= (-2147483648L), + LONG_BITS= 32, + + UNSIGNED_SHORT_MAX= 65535, + SHORT_MAX= 32767, + SHORT_MIN= (-32768), + SHORT_BITS= 16, + + UNSIGNED_CHAR_MAX= 255, + CHAR_MAX= 127, + CHAR_MIN= (-128), + CHAR_BITS= 8 +}; + +/* ---------- globals */ + +extern char temporary[256]; + +/* ---------- prototypes */ + +unsigned long machine_tick_count(void); + +char *strupr(char *string); +char *strlwr(char *string); + +void _assertion_failure(char *assertion, char *file, int line, boolean fatal); + +#define malloc(size) new_pointer(size) +#define free(ptr) dispose_pointer(ptr) +void *new_pointer(long size); +void dispose_pointer(void *pointer); + +#if 0 +handle rmalloc(size); +void rfree(handle h); +void *rlock(handle h); +void runlock(handle h); +#endif + +enum // for alert_user +{ + fatalError, + infoError +}; + +void alert_user(short type, short resource_number, short error_number, short identifier); + +char *getcstr(char *buffer, short collection_number, short string_number); + +boolean toggle_debug_status(void); + +void initialize_debugger(boolean force_debugger_on); +int dprintf(const char *format, ...); +char *csprintf(char *buffer, char *format, ...); +int rsprintf(char *s, short resource_number, short string_number, ...); + +#endif diff --git a/cseries.lib/cseries.lib.make b/cseries.lib/cseries.lib.make deleted file mode 100644 index a418095..0000000 --- a/cseries.lib/cseries.lib.make +++ /dev/null @@ -1,54 +0,0 @@ -# CSERIES.LIB -# -------------------------------------------------------------- -# Thursday, July 11, 1991 11:30:44 AM -# Saturday, January 15, 1994 2:04:56 PM - -# Define our object file directory, and give a directory dependency rule -Obj= :Objects: -{Obj} ƒ : - -COptions= -opt full -b2 -r -mbg on -d DEBUG -k {CSeriesLibraries} -#COptions= -opt full -b2 -r -mbg off -k {CSeriesLibraries} -OBJECTS= {Obj}macintosh_utilities.c.o {Obj}my32bqd.c.o {Obj}rle.c.o {Obj}preferences.c.o {Obj}proximity_strcmp.c.o ∂ - {Obj}temporary_files.c.o {Obj}devices.c.o {Obj}dialogs.c.o - -macintosh_cseries.h ƒ cseries.h - -### Portable -{Obj}proximity_strcmp.c.o ƒ proximity_strcmp.h cseries.h cseries.lib.make -{Obj}rle.c.o ƒ rle.h cseries.h cseries.lib.make - -### Macintosh -{Obj}macintosh_utilities.c.o ƒ macintosh_cseries.h cseries.lib.make -{Obj}my32bqd.c.o ƒ my32bqd.h macintosh_cseries.h cseries.lib.make -{Obj}devices.c.o ƒ macintosh_cseries.h cseries.lib.make -{Obj}dialogs.c.o ƒ macintosh_cseries.h cseries.lib.make -{Obj}preferences.c.o ƒ preferences.h macintosh_cseries.h cseries.lib.make -{Obj}temporary_files.c.o ƒ temporary_files.h macintosh_cseries.h cseries.lib.make - -cseries.lib ƒƒ {OBJECTS} - Lib -o cseries.lib {OBJECTS} - Move -y cseries.lib {CSeriesLibraries} - -cseries.lib ƒƒ {CSeriesInterfaces}cseries.h {CSeriesInterfaces}my32bqd.h {CSeriesInterfaces}rle.h ∂ - {CSeriesInterfaces}preferences.h {CSeriesInterfaces}macintosh_cseries.h {CSeriesInterfaces}proximity_strcmp.h ∂ - {CSeriesInterfaces}temporary_files.h {CSeriesInterfaces}cseries.a {CSeriesInterfaces}macintosh_interfaces.c - -{CSeriesInterfaces}cseries.h ƒ cseries.h - Duplicate -y cseries.h {CSeriesInterfaces} -{CSeriesInterfaces}cseries.a ƒ cseries.a - Duplicate -y cseries.a {CSeriesInterfaces} -{CSeriesInterfaces}my32bqd.h ƒ my32bqd.h - Duplicate -y my32bqd.h {CSeriesInterfaces} -{CSeriesInterfaces}rle.h ƒ rle.h - Duplicate -y rle.h {CSeriesInterfaces} -{CSeriesInterfaces}preferences.h ƒ preferences.h - Duplicate -y preferences.h {CSeriesInterfaces} -{CSeriesInterfaces}macintosh_cseries.h ƒ macintosh_cseries.h - Duplicate -y macintosh_cseries.h {CSeriesInterfaces} -{CSeriesInterfaces}proximity_strcmp.h ƒ proximity_strcmp.h - Duplicate -y proximity_strcmp.h {CSeriesInterfaces} -{CSeriesInterfaces}temporary_files.h ƒ temporary_files.h - Duplicate -y temporary_files.h {CSeriesInterfaces} -{CSeriesInterfaces}macintosh_interfaces.c ƒ macintosh_interfaces.c - Duplicate -y macintosh_interfaces.c {CSeriesInterfaces}macintosh_interfaces.c diff --git a/cseries.lib/cseries.xcoff.make b/cseries.lib/cseries.xcoff.make deleted file mode 100644 index fad3596..0000000 --- a/cseries.lib/cseries.xcoff.make +++ /dev/null @@ -1,61 +0,0 @@ -# CSERIES.XCOFF -# -------------------------------------------------------------- -# Thursday, July 11, 1991 11:30:44 AM -# Thursday, January 13, 1994 7:35:38 AM - -# {PPCCOptions} is used below in .xcoff dependency rule -#PPCCOptions= -i {CSeriesInterfaces} -appleext on -opt speed -dialect ansic -w conformance -PPCCOptions= -i {CSeriesInterfaces} -appleext on -sym on -dialect ansic -w conformance -d DEBUG - -# Define our object file directory, and give a directory dependency rule (what does this -# do again?) -Obj= :Objects: -{Obj} ƒ : - -# default dependency rule for .c files -.xcoff ƒ .c - ppcc {PPCCOptions} {default}.c -o {Obj}{default}.xcoff - -OBJECTS= {Obj}macintosh_utilities.xcoff {Obj}my32bqd.xcoff {Obj}rle.xcoff {Obj}preferences.xcoff {Obj}proximity_strcmp.xcoff ∂ - {Obj}temporary_files.xcoff {Obj}devices.xcoff {Obj}dialogs.xcoff - -macintosh_cseries.h ƒ cseries.h - -### Portable -{Obj}proximity_strcmp.xcoff ƒ proximity_strcmp.h cseries.h cseries.xcoff.make -{Obj}rle.xcoff ƒ rle.h cseries.h cseries.xcoff.make - -### Macintosh -{Obj}macintosh_utilities.xcoff ƒ macintosh_cseries.h cseries.xcoff.make -{Obj}my32bqd.xcoff ƒ my32bqd.h macintosh_cseries.h cseries.xcoff.make -{Obj}devices.xcoff ƒ macintosh_cseries.h cseries.xcoff.make -{Obj}dialogs.xcoff ƒ macintosh_cseries.h cseries.xcoff.make -{Obj}preferences.xcoff ƒ preferences.h macintosh_cseries.h cseries.xcoff.make -{Obj}temporary_files.xcoff ƒ temporary_files.h macintosh_cseries.h cseries.xcoff.make - -cseries.xcoff ƒƒ {OBJECTS} - PPCLink -o cseries.xcoff -xm library {OBJECTS} - Move -y cseries.xcoff {CSeriesLibraries} - -cseries.xcoff ƒƒ {CSeriesInterfaces}cseries.h {CSeriesInterfaces}my32bqd.h {CSeriesInterfaces}rle.h ∂ - {CSeriesInterfaces}preferences.h {CSeriesInterfaces}macintosh_cseries.h {CSeriesInterfaces}proximity_strcmp.h ∂ - {CSeriesInterfaces}temporary_files.h {CSeriesInterfaces}cseries.a {CSeriesInterfaces}macintosh_interfaces.h - -{CSeriesInterfaces}cseries.h ƒ cseries.h - Duplicate -y cseries.h {CSeriesInterfaces} -{CSeriesInterfaces}cseries.a ƒ cseries.a - Duplicate -y cseries.a {CSeriesInterfaces} -{CSeriesInterfaces}my32bqd.h ƒ my32bqd.h - Duplicate -y my32bqd.h {CSeriesInterfaces} -{CSeriesInterfaces}rle.h ƒ rle.h - Duplicate -y rle.h {CSeriesInterfaces} -{CSeriesInterfaces}preferences.h ƒ preferences.h - Duplicate -y preferences.h {CSeriesInterfaces} -{CSeriesInterfaces}macintosh_cseries.h ƒ macintosh_cseries.h - Duplicate -y macintosh_cseries.h {CSeriesInterfaces} -{CSeriesInterfaces}proximity_strcmp.h ƒ proximity_strcmp.h - Duplicate -y proximity_strcmp.h {CSeriesInterfaces} -{CSeriesInterfaces}temporary_files.h ƒ temporary_files.h - Duplicate -y temporary_files.h {CSeriesInterfaces} -{CSeriesInterfaces}macintosh_interfaces.h ƒ macintosh_interfaces.c - Duplicate -y macintosh_interfaces.c {CSeriesInterfaces}macintosh_interfaces.h diff --git a/cseries.lib/device_dialog.c b/cseries.lib/device_dialog.c new file mode 100644 index 0000000..daf4d08 --- /dev/null +++ b/cseries.lib/device_dialog.c @@ -0,0 +1,277 @@ +/* +DEVICE_DIALOG.C +Sunday, December 4, 1994 4:50:19 PM (Jason') +*/ + +#include "macintosh_cseries.h" + +/* ---------- constants */ + +#define dlogDEVICE 20000 + #define iCOLORS 3 + #define iGRAYS 4 + #define iDEVICE_AREA 5 + #define iDEVICE_NAME 9 + +#define DEVICE_AREA_MENU_BAR_HEIGHT 6 +#define DEVICE_AREA_SCALE 16 + +/* ---------- structures */ + +struct device_dialog_global_data +{ + GDSpec device_spec; + + GDHandle device; +}; + +/* ---------- globals */ + +static struct device_dialog_global_data device_dialog_globals; + +/* ---------- private code */ + +static device_dialog_instantiate_proc(DialogPtr dialog); +static pascal Boolean device_dialog_filter_proc(DialogPtr dialog, EventRecord *event, short *item_hit); + +static void draw_device_area(GDSpecPtr device_spec, GDHandle selected_device, Rect *frame); +static GDHandle click_in_device_area(GDSpecPtr device_spec, Rect *frame, Point mouse); + +static void get_device_area_offset(Rect *frame, Point *offset); +static void get_device_area_frame(GDHandle device, Rect *frame, Point offset); + +/* ---------- code */ + +GDHandle display_device_dialog( + GDSpecPtr device_spec) +{ + GDHandle device= BestDevice(device_spec); + + if (device) + { + DialogPtr dialog= myGetNewDialog(dlogDEVICE, NULL, (WindowPtr) -1, 0); + ModalFilterUPP device_dialog_filter_upp= NewModalFilterProc(device_dialog_filter_proc); + short item_hit; + + assert(dialog); + assert(device_dialog_filter_upp); + + /* setup globals */ + device_dialog_globals.device_spec= *device_spec; + device_dialog_globals.device= device; + + /* setup and show dialog */ + device_dialog_instantiate_proc(dialog); + ShowWindow(dialog); + + do + { + boolean reinstantiate= FALSE; + + ModalDialog(device_dialog_filter_upp, &item_hit); + switch(item_hit) + { + case iCOLORS: device_dialog_globals.device_spec.flags|= deviceIsColor; reinstantiate= TRUE; break; + case iGRAYS: device_dialog_globals.device_spec.flags&= ~deviceIsColor; reinstantiate= TRUE; break; + + case iDEVICE_AREA: reinstantiate= TRUE; break; + + case iOK: + *device_spec= device_dialog_globals.device_spec; + device= device_dialog_globals.device; + break; + } + + if (reinstantiate) device_dialog_instantiate_proc(dialog); + } + while (item_hit!=iOK && item_hit!=iCANCEL); + + DisposeDialog(dialog); + DisposeRoutineDescriptor(device_dialog_filter_upp); + } + + return device; +} + +/* ---------- private code */ + +static device_dialog_instantiate_proc( + DialogPtr dialog) +{ + short item_type; + Rect item_rectangle; + Handle item_handle; + OSErr error; + + modify_radio_button_family(dialog, iCOLORS, iGRAYS, (device_dialog_globals.device_spec.flags&deviceIsColor) ? iCOLORS : iGRAYS); + + error= GetNameFromGDevice(device_dialog_globals.device, temporary); + if (error!=noErr) temporary[0]= 0; + GetDItem(dialog, iDEVICE_NAME, &item_type, &item_handle, &item_rectangle); + SetIText(item_handle, (const unsigned char *)temporary); + + return; +} + +static pascal Boolean device_dialog_filter_proc( + DialogPtr dialog, + EventRecord *event, + short *item_hit) +{ + GrafPtr old_port; + short item_type; + Handle item_handle; + Rect item_rectangle; + boolean handled= FALSE; + + GetPort(&old_port); + SetPort(dialog); + + GetDItem(dialog, iDEVICE_AREA, &item_type, &item_handle, &item_rectangle); + + /* preprocess events */ + switch(event->what) + { + case mouseDown: + { + Point where= event->where; + + GlobalToLocal(&where); + switch (FindDItem(dialog, where)+1) + { + case iDEVICE_AREA: + { + GDHandle new_device= click_in_device_area(&device_dialog_globals.device_spec, &item_rectangle, where); + + if (new_device && new_device!=device_dialog_globals.device) + { + device_dialog_globals.device= new_device; + BuildExplicitGDSpec(&device_dialog_globals.device_spec, new_device, device_dialog_globals.device_spec.flags, device_dialog_globals.device_spec.bit_depth, 0, 0); + draw_device_area(&device_dialog_globals.device_spec, device_dialog_globals.device, &item_rectangle); + + *item_hit= iDEVICE_AREA; + } + handled= TRUE; + + break; + } + } + break; + } + + case updateEvt: + if ((DialogPtr)event->message==dialog) + { + draw_device_area(&device_dialog_globals.device_spec, device_dialog_globals.device, &item_rectangle); + } + break; + } + + SetPort(old_port); + + return handled ? TRUE : general_filter_proc(dialog, event, item_hit); +} + +static void draw_device_area( + GDSpecPtr device_spec, + GDHandle selected_device, + Rect *frame) +{ + Point offset; + GDHandle device; + + get_device_area_offset(frame, &offset); + + EraseRect(frame); + FrameRect(frame); + + for (device= GetDeviceList(); device; device= GetNextDevice(device)) + { + if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) + { + GDSpec spec; + Rect bounds; + + BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0); + + get_device_area_frame(device, &bounds, offset); + + RGBForeColor(HasDepthGDSpec(&spec) ? &rgb_dark_gray : &rgb_white); + PaintRect(&bounds); + RGBForeColor(&rgb_black); + + if (device==selected_device) PenSize(2, 2); + FrameRect(&bounds); + PenSize(1, 1); + + if (device==GetMainDevice()) + { + bounds.bottom= bounds.top + DEVICE_AREA_MENU_BAR_HEIGHT; + EraseRect(&bounds); + FrameRect(&bounds); + } + } + } + + return; +} + +static GDHandle click_in_device_area( + GDSpecPtr device_spec, + Rect *frame, + Point mouse) +{ + Point offset; + GDHandle device, intersected_device= (GDHandle) NULL; + + get_device_area_offset(frame, &offset); + + for (device= GetDeviceList(); device; device= GetNextDevice(device)) + { + if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) + { + GDSpec spec; + Rect bounds; + + BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0); + if (HasDepthGDSpec(&spec)) + { + get_device_area_frame(device, &bounds, offset); + if (PtInRect(mouse, &bounds)) + { + intersected_device= device; + break; + } + } + } + } + + return intersected_device; +} + +static void get_device_area_offset( + Rect *frame, + Point *offset) +{ + GDHandle device= GetMainDevice(); + + SetPt(offset, (*device)->gdRect.left + RECTANGLE_WIDTH(&(*device)->gdRect)/2, + (*device)->gdRect.top + RECTANGLE_HEIGHT(&(*device)->gdRect)/2); + SetPt(offset, frame->left + RECTANGLE_WIDTH(frame)/2 - offset->h/DEVICE_AREA_SCALE, + frame->top + RECTANGLE_HEIGHT(frame)/2 - offset->v/DEVICE_AREA_SCALE); + + return; +} + +static void get_device_area_frame( + GDHandle device, + Rect *frame, + Point offset) +{ + *frame= (*device)->gdRect; + frame->left/= DEVICE_AREA_SCALE, frame->right/= DEVICE_AREA_SCALE; + frame->top/= DEVICE_AREA_SCALE, frame->bottom/= DEVICE_AREA_SCALE; + OffsetRect(frame, offset.h, offset.v); + + return; +} diff --git a/cseries.lib/devices.c b/cseries.lib/devices.c index bc69506..0b69c7d 100644 --- a/cseries.lib/devices.c +++ b/cseries.lib/devices.c @@ -4,10 +4,21 @@ Wednesday, September 1, 1993 12:09:55 PM Friday, August 12, 1994 10:23:19 AM added LowLevelSetEntries(). +Wednesday, December 7, 1994 12:03:05 PM (Jason') + added GDSpec stuff, changed BestDevice. this is sort of the last nail in the coffin of + pathways ever being compiled easily again. */ #include "macintosh_cseries.h" + +#include "textures.h" + #include +#include + +#ifndef env68k +#include "RequestVideo.c" +#endif #ifdef mpwc #pragma segment modules @@ -15,8 +26,6 @@ Friday, August 12, 1994 10:23:19 AM /* ---------- constants */ -#define alrtCHANGE_DEPTH 130 - /* ---------- globals */ /* for menu bar hiding */ @@ -26,27 +35,37 @@ static RgnHandle old_gray_region; /* ---------- private code */ -static boolean parse_device(GDHandle device, short depth, GDHandle *changeable_device, - short *new_mode, short *new_type); - /* ---------- code */ void HideMenuBar( GDHandle device) { - RgnHandle new_gray_region; - - assert(!menu_bar_hidden); + RgnHandle device_region; + static boolean first_time= TRUE; + // <6/17/96 AMR> Commented out the following because it's called every time the depth + // or resolution is changed to resquare the corners of the main device. +// assert(!menu_bar_hidden); + if (device==GetMainDevice()) { - old_menu_bar_height= LMGetMBarHeight(); - LMSetMBarHeight(0); + Rect device_bounds= (*device)->gdRect; + + if (first_time) + { + first_time= FALSE; + + old_menu_bar_height= LMGetMBarHeight(); + LMSetMBarHeight(0); - old_gray_region= LMGetGrayRgn(); - new_gray_region= NewRgn(); - RectRgn(new_gray_region, &(*device)->gdRect); - LMSetGrayRgn(new_gray_region); + old_gray_region= NewRgn(); + CopyRgn(LMGetGrayRgn(), old_gray_region); + } + + device_region= NewRgn(); + RectRgn(device_region, &device_bounds); + UnionRgn(LMGetGrayRgn(), device_region, LMGetGrayRgn()); + DisposeRgn(device_region); menu_bar_hidden= TRUE; } @@ -60,13 +79,13 @@ void ShowMenuBar( if (menu_bar_hidden) { LMSetMBarHeight(old_menu_bar_height); - DisposeRgn(LMGetGrayRgn()); - LMSetGrayRgn(old_gray_region); + CopyRgn(old_gray_region, LMGetGrayRgn()); + DisposeRgn(old_gray_region); DrawMenuBar(); menu_bar_hidden= FALSE; } - + return; } @@ -79,9 +98,9 @@ GDHandle MostDevice( largest_area= 0; largest_device= (GDHandle) NULL; - for (device=GetDeviceList();device;device=GetNextDevice(device)) + for (device= GetDeviceList(); device; device= GetNextDevice(device)) { - if (TestDeviceAttribute(device, screenDevice)&&TestDeviceAttribute(device, screenActive)) + if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) { if (SectRect(bounds, &(*device)->gdRect, &intersection)) { @@ -98,47 +117,40 @@ GDHandle MostDevice( return largest_device; } +/* returns the device best matching the given GDSpec, if any, making the GDSpec more explicit if + necessary */ GDHandle BestDevice( - short depth) + GDSpecPtr device_spec) { - GDHandle device, changeable_device; - short new_mode= 0, new_type= 0; - OSErr error= noErr; - - /* use the main device, if it’s what we want */ - if (parse_device(GetMainDevice(), depth, &changeable_device, &new_mode, &new_type)) - { - return GetMainDevice(); - } + GDHandle best_device= (GDHandle) NULL; + GDSpec spec; - /* otherwise, go look for a device of the given depth */ - for (device=GetDeviceList();device;device=GetNextDevice(device)) + /* try the given GDSpec, then search the entire device list */ + if (HasDepthGDSpec(device_spec)) best_device= MatchGDSpec(device_spec); + if (!best_device) { - if (parse_device(device, depth, &changeable_device, &new_mode, &new_type)) + GDHandle device; + + for (device= GetDeviceList(); device && !best_device; device= GetNextDevice(device)) { - return device; + if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) + { + BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0); + if (HasDepthGDSpec(&spec)) *device_spec= spec, best_device= device; + } } } - /* was there any device we could switch to our depth? */ - if (new_mode) + /* if we failed to find anything in color, try in grayscale */ + if (!best_device && (device_spec->flags&deviceIsColor)) { - /* should this alert go on the destination monitor, or would that be hard to notice? */ - switch (myAlert(alrtCHANGE_DEPTH, get_general_filter_upp())) - { - case iOK: /* change now */ - error= SetDepth(changeable_device, new_mode, 1, new_type); - if (error==noErr) - { - return changeable_device; - } - - case iCANCEL: /* quit */ - exit(0); - } + spec= *device_spec; + spec.flags&= ~deviceIsColor; + + if (best_device= BestDevice(&spec)) *device_spec= spec; } - - return (GDHandle) NULL; + + return best_device; } void LowLevelSetEntries( @@ -150,70 +162,304 @@ void LowLevelSetEntries( CntrlParam pb; VDSetEntryRecord parameters; - GDHandle device= GetGDevice(); + if (count) + { + GDHandle device= GetGDevice(); + + parameters.csStart= start; + parameters.csCount= count; + parameters.csTable= (ColorSpec *) StripAddress((Ptr)aTable); + + memset(&pb, 0, sizeof(CntrlParam)); + pb.ioCompletion= (IOCompletionUPP) NULL; + pb.ioVRefNum= 0; + pb.ioCRefNum= (*device)->gdRefNum; + pb.csCode= (*device)->gdType==directType ? cscDirectSetEntries : cscSetEntries; + *((Ptr*)&pb.csParam)= (Ptr) ¶meters; + + error= PBControl((ParmBlkPtr)&pb, FALSE); + vwarn(error==noErr, csprintf(temporary, "Control(cscXSetEntries, ...) returned #%d;g;", error)); + } + return; +} - parameters.csStart= start; - parameters.csCount= count; - parameters.csTable= aTable; +short GetSlotFromGDevice( + GDHandle device) +{ + AuxDCEHandle DCE= (AuxDCEHandle) GetDCtlEntry((*device)->gdRefNum); + + assert(DCE); + + return DCE ? (*DCE)->dCtlSlot : 0; +} - pb.ioCompletion= (ProcPtr) NULL; - pb.ioVRefNum= 0; - pb.ioCRefNum= (*device)->gdRefNum; - pb.csCode= (*device)->gdType==directType ? cscDirectSetEntries : cscSetEntries; - *((Ptr*)&pb.csParam)= (Ptr) ¶meters; +OSErr GetNameFromGDevice( + GDHandle device, + char *name) +{ + OSErr error; + SpBlockPtr mySpBPtr= (SpBlockPtr) NewPtrClear(sizeof(SpBlock)); + + if (mySpBPtr) + { + mySpBPtr->spSlot= GetSlotFromGDevice(device); + mySpBPtr->spID= 0; + mySpBPtr->spExtDev= 0; + mySpBPtr->spCategory= 1; // Get the board sResource + mySpBPtr->spCType= 0; + mySpBPtr->spDrvrSW= 0; + mySpBPtr->spDrvrHW= 0; + mySpBPtr->spTBMask= 0; + + error= SNextTypeSRsrc(mySpBPtr); + if (error==noErr) + { + mySpBPtr->spID= 2; // get the description string (spSPointer was set up by NextTypeSRsrc) + error= SGetCString(mySpBPtr); + if (error==noErr) + { + strcpy(name, (char *) mySpBPtr->spResult); + DisposPtr((Ptr) mySpBPtr->spResult); + c2pstr(name); + } + } + + DisposePtr((Ptr)mySpBPtr); + } + else + { + error= MemError(); + } + + return error; +} + +/* based on explicit state provided */ +void BuildExplicitGDSpec( + GDSpecPtr device_spec, + GDHandle device, + word flags, + short bit_depth, + short width, + short height) +{ + assert(!(flags&~deviceIsColor)); + assert(bit_depth==8||bit_depth==16||bit_depth==32); - error= PBControl((ParmBlkPtr)&pb, FALSE); - vassert(error==noErr, csprintf(temporary, "Control(cscXSetEntries, ...) returned #%d", error)); + device_spec->slot= device ? GetSlotFromGDevice(device) : NONE; + device_spec->flags= flags; + device_spec->bit_depth= bit_depth; + device_spec->width= width; + device_spec->height= height; return; } -/* ---------- private code */ +/* based on current state */ +void BuildGDSpec( + GDSpecPtr device_spec, + GDHandle device) +{ + assert(device); + + device_spec->slot= GetSlotFromGDevice(device); + device_spec->flags= (*device)->gdFlags&deviceIsColor; + device_spec->bit_depth= (*(*device)->gdPMap)->pixelSize; + device_spec->width= RECTANGLE_WIDTH(&(*device)->gdRect); + device_spec->height= RECTANGLE_HEIGHT(&(*device)->gdRect); + + return; +} -static boolean parse_device( - GDHandle device, - short depth, - GDHandle *changeable_device, - short *new_mode, - short *new_type) +Boolean EqualGDSpec( + GDSpecPtr device_spec1, + GDSpecPtr device_spec2) { - PixMapHandle pixmap; - short mode; + Boolean equal= FALSE; - if (TestDeviceAttribute(device, screenDevice)&&TestDeviceAttribute(device, screenActive)) + if (MatchGDSpec(device_spec1)==MatchGDSpec(device_spec2)) { - pixmap= (*device)->gdPMap; - if ((*pixmap)->pixelType==chunky&&(*pixmap)->pixelSize==depth) + if (device_spec1->flags==device_spec2->flags && device_spec1->bit_depth==device_spec2->bit_depth) { - return TRUE; + // does not compare screen dimensions + + equal= TRUE; } - else + } + + return equal; +} + +boolean machine_has_display_manager( + void) +{ +#ifndef env68k + boolean displayMgrPresent; + SpBlock spBlock; + long value= 0; + OSErr err; + + err= Gestalt(gestaltDisplayMgrAttr, &value); + displayMgrPresent= !err && (value&(1<= 0x00020000); + + return displayMgrPresent; +#else + return FALSE; +#endif +} + +void SetResolutionGDSpec( + GDSpecPtr device_spec, + VDSwitchInfoPtr switchInfo) +{ +#ifndef env68k + if (machine_has_display_manager()) + { + GDHandle device= MatchGDSpec(device_spec); + + if (device_spec->width && device_spec->height) { - /* can this monitor do the given depth in color? if it can, pick it above a - previous monitor that can only do grays */ - mode= HasDepth(device, depth, 1, 1); - if (mode&&(!*new_mode||!*new_type)) + // device manager + VideoRequestRec record; + OSErr error; + + memset(&record, 0, sizeof(VideoRequestRec)); + + record.screenDevice= device; + record.reqBitDepth= device_spec->bit_depth; + record.reqHorizontal= device_spec->width; + record.reqVertical= device_spec->height; + +// dprintf("requesting settings for record @%p (device %p)", &record, device); +// GetRequestTheDM1Way(&record, device); + error= RVRequestVideoSetting(&record); + + if (switchInfo) { - *changeable_device= device; - *new_mode= mode; - *new_type= 1; + record.switchInfo= *switchInfo; // they want a specific mode } - else +// dprintf("trying to use display manager to go to (#%d,#%d)", device_spec->width, device_spec->height); + error= RVSetVideoRequest(&record); + if (error==noErr) { - if (!*new_mode) - { - /* can it do grayscale? (as a last resort) */ - mode= HasDepth(device, depth, 1, 0); - if (mode) - { - *changeable_device= device; - *new_mode= mode; - *new_type= 0; - } - } } - return FALSE; + if (error!=noErr) dprintf("Eric’s crazy code returned #%d", error); + } + } +#endif + + return; +} + +/* returns the given GDevice to the state specified by the GDSpec */ +void SetDepthGDSpec( + GDSpecPtr device_spec) +{ + GDHandle device= MatchGDSpec(device_spec); + + if (device) + { + short mode= HasDepth(device, device_spec->bit_depth, deviceIsColor, device_spec->flags); + + if (mode) + { + SetDepth(device, mode, deviceIsColor, device_spec->flags); + } + } + + return; +} + +boolean HasDepthGDSpec( + GDSpecPtr device_spec) +{ + GDHandle device= MatchGDSpec(device_spec); + boolean has_depth= FALSE; + + if (device) + { + if (HasDepth(device, device_spec->bit_depth, deviceIsColor, device_spec->flags)) + { + has_depth= TRUE; + } + } + + return has_depth; +} + +/* returns the GDHandle referenced by the given GDSpec */ +GDHandle MatchGDSpec( + GDSpecPtr device_spec) +{ + GDHandle device, matched_device= (GDHandle) NULL; + + for (device= GetDeviceList(); device; device= GetNextDevice(device)) + { + if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) + { + if (device_spec->slot==GetSlotFromGDevice(device)) + { + matched_device= device; + break; + } } } + + return matched_device; +} + +CTabHandle build_macintosh_color_table( + struct color_table *color_table) +{ + CTabHandle macintosh_color_table= (CTabHandle) NewHandle(sizeof(ColorTable)+color_table->color_count*sizeof(ColorSpec)); + + if (macintosh_color_table) + { + struct rgb_color *color; + ColorSpec *spec; + short i; + + (*macintosh_color_table)->ctFlags= 0; + (*macintosh_color_table)->ctSeed= GetCTSeed(); + (*macintosh_color_table)->ctSize= color_table->color_count-1; + + color= color_table->colors; + spec= (*macintosh_color_table)->ctTable; + for (i= 0; icolor_count; ++i, ++spec, ++color) + { + spec->value= i; + spec->rgb= *((RGBColor *) color); + } + + CTabChanged(macintosh_color_table); + } + + return macintosh_color_table; +} + +struct color_table *build_color_table( + struct color_table *color_table, + CTabHandle macintosh_color_table) +{ + struct rgb_color *color; + ColorSpec *spec; + short i; + + color_table->color_count= (*macintosh_color_table)->ctSize+1; + + color= color_table->colors; + spec= (*macintosh_color_table)->ctTable; + for (i= 0; icolor_count; ++i, ++spec, ++color) + { + *color= *((struct rgb_color *)&spec->rgb); + } + + return color_table; } diff --git a/cseries.lib/dialogs.c b/cseries.lib/dialogs.c index 154d16b..3bf1c99 100644 --- a/cseries.lib/dialogs.c +++ b/cseries.lib/dialogs.c @@ -104,6 +104,8 @@ pascal Boolean general_filter_proc( GrafPtr old_port; short part; + global_idle_proc(); + if (cursor_tracking) track_dialog_cursor(dialog); switch (event->what) @@ -134,6 +136,10 @@ pascal Boolean general_filter_proc( key= event->message&charCodeMask; switch (key) { + case 0: + /* we might get zeros from the stay_awake() proc, and we should eat them */ + return TRUE; + case 0x09: if (event->modifiers&shiftKey) { @@ -330,14 +336,14 @@ short myAlert( short alertID, ModalFilterUPP filterProc) { - Handle template; + Handle tmplate; - template= GetResource('ALRT', alertID); - assert(template); + tmplate= GetResource('ALRT', alertID); + assert(tmplate); - if (GetHandleSize(template)==14) + if (tmplate && GetHandleSize(tmplate)==14) { - position_window((Rect*)*template, *((word*)*template+6)); + position_window((Rect*)*tmplate, *((word*)*tmplate+6)); } return Alert(alertID, filterProc); @@ -350,14 +356,14 @@ DialogPtr myGetNewDialog( long refCon) { DialogPtr dialog; - Handle template; + Handle tmplate; - template= GetResource('DLOG', dialogID); - assert(template); + tmplate= GetResource('DLOG', dialogID); + assert(tmplate); - if (GetHandleSize(template)==24) + if (tmplate && GetHandleSize(tmplate)==24) { - position_window((Rect*)*template, *((word*)*template+11)); + position_window((Rect*)*tmplate, *((word*)*tmplate+11)); } dialog= GetNewDialog(dialogID, dStorage, behind); @@ -379,15 +385,18 @@ void standard_dialog_header_proc( header= (PicHandle) GetResource('PICT', 256); assert(header); - - SetRect(&background, frame->left, frame->top, frame->right, frame->top+ - RECTANGLE_HEIGHT(&(*header)->picFrame)+2*DIALOG_HEADER_SPACING); - PaintRect(&background); - - destination= (*header)->picFrame; - OffsetRect(&destination, frame->left+2*DIALOG_HEADER_SPACING-destination.left, - frame->top+DIALOG_HEADER_SPACING-destination.top); - DrawPicture(header, &destination); + + if (header) + { + SetRect(&background, frame->left, frame->top, frame->right, frame->top+ + RECTANGLE_HEIGHT(&(*header)->picFrame)+2*DIALOG_HEADER_SPACING); + PaintRect(&background); + + destination= (*header)->picFrame; + OffsetRect(&destination, frame->left+2*DIALOG_HEADER_SPACING-destination.left, + frame->top+DIALOG_HEADER_SPACING-destination.top); + DrawPicture(header, &destination); + } return; } @@ -406,7 +415,7 @@ Boolean CmdPeriodEvent( Handle hKCHR; /* Handle to the currently-used KCHR */ long keyInfo; /* Key information returned from KeyTrans */ long keyScript; /* Script of the current keyboard */ - long state; /* State used for KeyTrans */ + unsigned long state; /* State used for KeyTrans */ short virtualKey; /* Virtual keycode of the character-generating key */ short keyCode; /* Keycode of the character-generating key */ Boolean gotCmdPeriod; /* True if detected command-. */ @@ -429,7 +438,7 @@ Boolean CmdPeriodEvent( /* Get key information */ state = 0; - keyInfo = KeyTrans( *hKCHR, keyCode, &state ); + keyInfo = KeyTrans( *hKCHR, keyCode, &state); } else keyInfo = anEvent->message; @@ -460,12 +469,83 @@ long extract_number_from_text_item( Handle item_handle; GetDItem(dialog, item_number, &item_type, &item_handle, &item_box); - GetIText(item_handle, temporary); - StringToNum(temporary, &num); + GetIText(item_handle, (unsigned char *)temporary); + StringToNum((const unsigned char *)temporary, &num); return num; } +float extract_float_from_text_item( + DialogPtr dialog, + short item_num) +{ + Rect item_box; + short item_type; + float num; + Handle item_handle; + + GetDItem(dialog, item_num, &item_type, &item_handle, &item_box); + GetIText(item_handle, (unsigned char *)temporary); + p2cstr((unsigned char *)temporary); + sscanf(temporary, "%f", &num); + + return num; +} + +void insert_number_into_text_item( + DialogPtr dialog, + short item_number, + long new_value) +{ + char number_text[12]; // big enough to handle 4294967295 for sure. + Rect item_box; + short item_type; + Handle item_handle; + + GetDItem(dialog, item_number, &item_type, &item_handle, &item_box); + NumToString(new_value, (unsigned char *)number_text); + SetIText(item_handle, (StringPtr)number_text); +} + +void insert_float_into_text_item( + DialogPtr dialog, + short item_number, + float new_value) +{ + Rect item_box; + short item_type; + Handle item_handle; + + sprintf(temporary, "%.3f", new_value); + c2pstr(temporary); + + GetDItem(dialog, item_number, &item_type, &item_handle, &item_box); + SetIText(item_handle, (StringPtr)temporary); +} + +MenuHandle get_popup_menu_handle( + DialogPtr dialog, + short item) +{ + struct PopupPrivateData **privateHndl; + MenuHandle menu; + short item_type; + ControlHandle control; + Rect bounds; + + /* Add the maps.. */ + GetDItem(dialog, item, &item_type, (Handle *) &control, &bounds); + + /* I don't know how to assert that it is a popup control... */ + privateHndl= (PopupPrivateData **) ((*control)->contrlData); + assert(privateHndl); + + menu= (*privateHndl)->mHandle; + assert(menu); + + return menu; +} + /* ---------- private code */ /* all this positioning stuff didn’t seem to work terribly well under a system that was already @@ -683,7 +763,7 @@ static short dialog_keyboard_equivilents( { if ((*(ControlHandle)item_handle)->contrlHilite==CONTROL_ACTIVE) { - GetCTitle((ControlHandle)item_handle, temporary); + GetCTitle((ControlHandle)item_handle, (unsigned char *)temporary); if (((byte)*temporary)<128) /* ignore high ascii for kanji buttons */ { if (key==tolower(*(temporary+1))) diff --git a/cseries.lib/final.h b/cseries.lib/final.h new file mode 100644 index 0000000..ecd6228 --- /dev/null +++ b/cseries.lib/final.h @@ -0,0 +1,5 @@ +//#define DEBUG + +//#define ALPHA +//#define BETA +#define FINAL diff --git a/cseries.lib/macintosh_cseries.h b/cseries.lib/macintosh_cseries.h index 034b2ba..d0f91cf 100644 --- a/cseries.lib/macintosh_cseries.h +++ b/cseries.lib/macintosh_cseries.h @@ -32,20 +32,36 @@ Saturday, March 20, 1993 8:34:14 PM cursor position to the EOF’. glad i had a backup ... */ -#define _MACINTOSH_CODE - -#include "cseries.h" - -#ifdef powerc - #include "macintosh_interfaces.c" /* gak */ +#define mac + +#ifdef __MWERKS__ + #ifndef POWERPLANT + #ifdef powerc + #include "macintosh_interfaces.ppc" + #else + #include "macintosh_interfaces.68k" + #endif + #else + #ifdef powerc + #include "PP_interfaces.ppc" + #else + #include "PP_interfaces.68k" + #endif + #endif #else - #ifndef mc68881 - #pragma load "macintosh_interfaces.d" + #ifdef powerc + #include "macintosh_interfaces.c" /* gak */ #else - #pragma load "macintosh_interfaces881.d" + #ifndef mc68881 + #pragma load "macintosh_interfaces.d" + #else + #pragma load "macintosh_interfaces881.d" + #endif #endif #endif +#include "cseries.h" + /* ---------- constants */ #define OSEvt app4Evt @@ -105,14 +121,6 @@ Saturday, March 20, 1993 8:34:14 PM #define DIALOG_INSET 4 -enum -{ - fatalError, - infoError -}; - -#define NUMBER_OF_SYSTEM_COLORS 26 - /* indexes into the system_colors array */ enum { @@ -142,7 +150,8 @@ enum inactiveApplePurple, inactiveAppleBlue, - stupidColor1 + stupidColor1, + NUMBER_OF_SYSTEM_COLORS }; enum /* modes for AdjustRect */ @@ -206,11 +215,14 @@ long get_a0(void)= {0x2008}; long get_a1(void)= {0x2009}; #endif +#define AbsRandom() (Random()&0x7fff) + /* ---------- external calls (yuck) and their callers */ /* called by general_filter_proc() */ void update_any_window(WindowPtr window, EventRecord *event); void activate_any_window(WindowPtr window, EventRecord *event, boolean activate); +void global_idle_proc(void); /* ---------- prototypes: MACINTOSH_UTILITIES.C */ @@ -233,13 +245,13 @@ void draw_popup_frame(Rect *bounds); RGBColor *SetRGBColor(RGBColor *color, word red, word green, word blue); boolean wait_for_mouse_to_move(Point origin, short threshold); +short wait_for_click_or_keypress(long maximum_delay); void hold_for_visible_delay(void); void stay_awake(void); -void alert_user(short type, short resource_number, short error_number, short identifier); - /* getcstr is in cseries.h */ +short countstr(short resource_number); char *getpstr(char *buffer, short collection_number, short string_number); void AdjustRect(Rect *bounds, Rect *source, Rect *destination, short mode); @@ -248,26 +260,77 @@ void ScaleRect(Rect *bounds, Rect *source, Rect *destination); void initialize_system_colors(void); char *pstrcpy(char *destStr, const char *srcStr); +void pstrcat(unsigned char *str1, unsigned char *str2); /* rsprintf and dprintf are in cseries.h */ int prsprintf(char *s, short resource_number, short string_number, ...); int psprintf(char *s, const char *format, ...); -OSErr FSFlush(short handle); +OSErr FSFlush(short hndl, short VRefNum); void GetNewTextSpec(TextSpecPtr font_info, short resource_number, short font_index); void SetFont(TextSpecPtr font_info); void GetFont(TextSpecPtr font_info); +short get_our_country_code(void); + +short HOpenResFilePath(short vRefNum, long dirID, ConstStr255Param fileName, + char permission, short resource_number); +short HOpenPath(short vRefNum, long dirID, ConstStr255Param fileName, char permission, + short *refNum, short resource_number); + +void kill_screen_saver(void); +void restore_screen_saver(void); + +OSErr get_file_spec(FSSpec *spec, short string_resource_id, short file_name_index, short path_resource_id); +OSErr get_my_fsspec(FSSpec *file); + /* ---------- prototypes: DEVICES.C */ +#define deviceIsGrayscale 0x0000 +#define deviceIsColor 0x0001 + +struct GDSpec +{ + short slot; + + word flags; /* deviceIsGrayscale || deviceIsColor */ + short bit_depth; /* bits per pixel */ + + short width, height; +}; +typedef struct GDSpec GDSpec, *GDSpecPtr; + GDHandle MostDevice(Rect *bounds); -GDHandle BestDevice(short depth); +GDHandle BestDevice(GDSpecPtr device_spec); + +void BuildExplicitGDSpec(GDSpecPtr device_spec, GDHandle device, word flags, + short bit_depth, short width, short height); +void BuildGDSpec(GDSpecPtr device_spec, GDHandle device); +GDHandle MatchGDSpec(GDSpecPtr device_spec); +Boolean EqualGDSpec(GDSpecPtr device_spec1, GDSpecPtr device_spec2); + +boolean HasDepthGDSpec(GDSpecPtr device_spec); +void SetDepthGDSpec(GDSpecPtr device_spec); + +boolean machine_has_display_manager(void); +void SetResolutionGDSpec(GDSpecPtr device_spec, VDSwitchInfoPtr switchInfo); + +short GetSlotFromGDevice(GDHandle device); +OSErr GetNameFromGDevice(GDHandle device, char *name); + void HideMenuBar(GDHandle device); void ShowMenuBar(void); void LowLevelSetEntries(short start, short count, CSpecArray aTable); +CTabHandle build_macintosh_color_table(struct color_table *color_table); +struct color_table *build_color_table(struct color_table *color_table, CTabHandle macintosh_color_table); + +/* ---------- prototypes/DEVICE_DIALOG.C */ + +GDHandle display_device_dialog(GDSpecPtr device_spec); + /* ---------- prototypes: DIALOGS.C */ short myAlert(short alertID, ModalFilterUPP filterProc); @@ -295,4 +358,5 @@ float extract_float_from_text_item(DialogPtr dialog, short item_num); void insert_number_into_text_item(DialogPtr dialog, short item_number, long new_value); void insert_float_into_text_item(DialogPtr dialog, short item_num, float new_value); +MenuHandle get_popup_menu_handle(DialogPtr dialog, short item); #endif diff --git a/cseries.lib/macintosh_interfaces.c b/cseries.lib/macintosh_interfaces.c new file mode 100644 index 0000000..f7e6d90 --- /dev/null +++ b/cseries.lib/macintosh_interfaces.c @@ -0,0 +1,79 @@ +/* +MACINTOSH_INTERFACES.C +Tuesday, July 17, 1990 6:01:28 PM + +Monday, December 24, 1990 8:40:57 PM + Removed STDIO.H. +Wednesday, December 26, 1990 11:17:09 PM + We are now part of the macintosh core (ooOooOoh). +Tuesday, June 25, 1991 2:17:39 AM + The macintosh core is now all but defunct and we are in the Libraries + directory like we should have been all along; unfortunately there doesn’t + seem to be a nice way to put it there so we have hardcoded the full path + of the libraries folder, {Libraries}. +Thursday, July 11, 1991 11:12:55 AM + Ah ha! We finally figured out how to do that (I think). We will bring in + the environment variables via the -d command-line option. +Friday, July 12, 1991 7:37:36 PM + Not. The output file is copied by the make file. :( +Wednesday, August 28, 1991 7:39:29 PM + Preprocessor conditional MC68881 used for #pragma dump directive. +Sunday, September 1, 1991 6:00:19 PM + MPW already defines mc68881, so we use that now. +Friday, October 30, 1992 1:07:25 AM + We now compile stuff with SystemSixOrLater defined, to avoid linking some + glue code (hopefully). +Sunday, November 15, 1992 9:04:27 PM + removed Limits.h, TextEdit.h, Traps.h (!), SysEqu.h (this will certainly break + something, but we don’t need *all* those low-memory constants), Scrap.h, SANE.h, Picker.h, + AppleTalk.h, Serial.h, and String.h (the ANSI header). Hopefully this will speed compile + time considerably. +Thursday, December 29, 1994 12:23:59 PM (Jason') + added GestaltEqu.h, string.h and ctype.h +*/ + +#ifdef __MWERKS__ + #ifdef powerc + #pragma precompile_target "macintosh_interfaces.ppc" + #else + #pragma precompile_target "macintosh_interfaces.68k" + #endif +#endif + +#define SystemSevenOrLater 1 + +#include +#include +#include +#include /* kept for IUCompString */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* added for c2pstr and p2cstr */ +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef applec +#pragma dump DUMP_FILE +#endif \ No newline at end of file diff --git a/cseries.lib/macintosh_interfaces.d.make b/cseries.lib/macintosh_interfaces.d.make new file mode 100644 index 0000000..0b606e6 --- /dev/null +++ b/cseries.lib/macintosh_interfaces.d.make @@ -0,0 +1,11 @@ +# MACINTOSH_INTERFACES.D +# -------------------------------------------------------------- +# Thursday, July 11, 1991 11:30:55 AM +# Saturday, January 15, 1994 2:03:18 PM + +CFLAGS= -i "{CSeriesInterfaces}" -b2 -r -mbg on -k "{CseriesLibraries}" +CFLAGS881= -i "{CSeriesInterfaces}" -b2 -r -mbg on -mc68881 -elems881 -k "{CSeriesLibraries}" + +macintosh_interfaces.d ƒ macintosh_interfaces.c macintosh_interfaces.d.make + C -c -d DUMP_FILE='"macintosh_interfaces.d"' {CFLAGS} macintosh_interfaces.c + C -c -d DUMP_FILE='"macintosh_interfaces881.d"' {CFLAGS881} macintosh_interfaces.c diff --git a/cseries.lib/macintosh_utilities.c b/cseries.lib/macintosh_utilities.c index 2809f63..017ece2 100644 --- a/cseries.lib/macintosh_utilities.c +++ b/cseries.lib/macintosh_utilities.c @@ -98,6 +98,8 @@ Monday, August 30, 1993 2:57:36 PM hide/show_menu_bar work with multiple monitors, to an extent. Wednesday, September 1, 1993 12:11:33 PM moved MostDevice and menu bar routines to DEVICES.C. +Friday, April 14, 1995 9:50:43 AM (Jason') + added screen saver voodoo. */ #include "macintosh_cseries.h" @@ -106,6 +108,9 @@ Wednesday, September 1, 1993 12:11:33 PM #include #include +#define AD20x +#include "AfterDarkGestalt.h" + #ifdef mpwc #pragma segment modules #endif @@ -118,6 +123,8 @@ Wednesday, September 1, 1993 12:11:33 PM #define POPUP_ARROW_HEIGHT 6 #define POPUP_ARROW_WIDTH (2*(POPUP_ARROW_HEIGHT-1)) +#define VERS_RESOURCE_ID 1 + /* missing from Window.h, probably for a damn good reason :) */ enum { @@ -192,12 +199,10 @@ static boolean debug_status= TRUE; static boolean debug_status= FALSE; #endif -#ifdef env68k -/* non-zero if macsbug is installed on 68k machines */ -#define MacJmp *((Ptr*)0x120) -#endif +static boolean debugger_installed= FALSE; /* ---------- private prototypes */ +static OSErr FSSpecAppendSuffix(FSSpec *source, FSSpec *destination, char *new_suffix); /* ---------- code */ @@ -282,19 +287,22 @@ void modify_menu_item( menu_handle= GetMHandle(menu); assert(menu_handle); - - if (status) - { - EnableItem(menu_handle, item); - } - else - { - DisableItem(menu_handle, item); - } - - if (check!=NONE) + + if (menu_handle) { - CheckItem(menu_handle, item, check); + if (status) + { + EnableItem(menu_handle, item); + } + else + { + DisableItem(menu_handle, item); + } + + if (check!=NONE) + { + CheckItem(menu_handle, item, check); + } } return; @@ -309,19 +317,32 @@ void _assertion_failure( Str255 buffer; #ifdef DEBUG -#ifdef env68k - if (MacJmp) + if (debugger_installed) { - psprintf(buffer, "%s in %s,#%d: %s", fatal ? "halt" : "pause", file, line, + psprintf((char *)buffer, "%s in %s,#%d: %s", fatal ? "halt" : "pause", file, line, information ? information : ""); DebugStr(buffer); } else -#endif #endif { - psprintf(buffer, "Sorry, a run-time assertion failed in “%s” at line #%d. PLEASE WRITE THIS DOWN AND MAKE A BUG REPORT!", file, line); - ParamText(buffer, "\p-1", "", ""); + Handle fkeyHandle= GetResource('FKEY', 3); + + /* load and call FKEY 3 to get a screen shot before we draw a dialog over everything */ + + if (fkeyHandle) + { + LoadResource(fkeyHandle); + if (*fkeyHandle) + { + HLock(fkeyHandle); + CallFKEYProc((FKEYUPP) *fkeyHandle); + HUnlock(fkeyHandle); + } + } + + psprintf((char *)buffer, "Sorry, a run-time assertion failed in “%s” at line #%d. PLEASE WRITE THIS DOWN AND MAKE A BUG REPORT!", file, line); + ParamText(buffer, "\p-1", (StringPtr)"", (StringPtr)""); Alert(fatal ? alrtFATAL_ERROR : alrtNONFATAL_ERROR, (ModalFilterUPP) NULL); } @@ -344,13 +365,13 @@ void alert_user( char buffer[50]; psprintf(buffer, "%d", identifier); - ParamText(getpstr(temporary, resource_number, error_number), buffer, "", ""); + ParamText((StringPtr)getpstr(temporary, resource_number, error_number), (StringPtr)buffer, (StringPtr)"", (StringPtr)""); switch(type) { case fatalError: Alert(alrtFATAL_ERROR, (ModalFilterUPP) NULL); - ParamText("", "", "", ""); + ParamText((StringPtr)"", (StringPtr)"", (StringPtr)"", (StringPtr)""); exit(-1); case infoError: @@ -361,7 +382,7 @@ void alert_user( halt(); } - ParamText("", "", "", ""); + ParamText((StringPtr)"", (StringPtr)"", (StringPtr)"", (StringPtr)""); return; } @@ -397,6 +418,7 @@ long whats_on_top( return NONE; } +#ifdef OBSOLETE OSErr choose_new_file( short *file_handle, short *reference_number, @@ -471,6 +493,7 @@ OSErr choose_and_open_file( return error; } +#endif void mark_for_update( GrafPtr port, @@ -541,28 +564,83 @@ void stay_awake( return; } -void *new_pointer( +void *malloc( long size) { return NewPtr(size); } -void dispose_pointer( +void free( void *pointer) { - DisposePtr(pointer); + DisposePtr((Ptr)pointer); +} + +// This is the most overloaded routine I've seen in a long time. +void *realloc( + void *pointer, + size_t size) +{ + if ((pointer==NULL) && (size!=0)) + { + return NewPtr(size); + } + + if (size==0) + { + if (pointer) DisposePtr((Ptr)pointer); + return NULL; + } + + if (size==GetPtrSize((Ptr)pointer)) return pointer; + + SetPtrSize((Ptr)pointer, size); + + // SetPtrSize can fail if the pointer couldn't be expanded in place + if (MemError()) + { + Size old_size= GetPtrSize((Ptr)pointer); + Ptr realloced_pointer= NewPtr(size); + + // so we make a whole new one if possible + if (MemError()) return NULL; + + // and copy the data into it. + BlockMoveData(pointer, realloced_pointer, old_size > size ? size : old_size); + // and then destroy the old pointer + DisposePtr((Ptr)pointer); + + return realloced_pointer; + } + return pointer; } -void **new_handle( +handle rmalloc( long size) { - return NewHandle(size); + return (handle) NewHandle(size); +} + +void rfree( + handle h) +{ + DisposeHandle((Handle)h); +} + +void *rlock( + handle h) +{ + HLock((Handle)h); + + return (void *) *((Handle)h); } -void dispose_handle( - void **handle) +void runlock( + handle h) { - DisposeHandle(handle); + HUnlock((Handle)h); + + return; } void draw_popup_frame( @@ -591,32 +669,107 @@ char *getpstr( short string_number) { Handle strings= GetResource('STR#', resource_number); - short count; - byte *string_address; - + assert(strings); - assert(string_number>=0&&string_number<**((short**)strings)); - - HLock(strings); - count= 0; - string_address= ((byte *)*strings)+2; - while (count++=0&&string_number<**((short**)strings), + csprintf(temporary, "asked for #%d/#%d in 'STR#' ID#%d", string_number, **((short**)strings), resource_number)); + + HLock(strings); + count= 0; + string_address= ((byte *)*strings)+2; + while (count++=0 && font_index<*((short *) *resource)); - - /* Get to the right one.. */ - *font_info= *((TextSpecPtr)(*resource+sizeof(short))+font_index); + if (resource) + { + /* First short is the count */ + assert(font_index>=0 && font_index<*((short *) *resource)); + + /* Get to the right one.. */ + *font_info= *((TextSpecPtr)(*resource+sizeof(short))+font_index); + } + else + { + memset(font_info, 0, sizeof(TextSpecPtr)); + } return; } @@ -957,3 +1145,223 @@ void GetFont( return; } + +short get_our_country_code( + void) +{ + short country_code; + Handle vers_rsrc; + + country_code = 0; // this is the U.S. code. an ok default. + vers_rsrc = GetResource('vers', VERS_RESOURCE_ID); + if (vers_rsrc) + { + VersRec *vers; + + vers = (VersRec *) *vers_rsrc; + country_code = vers->countryCode; + } + + return country_code; +} + +short wait_for_click_or_keypress( + long maximum_delay) +{ + short keycode; + EventRecord event; + long first_tick= TickCount(); + + FlushEvents(keyDownMask|keyUpMask|autoKeyMask|mDownMask|mUpMask, 0); + + do + { + global_idle_proc(); + } + while (!GetOSEvent(keyDownMask|autoKeyMask|mDownMask, &event) && + (maximum_delay<0 || (TickCount()-first_tick)> 8; + break; + + default: + halt(); + } + + while (GetOSEvent(keyDownMask|autoKeyMask|mDownMask, &event)); + + return keycode; +} + +/* ---------- screen saver voodoo */ + +enum +{ + uppScreenSaverControlProcInfo= kPascalStackBased + | RESULT_SIZE(SIZE_CODE(sizeof(OSErr))) + | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))) +}; + +static SaverControlProcPtr control_proc; +static UniversalProcPtr control_proc_upp; + +void kill_screen_saver( + void) +{ + long attributes; + OSErr error; + + error= Gestalt(gestaltScreenSaverAttr, &attributes); + if (error==noErr && (attributes&FLAG(gestaltSaverTurnedOn))) + { + error= Gestalt(gestaltScreenSaverControl, (long *) &control_proc); + if (error==noErr) + { +#ifdef env68k + error= control_proc(eSaverOff); +#else + control_proc_upp= (UniversalProcPtr) NewRoutineDescriptor((ProcPtr)control_proc, + uppScreenSaverControlProcInfo, kM68kISA); + + if (control_proc_upp) + { + error= CallUniversalProc(control_proc_upp, uppScreenSaverControlProcInfo, eSaverOff); + } + else + { + error= MemError(); + } +#endif + if (error==noErr) + { + atexit(restore_screen_saver); + } + } + } + + return; +} + +void restore_screen_saver( + void) +{ + OSErr error; + +#ifdef env68k + error= control_proc(eSaverOn); +#else + error= CallUniversalProc(control_proc_upp, uppScreenSaverControlProcInfo, eSaverOn); +#endif + + return; +} + +#include +#include + +static OSErr FSSpecAppendSuffix( + FSSpec *source, + FSSpec *destination, + char *new_suffix) +{ + Str255 name; + OSErr error; + short i; + + pstrcpy((char *)name, (const char *)source->name); + p2cstr(name); + for (i= strlen((const char *)name)-1; i; --i) + { + if (name[i]=='.') name[i]= 0; + if (name[i]==':') break; + } + strcat((char *)name, new_suffix); + c2pstr((char *)name); + error= FSMakeFSSpec(0, source->parID, name, destination); + + return error; +} + +/* Get a fsspec from a given file, searching the given path... */ +OSErr get_file_spec( + FSSpec *spec, + short string_resource_id, + short file_name_index, + short path_resource_id) +{ + OSErr err; + FSSpec app_spec; + + /* Look for the files in the same directory that we are in.. */ + err= get_my_fsspec(&app_spec); + if(!err) + { + Boolean is_folder, was_alias; + Str255 fileName, new_filepath; + short ii; + + /* Get their name.. */ + getpstr((char *)fileName, string_resource_id, file_name_index); + + /* Check the first path.. */ + memcpy(new_filepath, fileName, *fileName+1); + err= FSMakeFSSpec(app_spec.vRefNum, app_spec.parID, new_filepath, spec); + + /* Didn't get the file- search for the paths... */ + if(err==fnfErr) + { + short path_count= countstr(path_resource_id); + + for(ii= 0; iigdPMap)->pixelSize==8); + + newBounds= *boundsRect; + OffsetRect(&newBounds, -newBounds.left, -newBounds.top); + + pixels= NewHandle((long)newBounds.right*(long)newBounds.bottom); + world= (myGWorldPtr) NewPtr(sizeof(struct myGWorld)); + if (world&&pixels) + { + world->device= NewGDevice(NULL, -1); + if (world->device) + { + /* initialize our device */ + device= world->device; + + (*device)->gdID= 0; + (*device)->gdType= clutType; + (*device)->gdResPref= 3; + (*device)->gdSearchProc= NULL; + (*device)->gdCompProc= NULL; + (*device)->gdRect= newBounds; + (*device)->gdFlags= (1<gdPMap; + (*pixmap)->baseAddr= NULL; + (*pixmap)->bounds= newBounds; + (*pixmap)->rowBytes= 0x8000 | (*pixmap)->bounds.right; + (*pixmap)->pixelSize= 8; + (*pixmap)->cmpCount= 1; + (*pixmap)->cmpSize= 8; + + /* install a new color table from the intersected device */ + DisposCTable((*pixmap)->pmTable); + (*pixmap)->pmTable= (*(*intersected_device)->gdPMap)->pmTable; + + error= HandToHand((Handle *)&(*pixmap)->pmTable); + if (error==noErr) + { + (*(*pixmap)->pmTable)->ctFlags= 0; + + MakeITable((*pixmap)->pmTable, (*device)->gdITable, 3); + + myGetGWorld(&old_port, &old_device); + SetGDevice(device); + + /* initialize the cgrafport */ + port= &world->port; + OpenCPort(port); + RectRgn(port->visRgn, &newBounds); + port->portRect= newBounds; + + world->locked= FALSE; + world->pixels= pixels; + + *offscreenGWorld= (GWorldPtr) world; + mySetGWorld(old_port, old_device); + } + } + else + { + error= MemError(); + } + } + else + { + error= MemError(); + } + myQDErrorValue= error; + break; + + case SystemSix32BQD: + error= NewGWorld(offscreenGWorld, PixelDepth, boundsRect, cTable, aGDevice, 0); + break; + case SystemSeven32BQD: + error= NewGWorld(offscreenGWorld, PixelDepth, boundsRect, cTable, aGDevice, keepLocal); + break; + + default: + halt(); + } + + return error; +} + +void myDisposeGWorld( + GWorldPtr offscreenGWorld) +{ + switch(offscreen_type) + { + case SystemSixQD: + DisposGDevice(((myGWorldPtr)offscreenGWorld)->device); + DisposeHandle(((myGWorldPtr)offscreenGWorld)->pixels); + DisposePtr((Ptr)offscreenGWorld); + myQDErrorValue= noErr; + break; + + case SystemSix32BQD: + case SystemSeven32BQD: + DisposeGWorld(offscreenGWorld); + break; + + default: + halt(); + } + + return; +} + +Boolean myLockPixels( + GWorldPtr world) +{ + myGWorldPtr myworld= (myGWorldPtr) world; + + switch(offscreen_type) + { + case SystemSixQD: + assert(!myworld->locked); + myworld->locked= TRUE; + HLock(myworld->pixels); + (*(*myworld->device)->gdPMap)->baseAddr= StripAddress(*(myworld->pixels)); + (*myworld->port.portPixMap)->baseAddr= StripAddress(*(myworld->pixels)); + return TRUE; + + case SystemSix32BQD: + return LockPixels(world->portPixMap); + + case SystemSeven32BQD: + return LockPixels(GetGWorldPixMap(world)); + + default: + halt(); + } +} + +void myUnlockPixels( + GWorldPtr world) +{ + myGWorldPtr myworld= (myGWorldPtr) world; + + switch(offscreen_type) + { + case SystemSixQD: + assert(myworld->locked); + myworld->locked= FALSE; + HUnlock(myworld->pixels); + (*(*myworld->device)->gdPMap)->baseAddr= NULL; + break; + + case SystemSix32BQD: + UnlockPixels(world->portPixMap); + break; + + case SystemSeven32BQD: + UnlockPixels(GetGWorldPixMap(world)); + break; + + default: + halt(); + } +} + +PixMapHandle myGetGWorldPixMap( + GWorldPtr offscreenGWorld) +{ + switch(offscreen_type) + { + case SystemSixQD: + case SystemSix32BQD: + /* though these are two totally different structures, they both begin with a CGrafPort + so this should work fine */ + return offscreenGWorld->portPixMap; + + case SystemSeven32BQD: + return GetGWorldPixMap(offscreenGWorld); + + default: + halt(); + } +} + +Ptr myGetPixBaseAddr( + GWorldPtr world) +{ + switch(offscreen_type) + { + case SystemSixQD: + assert(((myGWorldPtr)world)->locked); + return StripAddress(*(((myGWorldPtr)world)->pixels)); + + case SystemSix32BQD: + return GetPixBaseAddr(world->portPixMap); + + case SystemSeven32BQD: + return GetPixBaseAddr(GetGWorldPixMap(world)); + + default: + halt(); + } +} + +void myGetGWorld( + CGrafPtr *port, + GDHandle *gdh) +{ + switch(offscreen_type) + { + case SystemSixQD: + GetPort((GrafPtr *)port); + *gdh= GetGDevice(); + break; + + case SystemSix32BQD: + case SystemSeven32BQD: + GetGWorld(port, gdh); + break; + + default: + halt(); + } + + return; +} + +OSErr myQDError( + void) +{ + OSErr error; + + switch(offscreen_type) + { + case SystemSixQD: + error= myQDErrorValue; + break; + + default: + error= QDError(); + break; + } + + return error; +} + +void mySetGWorld( + CGrafPtr port, + GDHandle gdh) +{ + switch(offscreen_type) + { + case SystemSixQD: + if (IS_MYGWORLD(port)) + { + SetPort((GrafPtr)port); + SetGDevice(((myGWorldPtr)port)->device); + } + else + { + assert(gdh); + SetPort((GrafPtr)port); + SetGDevice(gdh); + } + break; + + case SystemSix32BQD: + case SystemSeven32BQD: + SetGWorld(port, gdh); + break; + + default: + halt(); + } +} + +/* we don’t behave exactly like the real 32BQD here because it would try to align + the pixmap for best copying performance, etc */ +GWorldFlags myUpdateGWorld( + GWorldPtr *offscreenGWorld, + short pixelDepth, + const Rect *boundsRect, + CTabHandle cTable, + GDHandle aGDevice, + GWorldFlags flags) +{ + GDHandle intersected_device; + CTabHandle intersected_color_table, world_color_table; + PixMapHandle intersected_pixmap, world_pixmap; + myGWorldPtr world= (myGWorldPtr) *offscreenGWorld; + short exit_flags; + Rect newBounds; + +#ifndef DEBUG + #pragma unused (flags) +#endif + + assert(!cTable&&!pixelDepth&&!flags); + + intersected_device= GetMaxDevice(boundsRect); + assert(intersected_device); + + intersected_pixmap= (*intersected_device)->gdPMap; + intersected_color_table= (*intersected_pixmap)->pmTable; + + exit_flags= 0; + switch(offscreen_type) + { + case SystemSixQD: + assert((*intersected_pixmap)->pixelSize==8); + + myQDErrorValue= noErr; + + world_pixmap= (*world->device)->gdPMap; + world_color_table= (*world_pixmap)->pmTable; + + /* check bounds; reallocate if changed */ + newBounds= *boundsRect; + OffsetRect(&newBounds, -newBounds.left, -newBounds.top); + if (newBounds.right!=world->port.portRect.right|| + newBounds.bottom!=world->port.portRect.bottom) + { + SetHandleSize(world->pixels, newBounds.right*newBounds.bottom); + if (MemError()!=noErr) + { + DisposeHandle(world->pixels); + world->pixels= NewHandle(newBounds.right*newBounds.bottom); + if (MemError()!=noErr) + { + myQDErrorValue= MemError(); + exit_flags|= gwFlagErr; + } + } + + if (myQDErrorValue==noErr) + { + (*world->device)->gdRect= newBounds; + (*world_pixmap)->bounds= newBounds; + (*world_pixmap)->rowBytes= 0x8000 | (*world_pixmap)->bounds.right; + RectRgn(world->port.visRgn, &newBounds); + world->port.portRect= newBounds; + + exit_flags|= reallocPix; + } + } + + if (myQDErrorValue==noErr) + { + /* check color table; bag old one if changed and copy in the new one */ + if ((*world_color_table)->ctSeed!=(*intersected_color_table)->ctSeed) + { + DisposCTable((*world_pixmap)->pmTable); + (*world_pixmap)->pmTable= intersected_color_table; + + if (HandToHand((Handle *)&(*world_pixmap)->pmTable)==noErr) + { + world_color_table= (*world_pixmap)->pmTable; + (*world_color_table)->ctFlags= 0; + + MakeITable(world_color_table, (*world->device)->gdITable, 3); + } + else + { + myQDErrorValue= MemError(); + exit_flags|= reallocPix; + } + } + } + + break; + + case SystemSix32BQD: + /* we’re fucked: system 6.0’s _UpdateGWorld doesn’t always work and we can’t + use our own method-- so we bag and reallocate it */ + DisposeGWorld(*offscreenGWorld); + if (NewGWorld(offscreenGWorld, pixelDepth, boundsRect, cTable, aGDevice, 0)!=noErr) + { + exit_flags= gwFlagErr; + } + break; + + case SystemSeven32BQD: + exit_flags= UpdateGWorld(offscreenGWorld, pixelDepth, boundsRect, cTable, aGDevice, 0); + break; + } + + return exit_flags; +} diff --git a/cseries.lib/my32bqd.h b/cseries.lib/my32bqd.h new file mode 100644 index 0000000..4b9c5ed --- /dev/null +++ b/cseries.lib/my32bqd.h @@ -0,0 +1,31 @@ +#ifndef __MY32BQD_H +#define __MY32BQD_H + +/* +MY32BQD.H +Saturday, January 11, 1992 7:40:52 PM +*/ + +void initialize_my_32bqd(void); + +QDErr myNewGWorld(GWorldPtr *offscreenGWorld, short PixelDepth, + const Rect *boundsRect, CTabHandle cTable, GDHandle aGDevice, + GWorldFlags flags); +void myDisposeGWorld(GWorldPtr offscreenGWorld); + +GWorldFlags myUpdateGWorld(GWorldPtr *offscreenGWorld, short pixelDepth, + const Rect *boundsRect, CTabHandle cTable, GDHandle aGDevice, + GWorldFlags flags); + +OSErr myQDError(void); + +Boolean myLockPixels(GWorldPtr offscreenGWorld); +void myUnlockPixels(GWorldPtr offscreenGWorld); + +PixMapHandle myGetGWorldPixMap(GWorldPtr offscreenGWorld); +Ptr myGetPixBaseAddr(GWorldPtr offscreenGWorld); + +void myGetGWorld(CGrafPtr *port, GDHandle *gdh); +void mySetGWorld(CGrafPtr port, GDHandle gdh); + +#endif diff --git a/cseries.lib/mytm.c b/cseries.lib/mytm.c index f8f63ca..c8e251e 100644 --- a/cseries.lib/mytm.c +++ b/cseries.lib/mytm.c @@ -9,6 +9,10 @@ Wednesday, June 29, 1994 10:31:55 PM #include "macintosh_cseries.h" #include "mytm.h" +#ifdef mpwc +#pragma segment modules +#endif + /* ---------- globals */ static TimerUPP myTMTaskUPP= (TimerUPP) NULL; @@ -21,11 +25,14 @@ static pascal void myTMTaskProc(void); static void myTMTaskProc(TMTaskPtr tmTask); #endif +static void myInsTime(myTMTaskPtr myTask); + /* ---------- code */ -myTMTaskPtr myTMSetup( +myTMTaskPtr myTimeManagerSetup( long period, - myTMTaskProcPtr procedure) + myTMTaskProcPtr procedure, + boolean useExtendedTM) { myTMTaskPtr myTask= (myTMTaskPtr) NewPtrClear(sizeof(myTMTask)); @@ -38,9 +45,9 @@ myTMTaskPtr myTMSetup( #endif myTask->period= period; myTask->procedure= procedure; - myTask->tmTask.tmAddr= (TimerUPP) myTMTaskUPP; + myTask->useExtendedTM= useExtendedTM; - InsTime((QElemPtr)myTask); + myInsTime(myTask); PrimeTime((QElemPtr)myTask, period); } @@ -53,7 +60,7 @@ void myTMReset( assert(myTask); RmvTime((QElemPtr)myTask); - InsTime((QElemPtr)myTask); + myInsTime(myTask); PrimeTime((QElemPtr)myTask, myTask->period); return; @@ -77,7 +84,7 @@ myTMTaskPtr myTMRemove( static pascal void myTMTaskProc( void) { - myTMTaskPtr myTask= get_a1(); /* get the pointer to this Time Manager task record from a1 */ + myTMTaskPtr myTask= (myTMTaskPtr) get_a1(); /* get the pointer to this Time Manager task record from a1 */ long old_a5= set_a5(myTask->a5); /* set our a5 world */ TMTaskPtr tmTask= &myTask->tmTask; #else @@ -99,3 +106,16 @@ static void myTMTaskProc( return; } + +static void myInsTime( + myTMTaskPtr myTask) +{ + myTask->tmTask.tmCount= 0; + myTask->tmTask.tmWakeUp= 0; + myTask->tmTask.tmReserved= 0; + myTask->tmTask.tmAddr= (TimerUPP) myTMTaskUPP; + + myTask->useExtendedTM ? InsXTime((QElemPtr)myTask) : InsTime((QElemPtr)myTask); + + return; +} diff --git a/cseries.lib/mytm.h b/cseries.lib/mytm.h index a8cce57..c3cfec7 100644 --- a/cseries.lib/mytm.h +++ b/cseries.lib/mytm.h @@ -5,6 +5,9 @@ Sunday, June 26, 1994 11:11:20 PM #include +#define myTMSetup(period, proc) myTimeManagerSetup(period, proc, FALSE) +#define myXTMSetup(period, proc) myTimeManagerSetup(period, proc, TRUE) + /* ---------- types */ typedef boolean (*myTMTaskProcPtr)(void); @@ -23,11 +26,12 @@ struct myTMTask myTMTaskProcPtr procedure; boolean active; + boolean useExtendedTM; }; typedef struct myTMTask myTMTask, *myTMTaskPtr; /* ---------- prototypes/MYTM.C */ -myTMTaskPtr myTMSetup(long period, myTMTaskProcPtr procedure); +myTMTaskPtr myTimeManagerSetup(long period, myTMTaskProcPtr procedure, boolean useExtendedTM); void myTMReset(myTMTaskPtr myTask); myTMTaskPtr myTMRemove(myTMTaskPtr myTask); /* returns NULL */ diff --git a/cseries.lib/preferences.c b/cseries.lib/preferences.c index 0d4a8a5..5e21d6b 100644 --- a/cseries.lib/preferences.c +++ b/cseries.lib/preferences.c @@ -20,10 +20,13 @@ Wednesday, July 28, 1993 8:59:24 AM Wednesday, December 8, 1993 2:16:37 PM the preferences are now allocated in a pointer. are_preferences_out_of_date was removed and read_preferences_file does all the magic now. +Monday, August 15, 1994 9:41:52 PM + now there is checksumming of the files, using the stuff from checksum.c */ #include "macintosh_cseries.h" #include "preferences.h" +#include "checksum.h" #include @@ -33,10 +36,21 @@ Wednesday, December 8, 1993 2:16:37 PM /* ---------- constants */ +#define PREFERENCES_HEADER_VERSION 1 + /* ---------- structures */ +struct preferences_header +{ + short preferences_version; + short preferences_header_version; + Checksum checksum; +}; + struct preferences_info { + short preferences_version; + short preferences_size; short prefVRefNum; long prefDirID; @@ -55,15 +69,26 @@ OSErr write_preferences_file( long size; OSErr error; short refNum; - + struct preferences_header header; + error= HOpen(prefInfo->prefVRefNum, prefInfo->prefDirID, prefInfo->prefName, fsRdWrPerm, &refNum); if (error==noErr) { - size= GetPtrSize(preferences); - assert(size>0); + header.preferences_header_version = PREFERENCES_HEADER_VERSION; + header.preferences_version = prefInfo->preferences_version; + new_checksum(&header.checksum, ADD_CHECKSUM); + update_checksum(&header.checksum, preferences, prefInfo->preferences_size); + size = sizeof(header); + error = FSWrite(refNum, &size, (Ptr) &header); - error= FSWrite(refNum, &size, preferences); - FSClose(refNum); + if (error == noErr) + { + size= GetPtrSize(preferences); + assert(size>0); + + error= FSWrite(refNum, &size, preferences); + FSClose(refNum); + } } return error; @@ -86,10 +111,14 @@ OSErr read_preferences_file( short refNum; OSErr error; long actual_size, size; + struct preferences_header header; + Checksum check; /* allocate space for our global structure to keep track of the prefs file */ prefInfo= (struct preferences_info *) NewPtr(sizeof(struct preferences_info)+*prefName); BlockMove(prefName, prefInfo->prefName, *prefName+1); + prefInfo->preferences_version = expected_version; + prefInfo->preferences_size = expected_size; /* allocate space for the prefs themselves */ *preferences= NewPtrClear(expected_size); @@ -119,14 +148,26 @@ OSErr read_preferences_file( /* read as many bytes as we can or as will fit into our buffer from the preferences file */ actual_size= infoPB->hFileInfo.ioFlLgLen; - size= MIN(expected_size, actual_size); - error= FSRead(refNum, &size, *preferences); + + size = MIN(sizeof(struct preferences_header), actual_size); + error = FSRead(refNum, &size, &header); + + size= MIN(expected_size, actual_size - sizeof(struct preferences_header)); + if (size > 0) + error= FSRead(refNum, &size, *preferences); + else + error= TRUE; FSClose(refNum); if (error==noErr) { - /* if we've got the wrong size or the wrong version, reinitialize */ - if (actual_size!=expected_size||*((short*)*preferences)!=expected_version) + new_checksum(&check, ADD_CHECKSUM); + update_checksum(&check, *preferences, size); + /* if we've got bad prefs, reinitialize */ + if (actual_size-sizeof(struct preferences_header) != expected_size + || header.preferences_header_version != PREFERENCES_HEADER_VERSION + || header.preferences_version != expected_version + || !equal_checksums(&header.checksum, &check)) { initialize_preferences(*preferences); error= write_preferences_file(*preferences); diff --git a/cseries.lib/preferences.h b/cseries.lib/preferences.h new file mode 100644 index 0000000..d87b15a --- /dev/null +++ b/cseries.lib/preferences.h @@ -0,0 +1,16 @@ +#ifndef __PREFERENCES_H +#define __PREFERENCES_H + +/* +PREFERENCES.H +Tuesday, September 29, 1992 11:17:46 AM +*/ + +/* ---------- prototypes: PREFERENCES.C */ + +OSErr read_preferences_file(void **preferences, char *prefName, OSType prefCreator, + OSType prefType, short expected_version, long expected_size, + void (*initialize_preferences)(void *preferences)); +OSErr write_preferences_file(void *preferences); + +#endif diff --git a/cseries.lib/proximity_strcmp.c b/cseries.lib/proximity_strcmp.c new file mode 100644 index 0000000..b499a64 --- /dev/null +++ b/cseries.lib/proximity_strcmp.c @@ -0,0 +1,157 @@ +/* +PROXIMITY_STRCMP.C +Wednesday, December 9, 1992 6:44:28 PM + +Wednesday, December 9, 1992 6:57:28 PM + pattern matcher from dr. dobb’s journal, ‘heavily modified’. +*/ + +#include +#include + +#include "cseries.h" +#include "proximity_strcmp.h" + +/* ---------- private prototypes */ + +short find_pattern(char *string1, short len1, char *string2, short len2); + +/* ---------- code */ + +short proximity_strcmp( + char *string1, + char *string2) +{ + short total; + + total= find_pattern(string1, strlen(string1), string2, strlen(string2)); + + return (2*PERFECT_MATCH*total)/(strlen(string1)+strlen(string2)); +} + +/* ---------- private code */ + +#if 0 +short find_pattern( + char *string1, + short len1, + char *string2, + short len2) +{ + register short pos1, pos2, offset; + register short current, longest, lpos1, lpos2; + register short total; + + for (longest= pos1= 0;pos1=len2)||(pos1+offset>=len1) + ||*(string1+pos1+offset)!=*(string2+pos2+offset)) + { + if (current>longest) + longest= current, lpos1= pos1, lpos2= pos2; + break; + } + } + } + + if (!longest) + { + return 0; + } + + total= longest; + if (lpos1&&lpos2) + { + total+= find_pattern(string1, lpos1, string2, lpos2); + } + if ((lpos1+longestlongest) + { + longest= current, lpos1= pos1, lpos2= pos2; + } + } + } + + total= longest; + if (total) + { + if (lpos1&&lpos2) + { + total+= find_pattern(string1, lpos1, string2, lpos2); + } + if ((lpos1+longest=len2)||(pos1+offset>=len1) + ||tolower(*(string1+pos1+offset))!=tolower(*(string2+pos2+offset))) + { + if (current>longest) + longest=current,lpos1=pos1,lpos2=pos2; + break; + } + } + + if (!longest) + return 0; + + total= longest; + if (lpos1&&lpos2) + total+= find_pattern(string1, lpos1, string2, lpos2); + if ((lpos1+longest=0’ expressions to ‘raw_size>0’ in compress_bytes, in an attempt to + fix the above problem. i doubt this is it. +Friday, February 19, 1993 1:58:23 PM + the read pointer in compress bytes wasn’t getting incremented while scanning non-repeating + data. who the fuck did that and have they gotten the tree out of their ass yet? and what + the hell, the raw_count was not being reset after we’d scanned 127 (or whatever) bytes of + uncompressable data. blow me. is it possible that minotaur’s shapes never contained + that much uncompressable data? +Wednesday, March 3, 1993 8:29:03 PM + this is a fucking comedy, right? we were allowing repeats of 131 bytes, which encoded + to [128] [byte] and only dropped one. deja vu: “is it possible that minotaur’s shapes + never contained that much COMPRESSABLE data?” what a piece of shit. that delayed me + three hours. +*/ + +#include "cseries.h" +#include "rle.h" + +#ifdef mpwc +#pragma segment modules +#endif + +/* ---------- code */ + +long compress_bytes( + byte *raw, + long raw_size, + byte *compressed, + long maximum_compressed_size) +{ + register byte *read; + register byte *write; + byte *last_raw_count; + long size; + short count; + register byte value; + + *((long*)compressed)= raw_size; + read= raw, write= compressed+4; + count= 0, size= 4, last_raw_count= (byte *) NULL; + + while (raw_size>0&&size=3&&value==*(read+1)&&value==*(read+2)) + { + if (last_raw_count) + { + *last_raw_count= count+127; + } + + count= 3; + read+= 3; + raw_size-= 3; + while (raw_size>0&&count<130&&value==*read) + { + read+= 1; + raw_size-= 1; + count+= 1; + } + + *write++= count-3; + *write++= value; + size+= 2; + + last_raw_count= (byte *) NULL; + count= 0; + } + else + { + if (!last_raw_count) + { + last_raw_count= write++; + size+= 1; + } + + *write++= value; + raw_size-= 1; + count+= 1; + size+= 1; + + if (count==255-127||!raw_size) + { + *last_raw_count= count+127; + + last_raw_count= (byte *) NULL; + count= 0; + } + + read+= 1; + } + } + + if (size>=maximum_compressed_size) + { + return -1; + } + else + { + return size; + } +} + +long get_destination_size( + byte *compressed) +{ + return *((long*)compressed); +} + +/* raw damn well have better been created after a get_destination_size call */ +void uncompress_bytes( + byte *compressed, + byte *raw) +{ + register byte *read; + register byte *write; + long current_size, raw_size; + short count; + byte value; + + current_size= 0; + raw_size= *((long*)compressed); + read= compressed+sizeof(long), write= raw; + + while (current_size - -#ifdef mpwc -#pragma segment modules -#endif - -/* ---------- constants */ - -#define TEMPORARY_FILENAME "\pGunfighter’s Amnesia" - -/* ---------- structures */ - -/* ---------- globals */ - -/* ---------- code */ - -OSErr OpenTemporaryFile( - short *tempRefNum) -{ - short tempVRefNum; - long tempDirID; - OSErr error; - - /* check for the temporary folder using FindFolder, creating it if necessary */ - FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &tempVRefNum, &tempDirID); - - error= HCreate(tempVRefNum, tempDirID, TEMPORARY_FILENAME, '\?\?\?\?', 'TEMP'); - if (error==noErr||error==dupFNErr) - { - error= HOpen(tempVRefNum, tempDirID, TEMPORARY_FILENAME, fsRdWrPerm, tempRefNum); - } - - return error; -} - -OSErr CloseTemporaryFile( - short tempRefNum) -{ - short tempVRefNum; - long tempDirID; - OSErr error; - - error= FSClose(tempRefNum); - if (error==noErr) - { - /* check for the temporary folder using FindFolder, creating it if necessary */ - FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &tempVRefNum, &tempDirID); - - error= HDelete(tempVRefNum, tempDirID, TEMPORARY_FILENAME); - } - - return error; -} diff --git a/cseries.lib/temporary_files.h b/cseries.lib/temporary_files.h deleted file mode 100644 index 8f0727e..0000000 --- a/cseries.lib/temporary_files.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __TEMPORARY_FILES_H -#define __TEMPORARY_FILES_H - -/* -TEMPORARY_FILES.H -Thursday, March 25, 1993 6:50:28 PM -*/ - -OSErr OpenTemporaryFile(short *tempRefNum); -OSErr CloseTemporaryFile(short tempRefNum); - -#endif diff --git a/cseries.lib/textures.h b/cseries.lib/textures.h new file mode 100644 index 0000000..e9b5a40 --- /dev/null +++ b/cseries.lib/textures.h @@ -0,0 +1,86 @@ +#ifndef __TEXTURES_H +#define __TEXTURES_H + +/* +TEXTURES.H +Saturday, August 20, 1994 12:08:34 PM +*/ + +/* ---------- pixels */ + +typedef unsigned char pixel8; +typedef unsigned short pixel16; +typedef unsigned long pixel32; + +#define PIXEL8_MAXIMUM_COLORS 256 +#define PIXEL16_MAXIMUM_COLORS 32768 +#define PIXEL32_MAXIMUM_COLORS 16777216 + +#define PIXEL16_BITS 5 +#define PIXEL32_BITS 8 + +#define NUMBER_OF_COLOR_COMPONENTS 3 +#define PIXEL16_MAXIMUM_COMPONENT 0x1f +#define PIXEL32_MAXIMUM_COMPONENT 0xff + +#define RED16(p) ((p)>>10) /* pel must be clean */ +#define GREEN16(p) (((p)>>5)&PIXEL16_MAXIMUM_COMPONENT) +#define BLUE16(p) ((p)&PIXEL16_MAXIMUM_COMPONENT) +#define BUILD_PIXEL16(r,g,b) (((r)<<10)|((g)<<5)|(b)) +#define RGBCOLOR_TO_PIXEL16(r,g,b) (((pixel16)((r)>>1)&(pixel16)0x7c00)|((pixel16)((g)>>6)&(pixel16)0x03e0)|((pixel16)((b)>>11)&(pixel16)0x1f)) + +#define RED32(p) ((p)>>16) /* pel must be clean; may be impossible */ +#define GREEN32(p) (((p)>>8)&PIXEL32_MAXIMUM_COMPONENT) +#define BLUE32(p) ((p)&PIXEL32_MAXIMUM_COMPONENT) +#define BUILD_PIXEL32(r,g,b) (((r)<<16)|((g)<<8)|(b)) +#define RGBCOLOR_TO_PIXEL32(r,g,b) (((((pixel32)(r))<<8)&0x00ff0000) | ((((pixel32)(g)))&0x0000ff00) | ((((pixel32)(b))>>8)&0x000000ff)) + +/* ---------- color tables */ + +struct rgb_color +{ + word red, green, blue; +}; + +struct color_table +{ + short color_count; + + struct rgb_color colors[256]; +}; + +/* ---------- structures */ + +enum /* bitmap flags */ +{ + _COLUMN_ORDER_BIT= 0x8000, + _TRANSPARENT_BIT= 0x4000 +}; + +struct bitmap_definition +{ + short width, height; /* in pixels */ + short bytes_per_row; /* if ==NONE this is a transparent RLE shape */ + + short flags; /* [column_order.1] [unused.15] */ + short bit_depth; /* should always be ==8 */ + + short unused[8]; + + pixel8 *row_addresses[1]; +}; + +/* ---------- prototypes/TEXTURES.C */ + +/* assumes pixel data follows bitmap_definition structure immediately */ +pixel8 *calculate_bitmap_origin(struct bitmap_definition *bitmap); + +/* initialize bytes_per_row, height and row_address[0] before calling */ +void precalculate_bitmap_row_addresses(struct bitmap_definition *texture); + +void map_bytes(byte *buffer, byte *table, long size); +void remap_bitmap(struct bitmap_definition *bitmap, pixel8 *table); + +void erase_bitmap(struct bitmap_definition *bitmap, long pel); + +#endif diff --git a/marathon2/buildfat b/marathon2/buildfat new file mode 100644 index 0000000..dab119d --- /dev/null +++ b/marathon2/buildfat @@ -0,0 +1,6 @@ +Directory "gungnir:marathon2:" +Set Target "marathon2" + +duplicate -y {Target}.ppc {Target}.fat +noresnames {Target}.fat +rez {Target}.r -d CODE_FILE=∂"{Target}.68k∂" -append -o {Target}.fat diff --git a/marathon2/buildprogram b/marathon2/buildprogram index 6a44c3f..6d80e13 100644 --- a/marathon2/buildprogram +++ b/marathon2/buildprogram @@ -61,6 +61,8 @@ Set Targ68k "{Application}" Set DemoTarg68k "{Application}.demo" Set TargPPC "{Application}.ppc" Set DemoTargPPC "{Application}.ppc.demo" +Set SprocketSupport "-d SPROCKETS -d SUPPORT_INPUT_SPROCKET" +Set SprocketLibraries "" #options for 68k full versions if "{program}" == "{Application}.alpha" || "{program}" == "{Application}.alpha.ppc" || "{program}" == "{Application}.alpha.fat" @@ -70,14 +72,14 @@ if "{program}" == "{Application}.alpha" || "{program}" == "{Application}.alpha.p Set VersionCOptions "-mbg on -d GAME -d ALPHA -d PERFORMANCE -d COMPILE_TIME=`Date -n`" Set Targ68k "{Application}.alpha" Set Link68kOptions "-l" - Set CSeriesLibraries68k "{CSeriesLibraries}cseries.debug.lib {Libraries}PerformLib.o" + Set CSeriesLibraries68k "∂"{CSeriesLibraries}∂"cseries.debug.lib {Libraries}PerformLib.o" else if "{program}" == "{Application}.beta" || "{program}" == "{Application}.beta.ppc" || "{program}" == "{Application}.beta.fat" Set Obj68k ":objects:game:68k:beta:" Set VerRezOptions "-d DEBUG" Set VersionAsmOptions "-d DEBUG=1" Set VersionCOptions "-d DEBUG -mbg on -d GAME -d BETA -d COMPILE_TIME=`Date -n`" Set Targ68k "{Application}.beta" - Set CSeriesLibraries68k "{CSeriesLibraries}cseries.debug.lib" + Set CSeriesLibraries68k "∂"{CSeriesLibraries}∂"cseries.debug.lib" Set Link68kOptions "" else if "{program}" == "{Application}.gamma" || "{program}" == "{Application}.gamma.ppc" || "{program}" == "{Application}.gamma.fat" Set Obj68k ":objects:game:68k:gamma:" @@ -87,13 +89,13 @@ else if "{program}" == "{Application}.gamma" || "{program}" == "{Application}.ga Set Targ68k "{Application}.gamma" Set CSeriesLibraries68k "{CSeriesLibraries}cseries.debug.lib" Set Link68kOptions "" -else if "{program}" == "{Application}" || "{program}" == "{Application}.ppc" || "{program}" == "{Application}.fat" +else if "{program}" == "{Application}" || "{program}" == "{Application}.ppc" || "{program}" == "{Application}.fat" || "{program}" == "{Application}.spr.fat" Set Obj68k ":objects:game:68k:final:" Set VerRezOptions "" Set VersionAsmOptions "-d DEBUG=0" - Set VersionCOptions "-mbg off -d GAME -d FINAL" + Set VersionCOptions "-mbg off -d GAME -d FINAL -d TRILOGY" Set Targ68k "{Application}" - Set CSeriesLibraries68k "{CSeriesLibraries}cseries.lib" + Set CSeriesLibraries68k "∂"{CSeriesLibraries}∂"cseries.lib" Set Link68kOptions "" #options for 68k demo versions @@ -103,21 +105,21 @@ else if "{program}" == "{Application}.demo.alpha" || "{program}" == "{Applicatio Set VersionAsmOptions "-d DEBUG=1" Set VersionCOptions "-d DEBUG -mbg on -d DEMO -d ALPHA -d DEBUG -d COMPILE_TIME=`Date -n`" Set DemoTarg68k "{Application}.demo.alpha" - Set CSeriesLibraries68k "{CSeriesLibraries}cseries.debug.lib" + Set CSeriesLibraries68k "∂"{CSeriesLibraries}∂"cseries.debug.lib" else if "{program}" == "{Application}.demo.beta" || "{program}" == "{Application}.demo.beta.ppc" || "{program}" == "{Application}.demo.beta.fat" Set Obj68k ":objects:demo:68k:beta:" Set VerRezOptions "-d DEBUG -d DEMO" Set VersionAsmOptions "-d DEBUG=1" Set VersionCOptions "-d DEBUG -mbg on -d DEMO -d BETA -d COMPILE_TIME=`Date -n`" Set DemoTarg68k "{Application}.demo.beta" - Set CSeriesLibraries68k "{CSeriesLibraries}cseries.debug.lib" -else if "{program}" == "{Application}.demo" || "{program}" == "{Application}.demo.ppc" || "{program}" == "{Application}.demo.fat" + Set CSeriesLibraries68k "∂"{CSeriesLibraries}∂"cseries.debug.lib" +else if "{program}" == "{Application}.demo" || "{program}" == "{Application}.demo.ppc" || "{program}" == "{Application}.demo.fat" || "{program}" == "{Application}.demo.spr.fat" Set Obj68k ":objects:demo:68k:final:" Set VerRezOptions "-d DEMO" Set VersionAsmOptions "-d DEBUG=0" Set VersionCOptions "-mbg off -d DEMO -d GAME -d FINAL" Set DemoTarg68k "{Application}.demo" - Set CSeriesLibraries68k "{CSeriesLibraries}cseries.lib" + Set CSeriesLibraries68k "∂"{CSeriesLibraries}∂"cseries.lib" else #we must be doing a PowerPC build; set some defaults so Make won't crap looking for 68k variables Set No68k 1 @@ -129,30 +131,64 @@ if "{program}" == "{Application}.alpha.ppc" || "{program}" == "{Application}.alp Set ObjPPC ":objects:game:ppc:alpha:" Set VerRezOptions "-d DEBUG" Set SymbolsPPC "-sym on" - Set VersionPPCCOptions "-opt off {SymbolsPPC} -d GAME -d ALPHA -d DEBUG -d COMPILE_TIME=`Date -n`" + Set VersionPPCCOptions "-opt off -traceback {SymbolsPPC} -d GAME -d ALPHA -d DEBUG -d COMPILE_TIME=`Date -n`" Set TargPPC "{Application}.alpha.ppc" - Set CSeriesLibrariesPPC "{CSeriesLibraries}cseries.sym.xcoff" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.sym.xcoff" else if "{program}" == "{Application}.beta.ppc" || "{program}" == "{Application}.beta" || "{program}" == "{Application}.beta.fat" Set ObjPPC ":objects:game:ppc:beta:" - Set VerRezOptions "-d DEBUG" + Set VerRezOptions "" Set SymbolsPPC "-sym off" - Set VersionPPCCOptions "-opt speed {SymbolsPPC} -d GAME -d DEBUG -d BETA -d COMPILE_TIME=`Date -n`" + Set VersionPPCCOptions "-opt speed,unroll,unswitch -traceback {SymbolsPPC} -d GAME -d DEBUG -d BETA -d COMPILE_TIME=`Date -n`" Set TargPPC "{Application}.beta.ppc" - Set CSeriesLibrariesPPC "{CSeriesLibraries}cseries.debug.xcoff" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.debug.xcoff" else if "{program}" == "{Application}.gamma.ppc" || "{program}" == "{Application}.gamma" || "{program}" == "{Application}.gamma.fat" - Set ObjPPC ":objects:game:ppc:beta:" + Set ObjPPC ":objects:game:ppc:gamma:" Set VerRezOptions "" Set SymbolsPPC "-sym off" - Set VersionPPCCOptions "-opt speed {SymbolsPPC} -d GAME -d DEBUG -d GAMMA -d COMPILE_TIME=`Date -n`" + Set VersionPPCCOptions "-opt speed,unroll,unswitch {SymbolsPPC} -d GAME -d DEBUG -d GAMMA -d COMPILE_TIME=`Date -n`" Set TargPPC "{Application}.gamma.ppc" - Set CSeriesLibrariesPPC "{CSeriesLibraries}cseries.debug.xcoff" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.debug.xcoff" else if "{program}" == "{Application}.ppc" || "{program}" == "{Application}" || "{program}" == "{Application}.fat" Set ObjPPC ":objects:game:ppc:final:" Set VerRezOptions "" Set SymbolsPPC "-sym off" - Set VersionPPCCOptions "-opt speed {SymbolsPPC} -d GAME -d FINAL" + Set VersionPPCCOptions "-opt speed,unroll,unswitch {SymbolsPPC} -d GAME -d FINAL" Set TargPPC "{Application}.ppc" - Set CSeriesLibrariesPPC "{CSeriesLibraries}cseries.xcoff" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.xcoff" + +#options for PowerPC full sprocket versions +else if "{program}" == "{Application}.spr.alpha.ppc" || "{program}" == "{Application}.spr.alpha" || "{program}" == "{Application}.spr.alpha.fat" + Set ObjPPC ":objects:game:ppc:sprocketalpha:" + Set VerRezOptions "-d DEBUG {SprocketSupport}" + Set SymbolsPPC "-sym on" + Set VersionPPCCOptions "-opt off -traceback {SymbolsPPC} -d GAME -d ALPHA -d DEBUG -d COMPILE_TIME=`Date -n` {SprocketSupport}" + Set SprocketLibraries "∂"{CSeriesLibraries}∂"InputSprocketStubLib ∂"{CSeriesLibraries}∂"DrawSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundLib" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.sym.xcoff" +else if "{program}" == "{Application}.spr.beta.ppc" || "{program}" == "{Application}.spr.beta" || "{program}" == "{Application}.spr.beta.fat" + Set ObjPPC ":objects:game:ppc:sprocketbeta:" + Set VerRezOptions "{SprocketSupport}" + Set SymbolsPPC "-sym off" + Set VersionPPCCOptions "-opt speed,unroll -traceback {SymbolsPPC} -d GAME -d DEBUG -d BETA -d COMPILE_TIME=`Date -n` {SprocketSupport}" + Set TargPPC "{Application}.spr.beta.ppc" + Set SprocketLibraries "∂"{CSeriesLibraries}∂"InputSprocketStubLib ∂"{CSeriesLibraries}∂"DrawSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundLib" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.debug.xcoff" +else if "{program}" == "{Application}.spr.gamma.ppc" || "{program}" == "{Application}.spr.gamma" || "{program}" == "{Application}.spr.gamma.fat" + Set ObjPPC ":objects:game:ppc:sprocketgamma:" + Set VerRezOptions "{SprocketSupport}" + Set SymbolsPPC "-sym off" + Set VersionPPCCOptions "-opt speed,unroll {SymbolsPPC} -d GAME -d DEBUG -d GAMMA -d COMPILE_TIME=`Date -n` {SprocketSupport}" + Set TargPPC "{Application}.spr.gamma.ppc" + Set SprocketLibraries "∂"{CSeriesLibraries}∂"InputSprocketStubLib ∂"{CSeriesLibraries}∂"DrawSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundLib" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.debug.xcoff" +else if "{program}" == "{Application}.spr.ppc" || "{program}" == "{Application}.spr" || "{program}" == "{Application}.spr.fat" + Set ObjPPC ":objects:game:ppc:sprocketfinal:" + Set VerRezOptions "{SprocketSupport}" + Set SymbolsPPC "-sym off" + Set VersionPPCCOptions "-opt speed,unroll {SymbolsPPC} -d GAME -d FINAL -d TRILOGY {SprocketSupport}" + Set TargPPC "{Application}.spr.ppc" + Set SprocketLibraries "∂"{CSeriesLibraries}∂"InputSprocketStubLib ∂"{CSeriesLibraries}∂"DrawSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundLib" + Set SprocketPPCFinalLinkOptions "-weakLib InputSprocketLib" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.xcoff" #options for PowerPC demo versions else if "{program}" == "{Application}.demo.alpha.ppc" || "{program}" == "{Application}.demo.alpha" || "{program}" == "{Application}.demo.alpha.fat" @@ -161,21 +197,48 @@ else if "{program}" == "{Application}.demo.alpha.ppc" || "{program}" == "{Applic Set SymbolsPPC "-sym on" Set VersionPPCCOptions "-opt off {SymbolsPPC} -d ALPHA -d DEMO -d DEBUG -d COMPILE_TIME=`Date -n`" Set DemoTargPPC "{Application}.demo.alpha.ppc" - Set CSeriesLibrariesPPC "{CSeriesLibraries}cseries.sym.xcoff" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.sym.xcoff" else if "{program}" == "{Application}.demo.beta.ppc" || "{program}" == "{Application}.demo.beta" || "{program}" == "{Application}.demo.beta.fat" Set ObjPPC ":objects:demo:ppc:beta:" - Set VerRezOptions "-d DEBUG -d DEMO" + Set VerRezOptions "-d DEBUG" Set SymbolsPPC "-sym off" Set VersionPPCCOptions "-opt speed {SymbolsPPC} -d BETA -d DEMO -d DEBUG -d COMPILE_TIME=`Date -n`" Set DemoTargPPC "{Application}.demo.beta.ppc" - Set CSeriesLibrariesPPC "{CSeriesLibraries}cseries.debug.xcoff" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.debug.xcoff" else if "{program}" == "{Application}.demo.ppc" || "{program}" == "{Application}.demo" || "{program}" == "{Application}.demo.fat" Set ObjPPC ":objects:demo:ppc:final:" Set VerRezOptions "-d DEMO" Set SymbolsPPC "-sym off" Set VersionPPCCOptions "-opt speed {SymbolsPPC} -d FINAL -d DEMO" Set DemoTargPPC "{Application}.demo.ppc" - Set CSeriesLibrariesPPC "{CSeriesLibraries}cseries.xcoff" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.xcoff" + +#options for PowerPC demo sprocket versions +else if "{program}" == "{Application}.demo.spr.alpha.ppc" || "{program}" == "{Application}.demo.spr.alpha" || "{program}" == "{Application}.demo.spr.alpha.fat" + Set ObjPPC ":objects:demo:ppc:sprocketalpha:" + Set VerRezOptions "-d DEBUG -d DEMO {SprocketSupport}" + Set SymbolsPPC "-sym on" + Set VersionPPCCOptions "-opt off {SymbolsPPC} -d ALPHA -d DEMO -d DEBUG -d COMPILE_TIME=`Date -n` {SprocketSupport}" + Set DemoTargPPC "{Application}.demo.spr.alpha.ppc" + Set SprocketLibraries "∂"{CSeriesLibraries}∂"InputSprocketStubLib ∂"{CSeriesLibraries}∂"DrawSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundLib" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.sym.xcoff" +else if "{program}" == "{Application}.demo.spr.beta.ppc" || "{program}" == "{Application}.demo.spr.beta" || "{program}" == "{Application}.demo.spr.beta.fat" + Set ObjPPC ":objects:demo:ppc:sprocketbeta:" + Set VerRezOptions "-d DEBUG {SprocketSupport}" + Set SymbolsPPC "-sym off" + Set VersionPPCCOptions "-opt speed {SymbolsPPC} -d BETA -d DEMO -d DEBUG -d COMPILE_TIME=`Date -n` {SprocketSupport}" + Set DemoTargPPC "{Application}.demo.spr.beta.ppc" + Set SprocketLibraries "∂"{CSeriesLibraries}∂"InputSprocketStubLib ∂"{CSeriesLibraries}∂"DrawSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundLib" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.debug.xcoff" +else if "{program}" == "{Application}.demo.spr.ppc" || "{program}" == "{Application}.spr.demo" || "{program}" == "{Application}.demo.spr.fat" + Set ObjPPC ":objects:demo:ppc:sprocketfinal:" + Set VerRezOptions "-d DEMO {SprocketSupport}" + Set SymbolsPPC "-sym off" + Set VersionPPCCOptions "-opt speed {SymbolsPPC} -d FINAL -d DEMO {SprocketSupport}" + Set DemoTargPPC "{Application}.demo.spr.ppc" + Set SprocketLibraries "∂"{CSeriesLibraries}∂"InputSprocketStubLib ∂"{CSeriesLibraries}∂"DrawSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundSprocketDebugLib ∂"{CSeriesLibraries}∂"SoundLib" + Set SprocketPPCFinalLinkOptions "-weakLib InputSprocketLib" + Set CSeriesLibrariesPPC "∂"{CSeriesLibraries}∂"cseries.xcoff" else #we must be doing a 68k build; set some defaults so Make won't crap looking for PowerPC variables @@ -188,9 +251,19 @@ if {MakeAILibrary} == 1 set VersionPPCCOptions "{VersionPPCCOptions}"" -d AI_LIBRARY" end +if {MakeVulcan} == 1 + set VersionCOptions "{VersionCOptions}"" -d VULCAN" + set VersionPPCCOptions "{VersionPPCCOptions}"" -d VULCAN" +end + +if {MakeModelFar} == 1 + set VersionCOptions "{VersionCOptions}"" -model far" + set Link68kOptions "{Link68kOptions}"" -model far" +end + # if we're doing a fat build, set FatTarg or DemoFatTarg appropriately, otherwise leave them # set to something that make will ignore (in this case {Application}.fat and {Application}.demo.fat -if "{program}" == "{Application}.fat" || "{program}" == "{Application}.beta.fat" || "{program}" == "{Application}.alpha.fat" || "{program}" == "{Application}.gamma.fat" +if "{program}" == "{Application}.fat" || "{program}" == "{Application}.spr.fat" || "{program}" == "{Application}.beta.fat" || "{program}" == "{Application}.alpha.fat" || "{program}" == "{Application}.gamma.fat" Set FatTarg "{program}" else Set FatTarg "{Application}.fat" @@ -218,6 +291,8 @@ Export CSeriesLibraries68k Export CSeriesLibrariesPPC Export SymbolsPPC Export VerRezOptions +Export SprocketLibraries +Export SprocketPPCFinalLinkOptions # from way, way above (ending "if {program}==shapes or {program}==demos") end diff --git a/marathon2/buildrelease b/marathon2/buildrelease new file mode 100644 index 0000000..850f9e6 --- /dev/null +++ b/marathon2/buildrelease @@ -0,0 +1,80 @@ +set -e sourceFolder "Crack Haüs:Infinity 11/15:" +set -e targetFolder "Dos:InfinityBuild:" + +set -e majorVersion 0x01 +set -e minorVersion 0x21 +set -e releaseStage "release" +set -e release 0x00 +set -e regionVersion "verUS" +set -e shortVersion '1.2.1' +set -e longVersion "∂"{shortVersion} © 1995-1996 Bungie Software Products Corp.∂"" +set -e short2Version "∂"{shortVersion}∂"" +set -e long2Version "∂"Marathon Infinity∂"" + +cd ::cseries.lib +buildprogram macintosh_interfaces.d +buildprogram cseries +buildprogram cseries.debug +cd ::marathon2 +buildprogram marathon2.fat +buildprogram export_definitions +buildprogram serial_numbers +set -e oldname marathon2.fat +set -e newname "Marathon ∞" +set -e buildtime "`date -s -d` 12:00 PM" +noresnames "{oldname}" +duplicate -d "{oldname}" "{targetFolder}{newname}" +echo "include ∂"{oldname}∂" not 'ckid';" | rez -align longword -o "{targetFolder}{oldname}" +echo "∂#include ∂"SysTypes.r∂"∂ninclude ∂"{targetFolder}{oldname}∂" not 'vers';∂nresource 'vers' (1) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{shortVersion}∂",∂"{longVersion}∂"∂};∂nresource 'vers' (2) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{short2Version}∂",∂"{long2Version}∂"∂};" | rez -align longword -o "{targetFolder}{newname}" +setfile -t APPL -c "26.∞" -a iB "{targetFolder}{newname}" -m "{buildtime}" -d "{buildtime}" +delete "{targetFolder}{oldname}" + +set -e filename "Images" +set -e oldname "{sourceFolder}{filename}" +set -e newname "{targetFolder}{filename}" +noresnames "{oldname}" +delete -y "{newname}" +echo "∂#include ∂"SysTypes.r∂"∂ninclude ∂"{oldname}∂" ('PICT');∂ninclude ∂"{oldname}∂" ('clut');∂nresource 'vers' (1) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{shortVersion}∂",∂"{longVersion}∂"∂};∂nresource 'vers' (2) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{short2Version}∂",∂"{long2Version}∂"∂};" | rez -align longword -o "{newname}" +setfile -t img2 -c '26.∞' "{newname}" -m "{buildtime}" -d "{buildtime}" + +set -e filename "Music" +set -e oldname "{sourceFolder}{filename}" +set -e newname "{targetFolder}{filename}" +delete -y "{newname}" +duplicate -d "{oldname}" "{newname}" +echo "∂#include ∂"SysTypes.r∂"∂nresource 'vers' (1) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{shortVersion}∂",∂"{longVersion}∂"∂};∂nresource 'vers' (2) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{short2Version}∂",∂"{long2Version}∂"∂};" | rez -align longword -o "{newname}" +setfile -t mus2 -c '26.∞' -a c "{newname}" -m "{buildtime}" -d "{buildtime}" + +set -e filename "Shapes" +set -e oldname "{sourceFolder}{filename}" +set -e newname "{targetFolder}{filename}" +duplicate -d "{oldname}" "{newname}" +echo "∂#include ∂"SysTypes.r∂"∂nresource 'vers' (1) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{shortVersion}∂",∂"{longVersion}∂"∂};∂nresource 'vers' (2) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{short2Version}∂",∂"{long2Version}∂"∂};" | rez -align longword -o "{newname}" +setfile -t 'shp∞' -c '26.∞' "{newname}" -m "{buildtime}" -d "{buildtime}" + +set -e filename "Sounds" +set -e oldname "{sourceFolder}{filename}" +set -e newname "{targetFolder}{filename}" +duplicate -d "{oldname}" "{newname}" +echo "∂#include ∂"SysTypes.r∂"∂nresource 'vers' (1) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{shortVersion}∂",∂"{longVersion}∂"∂};∂nresource 'vers' (2) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{short2Version}∂",∂"{long2Version}∂"∂};" | rez -align longword -o "{newname}" +setfile -t 'snd∞' -c '26.∞' "{newname}" -m "{buildtime}" -d "{buildtime}" + +set -e filename "Map" +set -e oldname "{sourceFolder}{filename}" +set -e newname "{targetFolder}{filename}" +delete -y "{newname}" +noresnames "{oldname}" +duplicate -d "{oldname}" "{newname}" +echo "∂#include ∂"SysTypes.r∂"∂ninclude ∂"{oldname}∂" ('PICT');∂ninclude ∂"{oldname}∂" ('clut');∂nresource 'vers' (1) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{shortVersion}∂",∂"{longVersion}∂"∂};∂nresource 'vers' (2) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{short2Version}∂",∂"{long2Version}∂"∂};" | rez -align longword -o "{newname}" +setfile -t 'sce2' -c '26.∞' "{newname}" -m "{buildtime}" -d "{buildtime}" + +export_definitions "{targetFolder}Standard" + +set -e filename "Standard" +set -e oldname "{filename}" +set -e newname "{targetFolder}{filename}" +delete -y "{newname}" +noresnames "{oldname}" +duplicate -d "{oldname}" "{newname}" +echo "∂#include ∂"SysTypes.r∂"∂nresource 'vers' (1) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{shortVersion}∂",∂"{longVersion}∂"∂};∂nresource 'vers' (2) ∂{{majorVersion},{minorVersion},{releaseStage},{release},{regionVersion},∂"{short2Version}∂",∂"{long2Version}∂"∂};" | rez -align longword -o "{newname}" +setfile -t 'phy∞' -c '26.∞' "{newname}" -m "{buildtime}" -d "{buildtime}" diff --git a/marathon2/computer_interface.c b/marathon2/computer_interface.c index c9e8704..6734c38 100644 --- a/marathon2/computer_interface.c +++ b/marathon2/computer_interface.c @@ -25,7 +25,7 @@ #include "screen_drawing.h" #include "overhead_map.h" #include "time.h" -#include "sound.h" +#include "game_sound.h" #include "interface.h" // for the error strings. #include "shell.h" #include "platforms.h" // for tagged platforms @@ -1068,7 +1068,7 @@ dprintf("Warning: Not large enough for pict: %d (width);g", picture_id); static void fill_terminal_with_static( Rect *bounds) { -#pragma unused (bounds); +#pragma unused (bounds) dprintf("Filling with static;g"); #ifdef OBSOLETE static long seed= TickCount(); diff --git a/marathon2/devices.c b/marathon2/devices.c index fcb7623..cf6a0fe 100644 --- a/marathon2/devices.c +++ b/marathon2/devices.c @@ -23,7 +23,7 @@ Wednesday, June 21, 1995 8:31:57 AM (Jason) #include "interface.h" #include "player.h" #include "platforms.h" -#include "sound.h" +#include "game_sound.h" #include "computer_interface.h" //#include "music.h" #include "lightsource.h" @@ -65,7 +65,7 @@ enum // control panel sounds struct control_panel_definition { - short class; + short panel_class; word flags; short collection; @@ -120,7 +120,7 @@ static struct control_panel_definition control_panel_definitions[]= {_panel_is_tag_switch, 0, _collection_walls3, 0, 1, {_snd_chip_insertion, NONE, NONE}, FIXED_ONE, _i_uplink_chip}, {_panel_is_tag_switch, 0, _collection_walls3, 1, 0, {_snd_destroy_control_panel, NONE, NONE}, FIXED_ONE, NONE}, - // _collection_walls4 + // _collection_walls5 {_panel_is_shield_refuel, 0, _collection_walls5, 2, 3, {_snd_energy_refuel, NONE, NONE}, FIXED_ONE, NONE}, {_panel_is_double_shield_refuel, 0, _collection_walls5, 2, 3, {_snd_energy_refuel, NONE, NONE}, FIXED_ONE+FIXED_ONE/8, NONE}, {_panel_is_triple_shield_refuel, 0, _collection_walls5, 2, 3, {_snd_energy_refuel, NONE, NONE}, FIXED_ONE+FIXED_ONE/4, NONE}, @@ -132,6 +132,19 @@ static struct control_panel_definition control_panel_definitions[]= {_panel_is_oxygen_refuel, 0, _collection_walls5, 2, 3, {_snd_oxygen_refuel, NONE, NONE}, FIXED_ONE, NONE}, {_panel_is_tag_switch, 0, _collection_walls5, 0, 1, {_snd_chip_insertion, NONE, NONE}, FIXED_ONE, _i_uplink_chip}, {_panel_is_tag_switch, 0, _collection_walls5, 1, 0, {_snd_destroy_control_panel, NONE, NONE}, FIXED_ONE, NONE}, + + // _collection_walls4 + {_panel_is_shield_refuel, 0, _collection_walls4, 2, 3, {_snd_energy_refuel, NONE, NONE}, FIXED_ONE, NONE}, + {_panel_is_double_shield_refuel, 0, _collection_walls4, 2, 3, {_snd_energy_refuel, NONE, NONE}, FIXED_ONE+FIXED_ONE/8, NONE}, + {_panel_is_triple_shield_refuel, 0, _collection_walls4, 2, 3, {_snd_energy_refuel, NONE, NONE}, FIXED_ONE+FIXED_ONE/4, NONE}, + {_panel_is_light_switch, 0, _collection_walls4, 0, 1, {_snd_switch_on, _snd_switch_off, _snd_cant_toggle_switch}, FIXED_ONE, NONE}, + {_panel_is_platform_switch, 0, _collection_walls4, 0, 1, {_snd_switch_on, _snd_switch_off, _snd_cant_toggle_switch}, FIXED_ONE, NONE}, + {_panel_is_tag_switch, 0, _collection_walls4, 0, 1, {_snd_switch_on, _snd_switch_off, _snd_cant_toggle_switch}, FIXED_ONE, NONE}, + {_panel_is_pattern_buffer, 0, _collection_walls4, 4, 4, {_snd_pattern_buffer, NONE, NONE}, FIXED_ONE, NONE}, + {_panel_is_computer_terminal, 0, _collection_walls4, 4, 4, {NONE, NONE, NONE}, FIXED_ONE, NONE}, + {_panel_is_oxygen_refuel, 0, _collection_walls4, 2, 3, {_snd_oxygen_refuel, NONE, NONE}, FIXED_ONE, NONE}, + {_panel_is_tag_switch, 0, _collection_walls4, 0, 1, {_snd_chip_insertion, NONE, NONE}, FIXED_ONE, _i_uplink_chip}, + {_panel_is_tag_switch, 0, _collection_walls4, 1, 0, {_snd_destroy_control_panel, NONE, NONE}, FIXED_ONE, NONE}, }; /* ------------ private prototypes */ @@ -171,7 +184,7 @@ void initialize_control_panels_for_level( struct control_panel_definition *definition= get_control_panel_definition(side->control_panel_type); boolean status= FALSE; - switch (definition->class) + switch (definition->panel_class) { case _panel_is_tag_switch: status= GET_CONTROL_PANEL_STATUS(side); @@ -216,7 +229,7 @@ void update_control_panels( player->variables.last_position.y == player->variables.position.y && player->variables.last_position.z == player->variables.position.z) { - switch (definition->class) + switch (definition->panel_class) { case _panel_is_oxygen_refuel: if (!(dynamic_world->tick_count&OXYGEN_RECHARGE_FREQUENCY)) @@ -237,7 +250,7 @@ void update_control_panels( { short maximum, rate; - switch (definition->class) + switch (definition->panel_class) { case _panel_is_shield_refuel: maximum= PLAYER_MAXIMUM_SUIT_ENERGY, rate= 1; break; case _panel_is_double_shield_refuel: maximum= 2*PLAYER_MAXIMUM_SUIT_ENERGY, rate= 2; break; @@ -319,7 +332,7 @@ boolean untoggled_repair_switches_on_level( { struct control_panel_definition *definition= get_control_panel_definition(side->control_panel_type); - switch (definition->class) + switch (definition->panel_class) { case _panel_is_platform_switch: untoggled_switch= platform_is_at_initial_state(get_polygon_data(side->control_panel_permutation)->permutation) ? TRUE : FALSE; @@ -349,7 +362,7 @@ void assume_correct_switch_position( { struct control_panel_definition *definition= get_control_panel_definition(side->control_panel_type); - if (switch_type==definition->class) + if (switch_type==definition->panel_class) { play_control_panel_sound(side_index, new_state ? _activating_sound : _deactivating_sound); SET_CONTROL_PANEL_STATUS(side, new_state); @@ -380,7 +393,7 @@ void try_and_toggle_control_panel( boolean make_sound, state= GET_CONTROL_PANEL_STATUS(side); struct control_panel_definition *definition= get_control_panel_definition(side->control_panel_type); - switch (definition->class) + switch (definition->panel_class) { case _panel_is_tag_switch: state= !state; @@ -441,9 +454,38 @@ short get_panel_class( { struct control_panel_definition *definition= get_control_panel_definition(panel_type); - return definition->class; + return definition->panel_class; } +//---------- changed 9.18.95 +#if 0 +boolean control_panel_type_valid_for_texture( + shape_descriptor shape, + short control_panel_type) +{ + boolean valid= FALSE; + short index; + + for(index= 0; indexcollection) + { + if((GET_DESCRIPTOR_SHAPE(shape)==definition->active_shape) || + (GET_DESCRIPTOR_SHAPE(shape)==definition->inactive_shape)) + { + if(control_panel_type==definition->panel_class) + { + valid= TRUE; + } + } + } + } + + return valid; +} +#endif //---------- changed 9.18.95 boolean control_panel_type_valid_for_texture( shape_descriptor shape, @@ -463,6 +505,7 @@ boolean control_panel_type_valid_for_texture( return valid; } + //------------------ /* ---------- private code */ @@ -615,23 +658,27 @@ static void change_panel_state( state= GET_CONTROL_PANEL_STATUS(side); /* Do the right thing, based on the panel type.. */ - switch (definition->class) + switch (definition->panel_class) { case _panel_is_oxygen_refuel: case _panel_is_shield_refuel: case _panel_is_double_shield_refuel: case _panel_is_triple_shield_refuel: +#ifndef VULCAN player->control_panel_side_index= player->control_panel_side_index==panel_side_index ? NONE : panel_side_index; state= get_recharge_status(panel_side_index); SET_CONTROL_PANEL_STATUS(side, state); if (!state) set_control_panel_texture(side); +#endif break; case _panel_is_computer_terminal: +#ifndef VULCAN if (get_game_state()==_game_in_progress && !PLAYER_HAS_CHEATED(player) && !PLAYER_HAS_MAP_OPEN(player)) { /* this will handle changing levels, if necessary (i.e., if we’re finished) */ enter_computer_interface(player_index, side->control_panel_permutation, calculate_level_completion_state()); } +#endif break; case _panel_is_tag_switch: if (definition->item==NONE || (!state && try_and_subtract_player_item(player_index, definition->item))) @@ -656,6 +703,7 @@ static void change_panel_state( make_sound= try_and_change_platform_state(get_polygon_data(side->control_panel_permutation)->permutation, state); break; case _panel_is_pattern_buffer: +#ifndef VULCAN if (dynamic_world->tick_count-player->ticks_at_last_successful_save>MINIMUM_RESAVE_TICKS && player_controlling_game() && !PLAYER_HAS_CHEATED(local_player) && !game_is_networked) { @@ -666,10 +714,12 @@ static void change_panel_state( player->ticks_at_last_successful_save= dynamic_world->tick_count; if (!save_game()) { - player->ticks_at_last_successful_save= 0; + // AMR 3/12/97 vidding happens with InputSprocket with this here + //player->ticks_at_last_successful_save= 0; } // fade_in_background_music(30); } +#endif break; default: diff --git a/marathon2/editor.h b/marathon2/editor.h new file mode 100644 index 0000000..be8310b --- /dev/null +++ b/marathon2/editor.h @@ -0,0 +1,58 @@ +/* + EDITOR.H + Sunday, April 17, 1994 10:50:25 PM +*/ + +#ifndef __EDITOR_H_ +#define __EDITOR_H_ + +#define MARATHON_ONE_DATA_VERSION 0 +#define MARATHON_TWO_DATA_VERSION 1 +#define MARATHON_INFINITY_DATA_VERSION 2 +#define EDITOR_MAP_VERSION (MARATHON_INFINITY_DATA_VERSION) + +typedef world_point2d saved_map_pt; +typedef struct line_data saved_line; +typedef struct side_data saved_side; +typedef struct polygon_data saved_poly; +typedef struct map_annotation saved_annotation; +typedef struct map_object saved_object; +typedef struct static_data saved_map_data; + +#define MINIMUM_MAP_X_COORDINATE SHORT_MIN +#define MAXIMUM_MAP_X_COORDINATE SHORT_MAX +#define MINIMUM_MAP_Y_COORDINATE SHORT_MIN +#define MAXIMUM_MAP_Y_COORDINATE SHORT_MAX + +#define MINIMUM_FLOOR_HEIGHT (-8*WORLD_ONE) +#define MINIMUM_CEILING_HEIGHT (MINIMUM_FLOOR_HEIGHT+WORLD_ONE) + +#define MAXIMUM_FLOOR_HEIGHT (8*WORLD_ONE) +#define MAXIMUM_CEILING_HEIGHT (MAXIMUM_FLOOR_HEIGHT+WORLD_ONE) + +#define INVALID_HEIGHT (MINIMUM_FLOOR_HEIGHT-1) + +enum { + _saved_guard_path_is_random= 0x0001 +}; + +struct map_index_data +{ + char level_name[LEVEL_NAME_LENGTH]; + char unused; + long level_flags; +}; + +#define MAXIMUM_GUARD_PATH_CONTROL_POINTS 20 + +struct saved_path +{ + short point_count; + word flags; + world_point2d points[MAXIMUM_GUARD_PATH_CONTROL_POINTS]; + short polygon_indexes[MAXIMUM_GUARD_PATH_CONTROL_POINTS]; +}; + +/* Prevent ridiculous maps.. */ +#define MAX_LINES_PER_VERTEX 15 +#endif \ No newline at end of file diff --git a/marathon2/effect_definitions.h b/marathon2/effect_definitions.h index b3518f8..78ee782 100644 --- a/marathon2/effect_definitions.h +++ b/marathon2/effect_definitions.h @@ -28,6 +28,7 @@ struct effect_definition /* ---------- effect definitions */ +#ifndef DONT_COMPILE_DEFINITIONS struct effect_definition effect_definitions[NUMBER_OF_EFFECT_TYPES]= { /* rocket explosion, contrail */ @@ -160,4 +161,15 @@ struct effect_definition effect_definitions[NUMBER_OF_EFFECT_TYPES]= /* _effect_juggernaut_spark, _effect_juggernaut_missile_contrail */ {_collection_juggernaut, 3, _normal_frequency, _end_when_animation_loops, 0, NONE}, {_collection_rocket, 24, _normal_frequency, _end_when_animation_loops, 0, NONE}, + + /* _effect_small_jjaro_splash, _effect_medium_jjaro_splash, _effect_large_jjaro_splash, _effect_large_jjaro_emergence */ + {_collection_scenery4, 0, _normal_frequency, _end_when_animation_loops|_media_effect, 0, NONE}, + {_collection_scenery4, 1, _normal_frequency, _end_when_animation_loops|_media_effect, 0, NONE}, + {_collection_scenery4, 2, _normal_frequency, _end_when_animation_loops|_sound_only, 0, NONE}, + {_collection_scenery4, 3, _normal_frequency, _end_when_animation_loops|_sound_only, 0, NONE}, + + /* vacuum civilian blood splash, vacuum assimilated civilian blood splash */ + {_collection_vacuum_civilian, 7, _normal_frequency, _end_when_animation_loops, 0, NONE}, + {BUILD_COLLECTION(_collection_vacuum_civilian, 3), 12, _normal_frequency, _end_when_animation_loops, 0, NONE}, }; +#endif diff --git a/marathon2/effects.c b/marathon2/effects.c index 0698521..9476317 100644 --- a/marathon2/effects.c +++ b/marathon2/effects.c @@ -15,7 +15,7 @@ Wednesday, February 1, 1995 12:58:17 AM (Jason') #include "map.h" #include "interface.h" #include "effects.h" -#include "sound.h" +#include "game_sound.h" #ifdef mpwc #pragma segment objects diff --git a/marathon2/effects.h b/marathon2/effects.h index 23692ae..70d8ebf 100644 --- a/marathon2/effects.h +++ b/marathon2/effects.h @@ -74,6 +74,12 @@ enum /* effect types */ _effect_yeti_melee_detonation, _effect_juggernaut_spark, _effect_juggernaut_missile_contrail, + _effect_small_jjaro_splash, + _effect_medium_jjaro_splash, + _effect_large_jjaro_splash, + _effect_large_jjaro_emergence, + _effect_vacuum_civilian_blood_splash, + _effect_assimilated_vacuum_civilian_blood_splash, NUMBER_OF_EFFECT_TYPES }; diff --git a/marathon2/environment.h b/marathon2/environment.h new file mode 100644 index 0000000..ecd6228 --- /dev/null +++ b/marathon2/environment.h @@ -0,0 +1,5 @@ +//#define DEBUG + +//#define ALPHA +//#define BETA +#define FINAL diff --git a/marathon2/export_definitions.c b/marathon2/export_definitions.c index cab6e33..c80125e 100644 --- a/marathon2/export_definitions.c +++ b/marathon2/export_definitions.c @@ -13,7 +13,7 @@ Tuesday, October 31, 1995 11:02:24 AM (Ryan) #include "weapons.h" #include "wad.h" #include "items.h" -#include "sound.h" +#include "game_sound.h" #include "media.h" #include "tags.h" @@ -27,7 +27,9 @@ Tuesday, October 31, 1995 11:02:24 AM (Ryan) #include "effect_definitions.h" #include "physics_models.h" +#define INCLUDE_STRUCTURES #include "extensions.h" +#undef INCLUDE_STRUCTURES /* ---------- private code */ static boolean create_physics_file(FileDesc *file); @@ -54,7 +56,7 @@ void main( error= get_my_fsspec(&physics_spec); strcpy(temporary, argv[1]); c2pstr(temporary); - error= FSMakeFSSpec(0, 0, temporary, &physics_spec); + error= FSMakeFSSpec(0, 0, (StringPtr)temporary, &physics_spec); if(!error || error==fnfErr) { if(!create_physics_file((FileDesc *) &physics_spec)) diff --git a/marathon2/export_definitions.make b/marathon2/export_definitions.make index 3dd3017..dea7ab6 100644 --- a/marathon2/export_definitions.make +++ b/marathon2/export_definitions.make @@ -15,14 +15,20 @@ export_definitions ƒƒ export_definitions.make {OBJECTS} -t 'MPST' ∂ -c 'MPS ' ∂ {OBJECTS} ∂ - "{CLibraries}"StdClib.o ∂ - "{Libraries}"Runtime.o ∂ - "{Libraries}"Interface.o ∂ - ":Objects:Game:68k:Beta:wad.lib" ∂ {CSeriesLibraries}cseries.debug.lib ∂ +# "{Libraries}"Stubs.o ∂ + "{Libraries}MacRuntime.o" ∂ + "{Libraries}"Interface.o ∂ + "{CLibraries}"StdCLib.o ∂ +# "{CLibraries}"CSANELib.o ∂ + "{Libraries}IntEnv.o" ∂ +# "{CLibraries}"Math.o ∂ +# "{Libraries}"ToolLibs.o ∂ + "{Libraries}MathLib.o" ∂ + ":Objects:Game:68k:Final:wad.lib" ∂ -o export_definitions delete export_definitions.c.o export_definitions.c.o ƒ export_definitions.make extensions.h ∂ weapon_definitions.h projectile_definitions.h monster_definitions.h ∂ - effect_definitions.h physics_models.h ":Objects:Game:68k:Beta:wad.lib" \ No newline at end of file + effect_definitions.h physics_models.h ":Objects:Game:68k:Final:wad.lib" \ No newline at end of file diff --git a/marathon2/extensions.h b/marathon2/extensions.h index e8564d3..408269b 100644 --- a/marathon2/extensions.h +++ b/marathon2/extensions.h @@ -8,7 +8,6 @@ #define BUNGIE_PHYSICS_DATA_VERSION 0 #define PHYSICS_DATA_VERSION 1 -#ifdef EXPORT_STRUCTURE struct definition_data { long tag; @@ -17,34 +16,17 @@ struct definition_data short size; }; +#ifdef INCLUDE_STRUCTURES static struct definition_data definitions[]= { {MONSTER_PHYSICS_TAG, monster_definitions, NUMBER_OF_MONSTER_TYPES, sizeof(struct monster_definition)}, {EFFECTS_PHYSICS_TAG, effect_definitions, NUMBER_OF_EFFECT_TYPES, sizeof(struct effect_definition)}, {PROJECTILE_PHYSICS_TAG, projectile_definitions, NUMBER_OF_PROJECTILE_TYPES, sizeof(struct projectile_definition)}, {PHYSICS_PHYSICS_TAG, physics_models, NUMBER_OF_PHYSICS_MODELS, sizeof(struct physics_constants)}, - {WEAPONS_PHYSICS_TAG, weapon_definitions, NUMBER_OF_WEAPONS, sizeof(struct weapon_definition)} -}; -#define NUMBER_OF_DEFINITIONS (sizeof(definitions)/sizeof(definitions[0])) -#else -#ifdef IMPORT_STRUCTURE -struct definition_data -{ - long tag; - void *data; -}; - -static struct definition_data definitions[]= -{ - {MONSTER_PHYSICS_TAG, monster_definitions}, - {EFFECTS_PHYSICS_TAG, effect_definitions}, - {PROJECTILE_PHYSICS_TAG, projectile_definitions}, - {PHYSICS_PHYSICS_TAG, physics_models}, - {WEAPONS_PHYSICS_TAG, weapon_definitions}, + {WEAPONS_PHYSICS_TAG, weapon_definitions, MAXIMUM_NUMBER_OF_WEAPONS, sizeof(struct weapon_definition)} }; #define NUMBER_OF_DEFINITIONS (sizeof(definitions)/sizeof(definitions[0])) #endif -#endif /* ------------- prototypes */ @@ -57,4 +39,7 @@ void set_to_default_physics_file(void); void import_definition_structures(void); void *get_network_physics_buffer(long *physics_length); -void process_network_physics_model(void *data); \ No newline at end of file +void process_network_physics_model(void *data); +void import_physics_wad_data(struct wad_data *wad); + +void *get_physics_array_and_size(long tag, long *size); diff --git a/marathon2/extract/sndextract.c b/marathon2/extract/sndextract.c index f17cf90..8f6b087 100644 --- a/marathon2/extract/sndextract.c +++ b/marathon2/extract/sndextract.c @@ -9,7 +9,7 @@ Saturday, July 3, 1993 8:19:20 AM #include #include "::world.h" -#include "::sound.h" +#include "::game_sound.h" #define STATIC_DEFINITIONS #include "::sound_definitions.h" diff --git a/marathon2/extract/sndextract.make b/marathon2/extract/sndextract.make index 846c32b..eaf32e0 100644 --- a/marathon2/extract/sndextract.make +++ b/marathon2/extract/sndextract.make @@ -11,6 +11,6 @@ COptions= -i "{CSeriesInterfaces}" -d DEBUG -opt full -b2 -r -mc68020 -k "{CSeri OBJECTS= {ToolName}.c.o {CSeriesLibraries}"cseries.debug.lib" {ToolName} ƒ {OBJECTS} Link -w -c 'MPS ' -t MPST {OBJECTS} -sn STDIO=Main -sn INTENV=Main -sn %A5Init=Main ∂ - "{Libraries}"Stubs.o "{Libraries}"Runtime.o "{Libraries}"Interface.o "{CLibraries}"StdCLib.o ∂ - "{CLibraries}"CSANELib.o "{CLibraries}"Math.o "{Libraries}"ToolLibs.o ∂ - -o {ToolName} + "{Libraries}"Stubs.o "{Libraries}MacRuntime.o" "{Libraries}"Interface.o "{CLibraries}"StdCLib.o ∂ + "{CLibraries}"CSANELib.o "{Libraries}IntEnv.o" "{CLibraries}"Math.o "{Libraries}"ToolLibs.o ∂ + "{Libraries}MathLib.o" -o {ToolName} diff --git a/marathon2/fades.c b/marathon2/fades.c index 350fcd0..ec3c3b6 100644 --- a/marathon2/fades.c +++ b/marathon2/fades.c @@ -22,6 +22,7 @@ Monday, October 30, 1995 8:02:12 PM (Jason) #include "cseries.h" #include "fades.h" #include "screen.h" +#include "textures.h" #include #include @@ -32,9 +33,13 @@ Monday, October 30, 1995 8:02:12 PM (Jason) /* ---------- constants */ -#define ADJUSTED_TRANSPARENCY_DOWNSHIFT 8 +enum +{ + ADJUSTED_TRANSPARENCY_DOWNSHIFT= 8, -#define MINIMUM_FADE_RESTART (MACHINE_TICKS_PER_SECOND/2) + MINIMUM_FADE_RESTART_TICKS= MACHINE_TICKS_PER_SECOND/2, + MINIMUM_FADE_UPDATE_TICKS= MACHINE_TICKS_PER_SECOND/8 +}; /* ---------- macros */ @@ -81,6 +86,7 @@ struct fade_data short type; short fade_effect_type; + long start_tick; long last_update_tick; struct color_table *original_color_table; @@ -111,24 +117,24 @@ static struct fade_definition fade_definitions[NUMBER_OF_FADE_TYPES]= {tint_color_table, {0, 0, 0}, 0, 0, 0, _full_screen_flag, 0}, /* _end_cinematic_fade_out */ {tint_color_table, {65535, 0, 0}, (3*FIXED_ONE)/4, 0, MACHINE_TICKS_PER_SECOND/4, 0, 0}, /* _fade_red */ - {tint_color_table, {65535, 0, 0}, FIXED_ONE, 0, (3*MACHINE_TICKS_PER_SECOND)/4, 0, 0}, /* _fade_big_red */ + {tint_color_table, {65535, 0, 0}, FIXED_ONE, 0, (3*MACHINE_TICKS_PER_SECOND)/4, 0, 25}, /* _fade_big_red */ {tint_color_table, {0, 65535, 0}, FIXED_ONE_HALF, 0, MACHINE_TICKS_PER_SECOND/4, 0, 0}, /* _fade_bonus */ {tint_color_table, {65535, 65535, 50000}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND/3, 0, 0}, /* _fade_bright */ - {tint_color_table, {65535, 65535, 50000}, FIXED_ONE, 0, 4*MACHINE_TICKS_PER_SECOND, 0, 1}, /* _fade_long_bright */ - {tint_color_table, {65535, 65535, 0}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND/2, 0, 0}, /* _fade_yellow */ - {tint_color_table, {65535, 65535, 0}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND, 0, 0}, /* _fade_big_yellow */ + {tint_color_table, {65535, 65535, 50000}, FIXED_ONE, 0, 4*MACHINE_TICKS_PER_SECOND, 0, 100}, /* _fade_long_bright */ + {tint_color_table, {65535, 65535, 0}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND/2, 0, 50}, /* _fade_yellow */ + {tint_color_table, {65535, 65535, 0}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND, 0, 75}, /* _fade_big_yellow */ {tint_color_table, {215*256, 107*256, 65535}, (3*FIXED_ONE)/4, 0, MACHINE_TICKS_PER_SECOND/4, 0, 0}, /* _fade_purple */ {tint_color_table, {169*256, 65535, 224*256}, (3*FIXED_ONE)/4, 0, MACHINE_TICKS_PER_SECOND/2, 0, 0}, /* _fade_cyan */ {tint_color_table, {65535, 65535, 65535}, FIXED_ONE_HALF, 0, MACHINE_TICKS_PER_SECOND/4, 0, 0}, /* _fade_white */ - {tint_color_table, {65535, 65535, 65535}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND/2, 0, 0}, /* _fade_big_white */ + {tint_color_table, {65535, 65535, 65535}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND/2, 0, 25}, /* _fade_big_white */ {tint_color_table, {65535, 32768, 0}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND/4, 0, 0}, /* _fade_orange */ - {tint_color_table, {65535, 32768, 0}, FIXED_ONE/4, 0, 3*MACHINE_TICKS_PER_SECOND, 0, 0}, /* _fade_long_orange */ + {tint_color_table, {65535, 32768, 0}, FIXED_ONE/4, 0, 3*MACHINE_TICKS_PER_SECOND, 0, 25}, /* _fade_long_orange */ {tint_color_table, {0, 65535, 0}, 3*FIXED_ONE/4, 0, MACHINE_TICKS_PER_SECOND/2, 0, 0}, /* _fade_green */ - {tint_color_table, {65535, 0, 65535}, FIXED_ONE/4, 0, 3*MACHINE_TICKS_PER_SECOND, 0, 0}, /* _fade_long_green */ + {tint_color_table, {65535, 0, 65535}, FIXED_ONE/4, 0, 3*MACHINE_TICKS_PER_SECOND, 0, 25}, /* _fade_long_green */ {randomize_color_table, {0, 0, 0}, FIXED_ONE, 0, (3*MACHINE_TICKS_PER_SECOND)/8, 0, 0}, /* _fade_static */ {negate_color_table, {65535, 65535, 65535}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND/2, 0, 0}, /* _fade_negative */ - {negate_color_table, {65535, 65535, 65535}, FIXED_ONE, 0, (3*MACHINE_TICKS_PER_SECOND)/2, 0, 0}, /* _fade_big_negative */ + {negate_color_table, {65535, 65535, 65535}, FIXED_ONE, 0, (3*MACHINE_TICKS_PER_SECOND)/2, 0, 25}, /* _fade_big_negative */ {negate_color_table, {0, 65535, 0}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND/2, _random_transparency_flag, 0}, /* _fade_flicker_negative */ {dodge_color_table, {0, 65535, 0}, FIXED_ONE, 0, (3*MACHINE_TICKS_PER_SECOND)/4, 0, 0}, /* _fade_dodge_purple */ {burn_color_table, {0, 65535, 65535}, FIXED_ONE, 0, MACHINE_TICKS_PER_SECOND, 0, 0}, /* _fade_burn_cyan */ @@ -163,7 +169,7 @@ static float actual_gamma_values[NUMBER_OF_GAMMA_LEVELS]= /* ---------- private prototypes */ -struct fade_definition *get_fade_definition(short index); +static struct fade_definition *get_fade_definition(short index); static struct fade_effect_definition *get_fade_effect_definition(short index); static void recalculate_and_display_color_table(short type, fixed transparency, @@ -190,21 +196,30 @@ boolean update_fades( if (FADE_IS_ACTIVE(fade)) { struct fade_definition *definition= get_fade_definition(fade->type); + long tick_count= machine_tick_count(); + boolean update= FALSE; fixed transparency; short phase; - if ((phase= machine_tick_count()-fade->last_update_tick)>=definition->period) + if ((phase= tick_count-fade->start_tick)>=definition->period) { transparency= definition->final_transparency; SET_FADE_ACTIVE_STATUS(fade, FALSE); + + update= TRUE; } else { - transparency= definition->initial_transparency + (phase*(definition->final_transparency-definition->initial_transparency))/definition->period; - if (definition->flags&_random_transparency_flag) transparency+= FADES_RANDOM()%(definition->final_transparency-transparency); + if (tick_count-fade->last_update_tick>=MINIMUM_FADE_UPDATE_TICKS) + { + transparency= definition->initial_transparency + (phase*(definition->final_transparency-definition->initial_transparency))/definition->period; + if (definition->flags&_random_transparency_flag) transparency+= FADES_RANDOM()%(definition->final_transparency-transparency); + + update= TRUE; + } } - recalculate_and_display_color_table(fade->type, transparency, fade->original_color_table, fade->animated_color_table); + if (update) recalculate_and_display_color_table(fade->type, transparency, fade->original_color_table, fade->animated_color_table); } return FADE_IS_ACTIVE(fade) ? TRUE : FALSE; @@ -247,7 +262,7 @@ void explicit_start_fade( struct color_table *animated_color_table) { struct fade_definition *definition= get_fade_definition(type); - long machine_ticks= machine_tick_count(); + long tick_count= machine_tick_count(); boolean do_fade= TRUE; if (FADE_IS_ACTIVE(fade)) @@ -255,7 +270,7 @@ void explicit_start_fade( struct fade_definition *old_definition= get_fade_definition(fade->type); if (old_definition->priority>definition->priority) do_fade= FALSE; - if (fade->type==type && machine_ticks-fade->last_update_tickstart_ticktype==type) do_fade= FALSE; } if (do_fade) @@ -266,7 +281,7 @@ void explicit_start_fade( if (definition->period) { fade->type= type; - fade->last_update_tick= machine_ticks; + fade->start_tick= fade->last_update_tick= tick_count; fade->original_color_table= original_color_table; fade->animated_color_table= animated_color_table; SET_FADE_ACTIVE_STATUS(fade, TRUE); @@ -306,9 +321,11 @@ void full_fade( memcpy(&animated_color_table, original_color_table, sizeof(struct color_table)); +#if !DRAW_SPROCKET_SUPPORT explicit_start_fade(type, original_color_table, &animated_color_table); - while (update_fades()); - + while (update_fades()) + ; /* empty loop body */ +#endif return; } @@ -432,7 +449,8 @@ static void randomize_color_table( /* calculate a mask which has all bits including and lower than the high-bit in the transparency set */ - for (mask= 0;~mask & adjusted_transparency;mask= (mask<<1)|1); + for (mask= 0;~mask & adjusted_transparency;mask= (mask<<1)|1) + ; /* empty loop body */ animated_color_table->color_count= original_color_table->color_count; for (i= 0; icolor_count; ++i, ++adjusted, ++unadjusted) diff --git a/marathon2/files_macintosh.c b/marathon2/files_macintosh.c index 78b4505..2a02680 100644 --- a/marathon2/files_macintosh.c +++ b/marathon2/files_macintosh.c @@ -47,8 +47,9 @@ fileref open_file_for_reading( error= FSpOpenDF((FSSpec *)file, fsRdPerm, &file_id); if (error) { +#ifdef BETA dprintf("HOpen('%P', #%d, #%d)==#%d;g;", file->name, file->vRefNum, file->parID, error); - +#endif file_id= NONE; set_game_error(systemError, error); } @@ -67,8 +68,9 @@ fileref open_file_for_writing( error= FSpOpenDF((FSSpec *)file, fsWrPerm, &file_id); if (error) { +#ifdef BETA dprintf("HOpen('%P', #%d, #%d)==#%d;g;", file->name, file->vRefNum, file->parID, error); - +#endif file_id= NONE; set_game_error(systemError, error); } @@ -224,7 +226,7 @@ FileError add_application_name_to_fsspec( err= PtrToHand(pascal_name, &resource, pascal_name[0]+1); assert(!err && resource); - AddResource(resource, 'STR ', -16396, ""); + AddResource(resource, 'STR ', -16396, (StringPtr)""); ReleaseResource(resource); CloseResFile(refnum); diff --git a/marathon2/find_files.c b/marathon2/find_files.c index 6ce566d..5416c27 100644 --- a/marathon2/find_files.c +++ b/marathon2/find_files.c @@ -13,7 +13,7 @@ #endif /* --------- local prototypes */ -static int alphabetical_names(const FSSpec *a, const FSSpec *b); +static int alphabetical_names(const void *a, const void *b); static OSErr enumerate_files(struct find_file_pb *param_block, long directory_id); /* ---------------- Parameter Block Version */ @@ -145,8 +145,8 @@ static OSErr enumerate_files( } static int alphabetical_names( - const FSSpec *a, - const FSSpec *b) + const void *a, + const void *b) { - return (IUCompString(a->name, b->name)); + return (IUCompString(((FSSpec *)a)->name, ((FSSpec *)b)->name)); } \ No newline at end of file diff --git a/marathon2/flood_map.c b/marathon2/flood_map.c index 735d9e6..d72cb87 100644 --- a/marathon2/flood_map.c +++ b/marathon2/flood_map.c @@ -64,8 +64,8 @@ static void add_node(short parent_node_index, short polygon_index, short depth, void allocate_flood_map_memory( void) { - nodes= malloc(MAXIMUM_FLOOD_NODES*sizeof(struct node_data)); - visited_polygons= malloc(MAXIMUM_POLYGONS_PER_MAP*sizeof(short)); + nodes= (struct node_data *)malloc(MAXIMUM_FLOOD_NODES*sizeof(struct node_data)); + visited_polygons= (short *)malloc(MAXIMUM_POLYGONS_PER_MAP*sizeof(short)); assert(nodes&&visited_polygons); return; diff --git a/marathon2/game_dialogs.c b/marathon2/game_dialogs.c index fc8c9de..158069a 100644 --- a/marathon2/game_dialogs.c +++ b/marathon2/game_dialogs.c @@ -11,11 +11,8 @@ Monday, September 19, 1994 11:16:09 PM (alain) Tuesday, September 20, 1994 7:41:56 PM (alain) key config dialog also has popup for selecting which key setup to use. Wednesday, June 14, 1995 8:47:39 AM - gutted. Keyboard stuff is now in keyboard_dialog.c. Preferences related stuff is - now in preferences.c. - */ #include "macintosh_cseries.h" @@ -26,6 +23,10 @@ Wednesday, June 14, 1995 8:47:39 AM #include "interface.h" #include "preferences.h" #include "screen.h" +#include "portable_files.h" + +#define DECODE_ONLY +#include "serial_numbers.c" #ifdef mpwc #pragma segment dialogs @@ -35,6 +36,18 @@ enum { dlogQUIT_WITHOUT_SAVING= 129 }; +enum { + dlogSERIAL_NUMBER= 133, + iSERIAL_NAME_BOX= 3, + iSERIAL_NUMBER_BOX +}; + +#define MAXIMUM_SERIAL_NUMBER_RETRIES 3 + +/* ----------- private prototypes */ +static void serial_dialog_instantiate_proc(DialogPtr dialog); +static void delete_partial_preferences_file(void); + /* ----------- code */ boolean quit_without_saving( void) @@ -59,4 +72,106 @@ boolean quit_without_saving( DisposeDialog(dialog); return item_hit!=iOK ? FALSE : TRUE; /* note default button is the safe, don’t quit, one */ +} + +void ask_for_serial_number( + void) +{ + DialogPtr dialog= myGetNewDialog(dlogSERIAL_NUMBER, NULL, (WindowPtr) -1, 0); + boolean valid_serial_number= FALSE; + short retries= 0; + short item_hit; + + assert(dialog); + assert(serial_preferences); + + /* setup and show dialog */ + serial_dialog_instantiate_proc(dialog); + ShowWindow(dialog); + + do + { + boolean reinstantiate= FALSE; + + ModalDialog(get_general_filter_upp(), &item_hit); + + switch(item_hit) + { + case iSERIAL_NAME_BOX: + case iSERIAL_NUMBER_BOX: + case iOK: + reinstantiate= TRUE; + break; + } + + if (reinstantiate) serial_dialog_instantiate_proc(dialog); + + if (item_hit==iOK) + { + byte short_serial_number[BYTES_PER_SHORT_SERIAL_NUMBER]; + byte inferred_pad[BYTES_PER_SHORT_SERIAL_NUMBER]; + + long_serial_number_to_short_serial_number_and_pad(serial_preferences->long_serial_number, short_serial_number, inferred_pad); + + // also allow marathon2 network-only numbers + if ((PADS_ARE_EQUAL(inferred_pad, actual_pad) || + (PADS_ARE_EQUAL(inferred_pad, actual_pad_m2) && ((char)short_serial_number[2])<0)) && + VALID_INVERSE_SEQUENCE(short_serial_number)) + { + serial_preferences->network_only= ((char)short_serial_number[2])<0 ? TRUE : FALSE; + valid_serial_number= TRUE; + } + else + { + /* If they are about to sped. */ + if(retries+1>=MAXIMUM_SERIAL_NUMBER_RETRIES) delete_partial_preferences_file(); + alert_user(++retries>=MAXIMUM_SERIAL_NUMBER_RETRIES ? fatalError : infoError, strERRORS, badSerialNumber, 0); + SelIText(dialog, iSERIAL_NUMBER_BOX, 0, SHORT_MAX); + } + } + } + while ((item_hit!=iOK || !valid_serial_number) && item_hit!=iCANCEL); + + DisposeDialog(dialog); + + if (!valid_serial_number) + { + delete_partial_preferences_file(); + exit(0); + } + + return; +} + +static void delete_partial_preferences_file( + void) +{ + FSSpec preferences_file; + + getpstr((char *)preferences_file.name, strFILENAMES, filenamePREFERENCES); + find_preferences_location((FileDesc *)&preferences_file); + FSpDelete(&preferences_file); + + return; +} + +/* ------------- private code */ +static void serial_dialog_instantiate_proc( + DialogPtr dialog) +{ + short item_type; + Handle item_handle; + Rect item_rectangle; + + GetDItem(dialog, iSERIAL_NAME_BOX, &item_type, &item_handle, &item_rectangle); + GetIText(item_handle, serial_preferences->user_name); + + GetDItem(dialog, iSERIAL_NUMBER_BOX, &item_type, &item_handle, &item_rectangle); + GetIText(item_handle, serial_preferences->tokenized_serial_number); + + modify_control(dialog, iOK, (*serial_preferences->user_name && *serial_preferences->tokenized_serial_number) ? CONTROL_ACTIVE : CONTROL_INACTIVE, 0); + + generate_long_serial_number_from_tokens((char *)serial_preferences->tokenized_serial_number+1, serial_preferences->long_serial_number); + + return; } \ No newline at end of file diff --git a/marathon2/sound.c b/marathon2/game_sound.c similarity index 93% rename from marathon2/sound.c rename to marathon2/game_sound.c index 6a3d444..da6c75d 100644 --- a/marathon2/sound.c +++ b/marathon2/game_sound.c @@ -1,5 +1,5 @@ /* -SOUND.C +GAME_SOUND.C Friday, March 26, 1993 10:16:00 AM Friday, March 26, 1993 10:16:01 AM @@ -62,7 +62,7 @@ Tuesday, August 29, 1995 8:56:16 AM (Jason) */ /* -sound pitches do not work +low-priority sounds (recharging, reloading, etc.) will not be played for certain periods of time there should be no difference between ambient and normal sound channels shortening radii on low-volume ambient sound sorces would be a good idea @@ -72,13 +72,18 @@ shortening radii on low-volume ambient sound sorces would be a good idea #ifdef mac #include + +#ifdef SUPPORT_SOUND_SPROCKET +#include +#include "SoundSprocket.h" +#endif #endif #include "shell.h" #include "world.h" #include "interface.h" -#include "sound.h" +#include "game_sound.h" #include "byte_swapping.h" #include @@ -124,10 +129,15 @@ enum /* channel flags */ struct sound_variables { - short volume, left_volume, right_volume; +#ifdef SUPPORT_SOUND_SPROCKET + TQ3CameraPlacement source; + Boolean useSprocketForSound; +#endif // SUPPORT_SOUND_SPROCKET fixed original_pitch, pitch; - + short left_volume, right_volume; + short volume; short priority; + }; struct channel_data @@ -147,6 +157,10 @@ struct channel_data SndChannelPtr channel; short callback_count; #endif + +#ifdef SUPPORT_SOUND_SPROCKET + SSpSourceReference sspSource; +#endif }; struct sound_manager_globals @@ -179,6 +193,8 @@ static struct sound_manager_parameters *_sm_parameters; /* include globals */ #include "sound_definitions.h" +static fixed pitch_modifier_override= 0; + /* ---------- machine-specific prototypes */ static void initialize_machine_sound_manager(struct sound_manager_parameters *parameters); @@ -219,10 +235,10 @@ static short distance_to_volume(struct sound_definition *definition, world_dista static void update_ambient_sound_sources(void); #ifdef DEBUG -struct sound_definition *get_sound_definition(short sound_index); -struct ambient_sound_definition *get_ambient_sound_definition(short ambient_sound_index); -struct random_sound_definition *get_random_sound_definition(short random_sound_index); -struct sound_behavior_definition *get_sound_behavior_definition(short sound_behavior_index); +static struct sound_definition *get_sound_definition(short sound_index); +static struct ambient_sound_definition *get_ambient_sound_definition(short ambient_sound_index); +static struct random_sound_definition *get_random_sound_definition(short random_sound_index); +static struct sound_behavior_definition *get_sound_behavior_definition(short sound_behavior_index); #else #define get_sound_definition(i) (_sm_globals->base_sound_definitions+(i)) #define get_ambient_sound_definition(i) (ambient_sound_definitions+(i)) @@ -319,6 +335,23 @@ void direct_play_sound( { struct sound_variables variables; struct channel_data *channel; + world_location3d *listener= _sound_listener_proc(); + + variables.priority= 0; + variables.volume= volume; + + if (direction==NONE || !listener) + { + variables.left_volume= variables.right_volume= volume; + } + else + { + angle_and_volume_to_stereo_volume(direction - listener->yaw, + volume, &variables.right_volume, &variables.left_volume); + } +#ifdef SUPPORT_SOUND_SPROCKET + variables.useSprocketForSound = false; +#endif /* make sure the sound data is in memory */ if (_load_sound(sound_index)) @@ -326,21 +359,6 @@ void direct_play_sound( /* get the channel, and free it for our new sound */ if (channel= best_channel(sound_index, &variables)) { - world_location3d *listener= _sound_listener_proc(); - - variables.priority= 0; - variables.volume= volume; - - if (direction==NONE || !listener) - { - variables.left_volume= variables.right_volume= volume; - } - else - { - angle_and_volume_to_stereo_volume(direction - listener->yaw, - volume, &variables.right_volume, &variables.left_volume); - } - /* set the volume and pitch in this channel */ instantiate_sound_variables(&variables, channel, TRUE); @@ -635,6 +653,9 @@ static void track_stereo_sounds( struct sound_variables variables= channel->variables; if (channel->dynamic_source) channel->source= *channel->dynamic_source; +#ifdef SUPPORT_SOUND_SPROCKET + variables.useSprocketForSound = true; +#endif calculate_sound_variables(channel->sound_index, &channel->source, &variables); instantiate_sound_variables(&variables, channel, FALSE); } @@ -754,7 +775,7 @@ static short _release_least_useful_sound( for (sound_index= 0, definition= _sm_globals->base_sound_definitions; sound_indexhandle && (!least_used_definition || least_used_definition->last_played>definition->last_played)) + if (definition->hndl && (!least_used_definition || least_used_definition->last_played>definition->last_played)) { least_used_sound_index= sound_index; least_used_definition= definition; @@ -801,21 +822,21 @@ boolean _load_sound( if (definition->sound_code!=NONE && ((_sm_parameters->flags&_ambient_sound_flag) || !(definition->flags&_sound_is_ambient))) { - if (!definition->handle) + if (!definition->hndl) { - definition->handle= read_sound_from_file(sound_index); + definition->hndl= read_sound_from_file(sound_index); definition->last_played= machine_tick_count(); while (_sm_globals->loaded_sounds_size>_sm_globals->total_buffer_size) _release_least_useful_sound(); } - if (definition->handle) + if (definition->hndl) { definition->permutations_played= 0; } } - return definition->handle ? TRUE : FALSE; + return definition->hndl ? TRUE : FALSE; } static void calculate_initial_sound_variables( @@ -834,12 +855,32 @@ static void calculate_initial_sound_variables( variables->volume= variables->left_volume= variables->right_volume= MAXIMUM_SOUND_VOLUME; } +#ifdef SUPPORT_SOUND_SPROCKET + if (source) + variables->useSprocketForSound = true; + else + variables->useSprocketForSound = false; +#endif + /* and finally, do all the stuff we regularly do ... */ calculate_sound_variables(sound_index, source, variables); return; } +void toggle_sound_pitch_modifier_override( + boolean toggle) +{ + if (toggle) + { + pitch_modifier_override= (pitch_modifier_override ? 0 : (0x238E3)); // (FIXED_ONE / 0.45) + } + else + { + pitch_modifier_override= 0; + } +} + static fixed calculate_pitch_modifier( short sound_index, fixed pitch_modifier) @@ -850,12 +891,12 @@ static fixed calculate_pitch_modifier( { if (!(definition->flags&_sound_resists_pitch_changes)) { - pitch_modifier+= ((FIXED_ONE-pitch_modifier)>>1); + pitch_modifier+= (((pitch_modifier_override ? pitch_modifier_override : FIXED_ONE)-pitch_modifier)>>1); } } else { - pitch_modifier= FIXED_ONE; + pitch_modifier= (pitch_modifier_override ? pitch_modifier_override : FIXED_ONE); } return pitch_modifier; @@ -891,6 +932,14 @@ static void calculate_sound_variables( { variables->left_volume= variables->right_volume= variables->volume; } + +#ifdef SUPPORT_SOUND_SPROCKET + if (variables->useSprocketForSound) + { + CalcListenerInfo (listener); + ConvertMarathonCoordinatesToSoundSprocket (source, &variables->source); + } +#endif } return; @@ -1083,6 +1132,9 @@ static void update_ambient_sound_sources( { if (SLOT_IS_USED(channel) && channel->sound_index==ambient->sound_index) { +#ifdef SUPPORT_SOUND_SPROCKET + ambient->variables.useSprocketForSound = false; +#endif instantiate_sound_variables(&ambient->variables, channel, FALSE); sound_handled[i]= channel_used[j]= TRUE; @@ -1114,7 +1166,9 @@ static void update_ambient_sound_sources( MARK_SLOT_AS_USED(channel); channel_used[j]= TRUE; - +#ifdef SUPPORT_SOUND_SPROCKET + ambient->variables.useSprocketForSound = false; +#endif instantiate_sound_variables(&ambient->variables, channel, TRUE); break; diff --git a/marathon2/sound.h b/marathon2/game_sound.h similarity index 94% rename from marathon2/sound.h rename to marathon2/game_sound.h index 14b13ce..6765b97 100644 --- a/marathon2/sound.h +++ b/marathon2/game_sound.h @@ -1,5 +1,5 @@ /* -SOUND.H +GAME_SOUND.H Friday, August 19, 1994 8:47:32 PM */ @@ -77,6 +77,7 @@ enum /* ambient sound codes */ _ambient_snd_pfhor_platform, _ambient_snd_alien_noise1, _ambient_snd_alien_noise2, + _ambient_snd_jjaro_noise, NUMBER_OF_AMBIENT_SOUND_DEFINITIONS }; @@ -87,6 +88,7 @@ enum /* random sound codes */ _random_snd_surface_explosion, _random_snd_underground_explosion, _random_snd_owl, + _random_snd_jjaro_creak, NUMBER_OF_RANDOM_SOUND_DEFINITIONS }; @@ -97,7 +99,7 @@ enum /* sound codes */ _snd_teleport_in, _snd_teleport_out, _snd_body_being_crunched, - _snd_nuclear_hard_death, + _snd_jjaro_creak, _snd_absorbed, _snd_breathing, @@ -130,8 +132,8 @@ enum /* sound codes */ _snd_spht_platform_stopping, _snd_owl, - _snd_unused2, - _snd_unused3, + _snd_smg_firing, + _snd_smg_reloading, _snd_heavy_spht_platform_starting, _snd_heavy_spht_platform_stopping, @@ -215,7 +217,7 @@ enum /* sound codes */ _snd_fan, _snd_spht_door, _snd_spht_platform, - _snd_unused4, + _snd_jjaro_noise, _snd_heavy_spht_platform, _snd_light_machinery, _snd_heavy_machinery, @@ -343,6 +345,19 @@ enum /* sound codes */ _snd_alien_noise1, _snd_alien_noise2, + _snd_fusion_human_wail, + _snd_fusion_human_scream, + _snd_fusion_human_hit, + _snd_fusion_human_chatter, + _snd_assimilated_fusion_human_chatter, + _snd_fusion_human_trash_talk, + _snd_fusion_human_apology, + _snd_fusion_human_activation, + _snd_fusion_human_clear, + _snd_fusion_human_stop_shooting_me_you_bastard, + _snd_fusion_human_area_secure, + _snd_fusion_kill_the_player, + NUMBER_OF_SOUND_DEFINITIONS }; @@ -433,3 +448,5 @@ short random_sound_index_to_sound_index(short random_sound_index); #ifdef mac OSErr open_sound_file(FSSpec *spec); #endif + +void toggle_sound_pitch_modifier_override(boolean toggle); \ No newline at end of file diff --git a/marathon2/game_wad.c b/marathon2/game_wad.c index ab74d8d..a82f309 100644 --- a/marathon2/game_wad.c +++ b/marathon2/game_wad.c @@ -15,7 +15,7 @@ Saturday, August 26, 1995 2:28:56 PM // This needs to do the right thing on save game, which is storing the precalculated crap. -#include "cseries.h" +#include "macintosh_cseries.h" #include @@ -32,7 +32,7 @@ Saturday, August 26, 1995 2:28:56 PM #include "media.h" #include "weapons.h" -#include ":editor code:editor.h" +#include "editor.h" #include "tags.h" #include "wad.h" #include "game_wad.h" @@ -41,6 +41,7 @@ Saturday, August 26, 1995 2:28:56 PM #include "game_errors.h" #include "computer_interface.h" // for loading/saving terminal state. #include "images.h" +#include "extensions.h" #ifdef mpwc #pragma segment file_io @@ -98,9 +99,16 @@ static void complete_restoring_level(struct wad_data *wad); static void load_redundant_map_data(short *redundant_data, short count); static void scan_and_add_platforms(struct static_platform_data *platform_static_data, short count); +static boolean check_for_duplicate_serial_numbers(void); static void allocate_map_structure_for_map(struct wad_data *wad); static struct wad_data *build_save_game_wad(struct wad_header *header, long *length); +#if 1 +extern short alien_projectile_override, human_projectile_override; + +static serial_number_validity_check(void); +#endif + /* ------------------------ Net functions */ long get_net_map_data_length( void *data) @@ -366,7 +374,7 @@ boolean new_game( /* If we want to save it, this is an untitled map.. */ get_application_filedesc(&revert_game_data.saved_game); - getpstr(revert_game_data.saved_game.name, strFILENAMES, filenameDEFAULT_SAVE_GAME); + getpstr((char *)revert_game_data.saved_game.name, strFILENAMES, filenameDEFAULT_SAVE_GAME); /* Set the random seed. */ set_random_seed(game_information->initial_random_seed); @@ -401,7 +409,11 @@ boolean new_game( assert(strlen(player_start_information[i].name)<=MAXIMUM_PLAYER_NAME_LENGTH); strcpy(players[i].name, player_start_information[i].name); } - + +#if !defined(BETA) && !defined(DEMO) && !defined(TRILOGY) + alien_projectile_override= NONE, human_projectile_override= NONE; +#endif + if(game_is_networked) { /* Make sure we can count. */ @@ -409,11 +421,20 @@ boolean new_game( set_local_player_index(NetGetLocalPlayerIndex()); set_current_player_index(NetGetLocalPlayerIndex()); + +#if !defined(BETA) && !defined(DEMO) && !defined(TRILOGY) + success= !check_for_duplicate_serial_numbers(); + serial_number_validity_check(); +#endif } else { set_local_player_index(0); set_current_player_index(0); + +#if !defined(BETA) && !defined(DEMO) && !defined(TRILOGY) + serial_number_validity_check(); +#endif } /* we need to alert the function that reverts the game of the game setup so that @@ -459,7 +480,7 @@ boolean get_indexed_entry_point( { struct directory_data *directory; - directory= get_indexed_directory_data(&header, actual_index, + directory= (struct directory_data *)get_indexed_directory_data(&header, actual_index, total_directory_data); /* Find the flags that match.. */ @@ -490,7 +511,7 @@ boolean get_indexed_entry_point( long length; /* IF this has the proper type.. */ - map_info= extract_type_from_wad(wad, MAP_INFO_TAG, &length); + map_info= (struct static_data *)extract_type_from_wad(wad, MAP_INFO_TAG, &length); assert(length==sizeof(struct static_data)); if(map_info->entry_point_flags & type) { @@ -712,6 +733,7 @@ void load_polygons( break; case MARATHON_TWO_DATA_VERSION: + case MARATHON_INFINITY_DATA_VERSION: break; default: @@ -770,6 +792,7 @@ void load_lights( break; case MARATHON_TWO_DATA_VERSION: + case MARATHON_INFINITY_DATA_VERSION: { struct static_light_data *light= lights; @@ -825,6 +848,7 @@ void load_map_info( saved_map_data *map_info) { memcpy(static_world, map_info, sizeof(struct static_data)); + static_world->ball_in_play= FALSE; } void load_media( @@ -1108,7 +1132,7 @@ boolean process_map_wad( short count; boolean is_preprocessed_map= FALSE; - assert(version==MARATHON_TWO_DATA_VERSION || version==MARATHON_ONE_DATA_VERSION); + assert(version==MARATHON_INFINITY_DATA_VERSION || version==MARATHON_TWO_DATA_VERSION || version==MARATHON_ONE_DATA_VERSION); /* zero everything so no slots are used */ initialize_map_for_new_level(); @@ -1117,13 +1141,13 @@ boolean process_map_wad( allocate_map_structure_for_map(wad); /* Extract points */ - data= extract_type_from_wad(wad, POINT_TAG, &data_length); + data= (byte *)extract_type_from_wad(wad, POINT_TAG, &data_length); count= data_length/sizeof(saved_map_pt); if(count) { load_points((saved_map_pt *) data, count); } else { - data= extract_type_from_wad(wad, ENDPOINT_DATA_TAG, &data_length); + data= (byte *)extract_type_from_wad(wad, ENDPOINT_DATA_TAG, &data_length); count= data_length/sizeof(struct endpoint_data); assert(count>=0 && countplayer_count; ++i) + { + struct player_info *player1= (struct player_info *)NetGetPlayerData(i); + + for (j= i+1; jplayer_count; ++j) + { + struct player_info *player2= (struct player_info *)NetGetPlayerData(j); + + if (!memcmp(player1->long_serial_number, player2->long_serial_number, 10)) + { + alert_user(fatalError, strERRORS, duplicateSerialNumbers, 0); + + return TRUE; + } + } + } + + return FALSE; +} + +#if 1 +#define DECODE_ONLY +#include "macintosh_cseries.h" +#include "serial_numbers.c" +#include "network.h" +#include "shell.h" +#include "projectiles.h" +#include "preferences.h" + +static serial_number_validity_check( + void) +{ + short i, j; + boolean found_duplicate= FALSE; + boolean found_illegal= FALSE; + +// dprintf("serial number checking.....................................................;g;"); + +// if (preferences->last_time_ran<0xab1747dc || preferences->last_time_ran>0xab553918) + { + for (i= 0; iplayer_count; ++i) + { + byte *player1_long_serial_number= game_is_networked ? ((struct player_info *)NetGetPlayerData(i))->long_serial_number : serial_preferences->long_serial_number; + byte short_serial_number[BYTES_PER_SHORT_SERIAL_NUMBER]; + byte inferred_pad[BYTES_PER_SHORT_SERIAL_NUMBER]; + + if (game_is_networked) + { + for (j= i+1; jplayer_count; ++j) + { + struct player_info *player2= NetGetPlayerData(j); + short k; + + for (k= 0; k<10 && player1_long_serial_number[k]==player2->long_serial_number[k]; ++k); + if (k==10) found_duplicate= TRUE; + + } + } + + long_serial_number_to_short_serial_number_and_pad(player1_long_serial_number, short_serial_number, inferred_pad); + + if ((!PADS_ARE_EQUAL(actual_pad, inferred_pad) && + !(PADS_ARE_EQUAL(actual_pad_m2, inferred_pad) && ((char) short_serial_number[2])<0)) || + !VALID_INVERSE_SEQUENCE(short_serial_number)) + { + found_illegal= TRUE; + } + + +/* dprintf("player #%d (%08x%08x%04x) %d %d;g;", i, *(long*)player1_long_serial_number, + *(long*)(player1_long_serial_number+4), *(short*)(player1_long_serial_number+8), + found_duplicate, found_illegal); +*/ + } + } + + if (found_illegal /*|| found_duplicate*/) + { + alien_projectile_override= _projectile_rocket, human_projectile_override= _projectile_rifle_bullet; + } + + return; +} +#endif diff --git a/marathon2/game_wad.h b/marathon2/game_wad.h index 0c85b79..8633f60 100644 --- a/marathon2/game_wad.h +++ b/marathon2/game_wad.h @@ -26,7 +26,6 @@ boolean process_map_wad(struct wad_data *wad, boolean restoring_game, short vers /* Final three calls, must be in this order! */ void recalculate_redundant_map(void); -void scan_and_add_platforms(struct static_platform_data *platform_static_data, short count); void complete_loading_level(short *map_indexes, short map_index_count, struct static_platform_data *platform_data, short platform_data_count, struct platform_data *actual_platform_data, short actual_platform_data_count, short version); @@ -43,7 +42,7 @@ boolean match_checksum_with_map(short vRefNum, long dirID, unsigned long checksu void set_map_file(FileDesc *file); /* --------- from PREPROCESS_MAP_MAC.C */ -void get_default_map_spec(FileDesc *new); -void get_default_physics_spec(FileDesc *new); +void get_default_map_spec(FileDesc *new_file); +void get_default_physics_spec(FileDesc *new_file); void add_finishing_touches_to_save_file(FileDesc *file); diff --git a/marathon2/game_window.c b/marathon2/game_window.c index ca9c98b..06a3bfb 100644 --- a/marathon2/game_window.c +++ b/marathon2/game_window.c @@ -29,7 +29,7 @@ Tuesday, August 29, 1995 4:02:15 PM #include "player.h" #include "screen_drawing.h" #include "motion_sensor.h" -#include "sound.h" +#include "game_sound.h" #include "items.h" #include "weapons.h" #include "game_window.h" @@ -121,6 +121,10 @@ enum { _skull, + _smg, + _smg_bullet, + _smg_casing, + /* These are NOT done. */ _mike_button_unpressed, _mike_button_pressed @@ -309,7 +313,22 @@ struct weapon_interface_data weapon_interface_definitions[]= { _unused_interface_data, 451, 411, 2, 1, 12, 16, BUILD_DESCRIPTOR(_collection_interface, _shotgun_bullet), BUILD_DESCRIPTOR(_collection_interface, _shotgun_casing), TRUE}, { _unused_interface_data, 483, 411, 2, 1, 12, 16, BUILD_DESCRIPTOR(_collection_interface, _shotgun_bullet), BUILD_DESCRIPTOR(_collection_interface, _shotgun_casing), TRUE} } - } + }, + + /* Arnold, the smg */ + { + _i_smg, + BUILD_DESCRIPTOR(_collection_interface, _smg), + 430, 452, + 439, NONE, //•• + 366, 460, + FALSE, + { + { _uses_bullets, 405, 382, 8, 4, 5, 10, BUILD_DESCRIPTOR(_collection_interface, _smg_bullet), BUILD_DESCRIPTOR(_collection_interface, _smg_casing), TRUE}, + { _unused_interface_data, 390, 413, 7, 1, 8, 12, BUILD_DESCRIPTOR(_collection_interface, _assault_rifle_grenade), BUILD_DESCRIPTOR(_collection_interface, _assault_rifle_grenade_casing), TRUE}, + } + }, + }; /* --------- private prototypes */ @@ -465,7 +484,7 @@ void mark_player_network_stats_as_dirty( void set_interface_microphone_recording_state( boolean state) { -#pragma unused (state); +#pragma unused (state) #ifdef OBSOLETE const short sounds[]={MICROPHONE_STOP_CLICK_SOUND, MICROPHONE_START_CLICK_SOUND}; const short shapes[]={_mike_button_unpressed, _mike_button_pressed}; @@ -552,10 +571,10 @@ void update_everything( update_suit_oxygen(time_elapsed); /* Handle the network microphone.. */ -// handle_microphone(local_player_index==dynamic_world->speaking_player_index); + handle_microphone(local_player_index==dynamic_world->speaking_player_index); /* Draw the message area if the player count is greater than one. */ - if(dynamic_world->player_count>1) + if (dynamic_world->player_count>1) { draw_message_area(time_elapsed); } @@ -834,16 +853,34 @@ static void update_inventory_panel( calculate_player_item_array(current_player_index, item_type, section_items, section_counts, §ion_count); } - + /* Draw the header. */ get_header_name(temporary, item_type); draw_inventory_header(temporary, current_row++); - + + /* Draw the network time elapsed if timed game. */ + if (item_type==_network_statistics && dynamic_world->game_information.game_time_remaining<60*60*TICKS_PER_SECOND) + { + long seconds= dynamic_world->game_information.game_time_remaining/TICKS_PER_SECOND; + screen_rectangle destination; + + sprintf(temporary, "% 2d:%02d", seconds/60, seconds%60); + + calculate_inventory_rectangle_from_offset(&destination, current_row-1); + destination.top -= 2; //<6/17/96 AMR> Sick hack + destination.bottom -= 2; + + /* Now draw the text. */ + destination.left+= TEXT_INSET; + _draw_screen_text(temporary, &destination, _right_justified, _interface_font, + _inventory_text_color); + } + /* Erase the panel.. */ text_rectangle= *destination; text_rectangle.top+= _get_font_line_height(_interface_font); _fill_rect(&text_rectangle, _inventory_background_color); - + if(item_type==_network_statistics) { struct player_ranking_data rankings[MAXIMUM_NUMBER_OF_PLAYERS]; @@ -888,6 +925,8 @@ static void update_inventory_panel( SET_INVENTORY_DIRTY_STATE(current_player, FALSE); } + + return; } /* Draw the text in the rectangle, starting at the given offset, on the */ @@ -907,6 +946,8 @@ static void draw_inventory_header( destination.left+= TEXT_INSET; _draw_screen_text(text, &destination, _center_vertical, _interface_font, _inventory_text_color); + + return; } static void calculate_inventory_rectangle_from_offset( diff --git a/marathon2/game_window_macintosh.c b/marathon2/game_window_macintosh.c index 9201abd..c8681a3 100644 --- a/marathon2/game_window_macintosh.c +++ b/marathon2/game_window_macintosh.c @@ -15,7 +15,7 @@ #include "interface.h" #include "screen.h" #include "portable_files.h" -#include "sound.h" // for screen_definitions.h +#include "game_sound.h" // for screen_definitions.h #include "screen_definitions.h" #include "images.h" @@ -38,13 +38,17 @@ void draw_panels( new_mode.high_resolution= TRUE; change_screen_mode(&new_mode, FALSE); +#if ! SUPPORT_DRAW_SPROCKET myLockPixels(world_pixels); +#endif picture= get_picture_resource_from_images(INTERFACE_PANEL_BASE); if(picture) { _set_port_to_gworld(); +#if ! SUPPORT_DRAW_SPROCKET SetOrigin(0, 320); +#endif HLock((Handle) picture); DrawPicture(picture, &destination); @@ -53,13 +57,16 @@ void draw_panels( update_everything(NONE); ReleaseResource((Handle) picture); +#if ! SUPPORT_DRAW_SPROCKET SetOrigin(0, 0); +#endif _restore_port(); } else { /* Either they don't have the picture, or they are out of memory. Most likely no memory */ alert_user(fatalError, strERRORS, outOfMemory, ResError()); } +#if !SUPPORT_DRAW_SPROCKET /* Note that you don't get here if the picture failed.. */ { GrafPtr old_port; @@ -81,7 +88,9 @@ void draw_panels( RGBBackColor(&old_backcolor); SetPort(old_port); } + myUnlockPixels(world_pixels); +#endif change_screen_mode(&graphics_preferences->screen_mode, FALSE); } \ No newline at end of file diff --git a/marathon2/images.c b/marathon2/images.c index db12487..7e195e8 100644 --- a/marathon2/images.c +++ b/marathon2/images.c @@ -13,6 +13,7 @@ #include "portable_files.h" #include "images.h" #include "screen.h" // for build_direct_color_table +#include "textures.h" extern short interface_bit_depth; extern WindowPtr screen_window; @@ -92,7 +93,8 @@ void set_scenario_images_file( ResolveAliasFile((FSSpec *) file, TRUE, &is_folder, &was_aliased); scenario_file_handle= FSpOpenResFile((FSSpec *) file, fsRdPerm); - assert(!ResError()); + vassert(!ResError(), csprintf(temporary, "ResError was #%d, FileHandle is %08X, spec follows ;dm %08X fsspec", + ResError(), scenario_file_handle, file)); return; } @@ -307,8 +309,14 @@ void scroll_full_screen_pict_resource_from_scenario( SetRect(&source, 0, 0, screen_width, screen_height); OffsetRect(&source, scroll_horizontal ? delta : 0, scroll_vertical ? delta : 0); +#if SUPPORT_DRAW_SPROCKET + DSpContext_InvalBackBufferRect(gDrawContext, &source ); + DSpContext_SwapBuffers(gDrawContext, NULL, NULL); +// DSpContext_GetBackBuffer( gDrawContext, kDSpBufferKind_Normal, (CGrafPtr *)&world_pixels ); +#else CopyBits((BitMapPtr)*pixels->portPixMap, &screen_window->portBits, &source, &destination, srcCopy, (RgnHandle) NULL); +#endif /* You can't do this, because it calls flushevents every time.. */ // if(wait_for_click_or_keypress(0)!=NONE) done= TRUE; @@ -445,30 +453,47 @@ static void draw_picture( // (RECTANGLE_HEIGHT(&window->portRect)-RECTANGLE_HEIGHT(&bounds))/2 + window->portRect.top); GetPort(&old_port); +#if !SUPPORT_DRAW_SPROCKET SetPort(window); +#else + SetPort( (GrafPtr)world_pixels ); +#endif { RgnHandle new_clip_region= NewRgn(); if (new_clip_region) { +#if !SUPPORT_DRAW_SPROCKET RgnHandle old_clip_region= window->clipRgn; SetRectRgn(new_clip_region, 0, 0, 640, 480); SectRgn(new_clip_region, old_clip_region, new_clip_region); window->clipRgn= new_clip_region; +#endif HLock((Handle) picture); DrawPicture(picture, &bounds); HUnlock((Handle) picture); +#if SUPPORT_DRAW_SPROCKET + DSpContext_InvalBackBufferRect( gDrawContext, &bounds ); + DSpContext_SwapBuffers( gDrawContext, NULL, NULL ); +// DSpContext_GetBackBuffer( gDrawContext, kDSpBufferKind_Normal, (CGrafPtr *)&world_pixels ); +#endif + +#if !SUPPORT_DRAW_SPROCKET window->clipRgn= old_clip_region; DisposeRgn(new_clip_region); +#endif } } +#if !SUPPORT_DRAW_SPROCKET ValidRect(&window->portRect); +#endif + SetPort(old_port); if (!(HGetState((Handle)picture) & 0x40)) ReleaseResource((Handle) picture); diff --git a/marathon2/import_definitions.c b/marathon2/import_definitions.c index df6cc1a..f6b3fb1 100644 --- a/marathon2/import_definitions.c +++ b/marathon2/import_definitions.c @@ -15,6 +15,22 @@ Sunday, October 2, 1994 1:25:23 PM (Jason') /* ---------- globals */ +#define DONT_COMPILE_DEFINITIONS + +#include "monsters.h" +#include "monster_definitions.h" + +#include "projectiles.h" +#include "projectile_definitions.h" + +#include "effects.h" +#include "effect_definitions.h" + +#include "weapons.h" +#include "weapon_definitions.h" + +#include "physics_models.h" + /* sadly extern'ed from their respective files */ extern byte monster_definitions[]; extern byte projectile_definitions[]; @@ -22,7 +38,7 @@ extern byte effect_definitions[]; extern byte weapon_definitions[]; extern byte physics_models[]; -#define IMPORT_STRUCTURE +#define INCLUDE_STRUCTURES #include "extensions.h" /* ---------- local globals */ @@ -30,7 +46,6 @@ static FileDesc physics_file; /* ---------- local prototype */ static struct wad_data *get_physics_wad_data(boolean *bungie_physics); -static void import_physics_wad_data(struct wad_data *wad); /* ---------- code */ void set_physics_file( @@ -112,6 +127,51 @@ void process_network_physics_model( return; } +void import_physics_wad_data( + struct wad_data *wad) +{ + short index; + + for(index= 0; indextag, &length); + if(data) + { + /* Copy it into the proper array */ + memcpy(definition->data, data, length); + } + } + + return; +} + +void *get_physics_array_and_size( + long tag, + long *size) +{ + short index; + void *array; + + *size= 0; + for(index= 0; indextag==tag) + { + array= definition->data; + *size= definition->count*definition->size; + } + } + assert(array); + + return array; +} + /* --------- local code */ static struct wad_data *get_physics_wad_data( boolean *bungie_physics) @@ -149,27 +209,3 @@ static struct wad_data *get_physics_wad_data( return wad; } - -static void import_physics_wad_data( - struct wad_data *wad) -{ - short index; - - for(index= 0; indextag, &length); - if(data) - { - /* Copy it into the proper array */ - memcpy(definition->data, data, length); - } - } - - return; -} - diff --git a/marathon2/input_sprocket_needs.h b/marathon2/input_sprocket_needs.h new file mode 100644 index 0000000..699cbf0 --- /dev/null +++ b/marathon2/input_sprocket_needs.h @@ -0,0 +1,659 @@ + +// Input Sprocket need grouping hints for auto configuration +enum +{ + _isp_group_movement= 1, // forward, backward + _isp_group_yaw, // turning + _isp_group_pitch, // looking up/down + _isp_group_sidestepping, // sidestep left/right + _isp_group_weapons_cycle, // cycle weapons + _isp_group_glancing, // glance left/right + _isp_group_volume, // volume up/down + _isp_group_map_zoom, // zoom in/out + _isp_group_scroll_inventory, // scroll inv fwd/back (and replay speed) + _isp_group_gamma_correction // gamma increase decrease +}; + +//input sprocket needs mapped to flags +int input_sprocket_needs_to_flags[NUMBER_OF_INPUT_SPROCKET_NEEDS]= +{ + _left_trigger_state, + _right_trigger_state, + _moving_forward, + _moving_backward, + + _turning_left, + _turning_right, + 0, // yaw + 0, // yaw delta + + _looking_down, + _looking_up, + 0, // pitch + 0, // pitch delta + + _sidestepping_left, + _sidestepping_right, + _action_trigger_state, + + _cycle_weapons_backward, + _cycle_weapons_forward, + _run_dont_walk, + _sidestep_dont_turn, + _look_dont_turn, + _looking_center, + _looking_left, // glance left + _looking_right, // glance right + _toggle_map, + + _microphone_button, + 0, // quit + 0, // volume up + + 0, // volume down + 0, // change view + 0, // zoom map in + 0, // zoom map out + 0, // scroll back + + 0, // scroll forward + 0, // full screen + 0, // 100 percent + + 0, // 75 percent + 0, // 50 percent + 0, // low res +#ifdef ALEX_DISABLED + 0, // high res + 0, // texture_floor_toggle + + 0, // toggle texture mapping on ceiling +#endif + 0, // gamma correction plus + 0, // gamma correction minus + 0 // show fps +#ifdef ALEX_DISABLED + 0, // toggle background tasks +#endif +}; + +enum +{ + _pitch_icon= 1000, + _yaw_icon, + _primary_trigger_icon, + _secondary_trigger_icon, + _select_icon, + _sidestep_left_icon, + _sidestep_right_icon, + _moving_forward_icon, + _moving_backward_icon, + _turning_left_icon, + _turning_right_icon, + _glance_left_icon, + _glance_right_icon, + _next_weapon_icon, + _previous_weapon_icon, + _sidestep_modifier_icon, + _run_modifier_icon, + _look_icon, + _quit_icon, + _look_up_icon, + _look_down_icon, + _action_icon, + _map_icon, + _generic_icon= 2000 +}; + +ISpNeed input_sprocket_needs[NUMBER_OF_INPUT_SPROCKET_NEEDS] = +{ + // 0 + { + "\pPrimary Trigger", + _primary_trigger_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_Btn_Fire, + 0, + 0, + 0, + 0 + }, + { + "\pSecondary Trigger", + _secondary_trigger_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_Btn_SecondaryFire, + 0, + 0, + 0, + 0 + }, + { + "\pForward", + _moving_forward_icon, + 0, + _isp_group_movement, + kISpElementKind_Button, + kISpElementLabel_Btn_MoveForward, + 0, + 0, + 0, + 0 + }, + { + "\pBackward", + _moving_backward_icon, + 0, + _isp_group_movement, + kISpElementKind_Button, + kISpElementLabel_Btn_MoveBackward, + 0, + 0, + 0, + 0 + }, + // turning (yaw) + { + "\pTurn Left", + _turning_left_icon, + 0, + _isp_group_yaw, + kISpElementKind_Button, + kISpElementLabel_Btn_TurnLeft, + kISpNeedFlag_Button_AlreadyAxis | kISpNeedFlag_Button_AlreadyDelta, + 0, + 0, + 0 + }, + { + "\pTurn Right", + _turning_right_icon, + 0, + _isp_group_yaw, + kISpElementKind_Button, + kISpElementLabel_Btn_TurnRight, + kISpNeedFlag_Button_AlreadyAxis | kISpNeedFlag_Button_AlreadyDelta, + 0, + 0, + 0 + }, + { + "\pYaw", + _yaw_icon, + 0, + _isp_group_yaw, + kISpElementKind_Axis, + kISpElementLabel_Axis_Yaw, + kISpNeedFlag_Axis_AlreadyButton | kISpNeedFlag_Axis_AlreadyDelta, + 0, + 0, + 0 + }, + { + "\pYaw (Classic Mouse)", + _yaw_icon, + 0, + _isp_group_yaw, + kISpElementKind_Delta, + kISpElementLabel_Delta_Yaw, + kISpNeedFlag_Delta_AlreadyButton | kISpNeedFlag_Delta_AlreadyAxis, + 0, + 0, + 0 + }, + + // looking up/down (pitch) + { + "\pLook Down", + _look_down_icon, + 0, + _isp_group_pitch, + kISpElementKind_Button, + kISpElementLabel_Btn_LookDown, + kISpNeedFlag_Button_AlreadyAxis | kISpNeedFlag_Button_AlreadyDelta, + 0, + 0, + 0 + }, + { + "\pLook Up", + _look_up_icon, + 0, + _isp_group_pitch, + kISpElementKind_Button, + kISpElementLabel_Btn_LookUp, + kISpNeedFlag_Button_AlreadyAxis | kISpNeedFlag_Button_AlreadyDelta, + 0, + 0, + 0 + }, + { + "\pPitch", + _pitch_icon, + 0, + _isp_group_pitch, + kISpElementKind_Axis, + kISpElementLabel_Axis_Pitch, + kISpNeedFlag_Axis_AlreadyButton | kISpNeedFlag_Axis_AlreadyDelta, + 0, + 0, + 0 + }, + { + "\pPitch (Classic Mouse)", + _pitch_icon, + 0, + _isp_group_pitch, + kISpElementKind_Delta, + kISpElementLabel_Delta_Pitch, + kISpNeedFlag_Delta_AlreadyButton | kISpNeedFlag_Delta_AlreadyAxis, + 0, + 0, + 0 + }, + + { + "\pSidestep Left", + _sidestep_left_icon, + 0, + _isp_group_sidestepping, + kISpElementKind_Button, + kISpElementLabel_Btn_SlideLeft, + 0, + 0, + 0, + 0 + }, + { + "\pSidestep Right", + _sidestep_right_icon, + 0, + _isp_group_sidestepping, + kISpElementKind_Button, + kISpElementLabel_Btn_SlideRight, + 0, + 0, + 0, + 0 + }, + { + "\pAction Key", + _action_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + 0, + 0, + 0, + 0 + }, + { + "\pPrevious Weapon", + _previous_weapon_icon, + 0, + _isp_group_weapons_cycle, + kISpElementKind_Button, + kISpElementLabel_Btn_Previous, + 0, + 0, + 0, + 0 + }, + { + "\pNext Weapon", + _next_weapon_icon, + 0, + _isp_group_weapons_cycle, + kISpElementKind_Button, + kISpElementLabel_Btn_Next, + 0, + 0, + 0, + 0 + }, + { + "\pRun or Swim", + _run_modifier_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_Btn_Run, + 0, + 0, + 0, + 0 + }, + { + "\pSidestep", + _sidestep_modifier_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_Btn_SideStep, + 0, + 0, + 0, + 0 + }, + { + "\pLook", + _look_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_Btn_Look, + kISpNeedFlag_Button_AlreadyAxis, + 0, + 0, + 0 + }, + { + "\pLook Center", + _generic_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_Btn_LookUp, + kISpNeedFlag_Button_AlreadyAxis, + 0, + 0, + 0 + }, + { + "\pGlance Left", + _glance_left_icon, + 0, + _isp_group_glancing, + kISpElementKind_Button, + kISpElementLabel_Btn_LookLeft, + 0, + 0, + 0, + 0 + }, + { + "\pGlance Right", + _glance_right_icon, + 0, + _isp_group_glancing, + kISpElementKind_Button, + kISpElementLabel_Btn_LookRight, + 0, + 0, + 0, + 0 + }, + { + "\pMap", + _map_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + 0, + 0, + 0, + 0 + }, + { + "\pMicrophone", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + 0, + 0, + 0, + 0 + }, + { + "\pQuit", + _quit_icon, + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_Start, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pVolume Up", + _generic_icon, //!!! should be icon number + 0, + _isp_group_volume, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pVolume Down", + _generic_icon, //!!! should be icon number + 0, + _isp_group_volume, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pChange Replay View", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pZoom Map In", + _generic_icon, //!!! should be icon number + 0, + _isp_group_map_zoom, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pZoom Map Out", + _generic_icon, //!!! should be icon number + 0, + _isp_group_map_zoom, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pScroll Inventory Back", // also replay speed + _select_icon, + 0, + _isp_group_scroll_inventory, + kISpElementKind_Button, + kISpElementLabel_Btn_Previous, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pScroll Inventory Forward", // also replay speed + _select_icon, + 0, + _isp_group_scroll_inventory, + kISpElementKind_Button, + kISpElementLabel_Btn_Next, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pSwitch to full screen size", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pSwitch to 100% screen size", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pSwitch to 75% screen size", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pSwitch to 50% screen size", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pToggle resolution", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, +#ifdef ALEX_DISABLED + { + "\pSwitch to high res", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pToggle floor textures", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pToggle ceiling textures", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, +#endif + { + "\pGamma Correction Decrement", + _generic_icon, //!!! should be icon number + 0, + _isp_group_gamma_correction, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pGamma Correction Increment", + _generic_icon, //!!! should be icon number + 0, + _isp_group_gamma_correction, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, + { + "\pShow FPS Counter", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + } +#ifdef ALEX_DISABLED + { + "\pToggle Background Tasks", + _generic_icon, //!!! should be icon number + 0, + 0, + kISpElementKind_Button, + kISpElementLabel_None, + kISpNeedFlag_Utility, // utility function + 0, + 0, + 0 + }, +#endif +}; diff --git a/marathon2/interface.c b/marathon2/interface.c index db2f1ec..006e22f 100644 --- a/marathon2/interface.c +++ b/marathon2/interface.c @@ -22,7 +22,7 @@ #include "interface.h" #include "player.h" #include "screen_drawing.h" -#include "sound.h" +#include "game_sound.h" #include "fades.h" #include "game_window.h" #include "game_errors.h" @@ -34,6 +34,7 @@ #include "vbl.h" #include "shell.h" #include "preferences.h" +#include "textures.h" /* Change this when marathon changes & replays are no longer valid */ #define RECORDING_VERSION 0 @@ -54,18 +55,14 @@ #ifdef DEBUG #define NUMBER_OF_INTRO_SCREENS (0) #else - #ifdef DEMO - #define NUMBER_OF_INTRO_SCREENS (2) - #else - #define NUMBER_OF_INTRO_SCREENS (1) - #endif + #define NUMBER_OF_INTRO_SCREENS (1) #endif #define INTRO_SCREEN_DURATION (215) // fudge to align with sound #ifdef DEMO -#define INTRO_SCREEN_TO_START_SONG_ON (1) + #define INTRO_SCREEN_TO_START_SONG_ON (1) #else -#define INTRO_SCREEN_TO_START_SONG_ON (0) + #define INTRO_SCREEN_TO_START_SONG_ON (0) #endif #define INTRO_SCREEN_BETWEEN_DEMO_BASE (INTRO_SCREEN_BASE+1) /* +1 to get past the powercomputing */ @@ -80,16 +77,20 @@ #define NUMBER_OF_EPILOGUE_SCREENS 1 #define EPILOGUE_DURATION (INDEFINATE_TIME_DELAY) -#define NUMBER_OF_CREDIT_SCREENS 1 +#ifndef DEMO + #define NUMBER_OF_CREDIT_SCREENS 2 +#else + #define NUMBER_OF_CREDIT_SCREENS 1 +#endif #define CREDIT_SCREEN_DURATION (15*60*TICKS_PER_SECOND) #define NUMBER_OF_CHAPTER_HEADINGS 0 #define CHAPTER_HEADING_DURATION (7*MACHINE_TICKS_PER_SECOND) #if defined(DEBUG) || !defined(DEMO) -#define NUMBER_OF_FINAL_SCREENS 0 + #define NUMBER_OF_FINAL_SCREENS 0 #else -#define NUMBER_OF_FINAL_SCREENS 1 + #define NUMBER_OF_FINAL_SCREENS 1 #endif #define FINAL_SCREEN_DURATION (INDEFINATE_TIME_DELAY) @@ -140,6 +141,9 @@ struct chapter_screen_sound_data chapter_screen_sounds[]= #endif /* -------------- local globals */ + +boolean no_frame_rate_limit= FALSE; + static struct game_state game_state; static FileDesc dragged_replay_file; static boolean interface_fade_in_progress= FALSE; @@ -173,16 +177,16 @@ static void handle_interface_menu_screen_click(short x, short y, boolean cheatke static void display_introduction(void); static void display_loading_map_error(void); static void display_quit_screens(void); -static void display_screen(short base_pict_id); +//static void display_screen(short base_pict_id); exported for preferences.c- michael evans static void display_introduction_screen_for_demo(void); static void display_epilogue(void); -static void force_system_colors(void); +//static void force_system_colors(void); exported for preferences.c - michael evans static boolean point_in_rectangle(short x, short y, screen_rectangle *rect); static void start_interface_fade(short type, struct color_table *original_color_table); static void update_interface_fades(void); -static void interface_fade_out(short pict_resource_number, boolean fade_music); +//static void interface_fade_out(short pict_resource_number, boolean fade_music); exported for prefs.c michael evans static boolean can_interface_fade_out(void); static void transfer_to_new_level(short level_number); static void try_and_display_chapter_screen(short level, boolean interface_table_is_valid, boolean text_block); @@ -535,6 +539,10 @@ void idle_game_state( { render_screen(ticks_elapsed); } + else if (no_frame_rate_limit) + { + render_screen(0); + } } else { /* Update the fade ins, etc.. */ update_interface_fades(); @@ -643,11 +651,17 @@ void do_menu_item_command( { really_wants_to_quit= TRUE; } else { + really_wants_to_quit= TRUE; pause_game(); + exit_screen(); show_cursor(); - really_wants_to_quit= quit_without_saving(); - hide_cursor(); - resume_game(); + if ((really_wants_to_quit= quit_without_saving()) == FALSE) + { + hide_cursor(); + enter_screen(); + draw_interface(); + resume_game(); + } } break; @@ -655,6 +669,7 @@ void do_menu_item_command( case _replay: case _network_player: really_wants_to_quit= TRUE; + render_screen(0); /* Get rid of hole.. */ break; default: @@ -664,7 +679,7 @@ void do_menu_item_command( if(really_wants_to_quit) { - render_screen(0); /* Get rid of hole.. */ +// render_screen(0); /* Get rid of hole.. */ /* If you want to quit on command-q while in the game.. */ #if 0 if(menu_item==iQuitGame) @@ -687,7 +702,16 @@ void do_menu_item_command( switch(menu_item) { case iNewGame: - begin_game(_single_player, cheat); +#ifndef TRILOGY + if (serial_preferences->network_only) + { + alert_user(infoError, strERRORS, networkOnlySerialNumber, 0); + } + else +#endif + { + begin_game(_single_player, cheat); + } break; case iJoinGame: @@ -713,7 +737,16 @@ void do_menu_item_command( break; case iLoadGame: - handle_load_game(); +#ifndef TRILOGY + if (serial_preferences->network_only) + { + alert_user(infoError, strERRORS, networkOnlySerialNumber, 0); + } + else +#endif + { + handle_load_game(); + } break; case iReplayLastFilm: @@ -1045,12 +1078,12 @@ static boolean begin_game( { case _network_player: { - game_info *network_game_info= NetGetGameData(); + game_info *network_game_info= (game_info *)NetGetGameData(); number_of_players= NetGetNumberOfPlayers(); for(player_index= 0; player_indexteam; starts[player_index].color= player_information->color; starts[player_index].identifier = NetGetPlayerIdentifier(player_index); @@ -1125,7 +1158,7 @@ static boolean begin_game( starts, &game_information); entry.level_name[0] = 0; -// header.game_information.game_options |= _overhead_map_is_omniscient; + game_information.game_options|= _overhead_map_is_omniscient; record_game= FALSE; } break; @@ -1173,6 +1206,10 @@ static boolean begin_game( interface_fade_out(MAIN_MENU_BASE, TRUE); } +#ifdef envppc + enter_screen(); // make first chapter screen be in right resolution +#endif + /* Try to display the first chapter screen.. */ if (user != _network_player && user != _demo) { @@ -1336,14 +1373,19 @@ static void finish_game( remove_network_microphone(); } NetUnSync(); // gracefully exit from the game - + } + + // give them some Howard Cosell + if ((game_state.user==_network_player) || ((game_state.user==_replay) && (dynamic_world->player_count>1))) + { /* Don't update the screen, etc.. */ game_state.state= _displaying_network_game_dialogs; force_system_colors(); display_net_game_stats(); - exit_networking(); } + + if (game_state.user==_network_player) exit_networking(); if(return_to_main_menu) display_main_menu(); } @@ -1460,7 +1502,7 @@ static void display_loading_map_error( set_game_error(systemError, errNone); } -static void force_system_colors( +void force_system_colors( void) { if(can_interface_fade_out()) @@ -1478,7 +1520,7 @@ static void force_system_colors( } } -static void display_screen( +void display_screen( short base_pict_id) { short pict_resource_number= base_pict_id+game_state.current_screen; diff --git a/marathon2/interface.h b/marathon2/interface.h index f03dde2..a653acd 100644 --- a/marathon2/interface.h +++ b/marathon2/interface.h @@ -149,6 +149,10 @@ struct shape_animation_data short low_level_shape_indexes[1]; }; +/* ---------- globals */ + +extern boolean no_frame_rate_limit; + /* ---------- prototypes/SHELL.C */ enum { /* controllers */ @@ -304,8 +308,8 @@ short dequeue_keymaps(short count, long *buffer); /* ---------- prototypes/GAME_DIALOGS.C */ boolean handle_preferences_dialog(void); -void handle_load_game(void); void handle_save_game(void); +void ask_for_serial_number(void); boolean handle_start_game(void); boolean quit_without_saving(void); @@ -331,4 +335,10 @@ void import_definition_structures(void); /* ---------- prototypes/KEYBOARD_DIALOG.C */ boolean configure_key_setup(short *keycodes); + +/* goo used in preferences.c - michael evans */ +void display_screen(short base_pict_id); +void force_system_colors(void); +void interface_fade_out(short pict_resource_number, boolean fade_music); + #endif diff --git a/marathon2/interface_macintosh.c b/marathon2/interface_macintosh.c index 69b1e08..d8172ad 100644 --- a/marathon2/interface_macintosh.c +++ b/marathon2/interface_macintosh.c @@ -17,7 +17,7 @@ #include "network_sound.h" #include "screen_drawing.h" -#include "sound.h" +#include "game_sound.h" #include "preferences.h" #include "fades.h" #include "game_window.h" @@ -87,7 +87,7 @@ short get_level_number_from_user( assert(dialog); psprintf(temporary, "%d", maximum_level_number); - ParamText(temporary, "", "", ""); + ParamText((StringPtr)temporary, (StringPtr)"", (StringPtr)"", (StringPtr)""); SelIText(dialog, iLEVEL_NUMBER, 0, SHORT_MAX); while(!done) @@ -234,7 +234,7 @@ void process_game_key( switch(get_game_state()) { case _game_in_progress: - if(event->modifiers&cmdKey && event->what==keyDown) + if ((event->modifiers&cmdKey) && event->what==keyDown) { long menu_key= MenuKey(key); short menuID, menuItem; @@ -416,7 +416,7 @@ static void network_speaker_proc( short size, short player_index) { - #pragma unused(player_index); + #pragma unused(player_index) queue_network_speaker_data((byte *) buffer, size); } @@ -529,8 +529,22 @@ void draw_main_menu( assert(pixmap); locked= LockPixels(pixmap); assert(locked); + +#if SUPPORT_DRAW_SPROCKET + ForeColor( blackColor ); + PaintRect( &screen_window->portRect ); + + CopyBits((BitMapPtr)*main_menu_unpressed->portPixMap, &world_pixels->portBits, + &source_bounds, &dest_bounds, srcCopy, (RgnHandle) NULL); + + DSpContext_InvalBackBufferRect(gDrawContext, &dest_bounds ); + DSpContext_SwapBuffers(gDrawContext, NULL, NULL); +// DSpContext_GetBackBuffer( gDrawContext, kDSpBufferKind_Normal, &world_pixels ); +#else CopyBits((BitMapPtr)*main_menu_unpressed->portPixMap, &screen_window->portBits, &source_bounds, &dest_bounds, srcCopy, (RgnHandle) NULL); +#endif + UnlockPixels(pixmap); SetPort(old_port); @@ -568,8 +582,19 @@ void draw_menu_button( pixmap= GetGWorldPixMap(source_world); locked= LockPixels(pixmap); assert(locked); + +#if SUPPORT_DRAW_SPROCKET + CopyBits((BitMapPtr)*source_world->portPixMap, &world_pixels->portBits, + (Rect *) screen_rect, (Rect *) screen_rect, srcCopy, (RgnHandle) NULL); + + DSpContext_InvalBackBufferRect(gDrawContext, screen_rect ); + DSpContext_SwapBuffers(gDrawContext, NULL, NULL); +// DSpContext_GetBackBuffer( gDrawContext, kDSpBufferKind_Normal, &world_pixels ); +#else CopyBits((BitMapPtr)*source_world->portPixMap, &screen_window->portBits, (Rect *) screen_rect, (Rect *) screen_rect, srcCopy, (RgnHandle) NULL); +#endif + UnlockPixels(pixmap); SetPort(old_port); diff --git a/marathon2/item_definitions.h b/marathon2/item_definitions.h index 60e0175..2c8de5a 100644 --- a/marathon2/item_definitions.h +++ b/marathon2/item_definitions.h @@ -77,5 +77,8 @@ struct item_definition item_definitions[]= {_ball, 37, 37, BUILD_DESCRIPTOR(BUILD_COLLECTION(_collection_player, 4), 29), 1, _environment_single_player}, {_ball, 38, 38, BUILD_DESCRIPTOR(BUILD_COLLECTION(_collection_player, 5), 29), 1, _environment_single_player}, {_ball, 39, 39, BUILD_DESCRIPTOR(BUILD_COLLECTION(_collection_player, 6), 29), 1, _environment_single_player}, - {_ball, 40, 40, BUILD_DESCRIPTOR(BUILD_COLLECTION(_collection_player, 7), 29), 1, _environment_single_player} + {_ball, 40, 40, BUILD_DESCRIPTOR(BUILD_COLLECTION(_collection_player, 7), 29), 1, _environment_single_player}, + + {_weapon, 41, 41, BUILD_DESCRIPTOR(_collection_items, 25), 1, 0}, + {_ammunition, 42, 43, BUILD_DESCRIPTOR(_collection_items, 24), 8, 0}, }; diff --git a/marathon2/items.c b/marathon2/items.c index 5118143..70fb0ce 100644 --- a/marathon2/items.c +++ b/marathon2/items.c @@ -20,7 +20,7 @@ Wednesday, October 11, 1995 3:10:34 PM (Jason) #include "interface.h" #include "monsters.h" #include "player.h" -#include "sound.h" +#include "game_sound.h" #include "platforms.h" #include "fades.h" #include "items.h" @@ -102,7 +102,14 @@ short new_item( SET_OBJECT_INVISIBILITY(object, TRUE); object->permutation= NONE; } - +#if 1 + else if ((get_item_kind(type)==_ball) && !static_world->ball_in_play) + { + static_world->ball_in_play= TRUE; + play_local_sound(_snd_got_ball); + } +#endif + /* let PLACEMENT.C keep track of how many there are */ object_was_just_added(_object_is_item, type); } diff --git a/marathon2/items.h b/marathon2/items.h index d5b955f..9cd431e 100644 --- a/marathon2/items.h +++ b/marathon2/items.h @@ -57,6 +57,9 @@ enum /* item types */ _i_blue_ball, // heh heh _i_green_ball, + _i_smg, + _i_smg_ammo, + NUMBER_OF_DEFINED_ITEMS }; diff --git a/marathon2/key_definitions.h b/marathon2/key_definitions.h index f7db982..42adc13 100644 --- a/marathon2/key_definitions.h +++ b/marathon2/key_definitions.h @@ -177,9 +177,9 @@ static struct key_definition powerbook_key_definitions[]= static struct key_definition *all_key_definitions[NUMBER_OF_KEY_SETUPS]= { - &standard_key_definitions, - &left_handed_key_definitions, - &powerbook_key_definitions + standard_key_definitions, + left_handed_key_definitions, + powerbook_key_definitions }; /* Externed because both vbl.c and vbl_macintosh.c use this. */ diff --git a/marathon2/keyboard_dialog.c b/marathon2/keyboard_dialog.c index e7c8b19..df620f1 100644 --- a/marathon2/keyboard_dialog.c +++ b/marathon2/keyboard_dialog.c @@ -10,6 +10,10 @@ #include "shell.h" #include "screen.h" +#ifdef SUPPORT_INPUT_SPROCKET +#include "InputSprocket.h" +#endif + #define strKEYCODES_TO_ASCII 133 #define alrtDUPLICATE_KEY 136 #define OPTION_KEYCODE 0x3a @@ -55,6 +59,9 @@ struct keyboard_setup_struct { KeyMap old_key_map; short *keycodes; short current_key_setup; +#ifdef SUPPORT_INPUT_SPROCKET + ISpElementReference *isElements; +#endif }; /* -------- globals. */ @@ -102,7 +109,7 @@ boolean configure_key_setup( ShowWindow(dialog); /* Setup the globals.. */ - GetKeys(&keyboard_setup_globals.old_key_map); + GetKeys(keyboard_setup_globals.old_key_map); keyboard_setup_globals.keycodes= keycodes; keyboard_setup_globals.current_key_setup= current_key_set; @@ -144,7 +151,7 @@ boolean configure_key_setup( { data_is_bad = TRUE; SelIText(dialog, location_of_duplicate + FIRST_KEY_ITEM, 0, SHORT_MAX); - ParamText(getpstr(temporary, strKEYCODES_TO_ASCII, keycodes[location_of_duplicate]), "", "", ""); + ParamText((StringPtr)getpstr(temporary, strKEYCODES_TO_ASCII, keycodes[location_of_duplicate]), (StringPtr)"", (StringPtr)"", (StringPtr)""); Alert(alrtDUPLICATE_KEY, NULL); } else @@ -185,9 +192,85 @@ static pascal Boolean key_setup_filter_proc( switch(event->what) { case nullEvent: +#if 0 +#ifdef SUPPORT_INPUT_SPROCKET + { + ISpElementListReference globalList = nil; + OSStatus theStatus = noErr; + ISpElementEvent theEvent; + Boolean wasEvent; + + theStatus = ISpGetGlobalElementList(&globalList); + assert(theStatus == noErr); + + // get event may return an error if there was a > 4 byte data, we ignore that data, so no error checking + // kinda a hack + ISpElementList_GetNextEvent(globalList, sizeof(ISpElementEvent), &theEvent, &wasEvent); + + if (wasEvent) + { + ISpElementInfo theInfo; + ControlHandle control; + Handle item_handle; + Rect item_box; + short item_type; + Boolean setText = false; + UInt32 enoughAxis = ((kISpAxisMaximum - kISpAxisMiddle) * 0.9) + kISpAxisMiddle; + static ISpElementReference bogusAxis = nil; + + current_edit_field= ((DialogRecord *) dialog)->editField + 1; + + ISpElement_GetInfo(theEvent.element, &theInfo); + + if (bogusAxis != nil) + { + // do something sometime to clear the bogus axis again if it is + // far enough back down... + } + + if ((theInfo.theKind == kISpElementKind_Button) && (theEvent.data == kISpButtonDown)) + { + // ok, this was a button stuff it into our structure + // theEvent.element was what was hit + setText = true; + } + else if ((theInfo.theKind == kISpElementKind_DPad) && (theEvent.data != kISpPadIdle)) + { + // set this one to activate if it is also == theEvent.data + setText = true; + } + else if ((theInfo.theAxis == kISpElementKind_Axis) && (theEvent.data > (enoughAxis)) && (bogusAxis != theEvent.element)) + { + setText = true; + } + else + { + setText = false; + + // handle axis and other stuff later + GetDItem(dialog, iKEY_LAYOUT_POPUP, &item_type, (Handle *) &control, &item_box); + SetCtlValue(control, _custom_keyboard_item+1); + } + + if (setText) + { + GetDItem(dialog, current_edit_field, &item_type, &item_handle, &item_box); + SetIText(item_handle, theInfo.theString); + + GetDItem(dialog, iKEY_LAYOUT_POPUP, &item_type, (Handle *) &control, &item_box); + SetCtlValue(control, _custom_keyboard_item+1); + + *item_hit = current_edit_field < LAST_KEY_ITEM ? current_edit_field + 1 : FIRST_KEY_ITEM; + SelIText(dialog, *item_hit, 0, SHORT_MAX); + } + } + } + break; +#endif +#endif case keyDown: case autoKey: - GetKeys(&key_map); + GetKeys(key_map); if (memcmp(key_map, keyboard_setup_globals.old_key_map, sizeof(KeyMap))) // the user has hit a new key { current_edit_field= ((DialogRecord *) dialog)->editField + 1; @@ -285,7 +368,7 @@ static void fill_in_key_name( csprintf(temporary, "which = %d, keycodes[which] = %d", which, keycodes[which])); getpstr(temporary, strKEYCODES_TO_ASCII, keycodes[which]); GetDItem(dialog, which + FIRST_KEY_ITEM, &item_type, &item_handle, &item_box); - SetIText(item_handle, temporary); + SetIText(item_handle, (StringPtr)temporary); } static short find_key_hit( @@ -355,6 +438,9 @@ static short find_key_hit( case kcF7: case kcF8: case kcF9: + case kcF10: + case kcF11: + case kcF12: error_message= keyIsUsedAlready; break; @@ -429,6 +515,6 @@ static boolean is_pressed( { KeyMap key_map; - GetKeys(&key_map); + GetKeys(key_map); return ((((byte*)key_map)[key_code>>3] >> (key_code & 7)) & 1); } diff --git a/marathon2/lightsource.c b/marathon2/lightsource.c index 7e89c41..38d7ab8 100644 --- a/marathon2/lightsource.c +++ b/marathon2/lightsource.c @@ -13,7 +13,7 @@ Monday, July 10, 1995 5:20:26 PM (Jason) stateless (six phase) lights. */ -#include +#include "cseries.h" #include "map.h" #include "lightsource.h" diff --git a/marathon2/low_level_textures.c b/marathon2/low_level_textures.c index 0acf54a..2624372 100644 --- a/marathon2/low_level_textures.c +++ b/marathon2/low_level_textures.c @@ -51,6 +51,15 @@ BIT_DEPTH==8 and BIT_DEPTH==16 #define LANDSCAPE_HORIZONTAL_POLYGON_LINES _landscape_horizontal_polygon_lines8 #endif +#if (BIT_DEPTH==8) +typedef struct { + unsigned int b0:8; + unsigned int b1:8; + unsigned int b2:8; + unsigned int b3:8; +} vectorized_long; +#endif + #if !defined(EXTERNAL) || BIT_DEPTH==32 void TEXTURE_HORIZONTAL_POLYGON_LINES( struct bitmap_definition *texture, @@ -68,7 +77,7 @@ void TEXTURE_HORIZONTAL_POLYGON_LINES( { short x0= *x0_table++, x1= *x1_table++; - register PEL *shading_table= data->shading_table; + register PEL *shading_table= (PEL *)data->shading_table; register PEL *write= (PEL *) screen->row_addresses[y0] + x0; register pixel8 *base_address= texture->row_addresses[0]; register unsigned long source_x= data->source_x; @@ -77,13 +86,50 @@ void TEXTURE_HORIZONTAL_POLYGON_LINES( register unsigned long source_dy= data->source_dy; register short count= x1-x0; +#if (BIT_DEPTH==8) +#define PIXEL_LOOKUP (((source_y>>(HORIZONTAL_HEIGHT_DOWNSHIFT-7))&(0x7f<<7))+(source_x>>HORIZONTAL_WIDTH_DOWNSHIFT)) + while (((unsigned int) write)&3) + { + *write++= shading_table[base_address[PIXEL_LOOKUP]]; + source_x+= source_dx, source_y+= source_dy; + count--; + } + + if (count>=4) + { + register short inner_count= count>>2; + + while ((inner_count-= 1)>=0) + { + register unsigned long temp; + + temp= (shading_table[base_address[PIXEL_LOOKUP]])<<24; + source_x+= source_dx, source_y+= source_dy; + temp|= (shading_table[base_address[PIXEL_LOOKUP]]&0xFF)<<16; + source_x+= source_dx, source_y+= source_dy; + temp|= (shading_table[base_address[PIXEL_LOOKUP]]&0xFF)<<8; + source_x+= source_dx, source_y+= source_dy; + temp|= (shading_table[base_address[PIXEL_LOOKUP]]&0xFF); + source_x+= source_dx, source_y+= source_dy; + *((unsigned long *) write)++= temp; + } + } + + while (count&3) + { + *write++= shading_table[base_address[PIXEL_LOOKUP]]; + source_x+= source_dx, source_y+= source_dy; + count--; + } +#undef PIXEL_LOOKUP +#else while ((count-= 1)>=0) { *write++= shading_table[base_address[((source_y>>(HORIZONTAL_HEIGHT_DOWNSHIFT-7))&(0x7f<<7))+(source_x>>HORIZONTAL_WIDTH_DOWNSHIFT)]]; // *write++= shading_table[source_y>>HORIZONTAL_HEIGHT_DOWNSHIFT][source_x>>HORIZONTAL_WIDTH_DOWNSHIFT]]; source_x+= source_dx, source_y+= source_dy; } - +#endif data+= 1; y0+= 1; } @@ -104,7 +150,7 @@ void LANDSCAPE_HORIZONTAL_POLYGON_LINES( short *x1_table, short line_count) { - register short landscape_texture_width_downshift= texture->height==1024 ? 32-10 : 32-9; + register int landscape_texture_width_downshift= texture->height==1024 ? 32-10 : 32-9; #pragma unused (view) @@ -112,19 +158,55 @@ void LANDSCAPE_HORIZONTAL_POLYGON_LINES( { short x0= *x0_table++, x1= *x1_table++; - register PEL *shading_table= data->shading_table; + register PEL *shading_table= (PEL *)data->shading_table; register PEL *write= (PEL *) screen->row_addresses[y0] + x0; register pixel8 *read= texture->row_addresses[data->source_y]; register unsigned long source_x= data->source_x; register unsigned long source_dx= data->source_dx; - register short count= x1-x0; + register int count= x1-x0; +#if (BIT_DEPTH==8) +#define PIXEL_LOOKUP (source_x>>landscape_texture_width_downshift) + while ((((unsigned int) write)&3) && ((count-= 1)>=0)) + { + *write++= shading_table[read[PIXEL_LOOKUP]]; + source_x+= source_dx; + } + + if (count>=4) + { + register short inner_count= count>>2; + + while ((inner_count-= 1)>=0) + { + register unsigned long temp=0; + + temp= (shading_table[read[PIXEL_LOOKUP]])<<24; + source_x+= source_dx; + temp|= (shading_table[read[PIXEL_LOOKUP]])<<16; + source_x+= source_dx; + temp|= (shading_table[read[PIXEL_LOOKUP]])<<8; + source_x+= source_dx; + temp|= (shading_table[read[PIXEL_LOOKUP]]); + source_x+= source_dx; + *((unsigned long *) write)++= temp; + } + } + + while ((count&3) && ((count-= 1)>=0)) + { + *write++= shading_table[read[PIXEL_LOOKUP]]; + source_x+= source_dx; + } +#undef PIXEL_LOOKUP +#else while ((count-= 1)>=0) { *write++= shading_table[read[source_x>>landscape_texture_width_downshift]]; source_x+= source_dx; } - +#endif + data+= 1; y0+= 1; } @@ -133,7 +215,8 @@ void LANDSCAPE_HORIZONTAL_POLYGON_LINES( } #if !defined(EXTERNAL) || BIT_DEPTH==32 -static void TEXTURE_VERTICAL_POLYGON_LINES( +//#define downshift 25 +void TEXTURE_VERTICAL_POLYGON_LINES( struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, @@ -160,7 +243,7 @@ static void TEXTURE_VERTICAL_POLYGON_LINES( PEL *write, *shading_table; pixel8 *read; - shading_table= line->shading_table; + shading_table= (PEL *)line->shading_table; read= line->texture; write= (PEL *)screen->row_addresses[y0] + x; @@ -180,19 +263,19 @@ static void TEXTURE_VERTICAL_POLYGON_LINES( { unsigned long texture_y0= line[0].texture_y, texture_dy0= line[0].texture_dy; pixel8 *read0= line[0].texture; - PEL *shading_table0= line[0].shading_table; + PEL *shading_table0= (PEL *)line[0].shading_table; unsigned long texture_y1= line[1].texture_y, texture_dy1= line[1].texture_dy; pixel8 *read1= line[1].texture; - PEL *shading_table1= line[1].shading_table; + PEL *shading_table1= (PEL *)line[1].shading_table; unsigned long texture_y2= line[2].texture_y, texture_dy2= line[2].texture_dy; pixel8 *read2= line[2].texture; - PEL *shading_table2= line[2].shading_table; + PEL *shading_table2= (PEL *)line[2].shading_table; unsigned long texture_y3= line[3].texture_y, texture_dy3= line[3].texture_dy; pixel8 *read3= line[3].texture; - PEL *shading_table3= line[3].shading_table; + PEL *shading_table3= (PEL *)line[3].shading_table; PEL *write; @@ -244,6 +327,99 @@ static void TEXTURE_VERTICAL_POLYGON_LINES( } } +#if (BIT_DEPTH==8) + /* parallel map (x4) */ + { + int dy0= y1_table[0] - ymax; + int dy1= y1_table[1] - ymax; + int dy2= y1_table[2] - ymax; + int dy3= y1_table[3] - ymax; + + count= MIN(dy0, dy1), count= MIN(count, dy2), count= MIN(count, dy3); + ymax+= count; + + { + vectorized_long temp; + unsigned long *long_write= (unsigned long *)write; + int old_t3= texture_y3>>downshift; + int old_t2= texture_y2>>downshift; + int old_t1= texture_y1>>downshift; + int old_t0= texture_y0>>downshift; + + temp.b0= shading_table3[read3[old_t3]]; + temp.b1= shading_table2[read2[old_t2]]; + temp.b2= shading_table1[read1[old_t1]]; + temp.b3= shading_table0[read0[old_t0]]; + downshift= 25; + for (; count>0; --count) + { + if ((texture_y3>>downshift) != old_t3) + { + old_t3= texture_y3>>downshift; + temp.b0= shading_table3[read3[old_t3]]; + } + texture_y3+= texture_dy3; + + if ((texture_y2>>downshift) != old_t2) + { + old_t2= texture_y2>>downshift; + temp.b1= shading_table2[read2[old_t2]]; + } + texture_y2+= texture_dy2; + + if ((texture_y1>>downshift) != old_t1) + { + old_t1= texture_y1>>downshift; + temp.b2= shading_table1[read1[old_t1]]; + } + texture_y1+= texture_dy1; + + if ((texture_y0>>downshift) != old_t0) + { + old_t0= texture_y0>>downshift; + temp.b3= shading_table0[read0[old_t0]]; + } + texture_y0+= texture_dy0; + + (*(vectorized_long *) write)= temp; + (byte *)write+= bytes_per_row; + } + } + } +#elif (BIT_DEPTH==16) + /* parallel map (x4) */ + { + int dy0= y1_table[0] - ymax; + int dy1= y1_table[1] - ymax; + int dy2= y1_table[2] - ymax; + int dy3= y1_table[3] - ymax; + unsigned long temp; + unsigned long *long_write= (unsigned long *)write; + + count= MIN(dy0, dy1), count= MIN(count, dy2), count= MIN(count, dy3); + ymax+= count; + + for (; count>0; --count) + { + temp= shading_table1[read1[texture_y1>>downshift]]; + texture_y1+= texture_dy1; + + temp|= (shading_table0[read0[texture_y0>>downshift]])<<16; + texture_y0+= texture_dy0; + + ((unsigned long *) write)[0]= temp; + + temp= shading_table3[read3[texture_y3>>downshift]]; + texture_y3+= texture_dy3; + + temp|= (shading_table2[read2[texture_y2>>downshift]])<<16; + texture_y2+= texture_dy2; + + ((unsigned long *) write)[1]= temp; + (byte *)write+= bytes_per_row; + } + } +#else /* parallel map (x4) */ { int dy0= y1_table[0] - ymax; @@ -271,6 +447,7 @@ static void TEXTURE_VERTICAL_POLYGON_LINES( (byte *)write+= bytes_per_row; } } +#endif /* desync */ { @@ -310,10 +487,11 @@ static void TEXTURE_VERTICAL_POLYGON_LINES( return; } +//#undef downshift #endif #if !defined(EXTERNAL) || BIT_DEPTH==32 -static void TRANSPARENT_TEXTURE_VERTICAL_POLYGON_LINES( +void TRANSPARENT_TEXTURE_VERTICAL_POLYGON_LINES( struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, @@ -341,7 +519,7 @@ static void TRANSPARENT_TEXTURE_VERTICAL_POLYGON_LINES( PEL *write, *shading_table; pixel8 *read; - shading_table= line->shading_table; + shading_table= (PEL *)line->shading_table; read= line->texture; write= (PEL *)screen->row_addresses[y0] + x; @@ -362,19 +540,19 @@ static void TRANSPARENT_TEXTURE_VERTICAL_POLYGON_LINES( { unsigned long texture_y0= line[0].texture_y, texture_dy0= line[0].texture_dy; pixel8 *read0= line[0].texture; - PEL *shading_table0= line[0].shading_table; + PEL *shading_table0= (PEL *)line[0].shading_table; unsigned long texture_y1= line[1].texture_y, texture_dy1= line[1].texture_dy; pixel8 *read1= line[1].texture; - PEL *shading_table1= line[1].shading_table; + PEL *shading_table1= (PEL *)line[1].shading_table; unsigned long texture_y2= line[2].texture_y, texture_dy2= line[2].texture_dy; pixel8 *read2= line[2].texture; - PEL *shading_table2= line[2].shading_table; + PEL *shading_table2= (PEL *)line[2].shading_table; unsigned long texture_y3= line[3].texture_y, texture_dy3= line[3].texture_dy; pixel8 *read3= line[3].texture; - PEL *shading_table3= line[3].shading_table; + PEL *shading_table3= (PEL *)line[3].shading_table; PEL *write; @@ -502,7 +680,7 @@ static void TRANSPARENT_TEXTURE_VERTICAL_POLYGON_LINES( } #endif -static void TINT_VERTICAL_POLYGON_LINES( +void TINT_VERTICAL_POLYGON_LINES( struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, @@ -529,8 +707,6 @@ static void TINT_VERTICAL_POLYGON_LINES( register struct tint_table32 *tint_tables= (struct tint_table32 *)line->shading_table + (tint_table_index<<3); #endif - #pragma unused (texture,view) - assert(tint_table_index>=0 && tint_table_index=0) @@ -573,7 +749,7 @@ static void TINT_VERTICAL_POLYGON_LINES( return; } -static void RANDOMIZE_VERTICAL_POLYGON_LINES( +void RANDOMIZE_VERTICAL_POLYGON_LINES( struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, @@ -589,8 +765,6 @@ static void RANDOMIZE_VERTICAL_POLYGON_LINES( register word seed= texture_random_seed; register word drop_less_than= transfer_data; - #pragma unused (texture,view) - while ((line_count-= 1)>=0) { short y0= *y0_table++, y1= *y1_table++; diff --git a/marathon2/macintosh_input.h b/marathon2/macintosh_input.h new file mode 100644 index 0000000..930acca --- /dev/null +++ b/marathon2/macintosh_input.h @@ -0,0 +1,77 @@ + +#ifdef SUPPORT_INPUT_SPROCKET + +enum +{ + //input sprocket needs that are flags only + + _input_sprocket_left_trigger, // # 0 + _input_sprocket_right_trigger, // # 1 + _input_sprocket_moving_forward, // # 2 + _input_sprocket_moving_backward, // # 3 + + _input_sprocket_turning_left, // # 4 + _input_sprocket_turning_right, // # 5 + _input_sprocket_yaw, // # 6 horizontal axis + _input_sprocket_yaw_delta, // # 7 + + _input_sprocket_look_down, // # 8 + _input_sprocket_look_up, // # 9 + _input_sprocket_pitch, // # 10 vertical axis + _input_sprocket_pitch_delta, // # 11 + + _input_sprocket_sidestep_left, // # 12 + _input_sprocket_sidestep_right, // # 13 + _input_sprocket_action_trigger, // # 14 + + _input_sprocket_previous_weapon, // # 15 + _input_sprocket_next_weapon, // # 16 + _input_sprocket_run_dont_walk, // # 17 + _input_sprocket_sidestep_dont_turn, // # 18 + _input_sprocket_look_dont_turn, // # 19 + + _input_sprocket_looking_center, // # 20 + _input_sprocket_looking_left, // # 21 glance left + _input_sprocket_looking_right, // # 22 glance right + _input_sprocket_toggle_map, // # 23 + _input_sprocket_microphone_button, // # 24 + + _input_sprocket_quit, // # 25 + + // utility keys here and below + + _input_sprocket_volume_up, // # 26 + _input_sprocket_volume_down, + _input_sprocket_change_view, + + _input_sprocket_zoom_map_in, // # 29 + _input_sprocket_zoom_map_out, + _input_sprocket_scroll_back_decrement_replay, + _input_sprocket_scroll_forward_increment_replay, + + _input_sprocket_full_screen, // f1 + _input_sprocket_100_percent, // f2 + + _input_sprocket_75_percent, // f3 + _input_sprocket_50_percent, // f4 + _input_sprocket_low_res, // f5 +#ifdef ALEX_DISABLED + _input_sprocket_high_res, // f6 + _input_sprocket_texture_floor_toggle, // f7 + + _input_sprocket_texture_ceiling_toggle, // f8 +#endif + _input_sprocket_gamma_minus, // f11 + _input_sprocket_gamma_plus, // f12 + + _input_sprocket_show_fps, // # 30 + +#ifdef ALEX_DISABLED + _input_sprocket_toggle_background_tasks, +#endif + NUMBER_OF_INPUT_SPROCKET_NEEDS, +}; + +extern int input_sprocket_needs_to_flags[]; + +#endif \ No newline at end of file diff --git a/marathon2/makefile b/marathon2/makefile index 9dc574d..cb771f3 100644 --- a/marathon2/makefile +++ b/marathon2/makefile @@ -17,7 +17,7 @@ # -------------------------------------------------------------------------------------- # creator type -Creator= 52.4 +Creator= '26.∞' # every source file should depend on {UbiqDependencies} UbiqDependencies= makefile buildprogram @@ -40,10 +40,10 @@ Source= : Environment68k= -d env68k -Standard68kLibraries= "{Libraries}Runtime.o" "{Libraries}Interface.o" "{CLibraries}StdCLib.o" ∂ - "{CLibraries}CSANELib.o" "{CLibraries}Math.o" -Standard68kLibraries881= "{CLibraries}CLib881.o" "{Libraries}Runtime.o" "{Libraries}Interface.o" ∂ - "{CLibraries}StdCLib.o" "{CLibraries}CSANELib881.o" "{CLibraries}Math881.o" +Standard68kLibraries= "{Libraries}MacRuntime.o" "{Libraries}Interface.o" "{CLibraries}StdCLib.o" ∂ + "{CLibraries}CSANELib.o" "{Libraries}IntEnv.o" "{CLibraries}Math.o" "{Libraries}MathLib.o" +Standard68kLibraries881= "{CLibraries}CLib881.o" "{Libraries}MacRuntime.o" "{Libraries}Interface.o" ∂ + "{CLibraries}StdCLib.o" "{CLibraries}CSANELib881.o" "{Libraries}IntEnv.o" "{CLibraries}Math881.o" "{Libraries}MathLib881.o" COptions881= -i "{CSeriesInterfaces}" {VersionCOptions} -opt full -b2 -r -mc68020 -k "{CSeriesLibraries}" -mc68881 -elems881 COptions= -i "{CSeriesInterfaces}" {VersionCOptions} -opt full -b2 -r -mc68020 -k "{CSeriesLibraries}" @@ -72,20 +72,30 @@ AOptions= -i "{CSeriesInterfaces}" -case object {VersionAsmOptions} EnvironmentPPC= -d envppc -StandardPPCLibraries= "{PPCLibraries}InterfaceLib.xcoff" "{PPCLibraries}MathLib.xcoff" ∂ - "{PPCLibraries}PPCCRuntime.o" "{PPCLibraries}StdCLib.xcoff" "{PPCLibraries}StdCRuntime.o" ∂ - "{PPCLibraries}QuickTimeLib.xcoff" +StandardPPCLibraries= "{SharedLibraries}InterfaceLib" "{SharedLibraries}MathLib" ∂ + "{PPCLibraries}PPCCRuntime.o" "{SharedLibraries}StdCLib" "{PPCLibraries}StdCRuntime.o" ∂ + "{SharedLibraries}QuickTimeLib" "{CSeriesLibraries}DisplayLib" {SprocketLibraries} -PPCFinalLinkOptions= -weakLib QuickTimeLib -libRename InterfaceLib.xcoff=InterfaceLib -libRename StdCLib.xcoff=StdCLib -libRename MathLib.xcoff=MathLib -libRename QuickTimeLib.xcoff=QuickTimeLib -PPCCOptions= -i "{CSeriesInterfaces}" {VersionPPCCOptions} -align mac68k -appleext on -dialect ansic -w conformance +PPCFinalLinkOptions= -weakLib QuickTimeLib {SprocketPPCFinalLinkOptions} +PPCCOptions= -i "{CSeriesInterfaces}" {VersionPPCCOptions} -align mac68k -typecheck relaxed # -------------------------------------------------------------------------------------- # PPC DEFAULT DEPENDENCY RULES # -------------------------------------------------------------------------------------- +# ••• Special case for MrC 2.0d5c2 bug +#{ObjPPC}keyboard_dialog.ppc.o ƒ keyboard_dialog.c +# MrC keyboard_dialog.c {PPCCOptions} -o "{ObjPPC}"keyboard_dialog.ppc.o -opt local + +#{ObjPPC}game_sound.ppc.o ƒ game_sound.c +# MrC game_sound.c {PPCCOptions} -o "{ObjPPC}"game_sound.ppc.o -opt local + +#{ObjPPC}sound_macintosh.ppc.o ƒ sound_macintosh.c +# MrC sound_macintosh.c {PPCCOptions} -o "{ObjPPC}"sound_macintosh.ppc.o -opt local + # default dependency rule for .ppc.o files .ppc.o ƒ .c - PPCC {Default}.c {PPCCOptions} -o "{ObjPPC}"{Default}.ppc.o + MrC {Default}.c {PPCCOptions} -o "{ObjPPC}"{Default}.ppc.o # default dependency rule for .s.o files .s.o ƒ .s @@ -125,7 +135,7 @@ PPCCOptions= -i "{CSeriesInterfaces}" {VersionPPCCOptions} -align mac68k -applee {Obj68k}files_macintosh.c.o ƒ portable_files.h game_errors.h tags.h {UbiqDependencies} #map library dependencies -{Obj68k}map.c.o ƒ map.h world.h interface.h monsters.h projectiles.h effects.h player.h platforms.h sound.h lightsource.h media.h {UbiqDependencies} +{Obj68k}map.c.o ƒ map.h world.h interface.h monsters.h projectiles.h effects.h player.h platforms.h game_sound.h lightsource.h media.h {UbiqDependencies} {Obj68k}map_constructors.c.o ƒ map.h world.h {UbiqDependencies} {Obj68k}map_accessors.c.o ƒ map.h world.h platforms.h {UbiqDependencies} {Obj68k}game_wad.c.o ƒ map.h world.h monsters.h network.h projectiles.h effects.h player.h ∂ @@ -135,11 +145,11 @@ PPCCOptions= -i "{CSeriesInterfaces}" {VersionPPCCOptions} -align mac68k -applee {Obj68k}flood_map.c.o ƒ map.h world.h flood_map.h {UbiqDependencies} {Obj68k}lightsource.c.o ƒ map.h world.h lightsource.h {UbiqDependencies} {Obj68k}media.c.o ƒ map.h world.h media.h media_definitions.h lightsource.h {UbiqDependencies} -{Obj68k}platforms.c.o ƒ map.h world.h platforms.h platform_definitions.h lightsource.h sound.h {UbiqDependencies} +{Obj68k}platforms.c.o ƒ map.h world.h platforms.h platform_definitions.h lightsource.h game_sound.h {UbiqDependencies} {Obj68k}placement.c.o ƒ map.h monsters.h {UbiqDependencies} #shell library dependencies -{Obj68k}shell.c.o ƒ map.h world.h monsters.h player.h render.h shell.h interface.h sound.h ∂ +{Obj68k}shell.c.o ƒ map.h world.h monsters.h player.h render.h shell.h interface.h game_sound.h ∂ music.h fades.h tags.h network_sound.h mouse.h screen_drawing.h computer_interface.h ∂ game_wad.h game_window.h {UbiqDependencies} {Obj68k}shapes.c.o ƒ shell.h interface.h shapes_macintosh.c {UbiqDependencies} @@ -147,21 +157,21 @@ PPCCOptions= -i "{CSeriesInterfaces}" {VersionPPCCOptions} -align mac68k -applee {Obj68k}screen.a.o ƒ {UbiqDependencies} {ObjPPC}valkyrie.c.o ƒ valkyrie.h textures.h {UbiqDependencies} {Obj68k}vbl_macintosh.c.o ƒ interface.h map.h world.h shell.h player.h mouse.h key_definitions.h {UbiqDependencies} -{Obj68k}sound.c.o ƒ interface.h shell.h sound.h sound_definitions.h sound_macintosh.c {UbiqDependencies} +{Obj68k}game_sound.c.o ƒ interface.h shell.h game_sound.h sound_definitions.h sound_macintosh.c {UbiqDependencies} {Obj68k}preprocess_map_mac.c.o ƒ map.h world.h ":editor code:editor.h" interface.h shell.h game_wad.h ∂ overhead_map.h player.h game_window.h tags.h wad.h {UbiqDependencies} {Obj68k}screen_drawing.c.o ƒ interface.h map.h shell.h screen_drawing.h {UbiqDependencies} -{Obj68k}game_dialogs.c.o ƒ interface.h world.h shell.h music.h {UbiqDependencies} +{Obj68k}game_dialogs.c.o ƒ interface.h world.h shell.h music.h serial_numbers.c {UbiqDependencies} {Obj68k}game_window_macintosh.c.o ƒ map.h world.h interface.h player.h screen_drawing.h motion_sensor.h ∂ - sound.h items.h weapons.h game_window.h {UbiqDependencies} + game_sound.h items.h weapons.h game_window.h {UbiqDependencies} {Obj68k}interface_macintosh.c.o ƒ map.h macintosh_network.h shell.h interface.h player.h network_sound.h ∂ - screen_drawing.h sound.h fades.h game_window.h game_errors.h {UbiqDependencies} + screen_drawing.h game_sound.h fades.h game_window.h game_errors.h {UbiqDependencies} {Obj68k}mouse.c.o ƒ mouse.h world.h player.h map.h {UbiqDependencies} {Obj68k}computer_interface.c.o ƒ screen_drawing.h computer_interface.h interface.h shell.h map.h overhead_map.h {UbiqDependencies} {Obj68k}music.c.o ƒ music.h shell.h {UbiqDependencies} {Obj68k}keyboard_dialog.c.o ƒ interface.h {UbiqDependencies} {Obj68k}images.c.o ƒ images.h interface.h map.h {UbiqDependencies} -{Obj68k}preferences.c.o ƒ map.h world.h shell.h interface.h sound.h preferences.h ∂ +{Obj68k}preferences.c.o ƒ map.h world.h shell.h interface.h game_sound.h preferences.h ∂ wad.h wad_prefs.h tags.h {UbiqDependencies} #network library dependencies @@ -183,25 +193,25 @@ PPCCOptions= -i "{CSeriesInterfaces}" {VersionPPCCOptions} -align mac68k -applee {Obj68k}{Application}.c.o ƒ map.h world.h render.h interface.h flood_map.h effects.h monsters.h projectiles.h player.h ∂ scottish_textures.h textures.h monsters.h projectiles.h effects.h flood_map.h player.h ∂ network.h scenery.h platforms.h lightsource.h media.h music.h fades.h items.h weapons.h game_window.h {UbiqDependencies} -{Obj68k}player.c.o ƒ map.h world.h player.h monsters.h interface.h sound.h fades.h media.h items.h ∂ +{Obj68k}player.c.o ƒ map.h world.h player.h monsters.h interface.h game_sound.h fades.h media.h items.h ∂ weapons.h game_window.h {UbiqDependencies} {Obj68k}pathfinding.c.o ƒ map.h world.h flood_map.h {UbiqDependencies} -{Obj68k}monsters.c.o ƒ monster_definitions.h render.h scottish_textures.h textures.h map.h world.h interface.h monsters.h projectiles.h effects.h player.h platforms.h sound.h {UbiqDependencies} +{Obj68k}monsters.c.o ƒ monster_definitions.h render.h scottish_textures.h textures.h map.h world.h interface.h monsters.h projectiles.h effects.h player.h platforms.h game_sound.h {UbiqDependencies} {Obj68k}scenery.c.o ƒ scenery_definitions.h scenery.h map.h world.h {UbiqDependencies} {Obj68k}projectiles.c.o ƒ projectile_definitions.h render.h scottish_textures.h textures.h map.h world.h interface.h monsters.h projectiles.h effects.h media.h {UbiqDependencies} {Obj68k}effects.c.o ƒ effect_definitions.h render.h scottish_textures.h textures.h map.h world.h interface.h effects.h {UbiqDependencies} -{Obj68k}devices.c.o ƒ map.h world.h monsters.h interface.h player.h platforms.h sound.h ∂ +{Obj68k}devices.c.o ƒ map.h world.h monsters.h interface.h player.h platforms.h game_sound.h ∂ computer_interface.h music.h lightsource.h game_window.h {UbiqDependencies} -{Obj68k}weapons.c.o ƒ map.h world.h projectiles.h player.h weapons.h sound.h interface.h ∂ +{Obj68k}weapons.c.o ƒ map.h world.h projectiles.h player.h weapons.h game_sound.h interface.h ∂ items.h monsters.h game_window.h weapon_definitions.h {UbiqDependencies} -{Obj68k}items.c.o ƒ map.h world.h interface.h monsters.h player.h sound.h platforms.h ∂ +{Obj68k}items.c.o ƒ map.h world.h interface.h monsters.h player.h game_sound.h platforms.h ∂ fades.h items.h flood_map.h effects.h game_window.h item_definitions.h weapons.h {UbiqDependencies} {Obj68k}physics.c.o ƒ physics_models.h render.h scottish_textures.h textures.h map.h world.h monsters.h player.h {UbiqDependencies} {Obj68k}vbl.c.o ƒ interface.h map.h world.h shell.h player.h mouse.h key_definitions.h {UbiqDependencies} {Obj68k}interface.c.o ƒ map.h macintosh_network.h shell.h interface.h player.h network_sound.h ∂ - screen_drawing.h sound.h fades.h game_window.h game_errors.h {UbiqDependencies} + screen_drawing.h game_sound.h fades.h game_window.h game_errors.h {UbiqDependencies} {Obj68k}game_window.c.o ƒ map.h world.h interface.h player.h screen_drawing.h motion_sensor.h ∂ - sound.h items.h weapons.h game_window.h {UbiqDependencies} + game_sound.h items.h weapons.h game_window.h {UbiqDependencies} {Obj68k}fades.c.o ƒ interface.h shell.h {UbiqDependencies} {Obj68k}import_definitions.c.o ƒ wad.h extensions.h shell.h {UbiqDependencies} @@ -218,7 +228,7 @@ MapLibObjects68k= {Obj68k}map.c.o {Obj68k}lightsource.c.o {Obj68k}flood_map.c.o {Obj68k}platforms.c.o {Obj68k}map_accessors.c.o {Obj68k}map_constructors.c.o {Obj68k}game_wad.c.o {Obj68k}wad.c.o ∂ {Obj68k}placement.c.o ShellLibObjects68k= {Obj68k}shell.c.o {Obj68k}screen.c.o {Obj68k}valkyrie.c.o {Obj68k}screen.a.o ∂ - {Obj68k}shapes.c.o {Obj68k}sound.c.o {Obj68k}preprocess_map_mac.c.o {Obj68k}game_dialogs.c.o ∂ + {Obj68k}shapes.c.o {Obj68k}game_sound.c.o {Obj68k}preprocess_map_mac.c.o {Obj68k}game_dialogs.c.o ∂ {Obj68k}game_window_macintosh.c.o {Obj68k}interface_macintosh.c.o {Obj68k}vbl_macintosh.c.o ∂ {Obj68k}screen_drawing.c.o {Obj68k}mouse.c.o {Obj68k}computer_interface.c.o ∂ {Obj68k}music.c.o {Obj68k}preferences.c.o {Obj68k}keyboard_dialog.c.o {Obj68k}images.c.o @@ -260,15 +270,15 @@ LinkDependencies68k= {ApplicationLibraries68k} {Targ68k} ƒƒ {RezDependencies68k} Rez {Application}.r {Environment68k} {VerRezOptions} -append -o {Targ68k} {Targ68k} ƒƒ {LinkDependencies68k} - Link {Link68kOptions} -w -t APPL -c "{Creator}" {ApplicationLibraries68k} {Standard68kLibraries} -o {Targ68k} > link.out + Link {Link68kOptions} -w -t APPL -c {Creator} {ApplicationLibraries68k} {Standard68kLibraries} -o {Targ68k} > link.out {Targ68k} ƒƒ {Obj68k}network_listener.a.o Link -rt SOCK=128 -m TheSocketListener -sg "socket_listener" ∂ "{Obj68k}"network_listener.a.o -o {Targ68k} SetFile -a iB {Targ68k} -{Application} ƒƒ {RezDependencies68k} {LinkDependencies68k} - noresnames {Application} -{Application}.gamma ƒƒ {RezDependencies68k} {LinkDependencies68k} - noresnames {Application}.gamma +#{Application} ƒƒ {RezDependencies68k} {LinkDependencies68k} +# noresnames {Application} +#{Application}.gamma ƒƒ {RezDependencies68k} {LinkDependencies68k} +# noresnames {Application}.gamma # -------------------------------------------------------------------------------------- # 68K DEMO APPLICATION DEPENDENCIES AND BUILD COMMANDS @@ -277,13 +287,13 @@ LinkDependencies68k= {ApplicationLibraries68k} {DemoTarg68k} ƒƒ {RezDependencies68k} Rez "{Application}.r" {Environment68k} {VerRezOptions} -append -o {DemoTarg68k} {DemoTarg68k} ƒƒ {LinkDependencies68k} - Link -w -t APPL -c "{Creator}" {ApplicationLibraries68k} {Standard68kLibraries} -o {DemoTarg68k} + Link -w -t APPL -c {Creator} {ApplicationLibraries68k} {Standard68kLibraries} -o {DemoTarg68k} {DemoTarg68k} ƒƒ {Obj68k}network_listener.a.o Link -rt SOCK=128 -m TheSocketListener -sg "socket_listener" ∂ "{Obj68k}"network_listener.a.o -o {DemoTarg68k} SetFile -a iB {DemoTarg68k} -{Application}.demo ƒƒ {RezDependencies68k} {LinkDependencies68k} - noresnames {Application}.demo +#{Application}.demo ƒƒ {RezDependencies68k} {LinkDependencies68k} +# noresnames {Application}.demo # -------------------------------------------------------------------------------------- # PPC OBJECT DEPENDENCIES @@ -294,6 +304,7 @@ LinkDependencies68k= {ApplicationLibraries68k} {ObjPPC}world.ppc.o ƒ world.h {UbiqDependencies} {ObjPPC}textures.ppc.o ƒ textures.h {UbiqDependencies} {ObjPPC}scottish_textures.ppc.o ƒ render.h scottish_textures.h textures.h world.h {UbiqDependencies} +{ObjPPC}scottish_textures.s.o ƒ {UbiqDependencies} {ObjPPC}motion_sensor.ppc.o ƒ render.h scottish_textures.h textures.h map.h world.h interface.h motion_sensor.h monsters.h screen_drawing.h {UbiqDependencies} {ObjPPC}overhead_map.ppc.o ƒ overhead_map.h map.h world.h player.h overhead_map_macintosh.c {UbiqDependencies} @@ -308,7 +319,7 @@ LinkDependencies68k= {ApplicationLibraries68k} {ObjPPC}files_macintosh.ppc.o ƒ portable_files.h game_errors.h tags.h {UbiqDependencies} #map library dependencies -{ObjPPC}map.ppc.o ƒ map.h world.h interface.h monsters.h projectiles.h effects.h player.h platforms.h sound.h lightsource.h media.h {UbiqDependencies} +{ObjPPC}map.ppc.o ƒ map.h world.h interface.h monsters.h projectiles.h effects.h player.h platforms.h game_sound.h lightsource.h media.h {UbiqDependencies} {ObjPPC}map_constructors.ppc.o ƒ map.h world.h {UbiqDependencies} {ObjPPC}map_accessors.ppc.o ƒ map.h world.h platforms.h {UbiqDependencies} {ObjPPC}game_wad.ppc.o ƒ map.h world.h monsters.h network.h projectiles.h effects.h player.h ∂ @@ -317,34 +328,34 @@ LinkDependencies68k= {ApplicationLibraries68k} {ObjPPC}flood_map.ppc.o ƒ map.h world.h flood_map.h {UbiqDependencies} {ObjPPC}lightsource.ppc.o ƒ map.h world.h lightsource.h {UbiqDependencies} {ObjPPC}media.ppc.o ƒ map.h world.h media.h media_definitions.h lightsource.h {UbiqDependencies} -{ObjPPC}platforms.ppc.o ƒ map.h world.h platforms.h platform_definitions.h lightsource.h sound.h {UbiqDependencies} +{ObjPPC}platforms.ppc.o ƒ map.h world.h platforms.h platform_definitions.h lightsource.h game_sound.h {UbiqDependencies} {ObjPPC}placement.ppc.o ƒ map.h monsters.h {UbiqDependencies} #shell library dependencies -{ObjPPC}shell.ppc.o ƒ map.h world.h monsters.h player.h render.h shell.h interface.h sound.h ∂ +{ObjPPC}shell.ppc.o ƒ map.h world.h monsters.h player.h render.h shell.h interface.h game_sound.h ∂ music.h fades.h tags.h network_sound.h mouse.h screen_drawing.h computer_interface.h ∂ - game_wad.h game_window.h {UbiqDependencies} + game_wad.h game_window.h {UbiqDependencies} #macintosh_input.h input_sprocket_needs.h {ObjPPC}shapes.ppc.o ƒ shell.h interface.h shapes_macintosh.c {UbiqDependencies} {ObjPPC}screen.ppc.o ƒ interface.h map.h world.h render.h scottish_textures.h textures.h shell.h monsters.h overhead_map.h player.h valkyrie.h game_window.h {UbiqDependencies} {ObjPPC}quadruple.s.o ƒ {UbiqDependencies} {ObjPPC}valkyrie.ppc.o ƒ valkyrie.h textures.h {UbiqDependencies} -{ObjPPC}sound.ppc.o ƒ interface.h shell.h sound.h sound_definitions.h sound_macintosh.c {UbiqDependencies} +{ObjPPC}game_sound.ppc.o ƒ interface.h shell.h game_sound.h sound_definitions.h sound_macintosh.c {UbiqDependencies} {ObjPPC}preprocess_map_mac.ppc.o ƒ map.h world.h ":editor code:editor.h" interface.h shell.h game_wad.h ∂ overhead_map.h player.h game_window.h tags.h wad.h {UbiqDependencies} -{ObjPPC}game_dialogs.ppc.o ƒ interface.h world.h shell.h music.h {UbiqDependencies} +{ObjPPC}game_dialogs.ppc.o ƒ interface.h world.h shell.h music.h serial_numbers.c {UbiqDependencies} {ObjPPC}screen_drawing.ppc.o ƒ interface.h map.h shell.h screen_drawing.h {UbiqDependencies} {ObjPPC}game_window_macintosh.ppc.o ƒ map.h world.h interface.h player.h screen_drawing.h motion_sensor.h ∂ - sound.h items.h weapons.h game_window.h {UbiqDependencies} + game_sound.h items.h weapons.h game_window.h {UbiqDependencies} {ObjPPC}images.ppc.o ƒ images.h interface.h map.h {UbiqDependencies} {ObjPPC}mouse.ppc.o ƒ mouse.h world.h player.h map.h {UbiqDependencies} {ObjPPC}computer_interface.ppc.o ƒ screen_drawing.h computer_interface.h interface.h shell.h map.h overhead_map.h {UbiqDependencies} {ObjPPC}music.ppc.o ƒ music.h shell.h {UbiqDependencies} {ObjPPC}keyboard_dialog.ppc.o ƒ interface.h {UbiqDependencies} -{ObjPPC}preferences.ppc.o ƒ map.h world.h shell.h interface.h sound.h preferences.h ∂ +{ObjPPC}preferences.ppc.o ƒ map.h world.h shell.h interface.h game_sound.h preferences.h ∂ wad.h wad_prefs.h tags.h {UbiqDependencies} {ObjPPC}vbl_macintosh.ppc.o ƒ interface.h map.h world.h shell.h player.h mouse.h key_definitions.h {UbiqDependencies} {ObjPPC}interface_macintosh.ppc.o ƒ map.h macintosh_network.h shell.h interface.h player.h network_sound.h ∂ - screen_drawing.h sound.h fades.h game_window.h game_errors.h {UbiqDependencies} + screen_drawing.h game_sound.h fades.h game_window.h game_errors.h {UbiqDependencies} #network library dependencies {ObjPPC}network_games.ppc.o ƒ map.h items.h player.h monsters.h network_games.h {UbiqDependencies} @@ -365,25 +376,25 @@ LinkDependencies68k= {ApplicationLibraries68k} {ObjPPC}{Application}.ppc.o ƒ map.h world.h render.h interface.h flood_map.h effects.h monsters.h projectiles.h player.h ∂ scottish_textures.h textures.h monsters.h projectiles.h effects.h flood_map.h player.h ∂ network.h scenery.h platforms.h lightsource.h media.h music.h fades.h items.h weapons.h game_window.h {UbiqDependencies} -{ObjPPC}player.ppc.o ƒ map.h world.h player.h monsters.h interface.h sound.h fades.h media.h items.h ∂ +{ObjPPC}player.ppc.o ƒ map.h world.h player.h monsters.h interface.h game_sound.h fades.h media.h items.h ∂ weapons.h game_window.h {UbiqDependencies} {ObjPPC}pathfinding.ppc.o ƒ map.h world.h flood_map.h {UbiqDependencies} -{ObjPPC}monsters.ppc.o ƒ monster_definitions.h render.h scottish_textures.h textures.h map.h world.h interface.h monsters.h projectiles.h effects.h player.h platforms.h sound.h {UbiqDependencies} +{ObjPPC}monsters.ppc.o ƒ monster_definitions.h render.h scottish_textures.h textures.h map.h world.h interface.h monsters.h projectiles.h effects.h player.h platforms.h game_sound.h {UbiqDependencies} {ObjPPC}scenery.ppc.o ƒ scenery_definitions.h scenery.h map.h world.h {UbiqDependencies} {ObjPPC}projectiles.ppc.o ƒ projectile_definitions.h render.h scottish_textures.h textures.h map.h world.h interface.h monsters.h projectiles.h effects.h media.h {UbiqDependencies} {ObjPPC}effects.ppc.o ƒ effect_definitions.h render.h scottish_textures.h textures.h map.h world.h interface.h effects.h {UbiqDependencies} -{ObjPPC}devices.ppc.o ƒ map.h world.h monsters.h interface.h player.h platforms.h sound.h ∂ +{ObjPPC}devices.ppc.o ƒ map.h world.h monsters.h interface.h player.h platforms.h game_sound.h ∂ computer_interface.h music.h lightsource.h game_window.h {UbiqDependencies} -{ObjPPC}weapons.ppc.o ƒ map.h world.h projectiles.h player.h weapons.h sound.h interface.h ∂ +{ObjPPC}weapons.ppc.o ƒ map.h world.h projectiles.h player.h weapons.h game_sound.h interface.h ∂ items.h monsters.h game_window.h weapon_definitions.h {UbiqDependencies} -{ObjPPC}items.ppc.o ƒ map.h world.h interface.h monsters.h player.h sound.h platforms.h ∂ +{ObjPPC}items.ppc.o ƒ map.h world.h interface.h monsters.h player.h game_sound.h platforms.h ∂ fades.h items.h flood_map.h effects.h game_window.h item_definitions.h weapons.h {UbiqDependencies} {ObjPPC}physics.ppc.o ƒ physics_models.h render.h scottish_textures.h textures.h map.h world.h player.h {UbiqDependencies} {ObjPPC}vbl.ppc.o ƒ interface.h map.h world.h shell.h player.h mouse.h key_definitions.h {UbiqDependencies} {ObjPPC}interface.ppc.o ƒ map.h shell.h interface.h player.h ∂ - screen_drawing.h sound.h fades.h game_window.h game_errors.h {UbiqDependencies} + screen_drawing.h game_sound.h fades.h game_window.h game_errors.h {UbiqDependencies} {ObjPPC}game_window.ppc.o ƒ map.h world.h interface.h player.h screen_drawing.h motion_sensor.h ∂ - sound.h items.h weapons.h game_window.h {UbiqDependencies} + game_sound.h items.h weapons.h game_window.h {UbiqDependencies} {ObjPPC}fades.ppc.o ƒ interface.h shell.h {UbiqDependencies} {ObjPPC}import_definitions.ppc.o ƒ extensions.h wad.h {UbiqDependencies} @@ -392,7 +403,8 @@ LinkDependencies68k= {ApplicationLibraries68k} # -------------------------------------------------------------------------------------- RenderLibObjectsPPC= {ObjPPC}render.ppc.o {ObjPPC}world.ppc.o {ObjPPC}textures.ppc.o ∂ - {ObjPPC}scottish_textures.ppc.o {ObjPPC}overhead_map.ppc.o {ObjPPC}motion_sensor.ppc.o + {ObjPPC}scottish_textures.s.o {ObjPPC}overhead_map.ppc.o {ObjPPC}motion_sensor.ppc.o ∂ + {ObjPPC}scottish_textures.ppc.o WadLibObjectsPPC= {ObjPPC}wad.ppc.o {ObjPPC}wad_macintosh.ppc.o {ObjPPC}find_files.ppc.o {ObjPPC}crc.ppc.o ∂ {ObjPPC}wad_prefs.ppc.o {ObjPPC}wad_prefs_macintosh.ppc.o {ObjPPC}game_errors.ppc.o ∂ {ObjPPC}files_macintosh.ppc.o @@ -401,7 +413,7 @@ MapLibObjectsPPC= {ObjPPC}map.ppc.o {ObjPPC}lightsource.ppc.o {ObjPPC}flood_map. {ObjPPC}placement.ppc.o ShellLibObjectsPPC= {ObjPPC}shell.ppc.o {ObjPPC}screen.ppc.o {ObjPPC}quadruple.s.o ∂ {ObjPPC}valkyrie.ppc.o {ObjPPC}shapes.ppc.o ∂ - {ObjPPC}sound.ppc.o {ObjPPC}preprocess_map_mac.ppc.o {ObjPPC}game_dialogs.ppc.o ∂ + {ObjPPC}game_sound.ppc.o {ObjPPC}preprocess_map_mac.ppc.o {ObjPPC}game_dialogs.ppc.o ∂ {ObjPPC}game_window_macintosh.ppc.o {ObjPPC}interface_macintosh.ppc.o {ObjPPC}vbl_macintosh.ppc.o ∂ {ObjPPC}screen_drawing.ppc.o {ObjPPC}mouse.ppc.o {ObjPPC}computer_interface.ppc.o ∂ {ObjPPC}music.ppc.o {ObjPPC}preferences.ppc.o {ObjPPC}keyboard_dialog.ppc.o {ObjPPC}images.ppc.o @@ -443,19 +455,19 @@ LinkDependenciesPPC= {ApplicationLibrariesPPC} {TargPPC} ƒƒ {RezDependenciesPPC} Rez {Application}.r {EnvironmentPPC} {VerRezOptions} -append -o {TargPPC} {TargPPC} ƒƒ {LinkDependenciesPPC} - PPCLink {ApplicationLibrariesPPC} {StandardPPCLibraries} {SymbolsPPC} {PPCFinalLinkOptions} -o "{TargPPC}" - MergeFragment {CSeriesLibraries}DisplayLib.runtime "{TargPPC}" + PPCLink {ApplicationLibrariesPPC} {StandardPPCLibraries} {SymbolsPPC} {PPCFinalLinkOptions} -weakLib DisplayLib -o "{TargPPC}" +# MergeFragment {CSeriesLibraries}DisplayLib.runtime "{TargPPC}" # MakePef "{ObjPPC}"{TargPPC}.xcoff -o {TargPPC} {MakePefOptions} - SetFile -t APPL -c "{Creator}" -a iB {TargPPC} + SetFile -t APPL -c {Creator} -a iB {TargPPC} {TargPPC} ƒƒ {Obj68k}network_listener.a.o Link -rt SOCK=128 -m TheSocketListener -sg "socket_listener" ∂ "{Obj68k}"network_listener.a.o -o {TargPPC} {Application}.alpha.ppc ƒƒ {LinkDependenciesPPC} MakeSym -i ::cseries.lib {SymbolsPPC} -o "{TargPPC}.xSYM" "{ObjPPC}{TargPPC}.xcoff" -{Application}.ppc ƒƒ {RezDependenciesPPC} {LinkDependenciesPPC} - noresnames {Application}.ppc -{Application}.gamma.ppc ƒƒ {RezDependencies68k} {LinkDependencies68k} - noresnames {Application}.gamma.ppc +#{Application}.ppc ƒƒ {RezDependenciesPPC} {LinkDependenciesPPC} +# noresnames {Application}.ppc +#{Application}.gamma.ppc ƒƒ {RezDependencies68k} {LinkDependencies68k} +# noresnames {Application}.gamma.ppc # -------------------------------------------------------------------------------------- # PPC DEMO APPLICATION DEPENDENCIES AND BUILD COMMANDS @@ -464,17 +476,17 @@ LinkDependenciesPPC= {ApplicationLibrariesPPC} {DemoTargPPC} ƒƒ {RezDependenciesPPC} Rez {Application}.r {EnvironmentPPC} {VerRezOptions} -append -o {DemoTargPPC} {DemoTargPPC} ƒƒ {LinkDependenciesPPC} - PPCLink {ApplicationLibrariesPPC} {StandardPPCLibraries} {SymbolsPPC} {PPCFinalLinkOptions} -o "{DemoTargPPC}" - MergeFragment {CSeriesLibraries}DisplayLib.runtime "{DemoTargPPC}" + PPCLink {ApplicationLibrariesPPC} {StandardPPCLibraries} {SymbolsPPC} {PPCFinalLinkOptions} -weakLib DisplayLib -o "{DemoTargPPC}" +# MergeFragment {CSeriesLibraries}DisplayLib.runtime "{DemoTargPPC}" # MakePef "{ObjPPC}{DemoTargPPC}.xcoff" -o {DemoTargPPC} {MakePefOptions} - SetFile -t APPL -c "{Creator}" -a iB {DemoTargPPC} + SetFile -t APPL -c {Creator} -a iB {DemoTargPPC} {DemoTargPPC} ƒƒ {Obj68k}network_listener.a.o Link -rt SOCK=128 -m TheSocketListener -sg "socket_listener" ∂ "{Obj68k}"network_listener.a.o -o {DemoTargPPC} {Application}.demo.alpha.ppc ƒƒ {LinkDependenciesPPC} MakeSym -i ::cseries.lib {SymbolsPPC} -o {DemoTargPPC}.xSYM "{ObjPPC}{DemoTargPPC}.xcoff" -{Application}.demo.ppc ƒƒ {RezDependenciesPPC} {LinkDependenciesPPC} - noresnames {Application}.demo.ppc +#{Application}.demo.ppc ƒƒ {RezDependenciesPPC} {LinkDependenciesPPC} +# noresnames {Application}.demo.ppc # -------------------------------------------------------------------------------------- # FAT APPLICATION DEPENDENCIES AND BUILD COMMANDS diff --git a/marathon2/map.c b/marathon2/map.c index d6c2fd2..5aef13b 100644 --- a/marathon2/map.c +++ b/marathon2/map.c @@ -35,7 +35,7 @@ find_line_crossed leaving polygon could be sped up considerable by reversing the #include "platforms.h" #include "lightsource.h" #include "media.h" -#include "sound.h" +#include "game_sound.h" #include @@ -115,8 +115,6 @@ static struct map_memory_data map_structure_memory; static short _new_map_object(shape_descriptor shape, angle facing); -short _find_line_crossed_leaving_polygon(short polygon_index, world_point2d *p0, world_point2d *p1, boolean *last_line); - /* ---------- code */ void allocate_map_memory( @@ -1646,12 +1644,9 @@ boolean line_is_obstructed( do { - boolean last_line; - - line_index= _find_line_crossed_leaving_polygon(polygon_index, (world_point2d *)p1, (world_point2d *)p2, &last_line); + line_index= find_line_crossed_leaving_polygon(polygon_index, (world_point2d *)p1, (world_point2d *)p2); if (line_index!=NONE) { - if (last_line && polygon_index==polygon_index2) break; if (!LINE_IS_SOLID(get_line_data(line_index))) { /* transparent line, find adjacent polygon */ @@ -1662,12 +1657,6 @@ boolean line_is_obstructed( { obstructed= TRUE; /* non-transparent line */ } - if (last_line) - { - if (polygon_index==polygon_index2) break; - obstructed= TRUE; - break; - } } else { @@ -1675,7 +1664,26 @@ boolean line_is_obstructed( destination point is in; this probably means that the source is on a different level than the caller, but it could also easily mean that we’re dealing with weird boundary conditions of find_line_crossed_leaving_polygon() */ - if (polygon_index!=polygon_index2) obstructed= TRUE; + if (polygon_index!=polygon_index2) + { + struct polygon_data *polygon= get_polygon_data(polygon_index); + struct polygon_data *polygon2= get_polygon_data(polygon_index2); + short i, j; + + obstructed= TRUE; + for (i= 0; ivertex_count; ++i) + { + for (j= 0; jvertex_count; ++j) + { + if (polygon->endpoint_indexes[i]==polygon2->endpoint_indexes[j]) + { + // if our destination polygon shares any endpoints with our actual destination, we're ok + obstructed= FALSE; + break; + } + } + } + } } last_polygon_index= polygon_index; @@ -1771,6 +1779,7 @@ void random_point_on_circle( /* ---------- private code */ +#if 0 /* returns the line_index of the line we intersected to leave this polygon, or NONE if destination is in the given polygon */ short _find_line_crossed_leaving_polygon( @@ -1810,6 +1819,7 @@ short _find_line_crossed_leaving_polygon( return intersected_line_index; } +#endif static short _new_map_object( shape_descriptor shape, @@ -2032,7 +2042,7 @@ void _sound_add_ambient_sources_proc( if (media && listener->point.zheight) { // if we’re under media don’t play the ambient sound image - add_one_ambient_sound_source(data, (world_location3d *) NULL, listener, + add_one_ambient_sound_source((struct ambient_sound_data *)data, (world_location3d *) NULL, listener, get_media_sound(listener_polygon->media_index, _media_snd_ambient_under), MAXIMUM_SOUND_VOLUME); under_media= TRUE; } @@ -2043,14 +2053,14 @@ void _sound_add_ambient_sources_proc( { struct ambient_sound_image_data *image= get_ambient_sound_image_data(listener_polygon->ambient_sound_image_index); - add_one_ambient_sound_source(data, (world_location3d *) NULL, listener, image->sound_index, image->volume); + add_one_ambient_sound_source((struct ambient_sound_data *)data, (world_location3d *) NULL, listener, image->sound_index, image->volume); } // if we’re over media, play that ambient sound image if (media && (media->height>=listener_polygon->floor_height || !MEDIA_SOUND_OBSTRUCTED_BY_FLOOR(media))) { source= *listener, source.point.z= media->height; - add_one_ambient_sound_source(data, &source, listener, + add_one_ambient_sound_source((struct ambient_sound_data *)data, &source, listener, get_media_sound(listener_polygon->media_index, _media_snd_ambient_over), MAXIMUM_SOUND_VOLUME); } } @@ -2063,7 +2073,7 @@ void _sound_add_ambient_sources_proc( if (PLATFORM_IS_ACTIVE(platform) && PLATFORM_IS_MOVING(platform)) { source= *listener, source.point.z= listener_polygon->floor_height; - add_one_ambient_sound_source(data, &source, listener, + add_one_ambient_sound_source((struct ambient_sound_data *)data, &source, listener, get_platform_moving_sound(listener_polygon->permutation), MAXIMUM_SOUND_VOLUME); } } @@ -2119,7 +2129,7 @@ void _sound_add_ambient_sources_proc( // .index is environmental sound type, .facing is volume if (active && (!under_media || (source.point.zheight && polygon->media_index==listener_polygon->media_index))) { - add_one_ambient_sound_source(data, &source, listener, sound_type, sound_volume); + add_one_ambient_sound_source((struct ambient_sound_data *)data, &source, listener, sound_type, sound_volume); } } } diff --git a/marathon2/map.h b/marathon2/map.h index cc1cb47..13ed842 100644 --- a/marathon2/map.h +++ b/marathon2/map.h @@ -689,7 +689,9 @@ struct static_data short mission_flags; short environment_flags; - short unused[4]; + boolean ball_in_play; // true if there's a ball in play + boolean unused1; + short unused[3]; char level_name[LEVEL_NAME_LENGTH]; long entry_point_flags; @@ -1036,8 +1038,6 @@ void update_lightsources(void); short new_lightsource_from_old(short old_source); void entered_polygon(short index); void left_polygon(short index); -/* Only send _light_turning_on, _light_turning_off, _light_toggle */ -void change_light_state(short lightsource_index, short state); /* ---------- prototypes/DEVICES.C */ diff --git a/marathon2/map_constructors.c b/marathon2/map_constructors.c index 73e4405..0ba6bea 100644 --- a/marathon2/map_constructors.c +++ b/marathon2/map_constructors.c @@ -10,6 +10,8 @@ Thursday, March 23, 1995 8:53:35 PM (Jason') #include "map.h" #include "flood_map.h" +#include + /* maps of one polygon don’t have their impassability information computed @@ -59,7 +61,7 @@ static void find_intersecting_endpoints_and_lines(short polygon_index, world_dis short *line_indexes, short *line_count, short *endpoint_indexes, short *endpoint_count, short *polygon_indexes, short *polygon_count); static long intersecting_flood_proc(short source_polygon_index, short line_index, - short destination_polygon_index, struct intersecting_flood_data *data); + short destination_polygon_index, void *data); static void precalculate_polygon_sound_sources(void); @@ -565,6 +567,21 @@ static void find_intersecting_endpoints_and_lines( data.polygon_count= 0; data.minimum_separation_squared= minimum_separation*minimum_separation; find_center_of_polygon(polygon_index, &data.center); + + { + struct polygon_data *polygon= get_polygon_data(polygon_index); + short i; + + for (i= 0; ivertex_count; ++i) + { + short adjacent_polygon_index= find_adjacent_polygon(polygon_index, polygon->line_indexes[i]); + + if (adjacent_polygon_index!=NONE) + { + data.polygon_indexes[data.polygon_count++]= adjacent_polygon_index; + } + } + } polygon_index= flood_map(polygon_index, LONG_MAX, intersecting_flood_proc, _breadth_first, &data); while (polygon_index!=NONE) @@ -586,6 +603,7 @@ static long intersecting_flood_proc( short destination_polygon_index, struct intersecting_flood_data *data) { + struct intersecting_flood_data data= *(struct intersecting_flood_data *)generic_data; struct polygon_data *polygon= get_polygon_data(source_polygon_index); struct polygon_data *original_polygon= get_polygon_data(data->original_polygon_index); boolean keep_searching= FALSE; /* don’t flood any deeper unless we find something close enough */ diff --git a/marathon2/marathon2.c b/marathon2/marathon2.c index 43fdf3d..8ddd5bb 100644 --- a/marathon2/marathon2.c +++ b/marathon2/marathon2.c @@ -28,9 +28,14 @@ Thursday, December 8, 1994 3:58:12 PM (Jason) #include "items.h" #include "weapons.h" #include "game_window.h" -#include "sound.h" +#include "game_sound.h" #include "network_games.h" +#ifdef envppc +#include "portable_files.h" +#include "vbl.h" +#endif + #ifdef mpwc #pragma segment marathon #endif @@ -179,6 +184,15 @@ boolean entering_map( set_fade_effect(NONE); +#ifdef envppc + // make sure that net games aren't cheating + if (game_is_networked) + { + toggle_ludicrous_speed(FALSE); + toggle_sound_pitch_modifier_override(FALSE); + } +#endif + /* if any active monsters think they have paths, we'll make them reconsider */ initialize_monsters_for_new_level(); @@ -272,12 +286,33 @@ void changed_polygon( case _polygon_must_be_explored: /* When a player enters a must be explored, it now becomes a normal polygon, to allow */ /* for must be explored flags to work across cooperative net games */ - if(player) + if (player) { new_polygon->type= _polygon_is_normal; } break; - + +#ifdef SCREAMING_METAL + case _polygon_sound_once_trigger: + if (player) + { + if (player_index==local_player_index) + { + play_local_sound(new_polygon->permutation); + } + + new_polygon->type= _polygon_is_normal; + } + break; + + case _polygon_sound_always_trigger: + if (player && player_index==local_player_index)) + { + play_local_sound(new_polygon->permutation); + } + break; +#endif + default: break; } @@ -430,12 +465,12 @@ static short preload_sounds1[]= {_snd_lava, _snd_wind}; static void load_all_game_sounds( short environment_code) { - load_sounds(&preload_sounds, NUMBER_OF_PRELOAD_SOUNDS); + load_sounds((short *) &preload_sounds, NUMBER_OF_PRELOAD_SOUNDS); switch (environment_code) { - case 0: load_sounds(&preload_sounds0, NUMBER_OF_PRELOAD_SOUNDS0); break; - case 1: load_sounds(&preload_sounds1, NUMBER_OF_PRELOAD_SOUNDS1); break; + case 0: load_sounds((short *) &preload_sounds0, NUMBER_OF_PRELOAD_SOUNDS0); break; + case 1: load_sounds((short *) &preload_sounds1, NUMBER_OF_PRELOAD_SOUNDS1); break; case 2: break; case 3: break; case 4: break; diff --git a/marathon2/marathon2.r b/marathon2/marathon2.r index ed23a7c..a3af643 100644 --- a/marathon2/marathon2.r +++ b/marathon2/marathon2.r @@ -13,25 +13,38 @@ Monday, March 28, 1994 3:08:23 PM #include "SysTypes.r" #include "CodeFragmentTypes.r" -#define CREATOR '52.4' -#define VERSION "1.0" +#define CREATOR '26.∞' +#define VERSION "1.5" #define MAJOR_VERSION 1 -#define MINOR_VERSION 0 -#define RELEASE_STAGE development +#define MINOR_VERSION 5 +#define RELEASE_STAGE release #define PRE_RELEASE_REVISION 0 #ifdef DEMO #define SHORT_VERSION_STRING "v" VERSION - #define LONG_VERSION_STRING "v" VERSION " DEMO © 1995 Bungie Software Products Corp." + #define LONG_VERSION_STRING "v" VERSION " DEMO © 1995-1997 Bungie Software Products Corp." #else #define SHORT_VERSION_STRING "v" VERSION - #define LONG_VERSION_STRING "v" VERSION " © 1995 Bungie Software Products Corp." + #define LONG_VERSION_STRING "v" VERSION " © 1995-1997 Bungie Software Products Corp." #endif +#ifdef __MWERKS__ +include CODE_FILE 'CODE'; +include CODE_FILE 'DATA'; // yay metrowerks +#else #ifndef fat -include ":binaries:marathon2.resource"; +/* zug zug */ +#ifdef SUPPORT_INPUT_SPROCKET +include ":binaries:infinityInput.rsrc" not 'ckid' ; +#endif + +include ":binaries:marathon2.resource" not 'ckid' ; +#ifdef DEMO +include ":demos.demo:demos.resource"; +#else include ":demos:demos.resource"; +#endif /* include ":texts:texts.resource"; */ /* include ":graphics:screens"; */ @@ -39,7 +52,7 @@ include ":demos:demos.resource"; include ":binaries:demo.resource"; /* overrides resources in marathon.resource */ include ":graphics:demo.screens"; #else -include ":binaries:game.resource"; +include ":binaries:game.resource" not 'ckid'; include ":graphics:game.screens"; #endif #endif /* fat */ @@ -47,6 +60,7 @@ include ":graphics:game.screens"; #ifdef envppc #ifdef fat include CODE_FILE 'CODE'; + include CODE_FILE 'SOCK'; #ifndef DEMO /* include whatever resource we need to get the 68k checksum from */ #endif @@ -70,6 +84,7 @@ include ":graphics:game.screens"; } }; #endif +#endif #ifdef DEBUG type 'dbug' as 'STR '; diff --git a/marathon2/media.c b/marathon2/media.c index 2833076..3763f01 100644 --- a/marathon2/media.c +++ b/marathon2/media.c @@ -3,14 +3,14 @@ MEDIA.C Sunday, March 26, 1995 1:13:11 AM (Jason') */ -#include +#include "cseries.h" #include "map.h" #include "media.h" #include "effects.h" #include "fades.h" #include "lightsource.h" -#include "sound.h" +#include "game_sound.h" #ifdef mpwc #pragma segment marathon diff --git a/marathon2/media.h b/marathon2/media.h index ce85b33..50ea961 100644 --- a/marathon2/media.h +++ b/marathon2/media.h @@ -13,6 +13,7 @@ enum /* media types */ _media_lava, _media_goo, _media_sewage, + _media_jjaro, NUMBER_OF_MEDIA_TYPES }; diff --git a/marathon2/media_definitions.h b/marathon2/media_definitions.h index 24b0019..79df7ed 100644 --- a/marathon2/media_definitions.h +++ b/marathon2/media_definitions.h @@ -82,4 +82,19 @@ static struct media_definition media_definitions[NUMBER_OF_MEDIA_TYPES]= _effect_under_sewage, /* submerged fade effect */ }, + + /* _media_jjaro */ + { + _collection_walls4, 13, 1, 0, /* collection, shape, shape_count, frequency */ + _xfer_normal, /* transfer mode */ + + 0, {NONE, 0, 0, 0, FIXED_ONE}, /* damage frequency and definition */ + + {_effect_small_jjaro_splash, _effect_medium_jjaro_splash, _effect_large_jjaro_splash, _effect_large_jjaro_emergence}, /* small, medium, large detonation effects */ + {NONE, NONE, _snd_enter_sewage, _snd_exit_sewage, + NONE, _ambient_snd_sewage, _ambient_snd_under_media, + _snd_enter_sewage, _snd_exit_sewage}, + + _effect_under_sewage, /* submerged fade effect */ + }, }; diff --git a/marathon2/monster_definitions.h b/marathon2/monster_definitions.h index 435b466..7a0159d 100644 --- a/marathon2/monster_definitions.h +++ b/marathon2/monster_definitions.h @@ -5,9 +5,9 @@ Monday, May 30, 1994 9:04:01 PM /* ---------- macros */ -#define TYPE_IS_NEUTRAL(definition,type) (!((definition->friends|definition->enemies)&monster_definitions[type].class)) -#define TYPE_IS_ENEMY(definition,type) (definition->enemies&monster_definitions[type].class) -#define TYPE_IS_FRIEND(definition,type) (definition->friends&monster_definitions[type].class) +#define TYPE_IS_NEUTRAL(definition,type) (!((definition->friends|definition->enemies)&monster_definitions[type].monster_class)) +#define TYPE_IS_ENEMY(definition,type) (definition->enemies&monster_definitions[type].monster_class) +#define TYPE_IS_FRIEND(definition,type) (definition->friends&monster_definitions[type].monster_class) /* ---------- constants */ @@ -152,7 +152,7 @@ struct monster_definition /* <128 bytes */ unsigned long immunities, weaknesses; unsigned long flags; - long class; /* our class */ + long monster_class; /* our class */ long friends, enemies; /* bit fields of what classes we consider friendly and what types we don’t like */ fixed sound_pitch; @@ -193,6 +193,7 @@ struct monster_definition /* <128 bytes */ /* ---------- monster definitions */ +#ifndef DONT_COMPILE_DEFINITIONS struct monster_definition monster_definitions[NUMBER_OF_MONSTER_TYPES]= { { /* _monster_marine (can’t be used as a regular monster) */ @@ -2619,4 +2620,219 @@ struct monster_definition monster_definitions[NUMBER_OF_MONSTER_TYPES]= 0, 0, WORLD_ONE/5, /* dx, dy, dz */ } }, + + { /* _civilian_crew "bob" */ + BUILD_COLLECTION(_collection_vacuum_civilian, 0), /* shape collection */ + 20, 0, 0, /* vitality, immunities, weaknesses */ + _monster_attacks_immediately|_monster_is_omniscent|_monster_cannot_be_dropped|_monster_waits_with_clear_shot|_monster_can_die_in_flames|_monster_uses_sniper_ledges, /* flags */ + + _class_human_civilian, /* class */ + _class_human, /* friends */ + (_class_hostile_alien^_class_assimilated_civilian)|_class_native, /* enemies */ + + _normal_frequency, /* sound pitch */ + _snd_fusion_human_activation, _snd_fusion_kill_the_player, _snd_fusion_human_clear, _snd_fusion_human_trash_talk, _snd_fusion_human_apology, _snd_fusion_human_stop_shooting_me_you_bastard, /* sounds: activation, friendly activation, clear, kill, apology, friendly-fire */ + _snd_fusion_human_wail, /* dying flaming */ + _snd_fusion_human_chatter, 0x1f, /* random sound, random sound mask */ + + _i_plasma_magazine, /* carrying item type */ + + WORLD_ONE/5, (4*WORLD_ONE)/5, /* radius, height */ + 0, /* preferred hover height */ + -2*WORLD_ONE, WORLD_ONE/3, /* minimum ledge delta, maximum ledge delta */ + FIXED_ONE, /* external velocity scale */ + _effect_vacuum_civilian_blood_splash, NONE, NONE, /* impact effect, melee impact effect, contrail effect */ + + QUARTER_CIRCLE, QUARTER_CIRCLE/3, /* half visual arc, half vertical visual arc */ + 30*WORLD_ONE, WORLD_ONE, /* visual range, dark visual range */ + _intelligence_high, /* intelligence */ + _speed_blinding, /* speed */ + NORMAL_MONSTER_GRAVITY, NORMAL_MONSTER_TERMINAL_VELOCITY, /* gravity, terminal velocity */ + _vidmaster_door_retry_mask, /* door retry mask */ + NONE, {NONE, 0, 0, 0}, /* shrapnel radius, shrapnel damage */ + + 10, /* being hit */ + 2, 1, /* dying hard (popping), dying soft (falling) */ + 4, 3, /* hard dead frames, soft dead frames */ + 6, 0, /* stationary shape, moving shape */ + 9, 8, /* teleport in shape, teleport out shape */ + + 3*TICKS_PER_SECOND, /* attack frequency (for both melee and ranged attacks) */ + + /* melee attack */ + { + NONE, /* melee attack type */ + }, + + /* ranged attack */ + { + _projectile_fusion_bolt_minor, /* ranged attack type */ + 1, /* repetitions */ + NUMBER_OF_ANGLES/150, /* error angle */ + 10*WORLD_ONE, /* range */ + 5, /* ranged attack shape */ + + 0, 0, WORLD_ONE*3/4, /* dx, dy, dz */ + } + }, + + { /* _civilian_science "fred" */ + BUILD_COLLECTION(_collection_vacuum_civilian, 1), /* shape collection */ + 25, 0, 0, /* vitality, immunities, weaknesses */ + _monster_attacks_immediately|_monster_is_omniscent|_monster_cannot_be_dropped|_monster_waits_with_clear_shot|_monster_can_die_in_flames|_monster_uses_sniper_ledges, /* flags */ + + _class_human_civilian, /* class */ + _class_human|_class_assimilated_civilian, /* friends */ + (_class_hostile_alien^_class_assimilated_civilian)|_class_native, /* enemies */ + + _normal_frequency, /* sound pitch */ + _snd_fusion_human_activation, _snd_fusion_kill_the_player, _snd_fusion_human_clear, _snd_fusion_human_trash_talk, _snd_fusion_human_apology, _snd_fusion_human_stop_shooting_me_you_bastard, /* sounds: activation, friendly activation, clear, kill, apology, friendly-fire */ + _snd_fusion_human_wail, /* dying flaming */ + _snd_fusion_human_chatter, 0x1f, /* random sound, random sound mask */ + + _i_plasma_magazine, /* carrying item type */ + + WORLD_ONE/5, (4*WORLD_ONE)/5, /* radius, height */ + 0, /* preferred hover height */ + -2*WORLD_ONE, WORLD_ONE/3, /* minimum ledge delta, maximum ledge delta */ + FIXED_ONE, /* external velocity scale */ + _effect_vacuum_civilian_blood_splash, NONE, NONE, /* impact effect, melee impact effect, contrail effect */ + + QUARTER_CIRCLE, QUARTER_CIRCLE/3, /* half visual arc, half vertical visual arc */ + 30*WORLD_ONE, WORLD_ONE, /* visual range, dark visual range */ + _intelligence_high, /* intelligence */ + _speed_blinding, /* speed */ + NORMAL_MONSTER_GRAVITY, NORMAL_MONSTER_TERMINAL_VELOCITY, /* gravity, terminal velocity */ + _vidmaster_door_retry_mask, /* door retry mask */ + NONE, {NONE, 0, 0, 0}, /* shrapnel radius, shrapnel damage */ + + 10, /* being hit */ + 2, 1, /* dying hard (popping), dying soft (falling) */ + 4, 3, /* hard dead frames, soft dead frames */ + 6, 0, /* stationary shape, moving shape */ + 9, 8, /* teleport in shape, teleport out shape */ + + 3*TICKS_PER_SECOND, /* attack frequency (for both melee and ranged attacks) */ + + /* melee attack */ + { + NONE, /* melee attack type */ + }, + + /* ranged attack */ + { + _projectile_fusion_bolt_minor, /* ranged attack type */ + 2, /* repetitions */ + NUMBER_OF_ANGLES/150, /* error angle */ + 13*WORLD_ONE, /* range */ + 5, /* ranged attack shape */ + + 0, 0, WORLD_ONE*3/4, /* dx, dy, dz */ + } + }, + + { /* _civilian_security "steve" */ + BUILD_COLLECTION(_collection_vacuum_civilian, 2), /* shape collection */ + 30, 0, 0, /* vitality, immunities, weaknesses */ + _monster_attacks_immediately|_monster_is_omniscent|_monster_cannot_be_dropped|_monster_waits_with_clear_shot|_monster_can_die_in_flames|_monster_uses_sniper_ledges, /* flags */ + + _class_human_civilian, /* class */ + _class_human|_class_assimilated_civilian, /* friends */ + (_class_hostile_alien^_class_assimilated_civilian)|_class_native, /* enemies */ + + _normal_frequency, /* sound pitch */ + _snd_fusion_human_activation, _snd_fusion_kill_the_player, _snd_fusion_human_clear, _snd_fusion_human_trash_talk, _snd_fusion_human_apology, _snd_fusion_human_stop_shooting_me_you_bastard, /* sounds: activation, friendly activation, clear, kill, apology, friendly-fire */ + _snd_fusion_human_wail, /* dying flaming */ + _snd_fusion_human_chatter, 0x1f, /* random sound, random sound mask */ + + _i_plasma_pistol, /* carrying item type */ + + WORLD_ONE/5, (4*WORLD_ONE)/5, /* radius, height */ + 0, /* preferred hover height */ + -2*WORLD_ONE, WORLD_ONE/3, /* minimum ledge delta, maximum ledge delta */ + FIXED_ONE, /* external velocity scale */ + _effect_vacuum_civilian_blood_splash, NONE, NONE, /* impact effect, melee impact effect, contrail effect */ + + QUARTER_CIRCLE, QUARTER_CIRCLE/3, /* half visual arc, half vertical visual arc */ + 30*WORLD_ONE, WORLD_ONE, /* visual range, dark visual range */ + _intelligence_high, /* intelligence */ + _speed_blinding, /* speed */ + NORMAL_MONSTER_GRAVITY, NORMAL_MONSTER_TERMINAL_VELOCITY, /* gravity, terminal velocity */ + _vidmaster_door_retry_mask, /* door retry mask */ + NONE, {NONE, 0, 0, 0}, /* shrapnel radius, shrapnel damage */ + + 10, /* being hit */ + 2, 1, /* dying hard (popping), dying soft (falling) */ + 4, 3, /* hard dead frames, soft dead frames */ + 6, 0, /* stationary shape, moving shape */ + 9, 8, /* teleport in shape, teleport out shape */ + + TICKS_PER_SECOND, /* attack frequency (for both melee and ranged attacks) */ + + /* melee attack */ + { + NONE, /* melee attack type */ + }, + + /* ranged attack */ + { + _projectile_fusion_bolt_minor, /* ranged attack type */ + 5, /* repetitions */ + NUMBER_OF_ANGLES/150, /* error angle */ + 17*WORLD_ONE, /* range */ + 5, /* ranged attack shape */ + + 0, 0, WORLD_ONE*3/4, /* dx, dy, dz */ + } + }, + + { /* _civilian_assimilated "evil bob" */ + BUILD_COLLECTION(_collection_vacuum_civilian, 3), /* shape collection */ + 30, 0, 0, /* vitality, immunities, weaknesses */ + _monster_is_alien|_monster_is_kamakazi|_monster_can_die_in_flames, /* flags */ + + _class_assimilated_civilian, + _class_pfhor, /* friends */ + _class_player|_class_defender, /* enemies */ + + _normal_frequency, /* sound pitch */ + NONE, NONE, NONE, NONE, NONE, _snd_fusion_human_stop_shooting_me_you_bastard, /* sounds: activation, friendly activation, clear, kill, apology, friendly-fire */ + _snd_fusion_human_wail, /* dying flaming */ + _snd_assimilated_fusion_human_chatter, 0xf, /* random sound, random sound mask */ + + NONE, /* carrying item type */ + + WORLD_ONE/5, (4*WORLD_ONE)/5, /* radius, height */ + 0, /* preferred hover height */ + -2*WORLD_ONE, WORLD_ONE/3, /* minimum ledge delta, maximum ledge delta */ + FIXED_ONE, /* external velocity scale */ + _effect_assimilated_vacuum_civilian_blood_splash, NONE, NONE, /* impact effect, melee impact effect, contrail effect */ + + QUARTER_CIRCLE, QUARTER_CIRCLE/3, /* half visual arc, half vertical visual arc */ + 15*WORLD_ONE, WORLD_ONE, /* visual range, dark visual range */ + _intelligence_high, /* intelligence */ + _speed_blinding, /* speed */ + NORMAL_MONSTER_GRAVITY, NORMAL_MONSTER_TERMINAL_VELOCITY, /* gravity, terminal velocity */ + _vidmaster_door_retry_mask, /* door retry mask */ + WORLD_ONE, {_damage_explosion, _alien_damage, 80, 40, FIXED_ONE}, /* shrapnel radius, shrapnel damage */ + + 10, /* being hit */ + 11, NONE, /* dying hard (popping), dying soft (falling) */ + 4, 0, /* hard dead frames, soft dead frames */ + 6, 0, /* stationary shape, moving shape */ + 8, NONE, /* teleport in shape, teleport out shape */ + + 2*TICKS_PER_SECOND, /* attack frequency (for both melee and ranged attacks) */ + + /* melee attack */ + { + NONE, /* melee attack type */ + }, + + /* ranged attack */ + { + NONE, /* ranged attack type */ + } + }, }; +#endif diff --git a/marathon2/monsters.c b/marathon2/monsters.c index 568a7cc..99cbd31 100644 --- a/marathon2/monsters.c +++ b/marathon2/monsters.c @@ -27,7 +27,7 @@ Monday, July 10, 1995 11:49:06 AM (Jason) #include "player.h" #include "platforms.h" #include "scenery.h" -#include "sound.h" +#include "game_sound.h" #include "fades.h" #include "items.h" #include "media.h" @@ -116,7 +116,7 @@ struct monster_pathfinding_data /* ---------- private prototypes */ #ifdef DEBUG -struct monster_definition *get_monster_definition(short type); +static struct monster_definition *get_monster_definition(short type); #else #define get_monster_definition(i) (monster_definitions+(i)) #endif @@ -137,7 +137,7 @@ static boolean translate_monster(short monster_index, world_distance distance); static boolean try_monster_attack(short monster_index); static long monster_pathfinding_cost_function(short source_polygon_index, short line_index, - short destination_polygon_index, struct monster_pathfinding_data *data); + short destination_polygon_index, void *data); static void set_monster_action(short monster_index, short action); static void set_monster_mode(short monster_index, short new_mode, short target_index); @@ -151,7 +151,7 @@ static void update_monster_vertical_physics_model(short monster_index); static void update_monster_physics_model(short monster_index); static long monster_activation_flood_proc(short source_polygon_index, short line_index, - short destination_polygon_index, long *flags); + short destination_polygon_index, void *flags); static boolean attempt_evasive_manouvers(short monster_index); @@ -271,7 +271,7 @@ short new_monster( } /* keep track of how many civilians we drop on this level */ -// if (monster_index!=NONE && (definition->class&_class_human_civilian)) dynamic_world->current_civilian_count+= 1; +// if (monster_index!=NONE && (definition->monster_class&_class_human_civilian)) dynamic_world->current_civilian_count+= 1; return monster_index; } @@ -639,7 +639,7 @@ void activate_nearby_monsters( /* flood out from the target monster’s polygon, searching through the object lists of all polygons we encounter */ - polygon_index= flood_map(polygon_index, LONG_MAX, monster_activation_flood_proc, _flagged_breadth_first, &flood_flags); + polygon_index= flood_map(polygon_index, LONG_MAX, monster_activation_flood_proc, _flagged_breadth_first, (void *)&flood_flags); while (polygon_index!=NONE) { short object_index; @@ -715,7 +715,7 @@ void activate_nearby_monsters( } } - polygon_index= flood_map(NONE, LONG_MAX, monster_activation_flood_proc, _flagged_breadth_first, &flood_flags); + polygon_index= flood_map(NONE, LONG_MAX, monster_activation_flood_proc, _flagged_breadth_first, (void *)&flood_flags); } // deferred find_closest_appropriate_target() calls @@ -1204,10 +1204,25 @@ void damage_monsters_in_radius( short object_count; short object_indexes[LOCAL_INTERSECTING_MONSTER_BUFFER_SIZE]; + boolean aggressor_is_live_player= FALSE; + #pragma unused (primary_target_index) object_count= 0; possible_intersecting_monsters(object_indexes, &object_count, LOCAL_INTERSECTING_MONSTER_BUFFER_SIZE, epicenter_polygon_index, FALSE); + + if (aggressor_index!=NONE) + { + struct monster_data *monster= get_monster_data(aggressor_index); + + if (MONSTER_IS_PLAYER(monster)) + { + struct player_data *player= get_player_data(monster_index_to_player_index(aggressor_index)); + + if (!PLAYER_IS_DEAD(player)) aggressor_is_live_player= TRUE; + } + } + for (i=0;igame_player_index)) + { + play_local_sound(_snd_you_are_it); + } +#else + if (player_index!=dynamic_world->game_player_index) + { + play_object_sound(player->object_index, _snd_you_are_it); + } +#endif + dynamic_world->game_player_index= player_index; + } + } + } + return; } @@ -1320,7 +1363,7 @@ void damage_monster( { aggressor_player->monster_damage_given.kills+= 1; - if (definition->class&_class_human_civilian) dynamic_world->civilians_killed_by_players+= 1; + if (definition->monster_class&_class_human_civilian) dynamic_world->civilians_killed_by_players+= 1; } } } @@ -1838,7 +1881,7 @@ static void generate_new_path_for_monster( /* if we can’t attack, run away, otherwise go for the target */ if (definition->flags&_monster_cannot_attack) { - dprintf("%p", monster); +// dprintf("%p", monster); destination= (world_point2d *) &bias; bias.i= object->location.x - target_object->location.x; bias.j= object->location.y - target_object->location.y; @@ -1883,7 +1926,7 @@ static void generate_new_path_for_monster( data.cross_zone_boundaries= destination_polygon_index==NONE ? FALSE : TRUE; monster->path= new_path((world_point2d *)&object->location, object->polygon, destination, - destination_polygon_index, 3*definition->radius, monster_pathfinding_cost_function, &data); + destination_polygon_index, 3*definition->radius, monster_pathfinding_cost_function, (void *)&data); if (monster->path==NONE) { if (monster->action!=_monster_is_being_hit || MONSTER_IS_DYING(monster)) set_monster_action(monster_index, _monster_is_stationary); @@ -1994,7 +2037,7 @@ static short get_monster_attitude( /* berserk monsters are hostile toward everything */ if (TYPE_IS_ENEMY(definition, target_type) || MONSTER_IS_BERSERK(monster) || (MONSTER_HAS_VALID_TARGET(monster) && monster->target_index==target_index) || - ((definition->class&_class_human_civilian) && MONSTER_IS_PLAYER(target) && dynamic_world->civilians_killed_by_players>=CIVILIANS_KILLED_BY_PLAYER_THRESHHOLD)) + ((definition->monster_class&_class_human_civilian) && MONSTER_IS_PLAYER(target) && dynamic_world->civilians_killed_by_players>=CIVILIANS_KILLED_BY_PLAYER_THRESHHOLD)) { attitude= _hostile; } @@ -2003,7 +2046,7 @@ static short get_monster_attitude( attitude= (TYPE_IS_FRIEND(definition, target_type)) ? _friendly : _neutral; } -// if ((definition->class&_class_human_civilian) && MONSTER_IS_PLAYER(target)) +// if ((definition->monster_class&_class_human_civilian) && MONSTER_IS_PLAYER(target)) // { // dprintf("#%d vs. #%d ==> #%d", monster_index, target_index, attitude); // } @@ -2033,7 +2076,7 @@ short find_closest_appropriate_target( /* flood out from the aggressor monster’s polygon, searching through the object lists of all polygons we encounter */ - polygon_index= flood_map(polygon_index, LONG_MAX, monster_activation_flood_proc, _flagged_breadth_first, &flood_flags); + polygon_index= flood_map(polygon_index, LONG_MAX, monster_activation_flood_proc, _flagged_breadth_first, (void *)&flood_flags); while (polygon_index!=NONE && closest_hostile_target_index==NONE) { short object_index; @@ -2875,13 +2918,13 @@ static void execute_monster_attack( world_point3d vector; projectile_polygon_index= position_monster_projectile(monster_index, monster->target_index, attack, &origin, (world_point3d *) NULL, &vector, object->facing); - new_projectile(&origin, projectile_polygon_index, &vector, attack->error, attack->type, + if (projectile_polygon_index!=NONE) new_projectile(&origin, projectile_polygon_index, &vector, attack->error, attack->type, monster_index, monster->type, monster->target_index, FIXED_ONE); if (definition->flags&_monster_fires_symmetrically) { attack->dy= -attack->dy; projectile_polygon_index= position_monster_projectile(monster_index, monster->target_index, attack, &origin, (world_point3d *) NULL, &vector, object->facing); - new_projectile(&origin, projectile_polygon_index, &vector, attack->error, attack->type, + if (projectile_polygon_index!=NONE) new_projectile(&origin, projectile_polygon_index, &vector, attack->error, attack->type, monster_index, monster->type, monster->target_index, FIXED_ONE); attack->dy= -attack->dy; } @@ -2905,8 +2948,6 @@ static long monster_pathfinding_cost_function( short object_index; long cost; - #pragma unused (unused) - /* base cost is the area of the polygon we’re leaving */ cost= source_polygon->area; @@ -3084,7 +3125,7 @@ static short find_obstructing_terrain_feature( switch (media->type) { case _media_water: if (definition->flags&_monster_is_not_afraid_of_water) media= (struct media_data *) NULL; break; - case _media_sewage: if (definition->flags&_monster_is_not_afraid_of_sewage) media= (struct media_data *) NULL; break; + case _media_jjaro: case _media_sewage: if (definition->flags&_monster_is_not_afraid_of_sewage) media= (struct media_data *) NULL; break; case _media_lava: height= 0; if (definition->flags&_monster_is_not_afraid_of_lava) media= (struct media_data *) NULL; break; case _media_goo: height= 0; if (definition->flags&_monster_is_not_afraid_of_goo) media= (struct media_data *) NULL; break; } diff --git a/marathon2/monsters.h b/marathon2/monsters.h index 8063691..8747f4f 100644 --- a/marathon2/monsters.h +++ b/marathon2/monsters.h @@ -80,6 +80,10 @@ enum /* monster types */ _monster_tiny_fighter, _monster_tiny_bob, _monster_tiny_yeti, + _vacuum_civilian_crew, + _vacuum_civilian_science, + _vacuum_civilian_security, + _vacuum_civilian_assimilated, NUMBER_OF_MONSTER_TYPES }; diff --git a/marathon2/motion_sensor.c b/marathon2/motion_sensor.c index aa2c97a..e3ed389 100644 --- a/marathon2/motion_sensor.c +++ b/marathon2/motion_sensor.c @@ -632,6 +632,10 @@ static shape_descriptor get_motion_sensor_entity_shape( case _civilian_science: case _civilian_security: case _civilian_assimilated: + case _vacuum_civilian_crew: + case _vacuum_civilian_science: + case _vacuum_civilian_security: + case _vacuum_civilian_assimilated: shape= friendly_shapes; break; diff --git a/marathon2/motion_sensor.h b/marathon2/motion_sensor.h index d48fdcf..92720c0 100644 --- a/marathon2/motion_sensor.h +++ b/marathon2/motion_sensor.h @@ -6,7 +6,7 @@ Friday, June 17, 1994 12:10:02 PM /* ---------- prototypes/MOTION_SENSOR.C */ void initialize_motion_sensor(shape_descriptor mount, shape_descriptor virgin_mounts, - shape_descriptor alien, shape_descriptor friend, shape_descriptor enemy, + shape_descriptor alien, shape_descriptor friendly, shape_descriptor enemy, shape_descriptor network_compass, short side_length); void reset_motion_sensor(short monster_index); void motion_sensor_scan(short ticks_elapsed); diff --git a/marathon2/mouse.c b/marathon2/mouse.c index 26314d8..1cc6866 100644 --- a/marathon2/mouse.c +++ b/marathon2/mouse.c @@ -3,8 +3,15 @@ MOUSE.C Tuesday, January 17, 1995 2:51:59 PM (Jason') */ +// Work around lack of valid symbols in InterfaceLib +#define NICK_KLEDZIK_IS_A_FUCKER + /* marathon includes */ #include "macintosh_cseries.h" +#ifdef SUPPORT_INPUT_SPROCKET +#include "InputSprocket.h" +#include "macintosh_input.h" +#endif #include "world.h" #include "map.h" #include "player.h" // for get_absolute_pitch_range() @@ -32,10 +39,17 @@ static boolean trap_available(short trap_num); static TrapType get_trap_type(short trap_num); static short num_toolbox_traps(void); +#ifdef NICK_KLEDZIK_IS_A_FUCKER +enum +{ + kDeviceClassTrackPad = 3 // they neglected to publish this +}; + extern pascal OSErr CrsrDevNextDevice(CursorDevicePtr *ourDevice) TWOWORDINLINE(0x700B, 0xAADB); extern pascal OSErr CrsrDevMoveTo(CursorDevicePtr ourDevice, long absX, long absY) TWOWORDINLINE(0x7001, 0xAADB); +#endif #define MBState *((byte *)0x0172) #define RawMouse *((Point *)0x082c) @@ -105,6 +119,109 @@ void exit_mouse( #define MAXIMUM_MOUSE_VELOCITY (1200/MACINTOSH_TICKS_PER_SECOND) //#define MAXIMUM_MOUSE_VELOCITY ((float)1500/MACINTOSH_TICKS_PER_SECOND) +#define DEAD_ZONE ((UInt32) 0x07000000) + +#define PIXELS_PER_INCH (72) + +#ifdef SUPPORT_INPUT_SPROCKET + +UInt32 axis_deadzone(UInt32 axis_value) +{ + UInt32 new_axis_value = axis_value; + + if (axis_value > (kISpAxisMiddle + DEAD_ZONE)) + { new_axis_value -= DEAD_ZONE; } + else if (axis_value < (kISpAxisMiddle - DEAD_ZONE)) + { new_axis_value += DEAD_ZONE; } + else + { new_axis_value = kISpAxisMiddle; } + + return new_axis_value; + +} + +fixed sprocket_do_xaxis(Boolean running, long ticks_elapsed) +{ + ISpElementReference xLook = input_sprocket_elements[_input_sprocket_yaw]; + ISpElementReference xDelta = input_sprocket_elements[_input_sprocket_yaw_delta]; + fixed delta_x; + UInt32 int_x; + float float_x; + fixed fixed_x; + OSStatus err; + + err = ISpElement_GetSimpleState(xDelta, &delta_x); + if (err != noErr) { delta_x = 0; } // kISpDeltaMiddle + + delta_x *= PIXELS_PER_INCH; + + err = ISpElement_GetSimpleState(xLook, &int_x); + if (err != noErr) { int_x = kISpAxisMiddle; } + + int_x = axis_deadzone(int_x); + + /* turn into -1 .. +1 */ + float_x = ((float)int_x - (float)kISpAxisMiddle) / (kISpAxisMiddle - DEAD_ZONE); + + /* make non-linear */ + float_x *= float_x; // square x + + /* restore sign */ + if (int_x < kISpAxisMiddle) { float_x = -float_x; } + + // magnitude modification + if (running) { float_x *= 15; } // was 40 + else { float_x *= 10; } + + fixed_x = FLOAT_TO_FIXED(float_x); + fixed_x += delta_x; // reverse axis per ISp engineers + fixed_x /= (ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); + fixed_x = PIN(fixed_x, -FIXED_ONE/2, FIXED_ONE/2), fixed_x>>= 1, fixed_x*= (fixed_x<0) ? -fixed_x : fixed_x, fixed_x>>= 14; + + return fixed_x; +} + +Fixed sprocket_do_yaxis(Boolean running, long ticks_elapsed) +{ + ISpElementReference yLook = input_sprocket_elements[_input_sprocket_pitch]; + ISpElementReference yDelta = input_sprocket_elements[_input_sprocket_pitch_delta]; + fixed delta_y; + UInt32 int_y; + float float_y; + fixed fixed_y; + OSStatus err; + + err = ISpElement_GetSimpleState(yDelta, &delta_y); + if (err != noErr) { delta_y = 0; } // kISpDeltaMiddle + + delta_y *= PIXELS_PER_INCH; + + err = ISpElement_GetSimpleState(yLook, &int_y); + if (err != noErr) { int_y = kISpAxisMiddle; } + + int_y = axis_deadzone(int_y); + + /* float_x,float_y = -1 .. +1 */ + float_y = ((float)int_y - (float)kISpAxisMiddle) / (kISpAxisMiddle - DEAD_ZONE); + + /* non-linear & restore the sign */ + float_y *= float_y; /* square y */ + if (int_y < kISpAxisMiddle) { float_y = -float_y; } + + /* magnitude modification */ + if (running) { float_y *= 30; } // was 30 + else { float_y *= 10; } + + fixed_y = FLOAT_TO_FIXED(float_y); + fixed_y += delta_y; // reverse axis per ISp engineers + fixed_y /= (ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); + fixed_y = PIN(fixed_y, -FIXED_ONE/2, FIXED_ONE/2), fixed_y>>= 1, fixed_y*= (fixed_y<0) ? -fixed_y : fixed_y, fixed_y>>= 14; + + return fixed_y; +} + +#endif + /* take a snapshot of the current mouse state */ void mouse_idle( short type) @@ -115,44 +232,87 @@ void mouse_idle( long tick_count= TickCount(); long ticks_elapsed= tick_count-last_tick_count; - get_mouse_location(&where); - - center.h= CENTER_MOUSE_X, center.v= CENTER_MOUSE_Y; - set_mouse_location(center); - - if (ticks_elapsed) +#ifdef SUPPORT_INPUT_SPROCKET + if (use_input_sprocket) { - /* calculate axis deltas */ - fixed vx= INTEGER_TO_FIXED(where.h-center.h)/(ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); - fixed vy= - INTEGER_TO_FIXED(where.v-center.v)/(ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); - - /* pin and do nonlinearity */ - vx= PIN(vx, -FIXED_ONE/2, FIXED_ONE/2), vx>>= 1, vx*= (vx<0) ? -vx : vx, vx>>= 14; - vy= PIN(vy, -FIXED_ONE/2, FIXED_ONE/2), vy>>= 1, vy*= (vy<0) ? -vy : vy, vy>>= 14; -// vx= PIN(vx, -FIXED_ONE/2, FIXED_ONE/2); -// vy= PIN(vy, -FIXED_ONE/2, FIXED_ONE/2); - - snapshot_delta_yaw= vx; + OSStatus err; + ISpElementReference run_element = input_sprocket_elements[_input_sprocket_run_dont_walk]; + UInt32 running = 0; - switch (type) + if (ticks_elapsed) { - case _mouse_yaw_pitch: - snapshot_delta_pitch= vy, snapshot_delta_velocity= 0; - break; - case _mouse_yaw_velocity: - snapshot_delta_velocity= vy, snapshot_delta_pitch= 0; - break; - - default: - halt(); - } + err = ISpElement_GetSimpleState(run_element, &running); + if (err != noErr) { running = 0; } - snapshot_button_state= Button(); - last_tick_count= tick_count; + snapshot_delta_yaw = sprocket_do_xaxis(running, ticks_elapsed); + snapshot_delta_pitch = sprocket_do_yaxis(running, ticks_elapsed); + snapshot_delta_velocity = 0; + last_tick_count = tick_count; + + get_mouse_location(&where); + center.h= CENTER_MOUSE_X, center.v= CENTER_MOUSE_Y; + set_mouse_location(center); + + // if the cursor moved this must be a mouse input sprocket does not support + if ((where.h != center.h) || (where.v != center.v)) + { + /* calculate axis deltas */ // [-320 * FIXED_ONE, 320*FIXED_ONE] #define INTEGER_TO_FIXED(x) (x*FIXED_ONE) + fixed vx= INTEGER_TO_FIXED(where.h-center.h)/(ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); + fixed vy= - INTEGER_TO_FIXED(where.v-center.v)/(ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); -// dprintf("%08x %08x %08x;g;", snapshot_delta_yaw, snapshot_delta_pitch, snapshot_delta_velocity); + /* pin and do nonlinearity */ + vx= PIN(vx, -FIXED_ONE/2, FIXED_ONE/2), vx>>= 1, vx*= (vx<0) ? -vx : vx, vx>>= 14; + vy= PIN(vy, -FIXED_ONE/2, FIXED_ONE/2), vy>>= 1, vy*= (vy<0) ? -vy : vy, vy>>= 14; + + snapshot_delta_yaw = vx; + snapshot_delta_pitch = vy; + } + } } + else +#endif + { + get_mouse_location(&where); + + center.h= CENTER_MOUSE_X, center.v= CENTER_MOUSE_Y; + set_mouse_location(center); + + if (ticks_elapsed) + { + /* calculate axis deltas */ // [-320 * FIXED_ONE, 320*FIXED_ONE] #define INTEGER_TO_FIXED(x) (x*FIXED_ONE) + fixed vx= INTEGER_TO_FIXED(where.h-center.h)/(ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); + fixed vy= - INTEGER_TO_FIXED(where.v-center.v)/(ticks_elapsed*MAXIMUM_MOUSE_VELOCITY); + /* pin and do nonlinearity */ + vx= PIN(vx, -FIXED_ONE/2, FIXED_ONE/2), vx>>= 1, vx*= (vx<0) ? -vx : vx, vx>>= 14; + vy= PIN(vy, -FIXED_ONE/2, FIXED_ONE/2), vy>>= 1, vy*= (vy<0) ? -vy : vy, vy>>= 14; +// vx= PIN(vx, -FIXED_ONE/2, FIXED_ONE/2); +// vy= PIN(vy, -FIXED_ONE/2, FIXED_ONE/2); + + snapshot_delta_yaw= vx; + + switch (type) + { + case _mouse_yaw_pitch: +#ifdef SUPPORT_INPUT_SPROCKET + case _input_sprocket_yaw_pitch: +#endif + snapshot_delta_pitch= vy, snapshot_delta_velocity= 0; + break; + case _mouse_yaw_velocity: + snapshot_delta_velocity= vy, snapshot_delta_pitch= 0; + break; + + default: + halt(); + } + + snapshot_button_state= Button(); + last_tick_count= tick_count; + +// dprintf("%08x %08x %08x;g;", snapshot_delta_yaw, snapshot_delta_pitch, snapshot_delta_velocity); + } + } return; } @@ -182,7 +342,13 @@ static void set_mouse_location( { if (mouse_device) { +#ifdef NICK_KLEDZIK_IS_A_FUCKER +#if 0 + CursorDeviceMoveTo(mouse_device, where.h, where.v); +#else CrsrDevMoveTo(mouse_device, where.h, where.v); +#endif +#endif } #ifdef env68k else @@ -200,15 +366,24 @@ static CursorDevicePtr find_mouse_device( void) { CursorDevicePtr device= (CursorDevicePtr) NULL; - + +#ifdef NICK_KLEDZIK_IS_A_FUCKER if (trap_available(_CursorADBDispatch)) { do { +#if 0 + CursorDeviceNextDevice(&device); +#else CrsrDevNextDevice(&device); +#endif } - while (device && device->devClass!=kDeviceClassMouse && device->devClass!=kDeviceClassTrackball); + while (device && + device->devClass!=kDeviceClassMouse && + device->devClass!=kDeviceClassTrackball && + device->devClass!=kDeviceClassTrackPad); } +#endif return device; } diff --git a/marathon2/music.c b/marathon2/music.c index ae444cd..b21a1e9 100644 --- a/marathon2/music.c +++ b/marathon2/music.c @@ -165,7 +165,7 @@ void queue_song( assert(music_state->state==_no_song_playing); /* Must be done everytime in case Jason killed it in sound.c */ - music_state->channel->userInfo= music_state; + music_state->channel->userInfo= (long) music_state; music_state->song_index= song_index; music_state->state= _delaying_for_loop; music_state->phase= 1; @@ -208,7 +208,7 @@ void music_idle_proc( OSErr error; music_state->sound_buffer_size= kDefaultSoundBufferSize; - music_state->sound_buffer= malloc(music_state->sound_buffer_size); + music_state->sound_buffer= (Ptr)malloc(music_state->sound_buffer_size); if (music_state->sound_buffer) { assert(music_state->channel); @@ -398,7 +398,7 @@ static void allocate_music_channel( #include "world.h" #include "map.h" #include "shell.h" -#include "sound.h" +#include "game_sound.h" #include "preferences.h" /* Non reusable stuff */ diff --git a/marathon2/network.c b/marathon2/network.c index cf77884..6bb8524 100644 --- a/marathon2/network.c +++ b/marathon2/network.c @@ -755,7 +755,8 @@ boolean NetStart( if (topology->player_count > 2) { - qsort(topology->players+1, topology->player_count-1, sizeof(struct NetPlayer), net_compare); + qsort(topology->players+1, topology->player_count-1, sizeof(struct NetPlayer), + (int (*)(const void *, const void *)) net_compare); } NetUpdateTopology(); @@ -1366,7 +1367,7 @@ static void NetProcessLossyDistribution( NetPacketHeaderPtr header; NetDistributionPacketPtr packet_data; - packet_data = buffer; + packet_data = (NetDistributionPacketPtr)buffer; type = packet_data->distribution_type; if (distribution_info[type].type_in_use) @@ -1526,7 +1527,7 @@ static void NetProcessIncomingBuffer( { case typeSYNC_RING_PACKET: case typeTIME_RING_PACKET: - NetBuildRingPacket(ringFrame, buffer, NetPacketSize((NetPacketPtr) buffer), status->lastValidRingSequence+1); + NetBuildRingPacket(ringFrame, (byte *)buffer, NetPacketSize((NetPacketPtr) buffer), status->lastValidRingSequence+1); /* We acknowledge just before sending the ring frame.... */ NetSendAcknowledgement(ackFrame, status->lastValidRingSequence); NetSendRingPacket(ringFrame); @@ -1537,7 +1538,7 @@ static void NetProcessIncomingBuffer( /* time out. (important if one machine is slower than the others. */ if(netState==netComingDown) { - NetBuildRingPacket(ringFrame, buffer, NetPacketSize((NetPacketPtr) buffer), status->lastValidRingSequence+1); + NetBuildRingPacket(ringFrame, (byte *)buffer, NetPacketSize((NetPacketPtr) buffer), status->lastValidRingSequence+1); NetSendAcknowledgement(ackFrame, status->lastValidRingSequence); NetSendRingPacket(ringFrame); @@ -2108,7 +2109,7 @@ static void drop_upring_player( { short flag_count, index, oldNextPlayerIndex; long *action_flags; - NetPacketPtr packet_data= ringFrame->data + sizeof(NetPacketHeader); + NetPacketPtr packet_data= (NetPacketPtr) (ringFrame->data + sizeof(NetPacketHeader)); /* Reset the retries for the new packet. */ status->retries= 0; @@ -2216,7 +2217,7 @@ boolean NetChangeMap( // being the server, we must send out the map to everyone. if(localPlayerIndex==status->server_player_index) { - wad= get_map_for_net_transfer(entry); + wad= (byte *)get_map_for_net_transfer(entry); if(wad) { length= get_net_map_data_length(wad); @@ -2269,7 +2270,7 @@ static OSErr NetDistributeGameDataToAllPlayers( length_written= 0l; /* Get the physics crap. */ - physics_buffer= get_network_physics_buffer(&physics_length); + physics_buffer= (byte *)get_network_physics_buffer(&physics_length); // go ahead and transfer the map to each player for (playerIndex= 1; !error && playerIndexplayer_count; playerIndex++) @@ -2354,7 +2355,7 @@ static byte *NetReceiveGameData( set_progress_dialog_message(_receiving_physics); #ifdef NO_PHYSICS - physics_buffer= receive_stream_data(&physics_length, &error); + physics_buffer= (byte *)receive_stream_data(&physics_length, &error); #else physics_buffer= NULL; #endif @@ -2367,7 +2368,7 @@ static byte *NetReceiveGameData( /* receiving the map.. */ set_progress_dialog_message(_receiving_map); reset_progress_bar(); /* Reset the progress bar */ - map_buffer= receive_stream_data(&map_length, &error); + map_buffer= (byte *)receive_stream_data(&map_length, &error); } // close everything up. diff --git a/marathon2/network.h b/marathon2/network.h index 9fbe971..fd930bc 100644 --- a/marathon2/network.h +++ b/marathon2/network.h @@ -1,3 +1,6 @@ +#ifndef __NETWORK_H__ +#define __NETWORK_H__ + /* NETWORK.H Tuesday, June 21, 1994 3:26:46 PM @@ -122,3 +125,5 @@ void display_net_game_stats(void); short NetAddDistributionFunction(NetDistributionProc proc, boolean lossy); void NetDistributeInformation(short type, void *buffer, short buffer_size, boolean send_to_self); void NetRemoveDistributionFunction(short type); + +#endif \ No newline at end of file diff --git a/marathon2/network_ddp.c b/marathon2/network_ddp.c index d130301..a779d06 100644 --- a/marathon2/network_ddp.c +++ b/marathon2/network_ddp.c @@ -124,23 +124,28 @@ OSErr NetDDPOpenSocket( { if (packet_handler_upp == NULL) { - packet_handler_upp = (UniversalProcPtr) NewRoutineDescriptor(packetHandler, + packet_handler_upp = (UniversalProcPtr) NewRoutineDescriptor((ProcPtr) packetHandler, uppPacketHandlerProcInfo, GetCurrentISA()); } assert(packet_handler_upp); if (initialize_upp == NULL) { - initialize_upp = (UniversalProcPtr) NewRoutineDescriptor(initialize_socket_listener, + initialize_upp = (ProcPtr) NewRoutineDescriptor((ProcPtr) initialize_socket_listener, uppInitializeListenerProcInfo, kM68kISA); // it's in a 68k code resource } assert(initialize_upp); #ifdef env68k // it seems that we don't have CallUniversalProc() in the library. strange... + #ifndef VULCAN + socket_listener = (ProcPtr) initialize_socket_listener(packet_handler_upp, ddpPacketBuffer, 1); + #else + debugstr("Hey, socket listener was never initialized"); + #endif #else - socket_listener = (ProcPtr) CallUniversalProc(initialize_upp, uppInitializeListenerProcInfo, + socket_listener = (ProcPtr) CallUniversalProc((UniversalProcPtr) initialize_upp, uppInitializeListenerProcInfo, packet_handler_upp, ddpPacketBuffer, 1); #endif diff --git a/marathon2/network_dialogs.c b/marathon2/network_dialogs.c index 1c3427b..51feb54 100644 --- a/marathon2/network_dialogs.c +++ b/marathon2/network_dialogs.c @@ -55,7 +55,16 @@ struct network_speeds // This number needs to be changed whenever a change occurs in the networking code // that would make 2 versions incompatible, or a change in the game occurs that // would make 2 versions out of sync. -#define MARATHON_NETWORK_VERSION 9 +// changed to "10" for marathon infinity +// changed to "11" for Infinity Demo with InputSprocket support (to prevent play against old release) +// changed to "12" for Infinity Full with InputSprocket (Trilogy, forces upgrade to lose serial numbers) +#ifdef DEMO + #define MARATHON_NETWORK_VERSION 11 +#elif TRILOGY + #define MARATHON_NETWORK_VERSION 12 +#else + #define MARATHON_NETWORK_VERSION 10 +#endif #define fontTOP_LEVEL_FONT 130 #define menuZONES 1002 @@ -177,7 +186,10 @@ static void draw_beveled_text_box(boolean inset, Rect *box, short bevel_size, RG static void menu_index_to_level_entry(short index, long entry_flags, struct entry_point *entry); static void fill_in_entry_points(DialogPtr dialog, short item, long entry_flags, short default_level); +#ifndef VULCAN static MenuHandle get_popup_menu_handle(DialogPtr dialog, short item); +#endif + static void setup_dialog_for_game_type(DialogPtr dialog, short game_type); static void draw_player_box_with_team(Rect *rectangle, short player_index); @@ -189,6 +201,9 @@ static short get_game_duration_radio(DialogPtr dialog); static boolean key_is_down(short key_code); +static int menu_item_to_game_type(int menu_item); +static int game_type_to_menu_item(int game_type); + /* ---------- code */ extern void NetUpdateTopology(void); @@ -222,7 +237,7 @@ boolean network_gather( short current_zone_index, item_type; OSErr error; Cell cell; - short item_hit; + short item_hit= 0; zones_menu= GetMHandle(menuZONES); if (!zones_menu) @@ -243,7 +258,7 @@ boolean network_gather( GetDItem(dialog, iZONES_MENU, &item_type, &item_handle, &item_rectangle); SetCtlValue((ControlHandle) item_handle, current_zone_index); GetDItem(dialog, iNETWORK_LIST_BOX, &item_type, &item_handle, &item_rectangle); - setup_network_list_box(dialog, &item_rectangle, "\p*"); + setup_network_list_box(dialog, &item_rectangle, (char *)"\p*"); // we'll show either the zone list, or a text item "Players in Network:" HideDItem(dialog, internet ? iPLAYER_LIST_TEXT : iZONES_MENU); @@ -282,7 +297,7 @@ boolean network_gather( CheckItem(zones_menu, current_zone_index, FALSE); current_zone_index= GetCtlValue((ControlHandle) item_handle); CheckItem(zones_menu, current_zone_index, TRUE); - GetItem(zones_menu, current_zone_index, temporary); + GetItem(zones_menu, current_zone_index, (unsigned char *)temporary); GetDItem(dialog, iNETWORK_LIST_BOX, &item_type, &item_handle, &item_rectangle); setup_network_list_box(dialog, &item_rectangle, temporary); break; @@ -290,7 +305,7 @@ boolean network_gather( } while(item_hit!=iCANCEL && item_hit!=iOK); } else { /* Failed on NetGather */ - item_hit==iCANCEL; + item_hit= iCANCEL; } dispose_network_list_box(); @@ -353,14 +368,14 @@ boolean network_join( memcpy(myPlayerInfo.name, player_preferences->name, name_length+1); GetDItem(dialog, iJOIN_NAME, &item_type, &item_handle, &item_rect); - SetIText(item_handle, myPlayerInfo.name); + SetIText(item_handle, (StringPtr)myPlayerInfo.name); SelIText(dialog, iJOIN_NAME, 0, SHORT_MAX); modify_control(dialog, iJOIN_TEAM, CONTROL_ACTIVE, player_preferences->team+1); modify_control(dialog, iJOIN_COLOR, CONTROL_ACTIVE, player_preferences->color+1); if (myPlayerInfo.name[0] == 0) modify_control(dialog, iOK, CONTROL_INACTIVE, NONE); GetDItem(dialog, iJOIN_MESSAGES, &item_type, &item_handle, &item_rect); - SetIText(item_handle, getpstr(temporary, strJOIN_DIALOG_MESSAGES, _join_dialog_welcome_string)); + SetIText(item_handle, (StringPtr)getpstr(temporary, strJOIN_DIALOG_MESSAGES, _join_dialog_welcome_string)); #ifdef USE_MODEM /* Adjust the transport layer using what's available */ @@ -381,7 +396,7 @@ boolean network_join( case iJOIN: SetPort(dialog); GetDItem(dialog, iJOIN_NAME, &item_type, &item_handle, &item_rect); - GetIText(item_handle, temporary); + GetIText(item_handle, (StringPtr)temporary); if (*temporary > MAX_NET_PLAYER_NAME_LENGTH) *temporary = MAX_NET_PLAYER_NAME_LENGTH; pstrcpy(myPlayerInfo.name, temporary); GetDItem(dialog, iJOIN_TEAM, &item_type, &item_handle, &item_rect); @@ -392,7 +407,7 @@ boolean network_join( memcpy(myPlayerInfo.long_serial_number, serial_preferences->long_serial_number, 10); SetCursor(*GetCursor(watchCursor)); - did_join= NetGameJoin(myPlayerInfo.name, PLAYER_TYPE, (void *) &myPlayerInfo, sizeof(myPlayerInfo), + did_join= NetGameJoin(myPlayerInfo.name, (char *)PLAYER_TYPE, (void *) &myPlayerInfo, sizeof(myPlayerInfo), MARATHON_NETWORK_VERSION); SetCursor(&qd.arrow); @@ -417,7 +432,7 @@ boolean network_join( write_preferences(); GetDItem(dialog, iJOIN_MESSAGES, &item_type, &item_handle, &item_rect); - SetIText(item_handle, getpstr(temporary, strJOIN_DIALOG_MESSAGES, _join_dialog_waiting_string)); + SetIText(item_handle, (StringPtr)getpstr(temporary, strJOIN_DIALOG_MESSAGES, _join_dialog_waiting_string)); } else { /* If you fail in joining the game, print the error and return */ /* to the main menu (this is primarily for modem) */ @@ -453,7 +468,7 @@ boolean network_join( if (accepted_into_game) { successful= TRUE; - myGameInfo= NetGetGameData(); + myGameInfo= (game_info *)NetGetGameData(); NetSetInitialParameters(myGameInfo->initial_updates_per_packet, myGameInfo->initial_update_latency); } else @@ -547,7 +562,7 @@ boolean network_game_setup( { short new_game_type; - new_game_type= get_dialog_control_value(dialog, iGAME_TYPE)-1; + new_game_type= menu_item_to_game_type(get_dialog_control_value(dialog, iGAME_TYPE)); if(new_game_type != game_information->net_game_type) { @@ -632,7 +647,7 @@ static short fill_in_game_setup_dialog( } fill_in_entry_points(dialog, iENTRY_MENU, entry_flags, NONE); - modify_control(dialog, iGAME_TYPE, CONTROL_ACTIVE, network_preferences->game_type+1); + modify_control(dialog, iGAME_TYPE, CONTROL_ACTIVE, game_type_to_menu_item(network_preferences->game_type)); setup_dialog_for_game_type(dialog, network_preferences->game_type); net_game_type= network_preferences->game_type; @@ -642,7 +657,7 @@ static short fill_in_game_setup_dialog( memcpy(player_information->name, player_preferences->name, name_length+1); GetDItem(dialog, iGATHER_NAME, &item_type, &item_handle, &item_rect); - SetIText(item_handle, player_information->name); + SetIText(item_handle, (StringPtr)player_information->name); SelIText(dialog, iGATHER_NAME, 0, SHORT_MAX); /* Set the menu values */ @@ -755,7 +770,7 @@ static void extract_setup_dialog_information( // get player information GetDItem(dialog, iGATHER_NAME, &item_type, &item_handle, &item_rect); - GetIText(item_handle, temporary); + GetIText(item_handle, (StringPtr)temporary); if (*temporary > MAX_NET_PLAYER_NAME_LENGTH) *temporary = MAX_NET_PLAYER_NAME_LENGTH; pstrcpy(player_information->name, temporary); @@ -767,7 +782,7 @@ static void extract_setup_dialog_information( player_preferences->team= player_information->team; game_information->server_is_playing = TRUE; - game_information->net_game_type= get_dialog_control_value(dialog, iGAME_TYPE)-1; + game_information->net_game_type= menu_item_to_game_type(get_dialog_control_value(dialog, iGAME_TYPE)); // get game information game_information->game_options= get_dialog_game_options(dialog, game_information->net_game_type); @@ -900,7 +915,7 @@ static void fill_in_entry_points( menu_index++; if(entry.level_name[0]) { - SetItem(menu, menu_index, entry.level_name); + SetItem(menu, menu_index, (StringPtr)entry.level_name); } if(entry.level_number==default_level) @@ -988,7 +1003,7 @@ boolean check_setup_information( else { GetDItem(dialog, iGATHER_NAME, &item_type, &item_handle, &item_rect); - GetIText(item_handle, temporary); + GetIText(item_handle, (StringPtr)temporary); if (*temporary == 0) { bad_item = iGATHER_NAME; @@ -1228,12 +1243,12 @@ static pascal Boolean join_dialog_filter_proc( case netPlayerAdded: if(last_join_state==netWaiting) { - game_info *info= NetGetGameData(); + game_info *info= (game_info *)NetGetGameData(); GetDItem(dialog, iJOIN_MESSAGES, &item_type, &item_handle, &item_rect); get_network_joined_message(temporary, info->net_game_type); c2pstr(temporary); - SetIText(item_handle, temporary); + SetIText(item_handle, (StringPtr)temporary); } update_player_list_item(dialog, iPLAYER_DISPLAY_AREA); break; @@ -1249,7 +1264,7 @@ static pascal Boolean join_dialog_filter_proc( last_join_state= join_state; GetDItem(dialog, iJOIN_NAME, &item_type, &item_handle, &item_rect); - GetIText(item_handle, temporary); + GetIText(item_handle, (StringPtr)temporary); if (join_state == NONE && *temporary) modify_control(dialog, iOK, CONTROL_ACTIVE, NONE); else @@ -1271,7 +1286,7 @@ static pascal Boolean game_setup_filter_proc( EventRecord *event, short *item_hit) { - #pragma unused(event, item_hit); + #pragma unused(event, item_hit) Rect item_rect; short item_type; @@ -1281,7 +1296,7 @@ static pascal Boolean game_setup_filter_proc( GetPort(&old_port); SetPort(dialog); GetDItem(dialog, iGATHER_NAME, &item_type, &item_handle, &item_rect); - GetIText(item_handle, temporary); + GetIText(item_handle, (StringPtr)temporary); if (*temporary) modify_control(dialog, iOK, CONTROL_ACTIVE, NONE); else @@ -1331,7 +1346,7 @@ static void setup_network_list_box( } /* spawn an asynchronous network name lookup */ - error= NetLookupOpen("\p=", PLAYER_TYPE, zone, MARATHON_NETWORK_VERSION, + error= NetLookupOpen((char *)"\p=", (char *)PLAYER_TYPE, zone, MARATHON_NETWORK_VERSION, network_list_box_update_proc, NetEntityNotInGame); if (error!=noErr) dprintf("NetLookupOpen() returned %d", error); @@ -1470,7 +1485,7 @@ static void reassign_player_colors( #pragma unused(player_index) assert(num_players<=MAXIMUM_NUMBER_OF_PLAYERS); - game= NetGetGameData(); + game= (game_info *)NetGetGameData(); memset(colors_taken, FALSE, sizeof(colors_taken)); memset(actual_colors, NONE, sizeof(actual_colors)); @@ -1481,7 +1496,7 @@ static void reassign_player_colors( for(index= 0; indexdesired_color]) { player->color= player->desired_color; @@ -1494,7 +1509,7 @@ static void reassign_player_colors( /* Now give them a random color.. */ for (index= 0; indexteam==team_color && !colors_taken[player->desired_color]) { @@ -1536,7 +1551,7 @@ static void reassign_player_colors( // ok, everyone remaining gets a team that we pick for them. for (index = 0; index < num_players; index++) { - player_info *player= NetGetPlayerData(index); + player_info *player= (player_info *)NetGetPlayerData(index); if (player->team==team_color && actual_colors[index]==NONE) // This player needs a team { @@ -1586,6 +1601,7 @@ static void menu_index_to_level_entry( return; } +#ifndef VULCAN static MenuHandle get_popup_menu_handle( DialogPtr dialog, short item) @@ -1608,6 +1624,7 @@ static MenuHandle get_popup_menu_handle( return menu; } +#endif #ifdef TEST_NET_STATS_DIALOG static void fake_initialize_stat_data(void) @@ -1647,11 +1664,11 @@ static void setup_dialog_for_game_type( GetDItem(dialog, iRADIO_KILL_LIMIT, &item_type, &item, &bounds); getpstr(temporary, strSETUP_NET_GAME_MESSAGES, killLimitString); - SetCTitle((ControlHandle) item, temporary); + SetCTitle((ControlHandle) item, (StringPtr)temporary); GetDItem(dialog, iTEXT_KILL_LIMIT, &item_type, &item, &bounds); getpstr(temporary, strSETUP_NET_GAME_MESSAGES, killsString); - SetIText(item, temporary); + SetIText(item, (StringPtr)temporary); /* Untimed.. */ setup_for_untimed_game(dialog); @@ -1666,11 +1683,11 @@ static void setup_dialog_for_game_type( GetDItem(dialog, iRADIO_KILL_LIMIT, &item_type, &item, &bounds); getpstr(temporary, strSETUP_NET_GAME_MESSAGES, killLimitString); - SetCTitle((ControlHandle) item, temporary); + SetCTitle((ControlHandle) item, (StringPtr)temporary); GetDItem(dialog, iTEXT_KILL_LIMIT, &item_type, &item, &bounds); getpstr(temporary, strSETUP_NET_GAME_MESSAGES, killsString); - SetIText(item, temporary); + SetIText(item, (StringPtr)temporary); setup_for_timed_game(dialog); break; @@ -1682,11 +1699,11 @@ static void setup_dialog_for_game_type( GetDItem(dialog, iRADIO_KILL_LIMIT, &item_type, &item, &bounds); getpstr(temporary, strSETUP_NET_GAME_MESSAGES, flagPullsString); - SetCTitle((ControlHandle) item, temporary); + SetCTitle((ControlHandle) item, (StringPtr)temporary); GetDItem(dialog, iTEXT_KILL_LIMIT, &item_type, &item, &bounds); getpstr(temporary, strSETUP_NET_GAME_MESSAGES, flagsString); - SetIText(item, temporary); + SetIText(item, (StringPtr)temporary); setup_for_timed_game(dialog); break; @@ -1698,11 +1715,11 @@ static void setup_dialog_for_game_type( GetDItem(dialog, iRADIO_KILL_LIMIT, &item_type, &item, &bounds); getpstr(temporary, strSETUP_NET_GAME_MESSAGES, pointLimitString); - SetCTitle((ControlHandle) item, temporary); + SetCTitle((ControlHandle) item, (StringPtr)temporary); GetDItem(dialog, iTEXT_KILL_LIMIT, &item_type, &item, &bounds); getpstr(temporary, strSETUP_NET_GAME_MESSAGES, pointsString); - SetIText(item, temporary); + SetIText(item, (StringPtr)temporary); setup_for_timed_game(dialog); break; @@ -1796,7 +1813,7 @@ static void draw_player_box_with_team( text_box= *rectangle; InsetRect(&text_box, NAME_BEVEL_SIZE, NAME_BEVEL_SIZE); pstrcpy(temporary, player->name); - p2cstr(temporary); + p2cstr((StringPtr)temporary); _draw_screen_text(temporary, (screen_rectangle *) &text_box, _center_horizontal|_center_vertical, _net_stats_font, _white_color); @@ -1983,7 +2000,8 @@ void display_net_game_stats( /* Calculate the rankings (once) for the entire graph */ calculate_rankings(rankings, dynamic_world->player_count); - qsort(rankings, dynamic_world->player_count, sizeof(struct net_rank), rank_compare); + qsort(rankings, dynamic_world->player_count, sizeof(struct net_rank), + (int (*)(const void *, const void *)) rank_compare); /* Create the graph popup menu */ current_graph_selection= create_graph_popup_menu(dialog, iGRAPH_POPUP); @@ -2059,14 +2077,14 @@ static short create_graph_popup_menu( strcpy(temporary, player->name); c2pstr(temporary); AppendMenu(graph_popup, "\p "); - SetItem(graph_popup, index+1, temporary); // +1 since it is 1's based + SetItem(graph_popup, index+1, (StringPtr)temporary); // +1 since it is 1's based } /* Add in the separator line */ AppendMenu(graph_popup, "\p-"); /* Add in the total carnage.. */ - AppendMenu(graph_popup, getpstr(temporary, strNET_STATS_STRINGS, strTOTALS_STRING)); + AppendMenu(graph_popup, (StringPtr)getpstr(temporary, strNET_STATS_STRINGS, strTOTALS_STRING)); current_graph_selection= CountMItems(graph_popup); /* Add in the scores */ @@ -2074,7 +2092,7 @@ static short create_graph_popup_menu( if(has_scores) { c2pstr(temporary); - AppendMenu(graph_popup, temporary); + AppendMenu(graph_popup, (StringPtr)temporary); current_graph_selection= CountMItems(graph_popup); } @@ -2084,13 +2102,13 @@ static short create_graph_popup_menu( /* Separator line */ if(has_scores) AppendMenu(graph_popup, "\p-"); - AppendMenu(graph_popup, getpstr(temporary, strNET_STATS_STRINGS, strTEAM_TOTALS_STRING)); + AppendMenu(graph_popup, (StringPtr)getpstr(temporary, strNET_STATS_STRINGS, strTEAM_TOTALS_STRING)); if(has_scores) { get_network_score_text_for_postgame(temporary, TRUE); c2pstr(temporary); - AppendMenu(graph_popup, temporary); + AppendMenu(graph_popup, (StringPtr)temporary); } } @@ -2625,7 +2643,7 @@ static void draw_kill_bars( getcstr(kill_string_format, strNET_STATS_STRINGS, strTOTAL_KILLS_STRING); psprintf(temporary, kill_string_format, total_kills, kpm); GetDItem(dialog, iTOTAL_KILLS, &item_type, &item_handle, &item_rect); - SetIText(item_handle, temporary); + SetIText(item_handle, (StringPtr)temporary); if (minutes > 0) dpm = total_deaths / minutes; else dpm = 0; @@ -2643,7 +2661,7 @@ static void draw_kill_bars( else psprintf(temporary, death_string_format, total_deaths, dpm); GetDItem(dialog, iTOTAL_DEATHS, &item_type, &item_handle, &item_rect); - SetIText(item_handle, temporary); + SetIText(item_handle, (StringPtr)temporary); return; } @@ -2688,9 +2706,10 @@ static void draw_beveled_text_box( color = inset || !name_box ? _black_color : _white_color; inset_box = *box; InsetRect(&inset_box, bevel_size, bevel_size); + text_box.top = inset_box.top; text_box.bottom = inset_box.bottom; text_box.left = inset_box.left; text_box.right = inset_box.right; - _draw_screen_text(text, &text_box, flags, _net_stats_font, color); + _draw_screen_text(text, &text_box, flags, _net_stats_font, color); } static void draw_beveled_box( @@ -2872,7 +2891,7 @@ static void draw_team_totals_graph( { ranks[team_index].ranking= ranks[team_index].kills - ranks[team_index].deaths; } - qsort(ranks, num_teams, sizeof(struct net_rank), team_rank_compare); + qsort(ranks, num_teams, sizeof(struct net_rank), (int (*)(const void *, const void *)) team_rank_compare); draw_names(dialog, ranks, num_teams, NONE); draw_kill_bars(dialog, ranks, num_teams, NONE, TRUE, TRUE); @@ -2889,7 +2908,8 @@ static void draw_total_scores_graph( memcpy(ranks, rankings, dynamic_world->player_count*sizeof(struct net_rank)); /* First qsort the rankings arrray by game_ranking.. */ - qsort(ranks, dynamic_world->player_count, sizeof(struct net_rank), score_rank_compare); + qsort(ranks, dynamic_world->player_count, sizeof(struct net_rank), + (int (*)(const void *, const void *)) score_rank_compare); /* Draw the names. */ draw_names(dialog, ranks, dynamic_world->player_count, NONE); @@ -2930,7 +2950,7 @@ static void draw_team_total_scores_graph( } /* Now qsort our team stuff. */ - qsort(ranks, team_count, sizeof(struct net_rank), score_rank_compare); + qsort(ranks, team_count, sizeof(struct net_rank), (int (*)(const void *, const void *)) score_rank_compare); /* And draw the bars.. */ draw_names(dialog, ranks, team_count, NONE); @@ -2947,7 +2967,7 @@ static void calculate_maximum_bar( GetDItem(dialog, iDAMAGE_STATS, &item_type, &item_handle, &item_rect); kill_bar_rect->left = item_rect.left + GRAPH_LEFT_INSET + NAME_BOX_WIDTH + GRAPH_BAR_SPACING; - kill_bar_rect->right = item_rect.right - GRAPH_RIGHT_INSET - kill_bar_rect->left; + kill_bar_rect->right = item_rect.right - GRAPH_RIGHT_INSET; kill_bar_rect->top = item_rect.top + GRAPH_TOP_INSET; kill_bar_rect->bottom = kill_bar_rect->top + NAME_BOX_HEIGHT; } @@ -2959,6 +2979,7 @@ static void draw_score_bars( { short index, maximum_width; long highest_ranking= LONG_MIN; + long lowest_ranking= LONG_MAX; Rect maximum_bar, bar; RGBColor color; short item_type; @@ -2967,6 +2988,7 @@ static void draw_score_bars( for(index= 0; indexhighest_ranking) highest_ranking= ranks[index].game_ranking; + if(ranks[index].game_ranking (bar.right - bar.left - (NAME_BEVEL_SIZE * 2))) + { + screen_rectangle text_box; + + text_box.left = bar.right + RANKING_INSET; + text_box.right = bar.right + 1000; // out to the moon + text_box.top = bar.top; + text_box.bottom = bar.bottom; + draw_beveled_box(FALSE, &bar, NAME_BEVEL_SIZE, &color); + _draw_screen_text(temporary, &text_box, _center_vertical, _net_stats_font, _black_color); + } + else + { /* Draw it! */ draw_beveled_text_box(FALSE, &bar, NAME_BEVEL_SIZE, &color, temporary, _right_justified|_center_vertical, FALSE); - - OffsetRect(&bar, 0, NAME_BOX_HEIGHT + GRAPH_BAR_SPACING); } + + OffsetRect(&bar, 0, NAME_BOX_HEIGHT + GRAPH_BAR_SPACING); } /* And clear the text. */ GetDItem(dialog, iTOTAL_DEATHS, &item_type, &item_handle, &bar); - SetIText(item_handle, ""); + SetIText(item_handle, (StringPtr)""); GetDItem(dialog, iTOTAL_KILLS, &item_type, &item_handle, &bar); - SetIText(item_handle, ""); + SetIText(item_handle, (StringPtr)""); } static boolean will_new_mode_reorder_dialog( @@ -3160,6 +3201,24 @@ static boolean key_is_down( { KeyMap key_map; - GetKeys(&key_map); + GetKeys(key_map); return ((((byte*)key_map)[key_code>>3] >> (key_code & 7)) & 1); } + +static int menu_item_to_game_type( + int menu_item) +{ + int table[]= { _game_of_kill_monsters, _game_of_cooperative_play, /* _game_of_capture_the_flag, */ + _game_of_king_of_the_hill, _game_of_kill_man_with_ball, /* _game_of_defense, */ + /* _game_of_rugby, */ _game_of_tag }; + + return table[menu_item-1]; +} + +static int game_type_to_menu_item( + int game_type) +{ + int table[]= { 1, 2, NONE, 3, 4, NONE, NONE, 5 }; + + return table[game_type]; +} diff --git a/marathon2/network_games.c b/marathon2/network_games.c index d99e682..0c9dcdb 100644 --- a/marathon2/network_games.c +++ b/marathon2/network_games.c @@ -12,7 +12,7 @@ #include "monsters.h" #include "network_games.h" #include "game_window.h" // for mark_player_network_stats_as_dirty -#include "sound.h" +#include "game_sound.h" /* ----------- #defines */ #define SINGLE_BALL_COLOR (1) @@ -255,6 +255,11 @@ boolean player_killed_player( if (dynamic_world->game_player_index!=dead_player_index) { // change of ‘it’ +#if 1 + struct player_data *player= get_player_data(dead_player_index); + + play_object_sound(player->object_index, _snd_you_are_it); +#endif dynamic_world->game_player_index= dead_player_index; } } @@ -290,6 +295,7 @@ boolean update_net_game( /* These games have no housekeeping associated with them. */ break; +#if 0 case _game_of_capture_the_flag: for(player_index= 0; player_indexplayer_count; ++player_index) { @@ -308,7 +314,8 @@ boolean update_net_game( } } break; - +#endif + case _game_of_king_of_the_hill: for(player_index= 0; player_indexplayer_count; ++player_index) { @@ -558,10 +565,6 @@ boolean get_network_score_text_for_postgame( string_id= flagsCapturedString; break; - case _game_of_rugby: - string_id= goalsString; - break; - case _game_of_king_of_the_hill: string_id= reignString; break; @@ -703,6 +706,7 @@ boolean game_is_over( } break; +#if 0 case _game_of_capture_the_flag: /* Kill limit is the number of flag pulls */ for(player_index= 0; player_indexplayer_count; ++player_index) @@ -734,6 +738,7 @@ boolean game_is_over( game_over= TRUE; } break; +#endif case _game_of_defense: //•• @@ -863,4 +868,4 @@ static void destroy_players_ball( /* Mark the player inventory as dirty.. */ mark_player_inventory_as_dirty(player_index, _i_knife); -} \ No newline at end of file +} diff --git a/marathon2/network_lookup.c b/marathon2/network_lookup.c index 15e0604..fa34b93 100644 --- a/marathon2/network_lookup.c +++ b/marathon2/network_lookup.c @@ -28,7 +28,7 @@ Wednesday, October 19, 1994 3:50:46 PM (Jason') #define NAMES_LIST_BUFFER_SIZE 4096 #define MAXIMUM_LOOKUP_NAME_COUNT 40 -#define MAXIMUM_ZONE_NAMES 400 +#define MAXIMUM_ZONE_NAMES 1000 /* ---------- structures */ @@ -93,9 +93,9 @@ OSErr NetLookupOpen( assert(!lookupMPPPBPtr); /* Note that this utilizes the mac extension for pstrings.. */ - sprintf(type_with_version, "%P%d", type, version); - assert(strlen(type_with_version)<32); - c2pstr(type_with_version); + sprintf((char *)type_with_version, "%P%d", type, version); + assert(strlen((const char *)type_with_version)<32); + c2pstr((char *)type_with_version); /* Type is pstring */ lookupMPPPBPtr= (MPPPBPtr) NewPtrClear(sizeof(MPPParamBlock)); @@ -106,7 +106,7 @@ OSErr NetLookupOpen( error= MemError(); if (error==noErr) { - NBPSetEntity((Ptr)lookupEntity, name, type_with_version, zone); + NBPSetEntity((Ptr)lookupEntity, (StringPtr)name, type_with_version, (StringPtr)zone); lookupMPPPBPtr->NBP.interval= 4; /* 4*8 ticks == 32 ticks */ lookupMPPPBPtr->NBP.count= 2; /* 2 retries == 64 ticks */ lookupMPPPBPtr->NBP.ioCompletion= (XPPCompletionUPP) NULL; /* no completion routine */ @@ -357,7 +357,7 @@ OSErr NetGetZonePopupMenu( for (i= 0; iXCALL.zipNumZones && *zone_countmilliseconds= 0; pb->bufferLength= NETWORK_SOUND_CHUNK_BUFFER_SIZE; pb->bufferPtr= net_microphone.buffer; - pb->completionRoutine= net_microphone.completion_proc; + pb->completionRoutine= (SICompletionUPP) net_microphone.completion_proc; /* Respawn the recording! */ pb->error= SPBRecord(pb, TRUE); @@ -381,6 +386,7 @@ static pascal void sound_recording_completed( break; default: + dprintf("SPBRecord()==#%d", pb->error); break; } diff --git a/marathon2/network_modem.c b/marathon2/network_modem.c index 05c4d01..aedb30e 100644 --- a/marathon2/network_modem.c +++ b/marathon2/network_modem.c @@ -283,16 +283,16 @@ static ConnHandle instantiate_connection_record( ConnHandle connection; Str255 tool_name; - load_connection_tool_name_from_preferences(tool_name); + load_connection_tool_name_from_preferences((char *)tool_name); procID= CMGetProcID(tool_name); if(procID==NONE) { OSErr err; - err= CRMGetIndToolName(classCM, 1, temporary); + err= CRMGetIndToolName(classCM, 1, (StringPtr)temporary); if(!err) { - procID= CMGetProcID(temporary); + procID= CMGetProcID((StringPtr)temporary); } } @@ -458,7 +458,7 @@ static void save_connection_preferences( static void load_connection_tool_name_from_preferences( char *name) { - strcpy(name, "\pSerial Tool"); + strcpy(name, (char *)"\pSerial Tool"); return; } diff --git a/marathon2/network_modem_protocol.c b/marathon2/network_modem_protocol.c index 1399a02..5b0f386 100644 --- a/marathon2/network_modem_protocol.c +++ b/marathon2/network_modem_protocol.c @@ -220,7 +220,7 @@ struct player_packet_data { struct server_packet_data { unsigned long sequence; - long flags[0]; // this is actually number_of_players flags.... + long flags[1]; // this is actually number_of_players flags.... }; /* @@ -526,7 +526,7 @@ short ModemAddDistributionFunction( NetDistributionProc proc, boolean lossy) { -#pragma unused(proc, lossy); +#pragma unused(proc, lossy) return NONE; } @@ -536,14 +536,14 @@ void ModemDistributeInformation( short buffer_size, boolean send_to_self) { -#pragma unused(type, buffer, buffer_size, send_to_self); +#pragma unused(type, buffer, buffer_size, send_to_self) return; } void ModemRemoveDistributionFunction( short type) { -#pragma unused(type); +#pragma unused(type) return; } @@ -575,7 +575,7 @@ boolean ModemGatherPlayer( boolean success= FALSE; long initial_tick_count= machine_tick_count(); -#pragma unused (player_index); +#pragma unused (player_index) assert(modemState==netGathering); assert(topology->player_countlocalPlayerIndex==status->server_player_index) { - wad= get_map_for_net_transfer(entry); + wad= (byte *)get_map_for_net_transfer(entry); if(wad) { length= get_net_map_data_length(wad); @@ -890,8 +890,8 @@ short ModemUpdateJoinState( got_packet= modem_read_packet(&packet_type, packet_buffers[_incoming_packet]); if(got_packet) { - struct join_player_data *packet= packet_buffers[_incoming_packet]; - struct accept_join_data *accept_packet= packet_buffers[_outgoing_packet]; + struct join_player_data *packet= (struct join_player_data *)packet_buffers[_incoming_packet]; + struct accept_join_data *accept_packet= (struct accept_join_data *)packet_buffers[_outgoing_packet]; switch(packet_type) { @@ -1182,7 +1182,7 @@ static void build_server_packet( static void handle_single_player( void) { - struct server_packet_data *packet_data= packet_buffers[_incoming_packet]; + struct server_packet_data *packet_data= (struct server_packet_data *)packet_buffers[_incoming_packet]; packet_data->sequence= status->sequence; packet_data->flags[status->localPlayerIndex]= parse_keymap(); @@ -1252,7 +1252,7 @@ static short server_packet_size( short size; assert(topology); - size= sizeof(struct server_packet_data)+(topology->player_count*sizeof(long)); + size= sizeof(struct server_packet_data)-sizeof(long)+(topology->player_count*sizeof(long)); return size; } @@ -1363,7 +1363,7 @@ static OSErr send_acknowledged_packet( got_packet= modem_read_packet(&packet_type, packet_buffers[_incoming_packet]); if(got_packet && packet_type==_acknowledge_packet) { - struct acknowledge_packet *packet= packet_buffers[_incoming_packet]; + struct acknowledge_packet *packet= (struct acknowledge_packet *)packet_buffers[_incoming_packet]; // if(packet->sequence==ACKNOWLEDGE_ACTION_FLAG) done= TRUE; @@ -1393,7 +1393,7 @@ static OSErr modem_send_packet( header.packet_type= packet_type; header.checksum= 0; - data= buffer; + data= (byte *)buffer; for(index= 0; index=0) @@ -1719,7 +1719,7 @@ static OSErr send_stream_data_with_progress( #endif for(sequence= 0, error= noErr, timed_out= FALSE; sequencesequence==sequence) { @@ -1809,7 +1809,7 @@ static long receive_stream_size( got_packet= modem_read_packet(&packet_type, packet_buffers[_incoming_packet]); if (got_packet && packet_type==_stream_size_packet) { - struct stream_size_packet *packet= packet_buffers[_incoming_packet]; + struct stream_size_packet *packet= (struct stream_size_packet *)packet_buffers[_incoming_packet]; /* Acknowledge the first map packet.. */ send_acknowledge(0l); @@ -1850,7 +1850,7 @@ static OSErr receive_stream_data_with_progress( got_packet= modem_read_packet(&packet_type, packet_buffers[_incoming_packet]); if(got_packet && packet_type==_stream_packet) { - struct stream_packet_data *data_packet= packet_buffers[_incoming_packet]; + struct stream_packet_data *data_packet= (struct stream_packet_data *)packet_buffers[_incoming_packet]; /* Acknowledge this sequence...*/ if(data_packet->sequence==sequence || data_packet->sequenceaction_flag= parse_keymap(); packet->sequence= status->sequence; *packet_type= _client_packet; @@ -2161,7 +2161,7 @@ static boolean modem_read_fake_packet( /* Create fake server packet.. */ struct server_packet_data *packet; - packet= data; + packet= (struct server_packet_data *)data; packet->sequence= status->sequence; packet->flags[0]= parse_keymap(); packet->flags[1]= parse_keymap(); @@ -2225,7 +2225,7 @@ boolean packet_tickler( /* If we are the server... */ if(status->server_player_index==status->localPlayerIndex) { - struct player_packet_data *player_packet= packet_buffers[_incoming_packet]; + struct player_packet_data *player_packet= (struct player_packet_data *)packet_buffers[_incoming_packet]; /* Process the packet.. */ if(status->sequence==player_packet->sequence) @@ -2287,7 +2287,7 @@ boolean packet_tickler( case _server_packet: if(status->server_player_index != status->localPlayerIndex) { - struct server_packet_data *packet_data= packet_buffers[_incoming_packet]; + struct server_packet_data *packet_data= (struct server_packet_data *)packet_buffers[_incoming_packet]; #ifdef DEBUG_MODEM modem_stats.server_packets_received++; @@ -2418,8 +2418,8 @@ static boolean network_queueing_task( static void build_and_post_async_client_packet( unsigned long sequence) { - struct stream_header *header= packet_buffers[_outgoing_packet]; - struct player_packet_data *packet= ((byte *) packet_buffers[_outgoing_packet]+sizeof(struct stream_header)); + struct stream_header *header= (struct stream_header *)packet_buffers[_outgoing_packet]; + struct player_packet_data *packet= (struct player_packet_data *) ((byte *) packet_buffers[_outgoing_packet]+sizeof(struct stream_header)); short index; byte *data; @@ -2447,8 +2447,8 @@ static void build_and_post_async_client_packet( static void build_and_post_async_server_packet( void) { - struct server_packet_data *server_packet= ((byte *) packet_buffers[_outgoing_packet]+sizeof(struct stream_header)); - struct stream_header *header= packet_buffers[_outgoing_packet]; + struct server_packet_data *server_packet= (struct server_packet_data *) ((byte *) packet_buffers[_outgoing_packet]+sizeof(struct stream_header)); + struct stream_header *header= (struct stream_header *)packet_buffers[_outgoing_packet]; byte *data; short index; diff --git a/marathon2/network_names.c b/marathon2/network_names.c index f4bfb63..9f78735 100644 --- a/marathon2/network_names.c +++ b/marathon2/network_names.c @@ -50,6 +50,7 @@ OSErr NetRegisterName( short version, short socketNumber) { + Handle user_name= (Handle)GetString(strUSER_NAME); MPPPBPtr myMPPPBPtr= (MPPPBPtr) NewPtrClear(sizeof(MPPParamBlock)); Str255 adjusted_name; Str255 adjusted_type; @@ -66,12 +67,17 @@ OSErr NetRegisterName( myNTEName= (NamesTableEntryPtr) NewPtrSysClear(sizeof(NamesTableEntry)); assert(myNTEName); - /* get user name if no object name was supplied*/ - pstrcpy(adjusted_name, name ? name : *GetString(strUSER_NAME)); + /* get user name if no object name was supplied */ + pstrcpy((char *)adjusted_name, name ? name : (user_name ? *user_name : "\p")); /* Calculate the adjusted type */ - sprintf(adjusted_type, "%P%d", type, version); - c2pstr(adjusted_type); + { + Str255 version_text; + + psprintf((char *)version_text, "%d", version); + pstrcpy((char *)adjusted_type, (char *)type); + pstrcat(adjusted_type, version_text); + } error= MemError(); if (error==noErr) diff --git a/marathon2/network_speaker.c b/marathon2/network_speaker.c index d1e2982..d67b246 100644 --- a/marathon2/network_speaker.c +++ b/marathon2/network_speaker.c @@ -19,7 +19,7 @@ Sunday, August 14, 1994 1:20:55 AM /* ---------- constants */ -#define MAXIMUM_DOUBLE_BUFFER_SIZE 1024 +#define MAXIMUM_DOUBLE_BUFFER_SIZE (2*NETWORK_SOUND_CHUNK_BUFFER_SIZE) #define MAXIMUM_QUEUE_SIZE (3*MAXIMUM_DOUBLE_BUFFER_SIZE) enum /* speaker states */ @@ -53,6 +53,10 @@ struct speaker_definition static struct speaker_definition *speaker= (struct speaker_definition *) NULL; static SndDoubleBackUPP doubleback_routine_descriptor; +#ifdef DEBUG +static int queue_being_emptied= 0; +#endif + /* ---------- private code */ static void fill_buffer_with_static(byte *buffer, short count); @@ -116,7 +120,8 @@ OSErr open_network_speaker( speaker->channel->userInfo= (long) get_a5(); #endif - error= SndNewChannel(&speaker->channel, sampledSynth, initMono|initMACE6, (SndCallBackProcPtr) NULL); + error= SndNewChannel(&speaker->channel, sampledSynth, initMono|initMACE6, + NULL); if (error==noErr) { quiet_network_speaker(); /* to set defaults */ @@ -187,18 +192,24 @@ void queue_network_speaker_data( { if (buffer) { - BlockMove(buffer, speaker->queue+speaker->queue_size, count); + BlockMoveData(buffer, speaker->queue+speaker->queue_size, count); } else { - fill_buffer_with_static(speaker->queue+speaker->queue_size, count); + fill_buffer_with_static((unsigned char *)speaker->queue+speaker->queue_size, count); } speaker->queue_size+= count; } else { + // Turned this off for gamma builds because it happens at interrupt time +#ifndef GAMMA +#ifdef DEBUG + dprintf("queue was emptied #%d times before failure.", queue_being_emptied); +#endif vpause(csprintf(temporary, "queue_net_speaker_data() is ignoring data: #%d+#%d>#%d", speaker->queue_size, count, MAXIMUM_QUEUE_SIZE)); +#endif } #ifdef SNDPLAYDOUBLEBUFFER_DOESNT_SUCK @@ -340,11 +351,15 @@ void fill_network_speaker_buffer( } /* for better or for worse, fill the waiting buffer */ - if (available_bytes) BlockMove(speaker->queue, doubleBufferPtr->dbSoundData, available_bytes); - if (missing_bytes) fill_buffer_with_static(doubleBufferPtr->dbSoundData+available_bytes, missing_bytes); - if (extra_bytes) BlockMove(speaker->queue+speaker->block_size, speaker->queue, extra_bytes); + if (available_bytes) BlockMoveData(speaker->queue, doubleBufferPtr->dbSoundData, available_bytes); + if (missing_bytes) fill_buffer_with_static((unsigned char *)doubleBufferPtr->dbSoundData+available_bytes, missing_bytes); + if (extra_bytes) BlockMoveData(speaker->queue+speaker->block_size, speaker->queue, extra_bytes); speaker->queue_size-= available_bytes; +#ifdef DEBUG + queue_being_emptied++; +#endif + switch (speaker->state) { case _speaker_is_off: diff --git a/marathon2/overhead_map.c b/marathon2/overhead_map.c index 72817d6..936ca39 100644 --- a/marathon2/overhead_map.c +++ b/marathon2/overhead_map.c @@ -175,7 +175,7 @@ void _render_overhead_map( case _media_water: color= _polygon_water_color; break; case _media_lava: color= _polygon_lava_color; break; case _media_goo: color= _polygon_goo_color; break; - case _media_sewage: color= _polygon_sewage_color; break; + case _media_jjaro: case _media_sewage: color= _polygon_sewage_color; break; default: halt(); break; } } @@ -341,6 +341,10 @@ void _render_overhead_map( case _civilian_science: case _civilian_security: case _civilian_assimilated: + case _vacuum_civilian_crew: + case _vacuum_civilian_science: + case _vacuum_civilian_security: + case _vacuum_civilian_assimilated: thing_type= _civilian_thing; break; @@ -376,9 +380,12 @@ void _render_overhead_map( break; case _object_is_garbage: - if (GET_COLLECTION(GET_DESCRIPTOR_COLLECTION(object->shape))==_collection_civilian) + switch (GET_COLLECTION(GET_DESCRIPTOR_COLLECTION(object->shape))) { - thing_type= _civilian_thing; + case _collection_civilian: + case _collection_vacuum_civilian: + thing_type= _civilian_thing; + break; } break; } diff --git a/marathon2/overhead_map.h b/marathon2/overhead_map.h index 445a029..0d53770 100644 --- a/marathon2/overhead_map.h +++ b/marathon2/overhead_map.h @@ -27,4 +27,5 @@ struct overhead_map_data boolean draw_everything; }; +void initialize_overhead_map(void); void _render_overhead_map(struct overhead_map_data *data); diff --git a/marathon2/overhead_map_macintosh.c b/marathon2/overhead_map_macintosh.c index 9070d8d..659e192 100644 --- a/marathon2/overhead_map_macintosh.c +++ b/marathon2/overhead_map_macintosh.c @@ -3,6 +3,39 @@ OVERHEAD_MAP_MAC.C Monday, August 28, 1995 1:41:36 PM (Jason) */ +static TextSpec overhead_map_name_font; + +enum +{ + finfMAP= 129 +}; + +struct annotation_definition +{ + RGBColor color; + short font, face; + + short sizes[OVERHEAD_MAP_MAXIMUM_SCALE-OVERHEAD_MAP_MINIMUM_SCALE+1]; +}; + +#define NUMBER_OF_ANNOTATION_DEFINITIONS (sizeof(annotation_definitions)/sizeof(struct annotation_definition)) +struct annotation_definition annotation_definitions[]= +{ + {{0, 65535, 0}, monaco, bold, {5, 9, 12, 18}}, +}; + +void initialize_overhead_map( + void) +{ + TextSpec overhead_map_annotation_font; + + // get the overhead map name font index + GetNewTextSpec(&overhead_map_name_font, finfMAP, 0); + // get the annotation font only + GetNewTextSpec(&overhead_map_annotation_font, finfMAP, 1); + annotation_definitions[0].font= overhead_map_annotation_font.font; +} + /* ---------- private code */ #define NUMBER_OF_POLYGON_COLORS (sizeof(polygon_colors)/sizeof(RGBColor)) @@ -224,20 +257,6 @@ static void draw_overhead_player( return; } -struct annotation_definition -{ - RGBColor color; - short font, face; - - short sizes[OVERHEAD_MAP_MAXIMUM_SCALE-OVERHEAD_MAP_MINIMUM_SCALE+1]; -}; - -#define NUMBER_OF_ANNOTATION_DEFINITIONS (sizeof(annotation_definitions)/sizeof(struct annotation_definition)) -struct annotation_definition annotation_definitions[]= -{ - {{0, 65535, 0}, monaco, bold, {5, 9, 12, 18}}, -}; - static void draw_overhead_annotation( world_point2d *location, short color, @@ -250,8 +269,8 @@ static void draw_overhead_annotation( vassert(color>=0&&colorx, location->y); TextFont(definition->font); TextFace(definition->face); @@ -270,12 +289,12 @@ static void draw_map_name( { Str255 pascal_name; - strcpy(pascal_name, name); - c2pstr(pascal_name); + strcpy((char *)pascal_name, name); + c2pstr((char *)pascal_name); - TextFont(monaco); - TextFace(normal); - TextSize(18); + TextFont(overhead_map_name_font.font); + TextFace(overhead_map_name_font.face); + TextSize(overhead_map_name_font.size); RGBForeColor(&map_name_color); MoveTo(data->half_width - (StringWidth(pascal_name)>>1), 25); DrawString(pascal_name); diff --git a/marathon2/pathfinding.c b/marathon2/pathfinding.c index 7ae2e6b..e5d60ec 100644 --- a/marathon2/pathfinding.c +++ b/marathon2/pathfinding.c @@ -395,7 +395,7 @@ world_point2d *path_peek( if (path->step_count!=NONE) { *step_count= path->step_count; - points= &path->points; + points= (world_point2d *) &path->points; } return points; diff --git a/marathon2/physics.c b/marathon2/physics.c index 2da60cc..35f3aea 100644 --- a/marathon2/physics.c +++ b/marathon2/physics.c @@ -564,7 +564,7 @@ static void physics_update( cosine= cosine_table[FIXED_INTEGERAL_PART(variables->direction)], sine= sine_table[FIXED_INTEGERAL_PART(variables->direction)]; dot_product= ((((variables->velocity*cosine)>>TRIG_SHIFT) + variables->external_velocity.i)*cosine + - (((variables->velocity*sine)>>TRIG_SHIFT) + variables->external_velocity.j)*sine)>>TRIG_MAGNITUDE; + (((variables->velocity*sine)>>TRIG_SHIFT) + variables->external_velocity.j)*sine)>>TRIG_SHIFT; if (dot_product>0 && dot_product<(constants->maximum_forward_velocity>>4)) dot_product= 0; switch (SGN(dot_product)) diff --git a/marathon2/physics_models.h b/marathon2/physics_models.h index 5febc5d..6b3a428 100644 --- a/marathon2/physics_models.h +++ b/marathon2/physics_models.h @@ -34,7 +34,7 @@ struct physics_constants }; /* ---------- globals */ - +#ifndef DONT_COMPILE_DEFINITIONS struct physics_constants physics_models[NUMBER_OF_PHYSICS_MODELS]= { /* game walking */ @@ -73,3 +73,4 @@ struct physics_constants physics_models[NUMBER_OF_PHYSICS_MODELS]= FIXED_ONE/32 /* camera separation */ }, }; +#endif \ No newline at end of file diff --git a/marathon2/physics_patches.c b/marathon2/physics_patches.c index b14cb23..64397d9 100644 --- a/marathon2/physics_patches.c +++ b/marathon2/physics_patches.c @@ -15,7 +15,7 @@ #include "weapons.h" #include "wad.h" #include "items.h" -#include "sound.h" +#include "game_sound.h" #include "media.h" #include "tags.h" diff --git a/marathon2/placement.c b/marathon2/placement.c index 6ef7234..d64a1f5 100644 --- a/marathon2/placement.c +++ b/marathon2/placement.c @@ -166,13 +166,16 @@ void place_initial_objects( dynamic_world->current_civilian_causalties= dynamic_world->current_civilian_count= 0; - for (index= 1; indexrandom_monsters_left[index] = monster_placement_info[index].random_count; } - dynamic_world->random_monsters_left[index] = monster_placement_info[index].random_count; } for (index= 0; indexfloor_height; diff --git a/marathon2/platforms.h b/marathon2/platforms.h index 64cbaed..a8ad6ab 100644 --- a/marathon2/platforms.h +++ b/marathon2/platforms.h @@ -1,3 +1,5 @@ +#ifndef __PLATFORMS_H__ +#define __PLATFORMS_H__ /* PLATFORMS.H Friday, July 15, 1994 3:42:39 PM @@ -263,3 +265,5 @@ struct platform_data *get_platform_data(short platform_index); #else #define get_platform_data(i) (platforms+(i)) #endif + +#endif \ No newline at end of file diff --git a/marathon2/player.c b/marathon2/player.c index d3635a5..c46b19a 100644 --- a/marathon2/player.c +++ b/marathon2/player.c @@ -19,7 +19,7 @@ Thursday, July 6, 1995 4:53:52 PM #include "player.h" #include "monsters.h" #include "interface.h" -#include "sound.h" +#include "game_sound.h" #include "fades.h" #include "media.h" #include "items.h" @@ -28,6 +28,7 @@ Thursday, July 6, 1995 4:53:52 PM #include "computer_interface.h" #include "projectiles.h" #include "network_games.h" +#include "screen.h" /* //anybody on the receiving pad of a teleport should explode (what happens to invincible guys?) @@ -109,9 +110,9 @@ static struct player_shape_definitions player_shapes= 9, 8, /* dying hard, dying soft */ 11, 10, /* dead hard, dead soft */ {7, 0, 0, 24, 23}, /* legs: stationary, walking, running, sliding, airborne */ - {1, 3, 20, 26, 14, 12, 31, 16, 28, 5, 18}, /* idle torsos: fists, magnum, fusion, assault, rocket, flamethrower, alien, shotgun, double pistol, double shotgun, da ball */ - {1, 3, 21, 26, 14, 12, 31, 16, 28, 5, 18}, /* charging torsos: fists, magnum, fusion, assault, rocket, flamethrower, alien, shotgun, double pistol, double shotgun, ball */ - {2, 4, 22, 27, 15, 13, 32, 17, 28, 6, 19}, /* firing torsos: fists, magnum, fusion, assault, rocket, flamethrower, alien, shotgun, double pistol, double shotgun, ball */ + {1, 3, 20, 26, 14, 12, 31, 16, 28, 33, 5, 18}, /* idle torsos: fists, magnum, fusion, assault, rocket, flamethrower, alien, shotgun, double pistol, double shotgun, da ball */ + {1, 3, 21, 26, 14, 12, 31, 16, 28, 33, 5, 18}, /* charging torsos: fists, magnum, fusion, assault, rocket, flamethrower, alien, shotgun, double pistol, double shotgun, ball */ + {2, 4, 22, 27, 15, 13, 32, 17, 28, 34, 6, 19}, /* firing torsos: fists, magnum, fusion, assault, rocket, flamethrower, alien, shotgun, double pistol, double shotgun, ball */ }; #define NUMBER_OF_PLAYER_INITIAL_ITEMS (sizeof(player_initial_items)/sizeof(short)) @@ -245,7 +246,7 @@ short new_player( /* Mark the player's inventory as dirty */ mark_player_inventory_as_dirty(player_index, NONE); initialize_player_weapons(player_index); - + /* give the player his initial items */ give_player_initial_items(player_index); try_and_strip_player_items(player_index); @@ -956,7 +957,7 @@ static void update_player_teleport( initialize_player_physics_variables(player_index); } else { /* -level number is the interlevel */ short level_number= -player->teleporting_destination; - + if(level_number==EPILOGUE_LEVEL_NUMBER) { /* Should this do something sly in cooperative play? */ diff --git a/marathon2/preferences.c b/marathon2/preferences.c index d4bf0b6..7dc39a9 100644 --- a/marathon2/preferences.c +++ b/marathon2/preferences.c @@ -10,7 +10,7 @@ #include "map.h" #include "shell.h" /* For the screen_mode structure */ #include "interface.h" -#include "sound.h" +#include "game_sound.h" #include "preferences.h" #include "wad.h" @@ -22,6 +22,7 @@ #include "screen.h" #include "fades.h" #include "extensions.h" +#include "screen_definitions.h" #include "tags.h" @@ -37,7 +38,8 @@ enum { iNUMBER_OF_COLORS, iWINDOW_SIZE, iDETAIL, - iBRIGHTNESS + iBRIGHTNESS, + iRESOLUTION_SWITCHING }; enum { @@ -59,12 +61,23 @@ enum { iMORE_SOUNDS }; +#ifdef SUPPORT_INPUT_SPROCKET +enum { + ditlINPUT= 4020, + iMOUSE_CONTROL= 1, + iKEYBOARD_CONTROL, + iINPUT_SPROCKET_CONTROL, + iSET_KEYS, + iINPUT_SPROCKET_STATIC_TEXT +}; +#else enum { ditlINPUT= 4004, iMOUSE_CONTROL= 1, iKEYBOARD_CONTROL, iSET_KEYS }; +#endif enum { ditlENVIRONMENT= 4005, @@ -85,7 +98,7 @@ enum { }; struct graphics_preferences_data *graphics_preferences; -struct serial_number_data *serial_preferences; +struct serial_number_data *serial_preferences= NULL; struct network_preferences_data *network_preferences; struct player_preferences_data *player_preferences; struct input_preferences_data *input_preferences; @@ -128,9 +141,14 @@ static void setup_environment_dialog(DialogPtr dialog, short first_item, void *p static void hit_environment_item(DialogPtr dialog, short first_item, void *prefs, short item_hit); static boolean teardown_environment_dialog(DialogPtr dialog, short first_item, void *prefs); static void fill_in_popup_with_filetype(DialogPtr dialog, short item, OSType type, unsigned long checksum); + +#ifndef VULCAN static MenuHandle get_popup_menu_handle(DialogPtr dialog, short item); +#endif + static boolean allocate_extensions_memory(void); static void free_extensions_memory(void); +static boolean increase_extensions_memory(void); static void build_extensions_list(void); static void search_from_directory(FSSpec *file); static unsigned long find_checksum_and_file_spec_from_dialog(DialogPtr dialog, @@ -162,17 +180,17 @@ void initialize_preferences( } /* If we didn't open, we initialized.. */ - graphics_preferences= get_graphics_pref_data(); - player_preferences= get_player_pref_data(); - input_preferences= get_input_pref_data(); - sound_preferences= get_sound_pref_data(); + graphics_preferences= (struct graphics_preferences_data *)get_graphics_pref_data(); + player_preferences= (struct player_preferences_data *)get_player_pref_data(); + input_preferences= (struct input_preferences_data *)get_input_pref_data(); + sound_preferences= (struct sound_manager_parameters *)get_sound_pref_data(); serial_preferences= w_get_data_from_preferences(prefSERIAL_TAG, sizeof(struct serial_number_data), default_serial_number_preferences, validate_serial_number_preferences); network_preferences= w_get_data_from_preferences(prefNETWORK_TAG, sizeof(struct network_preferences_data), default_network_preferences, validate_network_preferences); - environment_preferences= get_environment_pref_data(); + environment_preferences= (struct environment_preferences_data *)get_environment_pref_data(); } struct preferences_dialog_data prefs_data[]={ @@ -197,7 +215,9 @@ void handle_preferences( /* Save the new ones. */ write_preferences(); set_sound_manager_parameters(sound_preferences); +#ifndef DEMO load_environment_from_preferences(); +#endif } return; @@ -251,7 +271,16 @@ static void default_graphics_preferences( preferences->screen_mode.acceleration = _no_acceleration; preferences->screen_mode.bit_depth = 8; } - + + preferences->unused[0]= 0; + preferences->unused[1]= 0; + preferences->unused[2]= 0; +#ifdef envppc + preferences->do_resolution_switching= machine_has_display_manager(); +#else + preferences->do_resolution_switching= FALSE; +#endif + preferences->screen_mode.draw_every_other_line= FALSE; } @@ -316,14 +345,75 @@ static boolean validate_graphics_preferences( static void default_serial_number_preferences( struct serial_number_data *prefs) { - memset(prefs, 0, sizeof(struct serial_number_data)); +#if !defined(DEMO) && !defined(TRILOGY) && (defined(GAMMA) || defined(FINAL)) + if (!serial_preferences) +#endif + { + memset(prefs, 0, sizeof(struct serial_number_data)); + +#if !defined(DEMO) && !defined(TRILOGY) && (defined(GAMMA) || defined(FINAL)) + /* This has to be done here, because ask_for_serial number expects the global */ + /* variable to be valid. */ + serial_preferences= prefs; + ask_for_serial_number(); +#endif + } +#if !defined(DEMO) && !defined(TRILOGY) && (defined(GAMMA) || defined(FINAL)) + else + { + // this will ask them for us if the number is bad + memcpy(prefs, serial_preferences, sizeof(struct serial_number_data)); + validate_serial_number_preferences(prefs); + } +#endif } +#if !defined(DEMO) && !defined(TRILOGY) && (defined(GAMMA) || defined(FINAL)) +#define DECODE_ONLY +#include "serial_numbers.c" +#endif + static boolean validate_serial_number_preferences( struct serial_number_data *prefs) { -#pragma unused (prefs); +#if !defined(DEMO) && !defined(TRILOGY) && (defined(GAMMA) || defined(FINAL)) + boolean success= TRUE; + byte short_serial_number[BYTES_PER_SHORT_SERIAL_NUMBER]; + byte inferred_pad[BYTES_PER_SHORT_SERIAL_NUMBER]; + + long_serial_number_to_short_serial_number_and_pad(prefs->long_serial_number, short_serial_number, inferred_pad); + + if ((!PADS_ARE_EQUAL(actual_pad, inferred_pad) && + !(PADS_ARE_EQUAL(actual_pad_m2, inferred_pad) && ((char) short_serial_number[2])<0)) || + !VALID_INVERSE_SEQUENCE(short_serial_number)) + { + success= FALSE; + } + + +/* dprintf("player #%d (%08x%08x%04x) %d %d;g;", i, *(long*)player1_long_serial_number, + *(long*)(player1_long_serial_number+4), *(short*)(player1_long_serial_number+8), + found_duplicate, found_illegal); +*/ + + if (!success) + { + /* This has to be done here, because ask_for_serial number expects the global */ + /* variable to be valid. */ + serial_preferences= prefs; + ask_for_serial_number(); + success= TRUE; + } + else + { + success= FALSE; + } + + return success; +#else +#pragma unused (prefs) return FALSE; +#endif } /* -------------- network preferences */ @@ -403,7 +493,7 @@ static void default_player_preferences( static boolean validate_player_preferences( struct player_preferences_data *prefs) { -#pragma unused (prefs); +#pragma unused (prefs) return FALSE; } @@ -415,15 +505,20 @@ static void get_name_from_system( Handle name_handle; char old_state; - name_handle= GetString(strUSER_NAME); - assert(name_handle); - - old_state= HGetState(name_handle); - HLock(name_handle); - - pstrcpy(name, *name_handle); - HSetState(name_handle, old_state); - + name_handle= (Handle)GetString(strUSER_NAME); + if (name_handle) + { + old_state= HGetState(name_handle); + HLock(name_handle); + + pstrcpy(name, *name_handle); + HSetState(name_handle, old_state); + } + else + { + name[0]= 0; + } + return; } @@ -431,14 +526,30 @@ static void get_name_from_system( static void default_input_preferences( struct input_preferences_data *preferences) { + boolean is_powerbook_keyboard= FALSE; + long kbd_type; + + if (Gestalt(gestaltKeyboardType, &kbd_type)==noErr) + { + switch (kbd_type) + { + case gestaltPwrBookADBKbd: + case gestaltPwrBookISOADBKbd: + case gestaltPwrBkExtISOKbd: + case gestaltPwrBkExtJISKbd: + case gestaltPwrBkExtADBKbd: + is_powerbook_keyboard= TRUE; + break; + } + } preferences->input_device= _keyboard_or_game_pad; - set_default_keys(preferences->keycodes, _standard_keyboard_setup); + set_default_keys(preferences->keycodes, (is_powerbook_keyboard ? _powerbook_keyboard_setup : _standard_keyboard_setup)); } static boolean validate_input_preferences( struct input_preferences_data *prefs) { -#pragma unused (prefs); +#pragma unused (prefs) return FALSE; } @@ -467,8 +578,7 @@ static void *get_graphics_pref_data( enum { _hundreds_colors_menu_item= 1, _thousands_colors_menu_item, - _millions_colors_menu_item, - _billions_colors_menu_item + _millions_colors_menu_item }; static void setup_graphics_dialog( @@ -496,7 +606,6 @@ static void setup_graphics_dialog( active= FALSE; } set_popup_enabled_state(dialog, LOCAL_TO_GLOBAL_DITL(iNUMBER_OF_COLORS, first_item), _thousands_colors_menu_item, active); - set_popup_enabled_state(dialog, LOCAL_TO_GLOBAL_DITL(iNUMBER_OF_COLORS, first_item), _billions_colors_menu_item, FALSE); /* Force the stuff for the valkyrie board.. */ if(preferences->screen_mode.acceleration==_valkyrie_acceleration) @@ -553,6 +662,19 @@ static void setup_graphics_dialog( modify_control(dialog, LOCAL_TO_GLOBAL_DITL(iBRIGHTNESS, first_item), NONE, preferences->screen_mode.gamma_level+1); +#ifdef envppc + if (machine_has_display_manager()) + { + modify_control(dialog, LOCAL_TO_GLOBAL_DITL(iRESOLUTION_SWITCHING, first_item), CONTROL_ACTIVE, preferences->do_resolution_switching); + } + else + { + modify_control(dialog, LOCAL_TO_GLOBAL_DITL(iRESOLUTION_SWITCHING, first_item), CONTROL_INACTIVE, 0); + } +#else + modify_control(dialog, LOCAL_TO_GLOBAL_DITL(iRESOLUTION_SWITCHING, first_item), CONTROL_INACTIVE, 0); +#endif + active = (hardware_acceleration_code(&preferences->device_spec) == _valkyrie_acceleration) ? CONTROL_ACTIVE : CONTROL_INACTIVE; modify_control(dialog, LOCAL_TO_GLOBAL_DITL(iHARDWARE_ACCELERATION, first_item), active, (preferences->screen_mode.acceleration == _valkyrie_acceleration)); @@ -592,7 +714,13 @@ static void hit_graphics_item( preferences->screen_mode.acceleration= _valkyrie_acceleration; } break; - + +#ifdef envppc + case iRESOLUTION_SWITCHING: + preferences->do_resolution_switching= !preferences->do_resolution_switching; + break; +#endif + case iNUMBER_OF_COLORS: GetDItem(dialog, item_hit, &item_type, (Handle *) &control, &bounds); switch(GetCtlValue(control)) @@ -600,7 +728,6 @@ static void hit_graphics_item( case _hundreds_colors_menu_item: preferences->screen_mode.bit_depth= 8; break; case _thousands_colors_menu_item: preferences->screen_mode.bit_depth= 16; break; case _millions_colors_menu_item: preferences->screen_mode.bit_depth= 32; break; - case _billions_colors_menu_item: default: preferences->screen_mode.bit_depth= 8; halt(); break; } break; @@ -636,7 +763,7 @@ static boolean teardown_graphics_dialog( short first_item, void *prefs) { - #pragma unused (dialog, first_item, prefs); + #pragma unused (dialog, first_item, prefs) return TRUE; } @@ -654,7 +781,7 @@ static void setup_player_dialog( short first_item, void *prefs) { - struct player_preferences_data *preferences= prefs; + struct player_preferences_data *preferences= (struct player_preferences_data *)prefs; Handle item; short item_type; Rect bounds; @@ -665,7 +792,7 @@ static void setup_player_dialog( /* Setup the name. */ GetDItem(dialog, LOCAL_TO_GLOBAL_DITL(iNAME, first_item), &item_type, &item, &bounds); - SetDialogItemText(item, preferences->name); + SetDialogItemText(item, (StringPtr)preferences->name); SelectDialogItemText(dialog, LOCAL_TO_GLOBAL_DITL(iNAME, first_item), 0, SHORT_MAX); /* Setup the color */ @@ -686,7 +813,7 @@ static void hit_player_item( ControlHandle control; short item_type; Rect bounds; - struct player_preferences_data *preferences= prefs; + struct player_preferences_data *preferences= (struct player_preferences_data *)prefs; switch(GLOBAL_TO_LOCAL_DITL(item_hit, first_item)) { @@ -715,7 +842,7 @@ static boolean teardown_player_dialog( Handle control; short item_type; Rect bounds; - struct player_preferences_data *preferences= prefs; + struct player_preferences_data *preferences= (struct player_preferences_data *)prefs; Str255 buffer; /* Get the player name */ @@ -791,7 +918,7 @@ static void hit_sound_item( ControlHandle control; short item_type; Rect bounds; - struct sound_manager_parameters *preferences= prefs; + struct sound_manager_parameters *preferences= (struct sound_manager_parameters *)prefs; switch(GLOBAL_TO_LOCAL_DITL(item_hit, first_item)) { @@ -871,7 +998,7 @@ static boolean teardown_sound_dialog( short first_item, void *prefs) { -#pragma unused (dialog, first_item, prefs); +#pragma unused (dialog, first_item, prefs) return TRUE; } @@ -890,13 +1017,50 @@ static void setup_input_dialog( short first_item, void *prefs) { - struct input_preferences_data *preferences= prefs; + struct input_preferences_data *preferences= (struct input_preferences_data *)prefs; short which; +#ifdef SUPPORT_INPUT_SPROCKET + switch(preferences->input_device) + { + case _mouse_yaw_pitch: + which = iMOUSE_CONTROL; + break; + case _input_sprocket_yaw_pitch: + if (system_information->has_input_sprocket) + { + which = iINPUT_SPROCKET_CONTROL; + break; + } + /* FALL-THRU */ + case _keyboard_or_game_pad: + default: + which = iKEYBOARD_CONTROL; + } + + + if (system_information->has_input_sprocket) + { + modify_radio_button_family(dialog, LOCAL_TO_GLOBAL_DITL(iMOUSE_CONTROL, first_item), + LOCAL_TO_GLOBAL_DITL(iINPUT_SPROCKET_CONTROL, first_item), + LOCAL_TO_GLOBAL_DITL(which, first_item)); + } + else + { + modify_radio_button_family(dialog, LOCAL_TO_GLOBAL_DITL(iMOUSE_CONTROL, first_item), + LOCAL_TO_GLOBAL_DITL(iKEYBOARD_CONTROL, first_item), + LOCAL_TO_GLOBAL_DITL(which, first_item)); + + // disable the input sprocket radio button + modify_control(dialog, LOCAL_TO_GLOBAL_DITL(iINPUT_SPROCKET_CONTROL, first_item), + CONTROL_INACTIVE, NONE); + } +#else which = (preferences->input_device == _mouse_yaw_pitch) ? iMOUSE_CONTROL : iKEYBOARD_CONTROL; modify_radio_button_family(dialog, LOCAL_TO_GLOBAL_DITL(iMOUSE_CONTROL, first_item), LOCAL_TO_GLOBAL_DITL(iKEYBOARD_CONTROL, first_item), LOCAL_TO_GLOBAL_DITL(which, first_item)); +#endif } static void hit_input_item( @@ -905,19 +1069,84 @@ static void hit_input_item( void *prefs, short item_hit) { - struct input_preferences_data *preferences= prefs; + struct input_preferences_data *preferences= (struct input_preferences_data *)prefs; switch(GLOBAL_TO_LOCAL_DITL(item_hit, first_item)) { case iMOUSE_CONTROL: case iKEYBOARD_CONTROL: +#ifdef SUPPORT_INPUT_SPROCKET + use_input_sprocket= FALSE; + modify_radio_button_family(dialog, LOCAL_TO_GLOBAL_DITL(iMOUSE_CONTROL, first_item), + LOCAL_TO_GLOBAL_DITL(iINPUT_SPROCKET_CONTROL, first_item), item_hit); +#else modify_radio_button_family(dialog, LOCAL_TO_GLOBAL_DITL(iMOUSE_CONTROL, first_item), LOCAL_TO_GLOBAL_DITL(iKEYBOARD_CONTROL, first_item), item_hit); +#endif preferences->input_device= GLOBAL_TO_LOCAL_DITL(item_hit, first_item)==iMOUSE_CONTROL ? _mouse_yaw_pitch : _keyboard_or_game_pad; break; - + +#ifdef SUPPORT_INPUT_SPROCKET + case iINPUT_SPROCKET_CONTROL: + modify_radio_button_family(dialog, LOCAL_TO_GLOBAL_DITL(iMOUSE_CONTROL, first_item), + LOCAL_TO_GLOBAL_DITL(iINPUT_SPROCKET_CONTROL, first_item), item_hit); + if (system_information->has_input_sprocket) + { + use_input_sprocket= TRUE; + preferences->input_device = _input_sprocket_yaw_pitch; + } + break; +#endif case iSET_KEYS: +#ifdef SUPPORT_INPUT_SPROCKET + if (use_input_sprocket) + { +#ifndef INPUT_SPROCKET_BUG_FIX + short cur_res_file= CurResFile(); +#endif + GrafPtr old_port; + OSStatus err; + GDHandle main_device = GetMainDevice(); + PixMapHandle main_device_pixMapHandle = (*main_device)->gdPMap; + short main_device_depth = (*main_device_pixMapHandle)->pixelSize; + + GetPort(&old_port); + + /* if we are in 8 bit switch to system colors */ + if (main_device_depth == 8) + { + HideWindow(dialog); + paint_window_black(); + force_system_colors(); + } + +#ifndef INPUT_SPROCKET_BUG_FIX + UseResFile(HomeResFile(GetResource('SOCK', 128))); +#endif + err= ISpConfigure(NULL); +#ifndef INPUT_SPROCKET_BUG_FIX + UseResFile(cur_res_file); +#endif + + /* if we are in 8 bit switch back to our colors */ + if (main_device_depth == 8) + { + display_screen(MAIN_MENU_BASE); + + ShowWindow(dialog); + SelectWindow(dialog); + SetPort(dialog); + DrawDialog(dialog); + ShowCursor(); + + stop_fade(); + } + + SetPort(old_port); + } + else +#endif { short key_codes[NUMBER_OF_KEYS]; @@ -940,7 +1169,7 @@ static boolean teardown_input_dialog( short first_item, void *prefs) { - #pragma unused(dialog, first_item, prefs); + #pragma unused(dialog, first_item, prefs) return TRUE; } @@ -958,6 +1187,12 @@ static struct file_description *file_descriptions= NULL; static short accessory_file_count= 0; static boolean physics_valid= TRUE; +static int scenario_file_count= 0; +static int physics_file_count= 0; +static int shapes_file_count= 0; +static int sounds_file_count= 0; +static int patch_file_count= 0; + static void default_environment_preferences( struct environment_preferences_data *prefs) { @@ -979,11 +1214,51 @@ static void default_environment_preferences( return; } +static boolean file_exists( + FSSpec *file) +{ + OSErr err; + FSSpec spec; + + err= FSMakeFSSpec(file->vRefNum, file->parID, file->name, &spec); + + return (err==noErr); +} + static boolean validate_environment_preferences( struct environment_preferences_data *prefs) { -#pragma unused (prefs); - return FALSE; + boolean changed= FALSE; +#if 0 + if(!file_exists(&prefs->map_file)) + { + get_default_map_spec((FileDesc *) &prefs->map_file); + prefs->map_checksum= read_wad_file_checksum((FileDesc *) &prefs->map_file); + changed= TRUE; + } + + if(!file_exists(&prefs->physics_file)) + { + get_default_physics_spec((FileDesc *) &prefs->physics_file); + prefs->physics_checksum= read_wad_file_checksum((FileDesc *) &prefs->physics_file); + changed= TRUE; + } + + if(!file_exists(&prefs->shapes_file)) + { + get_file_spec(&prefs->shapes_file, strFILENAMES, filenameSHAPES8, strPATHS); + prefs->shapes_mod_date= get_file_modification_date(&prefs->shapes_file); + changed= TRUE; + } + + if(!file_exists(&prefs->sounds_file)) + { + get_file_spec(&prefs->sounds_file, strFILENAMES, filenameSOUNDS8, strPATHS); + prefs->sounds_mod_date= get_file_modification_date(&prefs->sounds_file); + changed= TRUE; + } +#endif + return changed; } static void *get_environment_pref_data( @@ -999,7 +1274,7 @@ static void setup_environment_dialog( short first_item, void *prefs) { - struct environment_preferences_data *preferences= prefs; + struct environment_preferences_data *preferences= (struct environment_preferences_data *)prefs; if(allocate_extensions_memory()) { @@ -1031,9 +1306,9 @@ static void hit_environment_item( void *prefs, short item_hit) { - struct environment_preferences_data *preferences= prefs; + struct environment_preferences_data *preferences= (struct environment_preferences_data *)prefs; -#pragma unused(dialog); +#pragma unused(dialog) switch(GLOBAL_TO_LOCAL_DITL(item_hit, first_item)) { case iMAP: @@ -1145,8 +1420,8 @@ static boolean teardown_environment_dialog( short first_item, void *prefs) { -#pragma unused (dialog, first_item); - struct environment_preferences_data *preferences= prefs; +#pragma unused (dialog, first_item) + struct environment_preferences_data *preferences= (struct environment_preferences_data *)prefs; /* Proceses the entire physics file.. */ free_extensions_memory(); @@ -1214,7 +1489,7 @@ static boolean allocate_extensions_memory( assert(!accessory_files); assert(!file_descriptions); - +/* accessory_file_count= 0; accessory_files= (FSSpec *) malloc(MAXIMUM_FIND_FILES*sizeof(FSSpec)); file_descriptions= (struct file_description *) malloc(MAXIMUM_FIND_FILES*sizeof(struct file_description)); @@ -1228,6 +1503,18 @@ static boolean allocate_extensions_memory( file_descriptions= NULL; success= FALSE; } +*/ + // dynamic to allow for up to MAXIMUM_FIND_FILES per popup. + scenario_file_count= 0; + physics_file_count= 0; + shapes_file_count= 0; + sounds_file_count= 0; + patch_file_count= 0; + + accessory_file_count= 0; + accessory_files= NULL; + file_descriptions= NULL; + success= TRUE; return success; } @@ -1235,18 +1522,46 @@ static boolean allocate_extensions_memory( static void free_extensions_memory( void) { - assert(accessory_files); - assert(file_descriptions); +// assert(accessory_files); +// assert(file_descriptions); - free(file_descriptions); - free(accessory_files); + if (file_descriptions) free(file_descriptions); + if (accessory_files) free(accessory_files); accessory_files= NULL; file_descriptions= NULL; accessory_file_count= 0; + scenario_file_count= 0; + physics_file_count= 0; + shapes_file_count= 0; + sounds_file_count= 0; + patch_file_count= 0; return; } +static boolean increase_extensions_memory( + void) +{ + FSSpec *new_accessory_files= NULL; + struct file_description *new_file_descriptions= NULL; + boolean success= FALSE; + + new_accessory_files= (FSSpec *)realloc(accessory_files,sizeof(FSSpec) * (accessory_file_count + 1)); + if (new_accessory_files!=NULL) + { + accessory_files= new_accessory_files; + new_file_descriptions= (struct file_description *)realloc(file_descriptions,sizeof(struct file_description) * (accessory_file_count + 1)); + if (new_file_descriptions!=NULL) + { + file_descriptions= new_file_descriptions; + + success= TRUE; + } + } + + return success; +} + static Boolean file_is_extension_and_add_callback( FSSpec *file, void *data) @@ -1254,10 +1569,10 @@ static Boolean file_is_extension_and_add_callback( unsigned long checksum; CInfoPBRec *pb= (CInfoPBRec *) data; - assert(accessory_files); - assert(file_descriptions); +// assert(accessory_files); +// assert(file_descriptions); - if(accessory_file_counthFileInfo.ioFlFndrInfo.fdType) { @@ -1266,9 +1581,23 @@ static Boolean file_is_extension_and_add_callback( checksum= read_wad_file_checksum((FileDesc *) file); if(checksum != NONE) /* error. */ { - accessory_files[accessory_file_count]= *file; - file_descriptions[accessory_file_count].file_type= pb->hFileInfo.ioFlFndrInfo.fdType; - file_descriptions[accessory_file_count++].checksum= checksum; + if (((pb->hFileInfo.ioFlFndrInfo.fdType==PHYSICS_FILE_TYPE) ? physics_file_count : scenario_file_count)hFileInfo.ioFlFndrInfo.fdType==PHYSICS_FILE_TYPE) + { + physics_file_count++; + } + else + { + scenario_file_count++; + } + accessory_files[accessory_file_count]= *file; + file_descriptions[accessory_file_count].file_type= pb->hFileInfo.ioFlFndrInfo.fdType; + file_descriptions[accessory_file_count++].checksum= checksum; + } + } } break; @@ -1278,19 +1607,37 @@ static Boolean file_is_extension_and_add_callback( { unsigned long parent_checksum; - parent_checksum= read_wad_file_parent_checksum((FileDesc *) file); - accessory_files[accessory_file_count]= *file; - file_descriptions[accessory_file_count].file_type= pb->hFileInfo.ioFlFndrInfo.fdType; - file_descriptions[accessory_file_count++].checksum= checksum; - file_descriptions[accessory_file_count++].parent_checksum= parent_checksum; + if ((patch_file_counthFileInfo.ioFlFndrInfo.fdType; + file_descriptions[accessory_file_count++].checksum= checksum; + file_descriptions[accessory_file_count++].parent_checksum= parent_checksum; + } } break; case SHAPES_FILE_TYPE: case SOUNDS_FILE_TYPE: - accessory_files[accessory_file_count]= *file; - file_descriptions[accessory_file_count].file_type= pb->hFileInfo.ioFlFndrInfo.fdType; - file_descriptions[accessory_file_count++].checksum= pb->hFileInfo.ioFlMdDat; + if (((pb->hFileInfo.ioFlFndrInfo.fdType==SHAPES_FILE_TYPE) ? shapes_file_count : sounds_file_count)hFileInfo.ioFlFndrInfo.fdType==SHAPES_FILE_TYPE) + { + shapes_file_count++; + } + else + { + sounds_file_count++; + } + accessory_files[accessory_file_count]= *file; + file_descriptions[accessory_file_count].file_type= pb->hFileInfo.ioFlFndrInfo.fdType; + file_descriptions[accessory_file_count++].checksum= pb->hFileInfo.ioFlMdDat; + } + } break; default: @@ -1321,7 +1668,7 @@ static void build_extensions_list( /* Hmm... check FSMakeFSSpec... */ /* Relative pathname.. */ - err= FSMakeFSSpec(my_spec.vRefNum, my_spec.parID, temporary, &file); + err= FSMakeFSSpec(my_spec.vRefNum, my_spec.parID, (StringPtr)temporary, &file); if(!err) { @@ -1390,7 +1737,7 @@ static void fill_in_popup_with_filetype( /* Remove whatever it had */ while(CountMItems(menu)) DelMenuItem(menu, 1); - assert(file_descriptions); +// assert(file_descriptions); for(index= 0; index #ifdef mpwc @@ -69,7 +71,7 @@ static boolean confirm_save_choice(FSSpec *file); /* --------- code begins */ void get_default_map_spec( - FileDesc *new) + FileDesc *new_file) { static boolean first_try= TRUE; static FSSpec default_map_spec; @@ -86,13 +88,13 @@ void get_default_map_spec( } /* Copy it in. */ - memcpy(new, &default_map_spec, sizeof(FileDesc)); + memcpy(new_file, &default_map_spec, sizeof(FileDesc)); return; } void get_default_physics_spec( - FileDesc *new) + FileDesc *new_file) { static boolean first_try= TRUE; static FSSpec default_physics_spec; @@ -106,14 +108,14 @@ void get_default_physics_spec( if(error) { get_my_fsspec(&default_physics_spec); - getpstr(default_physics_spec.name, strFILENAMES, filenamePHYSICS_MODEL); + getpstr((char *)default_physics_spec.name, strFILENAMES, filenamePHYSICS_MODEL); } first_try= FALSE; } /* Copy it in. */ - memcpy(new, &default_physics_spec, sizeof(FileDesc)); + memcpy(new_file, &default_physics_spec, sizeof(FileDesc)); return; } @@ -149,10 +151,14 @@ boolean save_game( boolean success= FALSE; pause_game(); + exit_screen(); ShowCursor(); /* Translate the name, and display the dialog */ - get_current_saved_game_name(file_name); + get_current_saved_game_name((char *)file_name); + + // added to ensure that dialog isn't named whatever the action key was + FlushEvents(keyDownMask|keyUpMask|autoKeyMask|mDownMask|mUpMask, 0); /* Create the UPP's */ dlgHook= NewDlgHookYDProc(custom_put_hook); @@ -160,7 +166,7 @@ boolean save_game( /* The drawback of this method-> I don't get a New Folder button. */ /* If this is terribly annoying, I will add the Sys7 only code. */ - CustomPutFile(getpstr(prompt, strPROMPTS, _save_game_prompt), + CustomPutFile((StringPtr)getpstr((char *)prompt, strPROMPTS, _save_game_prompt), file_name, &reply, 0, top_left, dlgHook, NULL, NULL, NULL, &reply.sfFile); /* Free them... */ @@ -176,6 +182,8 @@ boolean save_game( } HideCursor(); + enter_screen(); + draw_interface(); resume_game(); return success; @@ -200,7 +208,7 @@ void add_finishing_touches_to_save_file( err= PtrToHand(name, &resource, name[0]+1); assert(!err); - AddResource(resource, 'STR ', strSAVE_LEVEL_NAME, ""); + AddResource(resource, 'STR ', strSAVE_LEVEL_NAME, (StringPtr)""); ReleaseResource(resource); /* Add in the overhead thumbnail. */ @@ -257,7 +265,7 @@ static void add_overhead_thumbnail( ClosePicture(); - AddResource((Handle) picture, 'PICT', THUMBNAIL_ID, ""); + AddResource((Handle) picture, 'PICT', THUMBNAIL_ID, (StringPtr)""); ReleaseResource((Handle) picture); SetGWorld(old_gworld, old_device); @@ -322,7 +330,7 @@ static boolean confirm_save_choice( get_window_frame(FrontWindow(), &frame); /* Slam the ParamText */ - ParamText(file->name, "", "", ""); + ParamText(file->name, (StringPtr)"", (StringPtr)"", (StringPtr)""); /* Load in the dialog.. */ dialog= myGetNewDialog(dlogMY_REPLACE, NULL, (WindowPtr) -1, 0); @@ -339,7 +347,7 @@ static boolean confirm_save_choice( } while(item_hit > iCANCEL); /* Restore and cleanup.. */ - ParamText("", "", "", ""); + ParamText((StringPtr)"", (StringPtr)"", (StringPtr)"", (StringPtr)""); DisposeDialog(dialog); if(item_hit==iOK) /* replace.. */ diff --git a/marathon2/progress.c b/marathon2/progress.c index bc8c73b..6005883 100644 --- a/marathon2/progress.c +++ b/marathon2/progress.c @@ -65,7 +65,7 @@ void set_progress_dialog_message( assert(progress_data.dialog); GetDItem(progress_data.dialog, iPROGRESS_MESSAGE, &item_type, &item_handle, &bounds); getpstr(temporary, strPROGRESS_MESSAGES, message_id); - SetIText(item_handle, temporary); + SetIText(item_handle, (StringPtr)temporary); return; } diff --git a/marathon2/projectile_definitions.h b/marathon2/projectile_definitions.h index e57da33..c938840 100644 --- a/marathon2/projectile_definitions.h +++ b/marathon2/projectile_definitions.h @@ -27,7 +27,8 @@ enum /* projectile flags */ _bleeding_projectile= 0x20000, /* can use a monster’s custom bleeding detonation */ _horizontal_wander= 0x40000, /* random horizontal error perpendicular to direction of movement */ _vertical_wander= 0x80000, /* random vertical movement perpendicular to direction of movement */ - _affected_by_half_gravity= 0x100000 + _affected_by_half_gravity= 0x100000, + _projectile_passes_media_boundary= 0x200000 }; /* ---------- structures */ @@ -54,6 +55,7 @@ struct projectile_definition /* ---------- projectile definitions */ +#ifndef DONT_COMPILE_DEFINITIONS struct projectile_definition projectile_definitions[NUMBER_OF_PROJECTILE_TYPES]= { { /* player’s rocket */ @@ -340,7 +342,7 @@ struct projectile_definition projectile_definitions[NUMBER_OF_PROJECTILE_TYPES]= NONE, NONE, /* flyby sound, rebound sound */ }, - { /* _projectile_armageddon_sphere */ + { /* _projectile_unused */ 0 }, @@ -746,4 +748,24 @@ struct projectile_definition projectile_definitions[NUMBER_OF_PROJECTILE_TYPES]= _normal_frequency, /* sound pitch */ _snd_yeti_projectile_lava_flyby, NONE, /* flyby sound, rebound sound */ }, + + { /* _projectile_smg_bullet */ + NONE, 0, /* collection number, shape number */ + _effect_bullet_ricochet, _small_media_detonation_effect, /* detonation effect, media_detonation_effect */ + NONE, 0, 0, /* contrail effect, ticks between contrails, maximum contrails */ + NONE, /* media projectile promotion */ + + 0, /* radius */ + 0, /* area-of-effect */ + {_damage_projectile, 0, 9, 6}, /* damage */ + + _bleeding_projectile|_usually_pass_transparent_side|_projectile_passes_media_boundary, /* flags */ + + WORLD_ONE, /* speed */ + NONE, /* maximum range */ + + _normal_frequency, /* sound pitch */ + NONE, NONE, /* flyby sound, rebound sound */ + }, }; +#endif diff --git a/marathon2/projectiles.c b/marathon2/projectiles.c index f14c8fa..df3983a 100644 --- a/marathon2/projectiles.c +++ b/marathon2/projectiles.c @@ -29,7 +29,7 @@ Friday, October 6, 1995 8:35:04 AM (Jason) #include "player.h" #include "scenery.h" #include "media.h" -#include "sound.h" +#include "game_sound.h" #include "items.h" /* @@ -279,6 +279,7 @@ void move_projectiles( else { world_distance speed= definition->speed; + unsigned long adjusted_definition_flags= 0; word flags; /* base alien projectile speed on difficulty level */ @@ -296,6 +297,8 @@ void move_projectiles( /* if this is a guided projectile with a valid target, update guidance system */ if ((definition->flags&_guided) && projectile->target_index!=NONE && (dynamic_world->tick_count&1)) update_guided_projectile(projectile_index); + if (PROJECTILE_HAS_CROSSED_MEDIA_BOUNDARY(projectile)) adjusted_definition_flags= _penetrates_media; + /* move the projectile and check for collisions; if we didn’t detonate move the projectile and check to see if we need to leave a contrail */ if ((definition->flags&_affected_by_half_gravity) && (dynamic_world->tick_count&1)) projectile->gravity-= GRAVITATIONAL_ACCELERATION; @@ -305,7 +308,9 @@ void move_projectiles( translate_point3d(&new_location, speed, object->facing, projectile->elevation); if (definition->flags&_vertical_wander) new_location.z+= (random()&1) ? WANDER_MAGNITUDE : -WANDER_MAGNITUDE; if (definition->flags&_horizontal_wander) translate_point3d(&new_location, (random()&1) ? WANDER_MAGNITUDE : -WANDER_MAGNITUDE, NORMALIZE_ANGLE(object->facing+QUARTER_CIRCLE), 0); + definition->flags^= adjusted_definition_flags; flags= translate_projectile(projectile->type, &old_location, object->polygon, &new_location, &new_polygon_index, projectile->owner_index, &obstruction_index); + definition->flags^= adjusted_definition_flags; if (flags&_projectile_hit) { @@ -344,7 +349,10 @@ void move_projectiles( } else { - destroy_persistent_projectile= try_and_add_player_item(monster_obstruction_index, projectile->permutation); + if (MONSTER_IS_PLAYER(get_monster_data(monster_obstruction_index))) + { + destroy_persistent_projectile= try_and_add_player_item(monster_index_to_player_index(monster_obstruction_index), projectile->permutation); + } } } else @@ -385,13 +393,20 @@ void move_projectiles( if (detonation_effect!=NONE) new_effect(&new_location, new_polygon_index, detonation_effect, object->facing); - if ((definition->flags&_persistent_and_virulent) && !destroy_persistent_projectile && monster_obstruction_index!=NONE) + if (!(definition->flags&_projectile_passes_media_boundary) || !(flags&_projectile_hit_media)) { - projectile->owner_index= monster_obstruction_index; /* keep going, but don’t hit this target again */ + if ((definition->flags&_persistent_and_virulent) && !destroy_persistent_projectile && monster_obstruction_index!=NONE) + { + projectile->owner_index= monster_obstruction_index; /* keep going, but don’t hit this target again */ + } + else + { + remove_projectile(projectile_index); + } } else { - remove_projectile(projectile_index); + SET_PROJECTILE_CROSSED_MEDIA_BOUNDARY_STATUS(projectile, TRUE); } } } diff --git a/marathon2/projectiles.h b/marathon2/projectiles.h index ef83e1e..278ab4d 100644 --- a/marathon2/projectiles.h +++ b/marathon2/projectiles.h @@ -1,3 +1,6 @@ +#ifndef __PROJECTILES_H__ +#define __PROJECTILES_H__ + /* PROJECTILES.H Tuesday, June 28, 1994 7:12:00 PM @@ -24,7 +27,7 @@ enum /* projectile types */ _projectile_fusion_bolt_major, _projectile_hunter, _projectile_fist, - _projectile_armageddon_sphere, + _projectile_unused, _projectile_armageddon_electricity, _projectile_juggernaut_rocket, _projectile_trooper_bullet, @@ -47,6 +50,7 @@ enum /* projectile types */ _projectile_yeti, _projectile_sewage_yeti, _projectile_lava_yeti, + _projectile_smg_bullet, NUMBER_OF_PROJECTILE_TYPES }; @@ -57,6 +61,9 @@ enum /* projectile types */ #define PROJECTILE_HAS_CAUSED_DAMAGE(p) ((p)->flags&(word)0x2000) #define SET_PROJECTILE_DAMAGE_STATUS(p,v) ((v)?((p)->flags|=(word)0x2000):((p)->flags&=(word)~0x2000)) +#define PROJECTILE_HAS_CROSSED_MEDIA_BOUNDARY(p) ((p)->flags&(word)0x1000) +#define SET_PROJECTILE_CROSSED_MEDIA_BOUNDARY_STATUS(p,v) ((v)?((p)->flags|=(word)0x1000):((p)->flags&=(word)~0x1000)) + /* uses SLOT_IS_USED(), SLOT_IS_FREE(), MARK_SLOT_AS_FREE(), MARK_SLOT_AS_USED() macros (0x8000 bit) */ struct projectile_data /* 32 bytes */ @@ -119,3 +126,5 @@ struct projectile_data *get_projectile_data(short projectile_index); #else #define get_projectile_data(i) (projectiles+(i)) #endif + +#endif \ No newline at end of file diff --git a/marathon2/render.c b/marathon2/render.c index 57fa9be..a9afb49 100644 --- a/marathon2/render.c +++ b/marathon2/render.c @@ -88,6 +88,9 @@ extern WindowPtr screen_window; #pragma options align=power #endif +boolean has_ambiguous_flags= FALSE; +boolean exceeded_max_node_aliases= FALSE; + /* //render transparent walls (if a bit is set or if the transparent texture is non-NULL?) //use side lightsources instead of taking them from their polygons @@ -161,7 +164,7 @@ struct vertical_surface_data #define MAXIMUM_LINE_CLIPS 256 #define MAXIMUM_ENDPOINT_CLIPS 64 -#define MAXIMUM_CLIPPING_WINDOWS 128 +#define MAXIMUM_CLIPPING_WINDOWS 256 enum /* …_clip_data flags */ { @@ -428,18 +431,18 @@ void allocate_render_memory( render_objects= (struct render_object_data *) malloc(sizeof(struct render_object_data)*MAXIMUM_RENDER_OBJECTS); assert(render_objects); - endpoint_clips= malloc(MAXIMUM_ENDPOINT_CLIPS*sizeof(struct endpoint_clip_data)); + endpoint_clips= (struct endpoint_clip_data *)malloc(MAXIMUM_ENDPOINT_CLIPS*sizeof(struct endpoint_clip_data)); assert(endpoint_clips); - line_clips= malloc(MAXIMUM_LINE_CLIPS*sizeof(struct line_clip_data)); - line_clip_indexes= malloc(MAXIMUM_LINES_PER_MAP*sizeof(short)); + line_clips= (struct line_clip_data *)malloc(MAXIMUM_LINE_CLIPS*sizeof(struct line_clip_data)); + line_clip_indexes= (short *)malloc(MAXIMUM_LINES_PER_MAP*sizeof(short)); assert(line_clips&&line_clip_indexes); - clipping_windows= malloc(MAXIMUM_CLIPPING_WINDOWS*sizeof(struct clipping_window_data)); + clipping_windows= (struct clipping_window_data *)malloc(MAXIMUM_CLIPPING_WINDOWS*sizeof(struct clipping_window_data)); assert(clipping_windows); - endpoint_x_coordinates= malloc(MAXIMUM_ENDPOINTS_PER_MAP*sizeof(short)); - polygon_index_to_sorted_node= malloc(MAXIMUM_POLYGONS_PER_MAP*sizeof(struct sorted_node *)); + endpoint_x_coordinates= (short *)malloc(MAXIMUM_ENDPOINTS_PER_MAP*sizeof(short)); + polygon_index_to_sorted_node= (struct sorted_node_data **)malloc(MAXIMUM_POLYGONS_PER_MAP*sizeof(struct sorted_node *)); assert(endpoint_x_coordinates&&polygon_index_to_sorted_node); return; @@ -1144,13 +1147,16 @@ static void sort_render_tree( break; } } -#ifdef DEBUG else { - dprintf("exceeded MAXIMUM_NODE_ALIASES; this sucks, Beavis."); +#ifdef VULCAN + exceeded_max_node_aliases= TRUE; +#else + dprintf("exceeded MAXIMUM_NODE_ALIASES (#%d), remove some transparent walls.", MAXIMUM_NODE_ALIASES); +#endif + return; } -#endif } } @@ -2387,7 +2393,11 @@ static void render_node_floor_or_ceiling( case _clip_left: screen->x= window->x0; break; case _clip_right: screen->x= window->x1; break; default: +#ifdef VULCAN + if (window->x1-window->x0>1) has_ambiguous_flags= TRUE; +#else if (window->x1-window->x0>1) dprintf("ambiguous clip flags for window [%d,%d];g;", window->x0, window->x1); +#endif screen->x= window->x0; break; } @@ -2401,7 +2411,11 @@ static void render_node_floor_or_ceiling( case _clip_up: screen->y= window->y0; break; case _clip_down: screen->y= window->y1; break; default: - if (window->y1-window->y0>1) dprintf("ambiguous clip flags for window [%d,%d];g;", window->y0, window->y1); +#ifdef VULCAN + if (window->y1-window->y0>1) has_ambiguous_flags= TRUE; +#else + if (window->y1-window->y0>1) dprintf("ambiguous clip flags for window [%d,%d];g;", window->x0, window->x1); +#endif screen->y= window->y0; break; } @@ -2501,7 +2515,11 @@ static void render_node_side( case _clip_left: screen->x= window->x0; break; case _clip_right: screen->x= window->x1; break; default: +#ifdef VULCAN + if (window->x1-window->x0>1) has_ambiguous_flags= TRUE; +#else if (window->x1-window->x0>1) dprintf("ambiguous clip flags for window [%d,%d];g;", window->x0, window->x1); +#endif screen->x= window->x0; break; } @@ -2515,7 +2533,11 @@ static void render_node_side( case _clip_up: screen->y= window->y0; break; case _clip_down: screen->y= window->y1; break; default: - if (window->y1-window->y0>1) dprintf("ambiguous clip flags for window [%d,%d];g;", window->y0, window->y1); +#ifdef VULCAN + if (window->y1-window->y0>1) has_ambiguous_flags= TRUE; +#else + if (window->y1-window->y0>1) dprintf("ambiguous clip flags for window [%d,%d];g;", window->x0, window->x1); +#endif screen->y= window->y0; break; } diff --git a/marathon2/render.h b/marathon2/render.h index 7953383..012723d 100644 --- a/marathon2/render.h +++ b/marathon2/render.h @@ -129,3 +129,6 @@ void render_overhead_map(struct view_data *view); void render_computer_interface(struct view_data *view); #include "scottish_textures.h" + +extern boolean has_ambiguous_flags; +extern boolean exceeded_max_node_aliases; \ No newline at end of file diff --git a/marathon2/scenery.c b/marathon2/scenery.c index b8cf0d0..0c826d3 100644 --- a/marathon2/scenery.c +++ b/marathon2/scenery.c @@ -18,6 +18,7 @@ Tuesday, October 10, 1995 10:30:58 AM (Jason) #include "projectiles.h" #include "player.h" #include "platforms.h" +#include "scenery.h" #include @@ -52,7 +53,7 @@ struct scenery_definition *get_scenery_definition(short scenery_type); void initialize_scenery( void) { - animated_scenery_object_indexes= malloc(sizeof(short)*MAXIMUM_ANIMATED_SCENERY_OBJECTS); + animated_scenery_object_indexes= (short *)malloc(sizeof(short)*MAXIMUM_ANIMATED_SCENERY_OBJECTS); assert(animated_scenery_object_indexes); return; diff --git a/marathon2/scenery_definitions.h b/marathon2/scenery_definitions.h index a8336ba..a836cb1 100644 --- a/marathon2/scenery_definitions.h +++ b/marathon2/scenery_definitions.h @@ -87,4 +87,17 @@ struct scenery_definition scenery_definitions[]= {0, BUILD_DESCRIPTOR(_collection_scenery5, 12)}, // hunter shield {0, BUILD_DESCRIPTOR(_collection_scenery5, 13)}, // bones {0, BUILD_DESCRIPTOR(_collection_scenery5, 18)}, // alien sludge + + // jjaro + {_scenery_is_solid, BUILD_DESCRIPTOR(_collection_scenery4, 5), WORLD_ONE/6, -WORLD_ONE/8, NONE, BUILD_DESCRIPTOR(_collection_scenery3, 6)}, + {_scenery_is_solid, BUILD_DESCRIPTOR(_collection_scenery4, 7), WORLD_ONE/8, WORLD_ONE, NONE, BUILD_DESCRIPTOR(_collection_scenery3, 8)}, // long green light + {0, BUILD_DESCRIPTOR(_collection_scenery4, 4)}, // junk + {0, BUILD_DESCRIPTOR(_collection_scenery4, 9)}, // big antenna + {0, BUILD_DESCRIPTOR(_collection_scenery4, 10)}, // big antenna + {_scenery_is_solid, BUILD_DESCRIPTOR(_collection_scenery4, 11), WORLD_ONE_FOURTH, WORLD_ONE_HALF}, // alien supply can + {0, BUILD_DESCRIPTOR(_collection_scenery4, 13)}, // bones + {0, BUILD_DESCRIPTOR(_collection_scenery4, 17)}, // big bones + {0, BUILD_DESCRIPTOR(_collection_scenery4, 12)}, // pfhor pieces + {0, BUILD_DESCRIPTOR(_collection_scenery4, 14)}, // bob pieces + {0, BUILD_DESCRIPTOR(_collection_scenery4, 15)}, // bob blood }; diff --git a/marathon2/scottish_textures.c b/marathon2/scottish_textures.c index 4b801ca..88d11de 100644 --- a/marathon2/scottish_textures.c +++ b/marathon2/scottish_textures.c @@ -69,7 +69,7 @@ not only that, but texture_horizontal_polygon() is actually faster than texture_ //calculate_shading_table() needs to be inlined in a macro */ -#include +#include "cseries.h" #include "render.h" @@ -219,27 +219,27 @@ void _texture_vertical_polygon_lines8(struct bitmap_definition *screen, struct v void _transparent_texture_vertical_polygon_lines8(struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, short *y0_table, short *y1_table); void _tint_vertical_polygon_lines8(struct bitmap_definition *screen, struct view_data *view, - struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word data); + struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word transfer_data); void _randomize_vertical_polygon_lines8(struct bitmap_definition *screen, struct view_data *view, - struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word data); + struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word transfer_data); void _texture_vertical_polygon_lines16(struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, short *y0_table, short *y1_table); void _transparent_texture_vertical_polygon_lines16(struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, short *y0_table, short *y1_table); void _tint_vertical_polygon_lines16(struct bitmap_definition *screen, struct view_data *view, - struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word data); + struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word transfer_data); void _randomize_vertical_polygon_lines16(struct bitmap_definition *screen, struct view_data *view, - struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word data); + struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word transfer_data); void _texture_vertical_polygon_lines32(struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, short *y0_table, short *y1_table); void _transparent_texture_vertical_polygon_lines32(struct bitmap_definition *screen, struct view_data *view, struct _vertical_polygon_data *data, short *y0_table, short *y1_table); void _tint_vertical_polygon_lines32(struct bitmap_definition *screen, struct view_data *view, - struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word data); + struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word transfer_data); void _randomize_vertical_polygon_lines32(struct bitmap_definition *screen, struct view_data *view, - struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word data); + struct _vertical_polygon_data *data, short *y0_table, short *y1_table, word transfer_data); static short *build_x_table(short *table, short x0, short y0, short x1, short y1); static short *build_y_table(short *table, short x0, short y0, short x1, short y1); @@ -266,8 +266,8 @@ void _landscape_horizontal_polygon_lines32(struct bitmap_definition *texture, st void allocate_texture_tables( void) { - scratch_table0= malloc(sizeof(short)*MAXIMUM_SCRATCH_TABLE_ENTRIES); - scratch_table1= malloc(sizeof(short)*MAXIMUM_SCRATCH_TABLE_ENTRIES); + scratch_table0= (short *)malloc(sizeof(short)*MAXIMUM_SCRATCH_TABLE_ENTRIES); + scratch_table1= (short *)malloc(sizeof(short)*MAXIMUM_SCRATCH_TABLE_ENTRIES); precalculation_table= malloc(MAXIMUM_PRECALCULATION_TABLE_ENTRY_SIZE*MAXIMUM_SCRATCH_TABLE_ENTRIES); assert(scratch_table0&&scratch_table1&&precalculation_table); @@ -280,7 +280,7 @@ void texture_horizontal_polygon( struct view_data *view) { short vertex, highest_vertex, lowest_vertex; - point2d *vertices= &polygon->vertices; + point2d *vertices= (point2d *) &polygon->vertices; assert(polygon->vertex_count>=MINIMUM_VERTICES_PER_SCREEN_POLYGON&&polygon->vertex_counttexture, screen, view, precalculation_table, + _texture_horizontal_polygon_lines8(polygon->texture, screen, view, (struct _horizontal_polygon_line_data *)precalculation_table, vertices[highest_vertex].y, left_table, right_table, aggregate_total_line_count); break; case _big_landscaped_transfer: - _landscape_horizontal_polygon_lines8(polygon->texture, screen, view, precalculation_table, + _landscape_horizontal_polygon_lines8(polygon->texture, screen, view, (struct _horizontal_polygon_line_data *)precalculation_table, vertices[highest_vertex].y, left_table, right_table, aggregate_total_line_count); break; @@ -434,11 +434,11 @@ void texture_horizontal_polygon( switch (polygon->transfer_mode) { case _textured_transfer: - _texture_horizontal_polygon_lines16(polygon->texture, screen, view, precalculation_table, + _texture_horizontal_polygon_lines16(polygon->texture, screen, view, (struct _horizontal_polygon_line_data *)precalculation_table, vertices[highest_vertex].y, left_table, right_table, aggregate_total_line_count); break; case _big_landscaped_transfer: - _landscape_horizontal_polygon_lines16(polygon->texture, screen, view, precalculation_table, + _landscape_horizontal_polygon_lines16(polygon->texture, screen, view, (struct _horizontal_polygon_line_data *)precalculation_table, vertices[highest_vertex].y, left_table, right_table, aggregate_total_line_count); break; @@ -451,12 +451,12 @@ void texture_horizontal_polygon( switch (polygon->transfer_mode) { case _textured_transfer: - _texture_horizontal_polygon_lines32(polygon->texture, screen, view, precalculation_table, + _texture_horizontal_polygon_lines32(polygon->texture, screen, view, (struct _horizontal_polygon_line_data *)precalculation_table, vertices[highest_vertex].y, left_table, right_table, aggregate_total_line_count); break; case _big_landscaped_transfer: - _landscape_horizontal_polygon_lines32(polygon->texture, screen, view, precalculation_table, + _landscape_horizontal_polygon_lines32(polygon->texture, screen, view, (struct _horizontal_polygon_line_data *)precalculation_table, vertices[highest_vertex].y, left_table, right_table, aggregate_total_line_count); break; @@ -479,7 +479,7 @@ void texture_vertical_polygon( struct view_data *view) { short vertex, highest_vertex, lowest_vertex; - point2d *vertices= &polygon->vertices; + point2d *vertices= (point2d *) &polygon->vertices; assert(polygon->vertex_count>=MINIMUM_VERTICES_PER_SCREEN_POLYGON&&polygon->vertex_counttexture->flags&_TRANSPARENT_BIT) ? - _transparent_texture_vertical_polygon_lines8(screen, view, precalculation_table, left_table, right_table) : - _texture_vertical_polygon_lines8(screen, view, precalculation_table, left_table, right_table); + _transparent_texture_vertical_polygon_lines8(screen, view, (struct _vertical_polygon_data *)precalculation_table, left_table, right_table) : + _texture_vertical_polygon_lines8(screen, view, (struct _vertical_polygon_data *)precalculation_table, left_table, right_table); break; case _static_transfer: @@ -620,8 +620,8 @@ void texture_vertical_polygon( case _textured_transfer: // case _landscaped_transfer: (polygon->texture->flags&_TRANSPARENT_BIT) ? - _transparent_texture_vertical_polygon_lines16(screen, view, precalculation_table, left_table, right_table) : - _texture_vertical_polygon_lines16(screen, view, precalculation_table, left_table, right_table); + _transparent_texture_vertical_polygon_lines16(screen, view, (struct _vertical_polygon_data *)precalculation_table, left_table, right_table) : + _texture_vertical_polygon_lines16(screen, view, (struct _vertical_polygon_data *)precalculation_table, left_table, right_table); break; case _static_transfer: @@ -640,8 +640,8 @@ void texture_vertical_polygon( case _textured_transfer: // case _landscaped_transfer: (polygon->texture->flags&_TRANSPARENT_BIT) ? - _transparent_texture_vertical_polygon_lines32(screen, view, precalculation_table, left_table, right_table) : - _texture_vertical_polygon_lines32(screen, view, precalculation_table, left_table, right_table); + _transparent_texture_vertical_polygon_lines32(screen, view, (struct _vertical_polygon_data *)precalculation_table, left_table, right_table) : + _texture_vertical_polygon_lines32(screen, view, (struct _vertical_polygon_data *)precalculation_table, left_table, right_table); break; case _static_transfer: @@ -667,8 +667,6 @@ void texture_rectangle( struct bitmap_definition *screen, struct view_data *view) { - #pragma unused (view) /* we don’t need no steenkin’ view */ - if (rectangle->x0x1 && rectangle->y0y1) { /* subsume screen boundaries into clipping parameters */ @@ -696,7 +694,7 @@ void texture_rectangle( void *shading_table; short *y0_table= scratch_table0, *y1_table= scratch_table1; - struct _vertical_polygon_data *header= precalculation_table; + struct _vertical_polygon_data *header= (struct _vertical_polygon_data *)precalculation_table; struct _vertical_polygon_line_data *data= (struct _vertical_polygon_line_data *) (header+1); fixed texture_dx= INTEGER_TO_FIXED(texture->width)/screen_width; @@ -793,7 +791,7 @@ void texture_rectangle( data->texture_y= texture_y - INTEGER_TO_FIXED(first); data->texture_dy= texture_dy; data->shading_table= shading_table; - data->texture= read; + data->texture= (byte *)read; texture_x+= texture_dx; data+= 1; @@ -813,17 +811,17 @@ void texture_rectangle( switch (rectangle->transfer_mode) { case _textured_transfer: - _transparent_texture_vertical_polygon_lines8(screen, view, precalculation_table, + _transparent_texture_vertical_polygon_lines8(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1); break; case _static_transfer: - _randomize_vertical_polygon_lines8(screen, view, precalculation_table, + _randomize_vertical_polygon_lines8(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1, rectangle->transfer_data); break; case _tinted_transfer: - _tint_vertical_polygon_lines8(screen, view, precalculation_table, + _tint_vertical_polygon_lines8(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1, rectangle->transfer_data); break; @@ -836,17 +834,17 @@ void texture_rectangle( switch (rectangle->transfer_mode) { case _textured_transfer: - _transparent_texture_vertical_polygon_lines16(screen, view, precalculation_table, + _transparent_texture_vertical_polygon_lines16(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1); break; case _static_transfer: - _randomize_vertical_polygon_lines16(screen, view, precalculation_table, + _randomize_vertical_polygon_lines16(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1, rectangle->transfer_data); break; case _tinted_transfer: - _tint_vertical_polygon_lines16(screen, view, precalculation_table, + _tint_vertical_polygon_lines16(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1, rectangle->transfer_data); break; @@ -859,17 +857,17 @@ void texture_rectangle( switch (rectangle->transfer_mode) { case _textured_transfer: - _transparent_texture_vertical_polygon_lines32(screen, view, precalculation_table, + _transparent_texture_vertical_polygon_lines32(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1); break; case _static_transfer: - _randomize_vertical_polygon_lines32(screen, view, precalculation_table, + _randomize_vertical_polygon_lines32(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1, rectangle->transfer_data); break; case _tinted_transfer: - _tint_vertical_polygon_lines32(screen, view, precalculation_table, + _tint_vertical_polygon_lines32(screen, view, (struct _vertical_polygon_data *)precalculation_table, scratch_table0, scratch_table1, rectangle->transfer_data); break; diff --git a/marathon2/scottish_textures.s b/marathon2/scottish_textures.s new file mode 100644 index 0000000..e0e2826 --- /dev/null +++ b/marathon2/scottish_textures.s @@ -0,0 +1,788 @@ +;struct _vertical_polygon_data +;{ +; short downshift; +; short x0; +; short width; +; +; short pad; +;}; +data_downshift EQU 0 +data_x0 EQU 2 +data_width EQU 4 +data_pad EQU 6 + +;struct bitmap_definition +;{ +; short width, height; /* in pixels */ +; short bytes_per_row; /* if ==NONE this is a transparent RLE shape */ +; +; short flags; /* [column_order.1] [unused.15] */ +; short bit_depth; /* should always be ==8 */ +; +; short unused[8]; +; +; pixel8 *row_addresses[1]; +;}; +bitmap_width EQU 0 +bitmap_height EQU 2 +bitmap_bytes_per_row EQU 4 +bitmap_flags EQU 6 +bitmap_bit_depth EQU 8 +bitmap_row_addresses EQU 26 + +;struct _vertical_polygon_line_data +;{ +; void *shading_table; +; pixel8 *texture; +; long texture_y, texture_dy; +;}; +line_shading_table EQU 0 +line_texture EQU 4 +line_texture_y EQU 8 +line_texture_dy EQU 12 + + export ._texture_vertical_polygon_lines8[DS] + export ._texture_vertical_polygon_lines8 + + toc + + csect _texture_vertical_polygon_lines8[DS] + dc.l ._texture_vertical_polygon_lines8, TOC[tc0] + + toc + tc _texture_vertical_polygon_lines8[TC], _texture_vertical_polygon_lines8[DS] + + csect [PR] + +; parameters +; r3 struct bitmap_definition *screen +; r4 struct view_data *view +; r5 struct _vertical_polygon_data *data +; r6 short *y0_table +; r7 short *y1_table + +screen EQU r3 +view EQU r4 ; unused +data EQU r5 +y0_table EQU r6 +y1_table EQU r7 + +._texture_vertical_polygon_lines8: + stmw r13,-0x004C(SP) + stwu SP,-0x0110(SP) + addi r4,r5,8 + stw r4,0x0038(SP) + li r12,0 + lha r8,0x0004(r5) + stw r8,0x003C(SP) + cmpwi r8,0 + lha r9,0x0002(r5) + stb r12,0x0044(SP) + lha r11,0x0004(r3) + stw r9,0x0040(SP) + lha r10,0x0000(r5) + ble bail +outer_loop_start: + lwz r5,0x003C(SP) + lwz r4,0x0038(SP) + cmpwi r5,4 + lha r17,0x0000(r6) + lwz r9,0x0008(r4) + lwz r28,0x000C(r4) + lwz r29,0x0004(r4) + lwz r30,0x0000(r4) + lha r12,0x0000(r7) + blt do_trivial_loop + lwz r4,0x0040(SP) + clrlwi. r4,r4,30 + bne do_trivial_loop + lbz r4,0x0044(SP) + cmpwi r4,0 + beq skip_trivial_loop +do_trivial_loop: + lwz r0,0x0040(SP) + subc. r12,r12,r17 + slwi r4,r17,2 + li r8,0 + stb r8,0x0044(SP) + add r5,r3,r4 + lwz r8,0x001A(r5) + addi r6,r6,2 + addi r7,r7,2 + add r8,r0,r8 + ble trivial_loop_skip + mtctr r12 + subc r12,r8,r11 +trivial_loop: srw r4,r9,r10 + lbzx r5,r29,r4 + add r9,r9,r28 + lbzx r8,r30,r5 + stbux r8,r12,r11 + bdnz trivial_loop +trivial_loop_skip: + lwz r8,0x003C(SP) + lwz r4,0x0040(SP) + subi r8,r8,1 + lwz r5,0x0038(SP) + addi r4,r4,1 + stw r8,0x003C(SP) + addi r5,r5,16 + stw r4,0x0040(SP) + cmpwi cr6,r8,0 + stw r5,0x0038(SP) + b outer_loop_end +skip_trivial_loop: + lha r0,0x0002(r6) + stw r0,0x0048(SP) + cmpw r17,r0 + lwz r27,0x0038(SP) + stw r0,0x004C(SP) + lha r16,0x0004(r6) + lwz r8,0x0018(r27) + stw r16,0x0050(SP) + lwz r20,0x001C(r27) + lwz r26,0x0014(r27) + lwz r25,0x0010(r27) + lwz r5,0x0028(r27) + lwz r19,0x002C(r27) + lwz r24,0x0024(r27) + lwz r23,0x0020(r27) + lwz r4,0x0038(r27) + lwz r18,0x003C(r27) + lwz r22,0x0034(r27) + lwz r21,0x0030(r27) + lha r27,0x0006(r6) + stw r27,0x0054(SP) + lha r0,0x0002(r7) + sth r0,0x0058(SP) + cmpw cr6,r12,r0 + lha r0,0x0004(r7) + sth r0,0x005A(SP) + lha r0,0x0006(r7) + sth r0,0x005C(SP) + ble sync_max1 + stw r17,0x004C(SP) +sync_max1: lwz r0,0x004C(SP) + cmpw r0,r16 + ble sync_max2 + lwz r16,0x004C(SP) +sync_max2: cmpw r16,r27 + ble sync_max3 + mr r27,r16 +sync_max3: slwi r0,r27,2 + add r16,r3,r0 + lwz r0,0x0040(SP) + lwz r16,0x001A(r16) + add r16,r16,r0 + ble cr6,sync_min1 + lha r12,0x0058(SP) +sync_min1: lha r0,0x005A(SP) + cmpw r12,r0 + ble sync_min2 + lha r12,0x005A(SP) +sync_min2: lha r0,0x005C(SP) + cmpw r12,r0 + ble sync_min3 + lha r12,0x005C(SP) +sync_min3: cmpw r12,r27 + bgt sync_loops + lwz r4,0x003C(SP) + li r5,1 + stb r5,0x0044(SP) + cmpwi cr6,r4,0 + b outer_loop_end +sync_loops: slwi r0,r17,2 + subc. r12,r27,r17 + add r17,r3,r0 + lwz r0,0x0040(SP) + lwz r17,0x001A(r17) + li r15,255 + add r17,r0,r17 + li r14,-1 + li r13,-1 + subis r0,r15,1 + stw r0,0x0060(SP) + subis r0,r14,255 + stw r0,0x0064(SP) + addis r0,r13,256 + stw r0,0x0068(SP) + ble sync_loop_skip1 + mtctr r12 + subc r12,r17,r11 +sync_loop1: srw r17,r9,r10 + lbzx r15,r29,r17 + add r9,r9,r28 + lbzx r14,r30,r15 + stbux r14,r12,r11 + bdnz sync_loop1 +sync_loop_skip1: + lwz r0,0x0048(SP) + subc. r12,r27,r0 + slwi r0,r0,2 + add r17,r3,r0 + lwz r0,0x0040(SP) + lwz r17,0x001A(r17) + add r17,r17,r0 + ble sync_loop_skip2 + mtctr r12 + subc r15,r17,r11 + addi r12,r15,1 +sync_loop2: srw r17,r8,r10 + lbzx r15,r26,r17 + add r8,r8,r20 + lbzx r14,r25,r15 + stbux r14,r12,r11 + bdnz sync_loop2 +sync_loop_skip2: + lwz r0,0x0050(SP) + subc. r12,r27,r0 + slwi r0,r0,2 + add r17,r3,r0 + lwz r0,0x0040(SP) + lwz r17,0x001A(r17) + add r17,r17,r0 + ble sync_loop_skip3 + mtctr r12 + subc r15,r17,r11 + addi r12,r15,2 +sync_loop3: srw r17,r5,r10 + lbzx r15,r24,r17 + add r5,r5,r19 + lbzx r14,r23,r15 + stbux r14,r12,r11 + bdnz sync_loop3 +sync_loop_skip3: + lwz r0,0x0054(SP) + subc. r12,r27,r0 + slwi r0,r0,2 + add r17,r3,r0 + lwz r0,0x0040(SP) + lwz r17,0x001A(r17) + add r17,r17,r0 + ble sync_loop_skip4 + mtctr r12 + subc r15,r17,r11 + addi r12,r15,3 +sync_loop4: srw r17,r4,r10 + lbzx r15,r22,r17 + add r4,r4,r18 + lbzx r14,r21,r15 + stbux r14,r12,r11 + bdnz sync_loop4 +sync_loop_skip4: + lha r0,0x0004(r7) + lha r12,0x0000(r7) + subc r0,r0,r27 + lha r15,0x0002(r7) + subc r17,r12,r27 + stw r0,0x0070(SP) + subc r0,r15,r27 + lha r15,0x0006(r7) + stw r0,0x006C(SP) + cmpw r17,r0 + subc r0,r15,r27 + stw r0,0x0074(SP) + ble min1 + lwz r17,0x006C(SP) +min1: lwz r15,0x0070(SP) + cmpw r17,r15 + ble min2 + lwz r17,0x0070(SP) +min2: lwz r15,0x0074(SP) + cmpw r17,r15 + ble min3 + lwz r17,0x0074(SP) +min3: srw r0,r4,r10 + stw r0,0x009C(SP) + srw r15,r5,r10 + stw r0,0x0078(SP) + srw r0,r8,r10 + stw r15,0x00A0(SP) + srw r14,r9,r10 + stw r15,0x007C(SP) + cmpwi r17,0 + lwz r15,0x009C(SP) + stw r0,0x00A4(SP) + stw r0,0x0080(SP) + lbzx r0,r15,r22 + stw r14,0x00A8(SP) + stw r14,0x0084(SP) + lbzx r0,r21,r0 + lwz r31,0x0060(SP) + and r0,r0,r31 + lwz r31,0x00A0(SP) + stw r0,0x00AC(SP) + lbzx r0,r31,r24 + lbzx r0,r23,r0 + lwz r31,0x00AC(SP) + slwi r0,r0,8 + or r0,r31,r0 + lwz r31,0x0064(SP) + and r0,r0,r31 + lwz r31,0x00A4(SP) + stw r0,0x00B0(SP) + lbzx r0,r31,r26 + lbzx r0,r25,r0 + lwz r31,0x00B0(SP) + slwi r0,r0,16 + or r0,r31,r0 + lwz r31,0x0068(SP) + and r0,r0,r31 + lwz r31,0x00A8(SP) + stw r0,0x00B4(SP) + lbzx r0,r31,r29 + lwz r15,0x009C(SP) + lbzx r0,r30,r0 + lwz r31,0x00B4(SP) + slwi r0,r0,24 + or r31,r31,r0 + lwz r0,0x00A4(SP) + add r0,r17,r27 + lwz r27,0x00A0(SP) + stw r0,0x0088(SP) + ble desync + stw r3,0x008C(SP) + mtctr r17 + stw r6,0x0094(SP) + subc r12,r16,r11 + lwz r3,0x0090(SP) + stw r7,0x0098(SP) + lwz r6,0x0078(SP) + lwz r7,0x007C(SP) +inner_loop: + lwz r15,0x0080(SP) + srw r3,r4,r10 + srw r17,r8,r10 + srw r16,r5,r10 + cmplw r3,r6 + cmplw cr6,r16,r7 + cmplw cr7,r17,r15 + srw r27,r9,r10 + beq second_pixel + mr r6,r3 + lbzx r0,r22,r6 + ; clrrwi r31,r31,8 + lbzx r0,r21,r0 + ; or r31,r31,r0 + rlwimi r31,r0,0,24,31 # bottom 8 +second_pixel: beq cr6,third_pixel + lbzx r0,r24,r16 + mr r7,r16 + lbzx r0,r23,r0 + ; lwz r16,0x0060(SP) + ; slwi r0,r0,8 + ; and r31,r31,r16 + ; or r31,r31,r0 + rlwimi r31,r0,8,16,23 # third 8 +third_pixel beq cr7,fourth_pixel + lbzx r0,r26,r17 + ; lwz r16,0x0064(SP) + lbzx r0,r25,r0 + ; and r31,r31,r16 + stw r17,0x0080(SP) + ; slwi r0,r0,16 + ; or r31,r31,r0 + rlwimi r31,r0,16,8,15 # second 8 +fourth_pixel: + lwz r17,0x0084(SP) + cmplw r27,r17 + beq data_write + lbzx r17,r29,r27 + ; lwz r15,0x0068(SP) + lbzx r16,r30,r17 + ; and r14,r31,r15 + stw r27,0x0084(SP) + ; slwi r16,r16,24 + ; or r31,r14,r16 + rlwimi r31,r16,24,0,7 # top 8 +data_write: stwux r31,r12,r11 + add r4,r4,r18 + add r5,r5,r19 + add r8,r8,r20 + add r9,r9,r28 + bdnz inner_loop + + stw r7,0x007C(SP) + add r16,r12,r11 + stw r6,0x0078(SP) + lwz r7,0x0098(SP) + stw r3,0x0090(SP) + lwz r6,0x0094(SP) + lwz r3,0x008C(SP) + lha r12,0x0000(r7) +desync: + lwz r27,0x0088(SP) + subc. r12,r12,r27 + ble desync_loop_skip1 + mtctr r12 + subc r12,r16,r11 +desync_loop1: srw r27,r9,r10 + lbzx r17,r29,r27 + add r9,r9,r28 + lbzx r15,r30,r17 + stbux r15,r12,r11 + bdnz desync_loop1 +desync_loop_skip1: + lha r9,0x0002(r7) + lwz r30,0x0088(SP) + subc. r12,r9,r30 + ble desync_loop_skip2 + mtctr r12 + subc r9,r16,r11 + addi r12,r9,1 +desync_loop2: srw r9,r8,r10 + lbzx r30,r26,r9 + add r8,r8,r20 + lbzx r29,r25,r30 + stbux r29,r12,r11 + bdnz desync_loop2 +desync_loop_skip2: + lha r8,0x0004(r7) + lwz r9,0x0088(SP) + subc. r12,r8,r9 + ble desync_loop_skip3 + mtctr r12 + subc r8,r16,r11 + addi r12,r8,2 +desync_loop3: srw r8,r5,r10 + lbzx r9,r24,r8 + add r5,r5,r19 + lbzx r30,r23,r9 + stbux r30,r12,r11 + bdnz desync_loop3 +desync_loop_skip3: + lha r5,0x0006(r7) + lwz r8,0x0088(SP) + subc. r12,r5,r8 + ble desync_loop_skip4 + mtctr r12 + subc r5,r16,r11 + addi r12,r5,3 +desync_loop4: srw r5,r4,r10 + lbzx r8,r22,r5 + add r4,r4,r18 + lbzx r9,r21,r8 + stbux r9,r12,r11 + bdnz desync_loop4 +desync_loop_skip4: + lwz r4,0x003C(SP) + addi r6,r6,8 + lwz r5,0x0038(SP) + subi r4,r4,4 + lwz r8,0x0040(SP) + cmpwi cr6,r4,0 + stw r4,0x003C(SP) + addi r5,r5,64 + stw r5,0x0038(SP) + addi r8,r8,4 + stw r8,0x0040(SP) + addi r7,r7,8 +outer_loop_end: + bgt cr6,outer_loop_start +bail: + addi SP,SP,272 + lmw r13,-0x004C(SP) + blr + +funny_traceback: + dc.l 0x00000000 ; --- Traceback Table --- + dc.b 0x00 ; traceback format version + dc.b 0x00 ; language: TB_C (C) + dc.b 0x20 ; has_tboff + dc.b 0x40 ; name_present | WALK_ONCOND + dc.b 0x00 ; fpr_saved = 0 + dc.b 0x00 ; gpr_saved = 0 + dc.b 0x00 ; fixedparms = 0 + dc.b 0x01 ; floatparms = 0, parmsonstk + dc.l funny_traceback-._texture_vertical_polygon_lines8 + dc.w 28 ; name length + dc.b 'HeyPervertStopLookingAtMyPEF' + ALIGN 2 + +# +# HORIZONTAL POLYGON LINES +# +# + export ._texture_horizontal_polygon_lines8[DS] + export ._texture_horizontal_polygon_lines8 + + toc + + csect _texture_horizontal_polygon_lines8[DS] + dc.l ._texture_horizontal_polygon_lines8, TOC[tc0] + + toc + tc _texture_horizontal_polygon_lines8[TC], _texture_horizontal_polygon_lines8[DS] + + csect [PR] +._texture_horizontal_polygon_lines8: + stmw r22,-0x0028(SP) + extsh r5,r10 + extsh r7,r7 + subi r5,r5,1 + extsh. r10,r5 + blt @bail +@outer_loop_top: + lha r0,0x0000(r8) + slwi r12,r7,2 + lha r11,0x0000(r9) + add r12,r4,r12 + lwz r29,0x0010(r6) + subc r27,r11,r0 + lwz r12,0x001A(r12) + addi r9,r9,2 + lwz r28,0x001A(r3) + add r12,r0,r12 + lwz r11,0x0000(r6) + addi r8,r8,2 + lwz r5,0x0004(r6) + clrlwi. r0,r12,30 + lwz r31,0x0008(r6) + extsh r27,r27 + lwz r30,0x000C(r6) + beq @align_loop_skip +@align_loop: rlwinm r0,r5,14,18,24 + srwi r26,r11,25 + subi r27,r27,1 + add r26,r0,r26 + lbzx r0,r26,r28 + add r11,r11,r31 + lbzx r0,r29,r0 + add r5,r5,r30 + stb r0,0x0000(r12) + addi r12,r12,1 + extsh r27,r27 + clrlwi. r0,r12,30 + bne @align_loop +@align_loop_skip: + cmpwi r27,4 + blt @inner_loop_skip + srawi r0,r27,2 + extsh r26,r0 + subi r0,r26,1 + extsh. r26,r0 + blt @inner_loop_skip + addi r0,r26,1 + mtctr r0 + li r26,-256 + subi r12,r12,4 + addis r26,r26,1 +@inner_loop: rlwinm r0,r5,14,18,24 + srwi r25,r11,25 + add r5,r5,r30 + add r25,r0,r25 + lbzx r0,r25,r28 + add r11,r11,r31 + lbzx r0,r29,r0 + rlwinm r25,r5,14,18,24 + srwi r24,r11,25 + add r5,r30,r5 + add r25,r25,r24 + lbzx r25,r28,r25 + slwi r0,r0,24 + add r11,r31,r11 + lbzx r25,r29,r25 + rlwinm r24,r5,14,18,24 + srwi r23,r11,25 + add r22,r31,r11 + add r11,r24,r23 + lbzx r11,r28,r11 + rlwimi r0,r25,16,8,15 # stuff second byte + add r5,r30,r5 + lbzx r24,r29,r11 + add r11,r31,r22 + rlwinm r23,r5,14,18,24 + srwi r22,r22,25 + add r23,r23,r22 + lbzx r23,r28,r23 + rlwimi r0,r24,8,16,23 # stuff third byte + lbzx r23,r29,r23 + add r5,r30,r5 + rlwimi r0,r23,0,24,31 # stuff last byte + stwu r0,0x0004(r12) + bdnz @inner_loop + addi r12,r12,4 +@inner_loop_skip: + clrlwi. r26,r27,30 + beq @tail_loop_skip + subi r12,r12,1 +@tail_loop: rlwinm r0,r5,14,18,24 + srwi r26,r11,25 + subi r27,r27,1 + add r26,r0,r26 + lbzx r0,r26,r28 + extsh r27,r27 + lbzx r0,r29,r0 + add r11,r11,r31 + stbu r0,0x0001(r12) + clrlwi. r0,r27,30 + add r5,r5,r30 + bne @tail_loop +@tail_loop_skip: + subi r11,r10,1 + addi r5,r7,1 + extsh. r10,r11 + addi r6,r6,20 + extsh r7,r5 + bge @outer_loop_top +@bail: lmw r22,-0x0028(SP) + blr + +# +# LANDSCAPE POLYGON LINES +# +# +# parameters +# r3 struct bitmap_definition *texture +# r4 struct bitmap_definition *screen +# r5 struct view_data *view unused +# r6 struct _horizontal_polygon_line_data *data +# r7 short y0 +# r8 short *x0_table +# r9 short *x1_table +# r10 short line_count + +#struct _horizontal_polygon_line_data +#{ +# unsigned long source_x, source_y; +# unsigned long source_dx, source_dy; +# +# void *shading_table; +#}; +horiz_source_x EQU 0 +horiz_source_y EQU 4 +horiz_source_dx EQU 8 +horiz_source_dy EQU 12 +horiz_shading_table EQU 16 + + export ._landscape_horizontal_polygon_lines8[DS] + export ._landscape_horizontal_polygon_lines8 + + toc + + csect _landscape_horizontal_polygon_lines8[DS] + dc.l ._landscape_horizontal_polygon_lines8, TOC[tc0] + + toc + tc _landscape_horizontal_polygon_lines8[TC], _landscape_horizontal_polygon_lines8[DS] + + csect [PR] +._landscape_horizontal_polygon_lines8 + stmw r25,-0x001C(SP) + lha r5,bitmap_height(r3) + extsh r7,r7 + cmpwi r5,1024 + extsh r10,r10 + bne @1 + li r29,22 + b @2 +@1: li r29,23 +@2: subi r5,r10,1 + extsh. r10,r5 + blt @land_bail +@land_line_loop: + lha r0,0x0000(r8) + slwi r12,r7,2 + lwz r11,horiz_source_y(r6) + add r12,r4,r12 + lha r5,0x0000(r9) + slwi r11,r11,2 + lwz r12,0x001A(r12) + add r11,r3,r11 + lwz r31,horiz_shading_table(r6) + add r12,r0,r12 + lwz r30,0x001A(r11) + subc r27,r5,r0 + lwz r11,horiz_source_x(r6) + clrlwi. r0,r12,30 + lwz r5,horiz_source_dx(r6) + addi r9,r9,2 + addi r8,r8,2 + mr r28,r27 + beq @land_align_loop_skip + subi r28,r27,1 + cmpwi r28,0 + blt @land_align_loop_skip + mtctr r27 +@land_align_loop: + srw r0,r11,r29 + lbzx r0,r30,r0 + add r11,r11,r5 + lbzx r0,r31,r0 + stb r0,0x0000(r12) + addi r12,r12,1 + clrlwi. r0,r12,30 + beq @57F0 + bdnz @land_align_loop + mfctr r0 + subc r0,r27,r0 + subc r28,r28,r0 +@land_align_loop_skip: + cmpwi r28,4 + blt @land_inner_loop_skip + srawi r0,r28,2 + extsh r27,r0 + subi r0,r27,1 + extsh. r27,r0 + blt @land_inner_loop_skip + addi r0,r27,1 + mtctr r0 + subi r12,r12,4 +@land_inner_loop: + add r0,r11,r5 + srw r11,r11,r29 + lbzx r11,r30,r11 + add r27,r5,r0 + lbzx r11,r31,r11 + srw r0,r0,r29 + lbzx r0,r30,r0 + srw r26,r27,r29 + lbzx r0,r31,r0 + add r27,r5,r27 + lbzx r26,r30,r26 + rlwimi r0,r0,16,8,15 # second byte + lbzx r26,r31,r26 + rlwimi r0,r11,24,0,7 # first byte + srw r25,r27,r29 + lbzx r25,r30,r25 + rlwimi r0,r26,8,16,23 # third byte + lbzx r25,r31,r25 + add r11,r5,r27 + rlwimi r0,r25,0,24,31 # fourth byte + stwu r0,0x0004(r12) + bdnz @land_inner_loop + addi r12,r12,4 +@land_inner_loop_skip: + mr r27,r28 + clrlwi. r26,r27,30 + beq @land_tail_loop_skip + subi r28,r28,1 + cmpwi r28,0 + blt @land_tail_loop_skip + mtctr r27 + subi r12,r12,1 +@land_tail_loop: + srw r0,r11,r29 + lbzx r0,r30,r0 + clrlwi. r27,r28,30 + lbzx r0,r31,r0 + add r11,r11,r5 + stbu r0,0x0001(r12) + beq @land_tail_loop_skip + subi r28,r28,1 + bdnz @land_tail_loop +@land_tail_loop_skip: + subi r11,r10,1 + addi r5,r7,1 + extsh. r10,r11 + addi r6,r6,20 + extsh r7,r5 + bge @land_line_loop + lmw r25,-0x001C(SP) + blr +@57F0: mfctr r0 + subc r0,r27,r0 + subc r28,r28,r0 + b @land_align_loop_skip +@land_bail: lmw r25,-0x001C(SP) + blr diff --git a/marathon2/screen.c b/marathon2/screen.c index 09c1f53..552d1af 100644 --- a/marathon2/screen.c +++ b/marathon2/screen.c @@ -17,6 +17,7 @@ Friday, September 9, 1994 12:13:04 PM (alain) #include "macintosh_cseries.h" #include "my32bqd.h" +#include "textures.h" #include "valkyrie.h" #include @@ -38,13 +39,26 @@ Friday, September 9, 1994 12:13:04 PM (alain) #include +/* CJD --*/ +#if SUPPORT_DRAW_SPROCKET +#include "DrawSprocket.h" +#endif + +#if 1 +#include +extern pascal OSErr DMSuspendConfigure(Handle displayState, unsigned long reserved1) + THREEWORDINLINE(0x303C, 0x04E9, 0xABEB); +extern pascal OSErr DMResumeConfigure(Handle displayState, unsigned long reserved1) + THREEWORDINLINE(0x303C, 0x04E8, 0xABEB); +#endif + #ifdef mpwc #pragma segment screen #endif #ifdef DEBUG //#define CYBERMAXX -#define WHITE_SCREEN_BETWEEN_FRAMES +//#define WHITE_SCREEN_BETWEEN_FRAMES //#define DIRECT_SCREEN_TEST #endif @@ -114,7 +128,13 @@ struct copy_screen_data /* ---------- globals */ -GDHandle world_device; /* the device we’re running on */ +/* CJD -- */ +#if SUPPORT_DRAW_SPROCKET +DSpContextAttributes gDrawContextAttributes; +DSpContextReference gDrawContext; +#endif + +GDHandle world_device = nil; /* the device we’re running on */ WindowPtr screen_window; /* a window covering our entire device */ WindowPtr backdrop_window; /* a window covering all devices */ struct color_table *uncorrected_color_table; /* the pristine color environment of the game (can be 16bit) */ @@ -136,6 +156,8 @@ static boolean overhead_map_status= FALSE; //static short restore_depth, restore_flags; /* for SetDepth on exit */ static GDSpec restore_spec, resolution_restore_spec; +static VDSwitchInfoRec switchInfo; // save the real mode that the user had + #define FRAME_SAMPLE_SIZE 20 boolean displaying_fps= FALSE; short frame_count, frame_index; @@ -146,6 +168,15 @@ static boolean screen_initialized= FALSE; short bit_depth= NONE; short interface_bit_depth= NONE; +#if 1 +Handle display_manager_state; +#endif + +#ifdef envppc +boolean did_switch_the_resolution_on_last_enter_screen= FALSE; +boolean did_we_ever_switched_resolution= FALSE; +#endif + /* ---------- private prototypes */ static void update_screen(void); @@ -169,6 +200,11 @@ static void update_fps_display(GrafPtr port); static void calculate_screen_options(void); +/* CJD -- just a function to clear the attributes to a known init state */ +#if SUPPORT_DRAW_SPROCKET +static void InitDrawSprocketAttributes(DSpContextAttributes *inAttributes); +#endif + /* ---------- code */ void initialize_screen( struct screen_mode_data *mode) @@ -192,6 +228,41 @@ void initialize_screen( if (mode->bit_depth==32 && !enough_memory_for_32bit) mode->bit_depth= 16; if (mode->bit_depth==16 && !enough_memory_for_16bit) mode->bit_depth= 8; interface_bit_depth= bit_depth= mode->bit_depth; + + /* CJD -- Set up the DSp attributes before we ask it to request a context */ +#if SUPPORT_DRAW_SPROCKET + InitDrawSprocketAttributes(&gDrawContextAttributes); + + gDrawContextAttributes.displayWidth = 640; + gDrawContextAttributes.displayHeight = 480; + gDrawContextAttributes.colorNeeds = kDSpColorNeeds_Require; + + switch (mode->bit_depth) + { + case 32: + gDrawContextAttributes.backBufferDepthMask = kDSpDepthMask_32; + gDrawContextAttributes.displayDepthMask = kDSpDepthMask_32; + gDrawContextAttributes.backBufferBestDepth = 32; + gDrawContextAttributes.displayBestDepth = 32; + break; + + case 16: + gDrawContextAttributes.backBufferDepthMask = kDSpDepthMask_16; + gDrawContextAttributes.displayDepthMask = kDSpDepthMask_16; + gDrawContextAttributes.backBufferBestDepth = 16; + gDrawContextAttributes.displayBestDepth = 16; + break; + + default: + gDrawContextAttributes.backBufferDepthMask = kDSpDepthMask_8; + gDrawContextAttributes.displayDepthMask = kDSpDepthMask_8; + gDrawContextAttributes.backBufferBestDepth = 8; + gDrawContextAttributes.displayBestDepth = 8; + } + + gDrawContextAttributes.pageCount = 2; + +#else switch (mode->acceleration) { case _valkyrie_acceleration: @@ -200,7 +271,25 @@ void initialize_screen( interface_bit_depth= 8; break; } +#endif + + /* CJD -- Find a reserve a drawing context */ +#if SUPPORT_DRAW_SPROCKET + { + OSStatus theError; + + theError = DSpFindBestContext(&gDrawContextAttributes, &gDrawContext); + if (theError != noErr) + alert_user(fatalError, strERRORS, badMonitor, -1); + + gDrawContextAttributes.contextOptions |= kDSpContextOption_DontSyncVBL; + theError = DSpContext_Reserve(gDrawContext, &gDrawContextAttributes); + if (theError) + alert_user(fatalError, strERRORS, badMonitor, -1); + } + +#else /* beg, borrow or steal an n-bit device */ graphics_preferences->device_spec.bit_depth= interface_bit_depth; world_device= BestDevice(&graphics_preferences->device_spec); @@ -211,6 +300,7 @@ void initialize_screen( if (world_device) mode->bit_depth= bit_depth= interface_bit_depth= 8; } if (!world_device) alert_user(fatalError, strERRORS, badMonitor, -1); +#endif #ifdef OBSOLETE /* beg, borrow or steal an n-bit device */ @@ -227,27 +317,18 @@ void initialize_screen( { graphics_preferences->device_spec.width= DESIRED_SCREEN_WIDTH; graphics_preferences->device_spec.height= DESIRED_SCREEN_HEIGHT; -#if 0 - if (1) //(mode->texture_floor) - { - BuildGDSpec(&resolution_restore_spec, world_device); - SetResolutionGDSpec(&graphics_preferences->device_spec); - } - else - { - memset(&resolution_restore_spec, 0, sizeof(GDSpec)); - } -#endif - - /* get rid of the menu bar */ - HideMenuBar(GetMainDevice()); - uncorrected_color_table= malloc(sizeof(struct color_table)); - world_color_table= malloc(sizeof(struct color_table)); - visible_color_table= malloc(sizeof(struct color_table)); - interface_color_table= malloc(sizeof(struct color_table)); + uncorrected_color_table= (struct color_table *)malloc(sizeof(struct color_table)); + world_color_table= (struct color_table *)malloc(sizeof(struct color_table)); + visible_color_table= (struct color_table *)malloc(sizeof(struct color_table)); + interface_color_table= (struct color_table *)malloc(sizeof(struct color_table)); assert(uncorrected_color_table && world_color_table && visible_color_table && interface_color_table); + memset(world_color_table,0,sizeof(struct color_table)); + memset(interface_color_table,0,sizeof(struct color_table)); + /* CJD -- This is where we clear the screen to black and put up the window + in which the game is played */ +#if !SUPPORT_DRAW_SPROCKET backdrop_window= (WindowPtr) NewPtr(sizeof(CWindowRecord)); assert(backdrop_window); backdrop_window= GetNewCWindow(windBACKDROP_WINDOW, (Ptr) backdrop_window, (WindowPtr) -1); @@ -262,7 +343,33 @@ void initialize_screen( assert(screen_window); SetWRefCon(screen_window, refSCREEN_WINDOW); ShowWindow(screen_window); +#else + { + OSStatus theError; + DisplayIDType theID; + + DSpContext_FadeGammaOut(NULL, NULL); + theError = DSpContext_SetState(gDrawContext, kDSpContextState_Active); + DSpContext_FadeGammaIn(NULL, NULL); + + if (theError) + { + DebugStr("\pCould not set context state to active"); + } + /* CAF -- get the gdevice associated with the context */ + theError = DSpContext_GetBackBuffer(gDrawContext, kDSpBufferKind_Normal, (CGrafPtr *) &world_pixels); + if( theError ) + DebugStr("\p sh-t happened "); + + theError = DSpContext_GetDisplayID( gDrawContext, &theID ); + if( theError ) + DebugStr("\p sh-t happened again "); + + DMGetGDeviceByDisplayID( theID, &world_device, false ); + screen_window = (WindowPtr)world_pixels; + } +#endif /* allocate the bitmap_definition structure for our GWorld (it is reinitialized every frame */ world_pixels_structure= (struct bitmap_definition *) NewPtr(sizeof(struct bitmap_definition)+sizeof(pixel8 *)*MAXIMUM_WORLD_HEIGHT); assert(world_pixels_structure); @@ -280,7 +387,9 @@ void initialize_screen( /* make sure everything gets cleaned up after we leave */ atexit(restore_world_device); +#if !SUPPORT_DRAW_SPROCKET world_pixels= (GWorldPtr) NULL; +#endif } else { @@ -291,20 +400,49 @@ void initialize_screen( { if (screen_initialized) { + + /* get rid of the menu bar */ + HideMenuBar(GetMainDevice()); + GetPort(&old_port); SetPort(screen_window); PaintRect(&screen_window->portRect); SetPort(old_port); SetDepthGDSpec(&restore_spec); + + /* get rid of the menu bar */ + HideMenuBar(GetMainDevice()); + } BuildGDSpec(&restore_spec, world_device); +#ifdef envppc + // did we weak link in DisplayMgr? + if ((DMDisposeList!=NULL)) //(mode->texture_floor) + { + BuildGDSpec(&resolution_restore_spec, world_device); + resolution_restore_spec.bit_depth= graphics_preferences->device_spec.bit_depth; + if (!screen_initialized) + { + (void) DMGetDisplayMode(world_device, &switchInfo); + DMBeginConfigureDisplays(&display_manager_state); + DMResumeConfigure(display_manager_state, 0); + } + } +#endif } + + /* CAF -- just commenting out stuff that would make us crash */ +#if !SUPPORT_DRAW_SPROCKET SetDepthGDSpec(&graphics_preferences->device_spec); + /* get rid of the menu bar */ + HideMenuBar(GetMainDevice()); + MoveWindow(screen_window, (*world_device)->gdRect.left, (*world_device)->gdRect.top, FALSE); SizeWindow(screen_window, RECTANGLE_WIDTH(&(*world_device)->gdRect), RECTANGLE_HEIGHT(&(*world_device)->gdRect), TRUE); +#endif { Point origin; @@ -320,9 +458,12 @@ void initialize_screen( /* allocate and initialize our GWorld */ calculate_destination_frame(mode->size, mode->high_resolution, &bounds); + +#if ! SUPPORT_DRAW_SPROCKET error= screen_initialized ? myUpdateGWorld(&world_pixels, 0, &bounds, (CTabHandle) NULL, (GDHandle) NULL, 0) : myNewGWorld(&world_pixels, 0, &bounds, (CTabHandle) NULL, (GDHandle) NULL, 0); if (error!=noErr) alert_user(fatalError, strERRORS, outOfMemory, error); +#endif change_screen_mode(mode, FALSE); @@ -336,13 +477,52 @@ void enter_screen( { GrafPtr old_port; + if (world_view->overhead_map_active) set_overhead_map_status(FALSE); + if (world_view->terminal_mode_active) set_terminal_status(FALSE); + +#if defined(envppc) && ! SUPPORT_DRAW_SPROCKET + // did we weak link in DisplayMgr? + if ((DMDisposeList!=NULL) && graphics_preferences->do_resolution_switching) //(mode->texture_floor) + { + SetResolutionGDSpec(&graphics_preferences->device_spec, NULL); + did_switch_the_resolution_on_last_enter_screen= TRUE; + did_we_ever_switched_resolution= TRUE; + } + else + { + memset(&resolution_restore_spec, 0, sizeof(GDSpec)); + } + + MoveWindow(screen_window, (*world_device)->gdRect.left, (*world_device)->gdRect.top, FALSE); + SizeWindow(screen_window, RECTANGLE_WIDTH(&(*world_device)->gdRect), RECTANGLE_HEIGHT(&(*world_device)->gdRect), TRUE); + + { + Point origin; + + origin.h= - (RECTANGLE_WIDTH(&(*world_device)->gdRect)-DESIRED_SCREEN_WIDTH)/2; + origin.v= - (RECTANGLE_HEIGHT(&(*world_device)->gdRect)-DESIRED_SCREEN_HEIGHT)/2; + if (origin.v>0) origin.v= 0; + + GetPort(&old_port); + SetPort(screen_window); + SetOrigin(origin.h, origin.v); + SetPort(old_port); + } +#endif + GetPort(&old_port); SetPort(screen_window); + +#if SUPPORT_DRAW_SPROCKET + ForeColor( blackColor ); +#endif + PaintRect(&screen_window->portRect); SetPort(old_port); - if (world_view->overhead_map_active) set_overhead_map_status(FALSE); - if (world_view->terminal_mode_active) set_terminal_status(FALSE); +#ifdef envppc + assert_world_color_table(interface_color_table, world_color_table); +#endif change_screen_mode(&screen_mode, TRUE); @@ -359,6 +539,39 @@ void enter_screen( void exit_screen( void) { + +#if ! SUPPORT_DRAW_SPROCKET +#ifdef envppc + if (did_switch_the_resolution_on_last_enter_screen) + { + SetResolutionGDSpec(&resolution_restore_spec, NULL); +// DMSuspendConfigure(display_manager_state, 0); +// DMEndConfigureDisplays(display_manager_state); + did_switch_the_resolution_on_last_enter_screen= FALSE; + } + assert_world_color_table(interface_color_table, world_color_table); + + MoveWindow(screen_window, (*world_device)->gdRect.left, (*world_device)->gdRect.top, FALSE); + SizeWindow(screen_window, RECTANGLE_WIDTH(&(*world_device)->gdRect), RECTANGLE_HEIGHT(&(*world_device)->gdRect), FALSE); + + { + GrafPtr old_port; + Point origin; + + origin.h= - (RECTANGLE_WIDTH(&(*world_device)->gdRect)-DESIRED_SCREEN_WIDTH)/2; + origin.v= - (RECTANGLE_HEIGHT(&(*world_device)->gdRect)-DESIRED_SCREEN_HEIGHT)/2; + if (origin.v>0) origin.v= 0; + + GetPort(&old_port); + SetPort(screen_window); + SetOrigin(origin.h, origin.v); + PaintRect(&screen_window->portRect); + SetPort(old_port); + } +#endif + +#endif + switch (screen_mode.acceleration) { case _valkyrie_acceleration: @@ -424,8 +637,10 @@ void change_screen_mode( /* adjust the size of our GWorld based on mode->size and mode->resolution */ calculate_adjusted_source_frame(mode, &bounds); +#if ! SUPPORT_DRAW_SPROCKET error= myUpdateGWorld(&world_pixels, 0, &bounds, (CTabHandle) NULL, (GDHandle) NULL, 0); if (error!=noErr) alert_user(fatalError, strERRORS, outOfMemory, error); +#endif calculate_source_frame(mode->size, mode->high_resolution, &bounds); width= RECTANGLE_WIDTH(&bounds), height= RECTANGLE_HEIGHT(&bounds); @@ -444,6 +659,9 @@ void change_screen_mode( frame_count= frame_index= 0; +#ifdef envppc + resolution_restore_spec.bit_depth= graphics_preferences->device_spec.bit_depth; +#endif return; } @@ -493,8 +711,12 @@ void render_screen( if (world_view->terminal_mode_active) set_terminal_status(FALSE); } +#if ! SUPPORT_DRAW_SPROCKET myLockPixels(world_pixels); pixels= myGetGWorldPixMap(world_pixels); +#else + pixels=world_pixels->portPixMap; +#endif switch (screen_mode.acceleration) { @@ -593,7 +815,9 @@ void render_screen( halt(); } +#if ! SUPPORT_DRAW_SPROCKET myUnlockPixels(world_pixels); +#endif return; } @@ -645,8 +869,10 @@ void change_screen_clut( OSErr error; calculate_adjusted_source_frame(&screen_mode, &bounds); +#if ! SUPPORT_DRAW_SPROCKET error= myUpdateGWorld(&world_pixels, 0, &bounds, (CTabHandle) NULL, (GDHandle) NULL, 0); if (error!=noErr) alert_user(fatalError, strERRORS, outOfMemory, error); +#endif } return; @@ -886,7 +1112,12 @@ void animate_screen_clut( // if we’re doing full-screen fall through to LowLevelSetEntries case _no_acceleration: +#if SUPPORT_DRAW_SPROCKET + DSpContext_SetCLUTEntries( gDrawContext, (*macintosh_color_table)->ctTable, 0, + (*macintosh_color_table)->ctSize ); +#else LowLevelSetEntries(0, (*macintosh_color_table)->ctSize, (*macintosh_color_table)->ctTable); +#endif break; } @@ -901,12 +1132,16 @@ void assert_world_color_table( struct color_table *interface_color_table, struct color_table *world_color_table) { - if (interface_bit_depth==8) + if (interface_bit_depth==8 && interface_color_table->color_count) { CTabHandle macintosh_color_table= build_macintosh_color_table(interface_color_table); if (macintosh_color_table) { +#if SUPPORT_DRAW_SPROCKET + DSpContext_SetCLUTEntries( gDrawContext, (*macintosh_color_table)->ctTable, 0, + (*macintosh_color_table)->ctSize ); +#else GDHandle old_device; HLock((Handle)macintosh_color_table); @@ -914,12 +1149,12 @@ void assert_world_color_table( SetGDevice(world_device); SetEntries(0, (*macintosh_color_table)->ctSize, (*macintosh_color_table)->ctTable); SetGDevice(old_device); - DisposeHandle((Handle)macintosh_color_table); +#endif } } - if (world_color_table) animate_screen_clut(world_color_table, FALSE); + if (world_color_table && world_color_table->color_count) animate_screen_clut(world_color_table, FALSE); return; } @@ -946,6 +1181,7 @@ void darken_world_window( void validate_world_window( void) { +#if ! SUPPORT_DRAW_SPROCKET GrafPtr old_port; Rect bounds; @@ -954,6 +1190,7 @@ void validate_world_window( calculate_destination_frame(screen_mode.size, screen_mode.high_resolution, &bounds); ValidRect(&bounds); SetPort(old_port); +#endif switch (screen_mode.acceleration) { @@ -995,7 +1232,7 @@ static void update_fps_display( if (frame_countportRect.bottom-5); +#else + MoveTo(5, 20); +#endif RGBForeColor(&rgb_white); - DrawString(fps); + DrawString((StringPtr)fps); RGBForeColor(&rgb_black); SetPort(old_port); } @@ -1110,22 +1351,32 @@ static void restore_world_device( PaintRect(&screen_window->portRect); SetPort(old_port); - ShowMenuBar(); +#if !SUPPORT_DRAW_SPROCKET - /* put our device back the way we found it */ - SetDepthGDSpec(&restore_spec); + ShowMenuBar(); -#if 0 - if (resolution_restore_spec.width) +#ifdef envppc + if (did_switch_the_resolution_on_last_enter_screen || did_we_ever_switched_resolution) { - SetResolutionGDSpec(&resolution_restore_spec); + SetResolutionGDSpec(&resolution_restore_spec, &switchInfo); + } + if ((DMDisposeList!=NULL)) + { + DMSuspendConfigure(display_manager_state, 0); + DMEndConfigureDisplays(display_manager_state); } #endif + /* put our device back the way we found it */ + SetDepthGDSpec(&restore_spec); +#endif + +#if ! SUPPORT_DRAW_SPROCKET myDisposeGWorld(world_pixels); CloseWindow(screen_window); CloseWindow(backdrop_window); +#endif return; } @@ -1152,8 +1403,16 @@ static void update_screen( RGBForeColor(&rgb_black); RGBBackColor(&rgb_white); + OffsetRect(&source, -source.left, -source.top); + +#if SUPPORT_DRAW_SPROCKET + DSpContext_InvalBackBufferRect(gDrawContext, &source ); + DSpContext_SwapBuffers(gDrawContext, NULL, NULL); + DSpContext_GetBackBuffer( gDrawContext, kDSpBufferKind_Normal, (CGrafPtr *)&world_pixels ); +#else CopyBits((BitMapPtr)*world_pixels->portPixMap, &screen_window->portBits, &source, &destination, srcCopy, (RgnHandle) NULL); +#endif RGBForeColor(&old_forecolor); RGBBackColor(&old_backcolor); @@ -1167,15 +1426,24 @@ static void update_screen( short source_rowBytes, destination_rowBytes, source_width, destination_width; PixMapHandle screen_pixmap= (*world_device)->gdPMap; +#if ! SUPPORT_DRAW_SPROCKET source_rowBytes= (*myGetGWorldPixMap(world_pixels))->rowBytes&0x3fff; +#else + source_rowBytes = (*world_pixels->portPixMap)->rowBytes & 0x3FFF; +#endif + destination_rowBytes= (*screen_pixmap)->rowBytes&0x3fff; source_width= RECTANGLE_WIDTH(&source); destination_width= RECTANGLE_WIDTH(&destination); - data.source= myGetPixBaseAddr(world_pixels); +#if ! SUPPORT_DRAW_SPROCKET + data.source= (byte *)myGetPixBaseAddr(world_pixels); +#else + data.source = (byte *)(*world_pixels->portPixMap)->baseAddr; +#endif data.source_slop= source_rowBytes-source_width*pelsize; - data.destination= (*screen_pixmap)->baseAddr + (destination.top-screen_window->portRect.top)*destination_rowBytes + + data.destination= (byte *)(*screen_pixmap)->baseAddr + (destination.top-screen_window->portRect.top)*destination_rowBytes + (destination.left-screen_window->portRect.left)*pelsize; data.destination_slop= destination_rowBytes-destination_width*pelsize; @@ -1211,9 +1479,9 @@ static void update_screen( } mode= true32b; - SwapMMUMode(&mode); + SwapMMUMode((signed char *)&mode); quadruple_screen(&data); - SwapMMUMode(&mode); + SwapMMUMode((signed char *)&mode); } return; @@ -1404,3 +1672,32 @@ void quadruple_screen( return; } #endif + +// CJD -- just a function to clear the attributes to a known init state +#if SUPPORT_DRAW_SPROCKET +static void +InitDrawSprocketAttributes(DSpContextAttributes *inAttributes) +{ + if( NULL == inAttributes ) + DebugStr("\pNULL context sent to InitDrawSprocketAttributes!"); + + inAttributes->frequency = 0; + inAttributes->displayWidth = 0; + inAttributes->displayHeight = 0; + inAttributes->reserved1 = 0; + inAttributes->reserved2 = 0; + inAttributes->colorNeeds = 0; + inAttributes->colorTable = NULL; + inAttributes->contextOptions = 0; + inAttributes->backBufferDepthMask = 0; + inAttributes->displayDepthMask = 0; + inAttributes->backBufferBestDepth = 0; + inAttributes->displayBestDepth = 0; + inAttributes->pageCount = 0; + inAttributes->gameMustConfirmSwitch = false; + inAttributes->reserved3[0] = 0; + inAttributes->reserved3[1] = 0; + inAttributes->reserved3[2] = 0; + inAttributes->reserved3[3] = 0; +} +#endif \ No newline at end of file diff --git a/marathon2/screen.h b/marathon2/screen.h index 500884f..bddb844 100644 --- a/marathon2/screen.h +++ b/marathon2/screen.h @@ -30,6 +30,14 @@ extern struct color_table *world_color_table, *visible_color_table, *interface_c #ifdef mac extern GDHandle world_device; extern WindowPtr screen_window; +extern GWorldPtr world_pixels; + +#if SUPPORT_DRAW_SPROCKET +#include "DrawSprocket.h" +extern DSpContextAttributes gDrawContextAttributes; +extern DSpContextReference gDrawContext; +#endif + #endif /* ---------- prototypes/SCREEN.C */ @@ -59,6 +67,9 @@ void change_gamma_level(short gamma_level); void assert_world_color_table(struct color_table *world_color_table, struct color_table *interface_color_table); +void start_teleporting_effect(boolean out); +void start_extravision_effect(boolean out); + #ifdef mac void initialize_screen(struct screen_mode_data *mode); void change_screen_mode(struct screen_mode_data *mode, boolean redraw); diff --git a/marathon2/screen_drawing.c b/marathon2/screen_drawing.c index e9f1cf8..b66b7e8 100644 --- a/marathon2/screen_drawing.c +++ b/marathon2/screen_drawing.c @@ -74,10 +74,14 @@ void initialize_screen_drawing( void _set_port_to_screen_window( void) { +#if SUPPORT_DRAW_SPROCKET + _set_port_to_gworld(); +#else assert(!old_graphics_port && !old_graphics_device && !destination_graphics_port); GetGWorld(&old_graphics_port, &old_graphics_device); SetGWorld((GWorldPtr) screen_window, NULL); destination_graphics_port= (GrafPtr) screen_window; +#endif } void _set_port_to_gworld( @@ -97,6 +101,11 @@ void _restore_port( old_graphics_port= NULL; old_graphics_device= NULL; destination_graphics_port= NULL; + +#if SUPPORT_DRAW_SPROCKET + DSpContext_SwapBuffers(gDrawContext, NULL, NULL); + DSpContext_GetBackBuffer( gDrawContext, kDSpBufferKind_Normal, (CGrafPtr *)&world_pixels ); +#endif } /* If source==NULL, source= the shapes bounding rectangle */ diff --git a/marathon2/serial_numbers.c b/marathon2/serial_numbers.c new file mode 100644 index 0000000..98c92e8 --- /dev/null +++ b/marathon2/serial_numbers.c @@ -0,0 +1,449 @@ +/* +SERIAL_NUMBERS.C +Thursday, December 1, 1994 4:56:29 PM (Jason) + +Monday, December 5, 1994 1:12:01 PM (Jason') + heinous bug somewhere which rocks our stack frame (in ex libris, at the reg) +Thursday, December 8, 1994 4:03:13 PM (Jason') + blacklist. +*/ + +/* +serial numbers are ten bytes (eighty bits, sixteen tokens) +every other bit is redundant, and comes from the constant pad +every bit is XORed with the previous bit + +1 data bit, 1 checksum bit ==> 4 codes (2 valid, 2 invalid) +2 data bits, 2 checksum bits ==> 16 codes (4 valid, 12 invalid) +etc... + +the twenty valid bits are divided as follows: +[16 lot number] +[8 network-only bits] +[16 sequential serial number] +*/ + +#include "cseries.h" + +#include +#include + +/* ----------- constants */ + +#define BITS_PER_TOKEN 5 +#define NUMBER_OF_TOKENS (1<0) ? ((word)*((short*)(s+3))==calculate_complement(*((word*)(s)))) : \ + ((word)(*((short*)(s+3))^0xffff)==calculate_complement(*((word*)s)^0xffff))) + +#define EXTRACT_BIT(ptr, bit) ((((byte*)ptr)[(bit)>>3] & (1<<((bit)&7))) ? TRUE : FALSE) +#define INSERT_BIT(ptr, bit, value) if (value) \ + ((byte*)ptr)[(bit)>>3]|= (1<<((bit)&7)); else \ + ((byte*)ptr)[(bit)>>3]&= (byte)~(1<<((bit)&7)) + +/* ---------- globals */ + +static char raw_token_to_ascii_token[NUMBER_OF_TOKENS]= +{ + 'P', '9', 'L', 'K', 'Y', '1', '3', 'Q', 'J', + 'M', 'N', '8', 'V', 'G', 'A', 'U', 'H', 'B', + '4', 'C', 'X', 'D', 'F', '5', 'T', 'R', '2', + 'E', 'S', '7', '6', 'Z' +}; + +//static byte actual_pad[BITS_PER_SHORT_SERIAL_NUMBER/8]= {0xa5, 0x79, 0x4e, 0xf3, 0x9a}; // marathon1 +//static byte actual_pad[BITS_PER_SHORT_SERIAL_NUMBER/8]= {0x55, 0x19, 0x9f, 0xaa}; // marathon2 +//static byte actual_pad[BITS_PER_SHORT_SERIAL_NUMBER/8]= {0x77, 0x68, 0x6f, 0x72, 0x65}; // marathon infinity betas +static byte actual_pad_m2[BITS_PER_SHORT_SERIAL_NUMBER/8]= {0x55, 0x19, 0x9f, 0xaa}; // marathon2 +static byte actual_pad[BITS_PER_SHORT_SERIAL_NUMBER/8]= {0xB5, 0x4B, 0xB4, 0xCE, 0x55}; // marathon infinity + +static short long_serial_number_bit_offsets[BITS_PER_LONG_SERIAL_NUMBER]= +{ + 34, 74, 52, 15, 67, 4, 43, 48, 33, 78, 64, 40, 60, 26, 7, 70, 19, 44, 20, 30, + 21, 0, 35, 56, 25, 47, 10, 73, 77, 14, 18, 42, 61, 11, 69, 38, 1, 71, 54, 17, + 62, 13, 22, 32, 6, 55, 27, 16, 65, 59, 39, 79, 76, 3, 46, 23, 57, 72, 53, 31, + 51, 5, 75, 12, 28, 68, 36, 41, 63, 49, 29, 66, 8, 2, 37, 50, 58, 9, 45, 24, +}; + +#ifndef DECODE_ONLY +#define NUMBER_OF_BLACKLISTED_WORDS (sizeof(blacklisted_words)/sizeof(char *)) +static char *blacklisted_words[]= +{ + "fuck", "shit", "damn", "anus", "hell", "cunt", "clit", "sex", + "rape", "pussy", "cock", "doom", "cum", "tit", "twat", + "crap", "ass", "bitch", "slut", "whore", "piss", "dick", "prick", + "penis", "fag", "muff" +}; +#endif + +/* ---------- private prototypes */ + +static void tokens_to_short_serial_number_and_pad(char *tokens, byte *short_serial_number, byte *inferred_pad); +static void long_serial_number_to_short_serial_number_and_pad(byte *long_serial_number, byte *short_serial_number, byte *inferred_pad); +static void short_serial_number_and_pad_to_tokens(char *tokens, byte *short_serial_number, byte *actual_pad); + +static void verify_static_data(void); + +static void write_serial_numbers(FILE *stream, short group, long start, long end); + +static void generate_long_serial_number_from_short_serial_number(byte *short_serial_number, byte *actual_pad, byte *long_serial_number); +static char extract_token_from_long_serial_number(byte *long_serial_number, short *bit_offset); + +static void generate_long_serial_number_from_tokens(char *tokens, byte *long_serial_number); +static void insert_token_into_long_serial_number(char token, byte *long_serial_number, short *bit_offset); +static void extract_short_and_pad_bit_from_long_serial_number(byte *long_serial_number, short *bit_offset, byte *short_serial_number, byte *inferred_pad); + +static void valid_serial_number(char *tokens); + +static word calculate_complement(long iterations); + +static boolean serial_number_contains_blacklisted_words(char *tokens); + +/* ---------- code */ + +#ifndef DECODE_ONLY +void main( + int argc, + char **argv) +{ + short error= 0; + + initialize_debugger(TRUE); + + if (argc!=5) + { + fprintf(stderr, "Usage: %s \n", argv[0]); + exit(1); + } + else + { + long group= atoi(argv[1]); + long start= atoi(argv[2]), end= atoi(argv[3]); + FILE *stream= fopen(argv[4], "w"); + + if (stream) + { + if (group>=1 && group<=127) + { + if (start>=0 && start<=65535 && end>=0 && end<=65535 && start=0) + { + byte short_serial_number[BYTES_PER_SHORT_SERIAL_NUMBER]; + char tokenized_solo_serial_number[TOKENS_PER_SERIAL_NUMBER]; + char tokenized_network_serial_number[TOKENS_PER_SERIAL_NUMBER]; + + /* build the short solo serial number, tokenize and print it */ + *((short*)short_serial_number)= start; + short_serial_number[2]= group; + *((short*)(short_serial_number+3))= calculate_complement(start); + short_serial_number_and_pad_to_tokens(tokenized_solo_serial_number, short_serial_number, actual_pad); + + /* build the short network serial number, tokenize and print it */ + *((short*)short_serial_number)^= 0xffff; + short_serial_number[2]= -group; + *((short*)(short_serial_number+3))^= 0xffff; + short_serial_number_and_pad_to_tokens(tokenized_network_serial_number, short_serial_number, actual_pad); + + /* verify they are valid */ + valid_serial_number(tokenized_solo_serial_number); + valid_serial_number(tokenized_network_serial_number); + + if (!serial_number_contains_blacklisted_words(tokenized_solo_serial_number) && + !serial_number_contains_blacklisted_words(tokenized_network_serial_number)) + { + fprintf(stream, "%16.16s\t%16.16s\n", tokenized_solo_serial_number, tokenized_network_serial_number); + } + else + { + fprintf(stderr, "discarding %16.16s/%16.16s\n", tokenized_solo_serial_number, tokenized_network_serial_number); + } + + start+= 1; + } + + return; +} + +static boolean serial_number_contains_blacklisted_words( + char *tokens) +{ + char string[TOKENS_PER_SERIAL_NUMBER+1]; + boolean found_blacklisted_word= FALSE; + short i; + + memcpy(string, tokens, TOKENS_PER_SERIAL_NUMBER); + string[TOKENS_PER_SERIAL_NUMBER]= 0; + strlwr(string); + + for (i= 0; ilong == %08x%08x%04x", *((long*)long_serial_number), *((long*)(long_serial_number+4)), *((short*)(long_serial_number+8))); + + return; +} + +static char extract_token_from_long_serial_number( + byte *long_serial_number, + short *bit_offset) +{ + short bit; + byte raw_token[1]; + + raw_token[0]= 0; + for (bit= 0; bit=0 && raw_token[0]=0) seed= (seed&1) ? ((seed>>1)^0xb400) : (seed>>1); + + return seed; +} + +static void long_serial_number_to_short_serial_number_and_pad( + byte *long_serial_number, + byte *short_serial_number, + byte *inferred_pad) +{ + short bit_offset; + short i; + + // alex paranoia + for (i= 0;ilong == %08x%08x%04x", *((long*)long_serial_number), *((long*)(long_serial_number+4)), *((short*)(long_serial_number+8))); + + for (bit_offset= 0; bit_offsetbitmap_index); - - low_level_shape->world_left= (-low_level_shape->origin_x)*collection->pixels_to_world; - low_level_shape->world_top= - (-low_level_shape->origin_y)*collection->pixels_to_world; - low_level_shape->world_right= (bitmap->width-low_level_shape->origin_x)*collection->pixels_to_world; - low_level_shape->world_bottom= - (bitmap->height-low_level_shape->origin_y)*collection->pixels_to_world; - low_level_shape->world_x0= (low_level_shape->key_x-low_level_shape->origin_x)*collection->pixels_to_world; - low_level_shape->world_y0= - (low_level_shape->key_y-low_level_shape->origin_y)*collection->pixels_to_world; - } -#endif - return (struct shape_information_data *) low_level_shape; } @@ -413,7 +401,7 @@ void load_collections( update_color_environment(); #ifdef DEBUG -// debug_shapes_memory(); + debug_shapes_memory(); #endif return; @@ -525,7 +513,7 @@ static void update_color_environment( bitmap->row_addresses[0]= calculate_bitmap_origin(bitmap); precalculate_bitmap_row_addresses(bitmap); - /* ... and remap it */ + /* remap it ... */ remap_bitmap(bitmap, remapping_table); } @@ -560,15 +548,15 @@ static void update_color_environment( case 8: /* duplicate the primary shading table and remap it */ memcpy(alternate_shading_table, primary_shading_table, get_shading_table_size(collection_index)); - map_bytes(alternate_shading_table, shading_remapping_table, get_shading_table_size(collection_index)); + map_bytes((unsigned char *)alternate_shading_table, shading_remapping_table, get_shading_table_size(collection_index)); break; case 16: - build_shading_tables16(colors, color_count, alternate_shading_table, shading_remapping_table); break; + build_shading_tables16(colors, color_count, (unsigned short *)alternate_shading_table, shading_remapping_table); break; break; case 32: - build_shading_tables32(colors, color_count, alternate_shading_table, shading_remapping_table); break; + build_shading_tables32(colors, color_count, (unsigned long *)alternate_shading_table, shading_remapping_table); break; break; default: @@ -580,9 +568,9 @@ static void update_color_environment( /* build the primary shading table */ switch (collection_bit_depth) { - case 8: build_shading_tables8(colors, color_count, primary_shading_table); break; - case 16: build_shading_tables16(colors, color_count, primary_shading_table, (byte *) NULL); break; - case 32: build_shading_tables32(colors, color_count, primary_shading_table, (byte *) NULL); break; + case 8: build_shading_tables8(colors, color_count, (unsigned char *)primary_shading_table); break; + case 16: build_shading_tables16(colors, color_count, (unsigned short *)primary_shading_table, (byte *) NULL); break; + case 32: build_shading_tables32(colors, color_count, (unsigned long *)primary_shading_table, (byte *) NULL); break; default: halt(); } } @@ -665,9 +653,12 @@ static void build_shading_tables8( return; } #else -short find_closest_color( +static short find_closest_color(struct rgb_color *color, register struct rgb_color_value *colors, + short color_count); + +static short find_closest_color( struct rgb_color *color, - register struct rgb_color *colors, + register struct rgb_color_value *colors, short color_count) { short i; @@ -688,7 +679,7 @@ short find_closest_color( } static void build_shading_tables8( - struct rgb_color *colors, + struct rgb_color_value *colors, short color_count, pixel8 *shading_tables) { @@ -704,8 +695,8 @@ static void build_shading_tables8( { for (level= 0; levelred*level)/(number_of_shading_tables-1); result.green= (color->green*level)/(number_of_shading_tables-1); @@ -873,10 +864,10 @@ static boolean get_next_color_run( } static boolean new_color_run( - struct rgb_color_value *new, + struct rgb_color_value *new_run, struct rgb_color_value *last) { - if ((long)last->red+(long)last->green+(long)last->blue<(long)new->red+(long)new->green+(long)new->blue) + if ((long)last->red+(long)last->green+(long)last->blue<(long)new_run->red+(long)new_run->green+(long)new_run->blue) { return TRUE; } @@ -958,7 +949,7 @@ static void build_collection_tinting_table( case _collection_player: case _collection_rocket: case _collection_civilian: - case _collection_madd: + case _collection_vacuum_civilian: tint_color= _tint_collection_yellow; break; @@ -982,13 +973,13 @@ static void build_collection_tinting_table( switch (bit_depth) { case 8: - build_tinting_table8(colors, color_count, tint_table, tint_colors8[tint_color].start, tint_colors8[tint_color].count); + build_tinting_table8(colors, color_count, (unsigned char *)tint_table, tint_colors8[tint_color].start, tint_colors8[tint_color].count); break; case 16: - build_tinting_table16(colors, color_count, tint_table, tint_colors16+tint_color); + build_tinting_table16(colors, color_count, (unsigned short *)tint_table, tint_colors16+tint_color); break; case 32: - build_tinting_table32(colors, color_count, tint_table, tint_colors16+tint_color); + build_tinting_table32(colors, color_count, (unsigned long *)tint_table, tint_colors16+tint_color); break; } } @@ -1184,7 +1175,7 @@ static void debug_shapes_memory( short collection_index; struct collection_header *header; - long total_size; + long total_size= 0; for (collection_index= 0, header= collection_headers; collection_indexsize); +// dprintf("collection #% 2d @ #% 9d bytes", collection_index, definition->size); total_size+= definition->size; } } - dprintf(" #% 9d bytes total", total_size); +// dprintf(" #% 9d bytes total", total_size); + +// dprintf("shapes for this level take #%d bytes;g;", total_size); return; } diff --git a/marathon2/shapes_macintosh.c b/marathon2/shapes_macintosh.c index 40d8d6c..cd7013d 100644 --- a/marathon2/shapes_macintosh.c +++ b/marathon2/shapes_macintosh.c @@ -70,7 +70,7 @@ void initialize_shape_handler( assert(hollow_pixmap); if (HOLLOW_PIXMAP_BUFFER_SIZE) { - hollow_data= NewPtr(HOLLOW_PIXMAP_BUFFER_SIZE); + hollow_data= (pixel8 *)NewPtr(HOLLOW_PIXMAP_BUFFER_SIZE); assert(hollow_data); } @@ -152,7 +152,7 @@ PixMapHandle get_shape_pixmap( /* setup the pixmap (can’t wait to change this for Copland) */ SetRect(&(*hollow_pixmap)->bounds, 0, 0, bitmap->width, bitmap->height); (*hollow_pixmap)->rowBytes= bitmap->width|0x8000; - (*hollow_pixmap)->baseAddr= bitmap->row_addresses[0]; + (*hollow_pixmap)->baseAddr= (Ptr)bitmap->row_addresses[0]; if (bitmap->bytes_per_row==NONE) /* is this a compressed shape? */ { @@ -180,7 +180,7 @@ PixMapHandle get_shape_pixmap( } } - (*hollow_pixmap)->baseAddr= hollow_data; + (*hollow_pixmap)->baseAddr= (Ptr)hollow_data; } else { @@ -189,13 +189,113 @@ PixMapHandle get_shape_pixmap( { assert(bitmap->width*bitmap->height<=HOLLOW_PIXMAP_BUFFER_SIZE); BlockMove(bitmap->row_addresses[0], hollow_data, bitmap->width*bitmap->height); - (*hollow_pixmap)->baseAddr= hollow_data; + (*hollow_pixmap)->baseAddr= (Ptr)hollow_data; } } return hollow_pixmap; } +PixMapHandle editor_get_shape_pixmap( + short shape) +{ + OSErr error; + struct collection_definition *collection; + struct low_level_shape_definition *low_level_shape; + struct bitmap_definition *bitmap; + short collection_index, low_level_shape_index, clut_index; + + collection_index= GET_COLLECTION(GET_DESCRIPTOR_COLLECTION(shape)); + clut_index= GET_COLLECTION_CLUT(GET_DESCRIPTOR_COLLECTION(shape)); + low_level_shape_index= GET_DESCRIPTOR_SHAPE(shape); + collection= get_collection_definition(collection_index); + + switch (interface_bit_depth) + { + case 8: + /* if the ctSeed of our offscreen pixmap is different from the ctSeed of the world + device then the color environment has changed since the last call to our routine, + and we just HandToHand the device’s ctTable and throw away our old one. */ + if ((*(*(*world_device)->gdPMap)->pmTable)->ctSeed!=(*(*hollow_pixmap)->pmTable)->ctSeed) + { + DisposeHandle((Handle)(*hollow_pixmap)->pmTable); + + (*hollow_pixmap)->pmTable= (*(*world_device)->gdPMap)->pmTable; + HLock((Handle)hollow_pixmap); + error= HandToHand((Handle *)&(*hollow_pixmap)->pmTable); + HUnlock((Handle)hollow_pixmap); + + assert(error==noErr); + + /* this is a device color table so we don’t clear ctFlags (well, it isn’t a device + color table anymore, but it’s formatted like one */ + } + break; + + case 16: + case 32: + if (!hollow_pixmap_color_table) + { + hollow_pixmap_color_table= (CTabHandle) NewHandle(sizeof(ColorTable)+PIXEL8_MAXIMUM_COLORS*sizeof(ColorSpec)); + MoveHHi((Handle)hollow_pixmap_color_table); + HLock((Handle)hollow_pixmap_color_table); + assert(hollow_pixmap_color_table); + } + + (*hollow_pixmap_color_table)->ctSeed= GetCTSeed(); + (*hollow_pixmap_color_table)->ctSize= collection->color_count-NUMBER_OF_PRIVATE_COLORS-1; + (*hollow_pixmap_color_table)->ctFlags= 0; + + BlockMove(get_collection_colors(collection_index, clut_index)+NUMBER_OF_PRIVATE_COLORS, &(*hollow_pixmap_color_table)->ctTable, + (collection->color_count-NUMBER_OF_PRIVATE_COLORS)*sizeof(ColorSpec)); + + (*hollow_pixmap)->pmTable= hollow_pixmap_color_table; + + break; + + default: + halt(); + } + + low_level_shape= get_low_level_shape_definition(collection_index, low_level_shape_index); + bitmap= get_bitmap_definition(collection_index, low_level_shape->bitmap_index); + + /* setup the pixmap (can’t wait to change this for Copland) */ + SetRect(&(*hollow_pixmap)->bounds, 0, 0, bitmap->width, bitmap->height); + (*hollow_pixmap)->rowBytes= bitmap->width|0x8000; + (*hollow_pixmap)->baseAddr= (Ptr)bitmap->row_addresses[0]; + + /* Rotate if necessary */ + if ((bitmap->flags&_COLUMN_ORDER_BIT) && bitmap->width==128 && bitmap->height==128) + { + static char *buffer= NULL; + + if(!buffer) + { + buffer= (char *)malloc(bitmap->width*bitmap->height*sizeof(pixel8)); + } + + if(buffer) + { + short x, y; + pixel8 *dest= (pixel8 *) buffer; + + /* decompress column-order shape into row-order buffer */ + for (x=0;xwidth;x+=1) + { + for(y= 0; yheight; y+=1) + { + *dest++= bitmap->row_addresses[y][x]; + } + } + + (*hollow_pixmap)->baseAddr= buffer; + } + } + + return hollow_pixmap; +} + void open_shapes_file( FSSpec *spec) { @@ -407,7 +507,7 @@ static Handle read_handle_from_file( } } - vwarn(error==noErr, csprintf(temporary, "load_sound() got error #%d", error)); + vwarn(error==noErr, csprintf(temporary, "read_handle_from_file() got error #%d", error)); return data; } @@ -496,40 +596,60 @@ static void build_shading_tables16( } #endif -#if 0 -static void dump_colors(RGBColor *colors, short color_count) +#ifdef DEBUG +void dump_colors( + struct rgb_color_value *colors, + short color_count) { CTabHandle new_table; Handle old_bad_clut; - RGBColor *color; + struct rgb_color_value *color; short loop; - - new_table= (CTabHandle) NewHandleClear(sizeof(ColorTable)+color_count*sizeof(ColorSpec)); - HLock((Handle) new_table); - (*new_table)->ctSeed= GetCTSeed(); - (*new_table)->ctFlags= 0; - (*new_table)->ctSize= color_count-1; + FSSpec file; + short refnum; - /* Slam the colors.. */ - color= colors; - for(loop=0; loop<=color_count; ++loop) - { - (*new_table)->ctTable[loop].rgb= *color; - (*new_table)->ctTable[loop].value= loop; - color++; - } - HUnlock((Handle) new_table); + file.vRefNum= -1; + file.parID= 2; + strcpy((char *)file.name, (const char *)"\pMarathon2 Clut\0"); - old_bad_clut= GetResource('clut', 5454); - if (old_bad_clut) + FSpCreateResFile(&file, 'RSED', 'rsrc', smSystemScript); + refnum= FSpOpenResFile(&file, fsWrPerm); + if(refnum>=0) { - RmveResource((Handle) old_bad_clut); - DisposeHandle((Handle) old_bad_clut); - UpdateResFile(CurResFile()); - } + new_table= (CTabHandle) NewHandleClear(sizeof(ColorTable)+color_count*sizeof(ColorSpec)); + HLock((Handle) new_table); + (*new_table)->ctSeed= GetCTSeed(); + (*new_table)->ctFlags= 0; + (*new_table)->ctSize= color_count-1; + + /* Slam the colors.. */ + color= colors; + for(loop=0; loop<=color_count; ++loop) + { + (*new_table)->ctTable[loop].rgb.red= color->red; + (*new_table)->ctTable[loop].rgb.green= color->green; + (*new_table)->ctTable[loop].rgb.blue= color->blue; + (*new_table)->ctTable[loop].value= loop; + color++; + } + HUnlock((Handle) new_table); - AddResource((Handle) new_table, 'clut', 5454, "\pBad Colors"); - WriteResource((Handle) new_table); - ReleaseResource((Handle) new_table); + old_bad_clut= GetResource('clut', 5454); + if (old_bad_clut) + { + RmveResource((Handle) old_bad_clut); + DisposeHandle((Handle) old_bad_clut); + UpdateResFile(CurResFile()); + } + + AddResource((Handle) new_table, 'clut', 5454, "\pMarathon2 Color Table"); + if(ResError()) dprintf("Err adding it: %d", ResError()); + WriteResource((Handle) new_table); + ReleaseResource((Handle) new_table); + + CloseResFile(refnum); + } + + return; } #endif diff --git a/marathon2/shell.c b/marathon2/shell.c index cb9c38b..68d2e21 100644 --- a/marathon2/shell.c +++ b/marathon2/shell.c @@ -37,6 +37,19 @@ Thursday, September 28, 1995 7:37:12 PM #include "macintosh_cseries.h" #include #include +#ifdef SUPPORT_INPUT_SPROCKET +// we understand and use the grouping byte +#define USE_OLD_ISPNEED_STRUCT 0 +#include "InputSprocket.h" +#endif + +#ifdef SUPPORT_DRAW_SPROCKET +#include "DrawSprocket.h" +#endif + +#if defined(SUPPORT_INPUT_SPROCKET) || defined(SUPPORT_DRAW_SPROCKET) +#include +#endif #include "my32bqd.h" @@ -46,7 +59,7 @@ Thursday, September 28, 1995 7:37:12 PM #include "render.h" #include "shell.h" #include "interface.h" -#include "sound.h" +#include "game_sound.h" #include "fades.h" #include "screen.h" @@ -61,9 +74,11 @@ Thursday, September 28, 1995 7:37:12 PM #include "network_sound.h" #include "mouse.h" #include "screen_drawing.h" +#include "overhead_map.h" #include "computer_interface.h" #include "game_wad.h" /* yuck. •• */ #include "game_window.h" /* for draw_interface() */ +#include "wad.h" #include "extensions.h" #include "items.h" @@ -88,12 +103,18 @@ Thursday, September 28, 1995 7:37:12 PM /* ---------- constants */ #define alrtQUIT_FOR_SURE 138 +#ifdef COMPILE_TIME +#define DAYS_TO_EXPIRATION 18 +#define SECONDS_TO_EXPIRATION (DAYS_TO_EXPIRATION * 60 * 60 * 24) +#define EXPIRATION_TIME (COMPILE_TIME + SECONDS_TO_EXPIRATION) +#endif + #define kMINIMUM_MUSIC_HEAP (4*MEG) #define kMINIMUM_SOUND_HEAP (3*MEG) struct system_information_data *system_information; -#ifdef envppc +#ifndef __MWERKS__ QDGlobals qd; #endif @@ -101,6 +122,19 @@ QDGlobals qd; TP2PerfGlobals perf_globals; #endif +#ifdef SUPPORT_INPUT_SPROCKET +#include "macintosh_input.h" + +ISpElementReference *input_sprocket_elements; +boolean use_input_sprocket= FALSE; + +#include "input_sprocket_needs.h" +#endif + +#ifdef SUPPORT_DRAW_SPROCKET +boolean use_draw_sprocket= FALSE; +#endif + extern long first_frame_tick, frame_count; /* for determining frame rate */ /* ---------- externs that I couldn't fit into the #include heirarchy nicely */ @@ -140,6 +174,11 @@ static void handle_keyword(short type_of_cheat); boolean is_keypad(short keycode); +#ifdef SUPPORT_INPUT_SPROCKET +static void input_sprocket_handler(void); +static void enable_input_sprocket_device_class(OSType deviceClass, boolean enable); +#endif + /* ---------- code */ void main( @@ -181,6 +220,31 @@ void *level_transition_malloc( } /* ---------- private code */ +#ifdef SUPPORT_DRAW_SPROCKET +static void draw_sprocket_handler( + void) +{ + OSStatus err= noErr; + + err= DSpShutdown(); + + return; +} +#endif + +#ifdef SUPPORT_INPUT_SPROCKET +static void input_sprocket_handler( + void) +{ + OSStatus err= noErr; + + err= ISpStop(); + ISpElement_DisposeVirtual(NUMBER_OF_INPUT_SPROCKET_NEEDS, input_sprocket_elements); + free(input_sprocket_elements); + + return; +} +#endif static void initialize_application_heap( void) @@ -199,7 +263,7 @@ static void initialize_application_heap( InitDialogs(0); /* resume procedure ignored for multifinder and >=system 7.0 */ InitCursor(); -#ifdef DEBUG +#if defined(DEBUG) && !defined(GAMMA) initialize_debugger(TRUE); #endif @@ -224,6 +288,71 @@ static void initialize_application_heap( GetDateTime(&player_preferences->last_time_ran); write_preferences(); +#if defined(EXPIRATION_TIME) && !defined(AI_LIBRARY) + { + Handle some_resource; + unsigned long current_time; + + // we’re assuming that beta copies are all fat versions + some_resource = GetResource('SOCK', 128); // the socket listener + if (!some_resource) + { + alert_user(fatalError, strERRORS, copyHasExpired, 0); + ExitToShell(); + } + + GetDateTime(¤t_time); + if (current_time < player_preferences->last_time_ran || current_time > EXPIRATION_TIME) + { + some_resource= GetResource('CODE', 8); // the “render” segment + if (some_resource) RmveResource(some_resource); + some_resource= GetResource('SOCK', 128); // the socket listener + if (some_resource) RmveResource(some_resource); + UpdateResFile(CurResFile()); + alert_user(fatalError, strERRORS, copyHasExpired, 0); + ExitToShell(); // fool the cracker. heh. + } + + } +#endif + +#ifdef SUPPORT_INPUT_SPROCKET + if (system_information->has_input_sprocket) + { + OSStatus err= noErr; + + // turn on keyboard, mouse, speech and ticklish classes and ignore errors + ISpDevices_ActivateClass(kISpDeviceClass_Mouse); + ISpDevices_ActivateClass(kISpDeviceClass_Keyboard); + ISpDevices_ActivateClass(kISpDeviceClass_SpeechRecognition); + ISpDevices_ActivateClass(kISpDeviceClass_Tickle); + + input_sprocket_elements= (ISpElementReference *) malloc(sizeof(ISpElementReference) * NUMBER_OF_INPUT_SPROCKET_NEEDS); + assert(input_sprocket_elements); + err= ISpElement_NewVirtualFromNeeds(NUMBER_OF_INPUT_SPROCKET_NEEDS, input_sprocket_needs, input_sprocket_elements, 0); + if (err) dprintf("ISpElementVirtuals err=%d",err); + err= ISpInit(NUMBER_OF_INPUT_SPROCKET_NEEDS, input_sprocket_needs, input_sprocket_elements, '52.4', 'fooc', 0, 0, 0); + if (err) dprintf("ISpInit err=%d",err); + atexit(input_sprocket_handler); + err= ISpSuspend(); // start out suspended, resume when we begin the game + + if (input_preferences->input_device) + { + use_input_sprocket = true; + } + } +#endif + +#ifdef SUPPORT_DRAW_SPROCKET + if (system_information->has_draw_sprocket) + { + OSStatus err; + + err= DSpStartup(); + atexit(draw_sprocket_handler); + } +#endif + initialize_my_32bqd(); verify_environment(); @@ -235,6 +364,7 @@ static void initialize_application_heap( initialize_screen(&graphics_preferences->screen_mode); initialize_marathon(); initialize_screen_drawing(); + initialize_overhead_map(); initialize_terminal_manager(); initialize_shape_handler(); initialize_fades(); @@ -398,18 +528,39 @@ void handle_game_key( graphics_preferences->screen_mode.texture_ceiling = !graphics_preferences->screen_mode.texture_ceiling; changed_screen_mode = changed_prefs = TRUE; break; +#else + // PowerPC-only secret no frame rate limit + case kcF6: + no_frame_rate_limit= !no_frame_rate_limit; + break; #endif case kcF9: if(event->modifiers & shiftKey) { short keys[NUMBER_OF_KEYS]; - set_default_keys(&keys, 0); - set_keys(&keys); + set_default_keys((short *) &keys, 0); + set_keys((short *) &keys); } break; case kcF10: +#ifdef envppc + // secret ludicrous speed mode + if (event->modifiers & shiftKey) + { + if (game_is_networked) + { + toggle_ludicrous_speed(FALSE); + toggle_sound_pitch_modifier_override(FALSE); + } + else + { + toggle_ludicrous_speed(TRUE); + toggle_sound_pitch_modifier_override(TRUE); + } + } +#endif break; case kcF11: @@ -572,9 +723,18 @@ static pascal OSErr handle_open_document( break; case SAVE_GAME_TYPE: - if(load_and_start_game((FileDesc *) &myFSS)) +#ifndef TRILOGY + if (serial_preferences->network_only) { - done= TRUE; + alert_user(infoError, strERRORS, networkOnlySerialNumber, 0); + } + else +#endif + { + if(load_and_start_game((FileDesc *) &myFSS)) + { + done= TRUE; + } } break; @@ -621,6 +781,8 @@ static pascal OSErr handle_quit_application( if(err) return err; set_game_state(_quit_game); + + return noErr; } static pascal OSErr handle_print_document( @@ -749,6 +911,36 @@ static void initialize_system_information( } } +#ifdef SUPPORT_INPUT_SPROCKET + { + // assume false, if we linked and have version 1.2 mark as true + // we require 1.1 because we use some 1.1 specific calls + // and we use 1.2's delta features (which unfortunately crash 1.1) + system_information->has_input_sprocket= FALSE; + + if (ISpGetVersion != kUnresolvedCFragSymbolAddress) + { + NumVersion inputSprocketVersionStruct = ISpGetVersion(); + UInt32 inputSprocketVersion = * (UInt32 *) &(inputSprocketVersionStruct); + + if (inputSprocketVersion > 0x01200000) // require 1.2 (binary coded decimal) + { + system_information->has_input_sprocket= TRUE; + } + } + } +#endif +#ifdef SUPPORT_DRAW_SPROCKET + if ((Ptr)DSpStartup != (Ptr)kUnresolvedCFragSymbolAddress) + { + system_information->has_draw_sprocket= TRUE; + } + else + { + system_information->has_draw_sprocket= FALSE; + } +#endif + return; } @@ -839,7 +1031,8 @@ enum // cheat tags _tag_view, _tag_jump, _tag_aslag, - _tag_save + _tag_save, + _tag_level }; /* ---------- resources */ @@ -871,7 +1064,8 @@ static struct keyword_data keywords[]= {_tag_ammo, "AMMO"}, {_tag_jump, "QWE"}, {_tag_aslag, "SHIT"}, - {_tag_save, "YOURMOM"} + {_tag_save, "YOURMOM"}, + {_tag_level, "LEVEL"} }; static char keyword_buffer[MAXIMUM_KEYWORD_LENGTH+1]; @@ -973,7 +1167,7 @@ static void handle_keyword( _i_plasma_pistol, _i_alien_shotgun, _i_shotgun, _i_assault_rifle_magazine, _i_assault_grenade_magazine, _i_magnum_magazine, _i_missile_launcher_magazine, _i_flamethrower_canister, - _i_plasma_magazine, _i_shotgun_magazine, _i_shotgun }; + _i_plasma_magazine, _i_shotgun_magazine, _i_shotgun, _i_smg, _i_smg_ammo }; short index; for(index= 0; indexsuit_energy = 3*PLAYER_MAXIMUM_SUIT_ENERGY; update_interface(NONE); break; + + case _tag_level: + { + struct player_data *player= get_player_data(0); + int level_number= dynamic_world->current_level_number+1; + + player->teleporting_destination= -level_number; + player->delay_before_teleport= TICKS_PER_SECOND/2; + } + break; default: cheated= FALSE; @@ -1039,6 +1243,31 @@ static void handle_keyword( } #endif +#ifdef SUPPORT_INPUT_SPROCKET + +static Boolean check_input_sprocket_button( ISpElementReference theElement) +{ + OSStatus err; + ISpElementEvent input_sprocket_event; + Boolean was_input_sprocket_event; + + err= ISpElement_GetNextEvent( theElement, + sizeof(ISpElementEvent), + &input_sprocket_event, + &was_input_sprocket_event); + + if (!err && was_input_sprocket_event && (input_sprocket_event.data == kISpButtonDown)) + { + return true; + } + else + { + return false; + } +} + +#endif + static void main_event_loop( void) { @@ -1052,7 +1281,184 @@ static void main_event_loop( { EventRecord event; boolean got_event= FALSE; - + +#ifdef SUPPORT_INPUT_SPROCKET + unsigned int key_state= 0; + boolean changed_screen_mode = FALSE; + boolean changed_prefs = FALSE; + boolean update_interface = FALSE; + + if (use_input_sprocket) + { + ISpTickle(); // give input sprocket time + + // check slow stuff here + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_quit])) + { + do_menu_item_command(mGame, iQuitGame, FALSE); + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_volume_up])) + { + changed_prefs= adjust_sound_volume_up(sound_preferences, _snd_adjust_volume); + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_volume_down])) + { + changed_prefs= adjust_sound_volume_down(sound_preferences, _snd_adjust_volume); + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_change_view])) + { + walk_player_list(); + render_screen(0); + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_zoom_map_in])) + { + zoom_overhead_map_in(); + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_zoom_map_out])) + { + zoom_overhead_map_out(); + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_scroll_back_decrement_replay])) + { + if(player_controlling_game()) + { + scroll_inventory(-1); + } + else + { + decrement_replay_speed(); + } + + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_scroll_forward_increment_replay])) + { + if(player_controlling_game()) + { + scroll_inventory(1); + } + else + { + increment_replay_speed(); + } + } + +#ifdef ALEX_DISABLED + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_toggle_background_tasks])) + { + toggle_suppression_of_background_tasks(); + } +#endif + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_show_fps])) + { + extern boolean displaying_fps; + + displaying_fps= !displaying_fps; + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_full_screen])) + { + graphics_preferences->screen_mode.size = _full_screen; + changed_screen_mode = changed_prefs = TRUE; + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_100_percent])) + { + if(graphics_preferences->screen_mode.size==_full_screen) update_interface= TRUE; + graphics_preferences->screen_mode.size = _100_percent; + changed_screen_mode = changed_prefs = TRUE; + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_75_percent])) + { + if(graphics_preferences->screen_mode.size==_full_screen) update_interface= TRUE; + graphics_preferences->screen_mode.size = _75_percent; + changed_screen_mode = changed_prefs = TRUE; + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_50_percent])) + { + if(graphics_preferences->screen_mode.size==_full_screen) update_interface= TRUE; + graphics_preferences->screen_mode.size = _50_percent; + changed_screen_mode = changed_prefs = TRUE; + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_low_res])) + { + if (graphics_preferences->screen_mode.acceleration != _valkyrie_acceleration) + { + graphics_preferences->screen_mode.high_resolution = !graphics_preferences->screen_mode.high_resolution; + if (graphics_preferences->screen_mode.high_resolution) graphics_preferences->screen_mode.draw_every_other_line= FALSE; + changed_screen_mode = changed_prefs = TRUE; + } + } +#ifdef ALEX_DISABLED +#ifdef env68k + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_high_res])) + { + if (!graphics_preferences->screen_mode.high_resolution && graphics_preferences->screen_mode.acceleration != _valkyrie_acceleration) + { + graphics_preferences->screen_mode.draw_every_other_line = !graphics_preferences->screen_mode.draw_every_other_line; + changed_screen_mode = changed_prefs = TRUE; + } + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_texture_floor_toggle])) + { + graphics_preferences->screen_mode.texture_floor = !graphics_preferences->screen_mode.texture_floor; + changed_screen_mode = changed_prefs = TRUE; + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_texture_ceiling_toggle])) + { + graphics_preferences->screen_mode.texture_ceiling = !graphics_preferences->screen_mode.texture_ceiling; + changed_screen_mode = changed_prefs = TRUE; + } +#endif + +#ifdef envppc + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_high_res])) + { + no_frame_rate_limit= !no_frame_rate_limit; + } +#endif +#endif + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_gamma_plus])) + { + if (graphics_preferences->screen_mode.gamma_levelscreen_mode.gamma_level+= 1; + change_gamma_level(graphics_preferences->screen_mode.gamma_level); + changed_prefs= TRUE; + } + } + + if (check_input_sprocket_button(input_sprocket_elements[_input_sprocket_gamma_minus])) + { + if (graphics_preferences->screen_mode.gamma_level > 0) + { + graphics_preferences->screen_mode.gamma_level-= 1; + change_gamma_level(graphics_preferences->screen_mode.gamma_level); + changed_prefs= TRUE; + } + } + } + + if (changed_screen_mode) + { + change_screen_mode(&graphics_preferences->screen_mode, TRUE); + render_screen(0); + if(update_interface) draw_interface(); + } + if (changed_prefs) write_preferences(); + +#endif if(use_waitnext) { got_event= WaitNextEvent(everyEvent, &event, 2, (RgnHandle) NULL); @@ -1084,15 +1490,19 @@ static void wait_for_highlevel_event( EventRecord event; boolean done= FALSE; + // CAF -- this was blocking forever +#if !SUPPORT_DRAW_SPROCKET while(!done) { +#endif if(WaitNextEvent(highLevelEventMask, &event, 0, NULL)) { process_event(&event); done= TRUE; } +#if !SUPPORT_DRAW_SPROCKET } - +#endif return; } @@ -1137,6 +1547,15 @@ static void process_event( WindowPtr window; short part_code; + // CAF -- give DSp a chance to handle the event +#if SUPPORT_DRAW_SPROCKET + Boolean theEventWasProcessed = false; + + DSpProcessEvent( event, &theEventWasProcessed ); + if( theEventWasProcessed ) + return; +#endif + switch (event->what) { case mouseDown: @@ -1153,7 +1572,7 @@ static void process_event( break; default: - halt(); + vhalt(csprintf(temporary, "What the hell is part code: %d?", part_code)); break; } break; diff --git a/marathon2/shell.h b/marathon2/shell.h index 0f95ded..a0926da 100644 --- a/marathon2/shell.h +++ b/marathon2/shell.h @@ -1,3 +1,5 @@ +#ifndef __SHELL_H__ +#define __SHELL_H__ /* SHELL.H Saturday, August 22, 1992 2:18:48 PM @@ -54,14 +56,14 @@ struct screen_mode_data short bit_depth; // currently 8 or 16 short gamma_level; - short unused[8]; + short unused[6]; // two shorts removed for preferences use }; #define NUMBER_OF_KEYS 21 #define NUMBER_UNUSED_KEYS 10 #define PREFERENCES_VERSION 17 -#define PREFERENCES_CREATOR '52.4' +#define PREFERENCES_CREATOR '26.∞' #define PREFERENCES_TYPE 'pref' #define PREFERENCES_NAME_LENGTH 32 @@ -70,7 +72,8 @@ enum // input devices _keyboard_or_game_pad, _mouse_yaw_pitch, _mouse_yaw_velocity, - _cybermaxx_input // only put "_input" here because it was defined elsewhere. + _cybermaxx_input, // only put "_input" here because it was defined elsewhere. + _input_sprocket_yaw_pitch, }; struct system_information_data @@ -82,11 +85,27 @@ struct system_information_data boolean machine_is_68040; boolean machine_is_ppc; boolean machine_has_network_memory; +#ifdef SUPPORT_INPUT_SPROCKET + boolean has_input_sprocket; +#endif +#ifdef SUPPORT_DRAW_SPROCKET + boolean has_draw_sprocket; +#endif }; /* ---------- globals */ extern struct system_information_data *system_information; +#ifdef SUPPORT_INPUT_SPROCKET +extern boolean use_input_sprocket; + +#if defined(envppc) && defined(__INPUTSPROCKET__) +extern ISpElementReference *input_sprocket_elements; +#endif +#endif +#ifdef SUPPORT_DRAW_SPROCKET +extern boolean use_draw_sprocket; +#endif /* ---------- prototypes/SHELL.C */ @@ -112,3 +131,5 @@ boolean has_cheat_modifiers(EventRecord *event); /* ---------- prototypes/PREFERENCES.C */ void load_environment_from_preferences(void); + +#endif \ No newline at end of file diff --git a/marathon2/sound_definitions.h b/marathon2/sound_definitions.h index a88cab1..ee4b479 100644 --- a/marathon2/sound_definitions.h +++ b/marathon2/sound_definitions.h @@ -99,7 +99,7 @@ struct sound_definition /* 64 bytes */ unsigned long last_played; // machine ticks - long handle; // (machine-specific pointer type) zero if not loaded + long hndl; // (machine-specific pointer type) zero if not loaded short unused[2]; }; @@ -169,6 +169,7 @@ static struct ambient_sound_definition ambient_sound_definitions[NUMBER_OF_AMBIE {_snd_pfhor_platform}, {_snd_alien_noise1}, {_snd_alien_noise2}, + {_snd_jjaro_noise} }; /* ---------- random sound definition structures */ @@ -179,6 +180,7 @@ static struct random_sound_definition random_sound_definitions[NUMBER_OF_RANDOM_ {_snd_surface_explosion}, {_snd_underground_explosion}, {_snd_owl}, + {_snd_jjaro_creak} }; /* ---------- sound definition structures */ @@ -200,7 +202,7 @@ static struct sound_definition sound_definitions[NUMBER_OF_SOUND_DEFINITIONS]= {10000, _sound_is_normal}, // _snd_teleport_in {10010, _sound_is_normal}, // _snd_teleport_out {10020, _sound_is_loud, _sound_cannot_change_pitch}, // _snd_body_being_crunched - {NONE, _sound_is_normal}, // _snd_nuclear_hard_death + {14260, _sound_is_normal}, // _snd_jjaro_creak {10030, _sound_is_normal}, // _snd_absorbed {NONE, _sound_is_normal}, // _snd_breathing @@ -234,8 +236,8 @@ static struct sound_definition sound_definitions[NUMBER_OF_SOUND_DEFINITIONS]= {12040, _sound_is_normal}, // _snd_spht_platform_stopping, {14540, _sound_is_normal}, // _snd_owl - {NONE, _sound_is_normal}, // - {NONE, _sound_is_normal}, // + {18000, _sound_is_normal}, // _snd_smg_firing + {18010, _sound_is_normal}, // _snd_smg_reloading {12080, _sound_is_normal}, // _snd_pfhor_platform_starting, {12090, _sound_is_normal}, // _snd_pfhor_platform_stopping, @@ -330,7 +332,7 @@ static struct sound_definition sound_definitions[NUMBER_OF_SOUND_DEFINITIONS]= {14080, _sound_is_normal, _sound_is_ambient}, // _snd_fan, {14090, _sound_is_normal, _sound_is_ambient}, // _snd_spht_door {14100, _sound_is_normal, _sound_is_ambient}, // _snd_spht_platform - {14120, _sound_is_normal, _sound_is_ambient}, // _snd_unused4 + {14120, _sound_is_normal, _sound_is_ambient}, // _snd_jjaro_noise {14130, _sound_is_normal, _sound_is_ambient}, // _snd_heavy_spht_platform {14140, _sound_is_normal, _sound_is_ambient}, // _snd_light_machinery {14150, _sound_is_normal, _sound_is_ambient}, // _snd_heavy_machinery @@ -462,5 +464,18 @@ static struct sound_definition sound_definitions[NUMBER_OF_SOUND_DEFINITIONS]= {14240, _sound_is_normal, _sound_is_ambient}, // _snd_alien_noise1 {14250, _sound_is_normal, _sound_is_ambient}, // _snd_alien_noise2 + + {18100, _sound_is_loud}, // _snd_fusion_human_wail + {18110, _sound_is_normal}, // _snd_fusion_human_scream + {18120, _sound_is_normal}, // _snd_fusion_human_hit + {18130, _sound_is_normal, _sound_cannot_be_restarted}, // _snd_fusion_human_chatter "they’re everywhere!" + {18140, _sound_is_normal, _sound_cannot_be_restarted}, // _snd_assimilated_fusion_human_chatter "thank god it’s you!" + {18150, _sound_is_normal, _sound_cannot_be_restarted, _seventy_percent}, // _snd_fusion_human_trash_talk "eat that!" + {18160, _sound_is_normal, _sound_cannot_be_restarted}, // _snd_fusion_human_apology "oops!" + {18170, _sound_is_normal, _sound_cannot_be_restarted}, // _snd_fusion_human_activation "they’re over here!" + {18180, _sound_is_normal, _sound_cannot_be_restarted, _fifty_percent}, // _snd_fusion_human_clear "out of the way!" + {18190, _sound_is_normal, _sound_cannot_be_restarted, _thirty_percent}, // _snd_fusion_human_stop_shooting_me_you_bastard + {18200, _sound_is_normal, _sound_cannot_be_restarted, _fifty_percent}, // _snd_fusion_human_area_secure + {18210, _sound_is_normal, _sound_cannot_be_restarted}, // _snd_fusion_kill_the_player }; #endif diff --git a/marathon2/sound_macintosh.c b/marathon2/sound_macintosh.c index 8c0431a..966c03c 100644 --- a/marathon2/sound_macintosh.c +++ b/marathon2/sound_macintosh.c @@ -6,8 +6,131 @@ Tuesday, August 29, 1995 8:56:06 AM (Jason) running. Thursday, August 31, 1995 9:09:46 AM (Jason) pitch changes without bogus sound headers. +Saturday , January 27, 1996 9:26 AM (Jason) + use rateMultiplierCmd instead of rateCmd to adjust channel pitch before bufferCmd. */ + +#ifdef SUPPORT_SOUND_SPROCKET +#include "fp.h" + +static SSpListenerReference gListener = NULL; +static float gSprocketSinTable[NUMBER_OF_ANGLES]; +static float gSprocketCosTable[NUMBER_OF_ANGLES]; + +void InitializeTables(void); +SSpSourceReference CreateSource (void); +SSpListenerReference CreateListener(void); + +void ConvertMarathonCoordinatesToSoundSprocket (world_location3d *theWorld, + TQ3CameraPlacement *outCamera); + +void CalcSourceInfo(SSpSourceReference theSource, world_location3d *theWorld); +void CalcListenerInfo (world_location3d *marathonCoords); + +void InitializeTables(void) +{ + int loop; + long double angle = 0; + + for (loop = 0; loop < NUMBER_OF_ANGLES; loop++) + { + + long double angle = 360*loop/(57.296*NUMBER_OF_ANGLES); + + gSprocketSinTable[loop] = sin (angle); + gSprocketCosTable[loop] = cos (angle); + } + +} + +SSpSourceReference CreateSource () +{ + OSStatus theErr = noErr; + SSpSourceReference theSource = NULL; + + theErr = SSpSource_New (&theSource); + + if (theErr != noErr) + { + DebugStr ("\pFailed to create a source"); + theSource = NULL; + } + + return theSource; +} + + +SSpListenerReference CreateListener() +{ + OSStatus theErr = noErr; + SSpListenerReference theSource = NULL; + + theErr = SSpListener_New (&theSource); + + if (theErr != noErr) + { + DebugStr ("\pFailed to create a listener"); + theSource = NULL; + } + + return theSource; +} + +void ConvertMarathonCoordinatesToSoundSprocket (world_location3d *theWorld, + TQ3CameraPlacement *outCamera) +{ + // up vector and orientation are arbitrary, will fix later. + angle pitch = normalize_angle (theWorld->pitch); + angle yaw = normalize_angle (theWorld->yaw); + + outCamera->cameraLocation.x = (float) theWorld->point.x; + outCamera->cameraLocation.y = (float) theWorld->point.y; + outCamera->cameraLocation.z = (float) theWorld->point.z; + + outCamera->upVector.x = gSprocketSinTable[pitch]; + outCamera->upVector.y = 0; + outCamera->upVector.z = gSprocketCosTable[pitch]; + + outCamera->pointOfInterest.x = (float) theWorld->point.x + (gSprocketCosTable[yaw]*gSprocketCosTable[pitch]); + outCamera->pointOfInterest.y = (float) theWorld->point.y - gSprocketSinTable[yaw]; + outCamera->pointOfInterest.z = (float) theWorld->point.z + (gSprocketCosTable[yaw]*gSprocketSinTable[pitch]); +} + +// Only needs to be called once per frame +void CalcListenerInfo (world_location3d *marathonCoords) +{ + TQ3CameraPlacement listenerPosition; + OSStatus theErr = noErr; + + // need to get the world coordinate -- how? + + ConvertMarathonCoordinatesToSoundSprocket (marathonCoords, &listenerPosition); + + theErr = SSpListener_SetCameraPlacement (gListener, &listenerPosition); + + if (theErr != noErr) + DebugStr ("\pFailed to set the camera position of the listener"); +} + + +// Needs to be called once per sound source that is being dynamically changed +void CalcSourceInfo(SSpSourceReference theSource, world_location3d *theWorld) +{ + TQ3CameraPlacement sourcePosition; + OSStatus theErr = noErr; + + // need to get the world coordinate -- how? + + ConvertMarathonCoordinatesToSoundSprocket (theWorld, &sourcePosition); + + theErr = SSpSource_SetCameraPlacement (theSource, &sourcePosition); + + if (theErr != noErr) + DebugStr ("\pFailed to set the camera position of the source"); +} + +#endif /* --------- constants */ enum @@ -75,6 +198,9 @@ void set_sound_manager_status( short i; OSErr error; struct channel_data *channel; +#ifdef SUPPORT_SOUND_SPROCKET + SoundComponentLink myLink; +#endif if (active != _sm_active) { @@ -95,6 +221,12 @@ void set_sound_manager_status( GetDefaultOutputVolume(&_sm_globals->old_sound_volume); SetDefaultOutputVolume(sound_level_to_sound_volume(_sm_parameters->volume)); +#ifdef SUPPORT_SOUND_SPROCKET + InitializeTables(); + gListener = CreateListener(); + SSpListener_SetMetersPerUnit (gListener, 0.0001); +#endif + for (i= 0, channel= _sm_globals->channels; i<_sm_globals->total_channel_count; ++i, ++channel) { /* initialize the channel */ @@ -121,6 +253,25 @@ void set_sound_manager_status( break; } + +#ifdef SUPPORT_SOUND_SPROCKET + channel->sspSource = CreateSource(); + + myLink.description.componentType = kSoundEffectsType; + myLink.description.componentSubType = kSSpLocalizationSubType; + myLink.description.componentManufacturer = 0; + myLink.description.componentFlags = 0; + myLink.description.componentFlagsMask = 0; + myLink.mixerID = nil; + myLink.linkID = nil; + + error = SndSetInfo(channel->channel, siPreMixerSoundComponent, &myLink); + if (error != noErr) + { + DebugStr("\pError in SOUND_SPROCKET - set_sound_manager_status"); + } +#endif + } } else @@ -130,8 +281,15 @@ void set_sound_manager_status( { error= SndDisposeChannel(channel->channel, TRUE); assert(error==noErr); +#ifdef SUPPORT_SOUND_SPROCKET + SSpSource_Dispose (channel->sspSource); +#endif } +#ifdef SUPPORT_SOUND_SPROCKET + SSpListener_Dispose (gListener); +#endif + SetDefaultOutputVolume(_sm_globals->old_sound_volume); // noticing that the default sound volume wasn’t correctly restored until the @@ -157,50 +315,51 @@ OSErr open_sound_file( FSSpec *spec) { OSErr error= noErr; - - if (_sm_initialized) + short refNum; + + error= FSpOpenDF(spec, fsRdPerm, &refNum); + if (error==noErr) { - short refNum; - - error= FSpOpenDF(spec, fsRdPerm, &refNum); - if (error==noErr) + long count; + + // read header { - long count; - - // read header + struct sound_file_header header; + + count= sizeof(struct sound_file_header); + error= FSRead(refNum, &count, (void *) &header); + if (error==noErr) { - struct sound_file_header header; - - count= sizeof(struct sound_file_header); - error= FSRead(refNum, &count, (void *) &header); - if (error==noErr) + if (header.version!=SOUND_FILE_VERSION || + header.tag!=SOUND_FILE_TAG || + header.sound_count!=NUMBER_OF_SOUND_DEFINITIONS || + header.source_count!=NUMBER_OF_SOUND_SOURCES) { - if (header.version!=SOUND_FILE_VERSION || - header.tag!=SOUND_FILE_TAG || - header.sound_count!=NUMBER_OF_SOUND_DEFINITIONS || - header.source_count!=NUMBER_OF_SOUND_SOURCES) - { - dprintf("sound file discarded %p 0x%x '%4s' #%d/#%d;g;", &header, header.version, &header.tag, header.sound_count, NUMBER_OF_SOUND_DEFINITIONS); - error= -1; - } + dprintf("sound file discarded %p 0x%x '%4.4s' #%d/#%d;g;", &header, header.version, &header.tag, header.sound_count, NUMBER_OF_SOUND_DEFINITIONS); + error= -1; } } - + } + + if (error==noErr) + { + count= NUMBER_OF_SOUND_SOURCES*NUMBER_OF_SOUND_DEFINITIONS*sizeof(struct sound_definition); + error= FSRead(refNum, &count, (void *) sound_definitions); if (error==noErr) { - count= NUMBER_OF_SOUND_SOURCES*NUMBER_OF_SOUND_DEFINITIONS*sizeof(struct sound_definition); - error= FSRead(refNum, &count, (void *) sound_definitions); - if (error==noErr) - { - } } - - if (error!=noErr) + else { - FSClose(refNum); - refNum= -1; + _sm_initialized= FALSE; } - + } + + if (error!=noErr) + { + FSClose(refNum); + } + else + { close_sound_file(); _sm_globals->sound_file_refnum= refNum; } @@ -343,11 +502,11 @@ static void unlock_sound( { struct sound_definition *definition= get_sound_definition(sound_index); - assert(definition->handle); + assert(definition->hndl); - if (definition->handle) + if (definition->hndl) { - HUnlock((Handle)definition->handle); + HUnlock((Handle)definition->hndl); } return; @@ -358,11 +517,11 @@ static void dispose_sound( { struct sound_definition *definition= get_sound_definition(sound_index); - assert(definition->handle); + assert(definition->hndl); - _sm_globals->loaded_sounds_size-= GetHandleSize((Handle)definition->handle); - DisposeHandle((Handle)definition->handle); - definition->handle= 0; + _sm_globals->loaded_sounds_size-= GetHandleSize((Handle)definition->hndl); + DisposeHandle((Handle)definition->hndl); + definition->hndl= 0; return; } @@ -447,6 +606,73 @@ static void quiet_channel( return; } +//•••••••••• +#ifdef SUPPORT_SOUND_SPROCKET + +static void instantiate_sound_variables( + struct sound_variables *variables, + struct channel_data *channel, + boolean first_time) +{ + + OSStatus error= noErr; + SndCommand command; + SSpLocalizationData stereoData; + + + + if (variables->useSprocketForSound) + { + // set the source location + error = SSpSource_SetCameraPlacement (channel->sspSource, &variables->source); + if (error != noErr) DebugStr ("\pFailed to set the source location"); + + error = SSpSource_SetReferenceDistance (channel->sspSource, 2000.0); + + + // calculate our channel parameters and pass them along to the channel + error = SSpSource_CalcLocalization (channel->sspSource, gListener, &stereoData); + if (error != noErr) DebugStr ("\pFailed to calculate the localization"); + + if (first_time) + stereoData.currentLocation.sourceVelocity = 0; + + stereoData.sourceMode = kSSpSourceMode_Localized; + + command.param1= 0; + command.param2= BUILD_STEREO_VOLUME(variables->volume, variables->volume); + error= SndDoImmediate(channel->channel, &command); + + SndSetInfo (channel->channel, siSSpLocalization, &stereoData); + + channel->variables= *variables; + } + else + { + SndCommand command; + SSpLocalizationData bogusLocalization; + + if (first_time || variables->right_volume!=channel->variables.right_volume || variables->left_volume!=channel->variables.left_volume) + { + /* set the sound volume */ + command.cmd= volumeCmd; + command.param1= 0; + command.param2= BUILD_STEREO_VOLUME(variables->left_volume, variables->right_volume); + error= SndDoImmediate(channel->channel, &command); + } + + vwarn(error==noErr, csprintf(temporary, "SndDoImmediate() == #%d in instantiate_sound_variables()", error)); + + channel->variables= *variables; + + bogusLocalization.sourceMode = kSSpSourceMode_Unfiltered; + SndSetInfo (channel->channel, siSSpLocalization, &bogusLocalization); + return; + } + +} + +#else static void instantiate_sound_variables( struct sound_variables *variables, struct channel_data *channel, @@ -470,6 +696,7 @@ static void instantiate_sound_variables( return; } +#endif static void buffer_sound( struct channel_data *channel, @@ -482,46 +709,37 @@ static void buffer_sound( SndCommand command; OSErr error; - assert(definition->handle); - HLock((Handle)definition->handle); + assert(definition->hndl); + HLock((Handle)definition->hndl); assert(permutation>=0 && permutationpermutations); - sound_header= (SoundHeaderPtr) ((*(byte **)definition->handle) + definition->sound_offsets[permutation]); + sound_header= (SoundHeaderPtr) ((*(byte **)definition->hndl) + definition->sound_offsets[permutation]); - /* play the sound */ - command.cmd= bufferCmd; /* high bit not set: we’re sending a real pointer */ + command.cmd= rateMultiplierCmd; command.param1= 0; - command.param2= (long) sound_header; - error= SndDoCommand(channel->channel, &command, FALSE); + command.param2= (long) calculate_pitch_modifier(sound_index, pitch); + error= SndDoImmediate(channel->channel, &command); if (error==noErr) { - /* queue the callback */ - command.cmd= callBackCmd; + /* play the sound */ + command.cmd= bufferCmd; /* high bit not set: we’re sending a real pointer */ command.param1= 0; - command.param2= 0; + command.param2= (long) sound_header; error= SndDoCommand(channel->channel, &command, FALSE); if (error==noErr) { - if (pitch!=FIXED_ONE) + /* queue the callback */ + command.cmd= callBackCmd; + command.param1= 0; + command.param2= 0; + error= SndDoCommand(channel->channel, &command, FALSE); + if (error==noErr) { - fixed rate; - - command.cmd= getRateCmd; - command.param1= 0; - command.param2= &rate; - error= SndDoImmediate(channel->channel, &command); - if (error==noErr) - { - command.cmd= rateCmd; - command.param1= 0; - command.param2= FixMul(rate, calculate_pitch_modifier(sound_index, pitch)); - error= SndDoImmediate(channel->channel, &command); - } } } } - vassert(error==noErr, csprintf(temporary, "SndDoCommand() == #%d in buffer_sound()", error)); + vwarn(error==noErr, csprintf(temporary, "SndDoCommand() == #%d in buffer_sound()", error)); return; } @@ -624,6 +842,9 @@ static synchronous_global_fade_to_silence( new->left_volume= (old->left_volume*(FADE_OUT_STEPS-step-1))/FADE_OUT_STEPS; new->right_volume= (old->right_volume*(FADE_OUT_STEPS-step-1))/FADE_OUT_STEPS; +#ifdef SUPPORT_SOUND_SPROCKET + variables->useSprocketForSound = false; +#endif instantiate_sound_variables(&channel->variables, channel, TRUE); } } diff --git a/marathon2/tags.h b/marathon2/tags.h index a869a1c..83d9492 100644 --- a/marathon2/tags.h +++ b/marathon2/tags.h @@ -13,13 +13,13 @@ #define MAXIMUM_LEVEL_NAME_SIZE 64 /* OSTypes.. */ -#define APPLICATION_CREATOR '52.4' +#define APPLICATION_CREATOR '26.∞' #define SCENARIO_FILE_TYPE 'sce2' -#define SAVE_GAME_TYPE 'sga2' -#define FILM_FILE_TYPE 'fil2' -#define PHYSICS_FILE_TYPE 'phy2' -#define SHAPES_FILE_TYPE 'shp2' -#define SOUNDS_FILE_TYPE 'snd2' +#define SAVE_GAME_TYPE 'sga∞' +#define FILM_FILE_TYPE 'fil∞' +#define PHYSICS_FILE_TYPE 'phy∞' +#define SHAPES_FILE_TYPE 'shp∞' +#define SOUNDS_FILE_TYPE 'snd∞' #define PATCH_FILE_TYPE 'pat2' /* Other tags- */ diff --git a/marathon2/textures.c b/marathon2/textures.c index e0b4dfe..da231d4 100644 --- a/marathon2/textures.c +++ b/marathon2/textures.c @@ -185,3 +185,34 @@ void map_bytes( return; } + +#if 0 +long bitmap_size( + struct bitmap_definition *bitmap) +{ + pixel8 *read= bitmap->row_addresses[0]; + long size; + + if (bitmap->bytes_per_row==NONE) + { + short row; + + size= 0; + for (row= 0; rowwidth*bitmap->height; + } + + return size; +} +#endif \ No newline at end of file diff --git a/marathon2/textures.h b/marathon2/textures.h index 1458245..e9b5a40 100644 --- a/marathon2/textures.h +++ b/marathon2/textures.h @@ -1,8 +1,54 @@ +#ifndef __TEXTURES_H +#define __TEXTURES_H + /* TEXTURES.H Saturday, August 20, 1994 12:08:34 PM */ +/* ---------- pixels */ + +typedef unsigned char pixel8; +typedef unsigned short pixel16; +typedef unsigned long pixel32; + +#define PIXEL8_MAXIMUM_COLORS 256 +#define PIXEL16_MAXIMUM_COLORS 32768 +#define PIXEL32_MAXIMUM_COLORS 16777216 + +#define PIXEL16_BITS 5 +#define PIXEL32_BITS 8 + +#define NUMBER_OF_COLOR_COMPONENTS 3 +#define PIXEL16_MAXIMUM_COMPONENT 0x1f +#define PIXEL32_MAXIMUM_COMPONENT 0xff + +#define RED16(p) ((p)>>10) /* pel must be clean */ +#define GREEN16(p) (((p)>>5)&PIXEL16_MAXIMUM_COMPONENT) +#define BLUE16(p) ((p)&PIXEL16_MAXIMUM_COMPONENT) +#define BUILD_PIXEL16(r,g,b) (((r)<<10)|((g)<<5)|(b)) +#define RGBCOLOR_TO_PIXEL16(r,g,b) (((pixel16)((r)>>1)&(pixel16)0x7c00)|((pixel16)((g)>>6)&(pixel16)0x03e0)|((pixel16)((b)>>11)&(pixel16)0x1f)) + +#define RED32(p) ((p)>>16) /* pel must be clean; may be impossible */ +#define GREEN32(p) (((p)>>8)&PIXEL32_MAXIMUM_COMPONENT) +#define BLUE32(p) ((p)&PIXEL32_MAXIMUM_COMPONENT) +#define BUILD_PIXEL32(r,g,b) (((r)<<16)|((g)<<8)|(b)) +#define RGBCOLOR_TO_PIXEL32(r,g,b) (((((pixel32)(r))<<8)&0x00ff0000) | ((((pixel32)(g)))&0x0000ff00) | ((((pixel32)(b))>>8)&0x000000ff)) + +/* ---------- color tables */ + +struct rgb_color +{ + word red, green, blue; +}; + +struct color_table +{ + short color_count; + + struct rgb_color colors[256]; +}; + /* ---------- structures */ enum /* bitmap flags */ @@ -18,7 +64,7 @@ struct bitmap_definition short flags; /* [column_order.1] [unused.15] */ short bit_depth; /* should always be ==8 */ - + short unused[8]; pixel8 *row_addresses[1]; @@ -34,3 +80,7 @@ void precalculate_bitmap_row_addresses(struct bitmap_definition *texture); void map_bytes(byte *buffer, byte *table, long size); void remap_bitmap(struct bitmap_definition *bitmap, pixel8 *table); + +void erase_bitmap(struct bitmap_definition *bitmap, long pel); + +#endif diff --git a/marathon2/valkyrie.c b/marathon2/valkyrie.c index fe727c3..a88ac39 100644 --- a/marathon2/valkyrie.c +++ b/marathon2/valkyrie.c @@ -80,7 +80,7 @@ volatile struct valkyrie_data *valkyrie= (struct valkyrie_data *) NULL; /* ---------- private code */ -static void valkyrie_change_clut(byte *clut_register, CTabHandle color_table); +static void valkyrie_change_clut(volatile byte *clut_register, CTabHandle color_table); #ifdef env68k static pascal void vbl_proc(void); @@ -202,7 +202,7 @@ void valkyrie_initialize_invisible_video_buffer( if (valkyrie->pixel_doubling) bitmap->width>>= 1, bitmap->height>>= 1; bitmap->bit_depth= 16; bitmap->bytes_per_row= VALKYRIETranslatedVideoBufferRowBytes; - bitmap->row_addresses[0]= valkyrie->visible_video_buffer ? VALKYRIETranslatedVideoBuffer0 : VALKYRIETranslatedVideoBuffer1; + bitmap->row_addresses[0]= valkyrie->visible_video_buffer ? (byte *)VALKYRIETranslatedVideoBuffer0 : (byte *)VALKYRIETranslatedVideoBuffer1; precalculate_bitmap_row_addresses(bitmap); while (!valkyrie->refresh); @@ -250,7 +250,7 @@ void valkyrie_erase_graphic_key_frame( if (valkyrie) { PixMapHandle pixmap= (*valkyrie->device)->gdPMap; - byte *base= (*pixmap)->baseAddr; + byte *base= (byte *)(*pixmap)->baseAddr; short bytes_per_row= (*pixmap)->rowBytes&0x3fff; short row; @@ -303,10 +303,12 @@ boolean machine_has_valkyrie( Gestalt(gestaltMachineType, &machine_type); switch (machine_type) { - case 41: - case 42: - case 98: // original quadra 630 - case 99: + case 41: // PPC 5200 + case 42: // PPC 6200 + case 98: // Q630 + case 99: // LC580 + case 106: // Q630 with PPC upgrade + case 107: // Q580 with PPC upgrade has_valkyrie= TRUE; break; } @@ -319,7 +321,7 @@ boolean machine_has_valkyrie( /* ignores ColorSpec.index (assumes linear ordering) */ void valkyrie_change_clut( - byte *clut_register, + volatile byte *clut_register, CTabHandle color_table) { short i; diff --git a/marathon2/vbl.c b/marathon2/vbl.c index f6ab536..fffe90a 100644 --- a/marathon2/vbl.c +++ b/marathon2/vbl.c @@ -42,7 +42,11 @@ Friday, January 13, 1995 11:38:51 AM (Jason') fixed the 'a' key getting blacklisted. */ +#ifdef SUPPORT_INPUT_SPROCKET +#include "macintosh_cseries.h" +#else #include "cseries.h" +#endif #include #include "map.h" @@ -53,6 +57,21 @@ Friday, January 13, 1995 11:38:51 AM (Jason') #include "tags.h" #include "portable_files.h" #include "vbl.h" +// for no particular reason, cseries is built with PPC alignment +#ifdef envppc +#pragma options align=power +#endif +#include "mytm.h" // for ludicrous speed +#ifdef envppc +#pragma options align=reset +#endif + +#ifdef SUPPORT_INPUT_SPROCKET +#include "InputSprocket.h" +extern ISpElementReference *input_sprocket_elements; +#include "macintosh_input.h" +#include "shell.h" +#endif #ifdef mpwc #pragma segment input @@ -156,11 +175,39 @@ void initialize_keyboard_controller( return; } +void toggle_ludicrous_speed( + boolean ludicrous_speed) +{ + if (input_task_active && input_task) + { + ((myTMTaskPtr)input_task)->period= + ((ludicrous_speed && (((myTMTaskPtr)input_task)->period == 1000/TICKS_PER_SECOND))? + 450/TICKS_PER_SECOND : 1000/TICKS_PER_SECOND); + } +} + void set_keyboard_controller_status( boolean active) { - input_task_active= active; +#ifdef SUPPORT_INPUT_SPROCKET + long int itr; +#endif + + // if already set then drop out + if (input_task_active == active) { return; } + input_task_active= active; +#ifdef SUPPORT_INPUT_SPROCKET + if (use_input_sprocket) + { + for(itr = 0; itr < NUMBER_OF_INPUT_SPROCKET_NEEDS; itr++) + { + ISpElement_Flush(input_sprocket_elements[itr]); + } + + active ? (void) ISpResume() : (void) ISpSuspend(); + } +#endif return; } @@ -558,7 +605,7 @@ boolean setup_for_replay_from_file( { boolean successful= FALSE; -#pragma unused(map_checksum); +#pragma unused(map_checksum) replay.recording_file_refnum= open_file_for_reading(file); if(replay.recording_file_refnum > 0) { @@ -575,7 +622,7 @@ boolean setup_for_replay_from_file( /* Set to the mapfile this replay came from.. */ if(use_map_file(replay.header.map_checksum)) { - replay.fsread_buffer= malloc(DISK_CACHE_SIZE); + replay.fsread_buffer= (char *)malloc(DISK_CACHE_SIZE); assert(replay.fsread_buffer); if(!replay.fsread_buffer) alert_user(fatalError, strERRORS, outOfMemory, memory_error()); diff --git a/marathon2/vbl.h b/marathon2/vbl.h index abc3367..664c7c5 100644 --- a/marathon2/vbl.h +++ b/marathon2/vbl.h @@ -19,6 +19,7 @@ void get_recording_header_data(short *number_of_players, short *level_number, un short *version, struct player_start_data *starts, struct game_data *game_information); boolean input_controller(void); +void toggle_ludicrous_speed(boolean ludicrous_speed); /* ------------ prototypes/VBL_MACINTOSH.C */ void initialize_keyboard_controller(void); diff --git a/marathon2/vbl_macintosh.c b/marathon2/vbl_macintosh.c index f4b5058..8766248 100644 --- a/marathon2/vbl_macintosh.c +++ b/marathon2/vbl_macintosh.c @@ -8,6 +8,10 @@ #include "macintosh_cseries.h" #include #include +#ifdef SUPPORT_INPUT_SPROCKET +#include "InputSprocket.h" +#include "macintosh_input.h" +#endif #include "map.h" #include "shell.h" @@ -85,7 +89,7 @@ boolean get_freespace_on_disk( memset(&parms, 0, sizeof(HParamBlockRec)); parms.volumeParam.ioCompletion = NULL; parms.volumeParam.ioVolIndex = 0; - parms.volumeParam.ioNamePtr = temporary; + parms.volumeParam.ioNamePtr = (StringPtr)temporary; parms.volumeParam.ioVRefNum = file->vRefNum; error = PBHGetVInfo(&parms, FALSE); @@ -106,7 +110,7 @@ boolean get_recording_filedesc( if(!error) { getpstr(temporary, strFILENAMES, filenameMARATHON_RECORDING); - error= FSMakeFSSpec(vRef, parID, temporary, (FSSpec *) file); + error= FSMakeFSSpec(vRef, parID, (StringPtr)temporary, (FSSpec *) file); } return (error==noErr); @@ -119,8 +123,8 @@ void move_replay( StandardFileReply reply; getpstr(temporary, strPROMPTS, _save_replay_prompt); - getpstr(suggested_name, strFILENAMES, filenameMARATHON_RECORDING); - StandardPutFile(temporary, suggested_name, &reply); + getpstr((char *)suggested_name, strFILENAMES, filenameMARATHON_RECORDING); + StandardPutFile((StringPtr)temporary, suggested_name, &reply); if(reply.sfGood) { FSSpec source_spec; @@ -145,6 +149,54 @@ void move_replay( return; } +#ifdef SUPPORT_INPUT_SPROCKET + +// +// +// ReadButton +// +// return true if button is down or if it has been clicked and released +// +// + +static UInt32 ReadButton(ISpElementReference button) +{ + UInt32 button_state; // state of button + OSStatus err; // error code + UInt32 timeout = 10; // only get this many events + ISpElementEvent event; // our event structure + Boolean wasEvent; // was there an event + + err = ISpElement_GetSimpleState(button, &button_state); + + if (err) + { + ISpElement_Flush(button); + return kISpButtonUp; + } + + while(timeout > 0) + { + // get an event + err = ISpElement_GetNextEvent(button, sizeof(ISpElementEvent), &event, &wasEvent); + + if (err != noErr) { return kISpButtonUp; } // got an error call that a button up + if (!wasEvent) { break; } // no event break out of the loop + + if (event.data == kISpButtonDown) // if down mark the button as down and flush + { + button_state = kISpButtonDown; + ISpElement_Flush(button); // flush any remaining events from this element + break; // exit out of the loop + } + + timeout--; // decrease our timeout + } + + return button_state; // return our state +} +#endif + long parse_keymap( void) { @@ -153,13 +205,33 @@ long parse_keymap( KeyMap key_map; struct key_definition *key= current_key_definitions; struct special_flag_data *special= special_flags; + long old_action_key; - GetKeys(&key_map); + GetKeys(key_map); - /* parse the keymap */ - for (i=0;ioffset) & key->mask) flags|= key->action_flag; + /* parse the keymap */ + for (i=0;ioffset) & key->mask) flags|= key->action_flag; + } } /* post-process the keymap */ @@ -207,7 +279,9 @@ long parse_keymap( flags= mask_in_absolute_positioning_information(flags, delta_yaw, delta_pitch, delta_velocity); } - if(player_in_terminal_mode(local_player_index)) + /* this is fighting with input sprocket in some strange way */ + + if (player_in_terminal_mode(local_player_index)) { flags= build_terminal_action_flags((char *) key_map); } @@ -246,7 +320,7 @@ static OSErr copy_file( GetFPos(source_refnum, &total_length); SetFPos(source_refnum, fsFromStart, 0l); - data= malloc(COPY_BUFFER_SIZE); + data= (Ptr)malloc(COPY_BUFFER_SIZE); if(data) { long running_length= total_length; diff --git a/marathon2/wad.c b/marathon2/wad.c index af45a76..afec0e6 100644 --- a/marathon2/wad.c +++ b/marathon2/wad.c @@ -27,7 +27,8 @@ Future Options: // Note that level_transition_malloc is specific to marathon... -#include "cseries.h" +#include "macintosh_cseries.h" + #include #include "wad.h" @@ -106,7 +107,7 @@ boolean read_wad_header( set_game_error(systemError, error); success= FALSE; } else { - if(header->version>CURRENT_WADFILE_VERSION) + if(header->version>CURRENT_WADFILE_VERSION && header->version!=INFINITY_WADFILE_VERSION) { set_game_error(gameError, errUnknownWadVersion); success= FALSE; @@ -487,7 +488,7 @@ void fill_default_wad_header( header->version= wadfile_version; header->data_version= data_version; memcpy(header->file_name, file->name, file->name[0]+1); - p2cstr(header->file_name); + p2cstr((StringPtr)header->file_name); header->wad_count= wad_count; header->application_specific_directory_data_size= application_directory_data_size; @@ -564,7 +565,7 @@ void *get_indexed_directory_data( short index, void *directories) { - byte *data_ptr= directories; + byte *data_ptr= (byte *)directories; short base_entry_size= get_directory_base_length(header); assert(header->version>=WADFILE_HAS_DIRECTORY_ENTRY); @@ -583,7 +584,7 @@ void set_indexed_directory_offset_and_length( long length, short wad_index) { - byte *data_ptr= entries; + byte *data_ptr= (byte *)entries; struct directory_entry *entry; long data_offset; @@ -616,7 +617,7 @@ void *read_directory_data( assert(header->version>=WADFILE_HAS_DIRECTORY_ENTRY); size= get_size_of_directory_data(header); - data= malloc(size); + data= (byte *)malloc(size); if(data) { FileError error; @@ -909,7 +910,7 @@ void *get_flat_data( /* Read the file */ success= read_wad_header(file_handle, &header); - if (success); + if (success) { long length; FileError error= 0; @@ -981,7 +982,7 @@ struct wad_data *inflate_flat_data( assert(raw_length==d->length-sizeof(struct encapsulated_wad_data)); /* Now inflate.. */ - wad= convert_wad_from_raw(header, data, sizeof(struct encapsulated_wad_data), raw_length); + wad= (struct wad_data *)convert_wad_from_raw(header, (byte *)data, sizeof(struct encapsulated_wad_data), raw_length); return wad; } @@ -1073,6 +1074,7 @@ static long calculate_directory_offset( assert(header->application_specific_directory_data_size==0); case WADFILE_HAS_DIRECTORY_ENTRY: case WADFILE_SUPPORTS_OVERLAYS: + case INFINITY_WADFILE_VERSION: assert(header->application_specific_directory_data_size>=0); unit_size= header->application_specific_directory_data_size+get_directory_base_length(header); additional_offset= header->application_specific_directory_data_size; @@ -1118,7 +1120,7 @@ static short get_directory_base_length( short size; assert(header); - assert(header->version<=CURRENT_WADFILE_VERSION); + assert(header->version<=CURRENT_WADFILE_VERSION || header->version==INFINITY_WADFILE_VERSION); switch(header->version) { @@ -1222,7 +1224,7 @@ static FileError read_indexed_wad_from_file_into_buffer( /* Veracity Check */ /* ! an error, it has a length non-zero and calculated != actual */ - assert(entry.length==calculate_raw_wad_length(header, buffer)); + assert(entry.length==calculate_raw_wad_length(header, (byte *)buffer)); } return error; @@ -1520,7 +1522,7 @@ static struct wad_internal_data *allocate_internal_data_for_file_id( /* Make sure it isn't already allocated */ assert(!internal_data[actual_index]); - internal_data[actual_index]= malloc(sizeof(struct wad_internal_data)); + internal_data[actual_index]= (struct wad_internal_data *)malloc(sizeof(struct wad_internal_data)); if(!internal_data[actual_index]) alert_user(fatalError, strERRORS, outOfMemory, memory_error()); /* If we got it.. */ diff --git a/marathon2/wad.h b/marathon2/wad.h index 71d5722..69af966 100644 --- a/marathon2/wad.h +++ b/marathon2/wad.h @@ -14,6 +14,13 @@ #define WADFILE_HAS_DIRECTORY_ENTRY 1 #define WADFILE_SUPPORTS_OVERLAYS 2 #define CURRENT_WADFILE_VERSION (WADFILE_SUPPORTS_OVERLAYS) +// The Infinity demo was version 3. +// Infinity release will be version 4. +#ifdef DEMO +#define INFINITY_WADFILE_VERSION (CURRENT_WADFILE_VERSION+1) +#else +#define INFINITY_WADFILE_VERSION (CURRENT_WADFILE_VERSION+2) +#endif #define MAXIMUM_DIRECTORY_ENTRIES_PER_FILE 64 #define MAXIMUM_WADFILE_NAME_LENGTH 64 diff --git a/marathon2/wad_macintosh.c b/marathon2/wad_macintosh.c index aaa89d5..0f71941 100644 --- a/marathon2/wad_macintosh.c +++ b/marathon2/wad_macintosh.c @@ -65,7 +65,7 @@ boolean find_wad_file_that_has_checksum( FSSpec test_directory_spec; getpstr(temporary, path_resource_id, index); - err= FSMakeFSSpec(app_spec.vRefNum, app_spec.parID, temporary, &test_directory_spec); + err= FSMakeFSSpec(app_spec.vRefNum, app_spec.parID, (StringPtr)temporary, &test_directory_spec); if(!err) { @@ -163,7 +163,7 @@ boolean find_file_with_modification_date( FSSpec test_directory_spec; getpstr(temporary, path_resource_id, index); - err= FSMakeFSSpec(app_spec.vRefNum, app_spec.parID, temporary, &test_directory_spec); + err= FSMakeFSSpec(app_spec.vRefNum, app_spec.parID, (StringPtr)temporary, &test_directory_spec); if(!err) { @@ -214,13 +214,13 @@ static Boolean checksum_and_not_base_callback( void *data) { Boolean add_this_file= FALSE; - struct find_files_private_data *private= (struct find_files_private_data *) data; + struct find_files_private_data *private_data= (struct find_files_private_data *) data; /* Don't readd the base file.. */ - if(!equal_fsspecs(file, (FSSpec *) private->base_file)) + if(!equal_fsspecs(file, (FSSpec *) private_data->base_file)) { /* Do the checksums match? */ - if(wad_file_has_parent_checksum((FileDesc *) file, private->base_checksum)) + if(wad_file_has_parent_checksum((FileDesc *) file, private_data->base_checksum)) { add_this_file= TRUE; } @@ -234,10 +234,10 @@ static Boolean match_wad_checksum_callback( void *data) { Boolean add_this_file= FALSE; - struct find_checksum_private_data *private= (struct find_checksum_private_data *) data; + struct find_checksum_private_data *private_data= (struct find_checksum_private_data *) data; /* Do the checksums match? */ - if(wad_file_has_checksum((FileDesc *) file, private->checksum_to_match)) + if(wad_file_has_checksum((FileDesc *) file, private_data->checksum_to_match)) { add_this_file= TRUE; } @@ -344,7 +344,7 @@ static Boolean match_modification_date_callback( { Boolean add_this_file= FALSE; CInfoPBRec *pb= (CInfoPBRec *) data; -#pragma unused (file); +#pragma unused (file) if(pb->hFileInfo.ioFlMdDat==target_modification_date) { add_this_file= TRUE; diff --git a/marathon2/wad_prefs.c b/marathon2/wad_prefs.c index 623eab2..780921e 100644 --- a/marathon2/wad_prefs.c +++ b/marathon2/wad_prefs.c @@ -156,7 +156,7 @@ void *w_get_data_from_preferences( /* We can't hand append_data_to_wad a copy of the data pointer it */ /* contains */ - new_data= malloc(expected_size); + new_data= (char *)malloc(expected_size); assert(new_data); memcpy(new_data, data, expected_size); diff --git a/marathon2/wad_prefs_macintosh.c b/marathon2/wad_prefs_macintosh.c index b5a9a5a..db76abf 100644 --- a/marathon2/wad_prefs_macintosh.c +++ b/marathon2/wad_prefs_macintosh.c @@ -65,7 +65,7 @@ boolean set_preferences( { AppendMenu(mHandle, "\p "); getpstr(temporary, funcs[index].resource_group, funcs[index].string_index); - SetMenuItemText(mHandle, index+1, temporary); + SetMenuItemText(mHandle, index+1, (StringPtr)temporary); } /* Set our max value.. */ diff --git a/marathon2/weapon_definitions.h b/marathon2/weapon_definitions.h index b8bf6dc..5231011 100644 --- a/marathon2/weapon_definitions.h +++ b/marathon2/weapon_definitions.h @@ -66,11 +66,15 @@ enum { _flamethrower_idle, _flamethrower_transit, _flamethrower_firing, - _assault_rifle_shell_casing, _pistol_shell_casing, + _assault_rifle_shell_casing, _fusion_charged, _alien_weapon_idle, - _alien_weapon_firing + _alien_weapon_firing, + _smg_idle, + _smg_firing, + _smg_reloading, + _smg_shell_casing }; /* ---------- shell casings */ @@ -81,6 +85,7 @@ enum // shell casing types _shell_casing_pistol, _shell_casing_pistol_left, _shell_casing_pistol_right, + _shell_casing_smg, NUMBER_OF_SHELL_CASING_TYPES }; @@ -94,10 +99,11 @@ struct shell_casing_definition fixed dvx, dvy; }; +#ifndef DONT_COMPILE_DEFINITIONS struct shell_casing_definition shell_casing_definitions[NUMBER_OF_SHELL_CASING_TYPES]= { { // _shell_casing_assault_rifle, - _collection_weapons_in_hand, 19, /* collection, shape */ + _collection_weapons_in_hand, _assault_rifle_shell_casing, /* collection, shape */ FIXED_ONE/2 + FIXED_ONE/6, FIXED_ONE/8, /* x0, y0 */ FIXED_ONE/8, FIXED_ONE/32, /* vx0, vy0 */ @@ -105,7 +111,7 @@ struct shell_casing_definition shell_casing_definitions[NUMBER_OF_SHELL_CASING_T }, { // _shell_casing_pistol_center - _collection_weapons_in_hand, 18, /* collection, shape */ + _collection_weapons_in_hand, _pistol_shell_casing, /* collection, shape */ FIXED_ONE/2 + FIXED_ONE/8, FIXED_ONE/4, /* x0, y0 */ FIXED_ONE/16, FIXED_ONE/32, /* vx0, vy0 */ @@ -113,7 +119,7 @@ struct shell_casing_definition shell_casing_definitions[NUMBER_OF_SHELL_CASING_T }, { // _shell_casing_pistol_left - _collection_weapons_in_hand, 18, /* collection, shape */ + _collection_weapons_in_hand, _pistol_shell_casing, /* collection, shape */ FIXED_ONE/2 - FIXED_ONE/4, FIXED_ONE/4, /* x0, y0 */ - FIXED_ONE/16, FIXED_ONE/32, /* vx0, vy0 */ @@ -121,13 +127,22 @@ struct shell_casing_definition shell_casing_definitions[NUMBER_OF_SHELL_CASING_T }, { // _shell_casing_pistol_right - _collection_weapons_in_hand, 18, /* collection, shape */ + _collection_weapons_in_hand, _pistol_shell_casing, /* collection, shape */ FIXED_ONE/2 + FIXED_ONE/4, FIXED_ONE/4, /* x0, y0 */ FIXED_ONE/16, FIXED_ONE/32, /* vx0, vy0 */ 0, -FIXED_ONE/400, /* dvx, dvy */ }, + + { // _shell_casing_smg, + _collection_weapons_in_hand, _smg_shell_casing, /* collection, shape */ + + FIXED_ONE/2 + FIXED_ONE/6, FIXED_ONE/8, /* x0, y0 */ + FIXED_ONE/8, FIXED_ONE/32, /* vx0, vy0 */ + 0, -FIXED_ONE/256, /* dvx, dvy */ + }, }; +#endif /* ---------- structures */ @@ -185,19 +200,24 @@ struct weapon_definition { /* ------------------------ globals */ +#ifndef DONT_COMPILE_DEFINITIONS short weapon_ordering_array[]= { _weapon_fist, _weapon_pistol, _weapon_plasma_pistol, _weapon_shotgun, _weapon_assault_rifle, + _weapon_smg, _weapon_flamethrower, _weapon_missile_launcher, _weapon_alien_shotgun, - _weapon_ball + _weapon_ball, }; +#endif #define NUMBER_OF_WEAPONS (sizeof(weapon_definitions)/sizeof(struct weapon_definition)) + +#ifndef DONT_COMPILE_DEFINITIONS struct weapon_definition weapon_definitions[]= { /* Fist*/ @@ -1003,5 +1023,95 @@ struct weapon_definition weapon_definitions[]= 0 } } + }, + + /* The New SMG. */ + { + /* item type, powerup type, item class, item flags */ + _i_smg, NONE, _normal_class, _weapon_is_automatic | _weapon_fires_under_media, + + 3*FIXED_ONE/4, TICKS_PER_SECOND/5, /* firing intensity, firing decay */ + + /* idle height, bob amplitude, kick height, reload height */ + FIXED_ONE+FIXED_ONE/6, FIXED_ONE/35, FIXED_ONE/16, 3*FIXED_ONE/4, + + /* horizontal positioning.. */ + FIXED_ONE_HALF, 0, + + /* collection, idle, firing, reloading shapes; shell casing, charging, charged */ + _weapon_in_hand_collection, + _smg_idle, _smg_firing, _smg_reloading, + + NONE, + NONE, NONE, + + /* ready/await/load/finish/powerup rounds ticks */ + TICKS_PER_SECOND/2, TICKS_PER_SECOND/3, TICKS_PER_SECOND/3, TICKS_PER_SECOND/3, 0, + + { + { + /* rounds per magazine */ + 32, + + /* Ammunition type */ + _i_smg_ammo, + + /* Ticks per round, recovery ticks, charging ticks */ + NONE, 0, 0, + + /* recoil magnitude */ + 5, + + /* firing, click, charging, shell casing, reload sound */ + _snd_smg_firing, _snd_empty_gun, NONE, _snd_assault_rifle_shell_casings, _snd_smg_reloading, NONE, + + /* projectile type */ + _projectile_smg_bullet, + + /* theta error */ + 3, + + /* dx, dz */ + 0, -NORMAL_WEAPON_DZ, + + /* shell casing type */ + _shell_casing_smg, + + /* burst count */ + 2 + }, + { + /* rounds per magazine */ + 32, + + /* Ammunition type */ + _i_smg_ammo, + + /* Ticks per round, recovery ticks, charging ticks */ + NONE, 0, 0, + + /* recoil magnitude */ + 5, + + /* firing, click, charging, shell casing, reload sound */ + _snd_smg_firing, _snd_empty_gun, NONE, _snd_assault_rifle_shell_casings, _snd_smg_reloading, NONE, + + /* projectile type */ + _projectile_smg_bullet, + + /* theta error */ + 3, + + /* dx, dz */ + 0, -NORMAL_WEAPON_DZ, + + /* shell casing type */ + _shell_casing_smg, + + /* burst count */ + 2 + } + } } }; +#endif diff --git a/marathon2/weapons.c b/marathon2/weapons.c index 5587456..1cae7f2 100644 --- a/marathon2/weapons.c +++ b/marathon2/weapons.c @@ -10,7 +10,7 @@ #include "projectiles.h" #include "player.h" #include "weapons.h" -#include "sound.h" +#include "game_sound.h" #include "interface.h" #include "items.h" #include "monsters.h" @@ -939,6 +939,7 @@ static void debug_weapon( case _weapon_missile_launcher: case _weapon_flamethrower: case _weapon_alien_shotgun: + case _weapon_smg: break; default: @@ -1491,6 +1492,7 @@ static struct trigger_definition *get_trigger_definition( { case _weapon_missile_launcher: case _weapon_flamethrower: + case _weapon_smg: vassert(which_trigger==_primary_weapon, csprintf(temporary, "which: %d weapon: %d", which_trigger, which_weapon)); break; diff --git a/marathon2/weapons.h b/marathon2/weapons.h index 1dc9cd1..3171953 100644 --- a/marathon2/weapons.h +++ b/marathon2/weapons.h @@ -16,6 +16,7 @@ enum { /* Weapons */ _weapon_alien_shotgun, _weapon_shotgun, _weapon_ball, // or something + _weapon_smg, MAXIMUM_NUMBER_OF_WEAPONS, _weapon_doublefisted_pistols= MAXIMUM_NUMBER_OF_WEAPONS, /* This is a pseudo-weapon */