| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef VCLIP_H |
| 20 | |
| 21 | #define VCLIP_H |
| 22 | |
| 23 | #include <filesystem> |
| 24 | |
| 25 | #include "fix.h" |
| 26 | #include "manage.h" |
| 27 | |
| 28 | #define MAX_VCLIPS 200 |
| 29 | #define VCLIP_MAX_FRAMES 50 |
| 30 | |
| 31 | #define VCF_NOT_RESIDENT 1 |
| 32 | #define VCF_WANTS_MIPPED 2 |
| 33 | |
| 34 | struct vclip { |
| 35 | char name[PAGENAME_LEN]; |
| 36 | int16_t num_frames; |
| 37 | int16_t *frames; // bitmap indices |
| 38 | float frame_time; // time (in seconds) of each frame |
| 39 | int flags; |
| 40 | uint8_t target_size; // what size this vclip should use (texture wise) |
| 41 | uint8_t used; // Is this vclip in use? |
| 42 | }; |
| 43 | |
| 44 | extern vclip GameVClips[MAX_VCLIPS]; |
| 45 | extern int Num_vclips; |
| 46 | |
| 47 | // Simply sets all vclips to unused |
| 48 | void InitVClips(); |
| 49 | |
| 50 | // Allocs a vclip for use |
| 51 | // Returns -1 on error |
| 52 | int AllocVClip(); |
| 53 | |
| 54 | // Frees a vclip |
| 55 | void FreeVClip(int num); |
| 56 | |
| 57 | // Saves a given video clip to a file |
| 58 | // Returns 1 if everything ok, 0 otherwise |
| 59 | // "num" is index into GameVClip array |
| 60 | int SaveVClip(const std::filesystem::path& filename, int num); |
| 61 | |
| 62 | // Allocs and loads a vclip from the file named "filename" |
| 63 | // Returns -1 on error, index into GameVClip array on success |
| 64 | // Argument texture means that this vclip is an animated texture and |
| 65 | // needs to have an 8bit version |
| 66 | int AllocLoadVClip(const char *filename, int texture_size, int mipped, int pageable = 0, int format = 0); |
| 67 | |
| 68 | // Allocs and loads a vclip from a 3DS ILS file |
| 69 | // Returns -1 on error, else index into GameVClips on success |
| 70 | // Argument texture means that this vclip is an animated texture and |
| 71 | // needs to have an 8bit version |
| 72 | int AllocLoadIFLVClip(const char *filename, int texture_size, int mipped, int format = 0); |
| 73 | |
| 74 | // gets the filename from a path, plus appends our .oaf extension |
| 75 | void ChangeVClipName(const char *src, char *dest); |
| 76 | |
| 77 | // Searches thru all vclips for a specific name, returns -1 if not found |
| 78 | // or index of vclip with name |
| 79 | int FindVClipName(const char *name); |
| 80 | |
| 81 | // Pages in a vclip if it needs to be |
| 82 | void PageInVClip(int vcnum); |
| 83 | |
| 84 | #endif |