mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
MVE: Refactoring code
Merge libmve.h into mvelib.h
This commit is contained in:
parent
b94458f561
commit
99ec2e3a5e
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2002-2024 D2X Project
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _LIBMVE_H
|
|
||||||
#define _LIBMVE_H
|
|
||||||
|
|
||||||
#include "SystemInterfaces.h"
|
|
||||||
|
|
||||||
#define MVE_ERR_EOF 1
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int screenWidth;
|
|
||||||
int screenHeight;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int truecolor;
|
|
||||||
} MVE_videoSpec;
|
|
||||||
|
|
||||||
int MVE_rmPrepMovie(void *stream, int x, int y, int track);
|
|
||||||
int MVE_rmStepMovie(void);
|
|
||||||
void MVE_rmHoldMovie(void);
|
|
||||||
void MVE_rmEndMovie(void);
|
|
||||||
|
|
||||||
void MVE_getVideoSpec(MVE_videoSpec *vSpec);
|
|
||||||
|
|
||||||
void MVE_sndInit(ISoundDevice *lpDS);
|
|
||||||
|
|
||||||
void MVE_sndInit(int x);
|
|
||||||
|
|
||||||
typedef unsigned int (*mve_cb_Read)(void *stream, void *buffer, unsigned int count);
|
|
||||||
|
|
||||||
typedef void *(*mve_cb_Alloc)(unsigned int size);
|
|
||||||
typedef void (*mve_cb_Free)(void *ptr);
|
|
||||||
|
|
||||||
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 hicolor);
|
|
||||||
|
|
||||||
typedef void (*mve_cb_SetPalette)(unsigned char *p, unsigned int start, unsigned int count);
|
|
||||||
|
|
||||||
void MVE_ioCallbacks(mve_cb_Read io_read);
|
|
||||||
void MVE_memCallbacks(mve_cb_Alloc mem_alloc, mve_cb_Free mem_free);
|
|
||||||
void MVE_sfCallbacks(mve_cb_ShowFrame showframe);
|
|
||||||
void MVE_palCallbacks(mve_cb_SetPalette setpalette);
|
|
||||||
|
|
||||||
void MVE_ReleaseMem(void);
|
|
||||||
|
|
||||||
#endif /* _LIBMVE_H */
|
|
147
libmve/mvelib.h
147
libmve/mvelib.h
@ -21,7 +21,22 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "libmve.h"
|
#include "SystemInterfaces.h"
|
||||||
|
|
||||||
|
/* callback for reading stream */
|
||||||
|
typedef unsigned int (*mve_cb_Read)(void *stream, void *buffer, unsigned int count);
|
||||||
|
/* callback for memore allocating */
|
||||||
|
typedef void *(*mve_cb_Alloc)(unsigned int size);
|
||||||
|
/* callback for memory freeing */
|
||||||
|
typedef void (*mve_cb_Free)(void *ptr);
|
||||||
|
/* callback for showing frame */
|
||||||
|
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 hicolor);
|
||||||
|
/* callback for setting palette */
|
||||||
|
typedef void (*mve_cb_SetPalette)(unsigned char *p, unsigned int start, unsigned int count);
|
||||||
|
/* callback for segment type */
|
||||||
|
typedef int (*MVESEGMENTHANDLER)(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context);
|
||||||
|
|
||||||
extern mve_cb_Read mve_read;
|
extern mve_cb_Read mve_read;
|
||||||
extern mve_cb_Alloc mve_alloc;
|
extern mve_cb_Alloc mve_alloc;
|
||||||
@ -29,9 +44,17 @@ extern mve_cb_Free mve_free;
|
|||||||
extern mve_cb_ShowFrame mve_showframe;
|
extern mve_cb_ShowFrame mve_showframe;
|
||||||
extern mve_cb_SetPalette mve_setpalette;
|
extern mve_cb_SetPalette mve_setpalette;
|
||||||
|
|
||||||
/*
|
#define MVE_ERR_EOF 1
|
||||||
* structure for maintaining info on a MVEFILE stream
|
|
||||||
*/
|
typedef struct {
|
||||||
|
int screenWidth;
|
||||||
|
int screenHeight;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int truecolor;
|
||||||
|
} MVE_videoSpec;
|
||||||
|
|
||||||
|
/* structure for maintaining info on a MVEFILE stream */
|
||||||
typedef struct MVEFILE {
|
typedef struct MVEFILE {
|
||||||
void *stream;
|
void *stream;
|
||||||
unsigned char *cur_chunk;
|
unsigned char *cur_chunk;
|
||||||
@ -40,89 +63,71 @@ typedef struct MVEFILE {
|
|||||||
int next_segment;
|
int next_segment;
|
||||||
} MVEFILE;
|
} MVEFILE;
|
||||||
|
|
||||||
/*
|
/* structure for maintaining an MVE stream */
|
||||||
* open a .MVE file
|
|
||||||
*/
|
|
||||||
MVEFILE *mvefile_open(void *stream);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* close a .MVE file
|
|
||||||
*/
|
|
||||||
void mvefile_close(MVEFILE *movie);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* get size of next segment in chunk (-1 if no more segments in chunk)
|
|
||||||
*/
|
|
||||||
int mvefile_get_next_segment_size(MVEFILE *movie);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* get type of next segment in chunk (0xff if no more segments in chunk)
|
|
||||||
*/
|
|
||||||
unsigned char mvefile_get_next_segment_major(MVEFILE *movie);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* get subtype (version) of next segment in chunk (0xff if no more segments in
|
|
||||||
* chunk)
|
|
||||||
*/
|
|
||||||
unsigned char mvefile_get_next_segment_minor(MVEFILE *movie);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* see next segment (return NULL if no next segment)
|
|
||||||
*/
|
|
||||||
unsigned char *mvefile_get_next_segment(MVEFILE *movie);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* advance to next segment
|
|
||||||
*/
|
|
||||||
void mvefile_advance_segment(MVEFILE *movie);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* fetch the next chunk (return 0 if at end of stream)
|
|
||||||
*/
|
|
||||||
int mvefile_fetch_next_chunk(MVEFILE *movie);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* callback for segment type
|
|
||||||
*/
|
|
||||||
typedef int (*MVESEGMENTHANDLER)(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* structure for maintaining an MVE stream
|
|
||||||
*/
|
|
||||||
typedef struct MVESTREAM {
|
typedef struct MVESTREAM {
|
||||||
MVEFILE *movie;
|
MVEFILE *movie;
|
||||||
void *context;
|
void *context;
|
||||||
MVESEGMENTHANDLER handlers[32];
|
MVESEGMENTHANDLER handlers[32];
|
||||||
} MVESTREAM;
|
} MVESTREAM;
|
||||||
|
|
||||||
/*
|
int MVE_rmPrepMovie(void *stream, int x, int y, int track);
|
||||||
* open an MVE stream
|
int MVE_rmStepMovie();
|
||||||
*/
|
void MVE_rmHoldMovie();
|
||||||
|
void MVE_rmEndMovie();
|
||||||
|
|
||||||
|
void MVE_getVideoSpec(MVE_videoSpec *vSpec);
|
||||||
|
|
||||||
|
void MVE_sndInit(ISoundDevice *lpDS);
|
||||||
|
|
||||||
|
void MVE_sndInit(int x);
|
||||||
|
|
||||||
|
void MVE_ioCallbacks(mve_cb_Read io_read);
|
||||||
|
void MVE_memCallbacks(mve_cb_Alloc mem_alloc, mve_cb_Free mem_free);
|
||||||
|
void MVE_sfCallbacks(mve_cb_ShowFrame showframe);
|
||||||
|
void MVE_palCallbacks(mve_cb_SetPalette setpalette);
|
||||||
|
|
||||||
|
// Low-level functions
|
||||||
|
|
||||||
|
/* open an MVE file */
|
||||||
|
MVEFILE *mvefile_open(void *stream);
|
||||||
|
|
||||||
|
/* close an MVE file */
|
||||||
|
void mvefile_close(MVEFILE *movie);
|
||||||
|
|
||||||
|
/* get size of next segment in chunk (-1 if no more segments in chunk) */
|
||||||
|
int mvefile_get_next_segment_size(MVEFILE *movie);
|
||||||
|
|
||||||
|
/* get type of next segment in chunk (0xff if no more segments in chunk) */
|
||||||
|
unsigned char mvefile_get_next_segment_major(MVEFILE *movie);
|
||||||
|
|
||||||
|
/* get subtype (version) of next segment in chunk (0xff if no more segments in chunk) */
|
||||||
|
unsigned char mvefile_get_next_segment_minor(MVEFILE *movie);
|
||||||
|
|
||||||
|
/* see next segment (return NULL if no next segment) */
|
||||||
|
unsigned char *mvefile_get_next_segment(MVEFILE *movie);
|
||||||
|
|
||||||
|
/* advance to next segment */
|
||||||
|
void mvefile_advance_segment(MVEFILE *movie);
|
||||||
|
|
||||||
|
/* fetch the next chunk (return 0 if at end of stream) */
|
||||||
|
int mvefile_fetch_next_chunk(MVEFILE *movie);
|
||||||
|
|
||||||
|
/* open an MVE stream */
|
||||||
MVESTREAM *mve_open(void *stream);
|
MVESTREAM *mve_open(void *stream);
|
||||||
|
|
||||||
/*
|
/* close an MVE stream */
|
||||||
* close an MVE stream
|
|
||||||
*/
|
|
||||||
void mve_close(MVESTREAM *movie);
|
void mve_close(MVESTREAM *movie);
|
||||||
|
|
||||||
/*
|
/* reset an MVE stream */
|
||||||
* reset an MVE stream
|
|
||||||
*/
|
|
||||||
void mve_reset(MVESTREAM *movie);
|
void mve_reset(MVESTREAM *movie);
|
||||||
|
|
||||||
/*
|
/* set segment type handler */
|
||||||
* set segment type handler
|
|
||||||
*/
|
|
||||||
void mve_set_handler(MVESTREAM *movie, unsigned char major, MVESEGMENTHANDLER handler);
|
void mve_set_handler(MVESTREAM *movie, unsigned char major, MVESEGMENTHANDLER handler);
|
||||||
|
|
||||||
/*
|
/* set segment handler context */
|
||||||
* set segment handler context
|
|
||||||
*/
|
|
||||||
void mve_set_handler_context(MVESTREAM *movie, void *context);
|
void mve_set_handler_context(MVESTREAM *movie, void *context);
|
||||||
|
|
||||||
/*
|
/* play next chunk */
|
||||||
* play next chunk
|
|
||||||
*/
|
|
||||||
int mve_play_next_chunk(MVESTREAM *movie);
|
int mve_play_next_chunk(MVESTREAM *movie);
|
||||||
|
|
||||||
#endif /* INCLUDED_MVELIB_H */
|
#endif /* INCLUDED_MVELIB_H */
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "decoders.h"
|
#include "decoders.h"
|
||||||
#include "libmve.h"
|
|
||||||
#include "mvelib.h"
|
#include "mvelib.h"
|
||||||
#include "mve_audio.h"
|
#include "mve_audio.h"
|
||||||
#include "SystemInterfaces.h"
|
#include "SystemInterfaces.h"
|
||||||
@ -480,7 +479,8 @@ 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, g_truecolor);
|
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;
|
||||||
|
|
||||||
@ -574,16 +574,7 @@ 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;
|
|
||||||
|
|
||||||
if (mve) {
|
if (mve) {
|
||||||
mve_reset(mve);
|
mve_reset(mve);
|
||||||
return 0;
|
return 0;
|
||||||
@ -597,7 +588,7 @@ int MVE_rmPrepMovie(void *src, int x, int y, int track) {
|
|||||||
g_destX = x;
|
g_destX = x;
|
||||||
g_destY = y;
|
g_destY = y;
|
||||||
|
|
||||||
for (i = 0; i < 32; i++)
|
for (int i = 0; i < 32; i++)
|
||||||
mve_set_handler(mve, i, default_seg_handler);
|
mve_set_handler(mve, i, default_seg_handler);
|
||||||
|
|
||||||
mve_set_handler(mve, MVE_OPCODE_ENDOFSTREAM, end_movie_handler);
|
mve_set_handler(mve, MVE_OPCODE_ENDOFSTREAM, end_movie_handler);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
//#include "mvelibw.h"
|
//#include "mvelibw.h"
|
||||||
#include "libmve.h"
|
#include "mvelib.h"
|
||||||
#include "pserror.h"
|
#include "pserror.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
@ -377,7 +377,6 @@ int mve_PlayMovie(const char *pMovieName, oeApplication *pApp) {
|
|||||||
|
|
||||||
// cleanup and shutdown
|
// cleanup and shutdown
|
||||||
MVE_rmEndMovie();
|
MVE_rmEndMovie();
|
||||||
MVE_ReleaseMem();
|
|
||||||
|
|
||||||
// reset sound
|
// reset sound
|
||||||
mve_CloseSound(soundDevice);
|
mve_CloseSound(soundDevice);
|
||||||
@ -618,7 +617,7 @@ bool mve_SequenceClose(intptr_t hMovie, void *hFile) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO MVE_frClose((MVE_frStream)hMovie);
|
// TODO MVE_frClose((MVE_frStream)hMovie);
|
||||||
MVE_ReleaseMem();
|
MVE_rmEndMovie();
|
||||||
fclose((FILE *)hFile);
|
fclose((FILE *)hFile);
|
||||||
|
|
||||||
// free our bitmap
|
// free our bitmap
|
||||||
|
Loading…
Reference in New Issue
Block a user