Commit 61188d2b authored by MCMic's avatar MCMic 🎮

Applied clang-format to the code. Added .clang-format file as well

I had to revert clang-format changes is some corner cases for
readability
parent 426dde5a
---
BasedOnStyle: LLVM
---
Language: Cpp
UseTab: ForContinuationAndIndentation
TabWidth: 4
IndentWidth: 4
AllowShortIfStatementsOnASingleLine: false
ColumnLimit: 0
BreakBeforeBraces: Linux
SpaceAfterCStyleCast: true
IndentCaseLabels: true
...
......@@ -25,9 +25,9 @@
#include <stdlib.h>
#ifdef DOS
#include <pc.h>
#include <dpmi.h>
#include <go32.h>
#include <pc.h>
#include <sys/nearptr.h>
#endif
......@@ -38,38 +38,37 @@
#define DJ_SFX_TYPE_WAV 1
#define DJ_SFX_TYPE_SMP 2
typedef struct dj_hardware_info {
char sd_type;
short sd_version;
short sd_version;
short port;
char irq;
char dma;
} dj_hardware_info;
typedef struct dj_mixing_info {
char sfx_volume, num_sfx_channels;
char mod_volume, num_mod_channels;
char sfx_volume, num_sfx_channels;
char mod_volume, num_mod_channels;
char stereo_mix, auto_mix;
unsigned short mixing_freq;
unsigned short dma_time, dmabuf_len;
char cur_dmabuf;
unsigned short mixing_freq;
unsigned short dma_time, dmabuf_len;
char cur_dmabuf;
unsigned long dmabuf_address[2];
char *mixed_buf;
char *mixed_buf;
} dj_mixing_info;
typedef struct sfx_data {
char priority;
unsigned short default_freq;
char default_volume;
unsigned long length;
char loop;
unsigned long loop_start, loop_length;
unsigned char *buf;
char priority;
unsigned short default_freq;
char default_volume;
unsigned long length;
char loop;
unsigned long loop_start, loop_length;
unsigned char *buf;
} sfx_data;
typedef struct dj_mod_info {
char num_channels;
char num_channels;
char speed;
short bpm;
char order_pos;
......@@ -87,10 +86,9 @@ typedef struct dj_mod_info {
char song_length;
char num_pat;
char pat_order[128];
char *pat[128];
char *pat[128];
} dj_mod_info;
extern char dj_init(void);
extern void dj_deinit(void);
extern void dj_start(void);
......@@ -132,4 +130,3 @@ extern void dj_set_mod_volume(char volume);
extern char dj_get_mod_volume(void);
extern char dj_load_mod(unsigned char *file_handle, char *filename, char mod_num);
extern void dj_free_mod(char mod_num);
......@@ -27,7 +27,7 @@
typedef unsigned char byte;
static int scale2x_inited = 0;
static byte lookup_map[4*16];
static byte lookup_map[4 * 16];
void init_scale2x(void)
{
......@@ -57,22 +57,22 @@ void init_scale2x(void)
// #define getCode(b,f,h,d) ( (b == f)<<0 | (f == h)<<1 | (h == d)<<2 | (d == b)<<3 )
// encode the scale2x conditionals into a lookup code
for (i=0; i<16; i++) {
for (i = 0; i < 16; i++) {
// E0 = D == B && B != F && D != H ? D : E; // 10-0 => 1000 or 1010 => 8 or A
lookup_map[0*16+i] = (i == 0x8 || i == 0xA) ? 0 : 1;
lookup_map[0 * 16 + i] = (i == 0x8 || i == 0xA) ? 0 : 1;
// E1 = B == F && B != D && F != H ? F : E; // 0-01 => 0101 or 0001 => 5 or 1
lookup_map[1*16+i] = (i == 0x5 || i == 0x1) ? 2 : 1;
lookup_map[1 * 16 + i] = (i == 0x5 || i == 0x1) ? 2 : 1;
// E2 = D == H && D != B && H != F ? D : E; // 010- => 0101 or 0100 => 5 or 4
lookup_map[2*16+i] = (i == 0x4 || i == 0x5) ? 0 : 1;
lookup_map[2 * 16 + i] = (i == 0x4 || i == 0x5) ? 0 : 1;
// E3 = H == F && D != H && B != F ? F : E; // -010 => 1010 or 0010 => A or 2
lookup_map[3*16+i] = (i == 0xA || i == 0x2) ? 2 : 1;
lookup_map[3 * 16 + i] = (i == 0xA || i == 0x2) ? 2 : 1;
}
}
void do_scale2x(unsigned char *src,
int src_width,
int src_height,
unsigned char *dst)
int src_width,
int src_height,
unsigned char *dst)
{
int x;
int y;
......@@ -106,52 +106,63 @@ void do_scale2x(unsigned char *src,
rowColors[0] = *e;
rowColors[1] = *e;
rowColors[2] = *f;
code = ( (*f == *h)<<1 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
e++; f++; h++;
code = ((*f == *h) << 1);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
e++;
f++;
h++;
d = &src[src_width]; // (src_width - 1) + 1
e0+=2; e1+=2; e2+=2; e3+=2;
e0 += 2;
e1 += 2;
e2 += 2;
e3 += 2;
// normal case
for (x=1; x<(src_width-1); x++) {
for (x = 1; x < (src_width - 1); x++) {
rowColors[0] = *d;
rowColors[1] = *e;
rowColors[2] = *f;
code = ( (*f == *h)<<1 | (*h == *d)<<2 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
d++; e++; f++; h++;
e0+=2; e1+=2; e2+=2; e3+=2;
code = ((*f == *h) << 1 | (*h == *d) << 2);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
d++;
e++;
f++;
h++;
e0 += 2;
e1 += 2;
e2 += 2;
e3 += 2;
}
// special right case - f is unknown
rowColors[0] = *d;
rowColors[1] = *e;
rowColors[2] = *e;
code = ( (*h == *d)<<2 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
code = ((*h == *d) << 2);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
}
// top and bottom always known
for (y=1; y<(src_height-1); y++) {
for (y = 1; y < (src_height - 1); y++) {
byte *b;
byte *d;
byte *e;
byte *f;
byte *h;
e0 = &dst[y*dst_width*2];
e1 = &dst[y*dst_width*2 + 1];
e2 = &dst[y*dst_width*2 + dst_width];
e3 = &dst[y*dst_width*2 + dst_width + 1];
e0 = &dst[y * dst_width * 2];
e1 = &dst[y * dst_width * 2 + 1];
e2 = &dst[y * dst_width * 2 + dst_width];
e3 = &dst[y * dst_width * 2 + dst_width + 1];
b = &src[y * src_width - src_width];
e = &src[y * src_width];
f = &src[y * src_width + 1];
......@@ -161,38 +172,51 @@ void do_scale2x(unsigned char *src,
rowColors[0] = *e;
rowColors[1] = *e;
rowColors[2] = *f;
code = ( (*b == *f)<<0 | (*f == *h)<<1 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
b++; e++; f++; h++;
code = ((*b == *f) << 0 | (*f == *h) << 1);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
b++;
e++;
f++;
h++;
d = &src[y * src_width]; // (y * src_width - 1) + 1
e0+=2; e1+=2; e2+=2; e3+=2;
e0 += 2;
e1 += 2;
e2 += 2;
e3 += 2;
// normal case
for (x=1; x<(src_width-1); x++) {
for (x = 1; x < (src_width - 1); x++) {
rowColors[0] = *d;
rowColors[1] = *e;
rowColors[2] = *f;
code = ( (*b == *f)<<0 | (*f == *h)<<1 | (*h == *d)<<2 | (*d == *b)<<3 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
b++; d++; e++; f++; h++;
e0+=2; e1+=2; e2+=2; e3+=2;
code = ((*b == *f) << 0 | (*f == *h) << 1 | (*h == *d) << 2 | (*d == *b) << 3);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
b++;
d++;
e++;
f++;
h++;
e0 += 2;
e1 += 2;
e2 += 2;
e3 += 2;
}
// special right case - f is unknown
rowColors[0] = *d;
rowColors[1] = *e;
rowColors[2] = *e;
code = ( (*h == *d)<<2 | (*d == *b)<<3 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
code = ((*h == *d) << 2 | (*d == *b) << 3);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
}
// special bottom case - h is always unknown
......@@ -202,10 +226,10 @@ void do_scale2x(unsigned char *src,
byte *e;
byte *f;
e0 = &dst[y*dst_width*2];
e1 = &dst[y*dst_width*2 + 1];
e2 = &dst[y*dst_width*2 + dst_width];
e3 = &dst[y*dst_width*2 + dst_width + 1];
e0 = &dst[y * dst_width * 2];
e1 = &dst[y * dst_width * 2 + 1];
e2 = &dst[y * dst_width * 2 + dst_width];
e3 = &dst[y * dst_width * 2 + dst_width + 1];
b = &src[y * src_width - src_width];
e = &src[y * src_width];
f = &src[y * src_width + 1];
......@@ -214,37 +238,48 @@ void do_scale2x(unsigned char *src,
rowColors[0] = *e;
rowColors[1] = *e;
rowColors[2] = *f;
code = ( (*b == *f)<<0 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
b++; e++; f++;
code = ((*b == *f) << 0);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
b++;
e++;
f++;
d = &src[y * src_width]; // (y * src_width - 1) + 1
e0+=2; e1+=2; e2+=2; e3+=2;
e0 += 2;
e1 += 2;
e2 += 2;
e3 += 2;
// normal case
for (x=1; x<(src_width-1); x++) {
for (x = 1; x < (src_width - 1); x++) {
rowColors[0] = *d;
rowColors[1] = *e;
rowColors[2] = *f;
code = ( (*b == *f)<<0 | (*d == *b)<<3 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
b++; d++; e++; f++;
e0+=2; e1+=2; e2+=2; e3+=2;
code = ((*b == *f) << 0 | (*d == *b) << 3);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
b++;
d++;
e++;
f++;
e0 += 2;
e1 += 2;
e2 += 2;
e3 += 2;
}
// special right case - f is unknown
rowColors[0] = *d;
rowColors[1] = *e;
rowColors[2] = *e;
code = ( (*d == *b)<<3 );
*e0 = rowColors[lookup_map[0*16+code]];
*e1 = rowColors[lookup_map[1*16+code]];
*e2 = rowColors[lookup_map[2*16+code]];
*e3 = rowColors[lookup_map[3*16+code]];
code = ((*d == *b) << 3);
*e0 = rowColors[lookup_map[0 * 16 + code]];
*e1 = rowColors[lookup_map[1 * 16 + code]];
*e2 = rowColors[lookup_map[2 * 16 + code]];
*e3 = rowColors[lookup_map[3 * 16 + code]];
}
}
......@@ -27,8 +27,8 @@
#define __FILTER_H__
void do_scale2x(unsigned char *src,
int src_width,
int src_height,
unsigned char *dst);
int src_width,
int src_height,
unsigned char *dst);
#endif /* __FILTER_H__ */
This diff is collapsed.
......@@ -33,7 +33,7 @@ char menu_pal[768];
char menu_cur_pal[768];
char *message[] = {
"Jump 'n Bump "JNB_VERSION,
"Jump 'n Bump " JNB_VERSION,
"by Brainchild Design in 1998.",
"Code by Mattias Brynervall.",
"Graphics by Martin Magnusson",
......@@ -47,10 +47,9 @@ char *message[] = {
"libregames.gitlab.io/jumpnbump",
"Jump 'n Bump is free software",
"licensed under GPL 2.0 or later.",
""
};
""};
#define NUM_MESSAGES (sizeof(message)/sizeof(char *))
#define NUM_MESSAGES (sizeof(message) / sizeof(char *))
int menu(void)
{
......@@ -86,7 +85,7 @@ int menu(void)
mod_vol = 0;
mod_fade_direction = 1;
dj_ready_mod(MOD_MENU);
dj_set_mod_volume((char)mod_vol);
dj_set_mod_volume((char) mod_vol);
dj_set_sfx_volume(64);
dj_start_mod();
dj_set_nosound(0);
......@@ -111,7 +110,7 @@ int menu(void)
dj_mix();
for(c1 = 0; c1 < JNB_MAX_PLAYERS; c1++) // set AI to false
for (c1 = 0; c1 < JNB_MAX_PLAYERS; c1++) // set AI to false
ai[c1] = 0;
while (update_count) {
......@@ -344,7 +343,7 @@ int menu(void)
player[c1].frame_tick = 0;
player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
player[c1].jump_ready = 0;
dj_play_sfx(SFX_JUMP, (unsigned short)(SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
dj_play_sfx(SFX_JUMP, (unsigned short) (SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
}
} else {
if ((player[c1].y >> 16) >= (138 + c1 * 2)) {
......@@ -354,7 +353,7 @@ int menu(void)
player[c1].frame_tick = 0;
player[c1].image = player_anims[player[c1].anim].frame[player[c1].frame].image + player[c1].direction * 9;
player[c1].jump_ready = 0;
dj_play_sfx(SFX_JUMP, (unsigned short)(SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
dj_play_sfx(SFX_JUMP, (unsigned short) (SFX_JUMP_FREQ + rnd(2000) - 1000), 64, 0, 0, -1);
}
}
}
......@@ -449,12 +448,12 @@ int menu(void)
if (mod_fade_direction == 1) {
if (mod_vol < 35) {
mod_vol++;
dj_set_mod_volume((char)mod_vol);
dj_set_mod_volume((char) mod_vol);
}
} else {
if (mod_vol > 0) {
mod_vol--;
dj_set_mod_volume((char)mod_vol);
dj_set_mod_volume((char) mod_vol);
}
}
}
......@@ -477,40 +476,40 @@ int menu(void)
return 1;
}
switch (fade_dir) {
case 0:
if (fade_count < 30) {
for (c1 = 0; c1 < 48; c1++) {
if (fade_pal[c1] > 0)
fade_pal[c1]--;
case 0:
if (fade_count < 30) {
for (c1 = 0; c1 < 48; c1++) {
if (fade_pal[c1] > 0)
fade_pal[c1]--;
}
fade_count++;
} else {
draw_begin();
clear_lines(0, 220, 20, 0);
clear_lines(1, 220, 20, 0);
cur_message++;
if (cur_message >= NUM_MESSAGES)
cur_message -= NUM_MESSAGES;
put_text(0, 200, 220, message[cur_message], 2);
put_text(1, 200, 220, message[cur_message], 2);
fade_dir = 1;
fade_count = 0;
draw_end();
}
fade_count++;
} else {
draw_begin();
clear_lines(0, 220, 20, 0);
clear_lines(1, 220, 20, 0);
cur_message++;
if (cur_message >= NUM_MESSAGES)
cur_message -= NUM_MESSAGES;
put_text(0, 200, 220, message[cur_message], 2);
put_text(1, 200, 220, message[cur_message], 2);
fade_dir = 1;
fade_count = 0;
draw_end();
}
break;
case 1:
if (fade_count < 100) {
for (c1 = 0; c1 < 48; c1++) {
if (fade_pal[c1] < menu_pal[c1 + 720])
fade_pal[c1]++;
break;
case 1:
if (fade_count < 100) {
for (c1 = 0; c1 < 48; c1++) {
if (fade_pal[c1] < menu_pal[c1 + 720])
fade_pal[c1]++;
}
fade_count++;
} else {
fade_dir = 0;
fade_count = 0;
}
fade_count++;
} else {
fade_dir = 0;
fade_count = 0;
}
break;
break;
}
for (c1 = 0; c1 < 48; c1++) {
......@@ -545,15 +544,12 @@ int menu(void)
}
update_count = intr_sysupdate();
}
menu_deinit();
return 0;
}
int menu_init(void)
{
unsigned char *handle;
......@@ -565,7 +561,7 @@ int menu_init(void)
strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
return 1;
}
if (read_pcx(handle, background_pic, JNB_WIDTH*JNB_HEIGHT, menu_pal) != 0) {
if (read_pcx(handle, background_pic, JNB_WIDTH * JNB_HEIGHT, menu_pal) != 0) {
strcpy(main_info.error_str, "Error loading 'menu.pcx', aborting...\n");
return 1;
}
......@@ -573,7 +569,7 @@ int menu_init(void)
strcpy(main_info.error_str, "Error loading 'menumask.pcx', aborting...\n");
return 1;
}
if (read_pcx(handle, mask_pic, JNB_WIDTH*JNB_HEIGHT, 0) != 0) {
if (read_pcx(handle, mask_pic, JNB_WIDTH * JNB_HEIGHT, 0) != 0) {
strcpy(main_info.error_str, "Error loading 'menumask.pcx', aborting...\n");
return 1;
}
......@@ -613,10 +609,8 @@ int menu_init(void)
main_info.page_info[1].num_pobs = 0;
return 0;
}
void menu_deinit(void)
{
dj_set_nosound(1);
......
......@@ -12,9 +12,9 @@ typedef struct {
void **orig_data;
} gob_t;
static void read_pcx(FILE * handle, void *buf, int buf_len, char *pal)
static void read_pcx(FILE *handle, void *buf, int buf_len, char *pal)
{
unsigned char *buffer=buf;
unsigned char *buffer = buf;
short c1;
short a, b;
long ofs1;
......@@ -41,7 +41,7 @@ static void read_pcx(FILE * handle, void *buf, int buf_len, char *pal)
static void write_pcx(FILE *pcxfile, unsigned char *data, int width, int height, unsigned char *palette)
{
int i;
int i;
fputc(0x0a, pcxfile); /* manufacturer */
fputc(5, pcxfile); /* version */
......@@ -72,11 +72,10 @@ static void write_pcx(FILE *pcxfile, unsigned char *data, int width, int height,
/* pack the image */
for (i = 0 ; i < width*height ; i++)
if ( (*data & 0xc0) != 0xc0)
for (i = 0; i < width * height; i++)
if ((*data & 0xc0) != 0xc0)
fputc(*data++, pcxfile);
else
{
else {
fputc(0xc1, pcxfile);
fputc(*data++, pcxfile);
}
......@@ -85,10 +84,10 @@ static void write_pcx(FILE *pcxfile, unsigned char *data, int width, int height,
fputc(0x0c, pcxfile); /* palette ID byte */
if (palette)
for (i = 0 ; i < 768 ; i++)
for (i = 0; i < 768; i++)
fputc(*palette++, pcxfile);
else
for (i = 0 ; i < 768 ; i++)
for (i = 0; i < 768; i++)
fputc(i / 3, pcxfile);
}
......@@ -100,29 +99,33 @@ int read_gob(FILE *handle, gob_t *gob, int len)
gob_data = malloc(len);
fread(gob_data, 1, len, handle);
gob->num_images = (short)((gob_data[0]) + (gob_data[1] << 8));
gob->num_images = (short) ((gob_data[0]) + (gob_data[1] << 8));
gob->width = malloc(gob->num_images*sizeof(int));
gob->height = malloc(gob->num_images*sizeof(int));
gob->hs_x = malloc(gob->num_images*sizeof(int));
gob->hs_y = malloc(gob->num_images*sizeof(int));
gob->data = malloc(gob->num_images*sizeof(void *));
gob->orig_data = malloc(gob->num_images*sizeof(void *));
for (i=0; i<gob->num_images; i++) {
gob->width = malloc(gob->num_images * sizeof(int));
gob->height = malloc(gob->num_images * sizeof(int));
gob->hs_x = malloc(gob->num_images * sizeof(int));
gob->hs_y = malloc(gob->num_images * sizeof(int));
gob->data = malloc(gob->num_images * sizeof(void *));
gob->orig_data = malloc(gob->num_images * sizeof(void *));
for (i = 0; i < gob->num_images; i++) {
int image_size;
int offset;
offset = (gob_data[i*4+2]) + (gob_data[i*4+3] << 8) + (gob_data[i*4+4] << 16) + (gob_data[i*4+5] << 24);
offset = (gob_data[i * 4 + 2]) + (gob_data[i * 4 + 3] << 8) + (gob_data[i * 4 + 4] << 16) + (gob_data[i * 4 + 5] << 24);
gob->width[i] = (short)((gob_data[offset]) + (gob_data[offset+1] << 8)); offset += 2;
gob->height[i] = (short)((gob_data[offset]) + (gob_data[offset+1] << 8)); offset += 2;
gob->hs_x[i] = (short)((gob_data[offset]) + (gob_data[offset+1] << 8)); offset += 2;
gob->hs_y[i] = (short)((gob_data[offset]) + (gob_data[offset+1] << 8)); offset += 2;
gob->width[i] = (short) ((gob_data[offset]) + (gob_data[offset + 1] << 8));
offset += 2;
gob->height[i] = (short) ((gob_data[offset]) + (gob_data[offset + 1] << 8));
offset += 2;
gob->hs_x[i] = (short) ((gob_data[offset]) + (gob_data[offset + 1] << 8));
offset += 2;
gob->hs_y[i] = (short) ((gob_data[offset]) + (gob_data[offset + 1] << 8));
offset += 2;
image_size = gob->width[i] * gob->height[i];
gob->orig_data[i] = malloc(image_size);
memcpy(gob->orig_data[i], &gob_data[offset], image_size);
gob->data[i] = (unsigned short *)gob->orig_data[i];
gob->data[i] = (unsigned short *) gob->orig_data[i];
}
free(gob_data);
return 0;
......@@ -138,7 +141,7 @@ int write_gob(FILE *handle, gob_t *gob)
offset = 2 + (gob->num_images * 4);
for (i=0; i<gob->num_images; i++) {
for (i = 0; i < gob->num_images; i++) {
fputc((offset >> 0) & 0xff, handle);
fputc((offset >> 8) & 0xff, handle);
fputc((offset >> 16) & 0xff, handle);
......@@ -147,7 +150,7 @@ int write_gob(FILE *handle, gob_t *gob)
offset += 8;
offset += gob->width[i] * gob->height[i];
}
for (i=0; i<gob->num_images; i++) {
for (i = 0; i < gob->num_images; i++) {
fputc((gob->width[i] >> 0) & 0xff, handle);
fputc((gob->width[i] >> 8) & 0xff, handle);
......@@ -186,7 +189,7 @@ int main(int argc, char **argv)
} else
usage = 1;
}
if (usage) {
printf("Usage: gobpack [-u] <file> [palette.pcx]\n\t-u to unpack the gob\n");