import: src directory

This commit is contained in:
Jason Andersen 2024-01-07 19:36:36 -05:00
parent 262a009f73
commit 010f91c99e
51 changed files with 57619 additions and 0 deletions

28
src/control.c Normal file
View file

@ -0,0 +1,28 @@
/*
* xrick/src/control.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "config.h"
#include "system.h"
#include "game.h"
#ifdef IIGS
#pragma noroot
#endif
U8 control_status = 0;
U8 control_last = 0;
U8 control_active = TRUE;
/* eof */

912
src/dat_ents.c Normal file
View file

@ -0,0 +1,912 @@
/*
* xrick/data/dat_ents.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "ents.h"
#ifdef IIGS
#pragma noroot
segment "dat";
#endif
entdata_t ent_entdata[ENT_NBR_ENTDATA] = {
{0000, 0000, 000000, 000000, 0000, 0000, 0x00},
{0x18, 0x15, 000000, 000000, 0000, 0000, 0x00},
{0000, 0000, 000000, 000000, 0000, 0000, 0x00},
{0x18, 0x15, 000000, 000000, 0000, 0000, 0x00},
{0x18, 0x15, 0x002f, 0x008e, 0000, 0000, 0x00},
{0x18, 0x15, 0x002f, 0x008e, 0000, 0000, 0x00},
{0x18, 0x15, 0x002f, 0x008e, 0000, 0000, 0x00},
{0x18, 0x15, 0x0037, 0x007e, 0000, 0000, 0x00},
{0x18, 0x15, 0x0037, 0x007e, 0000, 0000, 0x00},
{0x18, 0x15, 0x0037, 0x007e, 0000, 0000, 0x00},
{0x18, 0x15, 0x0041, 0x0086, 0000, 0000, 0x00},
{0x18, 0x15, 0x0041, 0x0086, 0000, 0000, 0x00},
{0x18, 0x15, 0x0041, 0x0086, 0000, 0000, 0x00},
{0x18, 0x15, 0x004b, 0x0086, 0000, 0000, 0x00},
{0x18, 0x15, 0x004b, 0x0086, 0000, 0000, 0x00},
{0x18, 0x15, 0x004b, 0x0086, 0000, 0000, 0x00},
{0x18, 0x15, 0x0029, 0x0029, 0000, 0000, 0x00},
{0x18, 0x15, 0x002a, 0x002a, 0000, 0000, 0x00},
{0x18, 0x15, 0x002b, 0x002b, 0000, 0000, 0x00},
{0x18, 0x15, 0x002c, 0x002c, 0000, 0000, 0x00},
{0x18, 0x15, 0x002e, 0x002e, 0000, 0000, 0x00},
{0x18, 0x15, 0x002d, 0x002d, 0000, 0000, 0x00},
{0x18, 0x15, 0x001e, 0x001e, 0x04, 0x04, 0x00},
{0x18, 0x15, 0x001f, 0x001f, 0x04, 0x04, 0x00},
{0x18, 0x10, 0x000c, 000000, 0x03, 0x03, 0x14},
{0x18, 0x06, 0x000e, 0x0005, 0x04, 0x04, 0x14},
{0x18, 0x06, 0x000e, 0x0007, 0x10, 0x04, 0x14},
{0x18, 0x12, 0x0011, 0x0009, 0x04, 0x04, 0x18},
{0x18, 0x10, 0x000c, 0x0007, 0x04, 0x04, 0x14},
{0x18, 0x15, 0x0014, 0x00a4, 0x04, 0x04, 0x15},
{0x18, 0x15, 0x0014, 0x00ca, 0x04, 0x04, 0x15},
{0x18, 0x10, 0x000c, 0x000d, 0x04, 0x04, 0x14},
{0x04, 0x15, 0x0018, 0x0012, 0x04, 0x07, 0x14},
{0x18, 0x10, 0x000c, 0x0014, 0x14, 0x04, 0x19},
{0x10, 0x10, 0x001b, 0x0028, 0x04, 0x04, 0x00},
{0x10, 0x10, 0x001e, 0x002a, 0x04, 0x04, 0x00},
{0x18, 0x10, 0x000c, 0x002d, 0x03, 0x03, 0x14},
{0x20, 0x08, 0x0020, 0x0009, 0x04, 0x04, 0x18},
{0x18, 0x10, 0x000c, 0x0034, 0x04, 0x04, 0x14},
{0x20, 0x0d, 0x0023, 0x0009, 0x04, 0x04, 0x18},
{0x18, 0x15, 0x0026, 0x003a, 0x04, 0x04, 0x18},
{0x18, 0x15, 0x0026, 0x003c, 0x04, 0x04, 0x18},
{0x18, 0x15, 0x002c, 0x003e, 0x04, 0x04, 0x14},
{0x18, 0x10, 0x0030, 0x0048, 0x04, 0x04, 0x14},
{0x20, 0x10, 0x0008, 0x0007, 0x04, 0x04, 0x14},
{0x18, 0x15, 0x000a, 0x004c, 0x14, 0x04, 0x14},
{0x18, 0x15, 0x0036, 0x0009, 0x03, 0x03, 0x17},
{0x18, 0x15, 0x0039, 0x0053, 0x04, 0x04, 0x16},
{0x20, 0x10, 0x0008, 0x0055, 0x04, 0x04, 0x14},
{0x18, 0x15, 0x000a, 0x0061, 0x04, 0x04, 0x14},
{0x12, 0x15, 0x003c, 0x0067, 0x04, 0x04, 0x1A},
{0x12, 0x15, 0x0041, 0x006a, 0x18, 0x04, 0x1A},
{0x18, 0x15, 0x000a, 0x006c, 0x04, 0x04, 0x14},
{0x18, 0x15, 0x0046, 0x0071, 0x04, 0x04, 0x1A},
{0x12, 0x10, 0x004b, 0x0074, 0x04, 0x04, 0x17},
{0x12, 0x10, 0x004f, 0x0074, 0x04, 0x04, 0x17},
{0x18, 0x15, 0x0053, 0x0076, 0x04, 0x04, 0x13},
{0x10, 0x08, 0x0057, 0x0007, 0x10, 0x04, 0x1C},
{0x18, 0x10, 0x005a, 0x007e, 0x04, 0x04, 0x00},
{0x18, 0x10, 0x005c, 0x0009, 0x03, 0x03, 0x9A},
{0x18, 0x11, 0x0068, 0x0088, 0x04, 0x04, 0x14},
{0x12, 0x15, 0x003c, 0x008e, 0x18, 0x04, 0x1A},
{0x18, 0x15, 0x006a, 0x0009, 0x04, 0x04, 0x1A},
{0x20, 0x08, 0x0075, 0x0090, 0x14, 0x04, 0x15},
{0x18, 0x10, 0x006d, 0x0009, 0x03, 0x03, 0x9A},
{0x18, 0x15, 0x0077, 0x0012, 0x04, 0x06, 0x15},
{0x18, 0x15, 0x0046, 0x0092, 0x1f, 0x04, 0x1A},
/*
{0x18, 0x15, 0xfff4, 0x0094, 0x04, 0x04},
{0x18, 0x15, 0xfff4, 0x00bf, 0x04, 0x04},
*/
{0x18, 0x15, 0x0080, 0x0094, 0x04, 0x04, 0x1B},
{0x18, 0x15, 0x0080, 0x00bf, 0x04, 0x04, 0X00},
{0x18, 0x11, 0x0068, 0x00e5, 0x04, 0x04, 0x14},
{0x18, 0x10, 0x005a, 0x00ea, 0x04, 0x04, 0x00},
{0x12, 0x15, 0x003c, 0x00f4, 0x18, 0x04, 0x1A},
{0x20, 0x10, 0x0008, 0x0005, 0x04, 0x04, 0x14},
{0x18, 0x10, 0x000c, 0x0005, 0x04, 0x04, 0x14},
};
U8 ent_sprseq[ENT_NBR_SPRSEQ] = {
0000, 0x01, 0000, 0x02, 0x05, 0x03, 0x04, 0x03,
0x65, 0xff, 0x66, 0xff, 0x55, 0xff, 0000, 0x56,
0xff, 0000, 0x57, 0xff, 0000, 0x58, 0x59, 0xff,
0000, 0x5a, 0xff, 0x5b, 0000, 0xff, 0x5c, 0xff,
0x5d, 0000, 0xff, 0000, 0x79, 0xff, 0000, 0x5e,
0x5f, 0x60, 0x5f, 0xff, 0000, 0x61, 0x69, 0xff,
0x64, 0x62, 0x62, 0x63, 0x63, 0xff, 0x67, 0x68,
0xff, 0000, 0000, 0xff, 0x6a, 0x6a, 0x6b, 0x6b,
0xff, 0x6b, 0x6b, 0x6a, 0x6a, 0xff, 0x6d, 0x6e,
0x6f, 0x70, 0xff, 0x71, 0000, 0000, 0xff, 0x72,
0000, 0000, 0xff, 0x73, 0x47, 0x48, 0xff, 0000,
0x74, 0xff, 0x75, 0xff, 0000, 0x7c, 0x7c, 0x7a,
0x7a, 0x7b, 0x7b, 0x7a, 0x7a, 0x7c, 0x7c, 0xff,
0x78, 0xff, 0x6d, 0x6e, 0xff, 0000, 0x7a, 0x7a,
0x7b, 0x7b, 0x7c, 0x7c, 0xff, 0x6c, 0xff, 0x2d,
0xff, 0x10, 0000, 0000, 0x0c, 0000, 0x04, 0xfa,
/* xtra */
0xff, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xff, 0x00,
};
mvstep_t ent_mvstep[ENT_NBR_MVSTEP] = {
{ 0x10, 0, 0 } ,
{ 0x0c, 0, 4 } ,
{ 0xfa, 0, 0 } ,
{ 0x30, 0, -1 } ,
{ 0xff, 0, 0 } ,
{ 0x46, 8, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x46, -8, 0 } ,
{ 0xff, 0, 0 } ,
{ 0xf8, 0, 0 } ,
{ 0xf8, 0, 0 } ,
{ 0xf8, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0xfa, 0, 0 } ,
{ 0x08, 0, 4 } ,
{ 0x22, 0, 0 } ,
{ 0x08, 0, -4 } ,
{ 0xff, 0, 0 } ,
{ 0x46, 0, -8 } ,
{ 0xff, 0, 0 } ,
{ 0x09, 0, 0 } ,
{ 0x08, 0, 1 } ,
{ 0x05, 0, 0 } ,
{ 0x08, 0, 1 } ,
{ 0x05, 0, 0 } ,
{ 0x08, 0, 1 } ,
{ 0x05, 0, 0 } ,
{ 0x08, 0, 1 } ,
{ 0x05, 0, 0 } ,
{ 0x08, 0, 1 } ,
{ 0x05, 0, 0 } ,
{ 0x08, 0, 1 } ,
{ 0xfa, 0, 0 } ,
{ 0xfa, 0, 0 } ,
{ 0xfa, 0, 0 } ,
{ 0xfa, 0, 0 } ,
{ 0xfa, 0, 0 } ,
{ 0xfa, 0, 0 } ,
{ 0x06, 0, -8 } ,
{ 0xff, 0, 0 } ,
{ 0x01, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x23, 0, 0 } ,
{ 0x46, 0, 8 } ,
{ 0xff, 0, 0 } ,
{ 0x10, 0, 0 } ,
{ 0x0c, 0, 4 } ,
{ 0xfa, 0, 0 } ,
{ 0x04, 0, 8 } ,
{ 0x19, 0, 0 } ,
{ 0x0a, 0, -8 } ,
{ 0xff, 0, 0 } ,
{ 0x22, 2, 0 } ,
{ 0x96, 0, 0 } ,
{ 0x22, 2, 0 } ,
{ 0x19, 0, 0 } ,
{ 0x11, -8, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x80, 2, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x80, 1, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x60, 2, 0 } ,
{ 0x08, 0, 4 } ,
{ 0x0c, 0, 8 } ,
{ 0x2c, -2, 0 } ,
{ 0x08, 0, 4 } ,
{ 0x20, -2, 0 } ,
{ 0x08, 0, 4 } ,
{ 0x0c, 0, 8 } ,
{ 0x46, -2, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x20, 1, 2 } ,
{ 0x19, 0, 0 } ,
{ 0x20, -1, -2 } ,
{ 0xff, 0, 0 } ,
{ 0x08, 0, 2 } ,
{ 0x04, 0, 4 } ,
{ 0x25, 0, 0 } ,
{ 0x04, 0, -4 } ,
{ 0x08, 0, -2 } ,
{ 0x0c, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x18, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x08, -4, 0 } ,
{ 0x08, 0, 4 } ,
{ 0x10, -8, 0 } ,
{ 0x19, 0, 0 } ,
{ 0x08, 8, 0 } ,
{ 0x04, 0, -4 } ,
{ 0x96, 0, 0 } ,
{ 0x08, 8, 0 } ,
{ 0xfa, 0, 0 } ,
{ 0x04, 0, -4 } ,
{ 0x08, 4, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x04, 0, 4 } ,
{ 0x04, 0, 8 } ,
{ 0x32, 0, 0 } ,
{ 0x30, 0, -1 } ,
{ 0x4b, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x04, -4, 0 } ,
{ 0x1c, -2, 2 } ,
{ 0xff, 0, 0 } ,
{ 0x80, 3, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x20, 0, -1 } ,
{ 0x24, 0, 0 } ,
{ 0x04, 0, 4 } ,
{ 0x02, 0, 8 } ,
{ 0xff, 0, 0 } ,
{ 0x04, 0, 0 } ,
{ 0xfe, -2, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x08, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x02, 0, -4 } ,
{ 0x02, 0, -2 } ,
{ 0x01, 0, -1 } ,
{ 0x01, 0, 1 } ,
{ 0x02, 0, 2 } ,
{ 0x04, 0, 4 } ,
{ 0xfe, 0, 8 } ,
{ 0xff, 0, 0 } ,
{ 0x0c, 4, 0 } ,
{ 0x04, 2, 0 } ,
{ 0x02, 0, 0 } ,
{ 0x04, -2, 0 } ,
{ 0x30, -4, 0 } ,
{ 0x04, -2, 0 } ,
{ 0x2e, 0, 0 } ,
{ 0x04, 2, 0 } ,
{ 0x23, 4, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x10, 0, 0 } ,
{ 0x20, 1, 0 } ,
{ 0x10, 3, 0 } ,
{ 0x2c, 2, 0 } ,
{ 0x2a, -4, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x80, -3, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x80, -12, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x46, -6, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x06, 0, 0 } ,
{ 0x01, 64, -64 } ,
{ 0x06, 0, 0 } ,
{ 0x01, -80, -32 } ,
{ 0x06, 0, 0 } ,
{ 0x01, -80, 8 } ,
{ 0x06, 0, 0 } ,
{ 0x01, 32, 32 } ,
{ 0x06, 0, 0 } ,
{ 0x01, 0, 88 } ,
{ 0x06, 0, 0 } ,
{ 0x01, 64, -96 } ,
{ 0x06, 0, 0 } ,
{ 0x46, 6, 3 } ,
{ 0x06, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x03, -8, 0 } ,
{ 0x01, -10, -2 } ,
{ 0x01, -6, -2 } ,
{ 0x01, -6, -5 } ,
{ 0x01, -5, -6 } ,
{ 0x01, -2, -6 } ,
{ 0x01, -2, -10 } ,
{ 0x01, 2, -10 } ,
{ 0x01, 2, -6 } ,
{ 0x01, 5, -6 } ,
{ 0x01, 6, -5 } ,
{ 0x01, 6, -2 } ,
{ 0x01, 10, -2 } ,
{ 0x01, 10, 2 } ,
{ 0x01, 6, 2 } ,
{ 0x01, 6, 5 } ,
{ 0x01, 5, 6 } ,
{ 0x01, 2, 6 } ,
{ 0x01, 2, 10 } ,
{ 0x01, -2, 10 } ,
{ 0x01, -2, 6 } ,
{ 0x01, -5, 6 } ,
{ 0x01, -6, 5 } ,
{ 0x01, -6, 2 } ,
{ 0x01, -10, 2 } ,
{ 0x46, -8, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x06, 0, 0 } ,
{ 0x01, 0, -128 } ,
{ 0x06, 0, 0 } ,
{ 0x01, -64, 64 } ,
{ 0x06, 0, 0 } ,
{ 0x01, -128, -32 } ,
{ 0x06, 0, 0 } ,
{ 0x01, -32, -32 } ,
{ 0x06, 0, 0 } ,
{ 0x01, 112, 64 } ,
{ 0x06, 0, 0 } ,
{ 0x03, 8, 0 } ,
{ 0x01, 10, -2 } ,
{ 0x01, 6, -2 } ,
{ 0x01, 6, -5 } ,
{ 0x01, 5, -6 } ,
{ 0x01, 2, -6 } ,
{ 0x01, 2, -10 } ,
{ 0x01, -2, -10 } ,
{ 0x01, -2, -6 } ,
{ 0x01, -5, -6 } ,
{ 0x01, -6, -5 } ,
{ 0x01, -6, -2 } ,
{ 0x01, -10, -2 } ,
{ 0x01, -10, 2 } ,
{ 0x01, -6, 2 } ,
{ 0x01, -6, 5 } ,
{ 0x01, -5, 6 } ,
{ 0x01, -2, 6 } ,
{ 0x01, -2, 10 } ,
{ 0x01, 2, 10 } ,
{ 0x01, 2, 6 } ,
{ 0x01, 5, 6 } ,
{ 0x01, 6, 5 } ,
{ 0x01, 6, 2 } ,
{ 0x01, 10, 2 } ,
{ 0x46, 8, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x40, 2, 0 } ,
{ 0x20, -2, 0 } ,
{ 0x36, 2, 0 } ,
{ 0x56, -2, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x18, 0, 0 } ,
{ 0x04, -2, 0 } ,
{ 0x20, -4, 0 } ,
{ 0x04, -2, 0 } ,
{ 0x28, 0, 0 } ,
{ 0x04, 2, 0 } ,
{ 0x20, 4, 0 } ,
{ 0x04, 2, 0 } ,
{ 0x02, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0x02, -1, 0 } ,
{ 0x34, -3, 0 } ,
{ 0x02, -1, 0 } ,
{ 0x02, 0, 0 } ,
{ 0x02, 1, 0 } ,
{ 0x34, 3, 0 } ,
{ 0x02, 1, 0 } ,
{ 0x02, 0, 0 } ,
{ 0x02, -1, 0 } ,
{ 0x34, -3, 0 } ,
{ 0x02, -1, 0 } ,
{ 0x02, 0, 0 } ,
{ 0x02, 1, 0 } ,
{ 0x34, 3, 0 } ,
{ 0x02, 1, 0 } ,
{ 0x02, 0, 0 } ,
{ 0xff, 0, 0 } ,
{ 0000, 0, -128 } ,
{ 0x42, -118, 118 } ,
{ 0x35, 121, 0 } ,
{ 0000, -8, 66 } ,
{ 0x97, 118, 78 } ,
{ 0x79, 0, 0 } ,
{ 0xd0, 67, -92 } ,
{ 0x76, -118, 121 } ,
{ 0000, 0, 24 } ,
{ 0x44, -79, 118 } ,
{ 0xad, 121, 0 } ,
{ 0000, 32, 69 } ,
{ 0xbe, 118, 12 } ,
{ 0x7a, 0, 0 } ,
{ 0xc8, 69, -53 } ,
{ 0x76, 62, 122 } ,
{ 0000, 0, 24 } ,
{ 0x46, -40, 118 } ,
{ 0x52, 122, 0 } ,
{ 0000, 40, 71 } ,
{ 0xe5, 118, -99 } ,
{ 0x7a, 0, 0 } ,
{ 0x38, 72, -14 } ,
{ 0x76, -24, 122 } ,
{ 0000, 0, -128 } ,
{ 0x4a, -1, 118 } ,
{ 0x2e, 123, 0 } ,
{ 0000, -128, 75 } ,
{ 0x0c, 119, -110 } ,
{ 0x7b, 0, 0 } ,
{ 0x48, 76, 25 } ,
{ 0x77, -45, 123 } ,
{ 0000, 0, -64 } ,
{ 0x4c, 38, 119 } ,
{ 0x0a, 124, 0 } ,
{ 0000, 40, 77 } ,
{ 0x33, 119, 60 } ,
{ 0x7c, 0, 0 } ,
{ 0x98, 77, 64 } ,
{ 0x77, 105, 124 } ,
{ 0000, 0, 104 } ,
{ 0x4e, 77, 119 } ,
{ 0xaa, 124, 0 } ,
{ 0000, 104, 79 } ,
{ 0x5a, 119, -6 } ,
{ 0x7c, 0, 0 } ,
{ 0x78, 80, 103 } ,
{ 0x77, 74, 125 } ,
{ 0000, 0, -8 } ,
{ 0x50, 116, 119 } ,
{ 0x6d, 125, 0 } ,
{ 0000, -40, 81 } ,
{ 0x81, 119, -82 } ,
{ 0x7d, 1, 0 } ,
{ 0xe0, 82, -114 } ,
{ 0x77, -17, 125 } ,
{ 0x01, 0, 112 } ,
{ 0x53, -101, 119 } ,
{ 0x17, 126, 1 } ,
{ 0000, -64, 83 } ,
{ 0xb4, 119, 68 } ,
{ 0x7e, 1, 0 } ,
{ 0x10, 84, -51 } ,
{ 0x77, 103, 126 } ,
{ 0x01, 0, -64 } ,
{ 0x54, -38, 119 } ,
{ 0xa8, 126, 1 } ,
{ 0000, 64, 85 } ,
{ 0xe7, 119, -33 } ,
{ 0x7e, 1, 0 } ,
{ 0x90, 85, -6 } ,
{ 0x77, 2, 127 } ,
{ 0x01, 0, 64 } ,
{ 0x56, 13, 120 } ,
{ 0x2f, 127, 1 } ,
{ 0000, -112, 86 } ,
{ 0x26, 120, 77 } ,
{ 0x7f, 1, 0 } ,
{ 0x40, 87, 63 } ,
{ 0x78, -114, 127 } ,
{ 0x01, 0, -112 } ,
{ 0x57, 82, 120 } ,
{ 0xac, 127, 1 } ,
{ 0000, 16, 88 } ,
{ 0x65, 120, -19 } ,
{ 0x7f, 1, 0 } ,
{ 0x60, 88, 114 } ,
{ 0x78, 16, -128 } ,
{ 0x01, 0, 16 } ,
{ 0x59, 127, 120 } ,
{ 0x47, -128, 1 } ,
{ 0000, -64, 89 } ,
{ 0x8c, 120, -125 } ,
{ 0x80, 1, 0 } ,
{ 0xd0, 90, -103 } ,
{ 0x78, -50, -128 } ,
{ 0x01, 0, -128 } ,
{ 0x5b, -90, 120 } ,
{ 0xf6, -128, 1 } ,
{ 0000, 48, 92 } ,
{ 0xb3, 120, 30 } ,
{ 0x81, 1, 0 } ,
{ 0x0a, 93, -64 } ,
{ 0x78, 85, -127 } ,
{ 0x01, 0, 106 } ,
{ 0x5d, -51, 120 } ,
{ 0x82, -127, 1 } ,
{ 0000, 74, 94 } ,
{ 0xda, 120, -41 } ,
{ 0x81, 1, 0 } ,
{ 0x9a, 94, -25 } ,
{ 0x78, -6, -127 } ,
{ 0x01, 0, 122 } ,
{ 0x5f, -12, 120 } ,
{ 0x54, -126, 1 } ,
{ 0000, -54, 95 } ,
{ 0x01, 121, -127 } ,
{ 0x82, 1, 0 } ,
{ 0xaa, 96, 14 } ,
{ 0x79, -52, -126 } ,
{ 0x01, 0, -6 } ,
{ 0x60, 27, 121 } ,
{ 0xea, -126, 1 } ,
{ 0000, -38, 97 } ,
{ 0x28, 121, 63 } ,
{ 0x83, 0, 24 } ,
{ 0xff, 0, 0 } ,
{ 0000, 1, 56 } ,
{ 0x1a, 117, 24 } ,
{ 0000, -1, 0 } ,
{ 0x18, 18, 117 } ,
{ 0x38, 0, 1 } ,
{ 0x68, 34, 117 } ,
{ 0x20, 0, -1 } ,
{ 0000, 32, 26 } ,
{ 0x75, 104, 0 } ,
{ 0x01, 24, 42 } ,
{ 0x75, 24, 0 } ,
{ 0xff, 0, 24 } ,
{ 0x22, 117, 24 } ,
{ 0000, 1, -128 } ,
{ 0x32, 117, 24 } ,
{ 0000, -1, 0 } ,
{ 0x18, 42, 117 } ,
{ 0x80, 0, 1 } ,
{ 0x50, 58, 117 } ,
{ 0x18, 0, -1 } ,
{ 0000, 24, 50 } ,
{ 0x75, 80, 0 } ,
{ 0x01, 32, 66 } ,
{ 0x75, -128, 0 } ,
{ 0xff, 1, 24 } ,
{ 0x4a, 117, -128 } ,
{ 0000, 0, -128 } ,
{ 0x3a, 117, 32 } ,
{ 0000, -1, 1 } ,
{ 0x18, 82, 117 } ,
{ 0x18, 0, 0 } ,
{ 0x80, 66, 117 } ,
{ 0x18, 0, -1 } ,
{ 0000, 24, 74 } ,
{ 0x75, 24, 0 } ,
{ 0x01, -128, -1 } ,
{ 0000, 0, 0 } ,
{ 0xff, 1, 24 } ,
{ 0x62, 117, 96 } ,
{ 0000, 0, 120 } ,
{ 0xff, 0, 0 } ,
{ 0000, -1, 1 } ,
{ 0x18, 106, 117 } ,
{ 0x30, 0, 0 } ,
{ 0x60, 90, 117 } ,
{ 0x18, 0, -1 } ,
{ 0x01, 24, 114 } ,
{ 0x75, 48, 0 } ,
{ 0000, 48, 98 } ,
{ 0x75, 24, 0 } ,
{ 0xff, 1, 48 } ,
{ 0x7a, 117, 24 } ,
{ 0000, 0, 48 } ,
{ 0x6a, 117, 24 } ,
{ 0000, -1, 0 } ,
{ 0x18, 114, 117 } ,
{ 0x30, 0, 1 } ,
{ 0x30, -126, 117 } ,
{ 0x18, 0, -1 } ,
{ 0000, 24, 122 } ,
{ 0x75, 48, 0 } ,
{ 0x01, 96, -118 } ,
{ 0x75, 24, 0 } ,
{ 0xff, 0, 24 } ,
{ 0x82, 117, 96 } ,
{ 0000, 1, 120 } ,
{ 0x92, 117, -128 } ,
{ 0000, -1, 1 } ,
{ 0x18, -102, 117 } ,
{ 0x18, 0, 0 } ,
{ 0x80, -118, 117 } ,
{ 0x78, 0, -1 } ,
{ 0000, 24, -110 } ,
{ 0x75, 24, 0 } ,
{ 0x01, 56, -86 } ,
{ 0x75, 104, 0 } ,
{ 0xff, 0, 24 } ,
{ 0x9a, 117, 56 } ,
{ 0000, 1, 104 } ,
{ 0xaa, 117, 104 } ,
{ 0000, -1, 1 } ,
{ 0x18, -1, 0 } ,
{ 0000, 0, 0 } ,
{ 0x68, -94, 117 } ,
{ 0x68, 0, -1 } ,
{ 0000, 32, -1 } ,
{ 0000, 0, 0 } ,
{ 0x01, 64, -70 } ,
{ 0x75, 24, 0 } ,
{ 0xff, 0, 24 } ,
{ 0xb2, 117, 64 } ,
{ 0000, 1, 24 } ,
{ 0xc2, 117, 24 } ,
{ 0000, 0, 32 } ,
{ 0xc2, 117, 24 } ,
{ 0000, 1, 32 } ,
{ 0xc2, 117, 32 } ,
{ 0000, -1, 1 } ,
{ 0x18, -70, 117 } ,
{ 0x20, 0, 0 } ,
{ 0x18, -70, 117 } ,
{ 0x18, 0, 1 } ,
{ 0x20, -54, 117 } ,
{ 0x20, 0, 0 } ,
{ 0x20, -70, 117 } ,
{ 0x20, 0, -1 } ,
{ 0000, 32, -62 } ,
{ 0x75, 32, 0 } ,
{ 0x01, 80, -46 } ,
{ 0x75, 24, 0 } ,
{ 0xff, 0, 24 } ,
{ 0xca, 117, 80 } ,
{ 0000, 1, 56 } ,
{ 0xda, 117, 24 } ,
{ 0000, -1, 0 } ,
{ 0x18, -46, 117 } ,
{ 0x38, 0, 1 } ,
{ 0x18, -46, 117 } ,
{ 0x20, 0, 1 } ,
{ 0x20, -30, 117 } ,
{ 0x18, 0, -1 } ,
{ 0000, 24, -38 } ,
{ 0x75, 32, 0 } ,
{ 0x01, 72, -22 } ,
{ 0x75, 32, 0 } ,
{ 0x01, 80, -38 } ,
{ 0x75, 32, 0 } ,
{ 0xff, 1, 24 } ,
{ 0xea, 117, 24 } ,
{ 0000, 0, 24 } ,
{ 0xea, 117, 24 } ,
{ 0000, 0, 32 } ,
{ 0xe2, 117, 72 } ,
{ 0000, 1, 32 } ,
{ 0xf2, 117, 48 } ,
{ 0000, -1, 0 } ,
{ 0x18, -30, 117 } ,
{ 0x18, 0, 0 } ,
{ 0x30, -22, 117 } ,
{ 0x20, 0, 1 } ,
{ 0x48, -6, 117 } ,
{ 0x20, 0, 1 } ,
{ 0x50, -38, 117 } ,
{ 0x20, 0, -1 } ,
{ 0x01, 24, -6 } ,
{ 0x75, 24, 0 } ,
{ 0000, 32, -14 } ,
{ 0x75, 72, 0 } ,
{ 0x01, 32, 2 } ,
{ 0x76, 24, 0 } ,
{ 0xff, 0, 24 } ,
{ 0xfa, 117, 32 } ,
{ 0000, 1, 24 } ,
{ 0xca, 117, 24 } ,
{ 0000, 1, 56 } ,
{ 0x0a, 118, 32 } ,
{ 0000, -1, 0 } ,
{ 0x20, 2, 118 } ,
{ 0x38, 0, 1 } ,
{ 0x20, 18, 118 } ,
{ 0x50, 0, -1 } ,
{ 0x01, 24, 26 } ,
{ 0x76, 80, 0 } ,
{ 0000, 80, 10 } ,
{ 0x76, 32, 0 } ,
{ 0xff, 1, 24 } ,
{ 0x22, 118, 24 } ,
{ 0000, 0, 80 } ,
{ 0x12, 118, 24 } ,
{ 0000, -1, 0 } ,
{ 0x18, 26, 118 } ,
{ 0x18, 0, 1 } ,
{ 0x80, 42, 118 } ,
{ 0x50, 0, -1 } ,
{ 0x01, 24, 50 } ,
{ 0x76, 80, 0 } ,
{ 0000, 80, 34 } ,
{ 0x76, -128, 0 } ,
{ 0xff, 1, 24 } ,
{ 0x3a, 118, 24 } ,
{ 0000, 0, 80 } ,
{ 0x2a, 118, 24 } ,
{ 0000, -1, 0 } ,
{ 0x18, 50, 118 } ,
{ 0x18, 0, 1 } ,
{ 0x50, -1, 0 } ,
{ 0000, 0, -1 } ,
{ 0000, 32, -1 } ,
{ 0000, 0, 0 } ,
{ 0x01, 40, 74 } ,
{ 0x76, 104, 0 } ,
{ 0xff, 1, 24 } ,
{ 0x52, 118, 24 } ,
{ 0000, 0, 104 } ,
{ 0x42, 118, 40 } ,
{ 0000, -1, 0 } ,
{ 0x18, 74, 118 } ,
{ 0x18, 0, 1 } ,
{ 0x20, 90, 118 } ,
{ 0x18, 0, -1 } ,
{ 0000, 24, 82 } ,
{ 0x76, 32, 0 } ,
{ 0x01, 104, 98 } ,
{ 0x76, 24, 0 } ,
{ 0xff, 0, 24 } ,
{ 0x5a, 118, 104 } ,
{ 0000, 1, 24 } ,
{ 0x6a, 118, 104 } ,
{ 0000, -1, 1 } ,
{ 0x18, 114, 118 } ,
{ 0x20, 0, 0 } ,
{ 0x68, 98, 118 } ,
{ 0x18, 0, -1 } ,
{ 0x01, 24, 122 } ,
{ 0x76, 24, 0 } ,
{ 0000, 32, 106 } ,
{ 0x76, 24, 0 } ,
{ 0xff, 0, 24 } ,
{ 0x72, 118, 24 } ,
{ 0000, 1, 96 } ,
{ 0x82, 118, 32 } ,
{ 0000, -1, 0 } ,
{ 0x20, 122, 118 } ,
{ 0x60, 0, 1 } ,
{ 0x24, -1, 0 } ,
{ 0000, 0, -1 } ,
{ 0x18, 22, 0 } ,
{ 0x08, 8, 24 } ,
{ 0x2a, -120, 1 } ,
{ 0x28, 56, 4 } ,
{ 0xf0, 21, 41 } ,
{ 0x38, 23, 1 } ,
{ 0xe0, -32, -1 } ,
{ 0000, 0, 0 } ,
{ 0000, 24, 18 } ,
{ 0000, -59, 0 } ,
{ 0x18, 25, -120 } ,
{ 0x95, -61, 32 } ,
{ 0x04, 0, 101 } ,
{ 0x71, 40, 4 } ,
{ 0xf0, -123, -126 } ,
{ 0x30, 4, 0 } ,
{ 0x45, 96, 56 } ,
{ 0x19, -120, 17 } ,
{ 0x63, 72, 18 } ,
{ 0000, 77, 0 } ,
{ 0x60, 27, -120 } ,
{ 0xc2, -62, 104 } ,
{ 0x04, -16, -75 } ,
{ 0x61, 104, 25 } ,
{ 0x88, 17, 34 } ,
{ 0x68, 18, 0 } ,
{ 0x55, 0, -1 } ,
{ 0000, 0, 0 } ,
{ 0000, 24, 5 } ,
{ 0000, 73, 3 } ,
{ 0x18, 5, -16 } ,
{ 0xc1, 1, 24 } ,
{ 0x06, 0, -119 } ,
{ 0000, 32, 22 } ,
{ 0x01, 36, 36 } ,
{ 0x20, 23, 1 } ,
{ 0xc4, -60, 32 } ,
{ 0x12, 0, 117 } ,
{ 0000, -1, 0 } ,
{ 0000, 0, 0 } ,
{ 0x18, 22, 0 } ,
{ 0000, 0, 24 } ,
{ 0x04, 0, -127 } ,
{ 0x40, 24, 17 } ,
{ 0000, -103, 0 } ,
{ 0x38, 47, -127 } ,
{ 0x2d, -115, 56 } ,
{ 0x1b, -120, 37 } ,
{ 0x25, 64, 45 } ,
{ 0x8c, 114, 116 } ,
{ 0x40, 45, -114 } ,
{ 0x8a, 116, 72 } ,
{ 0x2b, -4, 105 } ,
{ 0x69, 80, 4 } ,
{ 0000, -127, 40 } ,
{ 0x50, 25, -120 } ,
{ 0x11, 64, 96 } ,
{ 0x12, 0, 85 } ,
{ 0000, 104, 44 } ,
{ 0x1f, -122, -108 } ,
{ 0x78, 46, 21 } ,
{ 0x7a, 106, 120 } ,
{ 0x2e, 21, -118 } ,
{ 0x7a, -128, 23 } ,
{ 0x01, -32, -32 } ,
{ 0x80, 18, 0 } ,
{ 0x35, 0, -128 } ,
{ 0x04, -16, 53 } ,
{ 0x61, -128, 4 } ,
{ 0000, -123, 48 } ,
{ 0xff, 0, 0 } ,
{ 0000, 0, 24 } ,
{ 0x12, 0, -82 } ,
{ 0000, 48, 25 } ,
{ 0x88, 21, -124 } ,
{ 0x38, 49, -116 } ,
{ 0x80, -92, 64 } ,
{ 0x10, 0, 13 } ,
{ 0000, 64, 4 } ,
{ 0xf0, 85, 96 } ,
{ 0x48, 25, 72 } ,
{ 0x15, -60, 72 } ,
{ 0x04, 0, -123 } ,
{ 0x40, 72, 4 } ,
{ 0000, 117, 56 } ,
{ 0x50, 46, 21 } ,
{ 0xc6, -74, -1 } ,
{ 0000, 0, 0 } ,
{ 0000, 24, 37 } ,
{ 0x84, 99, -124 } ,
{ 0x18, 37, -124 } ,
{ 0xa3, 64, 32 } ,
{ 0x30, -114, -30 } ,
{ 0x44, -1, 0 } ,
{ 0000, 0, 0 } ,
{ 0x20, 16, 0 } ,
{ 0xa1, 0, 40 } ,
{ 0x48, 31, 98 } ,
{ 0x80, 48, 4 } ,
{ 0x80, 69, -128 } ,
{ 0x30, 17, 0 } ,
{ 0x65, 0, 56 } ,
{ 0x1a, -120, -27 } ,
{ 0x84, 64, 5 } ,
{ 0000, 101, 3 } ,
{ 0x50, 25, -120 } ,
{ 0x11, 32, 80 } ,
{ 0x05, -16, 33 } ,
{ 0x07, 88, 5 } ,
{ 0000, -127, 5 } ,
{ 0x68, 4, 0 } ,
{ 0xa5, 64, 112 } ,
{ 0x12, 0, -51 } ,
{ 0000, 112, 25 } ,
{ 0x88, 21, 100 } ,
{ 0x78, 4, -16 } ,
{ 0x45, 96, -128 } ,
{ 0x04, -16, 69 } ,
{ 0x80, -1, 0 } ,
{ 0000, 0, 0 } ,
{ 0x18, 44, 31 } ,
{ 0xe2, -64, 24 } ,
{ 0x19, -120, 21 } ,
{ 0x24, 40, 17 } ,
{ 0000, -59, 0 } ,
{ 0x28, 26, -120 } ,
{ 0xd1, 32, 56 } ,
{ 0x04, 0, 33 } ,
{ 0x70, 64, 4 } ,
{ 0xf0, -127, 96 } ,
{ 0x40, 27, -120 } ,
{ 0x25, 36, 80 } ,
{ 0x12, 0, 33 } ,
{ 0000, 80, 25 } ,
{ 0x88, 17, 96 } ,
{ 0x60, 26, -120 } ,
{ 0xe1, -96, 96 } ,
{ 0x19, -120, 21 } ,
{ 0xc4, 104, 4 } ,
{ 0000, 33, 96 } ,
{ 0x70, 25, -120 } ,
{ 0x15, -124, 120 } ,
{ 0x05, 0, 69 } ,
{ 0000, -1, 0 } ,
{ 0000, 0, 0 } ,
{ 0x18, 39, -120 } ,
{ 0x62, 96, 24 } ,
{ 0x1b, -120, 37 } ,
{ 0x24, 24, 27 } ,
{ 0x88, -123, -124 } ,
{ 0x30, 26, -120 } ,
{ 0xe1, 64, 48 } ,
{ 0x19, -120, 17 } ,
{ 0x40, 56, 4 } ,
{ 0xf0, 85, 96 } ,
{ 0x58, 27, -120 } ,
{ 0x81, -128, 88 } ,
{ 0x04, -16, -123 } ,
{ 0x40, 104, 39 } ,
{ 0x88, 98, 96 } ,
{ 0x68, 18, 0 } ,
{ 0x25, 0, 120 } ,
{ 0x1a, -120, -31 } ,
{ 0000, -128, 44 } ,
{ 0x1f, -124, -128 } ,
{ 0x80, 44, 29 } ,
{ 0xe2, -64, -1 } ,
{ 0000, 0, 0 } ,
{ 0000, 24, 23 } ,
{ 0x01, -32, -32 } ,
};
/* eof */

