- screenjob. fixes from Raze

This commit is contained in:
Christoph Oelckers 2022-04-11 00:51:51 +02:00
parent 1bb750c061
commit 7ed8d3b3e2
7 changed files with 29 additions and 32 deletions

View file

@ -123,12 +123,9 @@ public:
frametime = currentclock;
int delay = 20;
if (frameTicks)
{
if (curframe == 1) delay = frameTicks[0];
else if (curframe < numframes - 2) delay = frameTicks[1];
else delay = frameTicks[2];
}
if (curframe == 1) delay = frameTicks[0];
else if (curframe < numframes - 2) delay = frameTicks[1];
else delay = frameTicks[2];
nextframetime += delay;
bool nostopsound = (flags & NOSOUNDCUTOFF);
@ -177,7 +174,7 @@ class MvePlayer : public MoviePlayer
{
InterplayDecoder decoder;
bool failed = false;
public:
bool isvalid() { return !failed; }
@ -532,7 +529,7 @@ public:
SmkPlayer* pId = (SmkPlayer*)userdata;
memcpy(buff, &pId->adata.samples[pId->adata.nRead], len);
pId->adata.nRead += len / 2;
if (pId->adata.nRead >= countof(pId->adata.samples)) pId->adata.nRead = 0;
if (pId->adata.nRead >= (int)countof(pId->adata.samples)) pId->adata.nRead = 0;
return true;
}
@ -541,7 +538,7 @@ public:
for (unsigned i = 0; i < count; i++)
{
adata.samples[adata.nWrite] = (audioBuffer[i] - 128) << 8;
if (++adata.nWrite >= countof(adata.samples)) adata.nWrite = 0;
if (++adata.nWrite >= (int)countof(adata.samples)) adata.nWrite = 0;
}
}
@ -551,7 +548,7 @@ public:
for (unsigned i = 0; i < count/2; i++)
{
adata.samples[adata.nWrite] = *ptr++;
if (++adata.nWrite >= countof(adata.samples)) adata.nWrite = 0;
if (++adata.nWrite >= (int)countof(adata.samples)) adata.nWrite = 0;
}
}
@ -565,7 +562,7 @@ public:
}
flags = flags_;
Smacker_GetFrameSize(hSMK, nWidth, nHeight);
pFrame.Resize(nWidth * nHeight + std::max(nWidth, nHeight));
pFrame.Resize(nWidth * nHeight + max(nWidth, nHeight));
float frameRate = Smacker_GetFrameRate(hSMK);
nFrameNs = uint64_t(1'000'000'000 / frameRate);
nFrames = Smacker_GetNumFrames(hSMK);
@ -789,7 +786,7 @@ DEFINE_ACTION_FUNCTION(_MoviePlayer, Create)
auto movie = OpenMovie(filename, *sndinf, frametime == -1? nullptr : frametimes, flags, error);
if (!movie)
{
Printf(TEXTCOLOR_YELLOW, "%s", error.GetChars());
Printf(TEXTCOLOR_YELLOW "%s", error.GetChars());
}
ACTION_RETURN_POINTER(movie);
}
@ -808,7 +805,6 @@ DEFINE_ACTION_FUNCTION(_MoviePlayer, Frame)
PARAM_SELF_STRUCT_PROLOGUE(MoviePlayer);
PARAM_FLOAT(clock);
ACTION_RETURN_INT(self->Frame(int64_t(clock)));
return 0;
}
DEFINE_ACTION_FUNCTION(_MoviePlayer, Destroy)

View file

