Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
*.aps
*.db
*.tlog
*.pdb
*.asm
*.pdb
*.idb
*.obj
*.sbr
*.tlog
*.ipch
*.log
*.db
*.opendb
*.bsc
*.exe
*.ilk
handy-win32src-0.95-patched/.vs/handy/v16/.suo
handy-win32src-0.95-patched/vs/*
handy-win32src-0.95-patched/vs/Debug/*
handy-win32src-0.95-patched/vs/Debug Dbg/*
handy-win32src-0.95-patched/vs/Release/*
handy-win32src-0.95-patched/vs/Release Dbg/*

Binary file not shown.
Empty file.
Binary file added handy-win32src-0.95-patched/.vs/handy/v17/.suo
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion handy-win32src-0.95-patched/core/c65c02.h
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ class C65C02
inline void xILLEGAL(void)
{
char addr[1024];
sprintf(addr,"C65C02::Update() - Illegal opcode (%02x) at PC=$%04x.",mOpcode,mPC);
sprintf_s(addr, 1024, "C65C02::Update() - Illegal opcode (%02x) at PC=$%04x.", mOpcode,mPC);
gError->Warning(addr);
}

Expand Down
22 changes: 9 additions & 13 deletions handy-win32src-0.95-patched/core/cart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize)
if(header.magic[0]!='L' || header.magic[1]!='Y' || header.magic[2]!='N' || header.magic[3]!='X' || header.version!=1) {
memset(&header,0,sizeof(LYNX_HEADER));
fprintf(stderr, "Invalid cart (no header?).\nGuessing a ROM layout...\n");
strncpy((char*)&header.cartname,"NO HEADER",32);
strncpy((char*)&header.manufname,"HANDY",16);
header.page_size_bank0=gamesize>>8;// Hard workaround...
strncpy_s((char*)&header.cartname, 32, "NO HEADER", 32);
strncpy_s((char*)&header.manufname, 16, "HANDY", 16);
header.page_size_bank0 = static_cast<UWORD>(gamesize >> 8); // Hard workaround...
/*
CLynxException lynxerr;

Expand All @@ -101,12 +101,10 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize)
}

// Setup name & manufacturer

strncpy(mName,(char*)&header.cartname,32);
strncpy(mManufacturer,(char*)&header.manufname,16);
strncpy_s(mName, 33, (char*)&header.cartname, 32);
strncpy_s(mManufacturer, 17, (char*)&header.manufname, 16);

// Setup rotation

mRotation=header.rotation;
if(mRotation!=CART_NO_ROTATE && mRotation!=CART_ROTATE_LEFT && mRotation!=CART_ROTATE_RIGHT) mRotation=CART_NO_ROTATE;
mAudinFlag=(header.aud_bits&0x01);
Expand All @@ -116,12 +114,10 @@ CCart::CCart(UBYTE *gamedata,ULONG gamesize)
header.page_size_bank1=0x000;

// Setup name & manufacturer

strcpy(mName,"<No cart loaded>");
strcpy(mManufacturer,"<No cart loaded>");
strcpy_s(mName, 33, "<No cart loaded>");
strcpy_s(mManufacturer, 17, "<No cart loaded>");

// Setup rotation

mAudinFlag=false;
mRotation=CART_NO_ROTATE;
}
Expand Down Expand Up @@ -380,8 +376,8 @@ bool CCart::ContextLoad(LSS_FILE *fp)
bool CCart::ContextLoadLegacy(LSS_FILE *fp)
{
TRACE_CART0("ContextLoadLegacy()");
strcpy(mName,"<** IMAGE **>");
strcpy(mManufacturer,"<** RESTORED **>");
strcpy_s(mName, 33, "<** IMAGE **>");
strcpy_s(mManufacturer, 17, "<** RESTORED **>");
char teststr[100]="XXXXXXXXXXXXXXXXXX";
if(!lss_read(teststr,sizeof(char),18,fp)) return 0;
if(strcmp(teststr,"CCart::ContextSave")!=0) return 0;
Expand Down
26 changes: 16 additions & 10 deletions handy-win32src-0.95-patched/core/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ CEEPROM::~CEEPROM()

void CEEPROM::Load(void)
{
if(!Available()) return;
FILE *fe;
if((fe=fopen(filename,"rb"))!=NULL){
if (!Available())
return;

FILE* fe;
errno_t err;
if ((err = fopen_s(&fe, filename, "rb")) == 0) {
printf("EEPROM LOAD %s\n",filename);
fread(romdata,1,1024,fe);
fclose(fe);
Expand All @@ -51,9 +54,12 @@ void CEEPROM::Load(void)

void CEEPROM::Save(void)
{
if(!Available()) return;
FILE *fe;
if((fe=fopen(filename,"wb+"))!=NULL){
if (!Available())
return;

FILE* fe;
errno_t err;
if ((err = fopen_s(&fe, filename, "wb+")) == 0) {
printf("EEPROM SAVE %s\n",filename);
fwrite(romdata,1,Size(),fe);
fclose(fe);
Expand Down Expand Up @@ -154,18 +160,18 @@ void CEEPROM::UpdateEeprom(UWORD cnt)
{
// Update if either counter strobed or AUDIN changed
bool CLKp, CLKn;
CLKp=counter&0x02;
CLKp = (counter & 0x02) != 0;
counter=cnt;
CLKn=counter&0x02;
CLKn = (counter & 0x02) != 0;

if( CLKp!=CLKn && CLKn) { // Rising edge
bool CS, DI;
mAUDIN_ext=(readdata&(DONE_MASK>>1)) ? 1 : 0 ;
readdata<<=1;
CS=cnt&0x80;
CS = (cnt & 0x80) != 0;
DI=false;
if(iodir&0x10) {
DI=iodat&0x10;
DI = (iodat & 0x10) != 0;
}
if(!CS) state=EE_NONE;
switch(state) {
Expand Down
6 changes: 3 additions & 3 deletions handy-win32src-0.95-patched/core/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ class CEEPROM : public CLynxBase
};
void SetEEPROMType(UBYTE b);
int Size(void);
int InitFrom(char *data,int count){ memcpy(romdata,data,min(count,Size()));};
int InitFrom(char *data,int count){ memcpy(romdata,data,__min(count,Size()));};

void Poke(ULONG addr,UBYTE data) { };
UBYTE Peek(ULONG addr)
{
return(0);
};

void SetFilename(char* f){strcpy(filename,f);};
char* GetFilename(void){ return filename;};
void SetFilename(char* f) { strcpy_s(filename, 1024, f); };
char* GetFilename(void) { return filename; };

void Load(void);
void Save(void);
Expand Down
12 changes: 6 additions & 6 deletions handy-win32src-0.95-patched/core/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ class CLynxException
{
int MsgCount,DescCount;

MsgCount = err.Message().pcount() + 1;
DescCount = err.Description().pcount() + 1;
MsgCount = static_cast<int>(err.Message().pcount()) + 1;
DescCount = static_cast<int>(err.Description().pcount()) + 1;
if(MsgCount>MAX_ERROR_MSG) MsgCount=MAX_ERROR_MSG;
if(DescCount>MAX_ERROR_DESC) DescCount=MAX_ERROR_DESC;

strncpy(mMsg,err.Message().str(),MsgCount);
mMsg[MsgCount-1]='\0';
strncpy(mDesc,err.Description().str(),DescCount);
mDesc[DescCount-1]='\0';
strncpy_s(mMsg, MAX_ERROR_MSG, err.Message().str(), MsgCount);
mMsg[MsgCount-1] = '\0';
strncpy_s(mDesc, MAX_ERROR_DESC, err.Description().str(), DescCount);
mDesc[DescCount-1] = '\0';
}

// Destructor
Expand Down
6 changes: 3 additions & 3 deletions handy-win32src-0.95-patched/core/lynxbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class CLynxBase
};

virtual void Poke(ULONG addr,UBYTE data)=0;
virtual UBYTE Peek(ULONG addr)=0;
virtual UBYTE Peek(ULONG addr)=0;
virtual void PokeW(ULONG addr,UWORD data) {}; // ONLY mSystem overloads these, they are never use by the clients
virtual UWORD PeekW(ULONG addr)
virtual UWORD PeekW(ULONG addr)
{
return 0;
};
virtual void BankSelect(EMMODE newbank) {};
virtual ULONG ObjectSize(void)
virtual ULONG ObjectSize(void)
{
return 1;
};
Expand Down
2 changes: 1 addition & 1 deletion handy-win32src-0.95-patched/core/lynxdec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int decrypt_frame(unsigned char * result,
const unsigned char * public_mod,
const int length)
{
int i, j;
int i;
int blocks;
int accumulator;
unsigned char* rptr = result;
Expand Down
2 changes: 2 additions & 0 deletions handy-win32src-0.95-patched/core/memfault.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#ifndef BADACCESS_H
#define BADACCESS_H

#include "lynxbase.h"

class CMemFaultObj : public CLynxBase
{
// Function members
Expand Down
10 changes: 5 additions & 5 deletions handy-win32src-0.95-patched/core/mikie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void CMikie::BlowOut(void)
char addr[100];
C6502_REGS regs;
mSystem.GetRegs(regs);
sprintf(addr,"Runtime Error - System Halted\nCMikie::Poke() - Read/Write to counter clocks at PC=$%04x.",regs.PC);
sprintf_s(addr, 100, "Runtime Error - System Halted\nCMikie::Poke() - Read/Write to counter clocks at PC=$%04x.", regs.PC);
gError->Warning(addr);
gSystemHalt=TRUE;
}
Expand Down Expand Up @@ -1874,13 +1874,13 @@ void CMikie::Poke(ULONG addr,UBYTE data)
char addr[256];
C6502_REGS regs;
mSystem.GetRegs(regs);
sprintf(addr,"Runtime Alert - System Halted\nCMikie::Poke(SYSCTL1) - Lynx power down occured at PC=$%04x.\nResetting system.",regs.PC);
sprintf_s(addr, 256, "Runtime Alert - System Halted\nCMikie::Poke(SYSCTL1) - Lynx power down occured at PC=$%04x.\nResetting system.", regs.PC);
gError->Warning(addr);
mSystem.Reset();
gSystemHalt=TRUE;
}
mSystem.CartAddressStrobe((data&0x01)?TRUE:FALSE);
if(mSystem.mEEPROM->Available()) mSystem.mEEPROM->ProcessEepromCounter(mSystem.mCart->GetCounterValue());
if(mSystem.mEEPROM->Available()) mSystem.mEEPROM->ProcessEepromCounter((UWORD) mSystem.mCart->GetCounterValue());
break;

case (MIKEYSREV&0xff):
Expand All @@ -1890,7 +1890,7 @@ void CMikie::Poke(ULONG addr,UBYTE data)
case (IODIR&0xff):
TRACE_MIKIE2("Poke(IODIR ,%02x) at PC=%04x",data,mSystem.mCpu->GetPC());
mIODIR=data;
if(mSystem.mEEPROM->Available()) mSystem.mEEPROM->ProcessEepromIO(mIODIR,mIODAT);
if(mSystem.mEEPROM->Available()) mSystem.mEEPROM->ProcessEepromIO((UBYTE) mIODIR, (UBYTE) mIODAT);
break;

case (IODAT&0xff):
Expand All @@ -1899,7 +1899,7 @@ void CMikie::Poke(ULONG addr,UBYTE data)
mSystem.CartAddressData((mIODAT&0x02)?TRUE:FALSE);
// Enable cart writes to BANK1 on AUDIN if AUDIN is set to output
if(mIODIR&0x10) mSystem.mCart->mWriteEnableBank1=(mIODAT&0x10)?TRUE:FALSE;// there is no reason to use AUDIN as Write Enable or latch. private patch??? TODO
if(mSystem.mEEPROM->Available()) mSystem.mEEPROM->ProcessEepromIO(mIODIR,mIODAT);
if(mSystem.mEEPROM->Available()) mSystem.mEEPROM->ProcessEepromIO((UBYTE) mIODIR, (UBYTE) mIODAT);
break;

case (SERCTL&0xff):
Expand Down
4 changes: 2 additions & 2 deletions handy-win32src-0.95-patched/core/mikie.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ class CMikie : public CLynxBase
inline void UpdateSound(void);
inline bool SwitchAudInDir(void)
{
return(mIODIR&0x10);
return (mIODIR & 0x10) != 0;
};
inline bool SwitchAudInValue(void)
{
return (mIODAT&0x10);
return (mIODAT & 0x10) != 0;
};

private:
Expand Down
13 changes: 6 additions & 7 deletions handy-win32src-0.95-patched/core/rom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CRom::CRom(char *romfile,bool useEmu)
{
mWriteEnable=FALSE;
mValid = TRUE;
strncpy(mFileName,romfile,1024);
strncpy_s(mFileName, 1024, romfile, 1024);
Reset();

// Initialise ROM
Expand All @@ -75,14 +75,13 @@ CRom::CRom(char *romfile,bool useEmu)
mRomData[0x1FE]=0x80;
mRomData[0x1FF]=0xFF;

if(useEmu){
if (useEmu) {
mValid = FALSE;
}else{
} else {
// Load up the file

FILE *fp;

if((fp=fopen(mFileName,"rb"))==NULL) {
FILE* fp;
errno_t err;
if ((err = fopen_s(&fp, mFileName, "rb")) != 0) {
CLynxException lynxerr;

lynxerr.Message() << "The Lynx Boot ROM image couldn't be located!";
Expand Down
12 changes: 6 additions & 6 deletions handy-win32src-0.95-patched/core/susie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,9 @@ ULONG CSusie::PaintSprites(void)
}

// Perform Sprite debugging if required, single step on sprite draw
if(gSingleStepModeSprites) {
if (gSingleStepModeSprites) {
char message[256];
sprintf(message,"CSusie:PaintSprites() - Rendered Sprite %03d",sprcount);
sprintf_s(message, 256, "CSusie:PaintSprites() - Rendered Sprite %03d", sprcount);
if(!gError->Warning(message)) gSingleStepModeSprites=0;
}
} else {
Expand Down Expand Up @@ -1786,7 +1786,7 @@ void CSusie::Poke(ULONG addr,UBYTE data)
} else {
mSystem.Poke_CARTB0(data);
}
mSystem.mEEPROM->ProcessEepromCounter(mSystem.mCart->GetCounterValue());
mSystem.mEEPROM->ProcessEepromCounter((UWORD) mSystem.mCart->GetCounterValue());
TRACE_SUSIE2("Poke(RCART0,%02x) at PC=$%04x",data,mSystem.mCpu->GetPC());
break;
case (RCART1&0xff):
Expand All @@ -1795,7 +1795,7 @@ void CSusie::Poke(ULONG addr,UBYTE data)
} else {
mSystem.Poke_CARTB1(data);
}
mSystem.mEEPROM->ProcessEepromCounter(mSystem.mCart->GetCounterValue());
mSystem.mEEPROM->ProcessEepromCounter((UWORD) mSystem.mCart->GetCounterValue());
TRACE_SUSIE2("Poke(RCART1,%02x) at PC=$%04x",data,mSystem.mCpu->GetPC());
break;

Expand Down Expand Up @@ -2193,7 +2193,7 @@ UBYTE CSusie::Peek(ULONG addr)
} else {
retval=mSystem.Peek_CARTB0();
}
mSystem.mEEPROM->ProcessEepromCounter(mSystem.mCart->GetCounterValue());
mSystem.mEEPROM->ProcessEepromCounter((UWORD) mSystem.mCart->GetCounterValue());
// TRACE_SUSIE2("Peek(RCART0)=$%02x at PC=$%04x",retval,mSystem.mCpu->GetPC());
return retval;
break;
Expand All @@ -2203,7 +2203,7 @@ UBYTE CSusie::Peek(ULONG addr)
} else {
retval=mSystem.Peek_CARTB1();
}
mSystem.mEEPROM->ProcessEepromCounter(mSystem.mCart->GetCounterValue());
mSystem.mEEPROM->ProcessEepromCounter((UWORD)mSystem.mCart->GetCounterValue());
// TRACE_SUSIE2("Peek(RCART1)=$%02x at PC=$%04x",retval,mSystem.mCpu->GetPC());
return retval;
break;
Expand Down
Loading