Skip to content

Commit

Permalink
Replaced RomFileProxy by MediaFileProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jun 7, 2024
1 parent 9fb074c commit 312078d
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Emulator/Components/C64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ C64::loadRom(const string &path)
}

void
C64::loadRom(const RomFile &file)
C64::loadRom(const MediaFile &file)
{
switch (file.type()) {

Expand Down Expand Up @@ -1449,13 +1449,13 @@ C64::loadRom(const RomFile &file)

case FILETYPE_VC1541_ROM:

drive8.mem.loadRom(file.data, file.size);
drive9.mem.loadRom(file.data, file.size);
drive8.mem.loadRom(file.getData(), file.getSize());
drive9.mem.loadRom(file.getData(), file.getSize());
debug(MEM_DEBUG, "VC1541 Rom flashed\n");
break;

default:
fatalError;
throw VC64Error(ERROR_FILE_TYPE_MISMATCH);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Emulator/Components/C64.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ class C64 final : public CoreComponent, public Inspectable<C64Info> {

// Installs a Rom
void loadRom(const string &path) throws;
void loadRom(const RomFile &file);
void loadRom(const MediaFile &file);

// Erases an installed Rom
void deleteRom(RomType type);
Expand Down
11 changes: 11 additions & 0 deletions Emulator/Media/AnyFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ class AnyFile : public CoreObject, public MediaFile {
void init(FILE *file) throws;


//
// Methods from MediaFile
//

// Returns the size of this file
virtual isize getSize() const override { return size; }

// Returns a pointer to the file data
virtual u8 *getData() const override { return data; }


//
// Accessing
//
Expand Down
6 changes: 6 additions & 0 deletions Emulator/Media/MediaFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class MediaFile {
// Returns the media type of this file
virtual FileType type() const { return FILETYPE_UNKNOWN; }

// Returns the size of this file
virtual isize getSize() const = 0;

// Returns a pointer to the file data
virtual u8 *getData() const = 0;

// Returns the logical name of this file
virtual string name() const = 0;

Expand Down
2 changes: 1 addition & 1 deletion Emulator/VirtualC64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ VirtualC64::C64API::loadRom(const string &path)
}

void
VirtualC64::C64API::loadRom(const RomFile &file)
VirtualC64::C64API::loadRom(const MediaFile &file)
{
c64->loadRom(file);
c64->markAsDirty();
Expand Down
2 changes: 1 addition & 1 deletion Emulator/VirtualC64.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class VirtualC64 : API {

/** @brief Loads a ROM, provided by a RomFile object
*/
void loadRom(const RomFile &file);
void loadRom(const MediaFile &file);

/** @brief Removes an installed ROM
* The ROM contents is overwritten with zeroes.
Expand Down
2 changes: 1 addition & 1 deletion GUI/Panels/Configuration/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class Configuration {
func load(_ url: URL?, type: vc64.FileType) {

if url != nil {
if let file = try? RomFileProxy.make(with: url!) {
if let file = try? MediaFileProxy.make(with: url!) {
if file.type == type { emu.loadRom(file) }
}
}
Expand Down
6 changes: 3 additions & 3 deletions GUI/Panels/Configuration/RomConf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ extension ConfigurationController {
let c = NSData(data: NSDataAsset(name: "chargen_openroms")!.data)
let k = NSData(data: NSDataAsset(name: "kernal_generic")!.data)

if let rom = try? RomFileProxy.makeWith(buffer: b.bytes, length: b.length) {
if let rom = try? MediaFileProxy.makeWith(buffer: b.bytes, length: b.length, type: .BASIC_ROM) {
emu.loadRom(rom)
}
if let rom = try? RomFileProxy.makeWith(buffer: c.bytes, length: c.length) {
if let rom = try? MediaFileProxy.makeWith(buffer: c.bytes, length: c.length, type: .CHAR_ROM) {
emu.loadRom(rom)
}
if let rom = try? RomFileProxy.makeWith(buffer: k.bytes, length: k.length) {
if let rom = try? MediaFileProxy.makeWith(buffer: k.bytes, length: k.length, type: .KERNAL_ROM) {
emu.loadRom(rom)
}

Expand Down
2 changes: 1 addition & 1 deletion GUI/Panels/Configuration/RomDropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class RomDropView: DropView {

do {

let rom = try RomFileProxy.make(with: url)
let rom = try MediaFileProxy.make(with: url)
emu.loadRom(rom)

return true
Expand Down
7 changes: 4 additions & 3 deletions Proxy/EmulatorProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using namespace vc64;
@class PRGFileProxy;
@class RecorderProxy;
@class RetroShellProxy;
@class RomFileProxy;
// @class RomFileProxy;
@class ScriptProxy;
@class SIDProxy;
// @class SnapshotProxy;
Expand Down Expand Up @@ -221,7 +221,7 @@ using namespace vc64;
- (BOOL)isRom:(RomType)type url:(NSURL *)url;

- (void)loadRom:(NSURL *)url exception:(ExceptionWrapper *)ex;
- (void)loadRom:(RomFileProxy *)proxy;
- (void)loadRom:(MediaFileProxy *)proxy;
- (void)saveRom:(RomType)type url:(NSURL *)url exception:(ExceptionWrapper *)ex;
- (void)deleteRom:(RomType)type;

Expand Down Expand Up @@ -754,13 +754,14 @@ struct GuardInfo {
// RomFile
//

/*
@interface RomFileProxy : AnyFileProxy <MakeWithFile, MakeWithBuffer> { }
+ (instancetype)makeWithFile:(NSString *)path exception:(ExceptionWrapper *)ex;
+ (instancetype)makeWithBuffer:(const void *)buf length:(NSInteger)len exception:(ExceptionWrapper *)ex;
@end

*/

//
// CRTFile
Expand Down
6 changes: 4 additions & 2 deletions Proxy/EmulatorProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,7 @@ - (void)execute:(EmulatorProxy *)proxy
// RomFile proxy
//

/*
@implementation RomFileProxy
+ (instancetype)make:(RomFile *)file
Expand All @@ -1471,6 +1472,7 @@ + (instancetype)makeWithBuffer:(const void *)buf length:(NSInteger)len exception
}
@end
*/


//
Expand Down Expand Up @@ -2480,9 +2482,9 @@ - (void) loadRom:(NSURL *)url exception:(ExceptionWrapper *)e
catch (VC64Error &error) { [e save:error]; }
}

- (void) loadRom:(RomFileProxy *)proxy
- (void) loadRom:(MediaFileProxy *)proxy
{
[self emu]->c64.loadRom(*(RomFile *)proxy->obj);
[self emu]->c64.loadRom(*(MediaFile *)proxy->obj);
}

- (void) saveRom:(RomType)type url:(NSURL *)url exception:(ExceptionWrapper *)e
Expand Down

0 comments on commit 312078d

Please sign in to comment.