Skip to content

Commit

Permalink
0.3a-c4d0269
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtBagXon committed Oct 10, 2024
1 parent 2add76c commit 25810de
Show file tree
Hide file tree
Showing 97 changed files with 869 additions and 837 deletions.
2 changes: 1 addition & 1 deletion Src/BlockFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CBlockFile
* name Block name. Must be unique and not NULL.
* comment Comment string to embed in the block header.
*/
void NewBlock(const std::string &title, const std::string &comment);
void NewBlock(const std::string &name, const std::string &comment);

/*
* Create(file, headerName, comment):
Expand Down
19 changes: 10 additions & 9 deletions Src/CPU/PowerPC/PPCDisasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ static void SPR(char *dest, unsigned spr_field)
case 982: strcat(dest, "rpa"); break;
case 1010: strcat(dest, "iabr"); break;

default: sprintf(dest, "%s%d", dest, spr);
default: strcat(dest, std::to_string(spr).c_str());
break;
}
}
Expand Down Expand Up @@ -655,7 +655,7 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch
sprintf(oprs, "r%d,r%d", G_RA(op), G_RT(op));
}
else
return 0;
return false;
}
else if ((op & ~(M_RT|M_RA|M_RB|M_RC)) == (D_OP(31)|D_XO(124)))
{
Expand All @@ -666,7 +666,7 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch
sprintf(oprs, "r%d,r%d", G_RA(op), G_RT(op));
}
else
return 0;
return false;
}
else if ((op & ~(M_RT|M_RA|M_SIMM)) == D_OP(14))
{
Expand All @@ -676,7 +676,7 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch
sprintf(oprs, "r%d,0x%08X", G_RT(op), value);
}
else
return 0;
return false;
}
else if ((op & ~(M_RT|M_RA|M_SIMM)) == D_OP(15))
{
Expand Down Expand Up @@ -757,7 +757,7 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch
strcat(mnem, "bt");
break;
default:
return 0;
return false;
}

if (op & M_LK) strcat(mnem, "l");
Expand All @@ -780,8 +780,8 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch
sprintf(oprs, "r%d,r%d,r%d", G_RT(op), G_RB(op), G_RA(op));
}
else
return 0; // no match
return 1;
return false; // no match
return true;
}

/*
Expand Down Expand Up @@ -821,7 +821,7 @@ Result DisassemblePowerPC(uint32_t op, uint32_t vpc, char *mnem, char *oprs,
* Decode signed 16-bit fields (SIMM and d) to spare us the work later
*/

DecodeSigned16(signed16, op, 0);
DecodeSigned16(signed16, op, false);

