some pedantic cleanup

svn-id: r6706
This commit is contained in:
Paweł Kołodziejski 2003-03-06 07:52:40 +00:00
parent 255e15248b
commit 7f536134a0
8 changed files with 229 additions and 239 deletions

View file

@ -55,8 +55,8 @@ void SkyState::initialise_disk()
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);
@ -81,8 +81,7 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest)
#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) {
@ -90,12 +89,12 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *dest)
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);
@ -182,7 +181,6 @@ uint16 *SkyState::load_file(uint16 file_nr, uint8 *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;
@ -195,10 +193,10 @@ 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));
} }
} }

View file

@ -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)

View file

@ -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,7 +76,7 @@ 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;
@ -85,7 +84,7 @@ uint16 crc_block(uint8 *block, uint32 size)
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];
@ -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);
} }
} }
@ -170,13 +168,13 @@ uint16 input_value(uint16 *table)
} while (valOne != valTwo); } while (valOne != valTwo);
value = *(table+0x1e); value = *(table + 0x1e);
input_bits((uint8)((value>>8)&0x00FF)); input_bits((uint8)((value>>8) & 0x00FF));
value &= 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;
} }
@ -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;

View file

@ -57,24 +57,23 @@ void SkyState::initialise_screen(void)
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;
} }
} }

View file

@ -91,7 +91,6 @@ void SkyState::initialise(void)
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

View file

@ -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

View file

@ -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;
}; };