project64/Source/nragev20/PakIO.h

173 lines
5.1 KiB
C
Raw Normal View History

2020-02-09 11:36:49 +00:00
/*
N-Rage`s Dinput8 Plugin
(C) 2002, 2006 Norbert Wladyka
2016-01-27 09:11:59 +00:00
Author`s Email: norbert.wladyka@chello.at
Website: http://go.to/nrage
2016-01-27 09:11:59 +00:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the free Software Foundation; either version 2 of the License, or
(at your option) any later version.
2016-01-27 09:11:59 +00:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2016-01-27 09:11:59 +00:00
You should have received a copy of the GNU General Public License
along with this program; if not, write to the free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2016-01-27 09:11:59 +00:00
*/
#ifndef _PAKIO_H_
#define _PAKIO_H_
bool InitControllerPak( const int iControl );
void SaveControllerPak( const int iControl );
BYTE ReadControllerPak( const int iControl, LPBYTE Command );
BYTE WriteControllerPak( const int iControl, LPBYTE Command );
void CloseControllerPak( const int iControl );
WORD ShowMemPakContent( const unsigned char * bMemPakBinary, HWND hListWindow );
int TranslateNotesA( const unsigned char * bNote, LPSTR Text, const int iChars );
int TranslateNotesW( const unsigned char * bNote, LPWSTR Text, const int iChars );
void FormatMemPak( LPBYTE aMemPak );
bool SaveNoteFileA( const unsigned char * aMemPak, const int iNote, LPCTSTR pszFileName );
bool InsertNoteFile( LPBYTE aMemPak, LPCTSTR pszFileName );
bool RemoveNote( LPBYTE aMemPak, const int iNote );
void TexttoHexA( LPCSTR szText, LPBYTE Data, const int nBytes );
void HextoTextA( const unsigned char * Data, LPSTR szText, const int nBytes );
#ifdef _UNICODE
#define TranslateNotes(x,y,z) TranslateNotesW(x,y,z)
#define ReverseNotes(x,y,z) ReverseNotesW(x,y,z)
#else
#define TranslateNotes(x,y,z) TranslateNotesA(x,y,z)
#define ReverseNotes(x,y,z) ReverseNotesA(x,y,z)
#endif
// Raw data
// Byte 1 = Number of bytes to send
// Byte 2 = Number of bytes to receive
// Byte 3 = Command type
2016-01-27 09:11:59 +00:00
// Get status
2020-02-09 11:36:49 +00:00
#define RD_GETSTATUS 0x00
// Read button values
2020-02-09 11:36:49 +00:00
#define RD_READKEYS 0x01
// Read from controller pak
2020-02-09 11:36:49 +00:00
#define RD_READPAK 0x02
// Write to controller pak
2020-02-09 11:36:49 +00:00
#define RD_WRITEPAK 0x03
// Reset controller
2020-02-09 11:36:49 +00:00
#define RD_RESETCONTROLLER 0xff
// Read EEPROM
2020-02-09 11:36:49 +00:00
#define RD_READEEPROM 0x04
// Write EEPROM
2020-02-09 11:36:49 +00:00
#define RD_WRITEEPROM 0x05
// Codes for retrieving status
// 0x010300 - A1B2C3FF
2016-01-27 09:11:59 +00:00
// A1
// Default controller
2020-02-09 11:36:49 +00:00
#define RD_ABSOLUTE 0x01
#define RD_RELATIVE 0x02
// Default controller
2020-02-09 11:36:49 +00:00
#define RD_GAMEPAD 0x04
// B2
2020-02-09 11:36:49 +00:00
#define RD_EEPROM 0x80
#define RD_NOEEPROM 0x00
// C3
// No plugin in controller
2020-02-09 11:36:49 +00:00
#define RD_NOPLUGIN 0x00
// Plugin in controller (memory pak, rumble pak, etc.)
2020-02-09 11:36:49 +00:00
#define RD_PLUGIN 0x01
// Pak interface was uninitialized before the call
2020-02-09 11:36:49 +00:00
#define RD_NOTINITIALIZED 0x02
// Address of last pak I/O was invalid
2020-02-09 11:36:49 +00:00
#define RD_ADDRCRCERR 0x04
// EEPROM busy
2020-02-09 11:36:49 +00:00
#define RD_EEPROMBUSY 0x80
2016-01-27 09:11:59 +00:00
// The error values are as follows:
2016-01-27 09:11:59 +00:00
// 0x01ER00 - ........
// ER
// No error, operation successful
2020-02-09 11:36:49 +00:00
#define RD_OK 0x00
// Error, device not present for specified command
2020-02-09 11:36:49 +00:00
#define RD_ERROR 0x80
// Error, unable to send/receive the number of bytes for command type
2020-02-09 11:36:49 +00:00
#define RD_WRONGSIZE 0x40
2016-01-27 09:11:59 +00:00
// The address where rumble-commands are sent to
// This is really 0xC01B but our addressing code truncates the last several bits
2020-02-09 11:36:49 +00:00
#define PAK_IO_RUMBLE 0xC000
2016-01-27 09:11:59 +00:00
// 32KB memory pak
2020-02-09 11:36:49 +00:00
#define PAK_MEM_SIZE 32*1024
#define PAK_MEM_DEXOFFSET 0x1040
2016-01-27 09:11:59 +00:00
// Pak-specific data
// First byte always determines current pak type
// This can be different to the pak type in the controller structure
// That makes sure to correctly handle/close the pak
2016-01-27 09:11:59 +00:00
//PAK_NONE
//pPakData = NULL;
//PAK_MEM
typedef struct _MEMPAK
{
BYTE bPakType; // Set to PAK_MEM
HANDLE hMemPakHandle; // A file mapping handle
bool fDexSave; // True if .n64 file, false if .mpk file
bool fReadonly; // Set if we can't open memory pak file in "write" mode
2020-02-09 11:36:49 +00:00
LPBYTE aMemPakData; //[PAK_MEM_SIZE];
BYTE aMemPakTemp[0x100]; // Some extra on the top for "test" (temporary) data
2016-01-27 09:11:59 +00:00
} MEMPAK, *LPMEMPAK;
//PAK_RUMBLE
typedef struct _RUMBLEPAK
{
2020-02-09 11:36:49 +00:00
BYTE bPakType;
// BYTE bRumbleTyp; // Obsolete: use g_pcControllers[i].xyz instead (comment by rabid)
2020-02-09 11:36:49 +00:00
// BYTE bRumbleStrength;
// bool fVisualRumble;
bool fLastData; // True if the last data sent to block 0x8000 was non-zero
2016-01-27 09:11:59 +00:00
} RUMBLEPAK, *LPRUMBLEPAK;
#include "GBCart.h"
//PAK_TRANSFER
typedef struct _TRANSFERPAK
{
2020-02-09 11:36:49 +00:00
BYTE bPakType;
int iCurrentBankNo;
int iCurrentAccessMode;
int iAccessModeChanged;
bool iEnableState;
bool bPakInserted;
GBCART gbCart;
2016-01-27 09:11:59 +00:00
} TRANSFERPAK, *LPTRANSFERPAK;
//PAK_VOICE
typedef struct _VOICEPAK // Not supported
2016-01-27 09:11:59 +00:00
{
2020-02-09 11:36:49 +00:00
BYTE bPakType;
2016-01-27 09:11:59 +00:00
} VOICEPAK, *LPVOICEPAK;
2020-02-09 11:36:49 +00:00
2016-01-27 09:11:59 +00:00
//PAK_ADAPTOID
typedef struct _ADAPTOIDPAK
{
2020-02-09 11:36:49 +00:00
BYTE bPakType;
BYTE bIdentifier;
bool fRumblePak;
2016-01-27 09:11:59 +00:00
} ADAPTOIDPAK, *LPADAPTOIDPAK;
#endif // #ifndef _PAKIO_H_