Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext Thread*Show in Threaded Mode


SubjectMaybe this is a fix for Casio key lag- new Reply to this message
Posted byAnonymous (207.226.219.111)
Posted on09/16/01 10:15 PM



http://pocketmx.temp.veriohosting.com/pocketmatrix.com/cgi-bin/forum/welcome.pl?board=Phantom&action=display&num=1969&start=30

Orbe mentions, "NOTE: Because of the well-known lag problem in the Casio keyboard driver this executable bypasses that driver and reads the key status directly from memory. "

Is this method already used in Lame or could this fix the key press problem when playing shooters in MameCE?






SubjectRe: Maybe this is a fix for Casio key lag- Reply to this message
Posted byAnonymous (207.226.219.111)
Posted on09/16/01 10:18 PM



Oops. I typ'od. I should have said "Is this method already used in MameCE"






SubjectHere's Orpe's code: new Reply to this message
Posted byAnonymous (207.226.219.111)
Posted on09/17/01 12:41 PM



http://pocketmx.temp.veriohosting.com/pocketmatrix.com/cgi-bin/forum/welcome.pl?board=Phantom&action=display&num=1969&start=60

//
// Key Definitions
//
#define CASIO_ACTION_UP 0x0001
#define CASIO_ACTION_DOWN 0x0002
#define CASIO_ACTION_PRESSED 0x0004
#define CASIO_WINDOWS 0x0008
#define CASIO_PAD_UP 0x0010
#define CASIO_PAD_DOWN 0x0020
#define CASIO_PAD_RIGHT 0x0040
#define CASIO_PAD_LEFT 0x0080
#define CASIO_NOTES 0x0200
#define CASIO_CONTACTS 0x0400
#define CASIO_CALENDAR 0x0800
#define CASIO_MENU 0x1000
//
// This function actually exists in the
// MicroSoft libraries but is not included in the header
// files (or in most documentation) It it documented on
// MSDN online though.
//
extern "C" BOOL VirtualCopy ( LPVOID lpvDest, LPVOID lpvSrc, DWORD cbSize, DWORD fdwProtect );
//
// Init code
// Sets some things up so that the specified address can
// be read. The address is 0x1400a018. At that address
// is a WORD containing the status of each key.
//
DWORD dwSize = 0xa018*2;
virtMem = VirtualAlloc (0, dwSize, MEM_RESERVE, PAGE_NOACCESS);
if (virtMem == NULL)
Error ("Cannot allocate virtual memory range.";
BOOL bRet = VirtualCopy(virtMem, (void *)((0x14000000) >>,
dwSize, PAGE_READWRITE |
PAGE_NOCACHE | PAGE_PHYSICAL);
if (!bRet)
Error ("Cannot allocate physical memory range.";
WORD * keyStatusPort = (WORD *) (((unsigned char *)
virtMem) + 0xa01;
//
// Reading the keys
//
WORD status = *keyStatusPort;
if ((status & CASIO_PAD_UP) != 0)
// up button on the pad was pressed...
//
// NOTE:
//
// The keyStatusPort is some sort of memory mapped
// hardware port and
// because of that works in some special ways.
//
// * When it is read it is also cleared, i.e. if you read
// it again it is all zeros.
// I think I remember this correctly, but do some
// tests...
//
// * This also means that if the built-in keyboard driver
// reads it before you do, keypresses will be lost. (In
// games like Descent this is not a problem though). And
// because the built-in driver is so slow and laggy (for
// some reason) the game will probably almost always beat
// it, at least if it reads the key-status often enough.
// The cost of reading the keystatus is basically 0.
//
// * It is possible to determine KEY_PAD_UP and
// KEY_PAD_DOWN from UP and DOWN on the action button
// =)
//
// * This probably isn't the Microsoft way of doing
// things... I have only tested it on an E-115, it
// seems that it doesn't work on E-125 but possibly the
// E-125 just has that port at another address.
//
//




Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode