some pedantic cleanup
svn-id: r6706
This commit is contained in:
parent
255e15248b
commit
7f536134a0
8 changed files with 229 additions and 239 deletions
72
sky/disk.cpp
72
sky/disk.cpp
|
@ -45,22 +45,22 @@ File *dnr_handle = new File();
|
||||||
void SkyState::initialise_disk()
|
void SkyState::initialise_disk()
|
||||||
{
|
{
|
||||||
uint32 entries_read;
|
uint32 entries_read;
|
||||||
|
|
||||||
dnr_handle->open(dinner_file_name, _gameDataPath);
|
dnr_handle->open(dinner_file_name, _gameDataPath);
|
||||||
if (dnr_handle->isOpen() == false)
|
if (dnr_handle->isOpen() == false)
|
||||||
error("Could not open %s%s!\n", _gameDataPath, dinner_file_name);
|
error("Could not open %s%s!\n", _gameDataPath, dinner_file_name);
|
||||||
|
|
||||||
if (!(dinner_table_size = dnr_handle->readUint32LE()))
|
if (!(dinner_table_size = dnr_handle->readUint32LE()))
|
||||||
error("Error reading from sky.dnr!\n"); //even though it was opened correctly?!
|
error("Error reading from sky.dnr!\n"); //even though it was opened correctly?!
|
||||||
|
|
||||||
debug(1, "Entries in dinner table: %d", dinner_table_size);
|
debug(1, "Entries in dinner table: %d", dinner_table_size);
|
||||||
|
|
||||||
dinner_table_area = (uint8 *)malloc(dinner_table_size*8);
|
dinner_table_area = (uint8 *)malloc(dinner_table_size * 8);
|
||||||
entries_read = dnr_handle->read(dinner_table_area, 8*dinner_table_size) / 8;
|
entries_read = dnr_handle->read(dinner_table_area, 8 * dinner_table_size) / 8;
|
||||||
|
|
||||||
if (entries_read != dinner_table_size)
|
if (entries_read != dinner_table_size)
|
||||||
warning("bytes_read != dinner_table_entries. [%d/%d]\n", entries_read, dinner_table_size);
|
warning("bytes_read != dinner_table_entries. [%d/%d]\n", entries_read, dinner_table_size);
|
||||||
|
|
||||||
data_disk_handle->open(data_file_name, _gameDataPath);
|
data_disk_handle->open(data_file_name, _gameDataPath);
|
||||||
if (data_disk_handle->isOpen() == false)
|
if (data_disk_handle->isOpen() == false)
|
||||||
error("Error opening %s%s!\n", _gameDataPath, data_file_name);
|
error("Error opening %s%s!\n", _gameDataPath, data_file_name);
|
||||||
|
@ -79,31 +79,30 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest)
|
||||||
#ifdef file_order_chk
|
#ifdef file_order_chk
|
||||||
warning("File order checking not implemented yet!\n");
|
warning("File order checking not implemented yet!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
comp_file = file_nr;
|
comp_file = file_nr;
|
||||||
debug(1, "load file %d,%d (%d)", (file_nr>>11), (file_nr&2047), file_nr);
|
debug(1, "load file %d,%d (%d)", (file_nr >> 11), (file_nr & 2047), file_nr);
|
||||||
|
|
||||||
|
|
||||||
file_ptr = (uint8 *)get_file_info(file_nr);
|
file_ptr = (uint8 *)get_file_info(file_nr);
|
||||||
if (file_ptr == NULL) {
|
if (file_ptr == NULL) {
|
||||||
printf("File %d not found!\n", file_nr);
|
printf("File %d not found!\n", file_nr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
eax = READ_LE_UINT32((file_ptr+5));
|
eax = READ_LE_UINT32((file_ptr + 5));
|
||||||
file_flags = eax;
|
file_flags = eax;
|
||||||
eax &= 0x03fffff;
|
eax &= 0x03fffff;
|
||||||
file_size = eax;
|
file_size = eax;
|
||||||
|
|
||||||
ecx = READ_LE_UINT32((file_ptr+2));
|
ecx = READ_LE_UINT32((file_ptr + 2));
|
||||||
ecx &= 0x0ffffff;
|
ecx &= 0x0ffffff;
|
||||||
|
|
||||||
cflag = (uint8)((ecx >> (23)) & 0x1);
|
cflag = (uint8)((ecx >> (23)) & 0x1);
|
||||||
ecx = (((1 << (23)) ^ 0xFFFFFFFF) & ecx);
|
ecx = (((1 << (23)) ^ 0xFFFFFFFF) & ecx);
|
||||||
|
|
||||||
if (cflag)
|
if (cflag)
|
||||||
ecx = ecx << 4;
|
ecx = ecx << 4;
|
||||||
|
|
||||||
file_offset = ecx;
|
file_offset = ecx;
|
||||||
fixed_dest = dest;
|
fixed_dest = dest;
|
||||||
file_dest = dest;
|
file_dest = dest;
|
||||||
|
@ -111,7 +110,7 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest)
|
||||||
|
|
||||||
if (dest == NULL) //we need to allocate memory for this file
|
if (dest == NULL) //we need to allocate memory for this file
|
||||||
file_dest = (uint8 *)malloc(eax);
|
file_dest = (uint8 *)malloc(eax);
|
||||||
|
|
||||||
data_disk_handle->seek(file_offset, SEEK_SET);
|
data_disk_handle->seek(file_offset, SEEK_SET);
|
||||||
|
|
||||||
#ifdef file_order_chk
|
#ifdef file_order_chk
|
||||||
|
@ -120,14 +119,14 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest)
|
||||||
|
|
||||||
//now read in the data
|
//now read in the data
|
||||||
bytes_read = data_disk_handle->read(file_dest, 1*file_size);
|
bytes_read = data_disk_handle->read(file_dest, 1*file_size);
|
||||||
|
|
||||||
if (bytes_read != (int32)file_size)
|
if (bytes_read != (int32)file_size)
|
||||||
printf("ERROR: Unable to read %d bytes from datadisk (%d bytes read)\n", file_size, bytes_read);
|
printf("ERROR: Unable to read %d bytes from datadisk (%d bytes read)\n", file_size, bytes_read);
|
||||||
|
|
||||||
cflag = (uint8)((file_flags >> (23)) & 0x1);
|
cflag = (uint8)((file_flags >> (23)) & 0x1);
|
||||||
|
|
||||||
//if cflag == 0 then file is compressed, 1 == uncompressed
|
//if cflag == 0 then file is compressed, 1 == uncompressed
|
||||||
|
|
||||||
if (!cflag)
|
if (!cflag)
|
||||||
{
|
{
|
||||||
debug(1, "File is compressed...");
|
debug(1, "File is compressed...");
|
||||||
|
@ -135,20 +134,20 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest)
|
||||||
memcpy(&file_header, file_dest, sizeof(struct dataFileHeader));
|
memcpy(&file_header, file_dest, sizeof(struct dataFileHeader));
|
||||||
if ( (uint8)((FROM_LE_16(file_header.flag) >> 7) & 0x1) ) {
|
if ( (uint8)((FROM_LE_16(file_header.flag) >> 7) & 0x1) ) {
|
||||||
debug(1, "with RNC!");
|
debug(1, "with RNC!");
|
||||||
|
|
||||||
eax = FROM_LE_16(file_header.flag);
|
eax = FROM_LE_16(file_header.flag);
|
||||||
eax &= 0xFFFFFF00; //clear al
|
eax &= 0xFFFFFF00; //clear al
|
||||||
eax = eax << 8;
|
eax = eax << 8;
|
||||||
eax |= FROM_LE_16((uint16)file_header.s_tot_size);
|
eax |= FROM_LE_16((uint16)file_header.s_tot_size);
|
||||||
|
|
||||||
decomp_size = eax;
|
decomp_size = eax;
|
||||||
|
|
||||||
if (fixed_dest == NULL) // is this valid?
|
if (fixed_dest == NULL) // is this valid?
|
||||||
comp_dest = (uint8 *)malloc(eax);
|
comp_dest = (uint8 *)malloc(eax);
|
||||||
|
|
||||||
esiptr = file_dest;
|
esiptr = file_dest;
|
||||||
ediptr = comp_dest;
|
ediptr = comp_dest;
|
||||||
|
|
||||||
if ( (uint8)(file_flags >> (22) & 0x1) ) //do we include the header?
|
if ( (uint8)(file_flags >> (22) & 0x1) ) //do we include the header?
|
||||||
esiptr += sizeof(struct dataFileHeader);
|
esiptr += sizeof(struct dataFileHeader);
|
||||||
else {
|
else {
|
||||||
|
@ -158,7 +157,7 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest)
|
||||||
}
|
}
|
||||||
|
|
||||||
eax = UnpackM1(esiptr, ediptr, 0);
|
eax = UnpackM1(esiptr, ediptr, 0);
|
||||||
|
|
||||||
debug(2, "UnpackM1 returned: %d", eax);
|
debug(2, "UnpackM1 returned: %d", eax);
|
||||||
|
|
||||||
if (eax == 0) { //Unpack returned 0: file was probably not packed.
|
if (eax == 0) { //Unpack returned 0: file was probably not packed.
|
||||||
|
@ -167,41 +166,40 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest)
|
||||||
|
|
||||||
return (uint16 *)file_dest;
|
return (uint16 *)file_dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (uint8)(file_flags >> (22) & 0x1) ) { // include header?
|
if (! (uint8)(file_flags >> (22) & 0x1) ) { // include header?
|
||||||
eax += sizeof(struct dataFileHeader);
|
eax += sizeof(struct dataFileHeader);
|
||||||
|
|
||||||
if (eax != decomp_size) {
|
if (eax != decomp_size) {
|
||||||
debug(1, "ERROR: invalid decomp size! (was: %d, should be: %d)", eax, decomp_size);
|
debug(1, "ERROR: invalid decomp size! (was: %d, should be: %d)", eax, decomp_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fixed_dest == NULL)
|
if (fixed_dest == NULL)
|
||||||
free(file_dest);
|
free(file_dest);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
debug(1, "but not with RNC! (?!)");
|
debug(1, "but not with RNC! (?!)");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return (uint16 *)file_dest;
|
return (uint16 *)file_dest;
|
||||||
|
|
||||||
return (uint16 *)comp_dest;
|
return (uint16 *)comp_dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16 *SkyState::get_file_info(uint16 file_nr)
|
uint16 *SkyState::get_file_info(uint16 file_nr)
|
||||||
{
|
{
|
||||||
uint16 i;
|
uint16 i;
|
||||||
uint16 *dnr_tbl_16_ptr = (uint16 *)dinner_table_area;
|
uint16 *dnr_tbl_16_ptr = (uint16 *)dinner_table_area;
|
||||||
|
|
||||||
for (i = 0; i < dinner_table_size/2; i++) {
|
for (i = 0; i < dinner_table_size / 2; i++) {
|
||||||
if (READ_LE_UINT16(dnr_tbl_16_ptr+(i*4)) == file_nr) {
|
if (READ_LE_UINT16(dnr_tbl_16_ptr + (i * 4)) == file_nr) {
|
||||||
debug(1, "file %d found!", file_nr);
|
debug(1, "file %d found!", file_nr);
|
||||||
return (dnr_tbl_16_ptr+(i*4));
|
return (dnr_tbl_16_ptr + (i * 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if file is speech file then return NULL if not found
|
// if file is speech file then return NULL if not found
|
||||||
printf("get_file_info() - speech file support not implemented yet!\n");
|
printf("get_file_info() - speech file support not implemented yet!\n");
|
||||||
return (uint16 *)NULL;
|
return (uint16 *)NULL;
|
||||||
|
|
207
sky/intro.cpp
207
sky/intro.cpp
|
@ -53,10 +53,10 @@
|
||||||
#define rev_time 8
|
#define rev_time 8
|
||||||
#define gibb_time 6
|
#define gibb_time 6
|
||||||
#else
|
#else
|
||||||
#define virgin_time_1 (3*50)
|
#define virgin_time_1 (3 * 50)
|
||||||
#define virgin_time_2 ((3*50)+8)
|
#define virgin_time_2 ((3 * 50) + 8)
|
||||||
#define rev_time ((8*50)+8)
|
#define rev_time ((8 * 50) + 8)
|
||||||
#define gibb_time ((6*50)+8)
|
#define gibb_time ((6 * 50) + 8)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void prepare_text(void);
|
void prepare_text(void);
|
||||||
|
@ -77,7 +77,6 @@ uint8 *seq5_data;
|
||||||
uint8 *seq6a_data;
|
uint8 *seq6a_data;
|
||||||
uint8 *seq6b_data;
|
uint8 *seq6b_data;
|
||||||
|
|
||||||
|
|
||||||
uint8 *vga_data;
|
uint8 *vga_data;
|
||||||
uint8 *diff_data;
|
uint8 *diff_data;
|
||||||
|
|
||||||
|
@ -100,145 +99,143 @@ uint32 frame_counter;
|
||||||
#define ic_make_sound 3
|
#define ic_make_sound 3
|
||||||
#define ic_fx_volume 4
|
#define ic_fx_volume 4
|
||||||
|
|
||||||
|
|
||||||
typedef void (*pfc)(void);
|
typedef void (*pfc)(void);
|
||||||
pfc command_routines[] = { &prepare_text, &show_intro_text, &remove_text, &intro_fx, &intro_vol };
|
pfc command_routines[] = { &prepare_text, &show_intro_text, &remove_text, &intro_fx, &intro_vol };
|
||||||
|
|
||||||
uint32 cockpit_commands[] =
|
uint32 cockpit_commands[] =
|
||||||
{
|
{
|
||||||
1000, //do straight away
|
1000, //do straight away
|
||||||
ic_prepare_text,
|
ic_prepare_text,
|
||||||
77,
|
77,
|
||||||
220,
|
220,
|
||||||
ic_show_text, //radar detects jamming signal
|
ic_show_text, //radar detects jamming signal
|
||||||
20,
|
20,
|
||||||
160,
|
160,
|
||||||
105,
|
105,
|
||||||
ic_remove_text,
|
ic_remove_text,
|
||||||
81,
|
81,
|
||||||
105,
|
105,
|
||||||
ic_show_text, //well switch to override you fool
|
ic_show_text, //well switch to override you fool
|
||||||
170,
|
170,
|
||||||
86,
|
86,
|
||||||
35,
|
35,
|
||||||
ic_remove_text,
|
ic_remove_text,
|
||||||
35,
|
35,
|
||||||
ic_prepare_text,
|
ic_prepare_text,
|
||||||
477,
|
477,
|
||||||
35,
|
35,
|
||||||
ic_show_text,
|
ic_show_text,
|
||||||
30,
|
30,
|
||||||
160,
|
160,
|
||||||
3,
|
3,
|
||||||
ic_remove_text
|
ic_remove_text
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 zero_commands[] = { 0 };
|
uint32 zero_commands[] = { 0 };
|
||||||
|
|
||||||
uint32 anim5_commands[] =
|
uint32 anim5_commands[] =
|
||||||
{
|
{
|
||||||
31,
|
31,
|
||||||
ic_make_sound,
|
ic_make_sound,
|
||||||
2,
|
2,
|
||||||
127,
|
127,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 anim4a_commands[] =
|
uint32 anim4a_commands[] =
|
||||||
{
|
{
|
||||||
136,
|
136,
|
||||||
ic_make_sound,
|
ic_make_sound,
|
||||||
1,
|
1,
|
||||||
70,
|
70,
|
||||||
90,
|
90,
|
||||||
ic_fx_volume,
|
ic_fx_volume,
|
||||||
80,
|
80,
|
||||||
50,
|
50,
|
||||||
ic_fx_volume,
|
ic_fx_volume,
|
||||||
90,
|
90,
|
||||||
5,
|
5,
|
||||||
ic_fx_volume,
|
ic_fx_volume,
|
||||||
100,
|
100,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 anim4c_commands[] =
|
uint32 anim4c_commands[] =
|
||||||
{
|
{
|
||||||
1000,
|
1000,
|
||||||
ic_fx_volume,
|
ic_fx_volume,
|
||||||
100,
|
100,
|
||||||
25,
|
25,
|
||||||
ic_fx_volume,
|
ic_fx_volume,
|
||||||
110,
|
110,
|
||||||
15,
|
15,
|
||||||
ic_fx_volume,
|
ic_fx_volume,
|
||||||
120,
|
120,
|
||||||
4,
|
4,
|
||||||
ic_fx_volume,
|
ic_fx_volume,
|
||||||
127,
|
127,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 anim6a_commands[] =
|
uint32 anim6a_commands[] =
|
||||||
{
|
{
|
||||||
1000,
|
1000,
|
||||||
ic_prepare_text,
|
ic_prepare_text,
|
||||||
478,
|
478,
|
||||||
13,
|
13,
|
||||||
ic_show_text,
|
ic_show_text,
|
||||||
175,
|
175,
|
||||||
155,
|
155,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 anim6b_commands[] =
|
uint32 anim6b_commands[] =
|
||||||
{
|
{
|
||||||
131,
|
131,
|
||||||
ic_remove_text,
|
ic_remove_text,
|
||||||
131,
|
131,
|
||||||
ic_prepare_text,
|
ic_prepare_text,
|
||||||
479,
|
479,
|
||||||
74,
|
74,
|
||||||
ic_show_text,
|
ic_show_text,
|
||||||
175,
|
175,
|
||||||
155,
|
155,
|
||||||
45,
|
45,
|
||||||
ic_remove_text,
|
ic_remove_text,
|
||||||
45,
|
45,
|
||||||
ic_prepare_text,
|
ic_prepare_text,
|
||||||
162,
|
162,
|
||||||
44,
|
44,
|
||||||
ic_show_text,
|
ic_show_text,
|
||||||
175,
|
175,
|
||||||
155,
|
155,
|
||||||
4,
|
4,
|
||||||
ic_remove_text,
|
ic_remove_text,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 *command_pointer = (uint32 *)zero_commands;
|
uint32 *command_pointer = (uint32 *)zero_commands;
|
||||||
|
|
||||||
|
|
||||||
void SkyState::init_virgin()
|
void SkyState::init_virgin()
|
||||||
{
|
{
|
||||||
_temp_pal = (uint8 *)load_file(60111, NULL);
|
_temp_pal = (uint8 *)load_file(60111, NULL);
|
||||||
if (_temp_pal != NULL)
|
if (_temp_pal != NULL)
|
||||||
set_palette(_temp_pal);
|
set_palette(_temp_pal);
|
||||||
|
|
||||||
_work_screen = (uint8 *)load_file(60110, NULL);
|
_work_screen = (uint8 *)load_file(60110, NULL);
|
||||||
|
|
||||||
if (_work_screen != NULL)
|
if (_work_screen != NULL)
|
||||||
show_screen();
|
show_screen();
|
||||||
|
|
||||||
// free the memory that was malloc'ed indirectly via load_file
|
// free the memory that was malloc'ed indirectly via load_file
|
||||||
free(_work_screen);
|
free(_work_screen);
|
||||||
free(_temp_pal);
|
free(_temp_pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyState::show_screen(void)
|
void SkyState::show_screen(void)
|
||||||
{
|
{
|
||||||
_system->copy_rect(_work_screen, 320, 0, 0, 320, 200);
|
_system->copy_rect(_work_screen, 320, 0, 0, 320, 200);
|
||||||
_system->update_screen();
|
_system->update_screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare_text(void)
|
void prepare_text(void)
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
|
||||||
#define ROL(x, n) (((x) << (n)) | ((x) >> (16-(n))))
|
#define ROL(x, n) (((x) << (n)) | ((x) >> (16 - (n))))
|
||||||
#define ROR(x, n) (((x) << (16-(n))) | ((x) >> (n)))
|
#define ROR(x, n) (((x) << (16 - (n))) | ((x) >> (n)))
|
||||||
#define XCHG(a, b) (a ^=b, b ^= a, a ^= b)
|
#define XCHG(a, b) (a ^=b, b ^= a, a ^= b)
|
||||||
|
|
||||||
//conditional flags
|
//conditional flags
|
||||||
|
@ -36,13 +36,13 @@
|
||||||
#define UNPACKED_CRC -2
|
#define UNPACKED_CRC -2
|
||||||
|
|
||||||
//other defines
|
//other defines
|
||||||
#define TABLE_SIZE (16*8)
|
#define TABLE_SIZE (16 * 8)
|
||||||
#define MIN_LENGTH 2
|
#define MIN_LENGTH 2
|
||||||
#define HEADER_LEN 18
|
#define HEADER_LEN 18
|
||||||
|
|
||||||
uint16 raw_table[TABLE_SIZE/2];
|
uint16 raw_table[TABLE_SIZE / 2];
|
||||||
uint16 pos_table[TABLE_SIZE/2];
|
uint16 pos_table[TABLE_SIZE / 2];
|
||||||
uint16 len_table[TABLE_SIZE/2];
|
uint16 len_table[TABLE_SIZE / 2];
|
||||||
|
|
||||||
#ifdef CHECKSUMS
|
#ifdef CHECKSUMS
|
||||||
uint16 crc_table[0x100];
|
uint16 crc_table[0x100];
|
||||||
|
@ -52,14 +52,13 @@ uint16 bit_buffl = 0;
|
||||||
uint16 bit_buffh = 0;
|
uint16 bit_buffh = 0;
|
||||||
uint8 bit_count = 0;
|
uint8 bit_count = 0;
|
||||||
|
|
||||||
|
|
||||||
uint8 *esiptr, *ediptr; //these need to be global because input_bits() uses them
|
uint8 *esiptr, *ediptr; //these need to be global because input_bits() uses them
|
||||||
|
|
||||||
void init_crc()
|
void init_crc()
|
||||||
{
|
{
|
||||||
uint16 cnt=0;
|
uint16 cnt = 0;
|
||||||
uint16 tmp1=0;
|
uint16 tmp1 = 0;
|
||||||
uint16 tmp2=0;
|
uint16 tmp2 = 0;
|
||||||
|
|
||||||
for (tmp2 = 0; tmp2 < 0x100; tmp2++) {
|
for (tmp2 = 0; tmp2 < 0x100; tmp2++) {
|
||||||
tmp1 = tmp2;
|
tmp1 = tmp2;
|
||||||
|
@ -77,19 +76,19 @@ void init_crc()
|
||||||
//calculate 16 bit crc of a block of memory
|
//calculate 16 bit crc of a block of memory
|
||||||
uint16 crc_block(uint8 *block, uint32 size)
|
uint16 crc_block(uint8 *block, uint32 size)
|
||||||
{
|
{
|
||||||
uint16 crc=0;
|
uint16 crc = 0;
|
||||||
uint8 *crcTable8 = (uint8 *)crc_table; //make a uint8* to crc_table
|
uint8 *crcTable8 = (uint8 *)crc_table; //make a uint8* to crc_table
|
||||||
uint8 tmp;
|
uint8 tmp;
|
||||||
uint32 i;
|
uint32 i;
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
tmp = *block++;
|
tmp = *block++;
|
||||||
crc ^= tmp;
|
crc ^= tmp;
|
||||||
tmp = (uint8)((crc>>8)&0x00FF);
|
tmp = (uint8)((crc >> 8) & 0x00FF);
|
||||||
crc &= 0x00FF;
|
crc &= 0x00FF;
|
||||||
crc = crc << 1;
|
crc = crc << 1;
|
||||||
crc = *(uint16 *)&crcTable8[crc];
|
crc = *(uint16 *)&crcTable8[crc];
|
||||||
crc ^= tmp;
|
crc ^= tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return crc;
|
return crc;
|
||||||
|
@ -116,7 +115,7 @@ uint16 input_bits(uint8 amount)
|
||||||
newBitBuffh = READ_LE_UINT16(esiptr);
|
newBitBuffh = READ_LE_UINT16(esiptr);
|
||||||
XCHG(newBitCount, amount);
|
XCHG(newBitCount, amount);
|
||||||
amount -= newBitCount;
|
amount -= newBitCount;
|
||||||
newBitCount = 16 - amount;
|
newBitCount = 16 - amount;
|
||||||
}
|
}
|
||||||
remBits = ROR((uint16)(((1 << amount) - 1) & newBitBuffh), amount);
|
remBits = ROR((uint16)(((1 << amount) - 1) & newBitBuffh), amount);
|
||||||
bit_buffh = newBitBuffh >> amount;
|
bit_buffh = newBitBuffh >> amount;
|
||||||
|
@ -124,7 +123,6 @@ uint16 input_bits(uint8 amount)
|
||||||
bit_count = (uint8)newBitCount;
|
bit_count = (uint8)newBitCount;
|
||||||
|
|
||||||
return returnVal;
|
return returnVal;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void make_huftable(uint16 *table)
|
void make_huftable(uint16 *table)
|
||||||
|
@ -153,7 +151,7 @@ void make_huftable(uint16 *table)
|
||||||
a |= ((b >> j) & 1) << (bitLength - j - 1);
|
a |= ((b >> j) & 1) << (bitLength - j - 1);
|
||||||
*table++ = a;
|
*table++ = a;
|
||||||
|
|
||||||
*(table+0x1e) = (huffLength[i]<<8)|(i & 0x00FF);
|
*(table + 0x1e) = (huffLength[i] << 8)|(i & 0x00FF);
|
||||||
huffCode += 1 << (16 - bitLength);
|
huffCode += 1 << (16 - bitLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,20 +161,20 @@ void make_huftable(uint16 *table)
|
||||||
uint16 input_value(uint16 *table)
|
uint16 input_value(uint16 *table)
|
||||||
{
|
{
|
||||||
uint16 valOne, valTwo, value = bit_buffl;
|
uint16 valOne, valTwo, value = bit_buffl;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
valTwo = (*table++) & value;
|
valTwo = (*table++) & value;
|
||||||
valOne = *table++;
|
valOne = *table++;
|
||||||
|
|
||||||
} while (valOne != valTwo);
|
|
||||||
|
|
||||||
value = *(table+0x1e);
|
} while (valOne != valTwo);
|
||||||
input_bits((uint8)((value>>8)&0x00FF));
|
|
||||||
value &= 0x00FF;
|
value = *(table + 0x1e);
|
||||||
|
input_bits((uint8)((value>>8) & 0x00FF));
|
||||||
|
value &= 0x00FF;
|
||||||
|
|
||||||
if (value >= 2) {
|
if (value >= 2) {
|
||||||
value--;
|
value--;
|
||||||
valOne = input_bits((uint8)value&0x00FF);
|
valOne = input_bits((uint8)value & 0x00FF);
|
||||||
valOne |= (1 << value);
|
valOne |= (1 << value);
|
||||||
value = valOne;
|
value = valOne;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +199,7 @@ int UnpackM1(void *input, void *output, uint16 key)
|
||||||
if (CHECKSUMS)
|
if (CHECKSUMS)
|
||||||
init_crc();
|
init_crc();
|
||||||
|
|
||||||
//Check for "RNC "
|
//Check for "RNC "
|
||||||
if (READ_BE_UINT32(inputptr) != 0x524e4301)
|
if (READ_BE_UINT32(inputptr) != 0x524e4301)
|
||||||
return NOT_PACKED;
|
return NOT_PACKED;
|
||||||
|
|
||||||
|
@ -211,25 +209,25 @@ int UnpackM1(void *input, void *output, uint16 key)
|
||||||
unpack_len = READ_BE_UINT32(inputptr); inputptr += 4;
|
unpack_len = READ_BE_UINT32(inputptr); inputptr += 4;
|
||||||
pack_len = READ_BE_UINT32(inputptr); inputptr += 4;
|
pack_len = READ_BE_UINT32(inputptr); inputptr += 4;
|
||||||
|
|
||||||
uint8 blocks = *(inputptr+5);
|
uint8 blocks = *(inputptr + 5);
|
||||||
|
|
||||||
if (CHECKSUMS) {
|
if (CHECKSUMS) {
|
||||||
//read CRC's
|
//read CRC's
|
||||||
crc_u = READ_BE_UINT16(inputptr); inputptr += 2;
|
crc_u = READ_BE_UINT16(inputptr); inputptr += 2;
|
||||||
crc_p = READ_BE_UINT16(inputptr); inputptr += 2;
|
crc_p = READ_BE_UINT16(inputptr); inputptr += 2;
|
||||||
inputptr = (inputptr+HEADER_LEN-16);
|
inputptr = (inputptr + HEADER_LEN - 16);
|
||||||
|
|
||||||
if (crc_block(inputptr, pack_len) != crc_p)
|
if (crc_block(inputptr, pack_len) != crc_p)
|
||||||
return PACKED_CRC;
|
return PACKED_CRC;
|
||||||
|
|
||||||
inputptr = (((uint8 *)input)+HEADER_LEN);
|
inputptr = (((uint8 *)input) + HEADER_LEN);
|
||||||
esiptr = inputptr;
|
esiptr = inputptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// inputLow = *input
|
// inputLow = *input
|
||||||
inputHigh = ((uint8 *)input) + pack_len + HEADER_LEN;;
|
inputHigh = ((uint8 *)input) + pack_len + HEADER_LEN;;
|
||||||
outputLow = (uint8 *)output;
|
outputLow = (uint8 *)output;
|
||||||
outputHigh = *(((uint8 *)input)+16) + unpack_len + outputLow;
|
outputHigh = *(((uint8 *)input) + 16) + unpack_len + outputLow;
|
||||||
|
|
||||||
if (! ((inputHigh <= outputLow) || (outputHigh <= inputHigh)) ) {
|
if (! ((inputHigh <= outputLow) || (outputHigh <= inputHigh)) ) {
|
||||||
esiptr = inputHigh;
|
esiptr = inputHigh;
|
||||||
|
@ -265,7 +263,7 @@ int UnpackM1(void *input, void *output, uint16 key)
|
||||||
bit_buffl &= d;
|
bit_buffl &= d;
|
||||||
d &= a;
|
d &= a;
|
||||||
|
|
||||||
a = READ_LE_UINT16((esiptr+2));
|
a = READ_LE_UINT16((esiptr + 2));
|
||||||
b = (b << bit_count);
|
b = (b << bit_count);
|
||||||
a = (a << bit_count);
|
a = (a << bit_count);
|
||||||
a |= d;
|
a |= d;
|
||||||
|
|
|
@ -55,26 +55,25 @@ void SkyState::initialise_screen(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint8 tmp_pal[1024];
|
uint8 tmp_pal[1024];
|
||||||
|
|
||||||
_system->init_size(full_screen_width, full_screen_height);
|
_system->init_size(full_screen_width, full_screen_height);
|
||||||
_backscreen = (uint8 *)malloc(full_screen_width*full_screen_height);
|
_backscreen = (uint8 *)malloc(full_screen_width * full_screen_height);
|
||||||
_game_grid = (uint8 *)malloc(GRID_X*GRID_Y*2);
|
_game_grid = (uint8 *)malloc(GRID_X * GRID_Y * 2);
|
||||||
_work_palette = (uint8 *)malloc(vga_colours*3);
|
_work_palette = (uint8 *)malloc(vga_colours * 3);
|
||||||
|
|
||||||
//blank the first 240 colors of the palette
|
//blank the first 240 colors of the palette
|
||||||
memset(tmp_pal, 0, game_colours * 4);
|
memset(tmp_pal, 0, game_colours * 4);
|
||||||
|
|
||||||
//set the remaining colors
|
//set the remaining colors
|
||||||
for (i = 0; i < (vga_colours-game_colours); i++) {
|
for (i = 0; i < (vga_colours-game_colours); i++) {
|
||||||
tmp_pal[game_colours+i*4] = (top_16_colours[i*3] << 2) + (top_16_colours[i*3] & 3);
|
tmp_pal[game_colours + i * 4] = (top_16_colours[i * 3] << 2) + (top_16_colours[i * 3] & 3);
|
||||||
tmp_pal[game_colours+i*4+1] = (top_16_colours[i*3+1] << 2) + (top_16_colours[i*3+1] & 3);
|
tmp_pal[game_colours + i * 4 + 1] = (top_16_colours[i * 3 + 1] << 2) + (top_16_colours[i * 3 + 1] & 3);
|
||||||
tmp_pal[game_colours+i*4+2] = (top_16_colours[i*3+2] << 2) + (top_16_colours[i*3+2] & 3);
|
tmp_pal[game_colours + i * 4 + 2] = (top_16_colours[i * 3 + 2] << 2) + (top_16_colours[i * 3 + 2] & 3);
|
||||||
tmp_pal[game_colours+i*4+3] = 0x00;
|
tmp_pal[game_colours + i * 4 + 3] = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
//set the palette
|
//set the palette
|
||||||
_system->set_palette(tmp_pal, 0, 256);
|
_system->set_palette(tmp_pal, 0, 256);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//set a new palette, pal is a pointer to dos vga rgb components 0..63
|
//set a new palette, pal is a pointer to dos vga rgb components 0..63
|
||||||
|
@ -89,9 +88,9 @@ void SkyState::convert_palette(uint8 *inpal, uint8* outpal) //convert 3 byte 0..
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < vga_colours; i++) {
|
for (i = 0; i < vga_colours; i++) {
|
||||||
outpal[4*i] = (inpal[3*i] << 2) + (inpal[3*i] & 3);
|
outpal[4 * i] = (inpal[3 * i] << 2) + (inpal[3 * i] & 3);
|
||||||
outpal[4*i+1] = (inpal[3*i+1] << 2) + (inpal[3*i+1] & 3);
|
outpal[4 * i + 1] = (inpal[3 * i + 1] << 2) + (inpal[3 * i + 1] & 3);
|
||||||
outpal[4*i+2] = (inpal[3*i+2] << 2) + (inpal[3*i+2] & 3);
|
outpal[4 * i + 2] = (inpal[3 * i + 2] << 2) + (inpal[3 * i + 2] & 3);
|
||||||
outpal[4*i+3] = 0x00;
|
outpal[4 * i + 3] = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,9 +89,8 @@ void SkyState::initialise(void)
|
||||||
//init_timer();
|
//init_timer();
|
||||||
//init_music();
|
//init_music();
|
||||||
initialise_disk();
|
initialise_disk();
|
||||||
initialise_screen();
|
initialise_screen();
|
||||||
init_virgin();
|
init_virgin();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyState::delay(uint amount) //copied and mutilated from Simon.cpp
|
void SkyState::delay(uint amount) //copied and mutilated from Simon.cpp
|
||||||
|
|
|
@ -68,7 +68,7 @@ protected:
|
||||||
void delay(uint amount);
|
void delay(uint amount);
|
||||||
void pollMouseXY();
|
void pollMouseXY();
|
||||||
void go();
|
void go();
|
||||||
void convert_palette(uint8 *inpal, uint8* outpal);
|
void convert_palette(uint8 *inpal, uint8* outpal);
|
||||||
|
|
||||||
void initialise();
|
void initialise();
|
||||||
void initialise_disk();
|
void initialise_disk();
|
||||||
|
@ -82,7 +82,7 @@ protected:
|
||||||
static int CDECL game_thread_proc(void *param);
|
static int CDECL game_thread_proc(void *param);
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
RandomSource _rnd;
|
RandomSource _rnd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,25 +27,25 @@
|
||||||
#define sequence_count 3
|
#define sequence_count 3
|
||||||
|
|
||||||
//screen/grid defines
|
//screen/grid defines
|
||||||
#define game_screen_width 320
|
#define game_screen_width 320
|
||||||
#define game_screen_height 192
|
#define game_screen_height 192
|
||||||
#define full_screen_width 320
|
#define full_screen_width 320
|
||||||
#define full_screen_height 200
|
#define full_screen_height 200
|
||||||
|
|
||||||
#define tot_no_grids 70
|
#define tot_no_grids 70
|
||||||
|
|
||||||
#define grid_size 120
|
#define grid_size 120
|
||||||
|
|
||||||
#define GRID_X 20
|
#define GRID_X 20
|
||||||
#define GRID_Y 24
|
#define GRID_Y 24
|
||||||
#define GRID_W 16
|
#define GRID_W 16
|
||||||
#define GRID_H 8
|
#define GRID_H 8
|
||||||
|
|
||||||
#define GRID_W_SHIFT 4
|
#define GRID_W_SHIFT 4
|
||||||
#define GRID_H_SHIFT 3
|
#define GRID_H_SHIFT 3
|
||||||
|
|
||||||
#define top_left_x 128
|
#define top_left_x 128
|
||||||
#define top_left_y 136
|
#define top_left_y 136
|
||||||
|
|
||||||
//item list defines
|
//item list defines
|
||||||
#define section_0_item 119
|
#define section_0_item 119
|
||||||
|
@ -54,37 +54,36 @@
|
||||||
#define c_base_mode56 56
|
#define c_base_mode56 56
|
||||||
#define c_action_mode 4
|
#define c_action_mode 4
|
||||||
#define c_sp_colour 90
|
#define c_sp_colour 90
|
||||||
#define c_mega_set 112
|
#define c_mega_set 112
|
||||||
#define c_grid_width 114
|
#define c_grid_width 114
|
||||||
|
|
||||||
//#define next_mega_set
|
//#define next_mega_set
|
||||||
|
|
||||||
#define send_sync -1
|
#define send_sync -1
|
||||||
#define lf_start_fx -2
|
#define lf_start_fx -2
|
||||||
#define safe_start_screen 0
|
#define safe_start_screen 0
|
||||||
|
|
||||||
//autoroute defines
|
//autoroute defines
|
||||||
#define upy 0
|
#define upy 0
|
||||||
#define downy 1
|
#define downy 1
|
||||||
#define lefty 2
|
#define lefty 2
|
||||||
#define righty 3
|
#define righty 3
|
||||||
|
|
||||||
#define route_space 64
|
#define route_space 64
|
||||||
|
|
||||||
#define l_script 1
|
#define l_script 1
|
||||||
#define l_ar 2
|
#define l_ar 2
|
||||||
#define l_ar_anim 3
|
#define l_ar_anim 3
|
||||||
#define l_ar_turning 4
|
#define l_ar_turning 4
|
||||||
#define l_alt 5
|
#define l_alt 5
|
||||||
#define l_mod_animate 6
|
#define l_mod_animate 6
|
||||||
#define l_turning 7
|
#define l_turning 7
|
||||||
#define l_cursor 8
|
#define l_cursor 8
|
||||||
#define l_talk 9
|
#define l_talk 9
|
||||||
#define l_listen 10
|
#define l_listen 10
|
||||||
#define l_stopped 11
|
#define l_stopped 11
|
||||||
#define l_choose 12
|
#define l_choose 12
|
||||||
#define l_frames 13
|
#define l_frames 13
|
||||||
#define l_pause 14
|
#define l_pause 14
|
||||||
#define l_wait_synch 15
|
#define l_wait_synch 15
|
||||||
#define l_simple_mod 16
|
#define l_simple_mod 16
|
||||||
|
|
||||||
|
|
26
sky/struc.h
26
sky/struc.h
|
@ -21,18 +21,18 @@
|
||||||
|
|
||||||
struct dataFileHeader
|
struct dataFileHeader
|
||||||
{
|
{
|
||||||
uint16 flag; // bit 0: set for colour data, clear for not
|
uint16 flag; // bit 0: set for colour data, clear for not
|
||||||
// bit 1: set for compressed, clear for uncompressed
|
// bit 1: set for compressed, clear for uncompressed
|
||||||
// bit 2: set for 32 colours, clear for 16 colours
|
// bit 2: set for 32 colours, clear for 16 colours
|
||||||
uint16 s_x;
|
uint16 s_x;
|
||||||
uint16 s_y;
|
uint16 s_y;
|
||||||
uint16 s_width;
|
uint16 s_width;
|
||||||
uint16 s_height;
|
uint16 s_height;
|
||||||
uint16 s_sp_size;
|
uint16 s_sp_size;
|
||||||
uint16 s_tot_size;
|
uint16 s_tot_size;
|
||||||
uint16 s_n_sprites;
|
uint16 s_n_sprites;
|
||||||
uint16 s_offset_x;
|
uint16 s_offset_x;
|
||||||
uint16 s_offset_y;
|
uint16 s_offset_y;
|
||||||
uint16 s_compressed_size;
|
uint16 s_compressed_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue