Permalink
Browse files

Some code cleanup

  • Loading branch information...
1 parent 2ea8052 commit 1006a5b7c25a6e9ee7fe18f9ee6e8fdb58606a9a @jweinberg committed Apr 5, 2012
@@ -26,7 +26,7 @@
*/
#import <Cocoa/Cocoa.h>
-#import <OpenEmuSystem/OpenEmuSystem.h>
+#import <OpenEmuSystem/OESystemController.h>
@interface OEVBSystemController : OESystemController
{
@@ -860,7 +860,7 @@
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_VERSION = "";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -881,7 +881,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_VERSION = "";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -952,6 +952,11 @@
INFOPLIST_FILE = "VirtualUtopia/VirtualUtopia-Info.plist";
INSTALL_PATH = "$(HOME)/Library/Bundles";
PRODUCT_NAME = "$(TARGET_NAME)";
+ WARNING_CFLAGS = (
+ "-Wextra",
+ "-Wall",
+ "-Wno-unused-parameter",
+ );
WRAPPER_EXTENSION = oecoreplugin;
};
name = Debug;
@@ -84,7 +84,16 @@ - (OEIntSize)bufferSize
- (const void *)videoBuffer
{
//memset(bmpData, 0xFF00FFFF, 384 * 256);
- memcpy(bmpData, vb->vip->bmpData, sizeof(uint32_t) * 384 * 256);
+ for (int y = 0; y < 256; ++y)
+ {
+ for (int x = 0; x < 384; ++x)
+ {
+ int left = *(vb->vip->leftBmpData + (y * 384) + x);
+ int right = *(vb->vip->rightBmpData + (y * 384) + x);
+ bmpData[x + (y * 384)] = (0xFF << 24) | (left << 16) | right;
+ }
+ }
+
return bmpData;
}
@@ -23,7 +23,7 @@ struct Fixed16x16
{
int32_t integer;
- const int16_t operator+(const Fixed16x16& other)
+ int16_t operator+(const Fixed16x16& other)
{
int64_t combined = ((int64_t)integer + (int64_t)other.integer + 0x7FFF);
@@ -14,7 +14,7 @@ namespace CPU
{
class Bitstring {
public:
- Bitstring(MMU& _mmu, uint32_t _address, uint8_t _offset, uint32_t _length) : mmu(_mmu), currentLocation(_address), offset(_offset), stringLength(_length)
+ Bitstring(MMU& _mmu, uint32_t _address, uint8_t _offset, uint32_t _length) : mmu(_mmu), stringLength(_length), offset(_offset), currentLocation(_address)
{
}
@@ -9,33 +9,38 @@
#include <iostream>
#include "channel.h"
-static int envelopeStepTimes[8] = {154, 307, 461, 614, 768, 922, 1075, 1229};
+static uint32_t envelopeStepTimes[8] = {154, 307, 461, 614, 768, 922, 1075, 1229};
namespace VSU
-{
-
-double Channel::frequency()
-{
- float hz = 5000000.0 / ((2048 - ((SxFRQH.upper3Bits << 8) | SxFRQL)) * 32);
- return hz;
-}
+{
+ Channel::Channel() : currentTimestep(0),
+ envelopeTimer(0),
+ envelopeValue(0)
+ {
+ }
-void Channel::update(long nanoseconds)
-{
- //Update envelope
- if (SxEV1.enabled)
+ double Channel::frequency()
+ {
+ float hz = 5000000.0 / ((2048 - ((SxFRQH.upper3Bits << 8) | SxFRQL)) * 32);
+ return hz;
+ }
+
+ void Channel::update(long nanoseconds)
{
- envelopeTimer += nanoseconds;
- while (envelopeTimer >= envelopeStepTimes[SxEV0.step])
+ //Update envelope
+ if (SxEV1.enabled)
{
- envelopeTimer -= nanoseconds;
- envelopeValue += (SxEV0.u_d ? 1 : -1);
- envelopeValue = clamp<int8_t>(0, 0xF, envelopeValue);
+ envelopeTimer += nanoseconds;
+ while (envelopeTimer >= envelopeStepTimes[SxEV0.step])
+ {
+ envelopeTimer -= nanoseconds;
+ envelopeValue += (SxEV0.u_d ? 1 : -1);
+ envelopeValue = clamp<int8_t>(0, 0xF, envelopeValue);
+ }
}
- }
-
-
+
+
-}
+ }
};
@@ -21,32 +21,32 @@ namespace VSU
class Channel
{
-
public:
+ Channel();
double frequency();
void update(long nanoseconds);
- REGISTER_BITFIELD(SxINT,
+ REGISTER_BITFIELD(uint8_t, SxINT,
uint8_t counter : 5;
uint8_t data : 1;
uint8_t reserved : 1;
uint8_t enabled : 1;
);
- REGISTER_BITFIELD(SxLRV,
+ REGISTER_BITFIELD(uint8_t, SxLRV,
uint8_t right : 4;
uint8_t left : 4;
);
uint8_t SxFRQL;
- REGISTER_BITFIELD(SxFRQH,
+ REGISTER_BITFIELD(uint8_t, SxFRQH,
uint8_t upper3Bits : 3;
uint8_t reserved : 5;
);
- REGISTER_BITFIELD(SxEV0,
+ REGISTER_BITFIELD(uint8_t, SxEV0,
uint8_t step : 3;
uint8_t u_d : 1;
uint8_t initialValue : 4;
);
- REGISTER_BITFIELD(SxEV1,
+ REGISTER_BITFIELD(uint8_t, SxEV1,
uint8_t enabled : 1;
uint8_t r_s : 1;
uint8_t reserved_0 : 2;
@@ -55,7 +55,7 @@ class Channel
uint8_t enable_sweep : 1;
uint8_t reserved : 1;
);
- REGISTER_BITFIELD(SxRAM,
+ REGISTER_BITFIELD(uint8_t, SxRAM,
uint8_t waveformAddress : 4;
uint8_t reserved : 4;
);
@@ -154,22 +154,22 @@ namespace CPU
};
};
public:
- const uint32_t disp26() const
+ uint32_t disp26() const
{
return ((instruction & 0x3FF) << 16) | (instruction >> 16);
}
- const uint16_t disp9() const
+ uint16_t disp9() const
{
return instruction & 0x1FF;
}
- const uint8_t subopcode() const
+ uint8_t subopcode() const
{
return instruction >> 26;
}
- const OpcodeMnumonic opcode() const
+ OpcodeMnumonic opcode() const
{
return (OpcodeMnumonic)((instruction & 0xE000) == 0x8000 ? (instruction & 0xFFFF) >> 9 : (instruction & 0xFFFF) >> 10);
}
@@ -2,7 +2,7 @@
#include <assert.h>
#include "mmu.h"
-MMU::MMU(const ROM &_rom, VIP::VIP &_vip, NVC::NVC &_nvc, VSU::VSU &_vsu) : rom(_rom), vip(_vip), nvc(_nvc), vsu(_vsu)
+MMU::MMU(const ROM &_rom, VIP::VIP &_vip, NVC::NVC &_nvc, VSU::VSU &_vsu) : rom(_rom), nvc(_nvc), vip(_vip), vsu(_vsu)
{
gamepackRam = (char*)calloc(0x20000, sizeof(char));
programRam = (char*)calloc(0x10000, sizeof(char));
@@ -42,6 +42,8 @@ class MMU
case 0x07000000 ... 0x07FFFFFF: //Cartridge ROM
return rom.read<T>(virtualAddress);
}
+// printf("Out of bounds access %X\n", virtualAddress);
+// return *(new T);
assert(false);
}
@@ -122,7 +122,7 @@ void NVC::NVC::Step(uint32_t cycles)
else
{
SCR.STAT = 0;
- if (SCR.INT && setKey)
+ if (!SCR.INT && setKey)
{
cpu->processInterrupt(CPU::INTKEY);
}
@@ -75,9 +75,9 @@ namespace NVC
case 0x200000C:
return *((T*)&CDRR);
case 0x2000010:
- return *((T*)(((uint8_t*)&SDR_HW)));
+ return *((T*)(((uint8_t*)&SDR_LATCHED)));
case 0x2000014:
- return *((T*)(((uint8_t*)&SDR_HW) + 1));
+ return *((T*)(((uint8_t*)&SDR_LATCHED) + 1));
case 0x2000018:
return *((T*)&TLR);
case 0x200001C:
@@ -169,7 +169,7 @@ namespace NVC
}
}
- REGISTER_BITFIELD(SCR,
+ REGISTER_BITFIELD(uint8_t, SCR,
uint8_t DIS:1;
uint8_t STAT:1;
uint8_t HWSI:1;
@@ -180,13 +180,13 @@ namespace NVC
uint8_t INT:1;
);
- REGISTER_BITFIELD(WCR,
+ REGISTER_BITFIELD(uint8_t, WCR,
uint8_t ROM1W:1;
uint8_t EXP1W:1;
uint8_t padding:6;
);
- REGISTER_BITFIELD(TCR,
+ REGISTER_BITFIELD(uint8_t, TCR,
uint8_t T_ENB:1;
uint8_t Z_STAT:1;
uint8_t Z_STAT_CLR:1;
@@ -214,8 +214,8 @@ namespace NVC
uint16_t internalTimerCount;
};
- REGISTER_BITFIELD(SDR,
- REGISTER_BITFIELD(SDLR,
+ REGISTER_BITFIELD(uint16_t, SDR,
+ REGISTER_BITFIELD(uint8_t, SDLR,
uint8_t PWR:1;
uint8_t SGN:1;
uint8_t A:1;
@@ -225,7 +225,7 @@ namespace NVC
uint8_t RU:1;
uint8_t RR:1;
);
- REGISTER_BITFIELD(SDHR,
+ REGISTER_BITFIELD(uint8_t, SDHR,
uint8_t LR:1;
uint8_t LL:1;
uint8_t LD:1;
@@ -9,12 +9,12 @@
#ifndef virtualutopia_registers_h
#define virtualutopia_registers_h
-#define REGISTER_BITFIELD(NAME, ...) \
+#define REGISTER_BITFIELD(T, NAME, ...) \
struct _##NAME \
{\
__VA_ARGS__\
- operator uint32_t&() { return *(uint32_t*)this; }\
- uint32_t &operator =(const uint32_t& val) { *(uint32_t*)this = val; return *(uint32_t*)this; }\
+ operator T&() { return *(T*)this; }\
+ T &operator =(const T& val) { *(T*)this = val; return *(T*)this; }\
} NAME
Oops, something went wrong. Retry.

0 comments on commit 1006a5b

Please sign in to comment.