Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marek Ratajczak's 64-bit patch #1218

Open
wants to merge 1 commit into
base: 4.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/shooter/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int main(int argc, char *argv[])
install_joystick(JOY_TYPE_NONE);
}

if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { //GFX_AUTODETECT
if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
allegro_message("Unable to set any graphic mode\n%s\n",
Expand Down
4 changes: 2 additions & 2 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ PACKFILE *pack_fopen_chunk(PACKFILE *f, int pack)
return NULL;
}
_al_sane_strncpy(chunk->normal.passdata, f->normal.passdata, strlen(f->normal.passdata)+1);
chunk->normal.passpos = chunk->normal.passdata + (long)f->normal.passpos - (long)f->normal.passdata;
chunk->normal.passpos = chunk->normal.passdata + (ULONG_PTR)f->normal.passpos - (ULONG_PTR)f->normal.passdata; //64bit long
Copy link
Contributor

@allefant allefant Jan 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ULONG_PTR will not exist in most compilers, did you mean intptr_t?

f->normal.passpos = f->normal.passdata;
}
chunk->normal.flags |= PACKFILE_FLAG_OLD_CRYPT;
Expand Down Expand Up @@ -2188,7 +2188,7 @@ PACKFILE *pack_fclose_chunk(PACKFILE *f)
}

if ((f->normal.passpos) && (f->normal.flags & PACKFILE_FLAG_OLD_CRYPT))
parent->normal.passpos = parent->normal.passdata + (long)f->normal.passpos - (long)f->normal.passdata;
parent->normal.passpos = parent->normal.passdata + (ULONG_PTR)f->normal.passpos - (ULONG_PTR)f->normal.passdata; //64bit long