/*
* Try simplified forms first, then real instructions
Expand Down Expand Up @@ -1053,7 +1053,8 @@ Result DisassemblePowerPC(uint32_t op, uint32_t vpc, char *mnem, char *oprs,

case F_MTSPR:
SPR(oprs, G_SPR(op));
sprintf(oprs, "%s,r%d", oprs, G_RT(op));
strcat(oprs, ",r");
strcat(oprs, std::to_string(G_RT(op)).c_str());
break;

case F_MTSR:
Expand Down
2 changes: 2 additions & 0 deletions Src/CPU/PowerPC/PPCDisasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#ifndef INCLUDED_PPCDISASM_H
#define INCLUDED_PPCDISASM_H

#include "Types.h"

/*
* DisassemblePowerPC(op, vpc, mnem, oprs, simplify):
*
Expand Down
15 changes: 7 additions & 8 deletions Src/CPU/PowerPC/ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ static UINT32 ppc_field_xlat[256];



#define BITMASK_0(n) (UINT32)(((UINT64)1 << n) - 1)
#define CRBIT(x) ((ppc.cr[x / 4] & (1 << (3 - (x % 4)))) ? 1 : 0)
#define BITMASK_0(n) (UINT32)(((UINT64)1 << (n)) - 1)
#define CRBIT(x) ((ppc.cr[(x) / 4] & (1 << (3 - ((x) % 4)))) ? 1 : 0)
#define _BIT(n) (1 << (n))
#define GET_ROTATE_MASK(mb,me) (ppc_rotate_mask[mb][me])
#define ADD_CA(r,a,b) ((UINT32)r < (UINT32)a)
#define SUB_CA(r,a,b) (!((UINT32)a < (UINT32)b))
#define ADD_CA(r,a,b) ((UINT32)(r) < (UINT32)(a))
#define SUB_CA(r,a,b) (!((UINT32)(a) < (UINT32)(b)))
#define ADD_OV(r,a,b) ((~((a) ^ (b)) & ((a) ^ (r))) & 0x80000000)
#define SUB_OV(r,a,b) (( ((a) ^ (b)) & ((a) ^ (r))) & 0x80000000)

Expand Down Expand Up @@ -154,8 +154,8 @@ static UINT32 ppc_field_xlat[256];
#define TSR_ENW 0x80000000
#define TSR_WIS 0x40000000

#define BYTE_REVERSE16(x) (((x >> 8) | (x << 8)) & 0xFFFF)
#define BYTE_REVERSE32(x) ((x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24))
#define BYTE_REVERSE16(x) ((((x) >> 8) | ((x) << 8)) & 0xFFFF)
#define BYTE_REVERSE32(x) (((x) >> 24) | (((x) << 8) & 0x00FF0000) | (((x) >> 8) & 0x0000FF00) | ((x) << 24))

typedef union {
UINT64 id;
Expand Down Expand Up @@ -714,10 +714,9 @@ void ppc_base_init(void)
/* Calculate rotate mask table */
for( i=0; i < 32; i++ ) {
for( j=0; j < 32; j++ ) {
UINT32 mask;
int mb = i;
int me = j;
mask = ((UINT32)0xFFFFFFFF >> mb) ^ ((me >= 31) ? 0 : ((UINT32)0xFFFFFFFF >> (me + 1)));
UINT32 mask = ((UINT32)0xFFFFFFFF >> mb) ^ ((me >= 31) ? 0 : ((UINT32)0xFFFFFFFF >> (me + 1)));
if( mb > me )
mask = ~mask;

Expand Down
2 changes: 1 addition & 1 deletion Src/CPU/Z80/Z80.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3803,7 +3803,7 @@ void CZ80::SetINT(bool state)
intLine = state;
}

UINT16 CZ80::GetPC(void)
UINT16 CZ80::GetPC(void) const
{
return pc;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/CPU/Z80/Z80.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class CZ80
* Returns:
* Current value of PC register.
*/
UINT16 GetPC(void);
UINT16 GetPC(void) const;

#ifdef SUPERMODEL_DEBUGGER
/*
Expand Down
2 changes: 1 addition & 1 deletion Src/Debugger/ConsoleDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ namespace Debugger
else if (CheckToken(token, "h", "help")) // help
{
// TODO - improve the following
const char *fmt = " %-6s %-25s %s\n";
static const char *fmt = " %-6s %-25s %s\n";

Print("Debugger Commands:\n");

Expand Down
8 changes: 4 additions & 4 deletions Src/Debugger/SupermodelDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace Debugger
cpu->AddMappedIO(addr + 0x17, 1, "EFSDL,EFPAN", s_mSlotStr[slot]);
}
// SCSP Master control registers
const char *masterCtl = "SCSP Master Control Registers";
static const char *masterCtl = "SCSP Master Control Registers";
cpu->AddMappedIO(0x100400, 1, "MEM4MB,DAC18B", masterCtl);
cpu->AddMappedIO(0x100401, 1, "VER,MVOL", masterCtl);
cpu->AddMappedIO(0x100402, 2, "RBL,RBP", masterCtl);
Expand Down Expand Up @@ -233,7 +233,7 @@ namespace Debugger
}

// SCSP Master control registers
const char *slaveCtl = "SCSP Slave Control Registers";
static const char *slaveCtl = "SCSP Slave Control Registers";
cpu->AddMappedIO(0x300400, 1, "MEM4MB,DAC18B", slaveCtl);
cpu->AddMappedIO(0x300401, 1, "VER,MVOL", slaveCtl);
cpu->AddMappedIO(0x300402, 2, "RBL,RBP", slaveCtl);
Expand Down Expand Up @@ -329,7 +329,7 @@ namespace Debugger
cpu->AddRegion(0x080000, 0x0bffff, false, false, "Net 2"); // commram ???
cpu->AddRegion(0x0c0000, 0x0c01ff, false, false, "Net 3"); // ??? size unknown

const char *NetReg = "NetBoard Control Registers";
static const char *NetReg = "NetBoard Control Registers";
cpu->AddMappedIO(0x010110, 4, "Reg 1", NetReg);
cpu->AddMappedIO(0x010114, 4, "Reg 2", NetReg);
cpu->AddMappedIO(0x010180, 4, "Reg 3", NetReg);
Expand Down Expand Up @@ -576,7 +576,7 @@ namespace Debugger
{
CConsoleDebugger::ProcessToken(token, cmd);

const char *fmt = " %-6s %-25s %s\n";
static const char *fmt = " %-6s %-25s %s\n";
Print(" Emulator:\n");
Print(fmt, "les", "loademustate", "<filename>");
Print(fmt, "ses", "saveemustate", "<filename>");
Expand Down
2 changes: 1 addition & 1 deletion Src/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct Game
uint32_t real3d_pci_id = 0; // overrides default Real3D PCI ID for stepping (0 for default)
float real3d_status_bit_set_percent_of_frame = 0; // overrides default status bit timing (0 for default)
uint32_t encryption_key = 0;
bool netboard_present;
bool netboard_present = false;

enum Inputs
{
Expand Down
14 changes: 7 additions & 7 deletions Src/GameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ bool GameLoader::LoadGamesFromXML(const Util::Config::Node &xml)

// Look up region structure or create new one if needed
std::string region_name = region_node["name"].Value<std::string>();
auto it = regions_by_name.find(region_name);
Region::ptr_t region = (it != regions_by_name.end()) ? it->second : Region::Create(*this, region_node);
auto it2 = regions_by_name.find(region_name);
Region::ptr_t region = (it2 != regions_by_name.end()) ? it2->second : Region::Create(*this, region_node);
if (!region)
continue;

Expand Down Expand Up @@ -432,7 +432,7 @@ bool GameLoader::LoadGamesFromXML(const Util::Config::Node &xml)

static bool IsChildSet(const Game &game)
{
return game.parent.length() > 0;
return !game.parent.empty();
}

bool GameLoader::MergeChildrenWithParents()
Expand Down Expand Up @@ -587,7 +587,7 @@ void GameLoader::IdentifyGamesInZipArchive(
Region::ptr_t region = v2.second;
if (!region->required)
continue;
for (auto file: region->files)
for (const auto &file: region->files)
{
// Add each file to the set of required files per game
files_required_by_game[game_name].insert(file);
Expand Down Expand Up @@ -772,7 +772,7 @@ bool GameLoader::ComputeRegionSize(uint32_t *region_size, const GameLoader::Regi
// use maximum end_addr = offset + stride * (num_chunks - 1) + chunk_size.
std::vector<uint32_t> end_addr;
bool error = false;
for (auto file: region->files)
for (const auto &file: region->files)
{
const ZippedFile *zipped_file = LookupFile(file, zip);
if (zipped_file)
Expand All @@ -782,7 +782,7 @@ bool GameLoader::ComputeRegionSize(uint32_t *region_size, const GameLoader::Regi
ErrorLog("File '%s' in '%s' is not sized in %d-byte chunks.", zipped_file->filename.c_str(), zipped_file->zipfilename.c_str(), region->chunk_size);
error = true;
}
uint32_t num_chunks = (uint32_t)(zipped_file->uncompressed_size / region->chunk_size);
uint32_t num_chunks = (uint32_t)(zipped_file->uncompressed_size / region->chunk_size);
end_addr.push_back(file->offset + region->stride * (num_chunks - 1) + region->chunk_size);
}
else
Expand All @@ -796,7 +796,7 @@ bool GameLoader::ComputeRegionSize(uint32_t *region_size, const GameLoader::Regi
static bool ApplyLayout(ROM *rom, const std::string &byte_layout, size_t stride, const std::string &region_name)
{
// Empty layout means do nothing
if (byte_layout.size() == 0)
if (byte_layout.empty())
return false;

// Validate that the layout string includes the same number of bytes as the region stride. The
Expand Down
2 changes: 0 additions & 2 deletions Src/GameLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class GameLoader
void ChooseGameInZipArchive(std::string *chosen_game, bool *missing_parent_roms, const ZipArchive &zip, const std::string &zipfilename) const;
bool LoadRegion(ROM *buffer, const GameLoader::Region::ptr_t &region, const ZipArchive &zip) const;
bool LoadROMs(ROMSet *rom_set, const std::string &game_name, const ZipArchive &zip) const;
std::string ChooseGame(const std::set<std::string> &games_found, const std::string &zipfilename) const;
static bool CompareFilesByName(const File::ptr_t &a,const File::ptr_t &b);

public:
GameLoader(const std::string &xml_file);
Expand Down
23 changes: 11 additions & 12 deletions Src/Graphics/Legacy3D/Legacy3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ const UINT32 *CLegacy3D::TranslateModelAddress(UINT32 modelAddr)
******************************************************************************/

// Macro to generate column-major (OpenGL) index from y,x subscripts
#define CMINDEX(y,x) (x*4+y)
#define CMINDEX(y,x) ((x)*4+(y))

/*
* MultMatrix():
Expand Down Expand Up @@ -527,7 +527,7 @@ void CLegacy3D::InitMatrixStack(UINT32 matrixBaseAddr)
}

// Set matrix base address and apply matrix #0 (coordinate system matrix)
matrixBasePtr = (float *) TranslateCullingAddress(matrixBaseAddr);
matrixBasePtr = (const float *) TranslateCullingAddress(matrixBaseAddr);
MultMatrix(0);
}

Expand All @@ -547,7 +547,7 @@ static bool IsDynamicModel(const UINT32 *data)
{
if (data == NULL)
return false;
unsigned sharedVerts[16] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 };
static constexpr unsigned sharedVerts[16] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 };
// VROM models are only dynamic if they reference polygon RAM via color palette indices
bool done = false;
do
Expand All @@ -561,7 +561,7 @@ static bool IsDynamicModel(const UINT32 *data)
unsigned numVerts = (data[0]&0x40 ? 4 : 3);
// Deduct number of reused verts
numVerts -= sharedVerts[data[0]&0xf];
done = (data[1] & 4) > 0;
done = (data[1] & 4) > 0;
// Skip header and vertices to next polygon
data += 7 + numVerts * 4;
}
Expand Down Expand Up @@ -1353,22 +1353,21 @@ CLegacy3D::~CLegacy3D(void)
if (glBindBuffer != NULL) // we may have failed earlier due to lack of OpenGL 2.0 functions
glBindBuffer(GL_ARRAY_BUFFER, 0); // disable VBOs by binding to 0
glDeleteTextures(numTexMaps, texMapIDs);

DestroyModelCache(&VROMCache);
DestroyModelCache(&PolyCache);

cullingRAMLo = NULL;
cullingRAMHi = NULL;
polyRAM = NULL;
vrom = NULL;
textureRAM = NULL;

if (texSheets != NULL)
delete [] texSheets;

if (textureBuffer != NULL)
delete [] textureBuffer;
textureBuffer = NULL;
delete [] texSheets;
texSheets = nullptr;

delete [] textureBuffer;
textureBuffer = nullptr;

DebugLog("Destroyed Legacy3D\n");
}
Expand Down
Loading

0 comments on commit 25810de

Please sign in to comment.