2373
src/dat_maps.c Normal file

File diff suppressed because it is too large Load diff

27
src/dat_picsPC.c Normal file
View file

@ -0,0 +1,27 @@
/*
* xrick/data/dat_picsPC.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "config.h"
#ifdef IIGS
#pragma noroot
#endif
#ifdef GFXPC
#include "system.h"
#include "pics.h"
#endif /* GFXPC */
/* eof */

10792
src/dat_picsST.c Normal file

File diff suppressed because it is too large Load diff

257
src/dat_screens.c Normal file
View file

@ -0,0 +1,257 @@
/*
* xrick/src/scr_data.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "screens.h"
#ifdef IIGS
#pragma noroot
segment "dat";
#endif
/*
* map intro, sprites lists
*/
U8 screen_imapsl[] = {
0x1b, 0x00,
0x1c, 0x1d, 0x00,
0x01, 0x00,
0x02, 0x03, 0x04, 0x05, 0x06, 0x00,
0x1e, 0x00,
0x0d, 0x00,
0x13, 0x14, 0x00,
0x1f, 0x00
};
/*
* map intro, steps
*/
screen_imapsteps_t screen_imapsteps[] = {
{ 0x0000, 0x0002, 0x0002, 0x0000 },
{ 0x000b, 0x0000, 0x0001, 0x0000 },
{ 0x0008, 0x0001, 0x0000, 0x0002 },
{ 0x0000, 0x0000, 0x000c, 0x0000 },
{ 0x000a, 0x0000, 0x0000, 0x0005 },
{ 0x0006, 0x0002, 0x0000, 0x0007 },
{ 0x0005, 0x0000, 0x0000, 0x0005 },
{ 0x0000, 0x0006, 0x0000, 0x0000 },
{ 0x000c, 0x0000, 0x0001, 0x0000 },
{ 0x0005, 0x0000, 0x0000, 0x000d },
{ 0x0000, 0x000c, 0x000c, 0x0000 },
{ 0x0005, 0x0000, 0x0000, 0x0005 },
{ 0x000a, 0x0000, 0x0000, 0x000f },
{ 0x000c, 0xffff, 0x0000, 0x0011 },
{ 0x0005, 0x0000, 0x0000, 0x000f },
{ 0x0000, 0x0006, 0x0001, 0x0000 },
{ 0x000a, 0x0000, 0x0000, 0x0014 },
{ 0x0006, 0x0000, 0x0001, 0x0014 },
{ 0x0005, 0x0000, 0x0000, 0x0014 },
{ 0x0003, 0x0001, 0x0000, 0x0014 },
{ 0x0006, 0xffff, 0x0000, 0x0014 },
{ 0x0003, 0x0000, 0xffff, 0x0014 },
{ 0x0000, 0x0000, 0x0000, 0x0000 }
};
/*
* map intro, step offset per map
*/
U8 screen_imapsofs[] = {
0x00, 0x03, 0x07, 0x0a, 0x0f
};
/*
* map intro, text
* (from ds + 0x8810 + 0x2000, 0x2138, 0x2251, 0x236a, 0x2464)
*
* \376=0xfe \377=0xff
*/
U8 screen_imaptext_amazon[] = "\
@@@@@SOUTH@AMERICA@1945@@@@@@@\377\
RICK@DANGEROUS@CRASH@LANDS@HIS\377\
@PLANE@OVER@THE@AMAZON@WHILE@@\377\
@SEARCHING@FOR@THE@LOST@GOOLU@\377\
@@@@@@@@@@@@TRIBE.@@@@@@@@@@@@\377\377\
@BUT,@BY@A@TERRIBLE@TWIST@OF@@\377\
FATE@HE@LANDS@IN@THE@MIDDLE@OF\377\
@@@A@BUNCH@OF@WILD@GOOLUS.@@@@\377\377\
@@CAN@RICK@ESCAPE@THESE@ANGRY@\377\
@@@AMAZONIAN@ANTAGONISTS@?@@@@\376";
U8 screen_imaptext_egypt[] = "\
@@@@EGYPT,@SOMETIMES@LATER@@@@\377\
RICK@HEADS@FOR@THE@PYRAMIDS@AT\377\
@@@@THE@REQUEST@OF@LONDON.@@@@\377\377\
HE@IS@TO@RECOVER@THE@JEWEL@OF@\377\
ANKHEL@THAT@HAS@BEEN@STOLEN@BY\377\
FANATICS@WHO@THREATEN@TO@SMASH\377\
@IT,@IF@A@RANSOM@IS@NOT@PAID.@\377\377\
CAN@RICK@SAVE@THE@GEM,@OR@WILL\377\
HE@JUST@GET@A@BROKEN@ANKHEL@?@\376";
U8 screen_imaptext_castle[] = "\
@@@@EUROPE,@LATER@THAT@WEEK@@@\377\
@@RICK@RECEIVES@A@COMMUNIQUE@@\377\
@@FROM@BRITISH@INTELLIGENCE@@@\377\
@@ASKING@HIM@TO@RESCUE@ALLIED@\377\
@PRISONERS@FROM@THE@NOTORIOUS@\377\
@@@@SCHWARZENDUMPF@CASTLE.@@@@\377\377\
@@RICK@ACCEPTS@THE@MISSION.@@@\377\377\
@@@BUT@CAN@HE@LIBERATE@THE@@@@\377\
@CRUELLY@CAPTURED@COOMANDOS@?@\376";
U8 screen_imaptext_missile[] = "\
@@@@@@EUROPE,@EVEN@LATER@@@@@@\377\
RICK@LEARNS@FROM@THE@PRISONERS\377\
@THAT@THE@ENEMY@ARE@TO@LAUNCH@\377\
AN@ATTACK@ON@LONDON@FROM@THEIR\377\
@@@@@SECRET@MISSILE@BASE.@@@@@\377\377\
WITHOUT@HESITATION,@HE@DECIDES\377\
@@@TO@INFILTRATE@THE@BASE.@@@@\377\377\
CAN@RICK@SAVE@LONDON@IN@TIME@?\376";
U8 screen_imaptext_muchlater[] = "\
@@@LONDON,@MUCH,@MUCH@LATER@@@\377\
@RICK@RETURNS@TO@A@TRIUMPHANT@\377\
@@WELCOME@HOME@HAVING@HELPED@@\377\
@@@@SECURE@ALLIED@VICTORY.@@@@\377\377\
BUT,@MEANWHILE,@IN@SPACE,@THE@\377\
@@@MASSED@STARSHIPS@OF@THE@@@@\377\
@@@BARFIAN@EMPIRE@ARE@POISED@@\377\
@@@@@TO@INVADE@THE@EARTH.@@@@@\377\377\
@WHAT@WILL@RICK@DO@NEXT@...@?@\376";
U8 *screen_imaptext[5] =
{ screen_imaptext_amazon,
screen_imaptext_egypt,
screen_imaptext_castle,
screen_imaptext_missile,
screen_imaptext_muchlater
};
/*
* main intro, hall of fame title
* (from ds + 0x8810 + 0x2642)
*/
U8 screen_imainhoft[] =
{ 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0xd4, 0xb7, 0xb1,
0xac, 0xc6, 0x2f, 0xc6, 0x2f, 0x2f, 0xa4, 0xac,
0x9b, 0xc1, 0x2f, 0x9b, 0xc1, 0xb1, 0xac, 0xb6,
0xbd, 0x9b, 0xc1, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
0xff,
0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0xb2, 0xb3, 0xb2,
0xb3, 0xad, 0x2f, 0xad, 0x2f, 0x2f, 0xa6, 0xae,
0xc2, 0xc3, 0x2f, 0xc2, 0xc3, 0xb2, 0xb3, 0xbe,
0xbf, 0xc2, 0xc3, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
0xff,
0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x9f, 0xc0, 0xb4,
0xb5, 0xaf, 0xc4, 0xaf, 0xc4, 0x2f, 0xa7, 0xb0,
0xb4, 0x2f, 0x2f, 0xb4, 0x2f, 0xb4, 0xb5, 0xb4,
0xb5, 0xaf, 0xc4, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f,
0xfe
};
/*
* main intro, Rick Dangerous title
* (from ds + 0x8810 + 0x27a1)
*/
U8 screen_imainrdt[] =
{ 0x2f, 0x2f, 0x2f, 0x9b, 0x9c, 0xa1, 0xa4, 0xa5,
0xa9, 0xaa, 0x2f, 0x9b, 0xac, 0xb1, 0xac, 0xb6,
0xb7, 0xa4, 0xa5, 0x9b, 0xc1, 0x9b, 0x9c, 0xa4,
0xac, 0xc6, 0xc7, 0xc8, 0xc9, 0x2f, 0x2f, 0x2f,
0xff,
0x2f, 0x2f, 0x2f, 0x9d, 0x9e, 0xa2, 0xa6, 0x2f,
0x9d, 0xab, 0x2f, 0xad, 0xae, 0xb2, 0xb3, 0xb8,
0xb9, 0xa6, 0xbb, 0xc2, 0xc3, 0x9d, 0x9e, 0xa6,
0xae, 0xad, 0xae, 0xca, 0xcb, 0x2f, 0x2f, 0x2f,
0xff,
0x2f, 0x2f, 0x2f, 0x9f, 0xa0, 0xa3, 0xa7, 0xa8,
0x9f, 0xa0, 0x2f, 0xaf, 0xb0, 0xb4, 0xb5, 0x9f,
0xba, 0xa7, 0xbc, 0xaf, 0xc4, 0x9f, 0xa0, 0xa7,
0xb0, 0xc5, 0xb0, 0xcc, 0xb0, 0x2f, 0x2f, 0x2f,
0xfe
};
/*
* congratulations
* (from ds + 0x8810 + 0x257d)
*/
U8 screen_congrats[] =
{ 0xa4, 0xa5, 0xa4, 0xac, 0xb6, 0xb7, 0xa4, 0xa5,
0x9b, 0x9c, 0xb1, 0xac, 0xcd, 0xce, 0xc6, 0xc7,
0xd3, 0x2f, 0xb1, 0xac, 0xcd, 0xce, 0xa1, 0xa4,
0xac, 0xb6, 0xb7, 0xc8, 0xc9, 0x2f, 0xd5, 0xd6,
0xff,
0xa6, 0x2f, 0xa6, 0xae, 0xb8, 0xb9, 0xa6, 0xbb,
0x9d, 0x9e, 0xb2, 0xb3, 0xcf, 0xd0, 0xad, 0xae,
0xad, 0x2f, 0xb2, 0xb3, 0xcf, 0xd0, 0xa2, 0xa6,
0xae, 0xb8, 0xb9, 0xca, 0xcb, 0x2f, 0xd7, 0xd8,
0xff,
0xa7, 0xa8, 0xa7, 0xb0, 0x9f, 0xba, 0xa7, 0xbc,
0x9f, 0xa0, 0xb4, 0xb5, 0xd1, 0xd2, 0xc5, 0xb0,
0xaf, 0xc4, 0xb4, 0xb5, 0xd1, 0xd2, 0xa3, 0xa7,
0xb0, 0x9f, 0xba, 0xcc, 0xb0, 0x2f, 0xd9, 0xda,
0xfe
};
/*
* main intro, Core Design copyright text
* (from ds + 0x8810 + 0x2288)
*
* \376=0xfe \377=0xff
*/
U8 screen_imaincdc[] = "\
@@@@@@@@@@@@@@@@@@@\377\377\
(C)@1989@CORE@DESIGN\377\377\377\
@PRESS@SPACE@TO@START\376";
/*
* gameover
* (from ds + 0x8810 + 0x2864)
*
* \376=0xfe \377=0xff
*/
U8 screen_gameovertxt[] = "\
@@@@@@@@@@@\377\
@GAME@OVER@\377\
@@@@@@@@@@@\376";
/*
* paused
*
* \376=0xfe \377=0xff
*/
U8 screen_pausedtxt[] = "\
@@@@@@@@@@\377\
@@PAUSED@@\377\
@@@@@@@@@@\376";
/* eof */

55
src/dat_snd.c Normal file
View file

@ -0,0 +1,55 @@
/*
* xrick/data/dat_snd.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "config.h"
#ifdef IIGS
#pragma noroot
//segment "dat";
#endif
#ifdef ENABLE_SOUND
#include "system.h"
#ifdef IIGS
sound_t WAV_WAA;
sound_t WAV_BOMB;
sound_t WAV_BULLET;
sound_t WAV_WALK;
sound_t WAV_JUMP;
sound_t WAV_TING;
sound_t WAV_BOMBSHHT;
sound_t WAV_BONUS;
sound_t WAV_SHHT;
sound_t WAV_BOX;
sound_t WAV_DDDING;
#else
sound_t *WAV_WAA;
sound_t *WAV_BOMB;
sound_t *WAV_BULLET;
sound_t *WAV_WALK;
sound_t *WAV_JUMP;
sound_t *WAV_TING;
sound_t *WAV_BOMBSHHT;
sound_t *WAV_BONUS;
sound_t *WAV_SHHT;
sound_t *WAV_BOX;
sound_t *WAV_DDDING;
#endif /* IIGS */
#endif /* ENABLE_SOUND */
/* eof */

14601
src/dat_spritesPC.c Normal file

File diff suppressed because it is too large Load diff

4981
src/dat_spritesST.c Normal file

File diff suppressed because it is too large Load diff

1611
src/dat_tilesPC.c Normal file

File diff suppressed because it is too large Load diff

7721
src/dat_tilesST.c Normal file

File diff suppressed because it is too large Load diff

258
src/data.c Normal file
View file

@ -0,0 +1,258 @@
/*
* xrick/src/data.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include <stdlib.h> /* malloc */
#include <string.h>
#include "system.h"
#include "data.h"
#if !(defined(IIGS) || defined(F256))
#include "unzip.h"
#endif
#ifdef IIGS
#pragma noroot
segment "dat";
#endif
/*
* Private typedefs
*/
#if !(defined(IIGS) || defined(F256))
typedef struct {
char *name;
unzFile zip;
} zipped_t;
typedef struct {
char *name;
unzFile zip;
} path_t;
/*
* Static variables
*/
static path_t path;
/*
* Prototypes
*/
static int str_zipext(char *);
static char *str_dup(char *);
static char *str_slash(char *);
#endif //IIGS
/*
*
*/
void
data_setpath(char *name)
{
#ifdef IIGS
#elif defined(F256)
#else
unzFile zip;
char *n;
if (str_zipext(name)) {
/* path has .zip extension */
n = str_slash(str_dup(name));
zip = unzOpen(n);
if (!zip) {
free(n);
sys_panic("(data) can not open data");
} else {
path.zip = zip;
path.name = n;
}
} else {
/* path has no .zip extension. it should be a directory */
/* FIXME check that it is a valid directory */
path.zip = NULL;
path.name = str_dup(name);
}
#endif
}
/*
*
*/
void
data_closepath()
{
#ifdef IIGS
#elif defined(F256)
#else
if (path.zip) {
unzClose(path.zip);
path.zip = NULL;
}
free(path.name);
path.name = NULL;
#endif
}
#if !(defined(IIGS) || defined(F256))
/*
* Open a data file.
*/
data_file_t *
data_file_open(char *name)
{
char *n;
FILE *fh;
zipped_t *z;
if (path.zip) {
z = malloc(sizeof(zipped_t));
z->name = strdup(name);
z->zip = unzDup(path.zip);
if (unzLocateFile(z->zip, name, 0) != UNZ_OK ||
unzOpenCurrentFile(z->zip) != UNZ_OK) {
unzClose(z->zip);
z = NULL;
}
return (data_file_t *)z;
} else {
n = malloc(strlen(path.name) + strlen(name) + 2);
sprintf(n, "%s/%s", path.name, name);
str_slash(n);
fh = fopen(n, "rb");
return (data_file_t *)fh;
}
}
int
data_file_size(data_file_t *file)
{
int s;
if (path.zip) {
/* not implemented */
} else {
fseek((FILE *)file, 0, SEEK_END);
s = ftell((FILE *)file);
fseek((FILE *)file, 0, SEEK_SET);
}
return s;
}
/*
* Seek.
*/
int
data_file_seek(data_file_t *file, long offset, int origin)
{
if (path.zip) {
/* not implemented */
return -1;
} else {
return fseek((FILE *)file, offset, origin);
}
}
/*
* Tell.
*/
int
data_file_tell(data_file_t *file)
{
if (path.zip) {
/* not implemented */
return -1;
} else {
return ftell((FILE *)file);
}
}
/*
* Read a file within a data archive.
*/
int
data_file_read(data_file_t *file, void *buf, size_t size, size_t count)
{
if (path.zip) {
return unzReadCurrentFile(((zipped_t *)file)->zip, buf, size * count) / size;
} else {
return fread(buf, size, count, (FILE *)file);
}
}
/*
* Close a file within a data archive.
*/
void
data_file_close(data_file_t *file)
{
if (path.zip) {
unzClose(((zipped_t *)file)->zip);
((zipped_t *)file)->zip = NULL;
free(((zipped_t *)file)->name);
((zipped_t *)file)->name = NULL;
} else {
fclose((FILE *)file);
}
}
/*
* Returns 1 if filename has .zip extension.
*/
static int
str_zipext(char *name)
{
int i;
i = strlen(name) - 1;
if (i < 0 || name[i] != 'p' && name[i] != 'P') return 0;
i--;
if (i < 0 || name[i] != 'i' && name[i] != 'I') return 0;
i--;
if (i < 0 || name[i] != 'z' && name[i] != 'Z') return 0;
i--;
if (i < 0 || name[i] != '.') return 0;
i--;
if (i < 0) return 0;
return 1;
}
/*
*
*/
static char *
str_dup(char *s)
{
char *s1;
int i;
i = strlen(s) + 1;
s1 = malloc(i);
strncpy(s1, s, i);
return s1;
}
static char *
str_slash(char *s)
{
#ifdef __WIN32__
int i, l;
l = strlen(s);
for (i = 0; i < l; i++)
if (s[i] == '/') s[i] = '\\';
#endif
return s;
}
#endif //IIGS
/* eof */

258
src/devtools.c Normal file
View file

@ -0,0 +1,258 @@
/*
* xrick/src/scr_devtools.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "config.h"
#ifdef IIGS
#pragma noroot
#endif
#ifdef ENABLE_DEVTOOLS
#include "system.h"
#include "game.h"
#include "control.h"
#include "screens.h"
#include "draw.h"
#include "sprites.h"
#include "maps.h"
/*
* DevTools
*/
U8
devtools_run(void)
{
static U8 seq = 0;
static U8 pos = 0;
static U8 pos2 = 0;
U8 i, j, k, l;
U8 s[128];
if (seq == 0) {
sysvid_clear();
game_rects = &draw_SCREENRECT;
#ifdef GFXPC
draw_filter = 0xffff;
#endif
seq = 1;
}
switch (seq) {
case 1: /* draw tiles */
sysvid_clear();
draw_tilesBank = 0;
sprintf(s, "TILES@BANK@%d\376", pos);
draw_setfb(4, 4);
draw_tilesListImm(s);
k = 0;
for (i = 0; i < 0x10; i++) {
draw_setfb(80 + i * 0x0a, 14);
draw_tile((i<10?0x30:'A'-10) + i);
draw_setfb(64, 30 + i * 0x0a);
draw_tile((i<10?0x30:'A'-10) + i);
}
#ifdef GFXGS
draw_tilesBank = pos << 8;
#else
draw_tilesBank = pos;
#endif
for (i = 0; i < 0x10; i++)
for (j = 0; j < 0x10; j++) {
draw_setfb(80 + j * 0x0a, 30 + i * 0x0a);
draw_tile(k++);
}
seq = 10;
break;
case 10: /* wait for key pressed */
if (control_status & CONTROL_FIRE)
seq = 98;
if (control_status & CONTROL_UP)
seq = 12;
if (control_status & CONTROL_DOWN)
seq = 13;
if (control_status & CONTROL_RIGHT)
seq = 11;
break;
case 11: /* wait for key released */
if (!(control_status & CONTROL_RIGHT)) {
pos = 0;
seq = 21;
}
break;
case 12: /* wait for key released */
if (!(control_status & CONTROL_UP)) {
if (pos < 4) pos++;
seq = 1;
}
break;
case 13: /* wait for key released */
if (!(control_status & CONTROL_DOWN)) {
if (pos > 0) pos--;
seq = 1;
}
break;
case 21: /* draw sprites */
sysvid_clear();
draw_tilesBank = 0;
sprintf(s, "SPRITES\376");
draw_setfb(4, 4);
draw_tilesListImm(s);
for (i = 0; i < 8; i++) {
draw_setfb(0x08 + 0x20 + i * 0x20, 0x30 - 26);
draw_tile((i<10?0x30:'A'-10) + i);
draw_setfb(0x08 + 0x20 + i * 0x20, 0x30 - 16);
draw_tile((i+8<10?0x30:'A'-10) + i+8);
}
for (i = 0; i < 4; i++) {
k = pos + i * 8;
draw_setfb(0x20 - 16, 0x08 + 0x30 + i * 0x20);
j = k%16;
k /= 16;
draw_tile((j<10?0x30:'A'-10) + j);
draw_setfb(0x20 - 26, 0x08 + 0x30 + i * 0x20);
j = k%16;
draw_tile((j<10?0x30:'A'-10) + j);
}
k = pos;
for (i = 0; i < 4; i++)
for (j = 0; j < 8; j++) {
draw_sprite(k++, 0x20 + j * 0x20, 0x30 + i * 0x20);
}
seq = 30;
break;
case 30: /* wait for key pressed */
if (control_status & CONTROL_FIRE)
seq = 98;
if (control_status & CONTROL_UP)
seq = 32;
if (control_status & CONTROL_DOWN)
seq = 33;
if (control_status & CONTROL_LEFT)
seq = 31;
if (control_status & CONTROL_RIGHT)
seq = 40;
break;
case 31: /* wait for key released */
if (!(control_status & CONTROL_LEFT)) {
pos = 0;
seq = 1;
}
break;
case 32: /* wait for key released */
if (!(control_status & CONTROL_UP)) {
if (pos < SPRITES_NBR_SPRITES - 32) pos += 32;
seq = 21;
}
break;
case 33: /* wait for key released */
if (!(control_status & CONTROL_DOWN)) {
if (pos > 0) pos -= 32;
seq = 21;
}
break;
case 40:
sysvid_clear();
#ifdef GFXPC
if (pos2 == 0) pos2 = 2;
#endif
#ifdef GFXST
if (pos2 == 0) pos2 = 1;
#endif
sprintf(s, "BLOCKS@%#04X@TO@%#04X@WITH@BANK@%d\376",
pos, pos + 4*8-1, pos2);
draw_setfb(4, 4);
draw_tilesBank = 0;
draw_tilesListImm(s);
#ifdef GFXGS
draw_tilesBank = pos2<<8;
#else
draw_tilesBank = pos2;
#endif
for (l = 0; l < 8; l++)
for (k = 0; k < 4; k++)
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++) {
draw_setfb(20 + j * 8 + l * 36, 30 + i * 8 + k * 36);
draw_tile(map_blocks[pos + l + k * 8][i * 4 + j]);
}
seq = 41;
break;
case 41:
if (control_status & CONTROL_FIRE)
seq = 98;
if (control_status & CONTROL_UP)
seq = 42;
if (control_status & CONTROL_DOWN)
seq = 43;
if (control_status & CONTROL_LEFT)
seq = 44;
if (control_status & CONTROL_PAUSE)
seq = 45;
break;
case 42:
if (!(control_status & CONTROL_UP)) {
if (pos < MAP_NBR_BLOCKS - 8*4) pos += 8 * 4;
seq = 40;
}
break;
case 43:
if (!(control_status & CONTROL_DOWN)) {
if (pos > 0) pos -= 8 * 4;
seq = 40;
}
break;
case 44:
if (!(control_status & CONTROL_LEFT)) {
pos = 0;
pos2 = 0;
seq = 21;
}
break;
case 45:
if (!(control_status & CONTROL_PAUSE)) {
#ifdef GFXPC
if (pos2 == 2) pos2 = 3;
else pos2 = 2;
#endif
#ifdef GFXST
if (pos2 == 1) pos2 = 2;
else pos2 = 1;
#endif
seq = 40;
}
break;
case 98: /* wait for key released */
if (!(control_status & CONTROL_FIRE))
seq = 99;
break;
}
if (control_status & CONTROL_EXIT) /* check for exit request */
return SCREEN_EXIT;
if (seq == 99) { /* we're done */
sysvid_clear();
seq = 0;
return SCREEN_DONE;
}
return SCREEN_RUNNING;
}
#endif /* ENABLE_DEVTOOLS */
/* eof */

791
src/draw.c Normal file
View file

