summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author MetalliC <0vetal0@gmail.com>2015-01-28 19:11:08 +0200
committer MetalliC <0vetal0@gmail.com>2015-01-28 19:11:08 +0200
commit6bccc57b7c644abdbb2c12ccd700e60095b4f608 (patch)
tree8c1699bfc15da5612b7887b58077ef9ba2d777e0
parent8317717dd546c6133d5685d39863477d8bc200da (diff)
jvs host: fix packet encoding, similar to previous
-rw-r--r--src/emu/machine/jvshost.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/emu/machine/jvshost.c b/src/emu/machine/jvshost.c
index c406afff250..ec4dd5a0f94 100644
--- a/src/emu/machine/jvshost.c
+++ b/src/emu/machine/jvshost.c
@@ -116,10 +116,13 @@ void jvs_host::encode(UINT8 *buffer, UINT32 &size)
if(!size)
return;
UINT32 add = 1;
+ UINT8 sum = 0;
+ for(UINT32 i=0; i<size; i++)
+ sum += buffer[i];
+ buffer[size++] = sum;
for(UINT32 i=0; i<size; i++)
if(buffer[i] == 0xd0 || buffer[i] == 0xe0)
add++;
- UINT32 nsize = size+add;
for(UINT32 i=size; i; i--) {
UINT8 t = buffer[i-1];
if(t == 0xd0 || t == 0xe0) {
@@ -130,11 +133,7 @@ void jvs_host::encode(UINT8 *buffer, UINT32 &size)
buffer[i+add-1] = t;
}
buffer[0] = 0xe0;
- UINT8 sum = 0;
- for(UINT32 i=1; i<nsize; i++)
- sum += buffer[i];
- buffer[nsize++] = sum;
- size = nsize;
+ size += add;
}
void jvs_host::decode(UINT8 *buffer, UINT32 &size)