@ -49,7 +49,7 @@
#include "v_draw.h"
#include "s_music.h"
#include "cmdlib.h"
#include "templates.h"
@ -97,7 +97,7 @@ static bool StreamCallbackFunc(SoundStream* stream, void* buff, int len, void* u
InterplayDecoder* pId = (InterplayDecoder*)userdata;
memcpy(buff, &pId->audio.samples[pId->audio.nRead], len);
pId->audio.nRead += len / 2;
if (pId->audio.nRead >= countof(pId->audio.samples)) pId->audio.nRead = 0;
if (pId->audio.nRead >= (int)countof(pId->audio.samples)) pId->audio.nRead = 0;
return true;
}
@ -364,7 +364,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock)
}
audio.samples[audio.nWrite++] = predictor[ch];
if (audio.nWrite >= countof(audio.samples)) audio.nWrite = 0;
if (audio.nWrite >= (int)countof(audio.samples)) audio.nWrite = 0;
}
int ch = 0;
@ -374,7 +374,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock)
predictor[ch] = clamp(predictor[ch], -32768, 32768);
audio.samples[audio.nWrite++] = predictor[ch];
if (audio.nWrite >= countof(audio.samples)) audio.nWrite = 0;
if (audio.nWrite >= (int)countof(audio.samples)) audio.nWrite = 0;
// toggle channel
ch ^= audio.nChannels - 1;
@ -442,7 +442,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock)
}
else
{
if (opcodeSize != decodeMap.nSize) {
if (opcodeSize != (int)decodeMap.nSize) {
delete[] decodeMap.pData;
decodeMap.pData = new uint8_t[opcodeSize];
decodeMap.nSize = opcodeSize;
@ -464,7 +464,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock)
if (decodeMap.nSize)
{
int i = 0;
for (uint32_t y = 0; y < nHeight; y += 8)
{
for (uint32_t x = 0; x < nWidth; x += 8)
@ -948,7 +948,7 @@ void InterplayDecoder::DecodeBlock13(int32_t offset)
{
// 4-color block encoding: each 4x4 block is a different color
uint8_t* pBuffer = GetCurrentFrame() + (intptr_t)offset;
uint8_t P[2];
uint8_t P[2] = {};
for (int y = 0; y < 8; y++)
{

View file

@ -58,7 +58,7 @@ public:
{
CHUNK_PREAMBLE_SIZE = 4,
OPCODE_PREAMBLE_SIZE = 4,
CHUNK_INIT_AUDIO = 0x0000,
CHUNK_AUDIO_ONLY = 0x0001,
CHUNK_INIT_VIDEO = 0x0002,
@ -70,7 +70,7 @@ public:
CHUNK_NOMEM = 0xFFFD,
CHUNK_EOF = 0xFFFE,
CHUNK_BAD = 0xFFFF,
OPCODE_END_OF_STREAM = 0x00,
OPCODE_END_OF_CHUNK = 0x01,
OPCODE_CREATE_TIMER = 0x02,
@ -93,7 +93,7 @@ public:
OPCODE_UNKNOWN_13 = 0x13,
OPCODE_UNKNOWN_14 = 0x14,
OPCODE_UNKNOWN_15 = 0x15,
PALETTE_COUNT = 256,
kAudioBlocks = 20 // alloc a lot of blocks - need to store lots of audio data before video frames start.
};

View file

@ -88,12 +88,14 @@ void Job_Init()
VMFunction* LookupFunction(const char* qname, bool validate)
{
size_t p = strcspn(qname, ".");
if (p == 0) I_Error("Call to undefined function %s", qname);
if (p == 0)
I_Error("Call to undefined function %s", qname);
FString clsname(qname, p);
FString funcname = qname + p + 1;
auto func = PClass::FindFunction(clsname, funcname);
if (func == nullptr) I_Error("Call to undefined function %s", qname);
if (func == nullptr)
I_Error("Call to undefined function %s", qname);
if (validate)
{
// these conditions must be met by all functions for this interface.
@ -141,7 +143,6 @@ DObject* CreateRunner(bool clearbefore)
void AddGenericVideo(DObject* runner, const FString& fn, int soundid, int fps)
{
auto obj = runnerclass->CreateNew();
auto func = LookupFunction("ScreenJobRunner.AddGenericVideo", false);
VMValue val[] = { runner, &fn, soundid, fps };
VMCall(func, val, 4, nullptr, 0);
@ -155,7 +156,7 @@ void AddGenericVideo(DObject* runner, const FString& fn, int soundid, int fps)
int CutsceneDef::GetSound()
{
int id;
int id = -1;
if (soundName.IsNotEmpty()) id = soundEngine->FindSound(soundName);
if (id <= 0) id = soundEngine->FindSoundByResID(soundID);
return id;
@ -332,7 +333,7 @@ bool StartCutscene(const char* s, int flags, const CompletionFunc& completion)
{
CutsceneDef def;
def.function = s;
return StartCutscene(def, 0, completion);
return StartCutscene(def, flags, completion);
}
//=============================================================================

View file

@ -15,6 +15,7 @@ enum gamestate_t : int
GS_TITLELEVEL, // [RH] A combination of GS_LEVEL and GS_DEMOSCREEN
GS_INTRO,
GS_CUTSCENE,
GS_MENUSCREEN = GS_DEMOSCREEN,
GS_FORCEWIPE = -1,

View file

@ -34,7 +34,6 @@ struct SystemCallbacks
void (*FontCharCreated)(FGameTexture* base, FGameTexture* untranslated);
void (*ToggleFullConsole)();
void (*StartCutscene)(bool blockui);
};
extern SystemCallbacks sysCallbacks;

View file

@ -243,9 +243,9 @@ const char *kSMK4iD = "SMK4";
* Context used for code reconstructing
*/
typedef struct HuffContext {
int length;
int maxlength;
int current;
int length = 0;
int maxlength = 0;
int current = 0;
std::vector<uint32_t> bits;
std::vector<int> lengths;