@ -0,0 +1,791 @@
/*
* xrick/src/draw.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
/*
* NOTES
*
* This is the only file which accesses the video. Anything calling d_*
* function should be video-independant.
*
* draw.c draws into a 320x200 or 0x0140x0xc8 8-bits depth frame buffer,
* using the CGA 2 bits color codes. It is up to the video to figure out
* how to display the frame buffer. Whatever draw.c does, does not show
* until the screen is explicitely refreshed.
*
* The "screen" is the whole 0x0140 by 0x00c8 screen, coordinates go from
* 0x0000,0x0000 to 0x013f,0x00c7.
*
* The "map" is a 0x0100 by 0x0140 rectangle that represents the active
* game area.
*
* Relative to the screen, the "map" is located at 0x0020,-0x0040 : the
* "map" is composed of two hidden 0x0100 by 0x0040 rectangles (one at the
* top and one at the bottom) and one visible 0x0100 by 0x00c0 rectangle (in
* the middle).
*
* The "map screen" is the visible rectangle ; it is a 0x0100 by 0xc0
* rectangle located at 0x0020,0x00.
*
* Coordinates can be relative to the screen, the map, or the map screen.
*
* Coordinates can be expressed in pixels. When relative to the map or the
* map screen, they can also be expressed in tiles, the map being composed
* of rows of 0x20 tiles of 0x08 by 0x08 pixels.
*/
#include "system.h"
#include "game.h"
#include "draw.h"
#include "sysvid.h"
#include "sprites.h"
#include "tiles.h"
#include "maps.h"
#include "rects.h"
#include "img.h"
#ifdef IIGS
#pragma noroot
segment "game";
#endif
/*
* counters positions (pixels, screen)
*/
#ifdef GFXPC
#define DRAW_STATUS_SCORE_X 0x28
#define DRAW_STATUS_LIVES_X 0xE8
#define DRAW_STATUS_Y 0x08
#endif
#define DRAW_STATUS_BULLETS_X 0x68
#define DRAW_STATUS_BOMBS_X 0xA8
#ifdef GFXST
#define DRAW_STATUS_SCORE_X 0x20
#define DRAW_STATUS_LIVES_X 0xF0
#define DRAW_STATUS_Y 0
#endif
#ifdef GFXGS
#define DRAW_STATUS_SCORE_X 0x20
#define DRAW_STATUS_LIVES_X 0xF0
#define DRAW_STATUS_Y 0
#endif
#ifdef GFXF256
#define DRAW_STATUS_SCORE_X 0x20
#define DRAW_STATUS_LIVES_X 0xF0
#define DRAW_STATUS_Y 0
#endif
/*
* public vars
*/
U8 *draw_tllst; /* pointer to tiles list */
#ifdef GFXPC
U16 draw_filter; /* CGA colors filter */
#endif
U16 draw_tilesBank; /* tile number offset */
rect_t draw_STATUSRECT = {
DRAW_STATUS_SCORE_X, DRAW_STATUS_Y,
DRAW_STATUS_LIVES_X + 6 * 8 - DRAW_STATUS_SCORE_X, 8,
NULL
};
rect_t draw_SCREENRECT = { 0, 0, 320, SYSVID_HEIGHT, NULL };
/*
* private vars
*/
U8 *fb; /* frame buffer pointer */
/*
* Set the frame buffer pointer
*
* x, y: position (pixels, screen)
*/
void
draw_setfb(U16 x, U16 y)
{
#ifdef IIGS
fb = sysvid_fb + (x>>1) + (y * SYSVID_WIDTH);
#else
fb = sysvid_fb + x + y * SYSVID_WIDTH;
#endif
}
/*
* Clip to map screen
*
* x, y: position (pixels, map) CHANGED clipped
* width, height: dimension CHANGED clipped
* return: TRUE if fully clipped, FALSE if still (at least partly) visible
*/
U8
draw_clipms(S16 *x, S16 *y, U16 *width, U16 *height)
{
if (*x < 0) {
if (*x + ((S16)*width) < 0)
return TRUE;
else {
*width += *x;
*x = 0;
}
}
else {
if (*x > 0x0100)
return TRUE;
else if (*x + *width > 0x0100) {
*width = 0x0100 - *x;
}
}
if (*y < DRAW_XYMAP_SCRTOP) {
if ((*y + ((S16)*height)) < DRAW_XYMAP_SCRTOP)
return TRUE;
else {
*height += *y - DRAW_XYMAP_SCRTOP;
*y = DRAW_XYMAP_SCRTOP;
}
}
else {
if (*y >= DRAW_XYMAP_HBTOP)
return TRUE;
else if (*y + ((S16)*height) > DRAW_XYMAP_HBTOP)
*height = DRAW_XYMAP_HBTOP - *y;
}
return FALSE;
}
/*
* Draw a list of tiles onto the frame buffer
* start at position indicated by fb ; at the end of each (sub)list,
* perform a "carriage return + line feed" i.e. go back to the initial
* position then go down one tile row (8 pixels)
*
* ASM 1e33
* fb: CHANGED (see above)
* draw_tllst: CHANGED points to the element following 0xfe/0xff end code
*/
void
draw_tilesList(void)
{
U8 *t;
t = fb;
while (draw_tilesSubList() != 0xFE) { /* draw sub-list */
t += 8 * SYSVID_WIDTH; /* go down one tile i.e. 8 lines */
fb = t;
}
}
/*
* Draw a list of tiles onto the frame buffer -- same as draw_tilesList,
* but accept an immediate string as parameter. Note that the string needs
* to be properly terminated with 0xfe (\376) and 0xff (\377) chars.
*/
void
draw_tilesListImm(U8 *list)
{
draw_tllst = list;
draw_tilesList();
}
/*
* Draw a sub-list of tiles onto the frame buffer
* start at position indicated by fb ; leave fb pointing to the next
* tile to the right of the last tile drawn
*
* ASM 1e41
* fpb: CHANGED (see above)
* draw_tllst: CHANGED points to the element following 0xfe/0xff end code
* returns: end code (0xfe : end of list ; 0xff : end of sub-list)
*/
#ifndef IIGS
U8
draw_tilesSubList()
{
U8 i;
i = *(draw_tllst++);
while (i != 0xFF && i != 0xFE) { /* while not end */
draw_tile(i); /* draw tile */
i = *(draw_tllst++);
}
return i;
}
#endif
/*
* Draw a tile
* at position indicated by fb ; leave fb pointing to the next tile
* to the right of the tile drawn
*
* ASM 1e6c
* tlnbr: tile number
* draw_filter: CGA colors filter
* fb: CHANGED (see above)
*/
/*#if !(defined(IIGS) || defined(F256))*/
#ifndef IIGS
void
draw_tile(U8 tileNumber)
{
#ifdef GFXF256
/* DO SOMETHING TODO */
#else
U8 i, k, *f;
#ifdef GFXPC
U16 x;
#endif
#ifdef GFXST
U32 x;
#endif
f = fb; /* frame buffer */
for (i = 0; i < 8; i++) { /* for all 8 pixel lines */
#ifdef GFXPC
x = tiles_data[draw_tilesBank][tileNumber][i] & draw_filter;
/*
* tiles / perform the transformation from CGA 2 bits
* per pixel to frame buffer 8 bits per pixels
*/
for (k = 8; k--; x >>= 2)
f[k] = x & 3;
f += SYSVID_WIDTH; /* next line */
#endif
#ifdef GFXST
x = tiles_data[draw_tilesBank][tileNumber][i];
/*
* tiles / perform the transformation from ST 4 bits
* per pixel to frame buffer 8 bits per pixels
*/
for (k = 8; k--; x >>= 4)
f[k] = x & 0x0F;
f += SYSVID_WIDTH; /* next line */
#endif
}
fb += 8; /* next tile */
#endif
}
#endif
/*
* Draw a sprite
*
* ASM 1a09
* nbr: sprite number
* x, y: sprite position (pixels, screen)
* fb: CHANGED
*/
#ifdef GFXPC
void
draw_sprite(U8 nbr, U16 x, U16 y)
{
U8 i, j, k, *f;
U16 xm = 0, xp = 0;
draw_setfb(x, y);
for (i = 0; i < 4; i++) { /* for each tile column */
f = fb; /* frame buffer */
for (j = 0; j < 0x15; j++) { /* for each pixel row */
xm = sprites_data[nbr][i][j].mask; /* mask */
xp = sprites_data[nbr][i][j].pict; /* picture */
/*
* sprites / perform the transformation from CGA 2 bits
* per pixel to frame buffer 8 bits per pixels
*/
for (k = 8; k--; xm >>= 2, xp >>= 2)
f[k] = (f[k] & (xm & 3)) | (xp & 3);
f += SYSVID_WIDTH;
}
fb += 8;
}
}
#endif
#ifdef GFXF256
void
draw_sprite(U8 number, U16 x, U16 y)
{
}
void
draw_sprite2(U8 number, U16 x, U16 y, U8 front)
{
}
#endif
#ifdef GFXGS
void
draw_sprite(U8 number, U16 x, U16 y)
{
int frameNo = number;
if (y >= (200-8))
return;
if (x >= 320)
return;
frameNo<<=1;
if (x & 1)
frameNo|=1;
draw_setfb(x,y);
DrawSprite((int)fb, frameNo);
}
void
draw_sprite2(U8 number, U16 x, U16 y, U8 front)
{
S16 x0, y0; /* clipped x, y */
U16 w, h; /* width, height */
int frameNo = number;
x0 = x;
y0 = y;
w = 0x20;
h = 0x15;
if (draw_clipms(&x0, &y0, &w, &h)) /* return if not visible */
return;
frameNo<<=1;
x -= (DRAW_XYMAP_SCRLEFT-1);
y -= (DRAW_XYMAP_SCRTOP-8);
if (x & 1)
frameNo|=1;
if (x >= 320)
{
return;
}
if (y >= (200 - 8))
return;
draw_setfb(x, y);
DrawSprite((int)fb, frameNo);
}
#endif
/*
* Draw a sprite
*
* foobar
*/
#ifdef GFXST
void
draw_sprite(U8 number, U16 x, U16 y)
{
U8 i, j, k, *f;
U16 g;
U32 d;
draw_setfb(x, y);
g = 0;
for (i = 0; i < 0x15; i++) { /* rows */
f = fb;
for (j = 0; j < 4; j++) { /* cols */
d = sprites_data[number][g++];
for (k = 8; k--; d >>= 4)
if (d & 0x0F) f[k] = (f[k] & 0xF0) | (d & 0x0F);
f += 8;
}
fb += SYSVID_WIDTH;
}
}
#endif
/*
* Draw a sprite
*
* NOTE re-using original ST graphics format
*/
#ifdef GFXST
void
draw_sprite2(U8 number, U16 x, U16 y, U8 front)
{
U32 d = 0; /* sprite data */
S16 x0, y0; /* clipped x, y */
U16 w, h; /* width, height */
S16 g, /* sprite data offset*/
r, c, /* row, column */
i, /* frame buffer shifter */
im; /* tile flag shifter */
U8 flg; /* tile flag */
x0 = x;
y0 = y;
w = 0x20;
h = 0x15;
if (draw_clipms(&x0, &y0, &w, &h)) /* return if not visible */
return;
g = 0;
draw_setfb(x0 - DRAW_XYMAP_SCRLEFT, y0 - DRAW_XYMAP_SCRTOP + 8);
for (r = 0; r < 0x15; r++) {
if (r >= h || y + r < y0) continue;
i = 0x1f;
im = x - (x & 0xfff8);
flg = map_eflg[map_map[(y + r) >> 3][(x + 0x1f)>> 3]];
#ifdef ENABLE_CHEATS
#define LOOP(N, C0, C1) \
d = sprites_data[number][g + N]; \
for (c = C0; c >= C1; c--, i--, d >>= 4, im--) { \
if (im == 0) { \
flg = map_eflg[map_map[(y + r) >> 3][(x + c) >> 3]]; \
im = 8; \
} \
if (c >= w || x + c < x0) continue; \
if (!front && !game_cheat3 && (flg & MAP_EFLG_FGND)) continue; \
if (d & 0x0F) fb[i] = (fb[i] & 0xF0) | (d & 0x0F); \
if (game_cheat3) fb[i] |= 0x10; \
}
#else
#define LOOP(N, C0, C1) \
d = sprites_data[number][g + N]; \
for (c = C0; c >= C1; c--, i--, d >>= 4, im--) { \
if (im == 0) { \
flg = map_eflg[map_map[(y + r) >> 3][(x + c) >> 3]]; \
im = 8; \
} \
if (!front && (flg & MAP_EFLG_FGND)) continue; \
if (c >= w || x + c < x0) continue; \
if (d & 0x0F) fb[i] = (fb[i] & 0xF0) | (d & 0x0F); \
}
#endif
LOOP(3, 0x1f, 0x18);
LOOP(2, 0x17, 0x10);
LOOP(1, 0x0f, 0x08);
LOOP(0, 0x07, 0x00);
#undef LOOP
fb += SYSVID_WIDTH;
g += 4;
}
}
#endif
/*
* Draw a sprite
* align to tile column, determine plane automatically, and clip
*
* nbr: sprite number
* x, y: sprite position (pixels, map).
* fb: CHANGED
*/
#ifdef GFXPC
void
draw_sprite2(U8 number, U16 x, U16 y, U8 front)
{
U8 k, *f, c, r, dx;
U16 cmax, rmax;
U16 xm = 0, xp = 0;
S16 xmap, ymap;
/* align to tile column, prepare map coordinate and clip */
xmap = x & 0xFFF8;
ymap = y;
cmax = 0x20; /* width, 4 tile columns, 8 pixels each */
rmax = 0x15; /* height, 15 pixels */
dx = (x - xmap) * 2;
if (draw_clipms(&xmap, &ymap, &cmax, &rmax)) /* return if not visible */
return;
/* get back to screen */
draw_setfb(xmap - DRAW_XYMAP_SCRLEFT, ymap - DRAW_XYMAP_SCRTOP);
xmap >>= 3;
cmax >>= 3;
/* draw */
for (c = 0; c < cmax; c++) { /* for each tile column */
f = fb;
for (r = 0; r < rmax; r++) { /* for each pixel row */
/* check that tile is not hidden behind foreground */
#ifdef ENABLE_CHEATS
if (front || game_cheat3 ||
!(map_eflg[map_map[(ymap + r) >> 3][xmap + c]] & MAP_EFLG_FGND)) {
#else
if (front ||
!(map_eflg[map_map[(ymap + r) >> 3][xmap + c]] & MAP_EFLG_FGND)) {
#endif
xp = xm = 0;
if (c > 0) {
xm |= sprites_data[number][c - 1][r].mask << (16 - dx);
xp |= sprites_data[number][c - 1][r].pict << (16 - dx);
}
else
xm |= 0xFFFF << (16 - dx);
if (c < cmax) {
xm |= sprites_data[number][c][r].mask >> dx;
xp |= sprites_data[number][c][r].pict >> dx;
}
else
xm |= 0xFFFF >> dx;
/*
* sprites / perform the transformation from CGA 2 bits
* per pixel to frame buffer 8 bits per pixels
*/
for (k = 8; k--; xm >>= 2, xp >>= 2) {
f[k] = ((f[k] & (xm & 3)) | (xp & 3));
#ifdef ENABLE_CHEATS
if (game_cheat3) f[k] |= 4;
#endif
}
}
f += SYSVID_WIDTH;
}
fb += 8;
}
}
#endif
/*
* Redraw the map behind a sprite
* align to tile column and row, and clip
*
* x, y: sprite position (pixels, map).
*/
void
draw_spriteBackground(U16 x, U16 y)
{
U8 r, c;
U16 rmax, cmax;
S16 xmap, ymap;
U16 xs, ys;
/* aligne to column and row, prepare map coordinate, and clip */
xmap = x & 0xFFF8;
ymap = y & 0xFFF8;
cmax = (x - xmap == 0 ? 0x20 : 0x28); /* width, 4 tl cols, 8 pix each */
rmax = (y & 0x04) ? 0x20 : 0x18; /* height, 3 or 4 tile rows */
if (draw_clipms(&xmap, &ymap, &cmax, &rmax)) /* don't draw if fully clipped */
return;
/* get back to screen */
xs = xmap - DRAW_XYMAP_SCRLEFT;
ys = ymap - DRAW_XYMAP_SCRTOP;
xmap >>= 3;
ymap >>= 3;
cmax >>= 3;
rmax >>= 3;
/* draw */
for (r = 0; r < rmax; r++) { /* for each row */
#ifdef GFXPC
draw_setfb(xs, ys + r * 8);
#endif
#if defined(GFXST) || defined(GFXGS) || defined(GFXF256)
draw_setfb(xs, 8 + ys + r * 8);
#endif
for (c = 0; c < cmax; c++) { /* for each column */
draw_tile(map_map[ymap + r][xmap + c]);
}
}
}
/*
* Draw entire map screen background tiles onto frame buffer.
*
* ASM 0af5, 0a54
*/
/*#if !(defined(GFXGS)||defined(GFXF256))*/
#ifndef GFXGS
void
draw_map(void)
{
#ifdef F256
#else
U8 i, j;
draw_tilesBank = map_tilesBank;
for (i = 0; i < 0x18; i++) { /* 0x18 rows */
#ifdef GFXPC
draw_setfb(0x20, (i * 8));
#endif
#if defined(GFXST) || defined(GFXGS)
draw_setfb(0x20, 8 + (i * 8));
#endif
for (j = 0; j < 0x20; j++) /* 0x20 tiles per row */
draw_tile(map_map[i + 8][j]);
}
#endif /*F256*/
}
#endif /*GFXGS*/
/*
* Draw status indicators
*
* ASM 0309
*/
void
draw_drawStatus(void)
{
S8 i;
U32 sv;
static U8 s[7] = {0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0xfe};
draw_tilesBank = 0;
for (i = 5, sv = game_score; i >= 0; i--) {
s[i] = 0x30 + (U8)(sv % 10);
sv /= 10;
}
draw_tllst = s;
draw_setfb(DRAW_STATUS_SCORE_X, DRAW_STATUS_Y);
draw_tilesList();
draw_setfb(DRAW_STATUS_BULLETS_X, DRAW_STATUS_Y);
for (i = 0; i < game_bullets; i++)
draw_tile(TILES_BULLET);
draw_setfb(DRAW_STATUS_BOMBS_X, DRAW_STATUS_Y);
for (i = 0; i < game_bombs; i++)
draw_tile(TILES_BOMB);
draw_setfb(DRAW_STATUS_LIVES_X, DRAW_STATUS_Y);
for (i = 0; i < game_lives; i++)
draw_tile(TILES_RICK);
}
/*
* Draw info indicators
*/
#ifdef ENABLE_CHEATS
void
draw_infos(void)
{
draw_tilesBank = 0;
#ifdef GFXPC
draw_filter = 0xffff;
#endif
draw_setfb(0x00, DRAW_STATUS_Y);
draw_tile(game_cheat1 ? 'T' : '@');
draw_setfb(0x08, DRAW_STATUS_Y);
draw_tile(game_cheat2 ? 'N' : '@');
draw_setfb(0x10, DRAW_STATUS_Y);
draw_tile(game_cheat3 ? 'V' : '@');
}
#endif
/*
* Clear status indicators
*/
void
draw_clearStatus(void)
{
U8 i;
#ifdef GFXPC
draw_tilesBank = map_tilesBank;
#endif
#if defined(GFXST) || defined(GFXGS)
draw_tilesBank = 0;
#endif
draw_setfb(DRAW_STATUS_SCORE_X, DRAW_STATUS_Y);
for (i = 0; i < DRAW_STATUS_LIVES_X/8 + 6 - DRAW_STATUS_SCORE_X/8; i++) {
#ifdef GFXPC
draw_tile(map_map[MAP_ROW_SCRTOP + (DRAW_STATUS_Y / 8)][i]);
#endif
#if defined(GFXST) || defined(GFXGS)
draw_tile('@');
#endif
}
}
/*
* Draw a picture
*/
#ifdef GFXST
void
draw_pic(U16 x, U16 y, U16 w, U16 h, U32 *pic)
{
U8 *f;
U16 i, j, k, pp;
U32 v;
draw_setfb(x, y);
pp = 0;
for (i = 0; i < h; i++) { /* rows */
f = fb;
for (j = 0; j < w; j += 8) { /* cols */
v = pic[pp++];
for (k = 8; k--; v >>=4)
f[k] = v & 0x0F;
f += 8;
}
fb += SYSVID_WIDTH;
}
}
#endif
/*
* Draw a bitmap
*/
void
draw_img(img_t *i)
{
#ifdef IIGS
LZ4_Unpack(sysvid_fb, (char*)i);
#elif defined(F256)
#else
U16 k;
draw_setfb(0, 0);
if (i->ncolors > 0)
sysvid_setPalette(i->colors, i->ncolors);
for (k = 0; k < SYSVID_WIDTH * SYSVID_HEIGHT; k++)
fb[k] = i->pixels[k];
#endif
}
/* eof */

164
src/e_bomb.c Normal file
View file

@ -0,0 +1,164 @@
/*
* xrick/src/e_bomb.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#include "ents.h"
#include "e_bomb.h"
#include "e_rick.h"
#ifdef IIGS
#pragma noroot
segment "e";
#endif
/*
* public vars (for performance reasons)
*/
U8 e_bomb_lethal;
U8 e_bomb_xc;
U16 e_bomb_yc;
/*
* private vars
*/
U8 e_bomb_ticker;
/*
* Bomb hit test
*
* ASM 11CD
* returns: TRUE/hit, FALSE/not
*/
U8 e_bomb_hit(ent_t *pEnt)
{
if (pEnt->x > (E_BOMB_ENT.x >= 0xE0 ? 0xFF : E_BOMB_ENT.x + 0x20))
return FALSE;
if (pEnt->x + pEnt->w < (E_BOMB_ENT.x > 0x04 ? E_BOMB_ENT.x - 0x04 : 0))
return FALSE;
if (pEnt->y > (E_BOMB_ENT.y + 0x1D))
return FALSE;
if (pEnt->y + pEnt->h < (E_BOMB_ENT.y > 0x0004 ? E_BOMB_ENT.y - 0x0004 : 0))
return FALSE;
return TRUE;
}
/*
* Initialize bomb
*/
void e_bomb_init(U16 x, U16 y)
{
E_BOMB_ENT.n = 0x03;
E_BOMB_ENT.x = x;
E_BOMB_ENT.y = y;
e_bomb_ticker = E_BOMB_TICKER;
e_bomb_lethal = FALSE;
/*
* Atari ST dynamite sprites are not centered the
* way IBM PC sprites were ... need to adjust things a little bit
*/
#if defined(GFXST) || defined(GFXGS)
E_BOMB_ENT.x += 4;
E_BOMB_ENT.y += 5;
#endif
}
/*
* Entity action
*
* ASM 18CA
*/
void
e_bomb_action(UNUSED(ent_t* pEnt))
{
/* tick */
e_bomb_ticker--;
if (e_bomb_ticker == 0)
{
/*
* end: deactivate
*/
E_BOMB_ENT.n = 0;
e_bomb_lethal = FALSE;
}
else if (e_bomb_ticker >= 0x0A)
{
/*
* ticking
*/
#ifdef ENABLE_SOUND
if ((e_bomb_ticker & 0x03) == 0x02)
syssnd_play(WAV_BOMBSHHT, 1);
#endif
#if defined(GFXST)||defined(GFXGS)
/* ST bomb sprites sequence is longer */
if (e_bomb_ticker < 40)
E_BOMB_ENT.sprite = 0x99 + 19 - (e_bomb_ticker >> 1);
else
#endif
E_BOMB_ENT.sprite = (e_bomb_ticker & 0x01) ? 0x23 : 0x22;
}
else if (e_bomb_ticker == 0x09)
{
if (E_RICK_STTST (E_RICK_STZOMBIE))
return;
/*
* explode
*/
#ifdef ENABLE_SOUND
syssnd_play(WAV_EXPLODE, 1);
#endif
#ifdef GFXPC
E_BOMB_ENT.sprite = 0x24 + 4 - (e_bomb_ticker >> 1);
#endif
#if defined(GFXST)||defined(GFXGS)
/* See above: fixing alignment */
E_BOMB_ENT.x -= 4;
E_BOMB_ENT.y -= 5;
E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1);
#endif
e_bomb_xc = E_BOMB_ENT.x + 0x0C;
e_bomb_yc = E_BOMB_ENT.y + 0x000A;
e_bomb_lethal = TRUE;
if (e_bomb_hit(&ent_ents[E_RICK_NO]))
e_rick_gozombie();
}
else
{
if (E_RICK_STTST (E_RICK_STZOMBIE))
return;
/*
* exploding
*/
#ifdef GFXPC
E_BOMB_ENT.sprite = 0x24 + 4 - (e_bomb_ticker >> 1);
#endif
#if defined(GFXST)||defined(GFXGS)
E_BOMB_ENT.sprite = 0xa8 + 4 - (e_bomb_ticker >> 1);
#endif
/* exploding, hence lethal */
if (e_bomb_hit(&ent_ents[E_RICK_NO]))
e_rick_gozombie();
}
}
/* eof */

65
src/e_bonus.c Normal file
View file

@ -0,0 +1,65 @@
/*
* xrick/src/e_bonus.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#include "ents.h"
#include "e_bonus.h"
#include "e_rick.h"
#include "maps.h"
#ifdef IIGS
#pragma noroot
segment "e";
#endif
/*
* Entity action
*
* ASM 242C
*/
void
e_bonus_action(ent_t *pEnt)
{
#define seq c1
if (pEnt->seq == 0) {
if (e_rick_boxtest(pEnt)) {
game_score += 500;
game_status_dirty = 1;
#ifdef ENABLE_SOUND
syssnd_play(WAV_BONUS, 1);
#endif
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
pEnt->seq = 1;
pEnt->sprite = 0xad;
pEnt->front = TRUE;
pEnt->y -= 0x08;
}
}
else if (pEnt->seq > 0 && pEnt->seq < 10) {
pEnt->seq++;
pEnt->y -= 2;
}
else {
pEnt->n = 0;
}
}
/* eof */

117
src/e_box.c Normal file
View file

@ -0,0 +1,117 @@
/*
* xrick/src/e_box.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#include "ents.h"
#include "e_box.h"
#include "e_bullet.h"
#include "e_bomb.h"
#include "e_rick.h"
#include "maps.h"
#include "util.h"
#ifdef IIGS
#pragma noroot
segment "e";
#endif
/*
* FIXME this is because the same structure is used
* for all entities. Need to replace this w/ an inheritance
* solution.
*/
#define cnt c1
/*
* Constants
*/
#define SEQ_INIT 0x0A
/*
* Prototypes
*/
static void explode(ent_t*);
/*
* Entity action
*
* ASM 245A
*/
void
e_box_action(ent_t* pEnt)
{
static U8 sp[] = {0x24, 0x25, 0x26, 0x27, 0x28}; /* explosion sprites sequence */
if (pEnt->n & ENT_LETHAL) {
/*
* box is lethal i.e. exploding
* play sprites sequence then stop
*/
pEnt->sprite = sp[pEnt->cnt >> 1];
if (--pEnt->cnt == 0) {
pEnt->n = 0;
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
}
} else {
/*
* not lethal: check to see if triggered
*/
if (e_rick_boxtest(pEnt)) {
/* rick: collect bombs or bullets and stop */
#ifdef ENABLE_SOUND
syssnd_play(WAV_BOX, 1);
#endif
if (pEnt->n == 0x10)
game_bombs = GAME_BOMBS_INIT;
else /* 0x11 */
game_bullets = GAME_BULLETS_INIT;
game_status_dirty = 1;
pEnt->n = 0;
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
}
else if (E_RICK_STTST(E_RICK_STSTOP) &&
u_fboxtest(pEnt, e_rick_stop_x, e_rick_stop_y)) {
/* rick's stick: explode */
explode(pEnt);
}
else if (E_BULLET_ENT.n && u_fboxtest(pEnt, e_bullet_xc, e_bullet_yc)) {
/* bullet: explode (and stop bullet) */
E_BULLET_ENT.n = 0;
explode(pEnt);
}
else if (e_bomb_lethal && e_bomb_hit(pEnt)) {
/* bomb: explode */
explode(pEnt);
}
}
}
/*
* Explode when
*/
static void explode(ent_t* pEnt)
{
pEnt->cnt = SEQ_INIT;
pEnt->n |= ENT_LETHAL;
#ifdef ENABLE_SOUND
syssnd_play(WAV_EXPLODE, 1);
#endif
}
/* eof */

85
src/e_bullet.c Normal file
View file

@ -0,0 +1,85 @@
/*
* xrick/src/e_bullet.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#include "ents.h"
#include "e_bullet.h"
#include "maps.h"
#ifdef IIGS
#pragma noroot
segment "e";
#endif
/*
* public vars (for performance reasons)
*/
S16 e_bullet_offsx;
S16 e_bullet_xc, e_bullet_yc;
/*
* Initialize bullet
*/
void
e_bullet_init(U16 x, U16 y)
{
E_BULLET_ENT.n = 0x02;
E_BULLET_ENT.x = x;
E_BULLET_ENT.y = y + 0x0006;
if (game_dir == LEFT) {
e_bullet_offsx = -0x08;
E_BULLET_ENT.sprite = 0x21;
}
else {
e_bullet_offsx = 0x08;
E_BULLET_ENT.sprite = 0x20;
}
#ifdef ENABLE_SOUND
syssnd_play(WAV_BULLET, 1);
#endif
}
/*
* Entity action
*
* ASM 1883, 0F97
*/
void
e_bullet_action(UNUSED(ent_t* pEnt))
{
/* move bullet */
E_BULLET_ENT.x += e_bullet_offsx;
if (E_BULLET_ENT.x <= -0x10 || E_BULLET_ENT.x > 0xe8) {
/* out: deactivate */
E_BULLET_ENT.n = 0;
}
else {
/* update bullet center coordinates */
e_bullet_xc = E_BULLET_ENT.x + 0x0c;
e_bullet_yc = E_BULLET_ENT.y + 0x05;
if (map_eflg[map_map[e_bullet_yc >> 3][e_bullet_xc >> 3]] &
MAP_EFLG_SOLID) {
/* hit something: deactivate */
E_BULLET_ENT.n = 0;
}
}
}
/* eof */

581
src/e_rick.c Normal file
View file

@ -0,0 +1,581 @@
/*
* xrick/src/e_rick.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "config.h"
#include "game.h"
#include "ents.h"
#include "e_rick.h"
#include "e_bullet.h"
#include "e_bomb.h"
#include "control.h"
#include "maps.h"
#include "util.h"
#ifdef IIGS
#pragma noroot
segment "e";
#endif
/*
* public vars
*/
S16 e_rick_stop_x = 0;
S16 e_rick_stop_y = 0;
U8 e_rick_state = 0;
/*
* local vars
*/
static U8 scrawl;
static U8 trigger = FALSE;
static S16 offsx;
static U8 ylow;
static S16 offsy;
static U8 seq;
static U8 save_crawl;
static U16 save_x, save_y;
/*
* Box test
*
* ASM 113E (based on)
*
* e: entity to test against (corresponds to SI in asm code -- here DI
* is assumed to point to rick).
* ret: TRUE/intersect, FALSE/not.
*/
U8
e_rick_boxtest(ent_t* pEnt)
{
/*
* rick: x+0x05 to x+0x11, y+[0x08 if rick's crawling] to y+0x14
* entity: x to x+w, y to y+h
*/
if (E_RICK_ENT.x + 0x11 < pEnt->x ||
E_RICK_ENT.x + 0x05 > pEnt->x + pEnt->w ||
E_RICK_ENT.y + 0x14 < pEnt->y ||
E_RICK_ENT.y + (E_RICK_STTST(E_RICK_STCRAWL) ? 0x08 : 0x00) > pEnt->y + pEnt->h - 1)
return FALSE;
else
return TRUE;
}
/*
* Go zombie
*
* ASM 1851
*/
void
e_rick_gozombie(void)
{
#ifdef ENABLE_CHEATS
if (game_cheat2) return;
#endif
/* already zombie? */
if E_RICK_STTST(E_RICK_STZOMBIE) return;
#ifdef ENABLE_SOUND
syssnd_play(WAV_DIE, 1);
#endif
E_RICK_STSET(E_RICK_STZOMBIE);
offsy = -0x0400;
offsx = (E_RICK_ENT.x > 0x80 ? -3 : +3);
ylow = 0;
E_RICK_ENT.front = TRUE;
}
/*
* Action sub-function for e_rick when zombie
*
* ASM 17DC
*/
static void
e_rick_z_action(void)
{
U32 i;
/* sprite */
E_RICK_ENT.sprite = (E_RICK_ENT.x & 0x04) ? 0x1A : 0x19;
/* x */
E_RICK_ENT.x += offsx;
/* y */
i = (((S32)E_RICK_ENT.y) << 8) + ((S32)offsy) + ((U32)ylow);
E_RICK_ENT.y = i >> 8;
offsy += 0x80;
ylow = i;
/* dead when out of screen */
if (E_RICK_ENT.y < 0 || E_RICK_ENT.y > 0x0140)
E_RICK_STSET(E_RICK_STDEAD);
}
/*
* Action sub-function for e_rick.
*
* ASM 13BE
*/
void
e_rick_action2(void)
{
U8 env0, env1;
S16 x, y;
U32 i;
E_RICK_STRST(E_RICK_STSTOP|E_RICK_STSHOOT);
/* if zombie, run dedicated function and return */
if E_RICK_STTST(E_RICK_STZOMBIE) {
e_rick_z_action();
return;
}
/* climbing? */
if E_RICK_STTST(E_RICK_STCLIMB)
goto climbing;
/*
* NOT CLIMBING
*/
E_RICK_STRST(E_RICK_STJUMP);
/* calc y */
i = (((S32)E_RICK_ENT.y) << 8) + ((S32)offsy) + ((U32)ylow);
y = i >> 8;
/* test environment */
u_envtest(E_RICK_ENT.x, y, E_RICK_STTST(E_RICK_STCRAWL), &env0, &env1);
/* stand up, if possible */
if (E_RICK_STTST(E_RICK_STCRAWL) && !env0)
E_RICK_STRST(E_RICK_STCRAWL);
/* can move vertically? */
if (env1 & (offsy < 0 ?
MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD :
MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))
goto vert_not;
/*
* VERTICAL MOVE
*/
E_RICK_STSET(E_RICK_STJUMP);
/* killed? */
if (env1 & MAP_EFLG_LETHAL) {
e_rick_gozombie();
return;
}
/* save */
E_RICK_ENT.y = y;
ylow = i;
/* climb? */
if ((env1 & MAP_EFLG_CLIMB) &&
(control_status & (CONTROL_UP|CONTROL_DOWN))) {
offsy = 0x0100;
E_RICK_STSET(E_RICK_STCLIMB);
return;
}
/* fall */
offsy += 0x0080;
if (offsy > 0x0800) {
offsy = 0x0800;
ylow = 0;
}
/*
* HORIZONTAL MOVE
*/
horiz:
/* should move? */
if (!(control_status & (CONTROL_LEFT|CONTROL_RIGHT))) {
seq = 2; /* no: reset seq and return */
return;
}
if (control_status & CONTROL_LEFT) { /* move left */
x = E_RICK_ENT.x - 2;
game_dir = LEFT;
if (x < 0) { /* prev submap */
game_chsm = TRUE;
E_RICK_ENT.x = 0xe2;
return;
}
} else { /* move right */
x = E_RICK_ENT.x + 2;
game_dir = RIGHT;
if (x >= 0xe8) { /* next submap */
game_chsm = TRUE;
E_RICK_ENT.x = 0x04;
return;
}
}
/* still within this map: test environment */
u_envtest(x, E_RICK_ENT.y, E_RICK_STTST(E_RICK_STCRAWL), &env0, &env1);
/* save x-position if it is possible to move */
if (!(env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
E_RICK_ENT.x = x;
if (env1 & MAP_EFLG_LETHAL) e_rick_gozombie();
}
/* end */
return;
/*
* NO VERTICAL MOVE
*/
vert_not:
if (offsy < 0) {
/* not climbing + trying to go _up_ not possible -> hit the roof */
E_RICK_STSET(E_RICK_STJUMP); /* fall back to the ground */
E_RICK_ENT.y &= 0xF8;
offsy = 0;
ylow = 0;
goto horiz;
}
/* else: not climbing + trying to go _down_ not possible -> standing */
/* align to ground */
E_RICK_ENT.y &= 0xF8;
E_RICK_ENT.y |= 0x03;
ylow = 0;
/* standing on a super pad? */
if ((env1 & MAP_EFLG_SPAD) && offsy >= 0X0200) {
offsy = (control_status & CONTROL_UP) ? 0xf800 : 0x00fe - offsy;
#ifdef ENABLE_SOUND
syssnd_play(WAV_PAD, 1);
#endif
goto horiz;
}
offsy = 0x0100; /* reset*/
/* standing. firing ? */
if (scrawl || !(control_status & CONTROL_FIRE))
goto firing_not;
/*
* FIRING
*/
if (control_status & (CONTROL_LEFT|CONTROL_RIGHT)) { /* stop */
if (control_status & CONTROL_RIGHT)
{
game_dir = RIGHT;
e_rick_stop_x = E_RICK_ENT.x + 0x17;
} else {
game_dir = LEFT;
e_rick_stop_x = E_RICK_ENT.x;
}
e_rick_stop_y = E_RICK_ENT.y + 0x000E;
E_RICK_STSET(E_RICK_STSTOP);
return;
}
if (control_status == (CONTROL_FIRE|CONTROL_UP)) { /* bullet */
E_RICK_STSET(E_RICK_STSHOOT);
/* not an automatic gun: shoot once only */
if (trigger)
return;
else
trigger = TRUE;
/* already a bullet in the air ... that's enough */
if (E_BULLET_ENT.n)
return;
/* else use a bullet, if any available */
if (!game_bullets)
return;
#ifdef ENABLE_CHEATS
if (!game_cheat1)
#endif
{
game_bullets--;
game_status_dirty = 1;
}
/* initialize bullet */
e_bullet_init(E_RICK_ENT.x, E_RICK_ENT.y);
return;
}
trigger = FALSE; /* not shooting means trigger is released */
seq = 0; /* reset */
if (control_status == (CONTROL_FIRE|CONTROL_DOWN)) { /* bomb */
/* already a bomb ticking ... that's enough */
if (E_BOMB_ENT.n)
return;
/* else use a bomb, if any available */
if (!game_bombs)
return;
#ifdef ENABLE_CHEATS
if (!game_cheat1)
#endif
{
game_bombs--;
game_status_dirty = 1;
}
/* initialize bomb */
e_bomb_init(E_RICK_ENT.x, E_RICK_ENT.y);
return;
}
return;
/*
* NOT FIRING
*/
firing_not:
if (control_status & CONTROL_UP) { /* jump or climb */
if (env1 & MAP_EFLG_CLIMB) { /* climb */
E_RICK_STSET(E_RICK_STCLIMB);
return;
}
offsy = -0x0580; /* jump */
ylow = 0;
#ifdef ENABLE_SOUND
syssnd_play(WAV_JUMP, 1);
#endif
goto horiz;
}
if (control_status & CONTROL_DOWN) { /* crawl or climb */
if ((env1 & MAP_EFLG_VERT) && /* can go down */
!(control_status & (CONTROL_LEFT|CONTROL_RIGHT)) && /* + not moving horizontaly */
(E_RICK_ENT.x & 0x1f) < 0x0a) { /* + aligned -> climb */
E_RICK_ENT.x &= 0xf0;
E_RICK_ENT.x |= 0x04;
E_RICK_STSET(E_RICK_STCLIMB);
}
else { /* crawl */
E_RICK_STSET(E_RICK_STCRAWL);
goto horiz;
}
}
goto horiz;
/*
* CLIMBING
*/
climbing:
/* should move? */
if (!(control_status & (CONTROL_UP|CONTROL_DOWN|CONTROL_LEFT|CONTROL_RIGHT))) {
seq = 0; /* no: reset seq and return */
return;
}
if (control_status & (CONTROL_UP|CONTROL_DOWN)) {
/* up-down: calc new y and test environment */
y = E_RICK_ENT.y + ((control_status & CONTROL_UP) ? -0x02 : 0x02);
u_envtest(E_RICK_ENT.x, y, E_RICK_STTST(E_RICK_STCRAWL), &env0, &env1);
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP) &&
!(control_status & CONTROL_UP)) {
/* FIXME what? */
E_RICK_STRST(E_RICK_STCLIMB);
return;
}
if (!(env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) ||
(env1 & MAP_EFLG_WAYUP)) {
/* ok to move, save */
E_RICK_ENT.y = y;
if (env1 & MAP_EFLG_LETHAL) {
e_rick_gozombie();
return;
}
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB))) {
/* reached end of climb zone */
offsy = (control_status & CONTROL_UP) ? -0x0300 : 0x0100;
#ifdef ENABLE_SOUND
if (control_status & CONTROL_UP)
syssnd_play(WAV_JUMP, 1);
#endif
E_RICK_STRST(E_RICK_STCLIMB);
return;
}
}
}
if (control_status & (CONTROL_LEFT|CONTROL_RIGHT)) {
/* left-right: calc new x and test environment */
if (control_status & CONTROL_LEFT) {
x = E_RICK_ENT.x - 0x02;
if (x < 0) { /* (i.e. negative) prev submap */
game_chsm = TRUE;
/*6dbd = 0x00;*/
E_RICK_ENT.x = 0xe2;
return;
}
}
else {
x = E_RICK_ENT.x + 0x02;
if (x >= 0xe8) { /* next submap */
game_chsm = TRUE;
/*6dbd = 0x01;*/
E_RICK_ENT.x = 0x04;
return;
}
}
u_envtest(x, E_RICK_ENT.y, E_RICK_STTST(E_RICK_STCRAWL), &env0, &env1);
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD)) return;
E_RICK_ENT.x = x;
if (env1 & MAP_EFLG_LETHAL) {
e_rick_gozombie();
return;
}
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) return;
E_RICK_STRST(E_RICK_STCLIMB);
if (control_status & CONTROL_UP)
offsy = -0x0300;
}
}
/*
* Action function for e_rick
*
* ASM 12CA
*/
void e_rick_action(UNUSED(ent_t* pEnt))
{
#ifdef ENABLE_SOUND
static U8 stopped = FALSE; /* is this the most elegant way? */
#endif
e_rick_action2();
scrawl = E_RICK_STTST(E_RICK_STCRAWL);
if E_RICK_STTST(E_RICK_STZOMBIE)
return;
/*
* set sprite
*/
if E_RICK_STTST(E_RICK_STSTOP) {
E_RICK_ENT.sprite = (game_dir ? 0x17 : 0x0B);
#ifdef ENABLE_SOUND
if (!stopped)
{
syssnd_play(WAV_STICK, 1);
stopped = TRUE;
}
#endif
return;
}
#ifdef ENABLE_SOUND
stopped = FALSE;
#endif
if E_RICK_STTST(E_RICK_STSHOOT) {
E_RICK_ENT.sprite = (game_dir ? 0x16 : 0x0A);
return;
}
if E_RICK_STTST(E_RICK_STCLIMB) {
E_RICK_ENT.sprite = (((E_RICK_ENT.x ^ E_RICK_ENT.y) & 0x04) ? 0x18 : 0x0c);
#ifdef ENABLE_SOUND
seq = (seq + 1) & 0x03;
if (seq == 0) syssnd_play(WAV_WALK, 1);
#endif
return;
}
if E_RICK_STTST(E_RICK_STCRAWL)
{
E_RICK_ENT.sprite = (game_dir ? 0x13 : 0x07);
if (E_RICK_ENT.x & 0x04) E_RICK_ENT.sprite++;
#ifdef ENABLE_SOUND
seq = (seq + 1) & 0x03;
if (seq == 0) syssnd_play(WAV_CRAWL, 1);
#endif
return;
}
if E_RICK_STTST(E_RICK_STJUMP)
{
E_RICK_ENT.sprite = (game_dir ? 0x15 : 0x06);
return;
}
seq++;
if (seq >= 0x14)
{
#ifdef ENABLE_SOUND
syssnd_play(WAV_WALK, 1);
#endif
seq = 0x04;
}
#ifdef ENABLE_SOUND
else
if (seq == 0x0C)
syssnd_play(WAV_WALK, 1);
#endif
E_RICK_ENT.sprite = (seq >> 2) + 1 + (game_dir ? 0x0c : 0x00);
}
/*
* Save status
*
* ASM part of 0x0BBB
*/
void e_rick_save(void)
{
save_x = E_RICK_ENT.x;
save_y = E_RICK_ENT.y;
save_crawl = E_RICK_STTST(E_RICK_STCRAWL);
/* FIXME
* save_C0 = E_RICK_ENT.b0C;
* plus some 6DBC stuff?
*/
}
/*
* Restore status
*
* ASM part of 0x0BDC
*/
void e_rick_restore(void)
{
E_RICK_ENT.x = save_x;
E_RICK_ENT.y = save_y;
E_RICK_ENT.front = FALSE;
if (save_crawl)
E_RICK_STSET(E_RICK_STCRAWL);
else
E_RICK_STRST(E_RICK_STCRAWL);
/* FIXME
* E_RICK_ENT.b0C = save_C0;
* plus some 6DBC stuff?
*/
}
/* eof */

