Skip to content

Commit

Permalink
Update Mednafen to 1.22.2
Browse files Browse the repository at this point in the history
  • Loading branch information
clobber committed Jun 6, 2019
1 parent c51389f commit 36ec9cd
Show file tree
Hide file tree
Showing 16 changed files with 179 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.22.1</string>
<string>1.22.2</string>
<key>NSPrincipalClass</key>
<string>OEGameCoreController</string>
<key>OEGameCoreClass</key>
Expand Down
8 changes: 4 additions & 4 deletions Mednafen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4747,9 +4747,9 @@
OTHER_CFLAGS = (
"-fwrapv",
"-DHAVE_MKDIR",
"-DMEDNAFEN_VERSION=\\\"1.22.1\\\"",
"-DMEDNAFEN_VERSION=\\\"1.22.2\\\"",
"-DPACKAGE=\\\"mednafen\\\"",
"-DMEDNAFEN_VERSION_NUMERIC=0x00102201",
"-DMEDNAFEN_VERSION_NUMERIC=0x00102202",
"-DPSS_STYLE=1",
"-DMPC_FIXED_POINT",
"-DARCH_X86",
Expand Down Expand Up @@ -4813,9 +4813,9 @@
OTHER_CFLAGS = (
"-fwrapv",
"-DHAVE_MKDIR",
"-DMEDNAFEN_VERSION=\\\"1.22.1\\\"",
"-DMEDNAFEN_VERSION=\\\"1.22.2\\\"",
"-DPACKAGE=\\\"mednafen\\\"",
"-DMEDNAFEN_VERSION_NUMERIC=0x00102201",
"-DMEDNAFEN_VERSION_NUMERIC=0x00102202",
"-DPSS_STYLE=1",
"-DMPC_FIXED_POINT",
"-DARCH_X86",
Expand Down
185 changes: 133 additions & 52 deletions mednafen/apple2/disk2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Disk2
enum : unsigned { num_tracks = 160 };
//enum : unsigned { samples_per_track = 1431818 };
enum : unsigned { min_bits_per_track = 46000 };
enum : unsigned { max_bits_per_track = 53168 };
enum : unsigned { max_bits_per_track = 56048 };

static uint8 BootROM[256];
static uint8 SequencerROM[256];
Expand Down Expand Up @@ -868,21 +868,27 @@ static void LoadD13(Stream* sp, FloppyDisk* disk)
}
}

static const uint8 woz_header_magic[8] = { 0x57, 0x4F, 0x5A, 0x31, 0xFF, 0x0A, 0x0D, 0x0A };
static const uint8 woz_header_magic[8] = { 0x57, 0x4F, 0x5A, 0x31, 0xFF, 0x0A, 0x0D, 0x0A };
static const uint8 woz2_header_magic[8] = { 0x57, 0x4F, 0x5A, 0x32, 0xFF, 0x0A, 0x0D, 0x0A };

