mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-07 01:13:18 +00:00
Fix track change logic (track is/should be serialized as BCD)
This commit is contained in:
+14
-5
@@ -324,10 +324,11 @@ static uint8_t toBCD(uint8_t x) {
|
||||
}
|
||||
|
||||
// Serialize cd_status into the wire format. The struct layout mirrors the wire
|
||||
// format byte-for-byte, except for mins/secs, which need converted from integer
|
||||
// to BCD
|
||||
// format byte-for-byte, except for track/mins/secs, which need converted from
|
||||
// decimal to BCD
|
||||
static void serializeCDStatus(uint8_t *dst) {
|
||||
memcpy(dst, &cd_status, sizeof(cd_status));
|
||||
dst[3] = toBCD(cd_status.track);
|
||||
dst[4] = toBCD(cd_status.mins);
|
||||
dst[5] = toBCD(cd_status.secs);
|
||||
}
|
||||
@@ -1037,7 +1038,10 @@ response_t AVCLAN_handleframe(const AVCLAN_frame_t *in, AVCLAN_frame_t *out) {
|
||||
break;
|
||||
case PACK3(dev_CMD_SW, dev_CD_CHANGER, Track_Seek_Up):
|
||||
cd_status.state = cd_SEEKING_TRACK;
|
||||
(*cd_Track)++;
|
||||
if (*cd_Track < 98)
|
||||
++*cd_Track;
|
||||
else
|
||||
*cd_Track = 1;
|
||||
*cd_Time_Min = 0xff;
|
||||
*cd_Time_Sec = 0x7f;
|
||||
cd_status.flags |= cd_SCAN;
|
||||
@@ -1047,10 +1051,15 @@ response_t AVCLAN_handleframe(const AVCLAN_frame_t *in, AVCLAN_frame_t *out) {
|
||||
break;
|
||||
case PACK3(dev_CMD_SW, dev_CD_CHANGER, Track_Seek_Down):
|
||||
cd_status.state = cd_SEEKING_TRACK;
|
||||
(*cd_Track)--;
|
||||
// Track down returns to track beginning if in ~middle of song
|
||||
if (*cd_Time_Min == 0 && *cd_Time_Sec < 0x05) {
|
||||
if (*cd_Track > 1)
|
||||
--*cd_Track;
|
||||
else
|
||||
*cd_Track = 99;
|
||||
}
|
||||
*cd_Time_Min = 0xff;
|
||||
*cd_Time_Sec = 0x7f;
|
||||
cd_status.flags |= cd_SCAN;
|
||||
cd_status.flags2 = 0xc0;
|
||||
AVCLAN_generateStatus(out);
|
||||
respond = r_TrackChange;
|
||||
|
||||
+3
-3
@@ -155,9 +155,9 @@ typedef struct AVCLAN_CD_Status {
|
||||
uint8_t cds;
|
||||
uint8_t state;
|
||||
uint8_t disc;
|
||||
uint8_t track;
|
||||
uint8_t mins;
|
||||
uint8_t secs;
|
||||
uint8_t track; // Decimal storage; serialize to BCD
|
||||
uint8_t mins; // Decimal storage; serialize to BCD
|
||||
uint8_t secs; // Decimal storage; serialize to BCD
|
||||
uint8_t flags;
|
||||
uint8_t flags2;
|
||||
} AVCLAN_CD_Status_t;
|
||||
|
||||
Reference in New Issue
Block a user