Finishing up on refactoring of the "C Core Interface.cpp" file

Added a 'header guard' to 7zip.h to stop multiple definitions

TODO: Refactor/clean up Mempak.cpp more
This commit is contained in:
Emmet Young 2012-10-02 01:32:32 +10:00
parent 15894a0e6c
commit 730655dda2
15 changed files with 198 additions and 258 deletions

View File

@ -1,3 +1,6 @@
#ifndef _7ZIP_H_
#define _7ZIP_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -57,4 +60,6 @@ public:
inline int FileSize ( void ) const { return m_FileSize; } inline int FileSize ( void ) const { return m_FileSize; }
void SetNotificationCallback (LP7ZNOTIFICATION NotfyFnc, void * CBInfo); void SetNotificationCallback (LP7ZNOTIFICATION NotfyFnc, void * CBInfo);
}; };
#endif

View File

@ -19,6 +19,7 @@ class CNotification;
#include "N64 System/Mips/OpCode.h" #include "N64 System/Mips/OpCode.h"
#include "N64 System/Mips/OpCode Analysis Class.h" #include "N64 System/Mips/OpCode Analysis Class.h"
#include "N64 System/Recompiler/X86ops.h" #include "N64 System/Recompiler/X86ops.h"
#include "N64 System/Mips/Mempak.h"
#include "N64 System/Mips/FlashRam.h" #include "N64 System/Mips/FlashRam.h"
#include "N64 System/Mips/Sram.h" #include "N64 System/Mips/Sram.h"
#include "N64 System/Mips/Eeprom.h" #include "N64 System/Mips/Eeprom.h"

View File

@ -1,19 +0,0 @@
#include "stdafx.h"
#include "mempak.h"
#include "Logging.h"
//settings
enum SAVE_CHIP_TYPE g_SaveUsing;
void CC_Core::SetSettings ( )
{
if (_Settings)
{
g_SaveUsing = (SAVE_CHIP_TYPE)_Settings->LoadDword(Game_SaveChip);
}
}
void CloseSaveChips ( void )
{
CloseMempak();
}

View File

@ -1,24 +0,0 @@
#pragma once
#ifdef __cplusplus
class CC_Core
{
public:
static void SetSettings ( );
};
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include "..\\Types.h"
void CloseSaveChips ( void );
//settings
extern enum SAVE_CHIP_TYPE g_SaveUsing;
#ifdef __cplusplus
}
#endif

View File

@ -1,29 +0,0 @@
/*
* Project 64 - A Nintendo 64 emulator.
*
* (c) Copyright 2001 zilmar (zilmar@emulation64.com) and
* Jabo (jabo@emulation64.com).
*
* pj64 homepage: www.pj64.net
*
* Permission to use, copy, modify and distribute Project64 in both binary and
* source form, for non-commercial purposes, is hereby granted without fee,
* providing that this license information and copyright notice appear with
* all copies and any derived work.
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event shall the authors be held liable for any damages
* arising from the use of this software.
*
* Project64 is freeware for PERSONAL USE only. Commercial users should
* seek permission of the copyright holders first. Commercial use includes
* charging money for Project64 or software derived from Project64.
*
* The copyright holders request that bug fixes and improvements to the code
* should be forwarded to them so if they want them.
*
*/
void CloseMempak ( void );
BYTE Mempacks_CalulateCrc ( BYTE * DataToCrc );
void ReadFromMempak ( int Control, int Address, BYTE * Buffer );
void WriteToMempak ( int Control, int Address, BYTE * Buffer );

View File