static void LoadWOZ(Stream* sp, FloppyDisk* disk)
{
uint8 header[12];

MDFN_printf(_("Parsing WOZ-format disk image...\n"));

if(sp->read(header, 12, false) != 12 || memcmp(header, woz_header_magic, sizeof(woz_header_magic)))
if(sp->read(header, 12, false) != 12 || (memcmp(header, woz_header_magic, sizeof(woz_header_magic)) && memcmp(header, woz2_header_magic, sizeof(woz2_header_magic))))
throw MDFN_Error(0, _("Bad or missing WOZ file header."));
//
const bool woz2 = !memcmp(header, woz2_header_magic, sizeof(woz2_header_magic));
//
uint8 disk_type;
uint8 write_protected;
uint8 synchronized;
uint8 cleaned;
uint8 optimal_bit_timing = 32;
uint16 compat_hw = 0;
uint16 req_ram = 0;
//
uint8 chunk_header[8];
unsigned required_chunks = 0;
Expand Down Expand Up @@ -922,6 +928,13 @@ static void LoadWOZ(Stream* sp, FloppyDisk* disk)
MDFN_zapctrlchars(creator);
MDFN_trim(creator);

if(woz2)
{
optimal_bit_timing = info[39];
compat_hw = MDFN_de16lsb(&info[40]);
req_ram = MDFN_de16lsb(&info[42]);
}

if(disk_type == 0x02)
throw MDFN_Error(0, _("3.5\" floppy disk images not currently supported."));
Expand All @@ -930,13 +943,40 @@ static void LoadWOZ(Stream* sp, FloppyDisk* disk)
disk->write_protect = (bool)write_protected;
MDFN_printf(" INFO:\n");
MDFN_printf(" Version: %u\n", info_version);
MDFN_printf(" Disk type: %u\n", disk_type);
MDFN_printf(" Write protected: %u\n", write_protected);
MDFN_printf(" Synchronized: %u\n", synchronized);
MDFN_printf(" Cleaned: %u\n", cleaned);
MDFN_printf(" Creator: %s\n", creator);
MDFN_printf(_(" INFO:\n"));
MDFN_printf(_(" Version: %u\n"), info_version);
MDFN_printf(_(" Disk type: %u\n"), disk_type);
MDFN_printf(_(" Write protected: %u\n"), write_protected);
MDFN_printf(_(" Synchronized: %u\n"), synchronized);
MDFN_printf(_(" Cleaned: %u\n"), cleaned);
MDFN_printf(_(" Creator: %s\n"), creator);
if(woz2)
{
static const char* compat_hw_tab[] = { "Apple II", "Apple II+", "Apple IIe", "Apple IIc", "Apple IIe Enhanced", "Apple IIgs", "Apple IIc Plus", "Apple III", "Apple III Plus" };
std::string compat_hw_str;
for(size_t i = 0; i < sizeof(compat_hw_tab) / sizeof(compat_hw_tab[0]); i++)
{
if(compat_hw & (1U << i))
{
if(compat_hw_str.size())
compat_hw_str += ", ";
compat_hw_str += compat_hw_tab[i];
}
}
if(!compat_hw_str.size())
compat_hw_str = _("Unknown");
MDFN_printf(_(" Optimal bit timing: %u\n"), optimal_bit_timing);
MDFN_printf(_(" Compatible hardware: %s\n"), compat_hw_str.c_str());
if(!req_ram)
MDFN_printf(_(" Required RAM: %s\n"), _("Unknown"));
else
MDFN_printf(_(" Required RAM: %u KiB\n"), req_ram);
}
//
required_chunks |= 1;
}
Expand All @@ -963,57 +1003,98 @@ static void LoadWOZ(Stream* sp, FloppyDisk* disk)
if(sp->tell() != 256)
throw MDFN_Error(0, _("Required chunk \"%s\" is at the wrong offset."), "TRKS");
if(chunk_size != num_src_tracks * 6656)
throw MDFN_Error(0, _("Required chunk \"%s\" is of the wrong size."), "TRKS");
//
src_tracks.reset(new FloppyDisk::Track[num_src_tracks]);
MDFN_printf(" TRKS:\n");
for(unsigned i = 0; i < num_src_tracks; i++)
if(woz2)
{
uint8 trk[6656];
std::unique_ptr<uint8[]> index(new uint8[1280]);
std::unique_ptr<uint8[]> trk(new uint8[(max_bits_per_track + 7) >> 3]);
sp->read(trk, 6656);
//
const uint16 bytes_used = MDFN_de16lsb(&trk[6646]);
const uint16 bit_count = MDFN_de16lsb(&trk[6648]);
const uint16 splice_point = MDFN_de16lsb(&trk[6650]);
const uint8 splice_nibble = trk[6652];
const uint8 splice_bit_count = trk[6653];
const uint16 reserved = MDFN_de16lsb(&trk[6654]);
if(bytes_used > 6646)
throw MDFN_Error(0, _("Bytes used of TRKS chunk TRK entry %u is larger than 6646!"), i);
if(bit_count > bytes_used * 8)
throw MDFN_Error(0, _("Bit count of TRKS chunk TRK entry %u is larger than the number of bytes used * 8!"), i);
//
// Sanity check, various assumptions to boost performance break down if the number of bits is too low or high.
// Maybe should check if the maximum absolute difference of one track's bit count compared to another track's bit count
// is too large too...
//
if(bit_count < min_bits_per_track || bit_count > max_bits_per_track)
throw MDFN_Error(0, _("Bit count(%u) of TRKS chunk TRK entry %u is out of the acceptable range of %u through %u!"), bit_count, i, min_bits_per_track, max_bits_per_track);
MDFN_printf(" Source track %u:\n", i);
MDFN_printf(_(" Bytes used: %u\n"), bytes_used);
MDFN_printf(_(" Bit count: %u\n"), bit_count);
MDFN_printf(_(" Splice point: %u\n"), splice_point);
MDFN_printf(_(" Splice nibble: 0x%02x\n"), splice_nibble);
MDFN_printf(_(" Splice bit count: %u\n"), splice_bit_count);
MDFN_printf(_(" Reserved: 0x%04x\n"), reserved);
sp->read(index.get(), 1280);
//
apple2_track_encoder te(&src_tracks[i], bit_count);
for(unsigned i = 0; i < num_src_tracks; i++)
{
const uint16 starting_block = MDFN_de16lsb(&index[i * 8 + 0]);
const uint16 block_count = MDFN_de16lsb(&index[i * 8 + 2]);
const uint32 bit_count = MDFN_de32lsb(&index[i * 8 + 4]);
if(bit_count > (block_count * 8 * 512))
throw MDFN_Error(0, _("Bit count of TRKS chunk TRK entry %u is larger than the block count * 512 * 8!"), i);
if(bit_count < min_bits_per_track || bit_count > max_bits_per_track)
throw MDFN_Error(0, _("Bit count(%u) of TRKS chunk TRK entry %u is out of the acceptable range of %u through %u!"), bit_count, i, min_bits_per_track, max_bits_per_track);
//
//
//
sp->seek(starting_block * 512);
sp->read(trk.get(), (bit_count + 7) >> 3);
//
MDFN_printf(_(" Source track %u:\n"), i);
MDFN_printf(_(" Starting block: %u\n"), starting_block);
MDFN_printf(_(" Block count: %u\n"), block_count);
MDFN_printf(_(" Bit count: %u\n"), bit_count);
//
apple2_track_encoder te(&src_tracks[i], bit_count);
for(size_t bi = 0; bi < bit_count; bi++)
{
te.encode_bit((trk[bi >> 3] >> (0x7 - (bi & 0x7))) & 1);
}
te.finish();
}
}
else
{
if(chunk_size != num_src_tracks * 6656)
throw MDFN_Error(0, _("Required chunk \"%s\" is of the wrong size."), "TRKS");
for(size_t bi = 0; bi < bit_count; bi++)
for(unsigned i = 0; i < num_src_tracks; i++)
{
te.encode_bit((trk[bi >> 3] >> (0x7 - (bi & 0x7))) & 1);
uint8 trk[6656];
sp->read(trk, 6656);
//
const uint16 bytes_used = MDFN_de16lsb(&trk[6646]);
const uint16 bit_count = MDFN_de16lsb(&trk[6648]);
const uint16 splice_point = MDFN_de16lsb(&trk[6650]);
const uint8 splice_nibble = trk[6652];
const uint8 splice_bit_count = trk[6653];
const uint16 reserved = MDFN_de16lsb(&trk[6654]);
if(bytes_used > 6646)
throw MDFN_Error(0, _("Bytes used of TRKS chunk TRK entry %u is larger than 6646!"), i);
if(bit_count > bytes_used * 8)
throw MDFN_Error(0, _("Bit count of TRKS chunk TRK entry %u is larger than the number of bytes used * 8!"), i);
//
// Sanity check, various assumptions to boost performance break down if the number of bits is too low or high.
// Maybe should check if the maximum absolute difference of one track's bit count compared to another track's bit count
// is too large too...
//
if(bit_count < min_bits_per_track || bit_count > max_bits_per_track)
throw MDFN_Error(0, _("Bit count(%u) of TRKS chunk TRK entry %u is out of the acceptable range of %u through %u!"), bit_count, i, min_bits_per_track, max_bits_per_track);
MDFN_printf(_(" Source track %u:\n"), i);
MDFN_printf(_(" Bytes used: %u\n"), bytes_used);
MDFN_printf(_(" Bit count: %u\n"), bit_count);
MDFN_printf(_(" Splice point: %u\n"), splice_point);
MDFN_printf(_(" Splice nibble: 0x%02x\n"), splice_nibble);
MDFN_printf(_(" Splice bit count: %u\n"), splice_bit_count);
MDFN_printf(_(" Reserved: 0x%04x\n"), reserved);
//
apple2_track_encoder te(&src_tracks[i], bit_count);
for(size_t bi = 0; bi < bit_count; bi++)
{
te.encode_bit((trk[bi >> 3] >> (0x7 - (bi & 0x7))) & 1);
}
te.finish();
}
te.finish();
}
for(unsigned i = 0; i < sizeof(tmap); i++)
Expand Down Expand Up @@ -1406,7 +1487,7 @@ static void LoadDisk(Stream* sp, const std::string& ext, FloppyDisk* disk)
MDFN_printf("Warning: Detecting Apple II disk image format by contents and/or size(ext=%s).\n", ext.c_str());
woz_header_detected = (sp->read(header, 12, false) == 12 && !memcmp(header, woz_header_magic, sizeof(woz_header_magic)));
woz_header_detected = (sp->read(header, 12, false) == 12 && (!memcmp(header, woz_header_magic, sizeof(woz_header_magic)) || !memcmp(header, woz2_header_magic, sizeof(woz2_header_magic))));
sp->rewind();
if(woz_header_detected)
Expand Down
4 changes: 2 additions & 2 deletions mednafen/lynx/ram.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class CRam : public CLynxBase