94
src/e_sbonus.c Normal file
View file

@ -0,0 +1,94 @@
/*
* xrick/src/e_sbonus.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#include "ents.h"
#include "e_sbonus.h"
#include "util.h"
#include "maps.h"
#include "e_rick.h"
#ifdef IIGS
#pragma noroot
segment "e";
#endif
/*
* public vars
*/
U8 e_sbonus_counting = FALSE;
U8 e_sbonus_counter = 0;
U16 e_sbonus_bonus = 0;
/*
* Entity action / start counting
*
* ASM 2182
*/
void
e_sbonus_start(ent_t* pEnt)
{
pEnt->sprite = 0; /* invisible */
if (u_trigbox(pEnt, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
/* rick is within trigger box */
pEnt->n = 0;
e_sbonus_counting = TRUE; /* 6DD5 */
e_sbonus_counter = 0x1e; /* 6DDB */
e_sbonus_bonus = 2000; /* 291A-291D */
#ifdef ENABLE_SOUND
syssnd_play(WAV_SBONUS1, 1);
#endif
}
}
/*
* Entity action / stop counting
*
* ASM 2143
*/
void
e_sbonus_stop(ent_t* pEnt)
{
pEnt->sprite = 0; /* invisible */
if (!e_sbonus_counting)
return;
if (u_trigbox(pEnt, ENT_XRICK.x + 0x0C, ENT_XRICK.y + 0x0A)) {
/* rick is within trigger box */
e_sbonus_counting = FALSE; /* stop counting */
pEnt->n = 0; /* deactivate entity */
game_score += e_sbonus_bonus; /* add bonus to score */
game_status_dirty = 1;
#ifdef ENABLE_SOUND
syssnd_play(WAV_SBONUS2, 1);
#endif
/* make sure the entity won't be activated again */
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
}
else {
/* keep counting */
if (--e_sbonus_counter == 0) {
e_sbonus_counter = 0x1e;
if (e_sbonus_bonus) e_sbonus_bonus--;
}
}
}
/* eof */

733
src/e_them.c Normal file
View file

@ -0,0 +1,733 @@
/*
* xrick/src/e_them.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#include "ents.h"
#include "e_them.h"
#include "e_rick.h"
#include "e_bomb.h"
#include "e_bullet.h"
#include "maps.h"
#include "util.h"
#define TYPE_1A (0x00)
#define TYPE_1B (0xff)
/*
* public vars
*/
U32 e_them_rndseed = 0;
/*
* local vars
*/
static U16 e_them_rndnbr = 0;
#ifdef IIGS
#pragma noroot
segment "e";
#endif
/*
* Check if entity boxtests with a lethal e_them i.e. something lethal
* in slot 0 and 4 to 8.
*
* ASM 122E
*
* e: entity slot number.
* ret: TRUE/boxtests, FALSE/not
*/
U8
u_themtest(ent_t* pEnt)
{
ent_t* pI;
if ((ent_ents[0].n & ENT_LETHAL) && u_boxtest(pEnt, ent_ents))
return TRUE;
for (pI = &ent_ents[4]; pI < &ent_ents[9]; pI++)
if ((pI->n & ENT_LETHAL) && u_boxtest(pEnt, pI))
return TRUE;
return FALSE;
}
/*
* Go zombie
*
* ASM 237B
*/
void
e_them_gozombie(ent_t* pEnt)
{
#define offsx c1
pEnt->n = 0x47; /* zombie entity */
pEnt->front = TRUE;
pEnt->offsy = -0x0400;
#ifdef ENABLE_SOUND
syssnd_play(WAV_DIE, 1);
#endif
game_score += 50;
game_status_dirty = 1;
if (pEnt->flags & ENT_FLG_ONCE) {
/* make sure entity won't be activated again */
map_marks[pEnt->mark].ent |= MAP_MARK_NACT;
}
pEnt->offsx = (pEnt->x >= 0x80 ? -0x02 : 0x02);
#undef offsx
}
/*
* Action sub-function for e_them _t1a and _t1b
*
* Those two types move horizontally, and fall if they have to.
* Type 1a moves horizontally over a given distance and then
* u-turns and repeats; type 1b is more subtle as it does u-turns
* in order to move horizontally towards rick.
*
* ASM 2242
*/
void
e_them_t1_action2(ent_t* pEnt, U8 type)
{
#define offsx c1
#define step_count c2
U32 i;
S16 x, y;
U8 env0, env1;
/* by default, try vertical move. calculate new y */
i = (((S32)pEnt->y) << 8) + ((S32)pEnt->offsy) + ((U32)pEnt->ylow);
y = i >> 8;
/* deactivate if outside vertical boundaries */
/* no need to test zero since e_them _t1a/b don't go up */
/* FIXME what if they got scrolled out ? */
if (y > 0x140) {
pEnt->n = 0;
return;
}
/* test environment */
u_envtest(pEnt->x, y, FALSE, &env0, &env1);
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
/* vertical move possible: falling */
if (env1 & MAP_EFLG_LETHAL) {
/* lethal entities kill e_them */
e_them_gozombie(pEnt);
return;
}
/* save, cleanup and return */
pEnt->y = y;
pEnt->ylow = i;
pEnt->offsy += 0x0080;
if (pEnt->offsy > 0x0800)
pEnt->offsy = 0x0800;
return;
}
/* vertical move not possible. calculate new sprite */
pEnt->sprite = pEnt->sprbase
+ ent_sprseq[(pEnt->x & 0x1c) >> 3]
+ (pEnt->offsx < 0 ? 0x03 : 0x00);
/* reset offsy */
pEnt->offsy = 0x0080;
/* align to ground */
pEnt->y &= 0xfff8;
pEnt->y |= 0x0003;
/* latency: if not zero then decrease and return */
if (pEnt->latency > 0) {
pEnt->latency--;
return;
}
/* horizontal move. calculate new x */
if (pEnt->offsx == 0) /* not supposed to move -> don't */
return;
x = pEnt->x + pEnt->offsx;
if (pEnt->x < 0 || pEnt->x > 0xe8) {
/* U-turn and return if reaching horizontal boundaries */
pEnt->step_count = 0;
pEnt->offsx = -pEnt->offsx;
return;
}
/* test environment */
u_envtest(x, pEnt->y, FALSE, &env0, &env1);
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) {
/* horizontal move not possible: u-turn and return */
pEnt->step_count = 0;
pEnt->offsx = -pEnt->offsx;
return;
}
/* horizontal move possible */
if (env1 & MAP_EFLG_LETHAL) {
/* lethal entities kill e_them */
e_them_gozombie(pEnt);
return;
}
/* save */
pEnt->x = x;
/* depending on type, */
if (type == TYPE_1B) {
/* set direction to move horizontally towards rick */
if ((pEnt->x & 0x1e) != 0x10) /* prevents too frequent u-turns */
return;
pEnt->offsx = (pEnt->x < E_RICK_ENT.x) ? 0x02 : -0x02;
return;
}
else {
/* set direction according to step counter */
pEnt->step_count++;
/* FIXME why trig_x (b16) ?? */
if ((pEnt->trig_x >> 1) > pEnt->step_count)
return;
}
/* type is 1A and step counter reached its limit: u-turn */
pEnt->step_count = 0;
pEnt->offsx = -pEnt->offsx;
#undef offsx
#undef step_count
}
/*
* ASM 21CF
*/
void
e_them_t1_action(ent_t* pEnt, U8 type)
{
e_them_t1_action2(pEnt, type);
/* lethal entities kill them */
if (u_themtest(pEnt)) {
e_them_gozombie(pEnt);
return;
}
/* bullet kills them */
if (E_BULLET_ENT.n &&
u_fboxtest(pEnt, E_BULLET_ENT.x + (e_bullet_offsx < 0 ? 0 : 0x18),
E_BULLET_ENT.y)) {
E_BULLET_ENT.n = 0;
e_them_gozombie(pEnt);
return;
}
/* bomb kills them */
if (e_bomb_lethal && e_bomb_hit(pEnt)) {
e_them_gozombie(pEnt);
return;
}
/* rick stops them */
if (E_RICK_STTST(E_RICK_STSTOP) &&
u_fboxtest(pEnt, e_rick_stop_x, e_rick_stop_y))
pEnt->latency = 0x14;
/* they kill rick */
if (e_rick_boxtest(pEnt))
e_rick_gozombie();
}
/*
* Action function for e_them _t1a type (stays within boundaries)
*
* ASM 2452
*/
void
e_them_t1a_action(ent_t* pEnt)
{
e_them_t1_action(pEnt, TYPE_1A);
}
/*
* Action function for e_them _t1b type (runs for rick)
*
* ASM 21CA
*/
void
e_them_t1b_action(ent_t* pEnt)
{
e_them_t1_action(pEnt, TYPE_1B);
}
/*
* Action function for e_them _z (zombie) type
*
* ASM 23B8
*/
void
e_them_z_action(ent_t* pEnt)
{
#define offsx c1
U32 i;
/* calc new sprite */
pEnt->sprite = pEnt->sprbase
+ ((pEnt->x & 0x04) ? 0x07 : 0x06);
/* calc new y */
i = (((S32)pEnt->y) << 8) + ((S32)pEnt->offsy) + ((U32)pEnt->ylow);
/* deactivate if out of vertical boundaries */
if (pEnt->y < 0 || pEnt->y > 0x0140) {
pEnt->n = 0;
return;
}
/* save */
pEnt->offsy += 0x0080;
pEnt->ylow = i;
pEnt->y = i >> 8;
/* calc new x */
pEnt->x += pEnt->offsx;
/* must stay within horizontal boundaries */
if (pEnt->x < 0)
pEnt->x = 0;
if (pEnt->x > 0xe8)
pEnt->x = 0xe8;
#undef offsx
}
/*
* Action sub-function for e_them _t2.
*
* Must document what it does.
*
* ASM 2792
*/
void
e_them_t2_action2(ent_t* pEnt)
{
#define flgclmb c1
#define offsx c2
U32 i;
S16 x, y, yd;
U8 env0, env1;
/*
* vars required by the Black Magic (tm) performance at the
* end of this function.
*/
static U16 bx;
static U8 *bl = (U8*)&bx;
U8 *bh = bl+1;
static U16 cx;
static U8 *cl = (U8*)&cx;
U8 *ch = cl+1;
static U16 *sl = (U16*)&e_them_rndseed;
U16 *sh = sl+1;
/*sys_printf("e_them_t2 ------------------------------\n");*/
/* latency: if not zero then decrease */
if (pEnt->latency > 0) pEnt->latency--;
/* climbing? */
if (pEnt->flgclmb != TRUE) goto climbing_not;
/* CLIMBING */
/*sys_printf("e_them_t2 climbing\n");*/
/* latency: if not zero then return */
if (pEnt->latency > 0) return;
/* calc new sprite */
pEnt->sprite = pEnt->sprbase + 0x08 +
(((pEnt->x ^ pEnt->y) & 0x04) ? 1 : 0);
/* reached rick's level? */
if ((pEnt->y & 0xfe) != (E_RICK_ENT.y & 0xfe)) goto ymove;
xmove:
/* calc new x and test environment */
pEnt->offsx = (pEnt->x < E_RICK_ENT.x) ? 0x02 : -0x02;
x = pEnt->x + pEnt->offsx;
u_envtest(x, pEnt->y, FALSE, &env0, &env1);
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))
return;
if (env1 & MAP_EFLG_LETHAL) {
e_them_gozombie(pEnt);
return;
}
pEnt->x = x;
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) /* still climbing */
return;
goto climbing_not; /* not climbing anymore */
ymove:
/* calc new y and test environment */
yd = pEnt->y < E_RICK_ENT.y ? 0x02 : -0x02;
y = pEnt->y + yd;
if (y < 0 || y > 0x0140) {
pEnt->n = 0;
return;
}
u_envtest(pEnt->x, y, FALSE, &env0, &env1);
if (env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP)) {
if (yd < 0)
goto xmove; /* can't go up */
else
goto climbing_not; /* can't go down */
}
/* can move */
pEnt->y = y;
if (env1 & (MAP_EFLG_VERT|MAP_EFLG_CLIMB)) /* still climbing */
return;
/* NOT CLIMBING */
climbing_not:
/*sys_printf("e_them_t2 climbing NOT\n");*/
pEnt->flgclmb = FALSE; /* not climbing */
/* calc new y (falling) and test environment */
i = (((U32)pEnt->y) << 8) + pEnt->offsy + pEnt->ylow;
y = i >> 8;
u_envtest(pEnt->x, y, FALSE, &env0, &env1);
if (!(env1 & (MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
/*sys_printf("e_them_t2 y move OK\n");*/
/* can go there */
if (env1 & MAP_EFLG_LETHAL) {
e_them_gozombie(pEnt);
return;
}
if (y > 0x0140) { /* deactivate if outside */
pEnt->n = 0;
return;
}
if (!(env1 & MAP_EFLG_VERT)) {
/* save */
pEnt->y = y;
pEnt->ylow = i;
pEnt->offsy += 0x0080;
if (pEnt->offsy > 0x0800)
pEnt->offsy = 0x0800;
return;
}
if (((pEnt->x & 0x07) == 0x04) && (y < E_RICK_ENT.y)) {
/*sys_printf("e_them_t2 climbing00\n");*/
pEnt->flgclmb = TRUE; /* climbing */
return;
}
}
/*sys_printf("e_them_t2 ymove nok or ...\n");*/
/* can't go there, or ... */
pEnt->y = (pEnt->y & 0xf8) | 0x03; /* align to ground */
pEnt->offsy = 0x0100;
if (pEnt->latency != 00)
return;
if ((env1 & MAP_EFLG_CLIMB) &&
((pEnt->x & 0x0e) == 0x04) &&
(pEnt->y > E_RICK_ENT.y)) {
/*sys_printf("e_them_t2 climbing01\n");*/
pEnt->flgclmb = TRUE; /* climbing */
return;
}
/* calc new sprite */
pEnt->sprite = pEnt->sprbase +
ent_sprseq[(pEnt->offsx < 0 ? 4 : 0) +
((pEnt->x & 0x0e) >> 3)];
/*sys_printf("e_them_t2 sprite %02x\n", pEnt->sprite);*/
/* */
if (pEnt->offsx == 0)
pEnt->offsx = 2;
x = pEnt->x + pEnt->offsx;
/*sys_printf("e_them_t2 xmove x=%02x\n", x);*/
if (x < 0xe8) {
u_envtest(x, pEnt->y, FALSE, &env0, &env1);
if (!(env1 & (MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP))) {
pEnt->x = x;
if ((x & 0x1e) != 0x08)
return;
/*
* Black Magic (tm)
*
* this is obviously some sort of randomizer to define a direction
* for the entity. it is an exact copy of what the assembler code
* does but I can't explain.
*/
bx = e_them_rndnbr + *sh + *sl + 0x0d;
cx = *sh;
*bl ^= *ch;
*bl ^= *cl;
*bl ^= *bh;
e_them_rndnbr = bx;
pEnt->offsx = (*bl & 0x01) ? -0x02 : 0x02;
/* back to normal */
return;
}
}
/* U-turn */
/*sys_printf("e_them_t2 u-turn\n");*/
if (pEnt->offsx == 0)
pEnt->offsx = 2;
else
pEnt->offsx = -pEnt->offsx;
#undef offsx
}
/*
* Action function for e_them _t2 type
*
* ASM 2718
*/
void
e_them_t2_action(ent_t* pEnt)
{
e_them_t2_action2(pEnt);
/* they kill rick */
if (e_rick_boxtest(pEnt))
e_rick_gozombie();
/* lethal entities kill them */
if (u_themtest(pEnt)) {
e_them_gozombie(pEnt);
return;
}
/* bullet kills them */
if (E_BULLET_ENT.n &&
u_fboxtest(pEnt, E_BULLET_ENT.x + (e_bullet_offsx < 0 ? 00 : 0x18),
E_BULLET_ENT.y)) {
E_BULLET_ENT.n = 0;
e_them_gozombie(pEnt);
return;
}
/* bomb kills them */
if (e_bomb_lethal && e_bomb_hit(pEnt)) {
e_them_gozombie(pEnt);
return;
}
/* rick stops them */
if (E_RICK_STTST(E_RICK_STSTOP) &&
u_fboxtest(pEnt, e_rick_stop_x, e_rick_stop_y))
pEnt->latency = 0x14;
}
/*
* Action sub-function for e_them _t3
*
* FIXME always starts asleep??
*
* Waits until triggered by something, then execute move steps from
* ent_mvstep with sprite from ent_sprseq. When done, either restart
* or disappear.
*
* Not always lethal ... but if lethal, kills rick.
*
* ASM: 255A
*/
void
e_them_t3_action2(ent_t* pEnt)
{
#define sproffs c1
#define step_count c2
U8 i;
S16 x, y;
while (1) {
/* calc new sprite */
i = ent_sprseq[pEnt->sprbase + pEnt->sproffs];
if (i == 0xff)
i = ent_sprseq[pEnt->sprbase];
pEnt->sprite = i;
if (pEnt->sproffs != 0) { /* awake */
/* rotate sprseq */
if (ent_sprseq[pEnt->sprbase + pEnt->sproffs] != 0xff)
pEnt->sproffs++;
if (ent_sprseq[pEnt->sprbase + pEnt->sproffs] == 0xff)
pEnt->sproffs = 1;
if (pEnt->step_count < ent_mvstep[pEnt->step_no].count) {
/*
* still running this step: try to increment x and y while
* checking that they remain within boudaries. if so, return.
* else switch to next step.
*/
pEnt->step_count++;
x = pEnt->x + ((S16)(ent_mvstep[pEnt->step_no].dx));
/* check'n save */
if (x > 0 && x < 0xe8) {
pEnt->x = x;
/*FIXME*/
/*
y = ent_mvstep[pEnt->step_no].dy;
if (y < 0)
y += 0xff00;
y += pEnt->y;
*/
y = pEnt->y + ((S16)(ent_mvstep[pEnt->step_no].dy));
if (y > 0 && y < 0x0140) {
pEnt->y = y;
return;
}
}
}
/*
* step is done, or x or y is outside boundaries. try to
* switch to next step
*/
pEnt->step_no++;
if (ent_mvstep[pEnt->step_no].count != 0xff) {
/* there is a next step: init and loop */
pEnt->step_count = 0;
}
else {
/* there is no next step: restart or deactivate */
if (!E_RICK_STTST(E_RICK_STZOMBIE) &&
!(pEnt->flags & ENT_FLG_ONCE)) {
/* loop this entity */
pEnt->sproffs = 0;
pEnt->n &= ~ENT_LETHAL;
if (pEnt->flags & ENT_FLG_LETHALR)
pEnt->n |= ENT_LETHAL;
pEnt->x = pEnt->xsave;
pEnt->y = pEnt->ysave;
if (pEnt->y < 0 || pEnt->y > 0x140) {
pEnt->n = 0;
return;
}
}
else {
/* deactivate this entity */
pEnt->n = 0;
return;
}
}
}
else { /* pEnt->sprseq1 == 0 -- waiting */
/* ugly GOTOs */
if (pEnt->flags & ENT_FLG_TRIGRICK) { /* reacts to rick */
/* wake up if triggered by rick */
if (u_trigbox(pEnt, E_RICK_ENT.x + 0x0C, E_RICK_ENT.y + 0x0A))
goto wakeup;
}
if (pEnt->flags & ENT_FLG_TRIGSTOP) { /* reacts to rick "stop" */
/* wake up if triggered by rick "stop" */
if (E_RICK_STTST(E_RICK_STSTOP) &&
u_trigbox(pEnt, e_rick_stop_x, e_rick_stop_y))
goto wakeup;
}
if (pEnt->flags & ENT_FLG_TRIGBULLET) { /* reacts to bullets */
/* wake up if triggered by bullet */
if (E_BULLET_ENT.n && u_trigbox(pEnt, e_bullet_xc, e_bullet_yc)) {
E_BULLET_ENT.n = 0;
goto wakeup;
}
}
if (pEnt->flags & ENT_FLG_TRIGBOMB) { /* reacts to bombs */
/* wake up if triggered by bomb */
if (e_bomb_lethal && u_trigbox(pEnt, e_bomb_xc, e_bomb_yc))
goto wakeup;
}
/* not triggered: keep waiting */
return;
/* something triggered the entity: wake up */
/* initialize step counter */
wakeup:
if E_RICK_STTST(E_RICK_STZOMBIE)
return;
#ifdef ENABLE_SOUND
/*
* FIXME the sound should come from a table, there are 10 of them
* but I dont have the table yet. must rip the data off the game...
* FIXME is it 8 of them, not 10?
* FIXME testing below...
*/
syssnd_play(WAV_ENTITY[(pEnt->trigsnd & 0x1F) - 0x14], 1);
/*syssnd_play(WAV_ENTITY[0], 1);*/
#endif
pEnt->n &= ~ENT_LETHAL;
if (pEnt->flags & ENT_FLG_LETHALI)
pEnt->n |= ENT_LETHAL;
pEnt->sproffs = 1;
pEnt->step_count = 0;
pEnt->step_no = pEnt->step_no_i;
return;
}
}
#undef step_count
}
/*
* Action function for e_them _t3 type
*
* ASM 2546
*/
void
e_them_t3_action(ent_t* pEnt)
{
e_them_t3_action2(pEnt);
/* if lethal, can kill rick */
if ((pEnt->n & ENT_LETHAL) &&
!E_RICK_STTST(E_RICK_STZOMBIE) && e_rick_boxtest(pEnt)) { /* CALL 1130 */
e_rick_gozombie();
}
}
/* eof */

1
src/ents.c Normal file

File diff suppressed because one or more lines are too long

924
src/game.c Normal file
View file

@ -0,0 +1,924 @@
/*
* xrick/src/game.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include <stdlib.h>
#include "system.h"
#include "config.h"
#include "game.h"
#include "draw.h"
#include "maps.h"
#include "ents.h"
#include "e_rick.h"
#include "e_sbonus.h"
#include "e_them.h"
#include "screens.h"
#include "rects.h"
#include "scroller.h"
#include "control.h"
#include "data.h"
#ifdef ENABLE_DEVTOOLS
#include "devtools.h"
#endif
#ifdef IIGS
#pragma noroot
segment "game";
#endif
/*
* local typedefs
*/
typedef enum {
#ifdef ENABLE_DEVTOOLS
DEVTOOLS,
#endif
#ifdef IIGS
CHOOSE_JOYKEY,
#endif
XRICK,
INIT_GAME, INIT_BUFFER,
INTRO_MAIN, INTRO_MAP,
PAUSE_PRESSED1, PAUSE_PRESSED1B, PAUSED, PAUSE_PRESSED2,
PLAY0, PLAY1, PLAY2, PLAY3,
CHAIN_SUBMAP, CHAIN_MAP, CHAIN_END,
SCROLL_UP, SCROLL_DOWN,
RESTART, GAMEOVER, GETNAME, EXIT
} game_state_t;
/*
* global vars
*/
U16 game_period = 0;
U16 game_waitevt = FALSE;
rect_t *game_rects = NULL;
U16 game_lives = 0;
U16 game_bombs = 0;
U16 game_bullets = 0;
U32 game_score = 0;
U16 game_map = 0;
U16 game_submap = 0;
U16 game_dir = 0;
U16 game_chsm = FALSE;
U16 game_cheat1 = 0;
U16 game_cheat2 = 0; // no die
U16 game_cheat3 = 0;
U16 game_status_dirty = 0;
#if defined(GFXST) || defined(GFXGS) || defined(GFXF256)
hscore_t game_hscores[8] = {
{ 8000, "SIMES@@@@@" },
{ 7000, "JAYNE@@@@@" },
{ 6000, "DANGERSTU@" },
{ 5000, "KEN@@@@@@@" },
{ 4000, "ROB@N@BOB@" },
{ 3000, "TELLY@@@@@" },
{ 2000, "NOBBY@@@@@" },
{ 1000, "JEZEBEL@@@" }
};
#endif
#ifdef GFXPC
hscore_t game_hscores[8] = {
{ 8000, "DANGERSTU@" },
{ 7000, "SIMES@@@@@" },
{ 6000, "KEN@T@ZEN@" },
{ 5000, "BOBBLE@@@@" },
{ 4000, "GREG@LAA@@" },
{ 3000, "TELLY@@@@@" },
{ 2000, "CHIGLET@@@" },
{ 1000, "ANDYSPLEEN" }
};
#endif
#ifdef ENABLE_SOUND
#ifdef IIGS
sound_t WAV_GAMEOVER;
sound_t WAV_SBONUS2;
//sound_t WAV_BULLET;
//sound_t WAV_BOMBSHHT;
sound_t WAV_EXPLODE;
sound_t WAV_STICK;
//sound_t WAV_WALK;
sound_t WAV_CRAWL;
//sound_t WAV_JUMP;
sound_t WAV_PAD;
//sound_t WAV_BOX;
//sound_t WAV_BONUS;
sound_t WAV_SBONUS1;
sound_t WAV_DIE;
sound_t WAV_ENTITY[10];
#else
sound_t *WAV_GAMEOVER;
sound_t *WAV_SBONUS2;
//sound_t *WAV_BULLET;
//sound_t *WAV_BOMBSHHT;
sound_t *WAV_EXPLODE;
sound_t *WAV_STICK;
//sound_t *WAV_WALK;
sound_t *WAV_CRAWL;
//sound_t *WAV_JUMP;
sound_t *WAV_PAD;
//sound_t *WAV_BOX;
//sound_t *WAV_BONUS;
sound_t *WAV_SBONUS1;
sound_t *WAV_DIE;
sound_t *WAV_ENTITY[10];
#endif /*IIGS*/
#endif /*ENABLE_SOUND*/
/*
* local vars
*/
static U8 isave_frow;
static game_state_t game_state;
#ifdef ENABLE_SOUND
static sound_t *music_snd;
#endif
/*
* prototypes
*/
static void frame(void);
static void init(void);
static void play0(void);
static void play3(void);
static void restart(void);
static void isave(void);
static void irestore(void);
static void loaddata(void);
static void freedata(void);
/*
* Cheats
*/
#ifdef ENABLE_CHEATS
void
game_toggleCheat(U8 nbr)
{
if (game_state != INTRO_MAIN && game_state != INTRO_MAP &&
game_state != GAMEOVER && game_state != GETNAME &&
#ifdef ENABLE_DEVTOOLS
game_state != DEVTOOLS &&
#endif
game_state != XRICK && game_state != EXIT) {
switch (nbr) {
case 1:
game_cheat1 = ~game_cheat1;
game_lives = 6;
game_bombs = 6;
game_bullets = 6;
game_status_dirty = 1;
break;
case 2:
game_cheat2 = ~game_cheat2;
break;
case 3:
game_cheat3 = ~game_cheat3;
break;
}
draw_infos();
/* FIXME this should probably only raise a flag ... */
/* plus we only need to update INFORECT not the whole screen */
sysvid_update(&draw_SCREENRECT);
}
}
#endif
#ifdef ENABLE_SOUND
#ifdef IIGS
void NTPstop(void);
void NTPplay(int bPlayOnce);
int NTPprepare(void* pNTPData);
extern char* pNtpSong;
#endif
/*
* Music
*/
void
game_setmusic(char *name, U8 loop)
{
#ifdef IIGS
NTPstop();
LZ4_Unpack(pNtpSong, name);
NTPprepare((void*)pNtpSong);
NTPplay(0);
#endif
#if !(defined(IIGS) || defined(F256))
U8 channel;
if (music_snd)
game_stopmusic();
music_snd = syssnd_load(name);
if (music_snd)
{
music_snd->dispose = TRUE; /* music is always "fire and forget" */
channel = syssnd_play(music_snd, loop);
}
#endif
}
void
game_stopmusic(void)
{
#ifdef IIGS
NTPstop();
#endif
#if !(defined(IIGS) || defined(F256))
syssnd_stopsound(music_snd);
music_snd = NULL;
#endif
}
#endif
/*
* Main loop
*/
void
game_run(void)
{
U32 tm, tmx;
loaddata(); /* load cached data */
game_period = sysarg_args_period ? sysarg_args_period : GAME_PERIOD;
tm = sys_gettime();
/*game_state = CHOOSE_JOYKEY;*/
#ifdef ENABLE_DEVTOOLS
game_state = DEVTOOLS;
#else
game_state = INIT_GAME;
#endif
/* main loop */
while (game_state != EXIT) {
/* timer */
tmx = tm; tm = sys_gettime(); tmx = tm - tmx;
if (tmx < game_period) sys_sleep(game_period - tmx);
// printf("tmx=%x\n");
/* video */
/*DEBUG*//*game_rects=&draw_SCREENRECT;*//*DEBUG*/
sysvid_update(game_rects);
draw_STATUSRECT.next = NULL; /* FIXME freerects should handle this */
/* sound */
/*snd_mix();*/
/* events */
if (game_waitevt)
sysevt_wait(); /* wait for an event */
else
sysevt_poll(); /* process events (non-blocking) */
/* frame */
frame();
}
freedata(); /* free cached data */
}
#ifndef F256
static char* game_state_strings[] =
{
#ifdef ENABLE_DEVTOOLS
"DEVTOOLS",
#endif
#ifdef IIGS
"CHOOSE_JOYKEY",
#endif
"XRICK",
"INIT_GAME",
"INIT_BUFFER",
"INTRO_MAIN",
"INTRO_MAP",
"PAUSE_PRESSED1",
"PAUSE_PRESSED1B",
"PAUSED",
"PAUSE_PRESSED2",
"PLAY0",
"PLAY1",
"PLAY2",
"PLAY3",
"CHAIN_SUBMAP",
"CHAIN_MAP",
"CHAIN_END",
"SCROLL_UP",
"SCROLL_DOWN",
"RESTART",
"GAMEOVER",
"GETNAME",
"EXIT"
};
#endif
/*
* Prepare frame
*
* This function loops forever: use 'return' when a frame is ready.
* When returning, game_rects must contain every parts of the buffer
* that have been modified.
*/
static void
frame(void)
{
while (1) {
switch (game_state) {
#ifdef ENABLE_DEVTOOLS
case DEVTOOLS:
switch (devtools_run()) {
case SCREEN_RUNNING:
return;
case SCREEN_DONE:
game_state = INIT_GAME;
break;
case SCREEN_EXIT:
game_state = EXIT;
return;
}
break;
#endif
#ifdef IIGS
case CHOOSE_JOYKEY:
switch (screen_joykey())
{
case SCREEN_RUNNING:
return;
case SCREEN_DONE:
game_state = INIT_GAME;
break;
case SCREEN_EXIT:
game_state = EXIT;
return;
}
break;
#endif
case XRICK:
switch(screen_xrick()) {
case SCREEN_RUNNING:
return;
case SCREEN_DONE:
#ifdef ENABLE_DEVTOOLS
game_state = DEVTOOLS;
#else
game_state = INIT_GAME;
#endif
break;
case SCREEN_EXIT:
game_state = EXIT;
return;
}
break;
case INIT_GAME:
init();
game_state = INTRO_MAIN;
break;
case INTRO_MAIN:
switch (screen_introMain()) {
case SCREEN_RUNNING:
return;
case SCREEN_DONE:
game_state = INTRO_MAP;
break;
case SCREEN_EXIT:
game_state = EXIT;
return;
}
break;
case INTRO_MAP:
switch (screen_introMap()) {
case SCREEN_RUNNING:
return;
case SCREEN_DONE:
game_waitevt = FALSE;
game_state = INIT_BUFFER;
break;
case SCREEN_EXIT:
game_state = EXIT;
return;
}
break;
case INIT_BUFFER:
sysvid_clear(); /* clear buffer */
draw_map(); /* draw the map onto the buffer */
draw_drawStatus(); /* draw the status bar onto the buffer */
#ifdef ENABLE_CHEATS
draw_infos(); /* draw the info bar onto the buffer */
#endif
game_rects = &draw_SCREENRECT; /* request full buffer refresh */
game_state = PLAY0;
return;
case PAUSE_PRESSED1:
screen_pause(TRUE);
game_state = PAUSE_PRESSED1B;
break;
case PAUSE_PRESSED1B:
if (control_status & CONTROL_PAUSE)
return;
game_state = PAUSED;
break;
case PAUSED:
if (control_status & CONTROL_PAUSE)
game_state = PAUSE_PRESSED2;
if (control_status & CONTROL_EXIT)
game_state = EXIT;
return;
case PAUSE_PRESSED2:
if (!(control_status & CONTROL_PAUSE)) {
game_waitevt = FALSE;
screen_pause(FALSE);
#ifdef ENABLE_SOUND
syssnd_pause(FALSE, FALSE);
#endif
game_state = PLAY2;
}
return;
case PLAY0:
play0();
break;
case PLAY1:
if (control_status & CONTROL_PAUSE) {
#ifdef ENABLE_SOUND
syssnd_pause(TRUE, FALSE);
#endif
game_waitevt = TRUE;
game_state = PAUSE_PRESSED1;
}
else if (control_active == FALSE) {
#ifdef ENABLE_SOUND
syssnd_pause(TRUE, FALSE);
#endif
game_waitevt = TRUE;
screen_pause(TRUE);
game_state = PAUSED;
}
else
game_state = PLAY2;
break;
case PLAY2:
if E_RICK_STTST(E_RICK_STDEAD) { /* rick is dead */
if (game_cheat1 || --game_lives) {
game_state = RESTART;
} else {
game_state = GAMEOVER;
}
game_status_dirty = 1;
}
else if (game_chsm) /* request to chain to next submap */
game_state = CHAIN_SUBMAP;
else
game_state = PLAY3;
break;
case PLAY3:
play3();
return;
case CHAIN_SUBMAP:
if (map_chain())
game_state = CHAIN_END;
else {
game_status_dirty = 1;
game_bullets = 0x06;
game_bombs = 0x06;
game_map++;
if (game_map == 0x04) {
/* reached end of game */
/* FIXME @292?*/
}
game_state = CHAIN_MAP;
}
break;
case CHAIN_MAP: /* CHAIN MAP */
switch (screen_introMap()) {
case SCREEN_RUNNING:
return;
case SCREEN_DONE:
if (game_map >= 0x04) { /* reached end of game */
sysarg_args_map = 0;
sysarg_args_submap = 0;
game_state = GAMEOVER;
}
else { /* initialize game */
ent_ents[1].x = map_maps[game_map].x;
ent_ents[1].y = map_maps[game_map].y;
map_frow = (U8)map_maps[game_map].row;
game_submap = map_maps[game_map].submap;
game_state = CHAIN_END;
}
break;
case SCREEN_EXIT:
game_state = EXIT;
return;
}
break;
case CHAIN_END:
map_init(); /* initialize the map */
isave(); /* save data in case of a restart */
ent_clprev(); /* cleanup entities */
draw_map(); /* draw the map onto the buffer */
draw_drawStatus(); /* draw the status bar onto the buffer */
draw_STATUSRECT.next = NULL;
ent_action();
game_state = PLAY3;
game_rects = &draw_SCREENRECT; /* request full screen refresh */
return;
case SCROLL_UP:
switch (scroll_up()) {
case SCROLL_RUNNING:
return;
case SCROLL_DONE:
game_state = PLAY0;
break;
}
break;
case SCROLL_DOWN:
switch (scroll_down()) {
case SCROLL_RUNNING:
return;
case SCROLL_DONE:
game_state = PLAY0;
break;
}
break;
case RESTART:
restart();
game_state = PLAY0;
return;
case GAMEOVER:
switch (screen_gameover()) {
case SCREEN_RUNNING:
return;
case SCREEN_DONE:
game_state = GETNAME;
break;
case SCREEN_EXIT:
game_state = EXIT;
break;
}
break;
case GETNAME:
switch (screen_getname()) {
case SCREEN_RUNNING:
return;
case SCREEN_DONE:
game_state = INIT_GAME;
return;
case SCREEN_EXIT:
game_state = EXIT;
break;
}
break;
case EXIT:
return;
}
}
}
/*
* Initialize the game
*/
static void
init(void)
{
U8 i;
E_RICK_STRST(0xff);
game_lives = 6;
game_bombs = 6;
game_bullets = 6;
game_score = 0;
game_status_dirty = 1;
game_map = sysarg_args_map;
if (sysarg_args_submap == 0) {
game_submap = map_maps[game_map].submap;
map_frow = (U8)map_maps[game_map].row;
}
else {
/* dirty hack to determine frow */
game_submap = sysarg_args_submap;
i = 0;
while (i < MAP_NBR_CONNECT &&
(map_connect[i].submap != game_submap ||
map_connect[i].dir != RIGHT))
i++;
map_frow = map_connect[i].rowin - 0x10;
ent_ents[1].y = 0x10 << 3;
}
ent_ents[1].x = map_maps[game_map].x;
ent_ents[1].y = map_maps[game_map].y;
ent_ents[1].w = 0x18;
ent_ents[1].h = 0x15;
ent_ents[1].n = 0x01;
ent_ents[1].sprite = 0x01;
ent_ents[1].front = FALSE;
ent_ents[ENT_ENTSNUM].n = 0xFF;
map_resetMarks();
map_init();
isave();
}
/*
* play0
*
*/
static void
play0(void)
{
if (control_status & CONTROL_END) { /* request to end the game */
game_state = GAMEOVER;
return;
}
if (control_last == CONTROL_EXIT) { /* request to exit the game */
game_state = EXIT;
return;
}
ent_action(); /* run entities */
e_them_rndseed++; /* (0270) */
game_state = PLAY1;
}
/*
* play3
*
*/
static void
play3(void)
{
static rect_t *r;
if (game_status_dirty)
{
draw_clearStatus(); /* clear the status bar */
ent_draw(); /* draw all entities onto the buffer */
draw_drawStatus(); /* draw the status bar onto the buffer*/
r = &draw_STATUSRECT; r->next = ent_rects; /* refresh status bar too */
game_rects = r; /* take care to cleanup draw_STATUSRECT->next later! */
game_status_dirty = 0;
}
else
{
ent_draw(); /* draw all entities onto the buffer */
game_rects = ent_rects;
}
if (!E_RICK_STTST(E_RICK_STZOMBIE)) { /* need to scroll ? */
if (ent_ents[1].y >= 0xCC) {
game_state = SCROLL_UP;
return;
}
if (ent_ents[1].y <= 0x60) {
game_state = SCROLL_DOWN;
return;
}
}
game_state = PLAY0;
}
/*
* restart
*
*/
static void
restart(void)
{
E_RICK_STRST(E_RICK_STDEAD|E_RICK_STZOMBIE);
game_bullets = 6;
game_bombs = 6;
game_status_dirty = 1;
ent_ents[1].n = 1;
irestore();
map_init();
isave();
ent_clprev();
draw_map();
draw_drawStatus();
game_rects = &draw_SCREENRECT;
}
/*
* isave (0bbb)
*
*/
static void
isave(void)
{
e_rick_save();
isave_frow = map_frow;
}
/*
* irestore (0bdc)
*
*/
static void
irestore(void)
{
e_rick_restore();
map_frow = isave_frow;
}
/*
*
*/
static void
loaddata()
{
#ifdef ENABLE_SOUND
/*
* Cache sounds
*
* tune[0-5].wav not cached
*/
#if !(defined(IIGS) || defined(F256))
WAV_GAMEOVER = syssnd_load("sounds/gameover.wav");
WAV_SBONUS2 = syssnd_load("sounds/sbonus2.wav");
WAV_BULLET = syssnd_load("sounds/bullet.wav");
WAV_BOMBSHHT = syssnd_load("sounds/bombshht.wav");
WAV_EXPLODE = syssnd_load("sounds/explode.wav");
WAV_STICK = syssnd_load("sounds/stick.wav");
WAV_WALK = syssnd_load("sounds/walk.wav");
WAV_CRAWL = syssnd_load("sounds/crawl.wav");
WAV_JUMP = syssnd_load("sounds/jump.wav");
WAV_PAD = syssnd_load("sounds/pad.wav");
WAV_BOX = syssnd_load("sounds/box.wav");
WAV_BONUS = syssnd_load("sounds/bonus.wav");
WAV_SBONUS1 = syssnd_load("sounds/sbonus1.wav");
WAV_DIE = syssnd_load("sounds/die.wav");
WAV_ENTITY[0] = syssnd_load("sounds/ent0.wav");
WAV_ENTITY[1] = syssnd_load("sounds/ent1.wav");
WAV_ENTITY[2] = syssnd_load("sounds/ent2.wav");
WAV_ENTITY[3] = syssnd_load("sounds/ent3.wav");
WAV_ENTITY[4] = syssnd_load("sounds/ent4.wav");
WAV_ENTITY[5] = syssnd_load("sounds/ent5.wav");
WAV_ENTITY[6] = syssnd_load("sounds/ent6.wav");
WAV_ENTITY[7] = syssnd_load("sounds/ent7.wav");
WAV_ENTITY[8] = syssnd_load("sounds/ent8.wav");
#endif
#ifdef IIGS
WAV_GAMEOVER = -1;
WAV_SBONUS2 = SND_SBONUS2;
WAV_BULLET = SND_BULLET;
WAV_BOMBSHHT = SND_BOMBSHHT;
WAV_EXPLODE = SND_EXPLODE;
WAV_STICK = SND_STICK;
WAV_WALK = SND_WALK;
WAV_CRAWL = SND_CRAWL;
WAV_JUMP = SND_JUMP;
WAV_PAD = SND_PAD;
WAV_BOX = SND_BOX;
WAV_BONUS = SND_BONUS;
WAV_SBONUS1 = SND_SBONUS1;
WAV_DIE = SND_DIE;
WAV_ENTITY[0] = SND_ENT0;
WAV_ENTITY[1] = SND_ENT1;
WAV_ENTITY[2] = SND_ENT2;
WAV_ENTITY[3] = SND_ENT3;
WAV_ENTITY[4] = SND_ENT4;
WAV_ENTITY[5] = SND_ENT4;
WAV_ENTITY[6] = SND_ENT6;
WAV_ENTITY[7] = SND_ENT6;
WAV_ENTITY[8] = SND_ENT8;
#endif
#endif
}
/*
*
*/
static void
freedata()
{
#ifdef ENABLE_SOUND
syssnd_stopall();
syssnd_free(WAV_GAMEOVER);
syssnd_free(WAV_SBONUS2);
syssnd_free(WAV_BULLET);
syssnd_free(WAV_BOMBSHHT);
syssnd_free(WAV_EXPLODE);
syssnd_free(WAV_STICK);
syssnd_free(WAV_WALK);
syssnd_free(WAV_CRAWL);
syssnd_free(WAV_JUMP);
syssnd_free(WAV_PAD);
syssnd_free(WAV_BOX);
syssnd_free(WAV_BONUS);
syssnd_free(WAV_SBONUS1);
syssnd_free(WAV_DIE);
syssnd_free(WAV_ENTITY[0]);
syssnd_free(WAV_ENTITY[1]);
syssnd_free(WAV_ENTITY[2]);
syssnd_free(WAV_ENTITY[3]);
syssnd_free(WAV_ENTITY[4]);
syssnd_free(WAV_ENTITY[5]);
syssnd_free(WAV_ENTITY[6]);
syssnd_free(WAV_ENTITY[7]);
syssnd_free(WAV_ENTITY[8]);
#endif
}
/* eof */

80
src/img_icon.e Normal file
View file

@ -0,0 +1,80 @@
#if !(defined(IIGS) || defined(F256))
static U8 IMG_ICON_PIXELS[] = {
0,0,0,0,0,0,0,0,0,
211,108,211,108,52,52,52,52,52,52,52,52,52,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,174,
92,15,188,130,130,121,148,197,197,197,148,148,177,105,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,92,
12,104,192,143,195,56,7,72,72,72,7,7,85,14,105,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,122,32,
186,7,7,104,143,195,65,7,186,7,104,56,195,51,174,52,
0,0,0,0,0,0,0,0,0,0,0,0,0,105,38,115,
134,149,149,149,13,13,13,149,166,83,31,120,13,72,168,14,
105,0,0,0,0,0,0,0,0,105,174,174,52,77,72,69,
126,21,126,126,21,21,21,126,159,195,84,139,21,12,30,122,
52,174,174,174,105,0,0,0,105,77,201,193,193,193,186,7,
104,42,42,104,104,104,42,104,104,78,42,104,104,186,193,193,
24,24,24,30,5,105,0,0,9,181,51,188,188,188,20,20,
73,73,73,73,73,73,73,73,20,73,20,20,20,73,20,20,
32,32,32,163,117,9,0,0,0,9,14,14,14,52,164,72,
72,72,72,72,72,72,72,164,12,72,164,72,72,164,164,72,
174,174,52,0,9,0,0,0,0,0,0,0,0,52,135,196,
23,193,6,23,23,23,23,23,202,193,23,23,23,23,196,135,
14,0,0,0,0,0,0,0,0,0,0,0,0,52,137,203,
151,6,127,84,98,43,19,84,159,46,127,127,127,127,162,128,
9,0,0,0,0,0,0,0,0,0,0,0,0,52,151,84,
84,84,151,151,165,170,183,208,139,126,7,7,7,7,182,174,
0,0,0,0,0,0,0,0,0,0,0,0,0,52,90,90,
90,74,88,84,165,1,93,116,91,132,161,62,96,17,204,175,
0,0,0,0,0,0,0,0,0,0,0,0,122,181,72,2,
74,157,54,88,53,176,152,50,4,140,67,133,33,95,34,0,
0,0,0,0,0,0,0,0,0,0,0,14,5,72,2,192,
143,111,74,12,87,145,11,35,94,165,84,84,84,7,148,58,
0,0,0,0,0,0,0,0,0,0,0,52,197,72,104,195,
195,65,193,72,98,137,142,158,138,142,84,84,84,39,59,52,
0,0,0,0,0,0,0,0,0,0,105,181,163,72,193,83,
195,143,192,101,44,68,87,151,84,84,84,208,114,86,178,52,
0,0,0,0,0,0,0,0,0,118,52,164,72,72,184,112,
111,195,56,104,72,69,21,84,151,151,151,139,21,12,197,52,
0,0,0,0,0,0,0,0,0,118,174,72,72,12,72,184,
193,18,171,104,72,22,114,180,129,145,110,53,81,181,122,0,
0,0,0,0,0,0,0,0,0,89,52,12,12,72,164,12,
12,193,7,7,90,150,84,87,141,136,131,28,122,52,0,0,
0,0,0,0,0,0,0,0,0,89,174,72,72,72,72,72,
164,54,57,7,208,84,151,151,159,186,7,74,164,117,0,0,
0,0,0,0,0,0,0,0,0,118,14,154,115,113,92,92,
92,72,54,153,84,84,84,84,88,2,2,190,30,30,27,0,
0,0,0,0,0,0,0,0,0,187,52,24,149,126,141,82,
179,72,184,107,172,47,47,23,22,72,80,66,70,30,197,160,
211,52,0,0,0,0,0,0,0,0,187,177,85,134,21,21,
21,164,74,104,143,13,126,72,30,191,35,152,11,211,102,176,
124,160,14,0,0,0,0,0,0,0,0,118,17,80,71,71,
71,92,200,10,41,97,205,12,209,165,125,35,1,173,11,35,
165,124,75,105,0,0,0,0,0,0,0,0,118,52,52,52,
108,108,173,176,11,11,165,72,109,165,11,94,123,64,35,35,
11,165,3,174,0,0,0,0,0,0,0,0,0,0,14,160,
124,64,183,26,170,94,11,14,102,165,165,165,94,35,100,106,
124,191,14,0,0,0,0,0,0,0,0,0,0,105,206,36,
11,183,147,76,152,49,3,105,105,167,11,165,165,189,199,165,
3,211,0,0,0,0,0,0,0,0,0,0,52,211,124,165,
156,26,103,123,48,174,52,0,118,52,167,165,11,165,165,191,
52,0,0,0,0,0,0,0,0,0,0,211,211,155,11,125,
123,35,125,165,52,58,0,0,0,89,52,3,124,165,167,14,
0,0,0,0,0,0,0,0,0,0,0,0,70,167,165,199,
45,103,16,125,75,48,58,0,0,0,89,14,191,191,52,58,
0,0,0,0,0,0,0,0,0,0,0,0,0,14,11,11,
1,147,103,123,11,167,52,0,0,0,0,194,14,52,194,0,
0,0,0,0,0,0,0,};
static img_color_t IMG_ICON_COLORS[] = {
{0,0,0,0},{90,94,92,0},{94,46,4,0},{46,50,44,0},{138,142,140,0},{50,34,20,0},{178,98,36,0},{142,70,4,0},{198,122,100,0},{0,0,0,0},{98,74,44,0},{74,74,76,0},{74,38,4,0},{198,106,44,0},{30,38,28,0},{74,50,20,0},{114,118,116,0},{50,42,28,0},{166,82,4,0},{214,142,116,0},{118,58,4,0},{178,110,108,0},{146,82,44,0},{222,130,92,0},{134,70,4,0},{138,94,84,0},{174,178,172,0},{42,38,20,0},{74,70,52,0},{0,0,0,0},{66,34,4,0},{190,102,44,0},{98,58,12,0},{174,142,132,0},{38,30,20,0},{102,106,100,0},{58,62,60,0},{82,86,84,0},{66,42,12,0},{170,98,76,0},{202,114,68,0},{126,86,44,0},{150,78,12,0},{202,130,108,0},{90,50,20,0},{130,130,132,0},{154,82,36,0},{238,138,100,0},{42,46,44,0},{54,58,52,0},{154,158,156,0},{58,34,12,0},{30,34,28,0},{110,86,76,0},{86,42,4,0},{38,38,28,0},{178,90,4,0},{130,66,4,0},{18,22,20,0},{102,66,52,0},{0,0,0,0},{122,94,84,0},{158,146,132,0},{174,98,52,0},{78,82,76,0},{210,106,4,0},{58,42,28,0},{198,170,156,0},{190,114,92,0},{122,70,52,0},{42,42,36,0},{86,62,60,0},{70,34,4,0},{114,58,4,0},{110,54,4,0},{54,54,52,0},{146,150,148,0},{50,38,20,0},{150,74,4,0},{214,122,68,0},{78,46,12,0},{74,58,52,0},{50,46,36,0},{174,86,4,0},{246,142,100,0},{122,66,4,0},{150,90,76,0},{230,134,100,0},{166,94,52,0},{18,18,20,0},{106,58,20,0},{170,154,148,0},{46,34,20,0},{110,114,108,0},{90,90,92,0},{66,46,20,0},{142,130,116,0},{118,86,68,0},{190,118,92,0},{0,0,0,0},{98,102,100,0},{102,50,4,0},{50,54,52,0},{142,146,140,0},{146,74,4,0},{26,30,28,0},{74,78,76,0},{82,42,4,0},{34,38,28,0},{70,54,36,0},{146,118,100,0},{170,86,4,0},{126,62,4,0},{142,82,68,0},{226,134,100,0},{134,70,20,0},{190,174,164,0},{46,38,20,0},{14,18,12,0},{62,38,4,0},{194,106,44,0},{102,62,20,0},{38,34,28,0},{106,110,108,0},{66,66,68,0},{86,90,84,0},{174,106,100,0},{214,118,68,0},{126,82,76,0},{158,106,92,0},{118,70,20,0},{110,102,84,0},{150,138,140,0},{186,158,148,0},{158,90,52,0},{162,98,92,0},{86,70,60,0},{198,118,100,0},{210,130,100,0},{214,126,100,0},{122,122,124,0},{134,86,84,0},{206,126,100,0},{218,110,4,0},{130,70,36,0},{118,90,84,0},{150,86,52,0},{178,182,180,0},{86,54,20,0},{158,86,44,0},{178,102,60,0},{250,146,108,0},{94,98,92,0},{98,50,4,0},{122,62,4,0},{62,66,60,0},{134,134,132,0},{90,46,4,0},{214,134,100,0},{198,110,52,0},{38,42,36,0},{170,158,140,0},{170,102,76,0},{58,38,12,0},{70,38,4,0},{70,70,68,0},{166,86,20,0},{50,50,52,0},{54,34,12,0},{26,26,28,0},{106,106,108,0},{154,78,4,0},{242,138,92,0},{58,58,60,0},{34,34,28,0},{10,10,12,0},{82,82,84,0},{46,42,28,0},{90,62,52,0},{54,46,44,0},{194,118,100,0},{42,34,20,0},{90,54,12,0},{142,142,140,0},{78,38,4,0},{54,42,28,0},{138,70,4,0},{14,14,12,0},{102,58,12,0},{86,86,84,0},{70,42,12,0},{46,46,44,0},{182,90,4,0},{134,66,4,0},{22,22,20,0},{214,106,4,0},{194,114,92,0},{54,38,20,0},{0,0,0,0},{78,78,76,0},{74,54,36,0},{66,38,4,0},{178,98,44,0},{222,130,100,0},{42,38,28,0},{110,86,84,0},{38,38,36,0},{174,98,60,0},{246,142,108,0},{66,46,28,0},{146,74,12,0},{34,38,36,0},{194,106,52,0},{154,78,12,0},{242,138,100,0},{34,34,36,0},};
static img_t IMG_ICON_OBJECT = {
32, 32,
216,
IMG_ICON_COLORS,
IMG_ICON_PIXELS
};
img_t *IMG_ICON = &IMG_ICON_OBJECT;
#endif

4023
src/img_splash.e Normal file

File diff suppressed because it is too large Load diff

233
src/maps.c Normal file
View file

@ -0,0 +1,233 @@
/*
* xrick/src/maps.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
/*
* NOTES
*
* A map is composed of submaps, which in turn are composed of rows of
* 0x20 tiles. map_map contains the tiles for the current portion of the
* current submap, i.e. a little bit more than what appear on the screen,
* but not the whole submap.
*
* map_frow is map_map top row within the submap.
*
* Submaps are stored as arrays of blocks, each block being a 4x4 tile
* array. map_submaps[].bnum points to the first block of the array.
*
* Before a submap can be played, it needs to be expanded from blocks
* to map_map.
*/
#include "system.h"
#include "game.h"
#include "maps.h"
#include "debug.h"
#include "ents.h"
#include "draw.h"
#include "screens.h"
#include "e_sbonus.h"
#ifdef IIGS
#pragma noroot
#endif
/*
* global vars
*/
U8 map_map[0x2C][0x20];
U8 map_eflg[0x100];
U16 map_frow;
U16 map_tilesBank;
/*
* prototypes
*/
static void map_eflg_expand(U8);
/*
* Fill in map_map with tile numbers by expanding blocks.
*
* add map_submaps[].bnum to map_frow to find out where to start from.
* We need to /4 map_frow to convert from tile rows to block rows, then
* we need to *8 to convert from block rows to block numbers (there
* are 8 blocks per block row). This is achieved by *2 then &0xfff8.
*/
void
map_expand(void)
{
U16 i, j, k, l;
U16 col;
U16 pbnum;
U8* pMap_map = &map_map[0][0];
U8* pBlock;
pbnum = map_submaps[game_submap].bnum + ((2 * map_frow) & 0xfff8);
col = 0;
for (i = 0; i < 0x0b; i++)
{ /* 0x0b rows of blocks */
for (j = 0; j < 0x08; j++)
{ /* 0x08 blocks per row */
pBlock = &map_blocks[map_bnums[pbnum]][0];
for (k = 0, l = 0; k < 0x04; k++)
{ /* expand one block */
pMap_map[col++] = pBlock[l++];
pMap_map[col++] = pBlock[l++];
pMap_map[col++] = pBlock[l++];
pMap_map[col] = pBlock[l++];
pMap_map+=32; col -= 3;
}
pMap_map -= (128); col += 4;
pbnum++;
}
pMap_map += 128; col = 0;
}
}
/*
* Initialize a new submap
*
* ASM 0cc3
*/
void
map_init(void)
{
/*sys_printf("xrick/map_init: map=%#04x submap=%#04x\n", g_map, game_submap);*/
#ifdef GFXPC
draw_filter = 0xffff;
map_tilesBank = (map_submaps[game_submap].page == 1) ? 3 : 2;
#endif
#ifdef GFXST
map_tilesBank = (map_submaps[game_submap].page == 1) ? 2 : 1;
#endif
#ifdef GFXGS
map_tilesBank = (map_submaps[game_submap].page == 1) ? 0x200 : 0x100;
#endif
map_eflg_expand((map_submaps[game_submap].page == 1) ? 0x10 : 0x00);
map_expand();
ent_reset();
ent_actvis(map_frow + MAP_ROW_SCRTOP, map_frow + MAP_ROW_SCRBOT);
ent_actvis(map_frow + MAP_ROW_HTTOP, map_frow + MAP_ROW_HTBOT);
ent_actvis(map_frow + MAP_ROW_HBTOP, map_frow + MAP_ROW_HBBOT);
}
/*
* Expand entity flags for this map
*
* ASM 1117
*/
void
map_eflg_expand(U8 offs)
{
U8 i, j, k;
for (i = 0, k = 0; i < 0x10; i++) {
j = map_eflg_c[offs + i++];
while (j--) map_eflg[k++] = map_eflg_c[offs + i];
}
}
/*
* Chain (sub)maps
*
* ASM 0c08
* return: TRUE/next submap OK, FALSE/map finished
*/
U8
map_chain(void)
{
U16 c, t;
game_chsm = 0;
e_sbonus_counting = FALSE;
/* find connection */
c = map_submaps[game_submap].connect;
t = 3;
IFDEBUG_MAPS(
sys_printf("xrick/maps: chain submap=%#04x frow=%#04x .connect=%#04x %s\n",
game_submap, map_frow, c,
(game_dir == LEFT ? "-> left" : "-> right"));
);
/*
* look for the first connector with compatible row number. if none
* found, then panic
*/
for (c = map_submaps[game_submap].connect; ; c++) {
if (map_connect[c].dir == 0xff)
sys_panic("(map_chain) can not find connector\n");
if (map_connect[c].dir != game_dir) continue;
t = (ent_ents[1].y >> 3) + map_frow - map_connect[c].rowout;
if (t < 3) break;
}
/* got it */
IFDEBUG_MAPS(
sys_printf("xrick/maps: chain frow=%#04x y=%#06x\n",
map_frow, ent_ents[1].y);
sys_printf("xrick/maps: chain connect=%#04x rowout=%#04x - ",
c, map_connect[c].rowout);
);
if (map_connect[c].submap == 0xff) {
/* no next submap - request next map */
IFDEBUG_MAPS(
sys_printf("chain to next map\n");
);
return FALSE;
}
else {
/* next submap */
IFDEBUG_MAPS(
sys_printf("chain to submap=%#04x rowin=%#04x\n",
map_connect[c].submap, map_connect[c].rowin);
);
map_frow = map_frow - map_connect[c].rowout + map_connect[c].rowin;
game_submap = map_connect[c].submap;
IFDEBUG_MAPS(
sys_printf("xrick/maps: chain frow=%#04x\n",
map_frow);
);
return TRUE;
}
}
/*
* Reset all marks, i.e. make them all active again.
*
* ASM 0025
*
*/
void
map_resetMarks(void)
{
U16 i;
for (i = 0; i < MAP_NBR_MARKS; i++)
map_marks[i].ent &= ~MAP_MARK_NACT;
}
/* eof */

54
src/rects.c Normal file
View file

@ -0,0 +1,54 @@
/*
* xrick/src/rects.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include <stdlib.h> /* malloc */
#include "system.h"
#include "rects.h"
#ifdef IIGS
#pragma noroot
#endif
/*
* Free a list of rectangles and set the pointer to NULL.
*
* p: rectangle list CHANGED to NULL
*/
void
rects_free(rect_t *r) {
if (r) {
rects_free(r->next);
free(r);
}
}
/*
* Add a rectangle to a list of rectangles
*/
rect_t *
rects_new(U16 x, U16 y, U16 width, U16 height, rect_t *next)
{
rect_t *r;
r = malloc(sizeof *r);
r->x = x;
r->y = y;
r->width = width;
r->height = height;
r->next = next;
return r;
}
/* eof */

15
src/resource.h Normal file
View file

@ -0,0 +1,15 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by xrick.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

28
src/scr_credit.c Normal file
View file

@ -0,0 +1,28 @@
//
// Early Splash Screen, on the GS Version
// Since it takes a while to initialize
//
#include "system.h"
#include "game.h"
#ifdef IIGS
segment "screen";
#pragma noroot
#include <Memory.h>
#endif
extern char credits_lz4;
void scr_credit()
{
#ifdef IIGS
// Keep the Screen on
*VIDEO_REGISTER|=0xC0;
// Blank the screen, so you don't see trash in the Frame Buffer
memset((void*)0xE19E00, (int)0, (size_t)32);
memset((void*)0xE19D00, (int)0, (size_t)200);
// Display the Credits
LZ4_Unpack((char*)(0xE12000), &credits_lz4);
#endif
}

108
src/scr_gameover.c Normal file
View file

@ -0,0 +1,108 @@
/*
* xrick/src/scr_gameover.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "stddef.h" /* NULL */
#include "system.h"
#include "game.h"
#include "screens.h"
#include "draw.h"
#include "control.h"
#ifdef IIGS
#pragma noroot
segment "screen";
#endif
/*
* Display the game over screen
*
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
*/
U8
screen_gameover(void)
{
static U8 seq = 0;
static U8 period = 0;
#if defined(GFXST) || defined(GFXGS)
static U32 tm = 0;
#endif
#ifdef ENABLE_SOUND
static sound_t *snd;
static U8 chan;
#endif
if (seq == 0) {
draw_tilesBank = 0;
seq = 1;
period = game_period; /* save period, */
game_period = 50; /* and use our own */
#ifdef ENABLE_SOUND
#if !(defined(IIGS) || defined(F256))
game_setmusic("sounds/gameover.wav", 1);
#endif
#endif
}
switch (seq) {
case 1: /* display banner */
#if defined(GFXST) || defined(GFXGS)
sysvid_clear();
tm = sys_gettime();
#endif
draw_tllst = screen_gameovertxt;
draw_setfb(120, 80);
#ifdef GFXPC
draw_filter = 0xAAAA;
#endif
draw_tilesList();
game_rects = &draw_SCREENRECT;
seq = 2;
break;
case 2: /* wait for key pressed */
if (control_status & CONTROL_FIRE)
seq = 3;
#if (defined GFXST) || (defined GFXGS)
else if (sys_gettime() - tm > SCREEN_TIMEOUT)
seq = 4;
#endif
else
sys_sleep(50);
break;
case 3: /* wait for key released */
if (!(control_status & CONTROL_FIRE))
seq = 4;
else
sys_sleep(50);
break;
}
if (control_status & CONTROL_EXIT) /* check for exit request */
return SCREEN_EXIT;
if (seq == 4) { /* we're done */
sysvid_clear();
seq = 0;
game_period = period;
return SCREEN_DONE;
}
return SCREEN_RUNNING;
}
/* eof */

280
src/scr_getname.c Normal file
View file

@ -0,0 +1,280 @@
/*
* xrick/src/scr_getname.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#include "screens.h"
#include "draw.h"
#include "control.h"
#ifdef IIGS
#pragma noroot
segment "screen";
#endif
/*
* local vars
*/
static U8 seq = 0;
static U8 x, y, p;
static U8 name[10];
#define TILE_POINTER '\072'
#define TILE_CURSOR '\073'
#define TOPLEFT_X 116
#define TOPLEFT_Y 64
#define NAMEPOS_X 120
#define NAMEPOS_Y 160
#define AUTOREPEAT_TMOUT 100
/*
* prototypes
*/
static void pointer_show(U8);
static void name_update(void);
static void name_draw(void);
/*
* Get name
*
* return: 0 while running, 1 when finished.
*/
U8
screen_getname(void)
{
static U32 tm = 0;
U8 i, j;
if (seq == 0) {
/* figure out if this is a high score */
if (game_score < game_hscores[7].score)
return SCREEN_DONE;
/* prepare */
draw_tilesBank = 0;
#ifdef GFXPC
draw_filter = 0xffff;
#endif
for (i = 0; i < 10; i++)
name[i] = '@';
x = y = p = 0;
game_rects = &draw_SCREENRECT;
seq = 1;
}
switch (seq) {
case 1: /* prepare screen */
sysvid_clear();
#ifdef GFXPC
draw_setfb(32, 8);
draw_filter = 0xaaaa; /* red */
draw_tilesListImm(screen_congrats);
#endif
draw_setfb(76, 40);
#ifdef GFXPC
draw_filter = 0xffff; /* yellow */
#endif
draw_tilesListImm((U8 *)"PLEASE@ENTER@YOUR@NAME\376");
#ifdef GFXPC
draw_filter = 0x5555; /* green */
#endif
for (i = 0; i < 6; i++)
for (j = 0; j < 4; j++) {
draw_setfb(TOPLEFT_X + i * 8 * 2, TOPLEFT_Y + j * 8 * 2);
draw_tile('A' + i + j * 6);
}
draw_setfb(TOPLEFT_X, TOPLEFT_Y + 64);
#if defined(GFXST)||defined(GFXGS)
draw_tilesListImm((U8 *)"Y@Z@.@@@\074\373\374\375\376");
#endif
#ifdef GFXPC
draw_tilesListImm((U8 *)"Y@Z@.@@@\074@\075@\376");
#endif
name_draw();
pointer_show(TRUE);
seq = 2;
break;
case 2: /* wait for key pressed */
if (control_status & CONTROL_FIRE)
seq = 3;
if (control_status & CONTROL_UP) {
if (y > 0) {
pointer_show(FALSE);
y--;
pointer_show(TRUE);
tm = sys_gettime();
}
seq = 4;
}
if (control_status & CONTROL_DOWN) {
if (y < 4) {
pointer_show(FALSE);
y++;
pointer_show(TRUE);
tm = sys_gettime();
}
seq = 5;
}
if (control_status & CONTROL_LEFT) {
if (x > 0) {
pointer_show(FALSE);
x--;
pointer_show(TRUE);
tm = sys_gettime();
}
seq = 6;
}
if (control_status & CONTROL_RIGHT) {
if (x < 5) {
pointer_show(FALSE);
x++;
pointer_show(TRUE);
tm = sys_gettime();
}
seq = 7;
}
if (seq == 2)
sys_sleep(50);
break;
case 3: /* wait for FIRE released */
if (!(control_status & CONTROL_FIRE)) {
if (x == 5 && y == 4) { /* end */
i = 0;
while (game_score < game_hscores[i].score)
i++;
j = 7;
while (j > i) {
game_hscores[j].score = game_hscores[j - 1].score;
for (x = 0; x < 10; x++)
game_hscores[j].name[x] = game_hscores[j - 1].name[x];
j--;
}
game_hscores[i].score = game_score;
for (x = 0; x < 10; x++)
game_hscores[i].name[x] = name[x];
seq = 99;
}
else {
name_update();
name_draw();
seq = 2;
}
}
else
sys_sleep(50);
break;
case 4: /* wait for UP released */
if (!(control_status & CONTROL_UP) ||
sys_gettime() - tm > AUTOREPEAT_TMOUT)
seq = 2;
else
sys_sleep(50);
break;
case 5: /* wait for DOWN released */
if (!(control_status & CONTROL_DOWN) ||
sys_gettime() - tm > AUTOREPEAT_TMOUT)
seq = 2;
else
sys_sleep(50);
break;
case 6: /* wait for LEFT released */
if (!(control_status & CONTROL_LEFT) ||
sys_gettime() - tm > AUTOREPEAT_TMOUT)
seq = 2;
else
sys_sleep(50);
break;
case 7: /* wait for RIGHT released */
if (!(control_status & CONTROL_RIGHT) ||
sys_gettime() - tm > AUTOREPEAT_TMOUT)
seq = 2;
else
sys_sleep(50);
break;
}
if (control_status & CONTROL_EXIT) /* check for exit request */
return SCREEN_EXIT;
if (seq == 99) { /* seq 99, we're done */
sysvid_clear();
seq = 0;
return SCREEN_DONE;
}
else
return SCREEN_RUNNING;
}
static void
pointer_show(U8 show)
{
draw_setfb(TOPLEFT_X + x * 8 * 2, TOPLEFT_Y + y * 8 * 2 + 8);
#ifdef GFXPC
draw_filter = 0xaaaa; /* red */
#endif
draw_tile((show == TRUE)?TILE_POINTER:'@');
}
static void
name_update(void)
{
U8 i;
i = x + y * 6;
if (i < 26 && p < 10)
name[p++] = 'A' + i;
if (i == 26 && p < 10)
name[p++] = '.';
if (i == 27 && p < 10)
name[p++] = '@';
if (i == 28 && p > 0) {
p--;
}
}
static void
name_draw(void)
{
U8 i;
draw_setfb(NAMEPOS_X, NAMEPOS_Y);
#ifdef GFXPC
draw_filter = 0xaaaa; /* red */
#endif
for (i = 0; i < p; i++)
draw_tile(name[i]);
for (i = p; i < 10; i++)
draw_tile(TILE_CURSOR);
#if defined(GFXST)||defined(GFXGS)
draw_setfb(NAMEPOS_X, NAMEPOS_Y + 8);
for (i = 0; i < 10; i++)
draw_tile('@');
draw_setfb(NAMEPOS_X + 8 * (p < 9 ? p : 9), NAMEPOS_Y + 8);
draw_tile(TILE_POINTER);
#endif
}
/* eof */

203
src/scr_imain.c Normal file
View file

@ -0,0 +1,203 @@
/*
* xrick/src/scr_imain.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include <stdio.h> /* sprintf */
#include "system.h"
#include "game.h"
#include "screens.h"
#include "draw.h"
#include "pics.h"
#include "control.h"
#ifdef IIGS
#pragma noroot
segment "screen";
extern img_t splash_lz4;
extern img_t pic_haf_lz4;
#endif
/*
* Main introduction
*
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
*/
U8
screen_introMain(void)
{
static U8 seq = 0;
static U8 seen = 0;
static U8 first = TRUE;
static U8 period = 0;
static U32 tm = 0;
U8 i, s[32];
if (seq == 0) {
draw_tilesBank = 0;
if (first == TRUE)
seq = 1;
else
seq = 4;
period = game_period;
game_period = 50;
game_rects = &draw_SCREENRECT;
#ifdef ENABLE_SOUND
#ifdef IIGS
game_setmusic(&rick1_lz4, -1);
#else
game_setmusic("sounds/tune5.wav", -1);
#endif
#endif
}
switch (seq) {
case 1: /* display hall of fame */
sysvid_clear();
tm = sys_gettime();
#ifdef GFXPC
/* Rick Dangerous title */
draw_tllst = (U8 *)screen_imainrdt;
draw_setfb(32, 16);
draw_filter = 0xaaaa;
draw_tilesList();
/* Core Design copyright + press space to start */
draw_tllst = (U8 *)screen_imaincdc;
draw_setfb(64, 80);
draw_filter = 0x5555;
draw_tilesList();
#endif
#ifdef GFXST
draw_pic(0, 0, 0x140, 0xc8, pic_splash);
#endif
#ifdef GFXGS
sysvid_FadeOut();
draw_img(&splash_lz4);
PresentFrameBuffer();
PresentPalette();
sysvid_FadeIn();
#endif
seq = 2;
break;
case 2: /* wait for key pressed or timeout */
if (control_status & CONTROL_FIRE)
seq = 3;
else if (sys_gettime() - tm > SCREEN_TIMEOUT) {
seen++;
seq = 4;
}
break;
case 3: /* wait for key released */
if (!(control_status & CONTROL_FIRE)) {
if (seen++ == 0)
seq = 4;
else
seq = 7;
}
break;
case 4: /* display Rick Dangerous title and Core Design copyright */
sysvid_clear();
tm = sys_gettime();
/* hall of fame title */
#ifdef GFXPC
draw_tllst = (U8 *)screen_imainhoft;
draw_setfb(32, 0);
draw_filter = 0xaaaa;
draw_tilesList();
#endif
#ifdef GFXST
draw_pic(0, 0, 0x140, 0x20, pic_haf);
#endif
#ifdef GFXGS
sysvid_FadeOut();
PresentFrameBuffer();
draw_img(&pic_haf_lz4);
#endif
/* hall of fame content */
draw_setfb(56, 40);
#ifdef GFXPC
draw_filter = 0x5555;
#endif
for (i = 0; i < 8; i++)
{
#ifdef IIGS
sprintf((char *)s, "%06ld@@@....@@@%s\n",
game_hscores[i].score, game_hscores[i].name);
#else
sprintf((char *)s, "%06d@@@....@@@%s",
game_hscores[i].score, game_hscores[i].name);
#endif
s[26] = '\377'; s[27] = '\377'; s[28] = '\376';
draw_tllst = s;
draw_tilesList();
}
#ifdef GFXGS
PresentFrameBuffer();
sysvid_FadeIn();
#endif
seq = 5;
break;
case 5: /* wait for key pressed or timeout */
if (control_status & CONTROL_FIRE)
seq = 6;
else if (sys_gettime() - tm > SCREEN_TIMEOUT) {
seen++;
seq = 1;
}
break;
case 6: /* wait for key released */
if (!(control_status & CONTROL_FIRE)) {
if (seen++ == 0)
seq = 1;
else
seq = 7;
}
break;
}
if (control_status & CONTROL_EXIT) /* check for exit request */
return SCREEN_EXIT;
if (seq == 7) { /* we're done */
sysvid_clear();
#ifdef GFXGS
sysvid_FadeOut();
PresentFrameBuffer();
sysvid_FadeIn();
#endif
seq = 0;
seen = 0;
first = FALSE;
game_period = period;
return SCREEN_DONE;
}
else
return SCREEN_RUNNING;
}
/* eof */

316
src/scr_imap.c Normal file
View file

@ -0,0 +1,316 @@
/*
* xrick/src/scr_imap.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include <stdio.h>
#include "system.h"
#include "game.h"
#include "screens.h"
#include "rects.h"
#include "draw.h"
#include "control.h"
#include "maps.h"
#ifdef IIGS
#pragma noroot
segment "screen";
#endif
/*
* local vars
*/
static U16 step; /* current step */
static U16 count; /* number of loops for current step */
static U16 run; /* 1 = run, 0 = no more step */
static U8 flipflop; /* flipflop for top, bottom, left, right */
static U16 spnum; /* sprite number */
static U16 spx, spdx; /* sprite x position and delta */
static U16 spy, spdy; /* sprite y position and delta */
static U16 spbase, spoffs; /* base, offset for sprite numbers table */
static U8 seq = 0; /* anim sequence */
static rect_t anim_rect = { 120, 16, 64, 64, NULL }; /* anim rectangle */
/*
* prototypes
*/
static void drawtb(void);
static void drawlr(void);
static void drawsprite(void);
static void drawcenter(void);
static void nextstep(void);
static void anim(void);
static void init(void);
/*
* Map introduction
*
* ASM: 1948
*
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
*/
U8
screen_introMap(void)
{
switch (seq) {
case 0:
sysvid_clear();
#ifdef GFXPC
draw_tilesBank = 1;
draw_filter = 0xAAAA;
#endif
#if defined(GFXST)||defined(GFXGS)
draw_tilesBank = 0;
#endif
draw_tllst = screen_imaptext[game_map];
draw_setfb(32, 0);
draw_tilesSubList();
draw_setfb(32, 96);
#ifdef GFXPC
draw_filter = 0x5555;
#endif
draw_tilesList();
game_rects = NULL;
#ifdef GFXPC
draw_filter = 0xFFFF;
#endif
init();
nextstep();
drawcenter();
drawtb();
drawlr();
drawsprite();
control_last = 0;
game_rects = &draw_SCREENRECT;
#ifdef ENABLE_SOUND
game_setmusic(map_maps[game_map].tune, 1);
#endif
seq = 1;
break;
case 1: /* top and bottom borders */
drawtb();
game_rects = &anim_rect;
seq = 2;
break;
case 2: /* background and sprite */
anim();
drawcenter();
drawsprite();
game_rects = &anim_rect;
seq = 3;
break;
case 3: /* all borders */
drawtb();
drawlr();
game_rects = &anim_rect;
seq = 1;
break;
case 4: /* wait for key release */
if (!(control_status & CONTROL_FIRE))
seq = 5;
else
sys_sleep(50); /* .5s */
break;
}
if (control_status & CONTROL_FIRE) { /* end as soon as key pressed */
seq = 4;
}
if (control_status & CONTROL_EXIT) /* check for exit request */
{
#ifdef IIGS
#ifdef ENABLE_SOUND
game_stopmusic();
#endif
#endif
return SCREEN_EXIT;
}
if (seq == 5) { /* end as soon as key pressed */
#ifdef IIGS
#ifdef ENABLE_SOUND
game_stopmusic();
#endif
#endif
sysvid_clear();
seq = 0;
return SCREEN_DONE;
}
else
return SCREEN_RUNNING;
}
/*
* Display top and bottom borders (0x1B1F)
*
*/
static void
drawtb(void)
{
U8 i;
flipflop++;
if (flipflop & 0x01) {
draw_setfb(128, 16);
for (i = 0; i < 6; i++)
draw_tile(0x40);
draw_setfb(128, 72);
for (i = 0; i < 6; i++)
draw_tile(0x06);
}
else {
draw_setfb(128, 16);
for (i = 0; i < 6; i++)
draw_tile(0x05);
draw_setfb(128, 72);
for (i = 0; i < 6; i++)
draw_tile(0x40);
}
}
/*
* Display left and right borders (0x1B7C)
*
*/
static void
drawlr(void)
{
U8 i;
if (flipflop & 0x02) {
for (i = 0; i < 8; i++) {
draw_setfb(120, 16 + i * 8);
draw_tile(0x04);
draw_setfb(176, 16 + i * 8);
draw_tile(0x04);
}
}
else {
for (i = 0; i < 8; i++) {
draw_setfb(120, 16 + i * 8);
draw_tile(0x2B);
draw_setfb(176, 16 + i * 8);
draw_tile(0x2B);
}
}
}
/*
* Draw the sprite (0x19C6)
*
*/
static void
drawsprite(void)
{
draw_sprite(spnum, 128 + ((spx << 1) & 0x1C), 24 + (spy << 1));
}
/*
* Draw the background (0x1AF1)
*
*/
static void
drawcenter(void)
{
static U8 tn0[] = { 0x07, 0x5B, 0x7F, 0xA3, 0xC7 };
U8 i, j, tn;
tn = tn0[game_map];
for (i = 0; i < 6; i++) {
draw_setfb(128, (24 + 8 * i));
for (j = 0; j < 6; j++)
draw_tile(tn++);
}
}
/*
* Next Step (0x1A74)
*
*/
static void
nextstep(void)
{
if (screen_imapsteps[step].count) {
count = screen_imapsteps[step].count;
spdx = screen_imapsteps[step].dx;
spdy = screen_imapsteps[step].dy;
spbase = screen_imapsteps[step].base;
spoffs = 0;
step++;
}
else {
run = 0;
}
}
/*
* Anim (0x1AA8)
*
*/
static void
anim(void)
{
U16 i;
if (run) {
i = screen_imapsl[spbase + spoffs];
if (i == 0) {
spoffs = 0;
i = screen_imapsl[spbase];
}
spnum = i;
spoffs++;
spx += spdx;
spy += spdy;
count--;
if (count == 0)
nextstep();
}
}
/*
* Initialize (0x1A43)
*
*/
static void
init(void)
{
run = 0; run--;
step = screen_imapsofs[game_map];
spx = screen_imapsteps[step].dx;
spy = screen_imapsteps[step].dy;
step++;
spnum = 0; /* NOTE spnum in [8728] is never initialized ? */
}
/* eof */

108
src/scr_joykey.c Normal file
View file

@ -0,0 +1,108 @@
/*
* xrickgs/src/scr_joykey.c
*/
#include "system.h"
#include "game.h"
#include "screens.h"
#include "draw.h"
#include "control.h"
#include "img.h"
#ifdef IIGS
segment "screen";
#pragma noroot
#endif
extern char joys_lz4;
#define KEY_0 0x1D
#define KEY_1 0x12
#define KEY_2 0x13
#define KEY_3 0x14
#define KEY_4 0x15
#define J_KEY 0x26
#define K_KEY 0x28
extern U16 bUseJoy;
/*
* Display (J)oystick or (K)eyboard screen
*
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
*/
U8
screen_joykey(void)
{
static U16 seq = 0;
static U16 wait = 0;
U16 bChosen = 0;
if (seq == 0) {
sysvid_clearPalette();
wait_vsync();
PresentPalette();
PresentSCB();
draw_img(&joys_lz4);
PresentFrameBuffer();
wait_vsync();
PresentPalette();
PresentSCB();
seq = 1;
}
if (control_status & CONTROL_EXIT) /* check for exit request */
return SCREEN_EXIT;
if (KeyArray[ J_KEY ])
{
// Choose JoyStick
bUseJoy = 1;
bChosen = 1;
}
if (KeyArray[ K_KEY ])
{
// Choose Keyboard
bUseJoy = 0;
bChosen = 1;
}
if (KeyArray[ KEY_0 ])
{
sysarg_args_map = 0;
}
if (KeyArray[ KEY_1 ])
{
sysarg_args_map = 1;
}
if (KeyArray[ KEY_2 ])
{
sysarg_args_map = 2;
}
if (KeyArray[ KEY_3 ])
{
sysarg_args_map = 3;
}
if (bChosen) { /* we're done */
sysvid_clear();
sysvid_setGamePalette();
sysvid_clearPalette();
wait_vsync();
PresentPalette();
PresentSCB();
PresentFrameBuffer();
seq = 0;
wait = 0;
return SCREEN_DONE;
}
return SCREEN_RUNNING;
}
/* eof */

57
src/scr_pause.c Normal file
View file

@ -0,0 +1,57 @@
/*
* xrick/src/scr_pause.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include <stddef.h> /* NULL */
#include "system.h"
#include "game.h"
#include "screens.h"
#include "draw.h"
#include "control.h"
#include "ents.h"
#ifdef IIGS
#pragma noroot
segment "screen";
#endif
/*
* Display the pause indicator
*/
void
screen_pause(U8 pause)
{
if (pause == TRUE) {
draw_tilesBank = 0;
draw_tllst = screen_pausedtxt;
draw_setfb(120, 80);
#ifdef GFXPC
draw_filter = 0xAAAA;
#endif
draw_tilesList();
}
else {
#ifdef GFXPC
draw_filter = 0xFFFF;
#endif
draw_map();
ent_draw();
draw_drawStatus();
}
game_rects = &draw_SCREENRECT;
}
/* eof */

103
src/scr_xrick.c Normal file
View file

@ -0,0 +1,103 @@
/*
* xrick/src/scr_xrick.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#include "screens.h"
#include "draw.h"
#include "control.h"
#include "img.h"
#ifdef IIGS
segment "screen";
#pragma noroot
#endif
#include "img_splash.e"
/*
* Display XRICK splash screen
*
* return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
*/
U8
screen_xrick(void)
{
static U8 seq = 0;
static U8 wait = 0;
if (seq == 0) {
#ifdef GFXGS
sysvid_clearPalette();
wait_vsync();
PresentPalette();
PresentSCB();
draw_img(IMG_SPLASH);
PresentFrameBuffer();
wait_vsync();
PresentPalette();
PresentSCB();
#else
sysvid_clear();
draw_img(IMG_SPLASH);
game_rects = &draw_SCREENRECT;
#endif
seq = 1;
}
switch (seq) {
case 1: /* wait */
if (wait++ > 0x2) {
#ifdef ENABLE_SOUND
#ifdef IIGS
syssnd_play(SND_BULLET,1);
#else
game_setmusic("sounds/bullet.wav", 1);
#endif
#endif
seq = 2;
wait = 0;
}
break;
case 2: /* wait */
if (wait++ > 0x20) {
seq = 99;
wait = 0;
}
}
if (control_status & CONTROL_EXIT) /* check for exit request */
return SCREEN_EXIT;
if (seq == 99) { /* we're done */
sysvid_clear();
sysvid_setGamePalette();
#ifdef GFXGS
sysvid_clearPalette();
wait_vsync();
PresentPalette();
PresentSCB();
PresentFrameBuffer();
#endif
seq = 0;
return SCREEN_DONE;
}
return SCREEN_RUNNING;
}
/* eof */

192
src/scroller.c Normal file
View file

@ -0,0 +1,192 @@
/*
* xrick/src/scroller.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include <stdlib.h>
#include "system.h"
#include "game.h"
#include "scroller.h"
#include "debug.h"
#include "draw.h"
#include "maps.h"
#include "ents.h"
static U8 period;
#ifdef IIGS
#pragma noroot
segment "screen";
#endif
rect_t scroll_SCREENRECT = { 32, 8, 256, SYSVID_HEIGHT-8, NULL };
#ifdef F256
void* memcpy(void *dest, const void *src, unsigned short n);
#endif
/*
* Scroll up
*
*/
U8
scroll_up(void)
{
U8 i;
ent_t *pEnt;
U8* pSrc;
U8* pDst;
static U8 n = 0;
/* last call: restore */
if (n == 8) {
n = 0;
game_period = period;
return SCROLL_DONE;
}
/* first call: prepare */
if (n == 0) {
period = game_period;
game_period = SCROLL_PERIOD;
}
/* translate map */
pDst = &map_map[MAP_ROW_SCRTOP][0];
pSrc = pDst+32;
for (i = MAP_ROW_SCRTOP; i < MAP_ROW_HBBOT; i++)
{
memcpy(pDst, pSrc, (size_t)32);
pDst = pSrc;
pSrc += 32;
}
/* translate entities */
for (pEnt = ent_ents; pEnt->n != 0xFF; ++pEnt) {
if (pEnt->n) {
pEnt->ysave -= 8;
pEnt->trig_y -= 8;
pEnt->y -= 8;
if (pEnt->y & 0x8000) { /* map coord. from 0x0000 to 0x0140 */
IFDEBUG_SCROLLER(
sys_printf("xrick/scroller: entity %#04X is gone\n", i);
);
pEnt->n = 0;
}
}
}
/* display */
draw_map();
ent_draw();
// draw_drawStatus();
map_frow++;
/* loop */
if (n++ == 7) {
/* activate visible entities */
ent_actvis(map_frow + MAP_ROW_HBTOP, map_frow + MAP_ROW_HBBOT);
/* prepare map */
map_expand();
/* display */
//draw_map();
ent_draw();
// draw_drawStatus();
}
game_rects = &scroll_SCREENRECT;
return SCROLL_RUNNING;
}
/*
* Scroll down
*
*/
U8
scroll_down(void)
{
U8 i;
ent_t *pEnt;
U8* pSrc;
U8* pDst;
static U8 n = 0;
/* last call: restore */
if (n == 8) {
n = 0;
game_period = period;
return SCROLL_DONE;
}
/* first call: prepare */
if (n == 0) {
period = game_period;
game_period = SCROLL_PERIOD;
}
/* translate map */
pDst = &map_map[MAP_ROW_SCRBOT][0];
pSrc = pDst-32;
for (i = MAP_ROW_SCRBOT; i > MAP_ROW_HTTOP; i--)
{
memcpy(pDst, pSrc, (size_t)32);
pDst = pSrc;
pSrc -= 32;
}
/* translate entities */
for (pEnt = ent_ents; pEnt->n != 0xFF; ++pEnt) {
if (pEnt->n) {
pEnt->ysave += 8;
pEnt->trig_y += 8;
pEnt->y += 8;
if (pEnt->y > 0x0140) { /* map coord. from 0x0000 to 0x0140 */
IFDEBUG_SCROLLER(
sys_printf("xrick/scroller: entity %#04X is gone\n", i);
);
pEnt->n = 0;
}
}
}
/* display */
draw_map();
ent_draw();
// draw_drawStatus();
map_frow--;
/* loop */
if (n++ == 7) {
/* activate visible entities */
ent_actvis(map_frow + MAP_ROW_HTTOP, map_frow + MAP_ROW_HTBOT);
/* prepare map */
map_expand();
/* display */
//draw_map();
ent_draw();
// draw_drawStatus();
}
game_rects = &scroll_SCREENRECT;
return SCROLL_RUNNING;
}
/* eof */

232
src/sdlcodes.e Normal file
View file

@ -0,0 +1,232 @@
{"BACKSPACE" , SDLK_BACKSPACE},
{"TAB" , SDLK_TAB},
{"CLEAR" , SDLK_CLEAR},
{"RETURN" , SDLK_RETURN},
{"PAUSE" , SDLK_PAUSE},
{"ESCAPE" , SDLK_ESCAPE},
{"SPACE" , SDLK_SPACE},
{"EXCLAIM" , SDLK_EXCLAIM},
{"QUOTEDBL" , SDLK_QUOTEDBL},
{"HASH" , SDLK_HASH},
{"DOLLAR" , SDLK_DOLLAR},
{"AMPERSAND" , SDLK_AMPERSAND},
{"QUOTE" , SDLK_QUOTE},
{"LEFTPAREN" , SDLK_LEFTPAREN},
{"RIGHTPAREN" , SDLK_RIGHTPAREN},
{"ASTERISK" , SDLK_ASTERISK},
{"PLUS" , SDLK_PLUS},
{"COMMA" , SDLK_COMMA},
{"MINUS" , SDLK_MINUS},
{"PERIOD" , SDLK_PERIOD},
{"SLASH" , SDLK_SLASH},
{"0" , SDLK_0},
{"1" , SDLK_1},
{"2" , SDLK_2},
{"3" , SDLK_3},
{"4" , SDLK_4},
{"5" , SDLK_5},
{"6" , SDLK_6},
{"7" , SDLK_7},
{"8" , SDLK_8},
{"9" , SDLK_9},
{"COLON" , SDLK_COLON},
{"SEMICOLON" , SDLK_SEMICOLON},
{"LESS" , SDLK_LESS},
{"EQUALS" , SDLK_EQUALS},
{"GREATER" , SDLK_GREATER},
{"QUESTION" , SDLK_QUESTION},
{"AT" , SDLK_AT},
{"LEFTBRACKET" , SDLK_LEFTBRACKET},
{"BACKSLASH" , SDLK_BACKSLASH},
{"RIGHTBRACKET" , SDLK_RIGHTBRACKET},
{"CARET" , SDLK_CARET},
{"UNDERSCORE" , SDLK_UNDERSCORE},
{"BACKQUOTE" , SDLK_BACKQUOTE},
{"a" , SDLK_a},
{"b" , SDLK_b},
{"c" , SDLK_c},
{"d" , SDLK_d},
{"e" , SDLK_e},
{"f" , SDLK_f},
{"g" , SDLK_g},
{"h" , SDLK_h},
{"i" , SDLK_i},
{"j" , SDLK_j},
{"k" , SDLK_k},
{"l" , SDLK_l},
{"m" , SDLK_m},
{"n" , SDLK_n},
{"o" , SDLK_o},
{"p" , SDLK_p},
{"q" , SDLK_q},
{"r" , SDLK_r},
{"s" , SDLK_s},
{"t" , SDLK_t},
{"u" , SDLK_u},
{"v" , SDLK_v},
{"w" , SDLK_w},
{"x" , SDLK_x},
{"y" , SDLK_y},
{"z" , SDLK_z},
{"DELETE" , SDLK_DELETE},
{"WORLD_0" , SDLK_WORLD_0},
{"WORLD_1" , SDLK_WORLD_1},
{"WORLD_2" , SDLK_WORLD_2},
{"WORLD_3" , SDLK_WORLD_3},
{"WORLD_4" , SDLK_WORLD_4},
{"WORLD_5" , SDLK_WORLD_5},
{"WORLD_6" , SDLK_WORLD_6},
{"WORLD_7" , SDLK_WORLD_7},
{"WORLD_8" , SDLK_WORLD_8},
{"WORLD_9" , SDLK_WORLD_9},
{"WORLD_10" , SDLK_WORLD_10},
{"WORLD_11" , SDLK_WORLD_11},
{"WORLD_12" , SDLK_WORLD_12},
{"WORLD_13" , SDLK_WORLD_13},
{"WORLD_14" , SDLK_WORLD_14},
{"WORLD_15" , SDLK_WORLD_15},
{"WORLD_16" , SDLK_WORLD_16},
{"WORLD_17" , SDLK_WORLD_17},
{"WORLD_18" , SDLK_WORLD_18},
{"WORLD_19" , SDLK_WORLD_19},
{"WORLD_20" , SDLK_WORLD_20},
{"WORLD_21" , SDLK_WORLD_21},
{"WORLD_22" , SDLK_WORLD_22},
{"WORLD_23" , SDLK_WORLD_23},
{"WORLD_24" , SDLK_WORLD_24},
{"WORLD_25" , SDLK_WORLD_25},
{"WORLD_26" , SDLK_WORLD_26},
{"WORLD_27" , SDLK_WORLD_27},
{"WORLD_28" , SDLK_WORLD_28},
{"WORLD_29" , SDLK_WORLD_29},
{"WORLD_30" , SDLK_WORLD_30},
{"WORLD_31" , SDLK_WORLD_31},
{"WORLD_32" , SDLK_WORLD_32},
{"WORLD_33" , SDLK_WORLD_33},
{"WORLD_34" , SDLK_WORLD_34},
{"WORLD_35" , SDLK_WORLD_35},
{"WORLD_36" , SDLK_WORLD_36},
{"WORLD_37" , SDLK_WORLD_37},
{"WORLD_38" , SDLK_WORLD_38},
{"WORLD_39" , SDLK_WORLD_39},
{"WORLD_40" , SDLK_WORLD_40},
{"WORLD_41" , SDLK_WORLD_41},
{"WORLD_42" , SDLK_WORLD_42},
{"WORLD_43" , SDLK_WORLD_43},
{"WORLD_44" , SDLK_WORLD_44},
{"WORLD_45" , SDLK_WORLD_45},
{"WORLD_46" , SDLK_WORLD_46},
{"WORLD_47" , SDLK_WORLD_47},
{"WORLD_48" , SDLK_WORLD_48},
{"WORLD_49" , SDLK_WORLD_49},
{"WORLD_50" , SDLK_WORLD_50},
{"WORLD_51" , SDLK_WORLD_51},
{"WORLD_52" , SDLK_WORLD_52},
{"WORLD_53" , SDLK_WORLD_53},
{"WORLD_54" , SDLK_WORLD_54},
{"WORLD_55" , SDLK_WORLD_55},
{"WORLD_56" , SDLK_WORLD_56},
{"WORLD_57" , SDLK_WORLD_57},
{"WORLD_58" , SDLK_WORLD_58},
{"WORLD_59" , SDLK_WORLD_59},
{"WORLD_60" , SDLK_WORLD_60},
{"WORLD_61" , SDLK_WORLD_61},
{"WORLD_62" , SDLK_WORLD_62},
{"WORLD_63" , SDLK_WORLD_63},
{"WORLD_64" , SDLK_WORLD_64},
{"WORLD_65" , SDLK_WORLD_65},
{"WORLD_66" , SDLK_WORLD_66},
{"WORLD_67" , SDLK_WORLD_67},
{"WORLD_68" , SDLK_WORLD_68},
{"WORLD_69" , SDLK_WORLD_69},
{"WORLD_70" , SDLK_WORLD_70},
{"WORLD_71" , SDLK_WORLD_71},
{"WORLD_72" , SDLK_WORLD_72},
{"WORLD_73" , SDLK_WORLD_73},
{"WORLD_74" , SDLK_WORLD_74},
{"WORLD_75" , SDLK_WORLD_75},
{"WORLD_76" , SDLK_WORLD_76},
{"WORLD_77" , SDLK_WORLD_77},
{"WORLD_78" , SDLK_WORLD_78},
{"WORLD_79" , SDLK_WORLD_79},
{"WORLD_80" , SDLK_WORLD_80},
{"WORLD_81" , SDLK_WORLD_81},
{"WORLD_82" , SDLK_WORLD_82},
{"WORLD_83" , SDLK_WORLD_83},
{"WORLD_84" , SDLK_WORLD_84},
{"WORLD_85" , SDLK_WORLD_85},
{"WORLD_86" , SDLK_WORLD_86},
{"WORLD_87" , SDLK_WORLD_87},
{"WORLD_88" , SDLK_WORLD_88},
{"WORLD_89" , SDLK_WORLD_89},
{"WORLD_90" , SDLK_WORLD_90},
{"WORLD_91" , SDLK_WORLD_91},
{"WORLD_92" , SDLK_WORLD_92},
{"WORLD_93" , SDLK_WORLD_93},
{"WORLD_94" , SDLK_WORLD_94},
{"WORLD_95" , SDLK_WORLD_95},
{"KP0" , SDLK_KP0},
{"KP1" , SDLK_KP1},
{"KP2" , SDLK_KP2},
{"KP3" , SDLK_KP3},
{"KP4" , SDLK_KP4},
{"KP5" , SDLK_KP5},
{"KP6" , SDLK_KP6},
{"KP7" , SDLK_KP7},
{"KP8" , SDLK_KP8},
{"KP9" , SDLK_KP9},
{"KP_PERIOD" , SDLK_KP_PERIOD},
{"KP_DIVIDE" , SDLK_KP_DIVIDE},
{"KP_MULTIPLY" , SDLK_KP_MULTIPLY},
{"KP_MINUS" , SDLK_KP_MINUS},
{"KP_PLUS" , SDLK_KP_PLUS},
{"KP_ENTER" , SDLK_KP_ENTER},
{"KP_EQUALS" , SDLK_KP_EQUALS},
{"UP" , SDLK_UP},
{"DOWN" , SDLK_DOWN},
{"RIGHT" , SDLK_RIGHT},
{"LEFT" , SDLK_LEFT},
{"INSERT" , SDLK_INSERT},
{"HOME" , SDLK_HOME},
{"END" , SDLK_END},
{"PAGEUP" , SDLK_PAGEUP},
{"PAGEDOWN" , SDLK_PAGEDOWN},
{"F1" , SDLK_F1},
{"F2" , SDLK_F2},
{"F3" , SDLK_F3},
{"F4" , SDLK_F4},
{"F5" , SDLK_F5},
{"F6" , SDLK_F6},
{"F7" , SDLK_F7},
{"F8" , SDLK_F8},
{"F9" , SDLK_F9},
{"F10" , SDLK_F10},
{"F11" , SDLK_F11},
{"F12" , SDLK_F12},
{"F13" , SDLK_F13},
{"F14" , SDLK_F14},
{"F15" , SDLK_F15},
{"NUMLOCK" , SDLK_NUMLOCK},
{"CAPSLOCK" , SDLK_CAPSLOCK},
{"SCROLLOCK" , SDLK_SCROLLOCK},
{"RSHIFT" , SDLK_RSHIFT},
{"LSHIFT" , SDLK_LSHIFT},
{"RCTRL" , SDLK_RCTRL},
{"LCTRL" , SDLK_LCTRL},
{"RALT" , SDLK_RALT},
{"LALT" , SDLK_LALT},
{"RMETA" , SDLK_RMETA},
{"LMETA" , SDLK_LMETA},
{"LSUPER" , SDLK_LSUPER},
{"RSUPER" , SDLK_RSUPER},
{"MODE" , SDLK_MODE},
{"COMPOSE" , SDLK_COMPOSE},
{"HELP" , SDLK_HELP},
{"PRINT" , SDLK_PRINT},
{"SYSREQ" , SDLK_SYSREQ},
{"BREAK" , SDLK_BREAK},
{"MENU" , SDLK_MENU},
{"POWER" , SDLK_POWER},
{"EURO" , SDLK_EURO},
{"NULL", 0}

251
src/sysarg.c Normal file
View file

@ -0,0 +1,251 @@
/*
* xrick/src/sysarg.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
/*
* 20021010 added test to prevent buffer overrun in -keys parsing.
*/
#ifdef IIGS
#pragma noroot
#endif
#include <stdlib.h> /* atoi */
#include <string.h> /* strcasecmp */
#if !(defined(IIGS) || defined(F256))
#include <SDL.h>
#endif
#include "system.h"
#include "config.h"
#include "game.h"
#include "maps.h"
#include "syssnd.h"
/* handle Microsoft Visual C (must come after system.h!) */
#ifdef __MSVC__
#define strcasecmp stricmp
#endif
typedef struct {
char name[16];
int code;
} sdlcodes_t;
#if !(defined(IIGS) || defined(F256))
static sdlcodes_t sdlcodes[SDLK_LAST] = {
#include "sdlcodes.e"
};
#endif
int sysarg_args_period = 0;
int sysarg_args_map = 0;
int sysarg_args_submap = 0;
int sysarg_args_fullscreen = 0;
int sysarg_args_zoom = 0;
int sysarg_args_nosound = 0;
int sysarg_args_vol = 0;
char *sysarg_args_data = NULL;
#ifdef IIGS
segment "system";
#endif
/*
* Fail
*/
void
sysarg_fail(char *msg)
{
#ifdef ENABLE_SOUND
printf("xrick [version #%s]: %s\nusage: xrick [<options>]\n<option> =\n -h, -help : Display this information. -fullscreen : Run in fullscreen mode.\n The default is to run in a window.\n -speed <speed> : Run at speed <speed>. Speed must be an integer between 1\n (fast) and 100 (slow). The default is %d\n -zoom <zoom> : Display with zoom factor <zoom>. <zoom> must be an integer\n between 1 (320x200) and %d (%d times bigger). The default is 2.\n -map <map> : Start at map number <map>. <map> must be an integer between\n 1 and %d. The default is to start at map number 1\n -submap <submap> : Start at submap <submap>. <submap> must be an integer\n between 1 and %d. The default is to start at submap number 1 or, if a map\n was specified, at the first submap of that map.\n -keys <left>-<right>-<up>-<down>-<fire> : Override the default key\n bindings (cf. KeyCodes)\n -nosound : Disable sounds. The default is to play with sounds enabled.\n -vol <vol> : Play sounds at volume <vol>. <vol> must be an integer\n between 0 (silence) and %d (max). The default is to play sounds\n at maximal volume (%d).\n", VERSION, msg, GAME_PERIOD, SYSVID_MAXZOOM, SYSVID_MAXZOOM, MAP_NBR_MAPS-1, MAP_NBR_SUBMAPS, SYSSND_MAXVOL, SYSSND_MAXVOL);
#else
printf("xrick [version #%s]: %s\nusage: xrick [<options>]\n<option> =\n -h, -help : Display this information. -fullscreen : Run in fullscreen mode.\n The default is to run in a window.\n -speed <speed> : Run at speed <speed>. Speed must be an integer between 1\n (fast) and 100 (slow). The default is %d\n -zoom <zoom> : Display with zoom factor <zoom>. <zoom> must be an integer\n between 1 (320x200) and %d (%d times bigger). The default is 2.\n -map <map> : Start at map number <map>. <map> must be an integer between\n 1 and %d. The default is to start at map number 1\n -submap <submap> : Start at submap <submap>. <submap> must be an integer\n between 1 and %d. The default is to start at submap number 1 or, if a map\n was specified, at the first submap of that map.\n -keys <left>-<right>-<up>-<down>-<fire> : Override the default key\n bindings (cf. KeyCodes)\n", VERSION, msg, GAME_PERIOD, SYSVID_MAXZOOM, SYSVID_MAXZOOM, MAP_NBR_MAPS-1, MAP_NBR_SUBMAPS);
#endif
exit(1);
}
#if !(defined(IIGS) || defined(F256))
/*
* Get SDL key code
*/
static int
sysarg_sdlcode(char *k)
{
int i, result;
i = 0;
result = 0;
while (sdlcodes[i].code) {
if (!strcasecmp(sdlcodes[i].name, k)) {
result = sdlcodes[i].code;
break;
}
i++;
}
return result;
}
#endif
/*
* Scan key codes sequence
*/
int
sysarg_scankeys(char *keys)
{
#if !(defined(IIGS) || defined(F256))
char k[16];
int i, j;
i = 0;
j = 0;
while (keys[i] != '\0' && keys[i] != '-' && j + 1 < sizeof k) k[j++] = keys[i++];
if (keys[i++] == '\0') return -1;
k[j] = '\0';
syskbd_left = sysarg_sdlcode(k);
if (!syskbd_left) return -1;
j = 0;
while (keys[i] != '\0' && keys[i] != '-' && j + 1 < sizeof k) k[j++] = keys[i++];
if (keys[i++] == '\0') return -1;
k[j] = '\0';
syskbd_right = sysarg_sdlcode(k);
if (!syskbd_right) return -1;
j = 0;
while (keys[i] != '\0' && keys[i] != '-' && j + 1 < sizeof k) k[j++] = keys[i++];
if (keys[i++] == '\0') return -1;
k[j] = '\0';
syskbd_up = sysarg_sdlcode(k);
if (!syskbd_up) return -1;
j = 0;
while (keys[i] != '\0' && keys[i] != '-' && j + 1 < sizeof k) k[j++] = keys[i++];
if (keys[i++] == '\0') return -1;
k[j] = '\0';
syskbd_down = sysarg_sdlcode(k);
if (!syskbd_down) return -1;
j = 0;
while (keys[i] != '\0' && keys[i] != '-' && j + 1 < sizeof k) k[j++] = keys[i++];
if (keys[i] != '\0') return -1;
k[j] = '\0';
syskbd_fire = sysarg_sdlcode(k);
if (!syskbd_fire) return -1;
#endif
return 0;
}
/*
* Read and process arguments
*/
void
sysarg_init(int argc, char **argv)
{
int i;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-fullscreen")) {
sysarg_args_fullscreen = 1;
}
else if (!strcmp(argv[i], "-help") ||
!strcmp(argv[i], "-h")) {
sysarg_fail("help");
}
else if (!strcmp(argv[i], "-speed")) {
if (++i == argc) sysarg_fail("missing speed value");
sysarg_args_period = atoi(argv[i]) - 1;
if (sysarg_args_period < 0 || sysarg_args_period > 99)
sysarg_fail("invalid speed value");
}
else if (!strcmp(argv[i], "-keys")) {
if (++i == argc) sysarg_fail("missing key codes");
if (sysarg_scankeys(argv[i]) == -1)
sysarg_fail("invalid key codes");
}
else if (!strcmp(argv[i], "-zoom")) {
if (++i == argc) sysarg_fail("missing zoom value");
sysarg_args_zoom = atoi(argv[i]);
if (sysarg_args_zoom < 1 || sysarg_args_zoom > SYSVID_MAXZOOM)
sysarg_fail("invalid zoom value");
}
else if (!strcmp(argv[i], "-map")) {
if (++i == argc) sysarg_fail("missing map number");
sysarg_args_map = atoi(argv[i]) - 1;
if (sysarg_args_map < 0 || sysarg_args_map >= MAP_NBR_MAPS-1)
sysarg_fail("invalid map number");
}
else if (!strcmp(argv[i], "-submap")) {
if (++i == argc) sysarg_fail("missing submap number");
sysarg_args_submap = atoi(argv[i]) - 1;
if (sysarg_args_submap < 0 || sysarg_args_submap >= MAP_NBR_SUBMAPS)
sysarg_fail("invalid submap number");
}
#ifdef ENABLE_SOUND
else if (!strcmp(argv[i], "-vol")) {
if (++i == argc) sysarg_fail("missing volume");
sysarg_args_vol = atoi(argv[i]) - 1;
if (sysarg_args_submap < 0 || sysarg_args_submap >= SYSSND_MAXVOL)
sysarg_fail("invalid volume");
}
else if (!strcmp(argv[i], "-nosound")) {
sysarg_args_nosound = 1;
}
#endif
else if (!strcmp(argv[i], "-data")) {
if (++i == argc) sysarg_fail("missing data");
sysarg_args_data = argv[i];
}
else {
sysarg_fail("invalid argument(s)");
}
}
/* this is dirty (sort of) */
if (sysarg_args_submap > 0 && sysarg_args_submap < 9)
sysarg_args_map = 0;
if (sysarg_args_submap >= 9 && sysarg_args_submap < 20)
sysarg_args_map = 1;
if (sysarg_args_submap >= 20 && sysarg_args_submap < 38)
sysarg_args_map = 2;
if (sysarg_args_submap >= 38)
sysarg_args_map = 3;
if (sysarg_args_submap == 9 ||
sysarg_args_submap == 20 ||
sysarg_args_submap == 38)
sysarg_args_submap = 0;
}
/* eof */

