mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
MVE: Switch to D2X implementation (first run)
Adapting movie and mve interfaces each other. Converted open() to fopen() et al. calls. movie expected image as RGB565 from old mve, but now it's RGB555, so there no need additional conversion. Fixed hicolor related conversion of width in movie's callbacks. Headers cleanup in both subsystems. Sound and frame callbacks are still unavailable.
This commit is contained in:
parent
a5b86bd0fb
commit
b94458f561
@ -28,8 +28,7 @@
|
|||||||
#include "appdatabase.h"
|
#include "appdatabase.h"
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <cstring>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static struct {
|
static struct {
|
||||||
@ -144,7 +143,7 @@ tCinematic *StartMovie(const char *moviename, bool looping) {
|
|||||||
|
|
||||||
SetMovieProperties(0, 0, Max_window_w, Max_window_h, Renderer_type);
|
SetMovieProperties(0, 0, Max_window_w, Max_window_h, Renderer_type);
|
||||||
|
|
||||||
int filehandle;
|
FILE *filehandle;
|
||||||
intptr_t hMovie = mve_SequenceStart(filename, &filehandle, Descent, looping);
|
intptr_t hMovie = mve_SequenceStart(filename, &filehandle, Descent, looping);
|
||||||
if (hMovie == 0)
|
if (hMovie == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
// Movie Cinematic
|
// Movie Cinematic
|
||||||
struct tCinematic {
|
struct tCinematic {
|
||||||
intptr_t mvehandle;
|
intptr_t mvehandle;
|
||||||
int filehandle;
|
void *filehandle;
|
||||||
chunked_bitmap frame_chunk; // used internally, don't access.
|
chunked_bitmap frame_chunk; // used internally, don't access.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
18
lib/movie.h
18
lib/movie.h
@ -24,12 +24,12 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#define MVELIB_NOERROR 0
|
#define MVELIB_NOERROR 0
|
||||||
#define MVELIB_FILE_ERROR -1
|
#define MVELIB_FILE_ERROR (-1)
|
||||||
#define MVELIB_NOTINIT_ERROR -2
|
#define MVELIB_NOTINIT_ERROR (-2)
|
||||||
#define MVELIB_DDGR_ERROR -3
|
#define MVELIB_DDGR_ERROR (-3)
|
||||||
#define MVELIB_INIT_ERROR -4
|
#define MVELIB_INIT_ERROR (-4)
|
||||||
#define MVELIB_PLAYBACK_ERROR -5
|
#define MVELIB_PLAYBACK_ERROR (-5)
|
||||||
#define MVELIB_PLAYBACK_ABORTED -6
|
#define MVELIB_PLAYBACK_ABORTED (-6)
|
||||||
|
|
||||||
class oeApplication;
|
class oeApplication;
|
||||||
|
|
||||||
@ -40,16 +40,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
|
// 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.
|
// handle to movie sequence is returned by function.
|
||||||
intptr_t mve_SequenceStart(const char *mvename, int *fhandle, oeApplication *app, bool looping = false);
|
intptr_t mve_SequenceStart(const char *mvename, void *fhandle, oeApplication *app, bool looping = false);
|
||||||
|
|
||||||
// frames movies started with SequenceStart. Optionally, pass a pointer to a variable which will receive
|
// 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.
|
// 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
|
// passing -1 to x and y centers the frame on that axis
|
||||||
// handle is the movie handle returned by mve_Sequence start
|
// 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.
|
// returned value is the handle passed into mve_SequenceFrame or new one if movie looped.
|
||||||
intptr_t mve_SequenceFrame(intptr_t handle, int fhandle, bool sequence, int *bm_handle);
|
intptr_t mve_SequenceFrame(intptr_t handle, void *fhandle, bool sequence, int *bm_handle);
|
||||||
|
|
||||||
bool mve_SequenceClose(intptr_t handle, int fhandle);
|
bool mve_SequenceClose(intptr_t handle, void *fhandle);
|
||||||
|
|
||||||
// sets render frame boundaries.
|
// sets render frame boundaries.
|
||||||
void mve_SetRenderProperties(int16_t x, int16_t y, int16_t w, int16_t h, renderer_type type, bool hicolor);
|
void mve_SetRenderProperties(int16_t x, int16_t y, int16_t w, int16_t h, renderer_type type, bool hicolor);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
set(CPPS
|
set(CPPS
|
||||||
|
# mveasm.cpp
|
||||||
|
# mvelibl.cpp
|
||||||
|
# platform.cpp
|
||||||
lnxdsound.cpp
|
lnxdsound.cpp
|
||||||
mveasm.cpp
|
|
||||||
mvelibl.cpp
|
|
||||||
platform.cpp
|
|
||||||
|
|
||||||
# d2x implementation
|
# d2x implementation
|
||||||
decoder8.cpp
|
decoder8.cpp
|
||||||
|
@ -17,9 +17,8 @@
|
|||||||
|
|
||||||
/* 16 bit decoding routines */
|
/* 16 bit decoding routines */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <cstring>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "decoders.h"
|
#include "decoders.h"
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
/* 8 bit decoding routines */
|
/* 8 bit decoding routines */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#include "decoders.h"
|
#include "decoders.h"
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#ifndef _LIBMVE_H
|
#ifndef _LIBMVE_H
|
||||||
#define _LIBMVE_H
|
#define _LIBMVE_H
|
||||||
|
|
||||||
|
#include "SystemInterfaces.h"
|
||||||
|
|
||||||
#define MVE_ERR_EOF 1
|
#define MVE_ERR_EOF 1
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -35,6 +37,8 @@ void MVE_rmEndMovie(void);
|
|||||||
|
|
||||||
void MVE_getVideoSpec(MVE_videoSpec *vSpec);
|
void MVE_getVideoSpec(MVE_videoSpec *vSpec);
|
||||||
|
|
||||||
|
void MVE_sndInit(ISoundDevice *lpDS);
|
||||||
|
|
||||||
void MVE_sndInit(int x);
|
void MVE_sndInit(int x);
|
||||||
|
|
||||||
typedef unsigned int (*mve_cb_Read)(void *stream, void *buffer, unsigned int count);
|
typedef unsigned int (*mve_cb_Read)(void *stream, void *buffer, unsigned int count);
|
||||||
@ -43,7 +47,8 @@ typedef void *(*mve_cb_Alloc)(unsigned int size);
|
|||||||
typedef void (*mve_cb_Free)(void *ptr);
|
typedef void (*mve_cb_Free)(void *ptr);
|
||||||
|
|
||||||
typedef void (*mve_cb_ShowFrame)(unsigned char *buffer, unsigned int bufw, unsigned int bufh, unsigned int sx,
|
typedef void (*mve_cb_ShowFrame)(unsigned char *buffer, unsigned int bufw, unsigned int bufh, unsigned int sx,
|
||||||
unsigned int sy, unsigned int w, unsigned int h, unsigned int dstx, unsigned int dsty);
|
unsigned int sy, unsigned int w, unsigned int h, unsigned int dstx, unsigned int dsty,
|
||||||
|
unsigned int hicolor);
|
||||||
|
|
||||||
typedef void (*mve_cb_SetPalette)(unsigned char *p, unsigned int start, unsigned int count);
|
typedef void (*mve_cb_SetPalette)(unsigned char *p, unsigned int start, unsigned int count);
|
||||||
|
|
||||||
@ -52,4 +57,6 @@ void MVE_memCallbacks(mve_cb_Alloc mem_alloc, mve_cb_Free mem_free);
|
|||||||
void MVE_sfCallbacks(mve_cb_ShowFrame showframe);
|
void MVE_sfCallbacks(mve_cb_ShowFrame showframe);
|
||||||
void MVE_palCallbacks(mve_cb_SetPalette setpalette);
|
void MVE_palCallbacks(mve_cb_SetPalette setpalette);
|
||||||
|
|
||||||
|
void MVE_ReleaseMem(void);
|
||||||
|
|
||||||
#endif /* _LIBMVE_H */
|
#endif /* _LIBMVE_H */
|
||||||
|
@ -15,17 +15,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#include <cstring> // for mem* functions
|
||||||
#include "conf.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string.h> // for mem* functions
|
|
||||||
#if !defined(_WIN32) && !defined(macintosh)
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "mvelib.h"
|
#include "mvelib.h"
|
||||||
|
|
||||||
@ -462,7 +452,9 @@ static MVESTREAM *_mvestream_alloc(void) {
|
|||||||
*/
|
*/
|
||||||
static void _mvestream_free(MVESTREAM *movie) {
|
static void _mvestream_free(MVESTREAM *movie) {
|
||||||
/* close MVEFILE */
|
/* close MVEFILE */
|
||||||
if (movie->movie)
|
if (movie == nullptr)
|
||||||
|
return;
|
||||||
|
if (movie->movie != nullptr)
|
||||||
mvefile_close(movie->movie);
|
mvefile_close(movie->movie);
|
||||||
movie->movie = NULL;
|
movie->movie = NULL;
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
#ifndef INCLUDED_MVELIB_H
|
#ifndef INCLUDED_MVELIB_H
|
||||||
#define INCLUDED_MVELIB_H
|
#define INCLUDED_MVELIB_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "libmve.h"
|
#include "libmve.h"
|
||||||
|
|
||||||
|
@ -15,31 +15,15 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
// TODO
|
||||||
#include <conf.h>
|
//#define AUDIO
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __MSDOS__
|
#include <cstring>
|
||||||
#define AUDIO
|
|
||||||
#endif
|
|
||||||
// #define DEBUG
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <errno.h>
|
#include <ctime>
|
||||||
#include <time.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#ifdef macintosh
|
|
||||||
#include <types.h>
|
|
||||||
#include <OSUtils.h>
|
|
||||||
#else
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif // macintosh
|
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
#if defined(AUDIO)
|
#if defined(AUDIO)
|
||||||
@ -47,12 +31,11 @@
|
|||||||
#include "SDL_mixer.h"
|
#include "SDL_mixer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "decoders.h"
|
||||||
|
#include "libmve.h"
|
||||||
#include "mvelib.h"
|
#include "mvelib.h"
|
||||||
#include "mve_audio.h"
|
#include "mve_audio.h"
|
||||||
|
#include "SystemInterfaces.h"
|
||||||
#include "decoders.h"
|
|
||||||
|
|
||||||
#include "libmve.h"
|
|
||||||
|
|
||||||
#define MVE_OPCODE_ENDOFSTREAM 0x00
|
#define MVE_OPCODE_ENDOFSTREAM 0x00
|
||||||
#define MVE_OPCODE_ENDOFCHUNK 0x01
|
#define MVE_OPCODE_ENDOFCHUNK 0x01
|
||||||
@ -81,6 +64,8 @@ int g_spdFactorNum = 0;
|
|||||||
static int g_spdFactorDenom = 10;
|
static int g_spdFactorDenom = 10;
|
||||||
static int g_frameUpdated = 0;
|
static int g_frameUpdated = 0;
|
||||||
|
|
||||||
|
static ISoundDevice *snd_ds = NULL;
|
||||||
|
|
||||||
static short get_short(unsigned char *data) {
|
static short get_short(unsigned char *data) {
|
||||||
short value;
|
short value;
|
||||||
value = data[0] | (data[1] << 8);
|
value = data[0] | (data[1] << 8);
|
||||||
@ -226,6 +211,8 @@ end:
|
|||||||
/*************************
|
/*************************
|
||||||
* audio handlers
|
* audio handlers
|
||||||
*************************/
|
*************************/
|
||||||
|
|
||||||
|
static int mve_audio_enabled = 0;
|
||||||
#ifdef AUDIO
|
#ifdef AUDIO
|
||||||
#define TOTAL_AUDIO_BUFFERS 64
|
#define TOTAL_AUDIO_BUFFERS 64
|
||||||
|
|
||||||
@ -493,7 +480,7 @@ static int display_video_handler(unsigned char major, unsigned char minor, unsig
|
|||||||
if (g_destY == -1) // center it
|
if (g_destY == -1) // center it
|
||||||
g_destY = (g_screenHeight - g_height) >> 1;
|
g_destY = (g_screenHeight - g_height) >> 1;
|
||||||
|
|
||||||
mve_showframe((unsigned char *)g_vBackBuf1, g_width, g_height, 0, 0, g_width, g_height, g_destX, g_destY);
|
mve_showframe((unsigned char *)g_vBackBuf1, g_width, g_height, 0, 0, g_width, g_height, g_destX, g_destY, g_truecolor);
|
||||||
|
|
||||||
g_frameUpdated = 1;
|
g_frameUpdated = 1;
|
||||||
|
|
||||||
@ -587,6 +574,13 @@ void MVE_sfCallbacks(mve_cb_ShowFrame showframe) { mve_showframe = showframe; }
|
|||||||
|
|
||||||
void MVE_palCallbacks(mve_cb_SetPalette setpalette) { mve_setpalette = setpalette; }
|
void MVE_palCallbacks(mve_cb_SetPalette setpalette) { mve_setpalette = setpalette; }
|
||||||
|
|
||||||
|
void MVE_ReleaseMem() {
|
||||||
|
MVE_rmEndMovie();
|
||||||
|
// ioRelease();
|
||||||
|
// sndRelease();
|
||||||
|
// nfRelease();
|
||||||
|
}
|
||||||
|
|
||||||
int MVE_rmPrepMovie(void *src, int x, int y, int track) {
|
int MVE_rmPrepMovie(void *src, int x, int y, int track) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -705,6 +699,12 @@ void MVE_rmEndMovie() {
|
|||||||
|
|
||||||
void MVE_rmHoldMovie() { timer_started = 0; }
|
void MVE_rmHoldMovie() { timer_started = 0; }
|
||||||
|
|
||||||
|
void MVE_sndInit(ISoundDevice *lpDS) {
|
||||||
|
#ifdef AUDIO
|
||||||
|
snd_ds = lpDS;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void MVE_sndInit(int x) {
|
void MVE_sndInit(int x) {
|
||||||
#ifdef AUDIO
|
#ifdef AUDIO
|
||||||
if (x == -1)
|
if (x == -1)
|
||||||
|
@ -16,14 +16,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include "lnxdsound.h"
|
||||||
#include <sys/uio.h>
|
|
||||||
|
|
||||||
#define O_BINARY 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -34,11 +29,11 @@
|
|||||||
#include "dsound.h"
|
#include "dsound.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <cstring>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
#include "mvelibw.h"
|
//#include "mvelibw.h"
|
||||||
|
#include "libmve.h"
|
||||||
#include "pserror.h"
|
#include "pserror.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
@ -239,7 +234,7 @@ public:
|
|||||||
|
|
||||||
static void *CallbackAlloc(uint32_t size);
|
static void *CallbackAlloc(uint32_t size);
|
||||||
static void CallbackFree(void *p);
|
static void CallbackFree(void *p);
|
||||||
static uint32_t CallbackFileRead(int hFile, void *pBuffer, uint32_t bufferCount);
|
static uint32_t CallbackFileRead(void *stream, void *pBuffer, uint32_t bufferCount);
|
||||||
static void InitializePalette();
|
static void InitializePalette();
|
||||||
static void CallbackSetPalette(uint8_t *pBuffer, uint32_t start, uint32_t count);
|
static void CallbackSetPalette(uint8_t *pBuffer, uint32_t start, uint32_t count);
|
||||||
static void CallbackShowFrame(uint8_t *buf, uint32_t bufw, uint32_t bufh, uint32_t sx,
|
static void CallbackShowFrame(uint8_t *buf, uint32_t bufw, uint32_t bufh, uint32_t sx,
|
||||||
@ -314,8 +309,8 @@ int mve_PlayMovie(const char *pMovieName, oeApplication *pApp) {
|
|||||||
real_name = pMovieName;
|
real_name = pMovieName;
|
||||||
#endif
|
#endif
|
||||||
// open movie file.
|
// open movie file.
|
||||||
int hFile = open(real_name.u8string().c_str(), O_RDONLY | O_BINARY);
|
FILE *hFile = fopen(real_name.u8string().c_str(), "rb");
|
||||||
if (hFile == -1) {
|
if (hFile == nullptr) {
|
||||||
mprintf(0, "MOVIE: Unable to open %s\n", real_name.u8string().c_str());
|
mprintf(0, "MOVIE: Unable to open %s\n", real_name.u8string().c_str());
|
||||||
return MVELIB_FILE_ERROR;
|
return MVELIB_FILE_ERROR;
|
||||||
}
|
}
|
||||||
@ -325,11 +320,11 @@ int mve_PlayMovie(const char *pMovieName, oeApplication *pApp) {
|
|||||||
bool highColor = (pExtension != NULL && stricmp(pExtension, ".mv8") != 0);
|
bool highColor = (pExtension != NULL && stricmp(pExtension, ".mv8") != 0);
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
MVE_rmFastMode(MVE_RM_NORMAL);
|
// MVE_rmFastMode(MVE_RM_NORMAL);
|
||||||
MVE_sfCallbacks(CallbackShowFrame);
|
MVE_sfCallbacks(CallbackShowFrame);
|
||||||
MVE_memCallbacks(CallbackAlloc, CallbackFree);
|
MVE_memCallbacks(CallbackAlloc, CallbackFree);
|
||||||
MVE_ioCallbacks(CallbackFileRead);
|
MVE_ioCallbacks(CallbackFileRead);
|
||||||
MVE_sfSVGA(640, 480, 480, 0, NULL, 0, 0, NULL, highColor ? 1 : 0);
|
// MVE_sfSVGA(640, 480, 480, 0, NULL, 0, 0, NULL, highColor ? 1 : 0);
|
||||||
MVE_palCallbacks(CallbackSetPalette);
|
MVE_palCallbacks(CallbackSetPalette);
|
||||||
InitializePalette();
|
InitializePalette();
|
||||||
Movie_bm_handle = -1;
|
Movie_bm_handle = -1;
|
||||||
@ -337,14 +332,14 @@ int mve_PlayMovie(const char *pMovieName, oeApplication *pApp) {
|
|||||||
MovieSoundDevice soundDevice;
|
MovieSoundDevice soundDevice;
|
||||||
if (!mve_InitSound(pApp, soundDevice)) {
|
if (!mve_InitSound(pApp, soundDevice)) {
|
||||||
mprintf(0, "Failed to initialize sound\n");
|
mprintf(0, "Failed to initialize sound\n");
|
||||||
close(hFile);
|
fclose(hFile);
|
||||||
return MVELIB_INIT_ERROR;
|
return MVELIB_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = MVE_rmPrepMovie(hFile, -1, -1, 0);
|
int result = MVE_rmPrepMovie(hFile, -1, -1, 0);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
mprintf(0, "PrepMovie result = %d\n", result);
|
mprintf(0, "PrepMovie result = %d\n", result);
|
||||||
close(hFile);
|
fclose(hFile);
|
||||||
mve_CloseSound(soundDevice);
|
mve_CloseSound(soundDevice);
|
||||||
return MVELIB_INIT_ERROR;
|
return MVELIB_INIT_ERROR;
|
||||||
}
|
}
|
||||||
@ -370,7 +365,7 @@ int mve_PlayMovie(const char *pMovieName, oeApplication *pApp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// close our file handle
|
// close our file handle
|
||||||
close(hFile);
|
fclose(hFile);
|
||||||
|
|
||||||
// determine the return code
|
// determine the return code
|
||||||
int err = MVELIB_NOERROR;
|
int err = MVELIB_NOERROR;
|
||||||
@ -398,8 +393,8 @@ void *CallbackAlloc(uint32_t size) { return mem_malloc(size); }
|
|||||||
|
|
||||||
void CallbackFree(void *p) { mem_free(p); }
|
void CallbackFree(void *p) { mem_free(p); }
|
||||||
|
|
||||||
uint32_t CallbackFileRead(int hFile, void *pBuffer, uint32_t bufferCount) {
|
uint32_t CallbackFileRead(void *stream, void *pBuffer, uint32_t bufferCount) {
|
||||||
uint32_t numRead = read(hFile, pBuffer, bufferCount);
|
uint32_t numRead = fread(pBuffer, 1, bufferCount, (FILE *)stream);
|
||||||
return (numRead == bufferCount) ? 1 : 0;
|
return (numRead == bufferCount) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,7 +434,7 @@ int NextPow2(int n) {
|
|||||||
void BlitToMovieBitmap(uint8_t *buf, uint32_t bufw, uint32_t bufh, uint32_t hicolor,
|
void BlitToMovieBitmap(uint8_t *buf, uint32_t bufw, uint32_t bufh, uint32_t hicolor,
|
||||||
bool usePow2Texture, int &texW, int &texH) {
|
bool usePow2Texture, int &texW, int &texH) {
|
||||||
// get some sizes
|
// get some sizes
|
||||||
int drawWidth = hicolor ? (bufw >> 1) : bufw;
|
int drawWidth = bufw;
|
||||||
int drawHeight = bufh;
|
int drawHeight = bufh;
|
||||||
|
|
||||||
if (usePow2Texture) {
|
if (usePow2Texture) {
|
||||||
@ -465,10 +460,8 @@ void BlitToMovieBitmap(uint8_t *buf, uint32_t bufw, uint32_t bufh, uint32_t hico
|
|||||||
for (int y = 0; y < drawHeight; ++y) {
|
for (int y = 0; y < drawHeight; ++y) {
|
||||||
for (int x = 0; x < drawWidth; ++x) {
|
for (int x = 0; x < drawWidth; ++x) {
|
||||||
uint16_t col16 = *wBuf++;
|
uint16_t col16 = *wBuf++;
|
||||||
uint32_t b = ((col16 >> 11) & 0x1F) << 3;
|
// Convert to RGB555
|
||||||
uint32_t g = ((col16 >> 5) & 0x3F) << 2;
|
pPixelData[x] = col16 | OPAQUE_FLAG;
|
||||||
uint32_t r = ((col16 >> 0) & 0x1F) << 3;
|
|
||||||
pPixelData[x] = OPAQUE_FLAG | GR_RGB16(r, g, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pPixelData += texW;
|
pPixelData += texW;
|
||||||
@ -492,7 +485,7 @@ void CallbackShowFrame(uint8_t *buf, uint32_t bufw, uint32_t bufh, uint32_t sx,
|
|||||||
BlitToMovieBitmap(buf, bufw, bufh, hicolor, true, texW, texH);
|
BlitToMovieBitmap(buf, bufw, bufh, hicolor, true, texW, texH);
|
||||||
|
|
||||||
// calculate UVs from texture
|
// calculate UVs from texture
|
||||||
int drawWidth = hicolor ? (bufw >> 1) : bufw;
|
int drawWidth = bufw;
|
||||||
int drawHeight = bufh;
|
int drawHeight = bufh;
|
||||||
float u = float(drawWidth - 1) / float(texW - 1);
|
float u = float(drawWidth - 1) / float(texW - 1);
|
||||||
float v = float(drawHeight - 1) / float(texH - 1);
|
float v = float(drawHeight - 1) / float(texH - 1);
|
||||||
@ -524,7 +517,7 @@ void CallbackShowFrame(uint8_t *buf, uint32_t bufw, uint32_t bufh, uint32_t sx,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
intptr_t mve_SequenceStart(const char *mvename, int *fhandle, oeApplication *app, bool looping) {
|
intptr_t mve_SequenceStart(const char *mvename, void *fhandle, oeApplication *app, bool looping) {
|
||||||
#ifndef NO_MOVIES
|
#ifndef NO_MOVIES
|
||||||
// first, find that movie..
|
// first, find that movie..
|
||||||
std::filesystem::path real_name;
|
std::filesystem::path real_name;
|
||||||
@ -532,22 +525,22 @@ intptr_t mve_SequenceStart(const char *mvename, int *fhandle, oeApplication *app
|
|||||||
real_name = mve_FindMovieFileRealName(mvename);
|
real_name = mve_FindMovieFileRealName(mvename);
|
||||||
if (real_name.empty()) {
|
if (real_name.empty()) {
|
||||||
mprintf(0, "MOVIE: No such file %s\n", mvename);
|
mprintf(0, "MOVIE: No such file %s\n", mvename);
|
||||||
*fhandle = -1;
|
fhandle = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
real_name = mvename;
|
real_name = mvename;
|
||||||
#endif
|
#endif
|
||||||
int hfile = open(real_name.u8string().c_str(), O_RDONLY | O_BINARY);
|
FILE *hfile = fopen(real_name.u8string().c_str(), "rb");
|
||||||
|
|
||||||
if (hfile == -1) {
|
if (hfile == nullptr) {
|
||||||
mprintf(1, "MOVIE: Unable to open %s\n", real_name.u8string().c_str());
|
mprintf(1, "MOVIE: Unable to open %s\n", real_name.u8string().c_str());
|
||||||
*fhandle = -1;
|
fhandle = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
MVE_rmFastMode(MVE_RM_NORMAL);
|
//MVE_rmFastMode(MVE_RM_NORMAL);
|
||||||
MVE_memCallbacks(CallbackAlloc, CallbackFree);
|
MVE_memCallbacks(CallbackAlloc, CallbackFree);
|
||||||
MVE_ioCallbacks(CallbackFileRead);
|
MVE_ioCallbacks(CallbackFileRead);
|
||||||
InitializePalette();
|
InitializePalette();
|
||||||
@ -557,14 +550,15 @@ intptr_t mve_SequenceStart(const char *mvename, int *fhandle, oeApplication *app
|
|||||||
// let the render know we will be copying bitmaps to framebuffer (or something)
|
// let the render know we will be copying bitmaps to framebuffer (or something)
|
||||||
rend_SetFrameBufferCopyState(true);
|
rend_SetFrameBufferCopyState(true);
|
||||||
|
|
||||||
*fhandle = hfile;
|
fhandle = hfile;
|
||||||
return (intptr_t)MVE_frOpen(CallbackFileRead, hfile, NULL);
|
// TODO return (intptr_t)MVE_frOpen(CallbackFileRead, hfile, NULL);
|
||||||
|
return 0;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr_t mve_SequenceFrame(intptr_t handle, int fhandle, bool sequence, int *bm_handle) {
|
intptr_t mve_SequenceFrame(intptr_t handle, void *fhandle, bool sequence, int *bm_handle) {
|
||||||
#ifndef NO_MOVIES
|
#ifndef NO_MOVIES
|
||||||
if (bm_handle) {
|
if (bm_handle) {
|
||||||
*bm_handle = -1;
|
*bm_handle = -1;
|
||||||
@ -581,14 +575,14 @@ reread_frame:
|
|||||||
|
|
||||||
// get the next frame of data
|
// get the next frame of data
|
||||||
uint8_t *pBuffer = NULL;
|
uint8_t *pBuffer = NULL;
|
||||||
err = MVE_frGet((MVE_frStream)handle, &pBuffer, &sw, &sh, &hicolor);
|
// TODO err = MVE_frGet((MVE_frStream)handle, &pBuffer, &sw, &sh, &hicolor);
|
||||||
|
|
||||||
// refresh our palette
|
// refresh our palette
|
||||||
{
|
{
|
||||||
uint32_t palstart = 0;
|
uint32_t palstart = 0;
|
||||||
uint32_t palcount = 0;
|
uint32_t palcount = 0;
|
||||||
uint8_t *pal = NULL;
|
uint8_t *pal = NULL;
|
||||||
MVE_frPal((MVE_frStream)handle, &pal, &palstart, &palcount);
|
// TODO MVE_frPal((MVE_frStream)handle, &pal, &palstart, &palcount);
|
||||||
CallbackSetPalette(pal, palstart, palcount);
|
CallbackSetPalette(pal, palstart, palcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,13 +599,9 @@ reread_frame:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Movie_looping && err == MVE_ERR_EOF) {
|
if (Movie_looping && err == MVE_ERR_EOF) {
|
||||||
MVE_frClose((MVE_frStream)handle);
|
// TODO MVE_frClose((MVE_frStream)handle);
|
||||||
#ifdef WIN32
|
fseek((FILE *)fhandle, 0, SEEK_SET);
|
||||||
_lseek(fhandle, 0, SEEK_SET);
|
// TODO handle = (intptr_t)MVE_frOpen(CallbackFileRead, (FILE *)fhandle, NULL);
|
||||||
#else
|
|
||||||
lseek(fhandle, 0, SEEK_SET);
|
|
||||||
#endif
|
|
||||||
handle = (intptr_t)MVE_frOpen(CallbackFileRead, fhandle, NULL);
|
|
||||||
sequence = true;
|
sequence = true;
|
||||||
goto reread_frame;
|
goto reread_frame;
|
||||||
}
|
}
|
||||||
@ -622,14 +612,14 @@ reread_frame:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mve_SequenceClose(intptr_t hMovie, int hFile) {
|
bool mve_SequenceClose(intptr_t hMovie, void *hFile) {
|
||||||
#ifndef NO_MOVIES
|
#ifndef NO_MOVIES
|
||||||
if (hMovie == -1)
|
if (hMovie == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MVE_frClose((MVE_frStream)hMovie);
|
// TODO MVE_frClose((MVE_frStream)hMovie);
|
||||||
MVE_ReleaseMem();
|
MVE_ReleaseMem();
|
||||||
close(hFile);
|
fclose((FILE *)hFile);
|
||||||
|
|
||||||
// free our bitmap
|
// free our bitmap
|
||||||
if (Movie_bm_handle != -1) {
|
if (Movie_bm_handle != -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user