void Reset(void) MDFN_COLD;

void Poke(uint32 addr, uint8 data){ mRamData[addr]=data;};
uint8 Peek(uint32 addr){ return(mRamData[addr]);};
void Poke(uint32 addr, uint8 data){ mRamData[(uint16)addr]=data;};
uint8 Peek(uint32 addr){ return(mRamData[(uint16)addr]);};
uint32 ReadCycle(void) {return 5;};
uint32 WriteCycle(void) {return 5;};
uint32 ObjectSize(void) {return RAM_SIZE;};
Expand Down
18 changes: 7 additions & 11 deletions mednafen/lynx/susie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,9 @@
// wa can access this directly without the hassle of
// going through the system object, much faster
//
//#define RAM_PEEK(m) (mSystem.Peek_RAM((m)))
//#define RAM_POKE(m1,m2) (mSystem.Poke_RAM((m1),(m2)))
//#define RAM_PEEKW(m) (mSystem.PeekW_RAM((m)))

#define RAM_PEEK(m) (mRamPointer[(m)])
#define RAM_PEEKW(m) (mRamPointer[(m)]+(mRamPointer[(m)+1]<<8))
#define RAM_POKE(m1,m2) {mRamPointer[(m1)]=(m2);}
#define RAM_PEEK(m) (mRamPointer[(uint16)(m)])
#define RAM_PEEKW(m) (mRamPointer[(uint16)(m)]+(mRamPointer[(uint16)((m)+1)]<<8))
#define RAM_POKE(m1,m2) {mRamPointer[(uint16)(m1)]=(m2);}

