mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 03:19:24 +01:00
Demarshal and marshal data, use linecnt for delay
This commit is contained in:
parent
e65c29ed4c
commit
6d79aaee12
@ -327,8 +327,7 @@ void MOS6510::write_byte_io(uint16 adr, uint8 byte)
|
|||||||
case 0x5:
|
case 0x5:
|
||||||
case 0x6:
|
case 0x6:
|
||||||
case 0x7:
|
case 0x7:
|
||||||
if (this->network_connection_type != CLIENT)
|
TheSID->WriteRegister(adr & 0x1f, byte);
|
||||||
TheSID->WriteRegister(adr & 0x1f, byte);
|
|
||||||
return;
|
return;
|
||||||
case 0x8: // Color RAM
|
case 0x8: // Color RAM
|
||||||
case 0x9:
|
case 0x9:
|
||||||
|
@ -402,16 +402,16 @@ void Network::EncodeTextMessage(char *str)
|
|||||||
|
|
||||||
|
|
||||||
static int bytes = 0;
|
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];
|
NetworkUpdateSoundInfo *cur = &this->sound_active[this->sound_head];
|
||||||
|
|
||||||
cur->adr = adr;
|
cur->adr = adr;
|
||||||
cur->val = val;
|
cur->val = val;
|
||||||
cur->delay_cycles = TheC64->CycleCounter - sound_last_cycles;
|
cur->delay_cycles = linecnt - sound_last_cycles;
|
||||||
|
|
||||||
/* Update the cycle counter */
|
/* Update the cycle counter */
|
||||||
sound_last_cycles = TheC64->CycleCounter;
|
sound_last_cycles = linecnt;
|
||||||
this->sound_head++;
|
this->sound_head++;
|
||||||
|
|
||||||
if (this->sound_head >= NETWORK_SOUND_BUF_SIZE)
|
if (this->sound_head >= NETWORK_SOUND_BUF_SIZE)
|
||||||
@ -650,7 +650,6 @@ bool Network::MarshalData(NetworkUpdate *p)
|
|||||||
case DISPLAY_UPDATE_RAW:
|
case DISPLAY_UPDATE_RAW:
|
||||||
case DISPLAY_UPDATE_RLE:
|
case DISPLAY_UPDATE_RLE:
|
||||||
case DISPLAY_UPDATE_DIFF:
|
case DISPLAY_UPDATE_DIFF:
|
||||||
case SOUND_UPDATE:
|
|
||||||
case JOYSTICK_UPDATE:
|
case JOYSTICK_UPDATE:
|
||||||
case DISCONNECT:
|
case DISCONNECT:
|
||||||
case CONNECT_TO_PEER:
|
case CONNECT_TO_PEER:
|
||||||
@ -695,6 +694,20 @@ bool Network::MarshalData(NetworkUpdate *p)
|
|||||||
pi->key = htons(pi->key);
|
pi->key = htons(pi->key);
|
||||||
pi->version = htonl(pi->version);
|
pi->version = htonl(pi->version);
|
||||||
} break;
|
} 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:
|
default:
|
||||||
/* Unknown data... */
|
/* Unknown data... */
|
||||||
fprintf(stderr, "Got unknown data %d while marshalling. Something is wrong\n",
|
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_RAW:
|
||||||
case DISPLAY_UPDATE_RLE:
|
case DISPLAY_UPDATE_RLE:
|
||||||
case DISPLAY_UPDATE_DIFF:
|
case DISPLAY_UPDATE_DIFF:
|
||||||
case SOUND_UPDATE:
|
|
||||||
case JOYSTICK_UPDATE:
|
case JOYSTICK_UPDATE:
|
||||||
case DISCONNECT:
|
case DISCONNECT:
|
||||||
case CONNECT_TO_PEER:
|
case CONNECT_TO_PEER:
|
||||||
@ -779,6 +791,20 @@ bool Network::DeMarshalData(NetworkUpdate *p)
|
|||||||
}
|
}
|
||||||
lp->your_port = ntohs(lp->your_port);
|
lp->your_port = ntohs(lp->your_port);
|
||||||
} break;
|
} 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:
|
default:
|
||||||
/* Unknown data... */
|
/* Unknown data... */
|
||||||
printf("Got unknown data: %d\n", p->type);
|
printf("Got unknown data: %d\n", p->type);
|
||||||
|
@ -179,7 +179,7 @@ public:
|
|||||||
|
|
||||||
void EncodeTextMessage(char *str);
|
void EncodeTextMessage(char *str);
|
||||||
|
|
||||||
void PushSound(uint8 addr, uint8 val);
|
void PushSound(uint32 linecnt, uint8 addr, uint8 val);
|
||||||
|
|
||||||
void FlushSound(void);
|
void FlushSound(void);
|
||||||
|
|
||||||
|
@ -921,7 +921,7 @@ void DigitalRenderer::WriteRegister(uint16 adr, uint8 byte)
|
|||||||
|
|
||||||
if (TheC64) {
|
if (TheC64) {
|
||||||
if (TheC64->network_connection_type == MASTER)
|
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)
|
else if (TheC64->network_connection_type == CLIENT)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user