524
src/sysevt.c Normal file
View file

@ -0,0 +1,524 @@
/*
* xrick/src/sysevt.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
/*
* 20021010 SDLK_n replaced by SDLK_Fn because some non-US keyboards
* requires that SHIFT be pressed to input numbers.
*/
#if !(defined(IIGS) || defined(F256))
#include <SDL.h>
#endif
#include "system.h"
#include "config.h"
#include "game.h"
#include "debug.h"
#include "control.h"
#include "draw.h"
#define SYSJOY_RANGE 3280
#define SETBIT(x,b) x |= (b)
#define CLRBIT(x,b) x &= ~(b)
#if !(defined(IIGS) || defined(F256))
static SDL_Event event;
#endif
#ifdef IIGS
segment "system";
#pragma noroot
#define LARROW 0x3B
#define RARROW 0x3C
#define DARROW 0x3D
#define UARROW 0x3E
#define SPACEBAR 0x31
#define ESC 0x35
#define Z_KEY 0x06
#define Q_KEY 0x0C
#define A_KEY 0x00
#define S_KEY 0x01
#define D_KEY 0x02
#define W_KEY 0x0D
#define I_KEY 0x22
#define J_KEY 0x26
#define K_KEY 0x28
#define L_KEY 0x25
#define KEY_1 0x12
#define KEY_2 0x13
#define KEY_3 0x14
#define KEY_4 0x15
#define KEY_5 0x17
#define KEY_6 0x16
#define KEY_7 0x1A
#define KEY_8 0x1C
#define KEY_9 0x19
#define KEY_0 0x1D
// If the IIGs, we just automatically support all the things
void ReadPaddles();
extern U16 paddle0;
extern U16 paddle1;
extern U16 paddle_button0;
U16 bUseJoy = 0;
#define TOLERANCE 48
#define JOY_LEFT (128-TOLERANCE)
#define JOY_RIGHT (128+TOLERANCE)
#define JOY_UP (128-TOLERANCE)
#define JOY_DOWN (128+TOLERANCE)
int last_key7 = 0;
int last_key8 = 0;
int last_key9 = 0;
#endif
/*
* Process an event
*/
static void
processEvent()
{
#ifdef IIGS
#if 0
int x;
for (x = 0; x < 128; ++x)
{
if (KeyArray[ x ])
{
printf("Key %d\n", x);
}
}
#endif
#if 0
U8* pScreen = (U8*)0x400;
int idx;
while (1)
{
for (idx = 0; idx < 128; ++idx)
{
pScreen[idx] = KeyArray[idx];
}
}
#endif
control_status = 0;
if (bUseJoy)
{
ReadPaddles();
if (paddle0 <= JOY_LEFT)
{
control_status |= CONTROL_LEFT;
if (!(control_last & CONTROL_LEFT))
control_last |= CONTROL_LEFT;
}
else
{
control_last &= ~CONTROL_LEFT;
}
if (paddle0 >= JOY_RIGHT)
{
control_status |= CONTROL_RIGHT;
if (!(control_last & CONTROL_RIGHT))
control_last |= CONTROL_RIGHT;
}
else
{
control_last &= ~CONTROL_RIGHT;
}
if (paddle1 <= JOY_UP)
{
control_status |= CONTROL_UP;
if (!(control_last & CONTROL_UP))
control_last |= CONTROL_UP;
}
else
{
control_last &= ~CONTROL_UP;
}
if (paddle1 >= JOY_DOWN)
{
control_status |= CONTROL_DOWN;
if (!(control_last & CONTROL_DOWN))
control_last |= CONTROL_DOWN;
}
else
{
control_last &= ~CONTROL_DOWN;
}
if (paddle_button0 >= 128)
{
control_status |= CONTROL_FIRE;
if (!(control_last & CONTROL_FIRE))
{
control_last |= CONTROL_FIRE;
}
}
else
{
control_last &= ~CONTROL_FIRE;
}
}
else
{
// ADB Keyboard Driver
if (KeyArray[ A_KEY ] || KeyArray[ J_KEY ])
{
control_status |= CONTROL_LEFT;
if (!(control_last & CONTROL_LEFT))
{
control_last |= CONTROL_LEFT;
KeyArray[ D_KEY ] = 0;
KeyArray[ L_KEY ] = 0;
}
}
else
{
control_last &= ~CONTROL_LEFT;
}
if (KeyArray[ D_KEY ] || KeyArray[ L_KEY ])
{
control_status |= CONTROL_RIGHT;
if (!(control_last & CONTROL_RIGHT))
{
control_last |= CONTROL_RIGHT;
KeyArray[ A_KEY ] = 0;
KeyArray[ J_KEY ] = 0;
}
}
else
{
control_last &= ~CONTROL_RIGHT;
}
if (KeyArray[ S_KEY ] || KeyArray[ K_KEY ])
{
control_status |= CONTROL_DOWN;
if (!(control_last & CONTROL_DOWN))
{
control_last |= CONTROL_DOWN;
KeyArray[ W_KEY ] = 0;
KeyArray[ I_KEY ] = 0;
}
}
else
{
control_last &= ~CONTROL_DOWN;
}
if (KeyArray[ W_KEY ] || KeyArray[ I_KEY ])
{
control_status |= CONTROL_UP;
if (!(control_last & CONTROL_UP))
{
control_last |= CONTROL_UP;
KeyArray[ S_KEY ] = 0;
KeyArray[ K_KEY ] = 0;
}
}
else
{
control_last &= ~CONTROL_UP;
}
if (KeyArray[ SPACEBAR ])
{
control_status |= CONTROL_FIRE;
if (!(control_last & CONTROL_FIRE))
{
control_last |= CONTROL_FIRE;
}
}
else
{
control_last &= ~CONTROL_FIRE;
}
}
if (KeyArray[ ESC ])
{
control_status |= CONTROL_END;
control_last |= CONTROL_END;
}
else
{
control_last &= ~CONTROL_END;
}
if (KeyArray[ Q_KEY ])
{
control_status |= CONTROL_EXIT;
control_last |= CONTROL_EXIT;
}
else
{
control_last &= ~CONTROL_EXIT;
}
#ifdef ENABLE_CHEATS
if (KeyArray[ KEY_7 ])
{
if (!last_key7)
{
last_key7 = 1;
game_toggleCheat(1);
}
}
else
{
last_key7 = 0;
}
if (KeyArray[ KEY_8 ])
{
if (!last_key8)
{
last_key8 = 1;
game_toggleCheat(2);
}
}
else
{
last_key8 = 0;
}
if (KeyArray[ KEY_9 ])
{
if (!last_key9)
{
last_key9 = 1;
//game_toggleCheat(3);
if (game_cheat2)
{
game_toggleCheat(2);
}
e_rick_gozombie();
}
}
else
{
last_key9 = 0;
}
#endif
#endif
#if !(defined(IIGS) || defined(F256))
U16 key;
#ifdef ENABLE_FOCUS
SDL_ActiveEvent *aevent;
#endif
switch (event.type) {
case SDL_KEYDOWN:
key = event.key.keysym.sym;
if (key == syskbd_up || key == SDLK_UP) {
SETBIT(control_status, CONTROL_UP);
control_last = CONTROL_UP;
}
else if (key == syskbd_down || key == SDLK_DOWN) {
SETBIT(control_status, CONTROL_DOWN);
control_last = CONTROL_DOWN;
}
else if (key == syskbd_left || key == SDLK_LEFT) {
SETBIT(control_status, CONTROL_LEFT);
control_last = CONTROL_LEFT;
}
else if (key == syskbd_right || key == SDLK_RIGHT) {
SETBIT(control_status, CONTROL_RIGHT);
control_last = CONTROL_RIGHT;
}
else if (key == syskbd_pause) {
SETBIT(control_status, CONTROL_PAUSE);
control_last = CONTROL_PAUSE;
}
else if (key == syskbd_end) {
SETBIT(control_status, CONTROL_END);
control_last = CONTROL_END;
}
else if (key == syskbd_xtra) {
SETBIT(control_status, CONTROL_EXIT);
control_last = CONTROL_EXIT;
}
else if (key == syskbd_fire) {
SETBIT(control_status, CONTROL_FIRE);
control_last = CONTROL_FIRE;
}
else if (key == SDLK_F1) {
sysvid_toggleFullscreen();
}
else if (key == SDLK_F2) {
sysvid_zoom(-1);
}
else if (key == SDLK_F3) {
sysvid_zoom(+1);
}
#ifdef ENABLE_SOUND
else if (key == SDLK_F4) {
syssnd_toggleMute();
}
else if (key == SDLK_F5) {
syssnd_vol(-1);
}
else if (key == SDLK_F6) {
syssnd_vol(+1);
}
#endif
#ifdef ENABLE_CHEATS
else if (key == SDLK_F7) {
game_toggleCheat(1);
}
else if (key == SDLK_F8) {
game_toggleCheat(2);
}
else if (key == SDLK_F9) {
game_toggleCheat(3);
}
#endif
break;
case SDL_KEYUP:
key = event.key.keysym.sym;
if (key == syskbd_up || key == SDLK_UP) {
CLRBIT(control_status, CONTROL_UP);
control_last = CONTROL_UP;
}
else if (key == syskbd_down || key == SDLK_DOWN) {
CLRBIT(control_status, CONTROL_DOWN);
control_last = CONTROL_DOWN;
}
else if (key == syskbd_left || key == SDLK_LEFT) {
CLRBIT(control_status, CONTROL_LEFT);
control_last = CONTROL_LEFT;
}
else if (key == syskbd_right || key == SDLK_RIGHT) {
CLRBIT(control_status, CONTROL_RIGHT);
control_last = CONTROL_RIGHT;
}
else if (key == syskbd_pause) {
CLRBIT(control_status, CONTROL_PAUSE);
control_last = CONTROL_PAUSE;
}
else if (key == syskbd_end) {
CLRBIT(control_status, CONTROL_END);
control_last = CONTROL_END;
}
else if (key == syskbd_xtra) {
CLRBIT(control_status, CONTROL_EXIT);
control_last = CONTROL_EXIT;
}
else if (key == syskbd_fire) {
CLRBIT(control_status, CONTROL_FIRE);
control_last = CONTROL_FIRE;
}
break;
case SDL_QUIT:
/* player tries to close the window -- this is the same as pressing ESC */
SETBIT(control_status, CONTROL_EXIT);
control_last = CONTROL_EXIT;
break;
#ifdef ENABLE_FOCUS
case SDL_ACTIVEEVENT: {
aevent = (SDL_ActiveEvent *)&event;
IFDEBUG_EVENTS(
printf("xrick/events: active %x %x\n", aevent->gain, aevent->state);
);
if (aevent->gain == 1)
control_active = TRUE;
else
control_active = FALSE;
}
break;
#endif
#ifdef ENABLE_JOYSTICK
case SDL_JOYAXISMOTION:
IFDEBUG_EVENTS(sys_printf("xrick/events: joystick\n"););
if (event.jaxis.axis == 0) { /* left-right */
if (event.jaxis.value < -SYSJOY_RANGE) { /* left */
SETBIT(control_status, CONTROL_LEFT);
CLRBIT(control_status, CONTROL_RIGHT);
}
else if (event.jaxis.value > SYSJOY_RANGE) { /* right */
SETBIT(control_status, CONTROL_RIGHT);
CLRBIT(control_status, CONTROL_LEFT);
}
else { /* center */
CLRBIT(control_status, CONTROL_RIGHT);
CLRBIT(control_status, CONTROL_LEFT);
}
}
if (event.jaxis.axis == 1) { /* up-down */
if (event.jaxis.value < -SYSJOY_RANGE) { /* up */
SETBIT(control_status, CONTROL_UP);
CLRBIT(control_status, CONTROL_DOWN);
}
else if (event.jaxis.value > SYSJOY_RANGE) { /* down */
SETBIT(control_status, CONTROL_DOWN);
CLRBIT(control_status, CONTROL_UP);
}
else { /* center */
CLRBIT(control_status, CONTROL_DOWN);
CLRBIT(control_status, CONTROL_UP);
}
}
break;
case SDL_JOYBUTTONDOWN:
SETBIT(control_status, CONTROL_FIRE);
break;
case SDL_JOYBUTTONUP:
CLRBIT(control_status, CONTROL_FIRE);
break;
#endif
default:
break;
}
#endif //IIGS
}
/*
* Process events, if any, then return
*/
void
sysevt_poll(void)
{
#if !(defined(IIGS) || defined(F256))
while (SDL_PollEvent(&event))
#endif
processEvent();
}
/*
* Wait for an event, then process it and return
*/
void
sysevt_wait(void)
{
#ifdef IIGS
printf("sysevt_wait\n");
#endif
#if !(defined(IIGS) || defined(F256))
SDL_WaitEvent(&event);
processEvent();
#endif
}
/* eof */

71
src/sysjoy.c Normal file
View file

@ -0,0 +1,71 @@
/*
* xrick/src/sysjoy.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
//#ifdef IIGS
#pragma noroot
//segment "system";
//#endif
#if !(defined(IIGS) || defined(F256))
#include <SDL.h>
#endif
#include "config.h"
#ifdef ENABLE_JOYSTICK
#include "system.h"
#include "debug.h"
static SDL_Joystick *j = NULL;
void
sysjoy_init(void)
{
U8 i, jcount;
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
IFDEBUG_JOYSTICK(
sys_printf("xrick/joystick: can not initialize joystick subsystem\n");
);
return;
}
jcount = SDL_NumJoysticks();
if (!jcount) { /* no joystick on this system */
IFDEBUG_JOYSTICK(sys_printf("xrick/joystick: no joystick available\n"););
return;
}
/* use the first joystick that we can open */
for (i = 0; i < jcount; i++) {
j = SDL_JoystickOpen(i);
if (j)
break;
}
/* enable events */
SDL_JoystickEventState(SDL_ENABLE);
}
void
sysjoy_shutdown(void)
{
if (j)
SDL_JoystickClose(j);
}
#endif /* ENABLE_JOYSTICK */
/* eof */

56
src/syskbd.c Normal file
View file

