make movies load faster
This commit is contained in:
parent
043aabf009
commit
fc9c64e5e7
|
@ -113,15 +113,26 @@ void MovieRecord::dumpJoy(std::ostream* os, uint8 joystate)
|
||||||
|
|
||||||
void MovieRecord::parseJoy(std::istream* is, uint8& joystate)
|
void MovieRecord::parseJoy(std::istream* is, uint8& joystate)
|
||||||
{
|
{
|
||||||
|
char buf[8];
|
||||||
|
is->read(buf,8);
|
||||||
joystate = 0;
|
joystate = 0;
|
||||||
for(int bit=7;bit>=0;bit--)
|
for(int i=0;i<8;i++)
|
||||||
{
|
{
|
||||||
int c = is->get();
|
joystate <<= 1;
|
||||||
if(c == -1)
|
joystate |= ((buf[i]!=' ')?1:0);
|
||||||
return;
|
|
||||||
if(c != ' ')
|
|
||||||
joystate |= (1<<bit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//older, slower(?) way:
|
||||||
|
|
||||||
|
//joystate = 0;
|
||||||
|
//for(int bit=7;bit>=0;bit--)
|
||||||
|
//{
|
||||||
|
// int c = is->get();
|
||||||
|
// if(c == -1)
|
||||||
|
// return;
|
||||||
|
// if(c != ' ')
|
||||||
|
// joystate |= (1<<bit);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovieRecord::parse(MovieData* md, std::istream* is)
|
void MovieRecord::parse(MovieData* md, std::istream* is)
|
||||||
|
@ -129,7 +140,7 @@ void MovieRecord::parse(MovieData* md, std::istream* is)
|
||||||
//by the time we get in here, the initial pipe has already been extracted
|
//by the time we get in here, the initial pipe has already been extracted
|
||||||
|
|
||||||
//extract the commands
|
//extract the commands
|
||||||
*is >> commands;
|
commands = uintDecFromIstream(is);
|
||||||
is->get(); //eat the pipe
|
is->get(); //eat the pipe
|
||||||
|
|
||||||
//a special case: if fourscore is enabled, parse four gamepads
|
//a special case: if fourscore is enabled, parse four gamepads
|
||||||
|
@ -150,6 +161,7 @@ void MovieRecord::parse(MovieData* md, std::istream* is)
|
||||||
{
|
{
|
||||||
int x,y,b;
|
int x,y,b;
|
||||||
*is >> x >> y >> b;
|
*is >> x >> y >> b;
|
||||||
|
//todo: test uintDecFromIstream
|
||||||
zappers[port].x = x;
|
zappers[port].x = x;
|
||||||
zappers[port].y = y;
|
zappers[port].y = y;
|
||||||
zappers[port].b = b;
|
zappers[port].b = b;
|
||||||
|
|
|
@ -462,3 +462,19 @@ char *U8ToHexStr(uint8 a)
|
||||||
TempArray[2] = 0;
|
TempArray[2] = 0;
|
||||||
return TempArray;
|
return TempArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int uintDecFromIstream(std::istream* is)
|
||||||
|
{
|
||||||
|
unsigned int ret = 0;
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
int d = is->get() - '0';
|
||||||
|
if(d<0 || d>9)
|
||||||
|
break;
|
||||||
|
ret *= 10;
|
||||||
|
ret += d;
|
||||||
|
}
|
||||||
|
is->unget();
|
||||||
|
return ret;
|
||||||
|
}
|
|
@ -21,6 +21,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
|
|
||||||
|
@ -53,3 +54,6 @@ char *U32ToDecStr(char* buf, uint32 a);
|
||||||
char *U8ToDecStr(uint8 a);
|
char *U8ToDecStr(uint8 a);
|
||||||
char *U8ToHexStr(uint8 a);
|
char *U8ToHexStr(uint8 a);
|
||||||
char *U16ToHexStr(uint16 a);
|
char *U16ToHexStr(uint16 a);
|
||||||
|
|
||||||
|
//extracts a decimal uint from an istream
|
||||||
|
unsigned int uintDecFromIstream(std::istream* is);
|
Loading…
Reference in New Issue