Movie handles avoid assuming pointer size is 32 bits

This commit is contained in:
Dan Raviv 2024-04-16 12:02:41 -07:00
parent 9fdf9c63b7
commit 3f11c5d78e
4 changed files with 17 additions and 17 deletions

View File

@ -131,7 +131,7 @@ tCinematic *StartMovie(const char *moviename, bool looping) {
SetMovieProperties(0, 0, Max_window_w, Max_window_h, Renderer_type);
int filehandle;
unsigned int hMovie = mve_SequenceStart(filename, &filehandle, Descent, looping);
intptr_t hMovie = mve_SequenceStart(filename, &filehandle, Descent, looping);
if (hMovie == 0)
return NULL;
@ -147,8 +147,8 @@ bool FrameMovie(tCinematic *mve, int x, int y, bool sequence) {
return false;
int bm_handle;
unsigned int hNewMovie = mve_SequenceFrame(mve->mvehandle, mve->filehandle, sequence, &bm_handle);
if (hNewMovie != (unsigned int)(-1)) {
intptr_t hNewMovie = mve_SequenceFrame(mve->mvehandle, mve->filehandle, sequence, &bm_handle);
if (hNewMovie != -1) {
// we must have looped, we have a new handle
mve->mvehandle = hNewMovie;
}
@ -167,7 +167,7 @@ bool FrameMovie(tCinematic *mve, int x, int y, bool sequence) {
rend_CopyBitmapToFramebuffer(bm_handle, x, y);
}
return (hNewMovie != (unsigned int)(-1));
return (hNewMovie != -1);
}
void EndMovie(tCinematic *mve) {

View File

@ -38,7 +38,7 @@
// Movie Cinematic
typedef struct tCinematic {
unsigned mvehandle;
intptr_t mvehandle;
int filehandle;
chunked_bitmap frame_chunk; // used internally, don't access.
} tCinematic;
@ -50,4 +50,4 @@ tCinematic *StartMovie(const char *moviename, bool looping = false);
bool FrameMovie(tCinematic *mve, int x, int y, bool sequence = true);
void EndMovie(tCinematic *mve);
#endif
#endif

View File

@ -20,16 +20,16 @@ int mve_PlayMovie(const char *mvename, oeApplication *app);
// used to copy movie data to a pointer, looping will loop, fhandle will be a pointer to a file handle to be returned
// handle to movie sequence is returned by function.
unsigned int mve_SequenceStart(const char *mvename, int *fhandle, oeApplication *app, bool looping = false);
intptr_t mve_SequenceStart(const char *mvename, int *fhandle, oeApplication *app, bool looping = false);
// frames movies started with SequenceStart. Optionally, pass a pointer to a variable which will receive
// bitmap handle containing data, nx and ny will contain adjusted x and y coordinates if needed.
// passing -1 to x and y centers the frame on that axis
// handle is the movie handle returned by mve_Sequence start
// returned value is the handle passed into mve_SequenceFrame or new one if movie looped.
unsigned int mve_SequenceFrame(unsigned int handle, int fhandle, bool sequence, int *bm_handle);
intptr_t mve_SequenceFrame(intptr_t handle, int fhandle, bool sequence, int *bm_handle);
bool mve_SequenceClose(unsigned int handle, int fhandle);
bool mve_SequenceClose(intptr_t handle, int fhandle);
// sets render frame boundaries.
void mve_SetRenderProperties(short x, short y, short w, short h, renderer_type type, bool hicolor);

View File

@ -663,7 +663,7 @@ void CallbackShowFrame(unsigned char *buf, unsigned int bufw, unsigned int bufh,
}
#endif
unsigned int mve_SequenceStart(const char *mvename, int *fhandle, oeApplication *app, bool looping) {
intptr_t mve_SequenceStart(const char *mvename, int *fhandle, oeApplication *app, bool looping) {
#ifndef NO_MOVIES
int hfile = open(mvename, O_RDONLY | O_BINARY);
@ -686,20 +686,20 @@ unsigned int mve_SequenceStart(const char *mvename, int *fhandle, oeApplication
rend_SetFrameBufferCopyState(true);
*fhandle = hfile;
return (unsigned int)MVE_frOpen(CallbackFileRead, hfile, NULL);
return (intptr_t)MVE_frOpen(CallbackFileRead, hfile, NULL);
#else
return 0;
#endif
}
unsigned int mve_SequenceFrame(unsigned int handle, int fhandle, bool sequence, int *bm_handle) {
intptr_t mve_SequenceFrame(intptr_t handle, int fhandle, bool sequence, int *bm_handle) {
#ifndef NO_MOVIES
if (bm_handle) {
*bm_handle = -1;
}
if (handle == -1) {
return (unsigned int)(-1);
return -1;
}
static unsigned sw = 0, sh = 0, hicolor = 0;
@ -739,18 +739,18 @@ reread_frame:
#else
lseek(fhandle, 0, SEEK_SET);
#endif
handle = (unsigned int)MVE_frOpen(CallbackFileRead, fhandle, NULL);
handle = (intptr_t)MVE_frOpen(CallbackFileRead, fhandle, NULL);
sequence = true;
goto reread_frame;
}
return (unsigned int)(-1);
return -1;
#else
return (unsigned int)(-1);
return -1;
#endif
}
bool mve_SequenceClose(unsigned int hMovie, int hFile) {
bool mve_SequenceClose(intptr_t hMovie, int hFile) {
#ifndef NO_MOVIES
if (hMovie == -1)
return false;