@ -31,8 +31,8 @@ void CDMA::PI_DMA_READ (void) {
} }
if ( _Reg->PI_CART_ADDR_REG >= 0x08000000 && _Reg->PI_CART_ADDR_REG <= 0x08010000) { if ( _Reg->PI_CART_ADDR_REG >= 0x08000000 && _Reg->PI_CART_ADDR_REG <= 0x08010000) {
if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_Sram; } if (_System->m_SaveUsing == SaveChip_Auto) { _System->m_SaveUsing = SaveChip_Sram; }
if (g_SaveUsing == SaveChip_Sram) { if (_System->m_SaveUsing == SaveChip_Sram) {
m_Sram.DmaToSram( m_Sram.DmaToSram(
_MMU->Rdram() + _Reg->PI_DRAM_ADDR_REG, _MMU->Rdram() + _Reg->PI_DRAM_ADDR_REG,
_Reg->PI_CART_ADDR_REG - 0x08000000, _Reg->PI_CART_ADDR_REG - 0x08000000,
@ -43,7 +43,7 @@ void CDMA::PI_DMA_READ (void) {
_Reg->CheckInterrupts(); _Reg->CheckInterrupts();
return; return;
} }
if (g_SaveUsing == SaveChip_FlashRam) { if (_System->m_SaveUsing == SaveChip_FlashRam) {
m_FlashRam.DmaToFlashram( m_FlashRam.DmaToFlashram(
_MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG, _MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG,
_Reg->PI_CART_ADDR_REG - 0x08000000, _Reg->PI_CART_ADDR_REG - 0x08000000,
@ -55,7 +55,7 @@ void CDMA::PI_DMA_READ (void) {
return; return;
} }
} }
if (g_SaveUsing == SaveChip_FlashRam) if (_System->m_SaveUsing == SaveChip_FlashRam)
{ {
_Notify->DisplayError("**** FLashRam DMA Read address %X *****",_Reg->PI_CART_ADDR_REG); _Notify->DisplayError("**** FLashRam DMA Read address %X *****",_Reg->PI_CART_ADDR_REG);
_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; _Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY;
@ -85,8 +85,8 @@ void CDMA::PI_DMA_WRITE (void) {
} }
if ( _Reg->PI_CART_ADDR_REG >= 0x08000000 && _Reg->PI_CART_ADDR_REG <= 0x08010000) { if ( _Reg->PI_CART_ADDR_REG >= 0x08000000 && _Reg->PI_CART_ADDR_REG <= 0x08010000) {
if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_Sram; } if (_System->m_SaveUsing == SaveChip_Auto) { _System->m_SaveUsing = SaveChip_Sram; }
if (g_SaveUsing == SaveChip_Sram) { if (_System->m_SaveUsing == SaveChip_Sram) {
m_Sram.DmaFromSram( m_Sram.DmaFromSram(
_MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG, _MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG,
_Reg->PI_CART_ADDR_REG - 0x08000000, _Reg->PI_CART_ADDR_REG - 0x08000000,
@ -97,7 +97,7 @@ void CDMA::PI_DMA_WRITE (void) {
_Reg->CheckInterrupts(); _Reg->CheckInterrupts();
return; return;
} }
if (g_SaveUsing == SaveChip_FlashRam) { if (_System->m_SaveUsing == SaveChip_FlashRam) {
m_FlashRam.DmaFromFlashram( m_FlashRam.DmaFromFlashram(
_MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG, _MMU->Rdram()+_Reg->PI_DRAM_ADDR_REG,
_Reg->PI_CART_ADDR_REG - 0x08000000, _Reg->PI_CART_ADDR_REG - 0x08000000,

View File

@ -26,11 +26,11 @@ void CEeprom::EepromCommand ( BYTE * Command) {
time_t curtime_time; time_t curtime_time;
struct tm curtime; struct tm curtime;
if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_Eeprom_4K; } if (_System->m_SaveUsing == SaveChip_Auto) { _System->m_SaveUsing = SaveChip_Eeprom_4K; }
switch (Command[2]) { switch (Command[2]) {
case 0: // check case 0: // check
if (g_SaveUsing != SaveChip_Eeprom_4K && g_SaveUsing != SaveChip_Eeprom_16K) { if (_System->m_SaveUsing != SaveChip_Eeprom_4K && _System->m_SaveUsing != SaveChip_Eeprom_16K) {
Command[1] |= 0x80; Command[1] |= 0x80;
break; break;
} }
@ -40,12 +40,12 @@ void CEeprom::EepromCommand ( BYTE * Command) {
if ((Command[1] & 3) > 0) if ((Command[1] & 3) > 0)
Command[3] = 0x00; Command[3] = 0x00;
if ((Command[1] & 3) > 1) if ((Command[1] & 3) > 1)
Command[4] = (g_SaveUsing == SaveChip_Eeprom_4K) ? 0x80 : 0xC0; Command[4] = (_System->m_SaveUsing == SaveChip_Eeprom_4K) ? 0x80 : 0xC0;
if ((Command[1] & 3) > 2) if ((Command[1] & 3) > 2)
Command[5] = 0x00; Command[5] = 0x00;
} else { } else {
Command[3] = 0x00; Command[3] = 0x00;
Command[4] = g_SaveUsing == SaveChip_Eeprom_4K?0x80:0xC0; Command[4] = _System->m_SaveUsing == SaveChip_Eeprom_4K?0x80:0xC0;
Command[5] = 0x00; Command[5] = 0x00;
} }
break; break;

View File

@ -1806,8 +1806,8 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) {
*Value = (*Value << 16) | *Value; *Value = (*Value << 16) | *Value;
return FALSE; return FALSE;
case 0x08000000: case 0x08000000:
if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_FlashRam; } if (_System->m_SaveUsing == SaveChip_Auto) { _System->m_SaveUsing = SaveChip_FlashRam; }
if (g_SaveUsing != SaveChip_FlashRam) { if (_System->m_SaveUsing != SaveChip_FlashRam) {
*Value = PAddr & 0xFFFF; *Value = PAddr & 0xFFFF;
*Value = (*Value << 16) | *Value; *Value = (*Value << 16) | *Value;
return FALSE; return FALSE;
@ -2284,8 +2284,9 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
break; break;
case 0x08000000: case 0x08000000:
if (PAddr != 0x08010000) { return FALSE; } if (PAddr != 0x08010000) { return FALSE; }
if (g_SaveUsing == SaveChip_Auto) { g_SaveUsing = SaveChip_FlashRam; } if (_System->m_SaveUsing == SaveChip_Auto) { _System->m_SaveUsing = SaveChip_FlashRam; }
if (g_SaveUsing != SaveChip_FlashRam) { return TRUE; } if (_System->m_SaveUsing != SaveChip_FlashRam) { return TRUE; }
WriteToFlashCommand(Value); WriteToFlashCommand(Value);
return TRUE; return TRUE;
break; break;

View File

@ -0,0 +1,13 @@
#ifndef _MEMPAK_H_
#define _MEMPAK_H_
class Mempak
{
public:
static void Close ( void );
static BYTE CalculateCrc ( BYTE * DataToCrc );
static void ReadFrom ( int Control, int Address, BYTE * Buffer );
static void WriteTo ( int Control, int Address, BYTE * Buffer );
};
#endif //_MEMPAK_H_

View File

@ -1,135 +1,134 @@
#include "stdafx.h" #include "stdafx.h"
static BYTE Mempaks[4][0x8000];
static BYTE Mempak[4][0x8000]; HANDLE hMempakFile = NULL;
static HANDLE hMempakFile = NULL;
void Mempak::Close(void) {
void CloseMempak (void) { if (hMempakFile) {
if (hMempakFile) { CloseHandle(hMempakFile);
CloseHandle(hMempakFile); hMempakFile = NULL;
hMempakFile = NULL; }
} }
}
void LoadMempak (void) {
void LoadMempak (void) { char File[256], Directory[256];
char File[256], Directory[256]; DWORD dwRead, count, count2;
DWORD dwRead, count, count2;
BYTE Initilize[] = {
BYTE Initilize[] = { 0x81,0x01,0x02,0x03, 0x04,0x05,0x06,0x07, 0x08,0x09,0x0a,0x0b, 0x0C,0x0D,0x0E,0x0F,
0x81,0x01,0x02,0x03, 0x04,0x05,0x06,0x07, 0x08,0x09,0x0a,0x0b, 0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13, 0x14,0x15,0x16,0x17, 0x18,0x19,0x1A,0x1B, 0x1C,0x1D,0x1E,0x1F,
0x10,0x11,0x12,0x13, 0x14,0x15,0x16,0x17, 0x18,0x19,0x1A,0x1B, 0x1C,0x1D,0x1E,0x1F, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD,
0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD,
0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD,
0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF, 0x05,0x1A,0x5F,0x13, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD,
0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0x01,0xFF, 0x66,0x25,0x99,0xCD, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x71,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03,
0x00,0x71,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03, 0x00,0x03,0x00,0x03, };
}; for (count = 0; count < 4; count ++) {
for (count = 0; count < 4; count ++) { for (count2 = 0; count2 < 0x8000; count2 += 2) {
for (count2 = 0; count2 < 0x8000; count2 += 2) { Mempaks[count][count2] = 0x00;
Mempak[count][count2] = 0x00; Mempaks[count][count2 + 1] = 0x03;
Mempak[count][count2 + 1] = 0x03; }
} memcpy(&Mempaks[count][0],Initilize,sizeof(Initilize));
memcpy(&Mempak[count][0],Initilize,sizeof(Initilize)); }
}
strcpy(Directory,_Settings->LoadString(Directory_NativeSave).c_str());
strcpy(Directory,_Settings->LoadString(Directory_NativeSave).c_str()); sprintf(File,"%s%s.mpk",Directory,_Settings->LoadString(Game_GameName).c_str());
sprintf(File,"%s%s.mpk",Directory,_Settings->LoadString(Game_GameName).c_str());
hMempakFile = CreateFile(File,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,NULL,OPEN_ALWAYS,
hMempakFile = CreateFile(File,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,NULL,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (hMempakFile == INVALID_HANDLE_VALUE) {
if (hMempakFile == INVALID_HANDLE_VALUE) { switch (GetLastError()) {
switch (GetLastError()) { case ERROR_PATH_NOT_FOUND:
case ERROR_PATH_NOT_FOUND: CreateDirectory(Directory,NULL);
CreateDirectory(Directory,NULL); hMempakFile = CreateFile(File,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,
hMempakFile = CreateFile(File,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (hMempakFile == INVALID_HANDLE_VALUE) {
if (hMempakFile == INVALID_HANDLE_VALUE) { _Notify->DisplayError(GS(MSG_FAIL_OPEN_MEMPAK));
_Notify->DisplayError(GS(MSG_FAIL_OPEN_MEMPAK)); }
} return;
return; break;
break; default:
default: _Notify->DisplayError(GS(MSG_FAIL_OPEN_MEMPAK));
_Notify->DisplayError(GS(MSG_FAIL_OPEN_MEMPAK)); return;
return; }
} }
} SetFilePointer(hMempakFile,0,NULL,FILE_BEGIN);
SetFilePointer(hMempakFile,0,NULL,FILE_BEGIN); ReadFile(hMempakFile,Mempaks,sizeof(Mempaks),&dwRead,NULL);
ReadFile(hMempakFile,Mempak,sizeof(Mempak),&dwRead,NULL); WriteFile(hMempakFile,Mempaks,sizeof(Mempaks),&dwRead,NULL);
WriteFile(hMempakFile,Mempak,sizeof(Mempak),&dwRead,NULL); }
}
BYTE Mempak::CalculateCrc(BYTE * DataToCrc) {
BYTE Mempacks_CalulateCrc(BYTE * DataToCrc) { DWORD Count;
DWORD Count; DWORD XorTap;
DWORD XorTap;
int Length;
int Length; BYTE CRC = 0;
BYTE CRC = 0;
for (Count = 0; Count < 0x21; Count++) {
for (Count = 0; Count < 0x21; Count++) { for (Length = 0x80; Length >= 1; Length >>= 1) {
for (Length = 0x80; Length >= 1; Length >>= 1) { XorTap = (CRC & 0x80) ? 0x85 : 0;
XorTap = (CRC & 0x80) ? 0x85 : 0; CRC <<= 1;
CRC <<= 1; if (Count == 0x20) {
if (Count == 0x20) { CRC &= 0xFF;
CRC &= 0xFF; } else {
} else { if ((*DataToCrc & Length) != 0) {
if ((*DataToCrc & Length) != 0) { CRC |= 1;
CRC |= 1; }
} }
} CRC ^= XorTap;
CRC ^= XorTap; }
} DataToCrc++;
DataToCrc++; }
}
return CRC;
return CRC; }
}
void Mempak::ReadFrom(int Control, int Address, BYTE * Buffer) {
void ReadFromMempak(int Control, int Address, BYTE * Buffer) { if (Address == 0x8001) {
if (Address == 0x8001) { memset(Buffer, 0, 0x20);
memset(Buffer, 0, 0x20); Buffer[0x20] = CalculateCrc(Buffer);
Buffer[0x20] = Mempacks_CalulateCrc(Buffer); return;
return; }
} Address &= 0xFFE0;
Address &= 0xFFE0;
if (Address <= 0x7FE0) {
if (Address <= 0x7FE0) { if (hMempakFile == NULL) {
if (hMempakFile == NULL) { LoadMempak();
LoadMempak(); }
} memcpy(Buffer, &Mempaks[Control][Address], 0x20);
memcpy(Buffer, &Mempak[Control][Address], 0x20); } else {
} else { memset(Buffer, 0, 0x20);
memset(Buffer, 0, 0x20); /* Rumble pack area */
/* Rumble pack area */ }
}
Buffer[0x20] = CalculateCrc(Buffer);
Buffer[0x20] = Mempacks_CalulateCrc(Buffer); }
}
void Mempak::WriteTo(int Control, int Address, BYTE * Buffer) {
void WriteToMempak(int Control, int Address, BYTE * Buffer) { DWORD dwWritten;
DWORD dwWritten;
if (Address == 0x8001) { Buffer[0x20] = CalculateCrc(Buffer); return; }
if (Address == 0x8001) { Buffer[0x20] = Mempacks_CalulateCrc(Buffer); return; }
Address &= 0xFFE0;
Address &= 0xFFE0; if (Address <= 0x7FE0) {
if (Address <= 0x7FE0) { if (hMempakFile == NULL) {
if (hMempakFile == NULL) { LoadMempak();
LoadMempak(); }
} memcpy(&Mempaks[Control][Address], Buffer, 0x20);
memcpy(&Mempak[Control][Address], Buffer, 0x20);
SetFilePointer(hMempakFile,Control*0x8000,NULL,FILE_BEGIN);
SetFilePointer(hMempakFile,Control*0x8000,NULL,FILE_BEGIN); WriteFile(hMempakFile,&Mempaks[Control][0],0x8000,&dwWritten,NULL);
WriteFile(hMempakFile,&Mempak[Control][0],0x8000,&dwWritten,NULL); } else {
} else { /* Rumble pack area */
/* Rumble pack area */ }
} Buffer[0x20] = CalculateCrc(Buffer);
Buffer[0x20] = Mempacks_CalulateCrc(Buffer);
} }

View File

@ -1,5 +1,4 @@
#include "stdafx.h" #include "stdafx.h"
#include "../C Core/mempak.h"
int CPifRamSettings::m_RefCount = 0; int CPifRamSettings::m_RefCount = 0;
bool CPifRamSettings::m_bShowPifRamErrors = false; bool CPifRamSettings::m_bShowPifRamErrors = false;
@ -448,10 +447,11 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
DWORD address = ((Command[3] << 8) | Command[4]); DWORD address = ((Command[3] << 8) | Command[4]);
switch (Controllers[Control].Plugin) { switch (Controllers[Control].Plugin) {
case PLUGIN_RUMBLE_PAK: case PLUGIN_RUMBLE_PAK:
memset(&Command[5], (address >= 0x8000 && address < 0x9000) ? 0x80 : 0x00, 0x20); memset(&Command[5], (address >= 0x8000 && address < 0x9000) ? 0x80 : 0x00, 0x20);
Command[0x25] = Mempacks_CalulateCrc(&Command[5]); Command[0x25] = Mempak::CalculateCrc(&Command[5]);
break; break;
case PLUGIN_MEMPAK: ReadFromMempak(Control, address, &Command[5]); break; case PLUGIN_MEMPAK: Mempak::ReadFrom(Control, address, &Command[5]); break;
case PLUGIN_RAW: if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Control, Command); } break; case PLUGIN_RAW: if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Control, Command); } break;
default: default:
memset(&Command[5], 0, 0x20); memset(&Command[5], 0, 0x20);
@ -476,14 +476,14 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command)
if (Controllers[Control].Present == TRUE) { if (Controllers[Control].Present == TRUE) {
DWORD address = ((Command[3] << 8) | Command[4]); DWORD address = ((Command[3] << 8) | Command[4]);
switch (Controllers[Control].Plugin) { switch (Controllers[Control].Plugin) {
case PLUGIN_MEMPAK: WriteToMempak(Control, address, &Command[5]); break; case PLUGIN_MEMPAK: Mempak::WriteTo(Control, address, &Command[5]); break;
case PLUGIN_RAW: if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Control, Command); } break; case PLUGIN_RAW: if (_Plugins->Control()->ControllerCommand) { _Plugins->Control()->ControllerCommand(Control, Command); } break;
case PLUGIN_RUMBLE_PAK: case PLUGIN_RUMBLE_PAK:
if ((address & 0xFFE0) == 0xC000 && _Plugins->Control()->RumbleCommand != NULL) { if ((address & 0xFFE0) == 0xC000 && _Plugins->Control()->RumbleCommand != NULL) {
_Plugins->Control()->RumbleCommand(Control, *(BOOL *)(&Command[5])); _Plugins->Control()->RumbleCommand(Control, *(BOOL *)(&Command[5]));
} }
default: default:
Command[0x25] = Mempacks_CalulateCrc(&Command[5]); Command[0x25] = Mempak::CalculateCrc(&Command[5]);
} }
} else { } else {
Command[1] |= 0x80; Command[1] |= 0x80;

View File

@ -478,7 +478,7 @@ void CN64System::Reset (bool bInitReg, bool ClearMenory)
m_Audio.Reset(); m_Audio.Reset();
m_MMU_VM.Reset(ClearMenory); m_MMU_VM.Reset(ClearMenory);
Debug_Reset(); Debug_Reset();
CloseSaveChips(); Mempak::Close();
m_CyclesToSkip = 0; m_CyclesToSkip = 0;
m_AlistCount = 0; m_AlistCount = 0;
@ -781,27 +781,26 @@ void CN64System::ExecuteCPU ( void )
//Check me //Check me
// _Rom->m_RomFileSize = _Rom->GetRomSize(); // _Rom->m_RomFileSize = _Rom->GetRomSize();
CC_Core C_Core; m_SaveUsing = (SAVE_CHIP_TYPE)_Settings->LoadDword(Game_SaveChip);
C_Core.SetSettings();
CInterpreterCPU::BuildCPU(); CInterpreterCPU::BuildCPU();
switch ((CPU_TYPE)_Settings->LoadDword(Game_CpuType)) { switch ((CPU_TYPE)_Settings->LoadDword(Game_CpuType)) {
case CPU_Recompiler: ExecuteRecompiler(C_Core); break; case CPU_Recompiler: ExecuteRecompiler(); break;
case CPU_SyncCores: ExecuteSyncCPU(C_Core); break; case CPU_SyncCores: ExecuteSyncCPU(); break;
default: ExecuteInterpret(C_Core); break; default: ExecuteInterpret(); break;
} }
CpuStopped(); CpuStopped();
SetActiveSystem(false); SetActiveSystem(false);
} }
void CN64System::ExecuteInterpret (CC_Core & C_Core) { void CN64System::ExecuteInterpret () {
InitializeCPUCore(); InitializeCPUCore();
SetActiveSystem(); SetActiveSystem();
CInterpreterCPU::ExecuteCPU(); CInterpreterCPU::ExecuteCPU();
} }
void CN64System::ExecuteRecompiler (CC_Core & C_Core) void CN64System::ExecuteRecompiler ()
{ {
//execute opcodes while no errors //execute opcodes while no errors
InitializeCPUCore(); InitializeCPUCore();
@ -810,7 +809,7 @@ void CN64System::ExecuteRecompiler (CC_Core & C_Core)
m_Recomp->Run(); m_Recomp->Run();
} }
void CN64System::ExecuteSyncCPU (CC_Core & C_Core) void CN64System::ExecuteSyncCPU ()
{ {
_Notify->DisplayMessage(5,"Copy Plugins"); _Notify->DisplayMessage(5,"Copy Plugins");
_Plugins->CopyPlugins(_Settings->LoadString(Directory_PluginSync)); _Plugins->CopyPlugins(_Settings->LoadString(Directory_PluginSync));

View File

@ -1,4 +1,5 @@
#pragma once #ifndef _N64CLASS_H_
#define _N64CLASS_H_
typedef std::list<SystemEvent> EVENT_LIST; typedef std::list<SystemEvent> EVENT_LIST;
@ -32,6 +33,7 @@ public:
CProfiling m_Profile; CProfiling m_Profile;
CCheats m_Cheats; CCheats m_Cheats;
bool m_EndEmulation; bool m_EndEmulation;
enum SAVE_CHIP_TYPE m_SaveUsing;
enum SystemType m_SystemType;; enum SystemType m_SystemType;;
//Methods //Methods
@ -93,9 +95,9 @@ private:
void InitRegisters ( bool bPostPif, CMipsMemory & MMU ); void InitRegisters ( bool bPostPif, CMipsMemory & MMU );
//CPU Methods //CPU Methods
void ExecuteRecompiler ( CC_Core & C_Core ); void ExecuteRecompiler ( );
void ExecuteInterpret ( CC_Core & C_Core ); void ExecuteInterpret ( );
void ExecuteSyncCPU ( CC_Core & C_Core ); void ExecuteSyncCPU ();
void AddEvent ( SystemEvent Event); void AddEvent ( SystemEvent Event);
@ -154,3 +156,5 @@ private:
//list of function that have been called .. used in profiling //list of function that have been called .. used in profiling
FUNC_CALLS m_FunctionCalls; FUNC_CALLS m_FunctionCalls;
}; };
#endif

View File

@ -530,6 +530,10 @@
RelativePath="N64 System\Mips\Memory.cpp" RelativePath="N64 System\Mips\Memory.cpp"
> >
</File> </File>
<File
RelativePath=".\N64 System\Mips\Mempak.cpp"
>
</File>
<File <File
RelativePath="N64 System\Mips\OpCode Analysis Class.cpp" RelativePath="N64 System\Mips\OpCode Analysis Class.cpp"
> >
@ -570,10 +574,6 @@
RelativePath="N64 System\C Core\BreakPoints.cpp" RelativePath="N64 System\C Core\BreakPoints.cpp"
> >
</File> </File>
<File
RelativePath="N64 System\C Core\C Core Interface.cpp"
>
</File>
<File <File
RelativePath="N64 System\C Core\C main.cpp" RelativePath="N64 System\C Core\C main.cpp"
> >
@ -582,10 +582,6 @@
RelativePath="N64 System\C Core\Logging.cpp" RelativePath="N64 System\C Core\Logging.cpp"
> >
</File> </File>
<File
RelativePath="N64 System\C Core\Mempak.cpp"
>
</File>
<File <File
RelativePath="N64 System\C Core\r4300i Commands.cpp" RelativePath="N64 System\C Core\r4300i Commands.cpp"
> >
@ -1255,6 +1251,10 @@
RelativePath="N64 System\Mips\Memory Virtual Mem.h" RelativePath="N64 System\Mips\Memory Virtual Mem.h"
> >
</File> </File>
<File
RelativePath=".\N64 System\Mips\Mempak.H"
>
</File>
<File <File
RelativePath="N64 System\Mips\OpCode Analysis Class.h" RelativePath="N64 System\Mips\OpCode Analysis Class.h"
> >
@ -1303,18 +1303,10 @@
RelativePath="N64 System\C Core\BreakPoints.h" RelativePath="N64 System\C Core\BreakPoints.h"
> >
</File> </File>
<File
RelativePath="N64 System\C Core\C Core Interface.h"
>
</File>
<File <File
RelativePath="N64 System\C Core\Logging.h" RelativePath="N64 System\C Core\Logging.h"
> >
</File> </File>
<File
RelativePath="N64 System\C Core\MEMPAK.H"
>
</File>
<File <File
RelativePath="N64 System\C Core\r4300i Commands.h" RelativePath="N64 System\C Core\r4300i Commands.h"
> >

View File

@ -13,7 +13,5 @@
#include "Validate Binary.h" #include "Validate Binary.h"
#include <Aclapi.h> #include <Aclapi.h>
#include "N64 System/C Core/C Core Interface.h"
#include "3rd Party/Zip.h" #include "3rd Party/Zip.h"
#include "3rd Party/7zip.h" #include "3rd Party/7zip.h"