uint32 cycles_used=0;

Expand Down Expand Up @@ -838,7 +834,7 @@ uint32 CSusie::PaintSprites(void)

INLINE void CSusie::WritePixel(uint32 hoff,uint32 pixel)
{
uint32 scr_addr=mLineBaseAddress+(hoff/2);
const uint16 scr_addr=mLineBaseAddress+(hoff/2);

uint8 dest=RAM_PEEK(scr_addr);
if(!(hoff&0x01))
Expand All @@ -861,7 +857,7 @@ INLINE void CSusie::WritePixel(uint32 hoff,uint32 pixel)

INLINE uint32 CSusie::ReadPixel(uint32 hoff)
{
uint32 scr_addr=mLineBaseAddress+(hoff/2);
const uint16 scr_addr=mLineBaseAddress+(hoff/2);

uint32 data=RAM_PEEK(scr_addr);
if(!(hoff&0x01))
Expand All @@ -883,7 +879,7 @@ INLINE uint32 CSusie::ReadPixel(uint32 hoff)

INLINE void CSusie::WriteCollision(uint32 hoff,uint32 pixel)
{
uint32 col_addr=mLineCollisionAddress+(hoff/2);
const uint16 col_addr=mLineCollisionAddress+(hoff/2);

uint8 dest=RAM_PEEK(col_addr);
if(!(hoff&0x01))
Expand All @@ -906,7 +902,7 @@ INLINE void CSusie::WriteCollision(uint32 hoff,uint32 pixel)

INLINE uint32 CSusie::ReadCollision(uint32 hoff)
{
uint32 col_addr=mLineCollisionAddress+(hoff/2);
const uint16 col_addr=mLineCollisionAddress+(hoff/2);

uint32 data=RAM_PEEK(col_addr);
if(!(hoff&0x01))
Expand Down
5 changes: 0 additions & 5 deletions mednafen/lynx/sysbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ class CSystemBase
virtual void PokeW_CPU(uint32 addr,uint16 data)=0;
virtual uint16 PeekW_CPU(uint32 addr)=0;

virtual void Poke_RAM(uint32 addr,uint8 data)=0;
virtual uint8 Peek_RAM(uint32 addr)=0;
virtual void PokeW_RAM(uint32 addr,uint16 data)=0;
virtual uint16 PeekW_RAM(uint32 addr)=0;

virtual uint8* GetRamPointer(void)=0;

};
Expand Down
8 changes: 0 additions & 8 deletions mednafen/lynx/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,6 @@ class CSystem : public CSystemBase
inline void PokeW_CPU(uint32 addr,uint16 data) { mMemoryHandlers[addr]->Poke(addr,data&0xff);addr++;mMemoryHandlers[addr]->Poke(addr,data>>8);};
inline uint16 PeekW_CPU(uint32 addr) {return ((mMemoryHandlers[addr]->Peek(addr))+(mMemoryHandlers[addr]->Peek(addr+1)<<8));};

//
// RAM
//
inline void Poke_RAM(uint32 addr, uint8 data) { mRam->Poke(addr,data);};
inline uint8 Peek_RAM(uint32 addr) { return mRam->Peek(addr);};
inline void PokeW_RAM(uint32 addr,uint16 data) { mRam->Poke(addr,data&0xff);addr++;mRam->Poke(addr,data>>8);};
inline uint16 PeekW_RAM(uint32 addr) {return ((mRam->Peek(addr))+(mRam->Peek(addr+1)<<8));};

// High level cart access for debug etc

inline void Poke_CART(uint32 addr, uint8 data) {mCart->Poke(addr,data);};
Expand Down
4 changes: 3 additions & 1 deletion mednafen/ngp/TLCS-900h/TLCS900h_interpret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,9 @@ static void ExR32()
//Undocumented mode!
if (data == 0x13)
{
mem = pc + (int16)fetch16();
const int16 disp = fetch16();

mem = pc + disp;
cycles_extra = 8; //Unconfirmed... doesn't make much difference
return;
}
Expand Down
2 changes: 1 addition & 1 deletion mednafen/pce/huc6280_ops.inc
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ case 0xCB:
if(EmulateWAI)
{
if(next_event > 1)
ADDCYC(next_event - 1);
ADDCYC_MASTER(next_event - 1);
LastCycle();
break;
}
Expand Down
Loading

0 comments on commit 36ec9cd

Please sign in to comment.