free_packfile(f);
}
Expand Down
2 changes: 1 addition & 1 deletion src/fsel.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ int file_select_ex(AL_CONST char *message, char *path, AL_CONST char *ext, int s
if (ugetc(get_filename(path))) {
p = get_extension(path);
if ((!ugetc(p)) && (ext) && (ugetc(ext)) && (!ustrpbrk(ext, uconvert_ascii(" ,;", tmp)))) {
size -= ((long)p - (long)path + ucwidth('.'));
size -= ((unsigned long long)p - (unsigned long long)path + ucwidth('.')); //64bit long
if (size >= uwidth_max(U_CURRENT) + ucwidth(0)) { /* do not end with '.' */
p += usetc(p, '.');
ustrzcpy(p, size, ext);
Expand Down
4 changes: 2 additions & 2 deletions src/glyph.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define DRAW_GLYPH(bits, size) \
{ \
AL_CONST unsigned char *data = glyph->dat; \
unsigned long addr; \
unsigned long long addr; \
int w = glyph->w; \
int h = glyph->h; \
int stride = (w+7)/8; \
Expand Down Expand Up @@ -183,7 +183,7 @@ void _linear_draw_glyph24(BITMAP *bmp, AL_CONST FONT_GLYPH *glyph, int x, int y,
*/
void _linear_draw_glyph32(BITMAP *bmp, AL_CONST FONT_GLYPH *glyph, int x, int y, int color, int bg)
{
DRAW_GLYPH(32, sizeof(int32_t));
DRAW_GLYPH(32, sizeof(int32_t)); //64bit int32_t
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/gsprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void _soft_draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, int c1
addr = bmp_write_line(bmp, j) + x1*3;
for (i=x1; i<x2; i++) {
bmp_select(sprite);
pixel = bmp_read24((unsigned long)(sprite->line[j-y] + (i-x)*3));
pixel = bmp_read24((unsigned long long)(sprite->line[j-y] + (i-x)*3)); //64bit unsigned long
bmp_select(bmp);
if (pixel != MASK_COLOR_24) {
pixel = _blender_func24(pixel, _blender_col_24, fixtoi(hc));
Expand Down
4 changes: 2 additions & 2 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static int obj_list_cmp(AL_CONST void *e1, AL_CONST void *e2)
*/
static int cmp_tab(AL_CONST DIALOG *d1, AL_CONST DIALOG *d2)
{
int ret = (int)((AL_CONST unsigned long)d2 - (AL_CONST unsigned long)d1);
int ret = (int)((AL_CONST unsigned long long)d2 - (AL_CONST unsigned long long)d1); //64bit unsigned long

/* Wrap around if d2 is before d1 in the dialog array. */
if (ret < 0)
Expand All @@ -587,7 +587,7 @@ static int cmp_tab(AL_CONST DIALOG *d1, AL_CONST DIALOG *d2)
*/
static int cmp_shift_tab(AL_CONST DIALOG *d1, AL_CONST DIALOG *d2)
{
int ret = (int)((AL_CONST unsigned long)d1 - (AL_CONST unsigned long)d2);
int ret = (int)((AL_CONST unsigned long long)d1 - (AL_CONST unsigned long long)d2); //64bit unsigned long

/* Wrap around if d2 is after d1 in the dialog array. */
if (ret < 0)
Expand Down
8 changes: 4 additions & 4 deletions src/guiproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1365,17 +1365,17 @@ int d_text_list_proc(int msg, DIALOG *d, int c)
thisitem = (*(getfuncptr)d->dp)(i, NULL);
failure = FALSE;

if ((int)((unsigned long)d->dp3) < ustrlen(thisitem)) {
for (a=0; a < (int)((unsigned long)d->dp3); a++) {
if ((int)((unsigned long long)d->dp3) < ustrlen(thisitem)) {
for (a=0; a < (int)((unsigned long long)d->dp3); a++) { //64bit unsigned long
if (utolower(ugetat(thisitem, a)) != utolower(ugetat(selected, a))) {
failure = TRUE;
break;
}
}

if ((!failure) && (utolower(ugetat(thisitem, (int)(unsigned long)d->dp3)) == utolower(c))) {
if ((!failure) && (utolower(ugetat(thisitem, (int)(unsigned long long)d->dp3)) == utolower(c))) {
d->d1 = i;
d->dp3 = (void *)((unsigned long)d->dp3 + 1);
d->dp3 = (void *)((unsigned long long)d->dp3 + 1);

if (sel) {
for (i=0; i<listsize; i++)
Expand Down
12 changes: 6 additions & 6 deletions src/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ int uoffset(AL_CONST char *s, int index)
}
}

return (long)s - (long)orig;
return (long long)s - (long long)orig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cast is pointless to begin with, just change it to: "return s - orig;" instead

}


Expand Down Expand Up @@ -1783,7 +1783,7 @@ int ustrsize(AL_CONST char *s)
last = s;
} while (ugetxc(&s) != 0);

return (long)last - (long)orig;
return (long long)last - (long long)orig;
}


Expand All @@ -1800,7 +1800,7 @@ int ustrsizez(AL_CONST char *s)
do {
} while (ugetxc(&s) != 0);

return (long)s - (long)orig;
return (long long)s - (long long)orig;
}


Expand Down Expand Up @@ -2313,7 +2313,7 @@ long ustrtol(AL_CONST char *s, char **endp, int base)
ret = strtol(t, &myendp, base);

if (endp)
*endp = (char *)s + uoffset(s, (long)myendp - (long)t);
*endp = (char *)s + uoffset(s, (long long)myendp - (long long)t);

return ret;
}
Expand All @@ -2337,7 +2337,7 @@ double ustrtod(AL_CONST char *s, char **endp)
ret = strtod(t, &myendp);

if (endp)
*endp = (char *)s + uoffset(s, (long)myendp - (long)t);
*endp = (char *)s + uoffset(s, (long long)myendp - (long long)t);

return ret;
}
Expand Down Expand Up @@ -2948,7 +2948,7 @@ static int decode_format_string(char *buf, STRING_ARG *string_arg, AL_CONST char

case 'p':
/* pointer */
slen = sprint_hex(string_arg, &info, FALSE, (unsigned long)(va_arg(args, void *)));
slen = sprint_hex(string_arg, &info, FALSE, (unsigned long long)(va_arg(args, void *)));
NEXT_C();
break;

Expand Down
2 changes: 1 addition & 1 deletion src/win/gdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static BYTE *get_dib_from_bitmap(BITMAP *bitmap)
int bpp;
int x, y;
int pitch;
int col;
long col;
BYTE *pixels;
BYTE *src, *dst;

Expand Down
4 changes: 2 additions & 2 deletions src/win/wddlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void gfx_directx_lock(BITMAP *bmp)
bmp->id |= BMP_ID_LOCKED;

/* update the line array if our parent has moved */
pitch = (long)parent->line[1] - (long)parent->line[0];
pitch = (long long)parent->line[1] - (long long)parent->line[0];
data = parent->line[0] +
(bmp->y_ofs - parent->y_ofs) * pitch +
(bmp->x_ofs - parent->x_ofs) * BYTES_PER_PIXEL(bitmap_color_depth(bmp));
Expand Down Expand Up @@ -263,7 +263,7 @@ void gfx_directx_autolock(BITMAP *bmp)
}

/* update the line array if our parent has moved */
pitch = (long)parent->line[1] - (long)parent->line[0];
pitch = (long long)parent->line[1] - (long long)parent->line[0];
data = parent->line[0] +
(bmp->y_ofs - parent->y_ofs) * pitch +
(bmp->x_ofs - parent->x_ofs) * BYTES_PER_PIXEL(bitmap_color_depth(bmp));
Expand Down
2 changes: 1 addition & 1 deletion src/win/wgdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ static struct BITMAP *gfx_gdi_init(int w, int h, int v_w, int v_h, int color_dep

/* create the screen surface */
screen_surf = _AL_MALLOC_ATOMIC(w * h * BYTES_PER_PIXEL(color_depth));
gdi_screen = _make_bitmap(w, h, (unsigned long)screen_surf, &gfx_gdi, color_depth, w * BYTES_PER_PIXEL(color_depth));
gdi_screen = _make_bitmap(w, h, (unsigned long long)screen_surf, &gfx_gdi, color_depth, w * BYTES_PER_PIXEL(color_depth));
if (!gdi_screen) {
_TRACE(PREFIX_E "Could not make a bitmap out of the screen surface.\n");
goto Error;
Expand Down
4 changes: 2 additions & 2 deletions src/win/wmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ int midi_win32_in_init(int input, int voices)
id = (midi_input_driver->id & 0xFF) - 'A';

/* open midi input device */
hr = midiInOpen(&midi_in_device, id, (DWORD)midi_in_proc,
(DWORD)NULL, CALLBACK_FUNCTION);
hr = midiInOpen(&midi_in_device, id, (unsigned long long)midi_in_proc,
(unsigned long long)NULL, CALLBACK_FUNCTION);
if (hr != MMSYSERR_NOERROR) {
_TRACE(PREFIX_E "midiInOpen failed (%x)\n", hr);
midi_win32_in_exit(input);
Expand Down
4 changes: 2 additions & 2 deletions src/win/wsndwo.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static void digi_waveout_mixer_callback(void)
if (++digiwobufpos > (digiwobufdivs-1))
digiwobufpos = 0;

_mix_some_samples((unsigned long) (digiwobufdata+((digiwobufsize/digiwobufdivs)*digiwobufpos)), 0, TRUE);
_mix_some_samples((unsigned long long) (digiwobufdata+((digiwobufsize/digiwobufdivs)*digiwobufpos)), 0, TRUE);
}
}

Expand Down Expand Up @@ -309,7 +309,7 @@ static int digi_waveout_init(int input, int voices)
goto Error;
}

_mix_some_samples((unsigned long) digiwobufdata, 0, TRUE);
_mix_some_samples((unsigned long long) digiwobufdata, 0, TRUE);

/* get volume */
waveOutGetVolume(hWaveOut, &initial_volume);
Expand Down