@ -0,0 +1,56 @@
/*
* xrick/src/syskbd.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#if !(defined(IIGS) || defined(F256))
#include <SDL.h>
#endif
#include "system.h"
#ifdef IIGS
#pragma noroot
segment "system";
#endif
#ifdef IIGS
U8 syskbd_up = 'W';
U8 syskbd_down = 'S';
U8 syskbd_left = 'A';
U8 syskbd_right = 'D';
U8 syskbd_pause = 'P';
U8 syskbd_end = '2';
U8 syskbd_xtra = '1';
U8 syskbd_fire = ' ';
#elif defined(F256)
U8 syskbd_up = 'W';
U8 syskbd_down = 'S';
U8 syskbd_left = 'A';
U8 syskbd_right = 'D';
U8 syskbd_pause = 'P';
U8 syskbd_end = '2';
U8 syskbd_xtra = '1';
U8 syskbd_fire = ' ';
#else
U8 syskbd_up = SDLK_o;
U8 syskbd_down = SDLK_k;
U8 syskbd_left = SDLK_z;
U8 syskbd_right = SDLK_x;
U8 syskbd_pause = SDLK_p;
U8 syskbd_end = SDLK_e;
U8 syskbd_xtra = SDLK_ESCAPE;
U8 syskbd_fire = SDLK_SPACE;
#endif
/* eof */

638
src/syssnd.c Normal file
View file

@ -0,0 +1,638 @@
/*
* xrick/src/syssnd.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#ifdef IIGS
#pragma noroot
#endif
#if !(defined(IIGS) || defined(F256))
#include <SDL.h>
#endif
#ifndef F256
#include <stdlib.h>
#include <memory.h>
#endif
#include "config.h"
#ifdef ENABLE_SOUND
#include "system.h"
#include "game.h"
#include "syssnd.h"
#include "debug.h"
#include "data.h"
segment "system";
#ifdef IIGS
char* pNtpDriver = NULL;
char* pNtpSong = NULL;
extern char ntpplayer_lz4;
extern char sfx_lz4;
extern char sfx_lz5;
void SetAudioBank(char bankNo);
void NTPstop(void);
void NTPplay(int bPlayOnce);
int NTPprepare(void* pNTPData);
void mraLoadBank(char* pAudioBank);
void mraPlay(U8 sfxNo);
void
syssnd_init(void)
{
U32* handle = NULL;
printf("syssnd_init\n");
// Allocate a buffer for the NTPAudio Driver
// and to place the various NTP songs that will play
printf("Alloc NTPDriver\n");
handle = (U32*)NewHandle(0x10000, userid(), 0xC014, 0);
if (toolerror())
{
printf("Unable to allocate Audio Driver Mem\n");
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
printf("SUCCESS\n");
pNtpDriver = (char*)*handle;
pNtpSong = pNtpDriver + 0x8000;
//printf("%p\n", pNtpDriver );
//printf("%p\n", pNtpSong );
//--- Take Advantage of the 64k bank we just
// Allocated, as a temp buffer to get our
// SFX loaded into the DOC
printf("Decompress SFX %p\n", &sfx_lz4); // Force this to be linked in
printf("Decompress SFX %p\n", &sfx_lz5); // Force this to be linked in
LZ4_Unpack(pNtpDriver, &sfx_lz4);
printf("Load SFX into the DOC\n");
mraLoadBank(pNtpDriver);
printf("Decompress NTP Driver\n");
LZ4_Unpack(pNtpDriver, &ntpplayer_lz4);
//printf("Decompress samerica\n");
//LZ4_Unpack(pNtpSong, &samerica_lz4);
printf("NTPSetAudioBank\n");
SetAudioBank( (*handle)>>16 );
#if 0
printf("NTPprepare\n");
if (NTPprepare(pNtpSong))
{
printf("NTPprepare failed\n");
}
else
{
printf("NTPplay\n");
NTPplay(0);
}
#endif
}
/*
* Shutdown
*/
void
syssnd_shutdown(void)
{
// If the driver has been loaded
if (pNtpDriver)
{
printf("syssnd_shutdown\n");
NTPstop();
}
//if (!isAudioActive) return;
//isAudioActive = FALSE;
}
/*
* Toggle mute
*
* When muted, sounds are still managed but not sent to the dsp, hence
* it is possible to un-mute at any time.
*/
void
syssnd_toggleMute(void)
{
printf("syssnd_toggleMute\n");
}
void
syssnd_vol(S8 d)
{
printf("syssnd_vol: %d\n", d);
}
/*
* Play a sound
*
* loop: number of times the sound should be played, -1 to loop forever
* returns: channel number, or -1 if none was available
*
* NOTE if sound is already playing, simply reset it (i.e. can not have
* twice the same sound playing -- tends to become noisy when too many
* bad guys die at the same time).
*/
S8
syssnd_play(sound_t sound, S8 loop)
{
//printf("syssnd_play\n");
if ((sound >= 0) && (sound<SND_MAX))
{
mraPlay((U8)sound);
}
return 0;
}
/*
* Pause
*
* pause: TRUE or FALSE
* clear: TRUE to cleanup all sounds and make sure we start from scratch
*/
void
syssnd_pause(U8 pause, U8 clear)
{
printf("syssnd_pause\n");
}
/*
* Stop a channel
*/
void
syssnd_stopchan(S8 chan)
{
printf("syssnd_stopchan\n");
}
/*
* Stop a sound
*/
void
syssnd_stopsound(sound_t sound)
{
printf("syssnd_stopsound\n");
}
/*
* See if a sound is playing
*/
int
syssnd_isplaying(sound_t sound)
{
printf("syssnd_isplaying\n");
return 0;
}
/*
* Stops all channels.
*/
void
syssnd_stopall(void)
{
printf("syssnd_stopall\n");
}
/*
*
*/
void
syssnd_free(sound_t s)
{
printf("syssnd_free\n");
}
#else
#define ADJVOL(S) (((S)*sndVol)/SDL_MIX_MAXVOLUME)
static U8 isAudioActive = FALSE;
static channel_t channel[SYSSND_MIXCHANNELS];
static U8 sndVol = SDL_MIX_MAXVOLUME; /* internal volume */
static U8 sndUVol = SYSSND_MAXVOL; /* user-selected volume */
static U8 sndMute = FALSE; /* mute flag */
static SDL_mutex *sndlock;
/*
* prototypes
*/
static int sdlRWops_open(SDL_RWops *context, char *name);
static int sdlRWops_seek(SDL_RWops *context, int offset, int whence);
static int sdlRWops_read(SDL_RWops *context, void *ptr, int size, int maxnum);
static int sdlRWops_write(SDL_RWops *context, const void *ptr, int size, int num);
static int sdlRWops_close(SDL_RWops *context);
static void end_channel(U8);
/*
* Callback -- this is also where all sound mixing is done
*
* Note: it may not be that much a good idea to do all the mixing here ; it
* may be more efficient to mix samples every frame, or maybe everytime a
* new sound is sent to be played. I don't know.
*/
void syssnd_callback(UNUSED(void *userdata), U8 *stream, int len)
{
U8 c;
S16 s;
U32 i;
SDL_mutexP(sndlock);
for (i = 0; i < (U32)len; i++) {
s = 0;
for (c = 0; c < SYSSND_MIXCHANNELS; c++) {
if (channel[c].loop != 0) { /* channel is active */
if (channel[c].len > 0) { /* not ending */
s += ADJVOL(*channel[c].buf - 0x80);
channel[c].buf++;
channel[c].len--;
}
else { /* ending */
if (channel[c].loop > 0) channel[c].loop--;
if (channel[c].loop) { /* just loop */
IFDEBUG_AUDIO2(sys_printf("xrick/audio: channel %d - loop\n", c););
channel[c].buf = channel[c].snd->buf;
channel[c].len = channel[c].snd->len;
s += ADJVOL(*channel[c].buf - 0x80);
channel[c].buf++;
channel[c].len--;
}
else { /* end for real */
IFDEBUG_AUDIO2(sys_printf("xrick/audio: channel %d - end\n", c););
end_channel(c);
}
}
}
}
if (sndMute)
stream[i] = 0x80;
else {
s += 0x80;
if (s > 0xff) s = 0xff;
if (s < 0x00) s = 0x00;
stream[i] = (U8)s;
}
}
memcpy(stream, stream, len);
SDL_mutexV(sndlock);
}
static void
end_channel(U8 c)
{
channel[c].loop = 0;
if (channel[c].snd->dispose)
syssnd_free(channel[c].snd);
channel[c].snd = NULL;
}
void
syssnd_init(void)
{
SDL_AudioSpec desired, obtained;
U16 c;
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
IFDEBUG_AUDIO(
sys_printf("xrick/audio: can not initialize audio subsystem\n");
);
return;
}
desired.freq = SYSSND_FREQ;
desired.format = AUDIO_U8;
desired.channels = SYSSND_CHANNELS;
desired.samples = SYSSND_MIXSAMPLES;
desired.callback = syssnd_callback;
desired.userdata = NULL;
if (SDL_OpenAudio(&desired, &obtained) < 0) {
IFDEBUG_AUDIO(
sys_printf("xrick/audio: can not open audio (%s)\n", SDL_GetError());
);
return;
}
sndlock = SDL_CreateMutex();
if (sndlock == NULL) {
IFDEBUG_AUDIO(sys_printf("xrick/audio: can not create lock\n"););
SDL_CloseAudio();
return;
}
if (sysarg_args_vol != 0) {
sndUVol = sysarg_args_vol;
sndVol = SDL_MIX_MAXVOLUME * sndUVol / SYSSND_MAXVOL;
}
for (c = 0; c < SYSSND_MIXCHANNELS; c++)
channel[c].loop = 0; /* deactivate */
isAudioActive = TRUE;
SDL_PauseAudio(0);
}
/*
* Shutdown
*/
void
syssnd_shutdown(void)
{
if (!isAudioActive) return;
SDL_CloseAudio();
SDL_DestroyMutex(sndlock);
isAudioActive = FALSE;
}
/*
* Toggle mute
*
* When muted, sounds are still managed but not sent to the dsp, hence
* it is possible to un-mute at any time.
*/
void
syssnd_toggleMute(void)
{
SDL_mutexP(sndlock);
sndMute = !sndMute;
SDL_mutexV(sndlock);
}
void
syssnd_vol(S8 d)
{
if ((d < 0 && sndUVol > 0) ||
(d > 0 && sndUVol < SYSSND_MAXVOL)) {
sndUVol += d;
SDL_mutexP(sndlock);
sndVol = SDL_MIX_MAXVOLUME * sndUVol / SYSSND_MAXVOL;
SDL_mutexV(sndlock);
}
}
/*
* Play a sound
*
* loop: number of times the sound should be played, -1 to loop forever
* returns: channel number, or -1 if none was available
*
* NOTE if sound is already playing, simply reset it (i.e. can not have
* twice the same sound playing -- tends to become noisy when too many
* bad guys die at the same time).
*/
S8
syssnd_play(sound_t *sound, S8 loop)
{
S8 c;
if (!isAudioActive) return -1;
if (sound == NULL) return -1;
c = 0;
SDL_mutexP(sndlock);
while ((channel[c].snd != sound || channel[c].loop == 0) &&
channel[c].loop != 0 &&
c < SYSSND_MIXCHANNELS)
c++;
if (c == SYSSND_MIXCHANNELS)
c = -1;
IFDEBUG_AUDIO(
if (channel[c].snd == sound && channel[c].loop != 0)
sys_printf("xrick/sound: already playing %s on channel %d - resetting\n",
sound->name, c);
else if (c >= 0)
sys_printf("xrick/sound: playing %s on channel %d\n", sound->name, c);
);
if (c >= 0) {
channel[c].loop = loop;
channel[c].snd = sound;
channel[c].buf = sound->buf;
channel[c].len = sound->len;
}
SDL_mutexV(sndlock);
return c;
}
/*
* Pause
*
* pause: TRUE or FALSE
* clear: TRUE to cleanup all sounds and make sure we start from scratch
*/
void
syssnd_pause(U8 pause, U8 clear)
{
U8 c;
if (!isAudioActive) return;
if (clear == TRUE) {
SDL_mutexP(sndlock);
for (c = 0; c < SYSSND_MIXCHANNELS; c++)
channel[c].loop = 0;
SDL_mutexV(sndlock);
}
if (pause == TRUE)
SDL_PauseAudio(1);
else
SDL_PauseAudio(0);
}
/*
* Stop a channel
*/
void
syssnd_stopchan(S8 chan)
{
if (chan < 0 || chan > SYSSND_MIXCHANNELS)
return;
SDL_mutexP(sndlock);
if (channel[chan].snd) end_channel(chan);
SDL_mutexV(sndlock);
}
/*
* Stop a sound
*/
void
syssnd_stopsound(sound_t *sound)
{
U8 i;
if (!sound) return;
SDL_mutexP(sndlock);
for (i = 0; i < SYSSND_MIXCHANNELS; i++)
if (channel[i].snd == sound) end_channel(i);
SDL_mutexV(sndlock);
}
/*
* See if a sound is playing
*/
int
syssnd_isplaying(sound_t *sound)
{
U8 i, playing;
playing = 0;
SDL_mutexP(sndlock);
for (i = 0; i < SYSSND_MIXCHANNELS; i++)
if (channel[i].snd == sound) playing = 1;
SDL_mutexV(sndlock);
return playing;
}
/*
* Stops all channels.
*/
void
syssnd_stopall(void)
{
U8 i;
SDL_mutexP(sndlock);
for (i = 0; i < SYSSND_MIXCHANNELS; i++)
if (channel[i].snd) end_channel(i);
SDL_mutexV(sndlock);
}
/*
* Load a sound.
*/
sound_t *
syssnd_load(char *name)
{
sound_t *s;
SDL_RWops *context;
SDL_AudioSpec audiospec;
/* alloc context */
context = malloc(sizeof(SDL_RWops));
context->seek = sdlRWops_seek;
context->read = sdlRWops_read;
context->write = sdlRWops_write;
context->close = sdlRWops_close;
/* open */
if (sdlRWops_open(context, name) == -1)
return NULL;
/* alloc sound */
s = malloc(sizeof(sound_t));
#ifdef DEBUG
s->name = malloc(strlen(name) + 1);
strncpy(s->name, name, strlen(name) + 1);
#endif
/* read */
/* second param == 1 -> close source once read */
if (!SDL_LoadWAV_RW(context, 1, &audiospec, &(s->buf), &(s->len)))
{
free(s);
return NULL;
}
s->dispose = FALSE;
return s;
}
/*
*
*/
void
syssnd_free(sound_t *s)
{
if (!s) return;
if (s->buf) SDL_FreeWAV(s->buf);
s->buf = NULL;
s->len = 0;
}
/*
*
*/
static int
sdlRWops_open(SDL_RWops *context, char *name)
{
data_file_t *f;
f = data_file_open(name);
if (!f) return -1;
context->hidden.unknown.data1 = (void *)f;
return 0;
}
static int
sdlRWops_seek(SDL_RWops *context, int offset, int whence)
{
return data_file_seek((data_file_t *)(context->hidden.unknown.data1), offset, whence);
}
static int
sdlRWops_read(SDL_RWops *context, void *ptr, int size, int maxnum)
{
return data_file_read((data_file_t *)(context->hidden.unknown.data1), ptr, size, maxnum);
}
static int
sdlRWops_write(SDL_RWops *context, const void *ptr, int size, int num)
{
/* not implemented */
return -1;
}
static int
sdlRWops_close(SDL_RWops *context)
{
if (context)
{
data_file_close((data_file_t *)(context->hidden.unknown.data1));
free(context);
}
return 0;
}
#endif /* IIGS */
#endif /* ENABLE_SOUND */
/* eof */

