From bf4ffa8bb7e429e20600278f5cdf263ab816643c Mon Sep 17 00:00:00 2001 From: Stian Skjelstad Date: Fri, 27 Dec 2024 23:14:45 +0100 Subject: [PATCH] [HVL] * files with size below 4096 were not able to be detected on modland.com virtual drive. * instrument-viewer must fetch the instruments from index 1, not 0. * track-viewer must fetch global commands from the actual number of channels in use. * reset the channel-information-cache on file-load, else we might try to dereference pointers from the previous song played. --- playhvl/hvlpinst.c | 31 ++++++++++++++----------------- playhvl/hvlplay.c | 3 ++- playhvl/hvlptrak.c | 2 +- playhvl/hvltype.c | 3 +-- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/playhvl/hvlpinst.c b/playhvl/hvlpinst.c index 689a4002..68ef549e 100644 --- a/playhvl/hvlpinst.c +++ b/playhvl/hvlpinst.c @@ -31,9 +31,10 @@ static void hvlDisplayIns40 (struct cpifaceSessionAPI_t *cpifaceSession, uint16_t *buf, int n, int plInstMode, int compoMode) { - char col=plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]]; + char col = plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]]; + cpifaceSession->console->WriteString (buf, 0, col, (!plInstMode&&plInstUsed[n])?"\xfe##: ":" ##: ", 5); - cpifaceSession->console->WriteNum (buf, 1, col, n+1, 16, 2, 0); + cpifaceSession->console->WriteNum (buf, 1, col, n, 16, 2, 0); cpifaceSession->console->WriteString (buf, 5, col, compoMode?"#":ht->ht_Instruments[n].ins_Name, 35); } @@ -42,7 +43,7 @@ static void hvlDisplayIns33 (struct cpifaceSessionAPI_t *cpifaceSession, uint16_ char col=plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]]; cpifaceSession->console->WriteString (buf, 0, col, (!plInstMode&&plInstUsed[n])?"\xfe##: ":" ##: ", 5); - cpifaceSession->console->WriteNum (buf, 1, col, n+1, 16, 2, 0); + cpifaceSession->console->WriteNum (buf, 1, col, n, 16, 2, 0); cpifaceSession->console->WriteString (buf, 5, col, compoMode?"#":ht->ht_Instruments[n].ins_Name, 28); } @@ -50,19 +51,17 @@ static void hvlDisplayIns52 (struct cpifaceSessionAPI_t *cpifaceSession, uint16_ { char col=plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]]; cpifaceSession->console->WriteString (buf, 0, col, (!plInstMode&&plInstUsed[n])?" \xfe##: ":" ##: ", 9); - cpifaceSession->console->WriteNum (buf, 5, col, n+1, 16, 2, 0); + cpifaceSession->console->WriteNum (buf, 5, col, n, 16, 2, 0); cpifaceSession->console->WriteString (buf, 9, col, compoMode?"#":ht->ht_Instruments[n].ins_Name, 43); } static void hvlDisplayIns80 (struct cpifaceSessionAPI_t *cpifaceSession, uint16_t *buf, int n, int plInstMode, int compoMode) { - char col; - + char col = plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]]; cpifaceSession->console->WriteString (buf, 0, 0, "", 80); - col = plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]]; cpifaceSession->console->WriteString (buf, 0, col, (!plInstMode&&plInstUsed[n])?"\xfe##: ":" ##: ", 5); - cpifaceSession->console->WriteNum (buf, 1, col, n+1, 16, 2, 0); + cpifaceSession->console->WriteNum (buf, 1, col, n, 16, 2, 0); cpifaceSession->console->WriteString (buf, 5, col, compoMode?"#":ht->ht_Instruments[n].ins_Name, 50); cpifaceSession->console->WriteNum (buf, 56, col, ht->ht_Instruments[n].ins_Volume, 10, 3, 0); cpifaceSession->console->WriteNum (buf, 63, col, ht->ht_Instruments[n].ins_WaveLength, 10, 3, 0); @@ -73,14 +72,12 @@ static void hvlDisplayIns80 (struct cpifaceSessionAPI_t *cpifaceSession, uint16_ static void hvlDisplayIns132 (struct cpifaceSessionAPI_t *cpifaceSession, uint16_t *buf, int n, int plInstMode, int compoMode) { - char col; + char col = plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]]; cpifaceSession->console->WriteString (buf, 0, 0, "", 132); - col = plInstMode?0x07:"\x08\x08\x0B\x0A"[(unsigned)plInstUsed[n]]; - cpifaceSession->console->WriteString (buf, 0, col, (!plInstMode&&plInstUsed[n])?"\xfe##: ":" ##: ", 5); - cpifaceSession->console->WriteNum (buf, 1, col, n+1, 16, 2, 0); + cpifaceSession->console->WriteNum (buf, 1, col, n, 16, 2, 0); cpifaceSession->console->WriteString (buf, 5, col, compoMode?"#":ht->ht_Instruments[n].ins_Name, 58); cpifaceSession->console->WriteNum (buf, 64, col, ht->ht_Instruments[n].ins_Volume, 10, 3, 0); @@ -114,19 +111,19 @@ static void hvlDisplayIns (struct cpifaceSessionAPI_t *cpifaceSession, uint16_t switch (width) { case cpiInstWidth_33: - hvlDisplayIns33 (cpifaceSession, buf, n, plInstMode, compoMode); + hvlDisplayIns33 (cpifaceSession, buf, n + 1, plInstMode, compoMode); break; case cpiInstWidth_40: - hvlDisplayIns40 (cpifaceSession, buf, n, plInstMode, compoMode); + hvlDisplayIns40 (cpifaceSession, buf, n + 1, plInstMode, compoMode); break; case cpiInstWidth_52: - hvlDisplayIns52 (cpifaceSession, buf, n, plInstMode, compoMode); + hvlDisplayIns52 (cpifaceSession, buf, n + 1, plInstMode, compoMode); break; case cpiInstWidth_80: - hvlDisplayIns80 (cpifaceSession, buf, n, plInstMode, compoMode); + hvlDisplayIns80 (cpifaceSession, buf, n + 1, plInstMode, compoMode); break; case cpiInstWidth_132: - hvlDisplayIns132 (cpifaceSession, buf, n, plInstMode, compoMode); + hvlDisplayIns132 (cpifaceSession, buf, n + 1, plInstMode, compoMode); break; } } diff --git a/playhvl/hvlplay.c b/playhvl/hvlplay.c index 12665790..28ef7503 100644 --- a/playhvl/hvlplay.c +++ b/playhvl/hvlplay.c @@ -250,7 +250,7 @@ OCP_INTERNAL void hvlIdler (struct cpifaceSessionAPI_t *cpifaceSession) { struct hvl_voice *voice = ht->ht_Voices + j; struct hvl_step *Step = ht->ht_Tracks[ht->ht_Positions[ht->ht_PosNr].pos_Track[voice->vc_VoiceNum]] + ht->ht_NoteNr; - if (ht->ht_Voices[j].vc_Instrument) + if (voice->vc_Instrument) { if (voice->vc_Instrument->ins_Name[0]) { @@ -629,6 +629,7 @@ OCP_INTERNAL int hvlOpenPlayer (const uint8_t *mem, size_t memlen, struct ocpfil return errPlay; } + memset (ChanInfo, 0, sizeof (ChanInfo)); hvl_InitReplayer (); hvlRate=0; diff --git a/playhvl/hvlptrak.c b/playhvl/hvlptrak.c index bfd352d8..5c56c7c1 100644 --- a/playhvl/hvlptrak.c +++ b/playhvl/hvlptrak.c @@ -224,7 +224,7 @@ static void hvl_getgcmd (struct cpifaceSessionAPI_t *cpifaceSession, uint16_t *b int i; struct hvl_step *Step; - for (i=0; i < MAX_CHANNELS; i++) + for (i=0; i < ht->ht_Channels; i++) { Step = ht->ht_Tracks [ ht->ht_Positions [ curPosition ] .pos_Track [ i ] ] + curRow; _hvl_getgcmd (cpifaceSession, buf, &n, Step->stp_FX, Step->stp_FXParam); diff --git a/playhvl/hvltype.c b/playhvl/hvltype.c index 80dab3c7..4637c25f 100644 --- a/playhvl/hvltype.c +++ b/playhvl/hvltype.c @@ -169,7 +169,6 @@ static int hvlReadMemInfo_hvl(struct moduleinfostruct *m, const char *_buf, size static int hvlReadMemInfo(struct moduleinfostruct *m, const char *buf, size_t len, const struct mdbReadInfoAPI_t *API) { - if (len >= 4) { if( ( buf[0] == 'T' ) && @@ -221,7 +220,7 @@ static int hvlReadInfo(struct moduleinfostruct *m, struct ocpfilehandle_t *fp, c filelen = fp->filesize(fp); /* hvlReadMemInfo already had the full file at the first pass */ - if (filelen == len) + if (m->modtype.integer.i == MODULETYPE("HVL")) { return 0; }