diff --git a/Src/CPUC64.cpp b/Src/CPUC64.cpp index 8a83ae0..b6b3bb4 100644 --- a/Src/CPUC64.cpp +++ b/Src/CPUC64.cpp @@ -327,8 +327,7 @@ void MOS6510::write_byte_io(uint16 adr, uint8 byte) case 0x5: case 0x6: case 0x7: - if (this->network_connection_type != CLIENT) - TheSID->WriteRegister(adr & 0x1f, byte); + TheSID->WriteRegister(adr & 0x1f, byte); return; case 0x8: // Color RAM case 0x9: diff --git a/Src/Network.cpp b/Src/Network.cpp index 3a560aa..98d71e9 100644 --- a/Src/Network.cpp +++ b/Src/Network.cpp @@ -402,16 +402,16 @@ void Network::EncodeTextMessage(char *str) static int bytes = 0; -void Network::PushSound(uint8 adr, uint8 val) +void Network::PushSound(uint32 linecnt, uint8 adr, uint8 val) { NetworkUpdateSoundInfo *cur = &this->sound_active[this->sound_head]; cur->adr = adr; cur->val = val; - cur->delay_cycles = TheC64->CycleCounter - sound_last_cycles; + cur->delay_cycles = linecnt - sound_last_cycles; /* Update the cycle counter */ - sound_last_cycles = TheC64->CycleCounter; + sound_last_cycles = linecnt; this->sound_head++; if (this->sound_head >= NETWORK_SOUND_BUF_SIZE) @@ -650,7 +650,6 @@ bool Network::MarshalData(NetworkUpdate *p) case DISPLAY_UPDATE_RAW: case DISPLAY_UPDATE_RLE: case DISPLAY_UPDATE_DIFF: - case SOUND_UPDATE: case JOYSTICK_UPDATE: case DISCONNECT: case CONNECT_TO_PEER: @@ -695,6 +694,20 @@ bool Network::MarshalData(NetworkUpdate *p) pi->key = htons(pi->key); pi->version = htonl(pi->version); } break; + case SOUND_UPDATE: + { + NetworkUpdateSound *snd = (NetworkUpdateSound *)p->data; + NetworkUpdateSoundInfo *info = (NetworkUpdateSoundInfo *)snd->info; + + snd->flags = htons(snd->flags); + snd->n_items = htons(snd->flags); + for (unsigned int i = 0; i < snd->n_items; i++) + { + NetworkUpdateSoundInfo *cur = &info[i]; + + cur->delay_cycles = htons(cur->delay_cycles); + } + } default: /* Unknown data... */ fprintf(stderr, "Got unknown data %d while marshalling. Something is wrong\n", @@ -741,7 +754,6 @@ bool Network::DeMarshalData(NetworkUpdate *p) case DISPLAY_UPDATE_RAW: case DISPLAY_UPDATE_RLE: case DISPLAY_UPDATE_DIFF: - case SOUND_UPDATE: case JOYSTICK_UPDATE: case DISCONNECT: case CONNECT_TO_PEER: @@ -779,6 +791,20 @@ bool Network::DeMarshalData(NetworkUpdate *p) } lp->your_port = ntohs(lp->your_port); } break; + case SOUND_UPDATE: + { + NetworkUpdateSound *snd = (NetworkUpdateSound *)p->data; + NetworkUpdateSoundInfo *info = (NetworkUpdateSoundInfo *)snd->info; + + snd->flags = ntohs(snd->flags); + snd->n_items = ntohs(snd->flags); + for (unsigned int i = 0; i < snd->n_items; i++) + { + NetworkUpdateSoundInfo *cur = &info[i]; + + cur->delay_cycles = ntohs(cur->delay_cycles); + } + } default: /* Unknown data... */ printf("Got unknown data: %d\n", p->type); diff --git a/Src/Network.h b/Src/Network.h index f27233b..6255fe1 100644 --- a/Src/Network.h +++ b/Src/Network.h @@ -179,7 +179,7 @@ public: void EncodeTextMessage(char *str); - void PushSound(uint8 addr, uint8 val); + void PushSound(uint32 linecnt, uint8 addr, uint8 val); void FlushSound(void); diff --git a/Src/SID.cpp b/Src/SID.cpp index 5c159a5..3ba56bf 100644 --- a/Src/SID.cpp +++ b/Src/SID.cpp @@ -921,7 +921,7 @@ void DigitalRenderer::WriteRegister(uint16 adr, uint8 byte) if (TheC64) { if (TheC64->network_connection_type == MASTER) - TheC64->peer->PushSound(adr, byte); + TheC64->peer->PushSound(this->linecnt, adr, byte); else if (TheC64->network_connection_type == CLIENT) return; }