182
src/system.c Normal file
View file

@ -0,0 +1,182 @@
/*
* xrick/src/system.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#ifdef IIGS
#pragma noroot
#endif
#if !(defined(IIGS) || defined(F256))
#include <SDL.h>
#endif
#ifndef F256
#include <stdarg.h> /* args for sys_panic */
#include <fcntl.h> /* fcntl in sys_panic */
#include <stdio.h> /* printf */
#include <stdlib.h>
#include <signal.h>
#endif
#include "system.h"
#ifdef F256
void puts(char* c_str)
{
}
void __putchar(char c)
{
}
#endif
/*
* Panic
*/
void
sys_panic(char *err, ...)
{
#ifndef F256
va_list argptr;
char s[1024];
/* change stdin to non blocking */
/*fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);*/
/* NOTE HPUX: use ... is it OK on Linux ? */
/* fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NDELAY); */
/* prepare message */
va_start(argptr, err);
vsprintf(s, err, argptr);
va_end(argptr);
/* print message and die */
printf("%s\npanic!\n", s);
exit(1);
#endif
}
/*
* Print a message
*/
void
sys_printf(char *msg, ...)
{
#ifndef F256
va_list argptr;
char s[1024];
/* change stdin to non blocking */
/*fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);*/
/* NOTE HPUX: use ... is it OK on Linux ? */
/* fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NDELAY); */
/* prepare message */
va_start(argptr, msg);
vsprintf(s, msg, argptr);
va_end(argptr);
printf(s);
#endif
}
/*
* Return number of microseconds elapsed since first call
*/
U32
sys_gettime(void)
{
#ifdef IIGS
return tick[0] << 4;
#elif defined(F256)
/*$$TODO -> Hook this to the jiffytime, make similar the the GS */
/* or use general purpose system timer */
static U32 dumb;
dumb+=1;
return dumb;
#else
static U32 ticks_base = 0;
U32 ticks;
ticks = SDL_GetTicks();
if (!ticks_base)
ticks_base = ticks;
return ticks - ticks_base;
#endif
}
/*
* Sleep a number of microseconds
*/
void
sys_sleep(int s)
{
#ifdef IIGS
// on GS we're going to work in ms, also we don't sleep, we just wait
while (s > 8)
{
sysvid_wait_vblank();
s -= 16; // About 1/60th of a second
}
#endif
#if !(defined(IIGS) || defined(F256))
SDL_Delay(s);
#endif
}
/*
* Initialize system
*/
void
sys_init(int argc, char **argv)
{
sysarg_init(argc, argv);
sysvid_init();
#ifdef ENABLE_JOYSTICK
sysjoy_init();
#endif
#ifdef ENABLE_SOUND
if (sysarg_args_nosound == 0)
syssnd_init();
#endif
#ifndef F256
atexit(sys_shutdown);
#endif
#if !(defined(IIGS) || defined(F256))
signal(SIGINT, exit);
signal(SIGTERM, exit);
#endif
}
/*
* Shutdown system
*/
void
sys_shutdown(void)
{
#ifdef ENABLE_SOUND
syssnd_shutdown();
#endif
#ifdef ENABLE_JOYSTICK
sysjoy_shutdown();
#endif
sysvid_shutdown();
}
/* eof */

806
src/sysvid.c Normal file
View file

@ -0,0 +1,806 @@
/*
* xrick/src/sysvid.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#ifdef IIGS
segment "system";
#pragma noroot
#endif
#include <stdlib.h> /* malloc */
#if !(defined(IIGS) || defined(F256))
#include <SDL.h>
#endif
#include "system.h"
#include "game.h"
#include "img.h"
#include "debug.h"
#ifdef IIGS
#include <Event.h>
#include <GSOS.h>
#include <Memory.h>
#include <Orca.h>
#include <Misctool.h>
#include <ADB.h>
#include <loader.h>
#endif
#ifdef __MSVC__
#include <memory.h> /* memset */
#endif
U8 *sysvid_fb; /* frame buffer */
rect_t SCREENRECT = {0, 0, 320, SYSVID_HEIGHT, NULL}; /* whole fb */
#if !(defined(IIGS) || defined(F256))
static SDL_Color palette[256];
static SDL_Surface *screen;
#endif
#ifdef IIGS
volatile char *VIDEO_REGISTER = (char*)0xC029;
volatile char *SHADOW_REGISTER = (char*)0xC035;
extern U8 tiles_lz4;
#endif
#ifndef F256
static U32 videoFlags;
static U8 zoom = SYSVID_ZOOM; /* actual zoom level */
static U8 szoom = 0; /* saved zoom level */
static U8 fszoom = 0; /* fullscreen zoom level */
#endif
#include "img_icon.e"
/*
* color tables
*/
#ifdef GFXPC
static U8 RED[] = { 0x00, 0x50, 0xf0, 0xf0, 0x00, 0x50, 0xf0, 0xf0 };
static U8 GREEN[] = { 0x00, 0xf8, 0x50, 0xf8, 0x00, 0xf8, 0x50, 0xf8 };
static U8 BLUE[] = { 0x00, 0x50, 0x50, 0x50, 0x00, 0xf8, 0xf8, 0xf8 };
#endif
#if defined(GFXST) || defined(GFXGS) || defined(GFXF256)
static U8 RED[] = { 0x00, 0xd8, 0xb0, 0xf8,
0x20, 0x00, 0x00, 0x20,
0x48, 0x48, 0x90, 0xd8,
0x48, 0x68, 0x90, 0xb0,
/* cheat colors */
0x50, 0xe0, 0xc8, 0xf8,
0x68, 0x50, 0x50, 0x68,
0x80, 0x80, 0xb0, 0xe0,
0x80, 0x98, 0xb0, 0xc8
};
static U8 GREEN[] = { 0x00, 0x00, 0x6c, 0x90,
0x24, 0x48, 0x6c, 0x48,
0x6c, 0x24, 0x48, 0x6c,
0x48, 0x6c, 0x90, 0xb4,
/* cheat colors */
0x54, 0x54, 0x9c, 0xb4,
0x6c, 0x84, 0x9c, 0x84,
0x9c, 0x6c, 0x84, 0x9c,
0x84, 0x9c, 0xb4, 0xcc
};
static U8 BLUE[] = { 0x00, 0x00, 0x68, 0x68,
0x20, 0xb0, 0xd8, 0x00,
0x20, 0x00, 0x00, 0x00,
0x48, 0x68, 0x90, 0xb0,
/* cheat colors */
0x50, 0x50, 0x98, 0x98,
0x68, 0xc8, 0xe0, 0x50,
0x68, 0x50, 0x50, 0x50,
0x80, 0x98, 0xb0, 0xc8};
#endif
/*
* Initialize screen
*/
#if !(defined(IIGS) || defined(F256))
static
SDL_Surface *initScreen(U16 w, U16 h, U8 bpp, U32 flags)
{
return SDL_SetVideoMode(w, h, bpp, flags);
}
#endif
void
sysvid_setPalette(img_color_t *pal, U16 n)
{
#if !(defined(IIGS) || defined(F256))
U16 i;
for (i = 0; i < n; i++) {
palette[i].r = pal[i].r;
palette[i].g = pal[i].g;
palette[i].b = pal[i].b;
}
SDL_SetColors(screen, (SDL_Color *)&palette, 0, n);
#endif
}
void
sysvid_restorePalette()
{
#if !(defined(IIGS) || defined(F256))
SDL_SetColors(screen, (SDL_Color *)&palette, 0, 256);
#endif
}
void
sysvid_setGamePalette()
{
U8 i;
img_color_t pal[256];
for (i = 0; i < 32; ++i) {
pal[i].r = RED[i];
pal[i].g = GREEN[i];
pal[i].b = BLUE[i];
}
sysvid_setPalette(pal, 32);
}
/*
* Initialize video modes
*/
void
sysvid_chkvm(void)
{
#if !(defined(IIGS) || defined(F256))
SDL_Rect **modes;
U8 i, mode = 0;
IFDEBUG_VIDEO(sys_printf("xrick/video: checking video modes\n"););
modes = SDL_ListModes(NULL, videoFlags|SDL_FULLSCREEN);
if (modes == (SDL_Rect **)0)
sys_panic("xrick/video: SDL can not find an appropriate video mode\n");
if (modes == (SDL_Rect **)-1) {
/* can do what you want, everything is possible */
IFDEBUG_VIDEO(sys_printf("xrick/video: SDL says any video mode is OK\n"););
fszoom = 1;
}
else {
IFDEBUG_VIDEO(sys_printf("xrick/video: SDL says, use these modes:\n"););
for (i = 0; modes[i]; i++) {
IFDEBUG_VIDEO(sys_printf(" %dx%d\n", modes[i]->w, modes[i]->h););
if (modes[i]->w <= modes[mode]->w && modes[i]->w >= SYSVID_WIDTH &&
modes[i]->h * SYSVID_WIDTH >= modes[i]->w * SYSVID_HEIGHT) {
mode = i;
fszoom = modes[mode]->w / SYSVID_WIDTH;
}
}
if (fszoom != 0) {
IFDEBUG_VIDEO(
sys_printf("xrick/video: fullscreen at %dx%d w/zoom=%d\n",
modes[mode]->w, modes[mode]->h, fszoom);
);
}
else {
IFDEBUG_VIDEO(
sys_printf("xrick/video: can not compute fullscreen zoom, use 1\n");
);
fszoom = 1;
}
}
#endif
}
#ifdef IIGS
volatile unsigned long* tick;
typedef struct
{
void* pLink;
Word Count;
Word Sig;
} taskHeader_t;
taskHeader_t dummyTask = {
0,
0,
0xA55A
};
#endif
#ifdef IIGS
extern U8 xrickspr_00;
extern U8 xrickspr_01;
extern U8 xrickspr_02;
extern U8 xrickspr_03;
U8* compressedSprites[] =
{
&xrickspr_00,
&xrickspr_01,
&xrickspr_02,
&xrickspr_03
};
void PrepareSprites()
{
int idx;
U32* handles[4];
for (idx = 0; idx < 4; ++idx)
{
printf("Alloc Sprites %d\n",idx);
handles[idx] = (U32*)NewHandle(0x10000, userid(), 0xC014, 0);
if (toolerror())
{
*VIDEO_REGISTER&=0x3F;
printf("Unable to allocate 64k Sprites Bank %d\n", idx);
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
printf("SUCCESS\n");
}
for (idx = 0; idx < 4; ++idx)
{
printf("Decompress Sprites %d\n", idx);
LZ4_Unpack((char*)*handles[idx], compressedSprites[idx]);
}
SetSpriteBanks( (*handles[0])>>16,
(*handles[1])>>16,
(*handles[2])>>16,
(*handles[3])>>16 );
}
struct LoadSegRec {
Word userID;
Pointer startAddr;
Word LoadFileNo;
Word LoadSegNo;
Word LoadSegKind;
};
typedef struct LoadSegRec LoadSegRec;
//
// Summarize the LoadSegments
//
void GetLoadSegments()
{
long* outData = (long*)0x011000; // hard coded address, so kegs can shit this out
int idx;
static LoadSegRec result;
outData[0] = 19; // first value, the number of segments
printf("$%08p GetLoadSegments\n", (Pointer)&GetLoadSegments);
printf("$%04X userid\n", userid());
for (idx = 1; idx < 255; ++idx)
{
// userid, loadfilenum, segnum, outptr
memset(&result, 0, sizeof(LoadSegRec));
GetLoadSegInfo(0,1,idx, (Pointer)&result);
if (toolerror())
{
printf("toolerror = $%04X\n", toolerror());
break;
}
else
{
Pointer pMem = *(Pointer*)result.startAddr;
printf("Seg:%d userid=$%04X ptr=%08p\n", idx, result.userID, pMem);
outData[idx] = (long)pMem;
}
//printf("Seg:%d $%08p\n", idx, *(Pointer)result.startAddr);
}
//sys_sleep(30000); // Wait 30 seconds
}
//
// Attempt a proper shutdown
//
void IIGShutdown()
{
RemoveKeyboardDriver();
ADBShutDown();
EMShutDown();
MTShutDown();
syssnd_shutdown(); // Shutdown the NTP player
DisposeAll(userid());
//SystemMMShutDown();
}
#endif
/*
* Initialise video
*/
void
sysvid_init(void)
{
#ifdef IIGS
handle hndl; // "generic memory handle"
U32* directPageHandle;
U32* tilesPageHandle;
// PushLong #0 ;/* Ask Shadowing Screen ($8000 bytes from $01/2000)*/
// PushLong #$8000
// PushWord myID
// PushWord #%11000000_00000011
// PushLong #$012000
// _NewHandle
// PLA
// PLA
// Allocate Bank 01 memory + 4K before and after (25 lines pre flow)
// $012000-$019BFF pixel data
// $019D00-$019DC7 SCB data
// $019E00-$019FFF Clut data
// $900 bytes afer, (14 lines buffer on the bottom, which will wreck SCB+CLUT
//
printf("Allocate Bank $01 memory\n");
hndl = NewHandle(0x9600, userid(), 0xC003, (pointer) 0x011000);
if (toolerror())
{
*VIDEO_REGISTER&=0x3F;
printf("Unable to allocate backpage at 0x012000\n");
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
printf("SUCCESS\n");
GetLoadSegments();
#if 1
// Allocate Bank E1 memory - Actual Video memory
printf("Allocate Bank $E1 memory\n");
hndl = NewHandle(0x8000, userid(), 0xC003, (pointer) 0xE12000);
if (toolerror())
{
*VIDEO_REGISTER&=0x3F;
printf("Unable to allocate display buffer at 0xE12000\n");
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
printf("SUCCESS\n");
#endif
// Allocate Some Direct Page memory
printf("Allocate Direct Page space 256 bytes\n");
directPageHandle = (U32*)NewHandle( 0x100, userid(), 0xC005, 0 );
if (toolerror())
{
*VIDEO_REGISTER&=0x3F;
printf("Unable to allocate 256 bytes Direct Page\n");
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
printf("SUCCESS\n");
//BlitFieldHndl = NewHandle(0x10000, userid(), 0xC014, 0);
printf("Allocate Bank for 8x8 Tiles\n");
tilesPageHandle = (U32*)NewHandle(0x10000, userid(), 0xC014, 0);
if (toolerror())
{
*VIDEO_REGISTER&=0x3F;
printf("Unable to allocate 64k Tiles Bank\n");
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
printf("SUCCESS\n");
SetTileBank((*tilesPageHandle)>>16);
printf("Decompressing Tiles\n");
LZ4_Unpack((char*)*tilesPageHandle, &tiles_lz4);
PrepareSprites();
printf("MiscTool Startup\n");
MTStartUp(); // MiscTool Startup, for the Heartbeat
if (toolerror())
{
*VIDEO_REGISTER&=0x3F;
printf("Unable to Start MiscTool\n");
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
printf("Enable Tick Timer\n");
SetHeartBeat((pointer)&dummyTask); // Force the Tick Timer On
DelHeartBeat((pointer)&dummyTask); // Clear the dummy task from the list
// Address of GetTick internal tick variable
tick = (unsigned long*)GetAddr(tickCnt);
printf("EventManager Startup(why?)\n");
EMStartUp((Word)(*directPageHandle),(Word)32,(Integer)0,(Integer)320,(Integer)0,(Integer)200,(Word)userid());
if (toolerror())
{
*VIDEO_REGISTER&=0x3F;
printf("Unable to Start Event Manager\n");
printf("ROM3, game can't run\n");
sys_sleep(5000);
exit(1);
}
printf("ADBTool Startup\n");
ADBStartUp();
if (toolerror())
{
*VIDEO_REGISTER&=0x3F;
printf("Unable to Start ADBTool\n");
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
// Hook in the Keyboard Driver
AddKeyboardDriver();
#if 0
printf("Event Manager Startup\n");
EMStartUp((Word)*directPageHandle,
(Word)0, // default 20
(Integer)0,
(Integer)320,
(Integer)0,
(Integer)200,
(Word)userid());
#endif
// Framebuffer
sysvid_fb = (U8*)0x12000;
// SHR ON
*VIDEO_REGISTER|=0xC0;
// ENABLE Shadowing of SHR
//*SHADOW_REGISTER&=~0x08; // Shadow Enable
// DISABLE Shadowing of SHR
*SHADOW_REGISTER|=0x08; // Shadow Disable
#endif
#if !(defined(IIGS) || defined(F256))
SDL_Surface *s;
U8 *mask, tpix;
U32 len, i;
IFDEBUG_VIDEO(printf("xrick/video: start\n"););
/* SDL */
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0)
sys_panic("xrick/video: could not init SDL\n");
/* various WM stuff */
SDL_WM_SetCaption("xrick", "xrick");
SDL_ShowCursor(SDL_DISABLE);
s = SDL_CreateRGBSurfaceFrom(IMG_ICON->pixels, IMG_ICON->w, IMG_ICON->h, 8, IMG_ICON->w, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
SDL_SetColors(s, (SDL_Color *)IMG_ICON->colors, 0, IMG_ICON->ncolors);
tpix = *(IMG_ICON->pixels);
IFDEBUG_VIDEO(
sys_printf("xrick/video: icon is %dx%d\n",
IMG_ICON->w, IMG_ICON->h);
sys_printf("xrick/video: icon transp. color is #%d (%d,%d,%d)\n", tpix,
IMG_ICON->colors[tpix].r,
IMG_ICON->colors[tpix].g,
IMG_ICON->colors[tpix].b);
);
/*
* old dirty stuff to implement transparency. SetColorKey does it
* on Windows w/out problems. Linux? FIXME!
len = IMG_ICON->w * IMG_ICON->h;
mask = (U8 *)malloc(len/8);
memset(mask, 0, len/8);
for (i = 0; i < len; i++)
if (IMG_ICON->pixels[i] != tpix) mask[i/8] |= (0x80 >> (i%8));
*/
/*
* FIXME
* Setting a mask produces strange results depending on the
* Window Manager. On fvwm2 it is shifted to the right ...
*/
/*SDL_WM_SetIcon(s, mask);*/
SDL_SetColorKey(s,
SDL_SRCCOLORKEY,
SDL_MapRGB(s->format,IMG_ICON->colors[tpix].r,IMG_ICON->colors[tpix].g,IMG_ICON->colors[tpix].b));
SDL_WM_SetIcon(s, NULL);
/* video modes and screen */
videoFlags = SDL_HWSURFACE|SDL_HWPALETTE;
sysvid_chkvm(); /* check video modes */
if (sysarg_args_zoom)
zoom = sysarg_args_zoom;
if (sysarg_args_fullscreen) {
videoFlags |= SDL_FULLSCREEN;
szoom = zoom;
zoom = fszoom;
}
screen = initScreen(SYSVID_WIDTH * zoom,
SYSVID_HEIGHT * zoom,
8, videoFlags);
/*
* create v_ frame buffer
*/
sysvid_fb = malloc(SYSVID_WIDTH * SYSVID_HEIGHT);
if (!sysvid_fb)
sys_panic("xrick/video: sysvid_fb malloc failed\n");
IFDEBUG_VIDEO(printf("xrick/video: ready\n"););
#endif
}
/*
* Shutdown video
*/
void
sysvid_shutdown(void)
{
#if !(defined(IIGS) || defined(F256))
free(sysvid_fb);
sysvid_fb = NULL;
SDL_Quit();
#endif
}
/*
* Update screen
* NOTE errors processing ?
*/
void
sysvid_update(rect_t *rects)
{
#ifdef IIGS
int result;
//PresentFrameBuffer();
while (rects)
{
#if 0
printf("%d,%d,%d,%d\n",
rects->x,
rects->y,
rects->width,
rects->height
);
#endif
result = BlitRect(rects->x, rects->y, rects->width-1, rects->height-1);
rects = rects->next;
}
#endif
#if !(defined(IIGS) || defined(F256))
static SDL_Rect area;
U16 x, y, xz, yz;
U8 *p, *q, *p0, *q0;
if (rects == NULL)
return;
if (SDL_LockSurface(screen) == -1)
sys_panic("xrick/panic: SDL_LockSurface failed\n");
while (rects) {
p0 = sysvid_fb;
p0 += rects->x + rects->y * SYSVID_WIDTH;
q0 = (U8 *)screen->pixels;
q0 += (rects->x + rects->y * SYSVID_WIDTH * zoom) * zoom;
for (y = rects->y; y < rects->y + rects->height; y++) {
for (yz = 0; yz < zoom; yz++) {
p = p0;
q = q0;
for (x = rects->x; x < rects->x + rects->width; x++) {
for (xz = 0; xz < zoom; xz++) {
*q = *p;
q++;
}
p++;
}
q0 += SYSVID_WIDTH * zoom;
}
p0 += SYSVID_WIDTH;
}
IFDEBUG_VIDEO2(
for (y = rects->y; y < rects->y + rects->height; y++)
for (yz = 0; yz < zoom; yz++) {
p = (U8 *)screen->pixels + rects->x * zoom + (y * zoom + yz) * SYSVID_WIDTH * zoom;
*p = 0x01;
*(p + rects->width * zoom - 1) = 0x01;
}
for (x = rects->x; x < rects->x + rects->width; x++)
for (xz = 0; xz < zoom; xz++) {
p = (U8 *)screen->pixels + x * zoom + xz + rects->y * zoom * SYSVID_WIDTH * zoom;
*p = 0x01;
*(p + ((rects->height * zoom - 1) * zoom) * SYSVID_WIDTH) = 0x01;
}
);
area.x = rects->x * zoom;
area.y = rects->y * zoom;
area.h = rects->height * zoom;
area.w = rects->width * zoom;
SDL_UpdateRects(screen, 1, &area);
rects = rects->next;
}
SDL_UnlockSurface(screen);
#endif
}
/*
* Clear screen
* (077C)
*/
void
sysvid_clear(void)
{
#ifdef F256
/* FIX THIS $$TODO F256 */
#elif defined(IIGS)
size_t length = SYSVID_WIDTH * SYSVID_HEIGHT;
memset(sysvid_fb, 0, length);
#else
memset(sysvid_fb, 0, SYSVID_WIDTH * SYSVID_HEIGHT);
#endif
}
void sysvid_clearPalette(void)
{
#ifdef IIGS
size_t offset = SYSVID_WIDTH * SYSVID_HEIGHT;
size_t length = 768;
U8* ptr = sysvid_fb + offset;
memset(ptr, 0, length);
#endif
}
void sysvid_FadeIn()
{
#ifdef IIGS
size_t offset = SYSVID_WIDTH * SYSVID_HEIGHT;
size_t length = 200;
U8* ptr = sysvid_fb + offset;
int idx;
for (idx = 0;idx<16; ++idx)
{
memset(ptr, idx, length);
wait_vsync();
PresentSCB();
}
#endif
}
void sysvid_FadeOut()
{
#ifdef IIGS
size_t offset = SYSVID_WIDTH * SYSVID_HEIGHT;
size_t length = 200;
U8* ptr = sysvid_fb + offset;
int idx;
for (idx = 15;idx>=0; --idx)
{
memset(ptr, idx, length);
wait_vsync();
PresentSCB();
}
#endif
}
/*
* Zoom
*/
void
sysvid_zoom(S8 z)
{
#if !(defined(IIGS) || defined(F256))
if (!(videoFlags & SDL_FULLSCREEN) &&
((z < 0 && zoom > 1) ||
(z > 0 && zoom < SYSVID_MAXZOOM))) {
zoom += z;
screen = initScreen(SYSVID_WIDTH * zoom,
SYSVID_HEIGHT * zoom,
screen->format->BitsPerPixel, videoFlags);
sysvid_restorePalette();
sysvid_update(&SCREENRECT);
}
#endif
}
/*
* Toggle fullscreen
*/
void
sysvid_toggleFullscreen(void)
{
#if !(defined(IIGS) || defined(F256))
videoFlags ^= SDL_FULLSCREEN;
if (videoFlags & SDL_FULLSCREEN) { /* go fullscreen */
szoom = zoom;
zoom = fszoom;
}
else { /* go window */
zoom = szoom;
}
screen = initScreen(SYSVID_WIDTH * zoom,
SYSVID_HEIGHT * zoom,
screen->format->BitsPerPixel, videoFlags);
sysvid_restorePalette();
sysvid_update(&SCREENRECT);
#endif
}
void sysvid_wait_vblank()
{
#ifdef IIGS
volatile const S8* VSTATUS = (S8*) 0xC019;
#if 1
// While already in vblank wait
while ((*VSTATUS & 0x80) == 0)
{
// Wait for VBLANK to END
}
while ((*VSTATUS & 0x80) != 0)
{
// Wait for VBLANK to BEGIN
}
#else
// While already in vblank wait
while (VSTATUS[0] >= 0)
{
// Wait for VBLANK to END
}
while (VSTATUS[0] < 0)
{
// Wait for VBLANK to BEGIN
}
#endif
#endif
}
/* eof */

1327
src/unzip.c Normal file

File diff suppressed because it is too large Load diff

215
src/util.c Normal file
View file

@ -0,0 +1,215 @@
/*
* xrick/src/util.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#ifdef IIGS
#pragma noroot
#endif
#include <stdlib.h> /* NULL */
#include "system.h"
#include "config.h"
#include "game.h"
#include "util.h"
#include "ents.h"
#include "e_rick.h"
#include "maps.h"
/*
* Full box test.
*
* ASM 1199
*
* e: entity to test against.
* x,y: coordinates to test.
* ret: TRUE/(x,y) is within e's space, FALSE/not.
*/
U8
u_fboxtest(ent_t* pEnt, S16 x, S16 y)
{
if (pEnt->x >= x ||
pEnt->x + pEnt->w < x ||
pEnt->y >= y ||
pEnt->y + pEnt->h < y)
return FALSE;
else
return TRUE;
}
/*
* Box test (then whole e2 is checked agains the center of e1).
*
* ASM 113E
*
* e1: entity to test against (corresponds to DI in asm code).
* e2: entity to test (corresponds to SI in asm code).
* ret: TRUE/intersect, FALSE/not.
*/
U8
u_boxtest(ent_t* pEnt1, ent_t* pEnt2)
{
/* rick is special (may be crawling) */
if (pEnt1 == &ent_ents[E_RICK_NO])
return e_rick_boxtest(pEnt2);
/*
* entity 1: x+0x05 to x+0x011, y to y+0x14
* entity 2: x to x+ .w, y to y+ .h
*/
if (pEnt1->x + 0x11 < pEnt2->x ||
pEnt1->x + 0x05 > pEnt2->x + pEnt2->w ||
pEnt1->y + 0x14 < pEnt2->y ||
pEnt1->y > pEnt2->y + pEnt2->h - 1)
return FALSE;
else
return TRUE;
}
/*
* Compute the environment flag.
*
* ASM 0FBC if !crawl, else 103E
*
* x, y: coordinates where to compute the environment flag
* crawl: is rick crawling?
* rc0: anything CHANGED to the environment flag for crawling (6DBA)
* rc1: anything CHANGED to the environment flag (6DAD)
*/
void
u_envtest(S16 x, S16 y, U8 crawl, U8 *rc0, U8 *rc1)
{
U8 i, xx;
/* prepare for ent #0 test */
ent_ents[ENT_ENTSNUM].x = x;
ent_ents[ENT_ENTSNUM].y = y;
i = 1;
if (!crawl) i++;
if (y & 0x0004) i++;
x += 4;
xx = (U8)x; /* FIXME? */
x = x >> 3; /* from pixels to tiles */
y = y >> 3; /* from pixels to tiles */
*rc0 = *rc1 = 0;
if (xx & 0x07) { /* tiles columns alignment */
if (crawl) {
*rc0 |= (map_eflg[map_map[y][x]] &
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
*rc0 |= (map_eflg[map_map[y][x + 1]] &
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
*rc0 |= (map_eflg[map_map[y][x + 2]] &
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
y++;
}
do {
*rc1 |= (map_eflg[map_map[y][x]] &
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
MAP_EFLG_LETHAL|MAP_EFLG_01));
*rc1 |= (map_eflg[map_map[y][x + 1]] &
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
MAP_EFLG_LETHAL|MAP_EFLG_CLIMB|MAP_EFLG_01));
*rc1 |= (map_eflg[map_map[y][x + 2]] &
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
MAP_EFLG_LETHAL|MAP_EFLG_01));
y++;
} while (--i > 0);
*rc1 |= (map_eflg[map_map[y][x]] &
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP|MAP_EFLG_FGND|
MAP_EFLG_LETHAL|MAP_EFLG_01));
*rc1 |= (map_eflg[map_map[y][x + 1]]);
*rc1 |= (map_eflg[map_map[y][x + 2]] &
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP|MAP_EFLG_FGND|
MAP_EFLG_LETHAL|MAP_EFLG_01));
}
else {
if (crawl) {
*rc0 |= (map_eflg[map_map[y][x]] &
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
*rc0 |= (map_eflg[map_map[y][x + 1]] &
(MAP_EFLG_VERT|MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_WAYUP));
y++;
}
do {
*rc1 |= (map_eflg[map_map[y][x]] &
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
MAP_EFLG_LETHAL|MAP_EFLG_CLIMB|MAP_EFLG_01));
*rc1 |= (map_eflg[map_map[y][x + 1]] &
(MAP_EFLG_SOLID|MAP_EFLG_SPAD|MAP_EFLG_FGND|
MAP_EFLG_LETHAL|MAP_EFLG_CLIMB|MAP_EFLG_01));
y++;
} while (--i > 0);
*rc1 |= (map_eflg[map_map[y][x]]);
*rc1 |= (map_eflg[map_map[y][x + 1]]);
}
/*
* If not lethal yet, and there's an entity on slot zero, and (x,y)
* boxtests this entity, then raise SOLID flag. This is how we make
* sure that no entity can move over the entity that is on slot zero.
*
* Beware! When game_cheat2 is set, this means that a block can
* move over rick without killing him -- but then rick is trapped
* because the block is solid.
*/
if (!(*rc1 & MAP_EFLG_LETHAL)
&& ent_ents[0].n
&& u_boxtest(&ent_ents[ENT_ENTSNUM], &ent_ents[0])) {
*rc1 |= MAP_EFLG_SOLID;
}
/* When game_cheat2 is set, the environment can not be lethal. */
#ifdef ENABLE_CHEATS
if (game_cheat2) *rc1 &= ~MAP_EFLG_LETHAL;
#endif
}
/*
* Check if x,y is within e trigger box.
*
* ASM 126F
* return: FALSE if not in box, TRUE if in box.
*/
U8
u_trigbox(ent_t* pEnt, S16 x, S16 y)
{
U16 xmax, ymax;
//printf("u_trigbox e=%d x=%d y=%d ", e, x, y);
xmax = pEnt->trig_x + (ent_entdata[pEnt->n & 0x7F].trig_w << 3);
ymax = pEnt->trig_y + (ent_entdata[pEnt->n & 0x7F].trig_h << 3);
if (xmax > 0xFF) xmax = 0xFF;
if (x <= pEnt->trig_x || x > xmax ||
y <= pEnt->trig_y || y > ymax)
return FALSE;
else
return TRUE;
}
/* eof */

65
src/xrick.c Normal file
View file

@ -0,0 +1,65 @@
/*
* xrick/src/xrick.c
*
* Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
*
* The use and distribution terms for this software are contained in the file
* named README, which can be found in the root of this distribution. By
* using this software in any fashion, you are agreeing to be bound by the
* terms of this license.
*
* You must not remove this notice, or any other, from this software.
*/
#include "system.h"
#include "game.h"
#if !(defined(IIGS) || defined(F256))
#include <SDL.h>
#endif
#if defined(IIGS) || defined(F256)
void scr_credit();
#endif
#ifdef IIGS
#include <Memory.h>
#include <orca.h>
/* According to the ORCA/C Documentation
The Tool Locater, Memory Manager, Loader and
SANE are started by all C programs.
*/
void scr_credit();
void IIGShutdown();
#endif
/*
* main
*/
int
main(int argc, char *argv[])
{
#ifdef IIGS
atexit( IIGShutdown ); // Make Sure cleanup stuff is done
#endif
// Get the credit screen up ASAP
scr_credit();
printf("Hello from xrick IIgs\n");
sys_init(argc, argv);
if (sysarg_args_data)
data_setpath(sysarg_args_data);
else
data_setpath("data.zip");
game_run();
data_closepath();
sys_shutdown();
return 0;
}
/* eof */

23
src/xrick.rc Normal file
View file

@ -0,0 +1,23 @@
// xrick/src/xrick.rc
//
// Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved.
//
// The use and distribution terms for this software are contained in the file
// named README, which can be found in the root of this distribution. By
// using this software in any fashion, you are agreeing to be bound by the
// terms of this license.
//
// You must not remove this notice, or any other, from this software.
//
#include "..\include\config.h"
#ifdef GFXST
XRICK_ICON ICON DISCARDABLE "xrickST.ico"
#endif
#ifdef GFXPC
XRICK_ICON ICON DISCARDABLE "xrickPC.ico"
#endif
// eof

BIN
src/xrickPC.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

BIN
src/xrickST.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB