Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 1 | /* |
| 2 | * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>. |
||
| 3 | * It is copyright by its individual contributors, as recorded in the |
||
| 4 | * project's Git history. See COPYING.txt at the top level for license |
||
| 5 | * terms and a link to the Git history. |
||
| 6 | */ |
||
| 7 | |||
| 8 | #pragma once |
||
| 9 | |||
| 10 | #include <stdio.h> |
||
| 11 | #include <stdlib.h> |
||
| 12 | |||
| 13 | #include "libmve.h" |
||
| 14 | |||
| 15 | #ifdef __cplusplus |
||
| 16 | #include <cstdint> |
||
| 17 | #include <vector> |
||
| 18 | #include "dxxsconf.h" |
||
| 19 | #include <array> |
||
| 20 | |||
| 21 | extern mve_cb_Read mve_read; |
||
| 22 | extern mve_cb_Alloc mve_alloc; |
||
| 23 | extern mve_cb_Free mve_free; |
||
| 24 | extern mve_cb_ShowFrame mve_showframe; |
||
| 25 | extern mve_cb_SetPalette mve_setpalette; |
||
| 26 | |||
| 27 | /* |
||
| 28 | * structure for maintaining info on a MVEFILE stream |
||
| 29 | */ |
||
| 30 | struct MVEFILE |
||
| 31 | { |
||
| 32 | MVEFILE(); |
||
| 33 | ~MVEFILE(); |
||
| 34 | void *stream = nullptr; |
||
| 35 | std::vector<uint8_t> cur_chunk; |
||
| 36 | std::size_t next_segment = 0; |
||
| 37 | }; |
||
| 38 | |||
| 39 | /* |
||
| 40 | * open a .MVE file |
||
| 41 | */ |
||
| 42 | std::unique_ptr<MVEFILE> mvefile_open(void *stream); |
||
| 43 | |||
| 44 | /* |
||
| 45 | * get size of next segment in chunk (-1 if no more segments in chunk) |
||
| 46 | */ |
||
| 47 | int_fast32_t mvefile_get_next_segment_size(const MVEFILE *movie); |
||
| 48 | |||
| 49 | /* |
||
| 50 | * get type of next segment in chunk (0xff if no more segments in chunk) |
||
| 51 | */ |
||
| 52 | unsigned char mvefile_get_next_segment_major(const MVEFILE *movie); |
||
| 53 | |||
| 54 | /* |
||
| 55 | * get subtype (version) of next segment in chunk (0xff if no more segments in |
||
| 56 | * chunk) |
||
| 57 | */ |
||
| 58 | unsigned char mvefile_get_next_segment_minor(const MVEFILE *movie); |
||
| 59 | |||
| 60 | /* |
||
| 61 | * see next segment (return NULL if no next segment) |
||
| 62 | */ |
||
| 63 | const unsigned char *mvefile_get_next_segment(const MVEFILE *movie); |
||
| 64 | |||
| 65 | /* |
||
| 66 | * advance to next segment |
||
| 67 | */ |
||
| 68 | void mvefile_advance_segment(MVEFILE *movie); |
||
| 69 | |||
| 70 | /* |
||
| 71 | * fetch the next chunk (return 0 if at end of stream) |
||
| 72 | */ |
||
| 73 | int mvefile_fetch_next_chunk(MVEFILE *movie); |
||
| 74 | |||
| 75 | /* |
||
| 76 | * callback for segment type |
||
| 77 | */ |
||
| 78 | typedef int (*MVESEGMENTHANDLER)(unsigned char major, unsigned char minor, const unsigned char *data, int len, void *context); |
||
| 79 | |||
| 80 | /* |
||
| 81 | * structure for maintaining an MVE stream |
||
| 82 | */ |
||
| 83 | struct MVESTREAM |
||
| 84 | { |
||
| 85 | MVESTREAM(); |
||
| 86 | ~MVESTREAM(); |
||
| 87 | std::unique_ptr<MVEFILE> movie; |
||
| 88 | void *context = nullptr; |
||
| 89 | std::array<MVESEGMENTHANDLER, 32> handlers = {}; |
||
| 90 | }; |
||
| 91 | |||
| 92 | struct MVESTREAM_deleter_t |
||
| 93 | { |
||
| 94 | void operator()(MVESTREAM *p) const |
||
| 95 | { |
||
| 96 | MVE_rmEndMovie(std::unique_ptr<MVESTREAM>(p)); |
||
| 97 | } |
||
| 98 | }; |
||
| 99 | |||
| 100 | typedef std::unique_ptr<MVESTREAM, MVESTREAM_deleter_t> MVESTREAM_ptr_t; |
||
| 101 | int MVE_rmPrepMovie(MVESTREAM_ptr_t &, void *stream, int x, int y, int track); |
||
| 102 | |||
| 103 | /* |
||
| 104 | * open an MVE stream |
||
| 105 | */ |
||
| 106 | MVESTREAM_ptr_t mve_open(void *stream); |
||
| 107 | |||
| 108 | /* |
||
| 109 | * reset an MVE stream |
||
| 110 | */ |
||
| 111 | void mve_reset(MVESTREAM *movie); |
||
| 112 | |||
| 113 | /* |
||
| 114 | * set segment type handler |
||
| 115 | */ |
||
| 116 | void mve_set_handler(MVESTREAM &movie, unsigned char major, MVESEGMENTHANDLER handler); |
||
| 117 | |||
| 118 | /* |
||
| 119 | * set segment handler context |
||
| 120 | */ |
||
| 121 | void mve_set_handler_context(MVESTREAM *movie, void *context); |
||
| 122 | |||
| 123 | /* |
||
| 124 | * play next chunk |
||
| 125 | */ |
||
| 126 | int mve_play_next_chunk(MVESTREAM &movie); |
||
| 127 | |||
| 128 | #endif |