Skip to content

Commit

Permalink
[HVL]
Browse files Browse the repository at this point in the history
 * 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.
  • Loading branch information
mywave82 committed Dec 27, 2024
1 parent 1aa1151 commit bf4ffa8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
31 changes: 14 additions & 17 deletions playhvl/hvlpinst.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -42,27 +43,25 @@ 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);
}

static void hvlDisplayIns52 (struct cpifaceSessionAPI_t *cpifaceSession, uint16_t *buf, int n, int plInstMode, int compoMode)
{
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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion playhvl/hvlplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion playhvl/hvlptrak.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions playhvl/hvltype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) &&
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit bf4ffa8

Please sign in to comment.