Skip to content

Commit

Permalink
undo some #ifdef intrusions into upstream code
Browse files Browse the repository at this point in the history
  • Loading branch information
sh95014 committed Jan 1, 2022
1 parent 950eec0 commit e00a81e
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 67 deletions.
12 changes: 8 additions & 4 deletions Mariani.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@
B049E83A277B61A100FC14A3 /* utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B049E838277B61A100FC14A3 /* utils.cpp */; };
B049E83F277B61AC00FC14A3 /* utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B049E83D277B61AC00FC14A3 /* utils.cpp */; };
B049E843277B61CB00FC14A3 /* speed.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B049E841277B61CB00FC14A3 /* speed.cpp */; };
B049E847277B677400FC14A3 /* sdlrendererframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B049E845277B677400FC14A3 /* sdlrendererframe.cpp */; };
B049E84C277B6DE300FC14A3 /* programoptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B049E84B277B6DE300FC14A3 /* programoptions.cpp */; };
B049E84E277B6F4A00FC14A3 /* libboost_program_options.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B049E84D277B6F4A00FC14A3 /* libboost_program_options.a */; };
B049E852277B6FFE00FC14A3 /* fileregistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B049E850277B6FFE00FC14A3 /* fileregistry.cpp */; };
B049E855277B702100FC14A3 /* ptreeregistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B049E853277B702000FC14A3 /* ptreeregistry.cpp */; };
Expand All @@ -179,6 +177,8 @@
B049E8AD277C880800FC14A3 /* EmulatorView.mm in Sources */ = {isa = PBXBuildFile; fileRef = B049E8AB277C880800FC14A3 /* EmulatorView.mm */; };
B049E8AF277C9A8000FC14A3 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B049E8AE277C9A8000FC14A3 /* MetalKit.framework */; };
B049E8B2277D8B3B00FC14A3 /* Preferences.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B049E8B1277D8B3B00FC14A3 /* Preferences.storyboard */; };
B0689D0A2780B9B60029EB7D /* sdldummyframe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B0689D082780B9B60029EB7D /* sdldummyframe.cpp */; };
B0689D0D2780C85F0029EB7D /* programoptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B049E84B277B6DE300FC14A3 /* programoptions.cpp */; };
B0927417277D9399003FFB79 /* PreferencesViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = B0927415277D9399003FFB79 /* PreferencesViewController.mm */; };
B092741B277D9403003FFB79 /* PreferencesWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = B0927419277D9403003FFB79 /* PreferencesWindowController.m */; };
B09AB674277A14DB0002A6C3 /* Speech.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B09AB626277A14DB0002A6C3 /* Speech.cpp */; };
Expand Down Expand Up @@ -318,6 +318,8 @@
B049E8AB277C880800FC14A3 /* EmulatorView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = EmulatorView.mm; sourceTree = "<group>"; };
B049E8AE277C9A8000FC14A3 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; };
B049E8B1277D8B3B00FC14A3 /* Preferences.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Preferences.storyboard; sourceTree = "<group>"; };
B0689D082780B9B60029EB7D /* sdldummyframe.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = sdldummyframe.cpp; sourceTree = "<group>"; };
B0689D092780B9B60029EB7D /* sdldummyframe.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = sdldummyframe.hpp; sourceTree = "<group>"; };
B0927414277D9399003FFB79 /* PreferencesViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PreferencesViewController.h; sourceTree = "<group>"; };
B0927415277D9399003FFB79 /* PreferencesViewController.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; path = PreferencesViewController.mm; sourceTree = "<group>"; };
B0927418277D9403003FFB79 /* PreferencesWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PreferencesWindowController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -657,6 +659,8 @@
B049E8B1277D8B3B00FC14A3 /* Preferences.storyboard */,
B032DE2C277A0C24006DC0F7 /* main.m */,
B032DE2E277A0C24006DC0F7 /* mariani.entitlements */,
B0689D082780B9B60029EB7D /* sdldummyframe.cpp */,
B0689D092780B9B60029EB7D /* sdldummyframe.hpp */,
);
name = mariani;
path = source/frontends/mariani;
Expand Down Expand Up @@ -1409,9 +1413,11 @@
B09AB80D277A21410002A6C3 /* guiddef.cpp in Sources */,
B049E820277B512500FC14A3 /* sdirectsound.cpp in Sources */,
B09AB7D2277A21180002A6C3 /* Joystick.cpp in Sources */,
B0689D0A2780B9B60029EB7D /* sdldummyframe.cpp in Sources */,
B09AB72E277A1BA40002A6C3 /* Util_MemoryTextFile.cpp in Sources */,
B049E852277B6FFE00FC14A3 /* fileregistry.cpp in Sources */,
B032DE2D277A0C24006DC0F7 /* main.m in Sources */,
B0689D0D2780C85F0029EB7D /* programoptions.cpp in Sources */,
B09AB7D9277A21180002A6C3 /* FourPlay.cpp in Sources */,
B09AB7D3277A21180002A6C3 /* Debugger_Win32.cpp in Sources */,
B09AB7DA277A21180002A6C3 /* Keyboard.cpp in Sources */,
Expand All @@ -1433,7 +1439,6 @@
B09AB805277A21410002A6C3 /* dsound.cpp in Sources */,
B049E843277B61CB00FC14A3 /* speed.cpp in Sources */,
B09AB73C277A1BA40002A6C3 /* Debugger_Console.cpp in Sources */,
B049E84C277B6DE300FC14A3 /* programoptions.cpp in Sources */,
B032DE26277A0C23006DC0F7 /* AppDelegate.mm in Sources */,
B049E826277B52B200FC14A3 /* sdlframe.cpp in Sources */,
B09AB736277A1BA40002A6C3 /* Debug.cpp in Sources */,
Expand All @@ -1446,7 +1451,6 @@
B09AB811277A21410002A6C3 /* winhandles.cpp in Sources */,
B09AB72A277A1BA40002A6C3 /* Debugger_Symbols.cpp in Sources */,
B049E836277B614900FC14A3 /* processfile.cpp in Sources */,
B049E847277B677400FC14A3 /* sdlrendererframe.cpp in Sources */,
B09AB803277A21410002A6C3 /* winuser.cpp in Sources */,
B09AB804277A21410002A6C3 /* timeapi.cpp in Sources */,
B09AB728277A1BA40002A6C3 /* Debugger_DisassemblerData.cpp in Sources */,
Expand Down
4 changes: 0 additions & 4 deletions source/frontends/common2/programoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ namespace common2
;
desc.add(paddleDesc);

#ifndef MARIANI
po::variables_map vm;
try
{
Expand Down Expand Up @@ -206,9 +205,6 @@ namespace common2
std::cerr << "ERROR: " << e.what() << std::endl;
return false;
}
#else
return true;
#endif // MARIANI
}

void applyOptions(const EmulatorOptions & options)
Expand Down
91 changes: 36 additions & 55 deletions source/frontends/mariani/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import "gamepad.h"
#import "programoptions.h"
#import "sdirectsound.h"
#import "sdlrendererframe.h"
#import "sdldummyframe.hpp"
#import "utils.h"

// AppleWin
Expand Down Expand Up @@ -73,68 +73,49 @@ - (int)getRefreshRate {
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
_hasStatusBar = YES;

const Uint32 flags = SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO | SDL_INIT_TIMER;
const Uint32 flags = SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO;
if (SDL_Init(flags) != 0) {
NSLog(@"SDL_Init error %s", SDL_GetError());
}

common2::EmulatorOptions options;
self.logger = new LoggerContext(options.log);
self.registryContext = new RegistryContext(CreateFileRegistry(options));

frame.reset(new sa2::SDLDummyFrame(options));

std::shared_ptr<Paddle> paddle(new sa2::Gamepad(0));
self.initialisation = new Initialisation(frame, paddle);
applyOptions(options);
frame->Begin();

Video &video = GetVideo();
const int sw = video.GetFrameBufferBorderlessWidth();
const int sh = video.GetFrameBufferBorderlessHeight();

options.geometry.empty = true;
options.geometry.width = sw * 2;
options.geometry.height = sh * 2;
options.geometry.x = SDL_WINDOWPOS_UNDEFINED;
options.geometry.y = SDL_WINDOWPOS_UNDEFINED;
const bool run = getEmulatorOptions(0, NULL, "macOS", options);

if (run) {
self.logger = new LoggerContext(options.log);
self.registryContext = new RegistryContext(CreateFileRegistry(options));

frame.reset(new sa2::SDLRendererFrame(options));

std::shared_ptr<Paddle> paddle(new sa2::Gamepad(0));
self.initialisation = new Initialisation(frame, paddle);
applyOptions(options);
frame->Begin();

NSLog(@"Default GL swap interval: %d", SDL_GL_GetSwapInterval());

const int fps = [self getRefreshRate];
NSLog(@"Video refresh rate: %d Hz, %f", fps, 1000.0 / fps);

Video &video = GetVideo();
frameBuffer.borderWidth = video.GetFrameBufferBorderWidth();
frameBuffer.borderHeight = video.GetFrameBufferBorderHeight();
frameBuffer.bufferWidth = video.GetFrameBufferWidth();
frameBuffer.bufferHeight = video.GetFrameBufferHeight();
frameBuffer.pixelWidth = video.GetFrameBufferBorderlessWidth();
frameBuffer.pixelHeight = video.GetFrameBufferBorderlessHeight();
[self.emulatorVC createScreen:&frameBuffer];

self.window.delegate = self;

// populate the Display Type menu with options
const VideoType_e currentVideoType = video.GetVideoType();
for (NSInteger videoType = VT_MONO_CUSTOM; videoType < NUM_VIDEO_MODES; videoType++) {
NSString *itemTitle = [self localizedVideoType:videoType];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:itemTitle
action:@selector(displayTypeAction:)
keyEquivalent:@""];
item.tag = videoType;
item.state = (currentVideoType == videoType) ? NSControlStateValueOn : NSControlStateValueOff;
[self.displayTypeMenu addItem:item];
}

self.driveLightButtonTemplateArchive = [self archiveFromTemplateView:self.driveLightButtonTemplate];
[self createDriveLightButtons];

[self startEmulationTimer];
frameBuffer.borderWidth = video.GetFrameBufferBorderWidth();
frameBuffer.borderHeight = video.GetFrameBufferBorderHeight();
frameBuffer.bufferWidth = video.GetFrameBufferWidth();
frameBuffer.bufferHeight = video.GetFrameBufferHeight();
frameBuffer.pixelWidth = video.GetFrameBufferBorderlessWidth();
frameBuffer.pixelHeight = video.GetFrameBufferBorderlessHeight();
[self.emulatorVC createScreen:&frameBuffer];

self.window.delegate = self;

// populate the Display Type menu with options
const VideoType_e currentVideoType = video.GetVideoType();
for (NSInteger videoType = VT_MONO_CUSTOM; videoType < NUM_VIDEO_MODES; videoType++) {
NSString *itemTitle = [self localizedVideoType:videoType];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:itemTitle
action:@selector(displayTypeAction:)
keyEquivalent:@""];
item.tag = videoType;
item.state = (currentVideoType == videoType) ? NSControlStateValueOn : NSControlStateValueOff;
[self.displayTypeMenu addItem:item];
}

self.driveLightButtonTemplateArchive = [self archiveFromTemplateView:self.driveLightButtonTemplate];
[self createDriveLightButtons];

[self startEmulationTimer];
}

- (void)timerFired {
Expand Down
33 changes: 33 additions & 0 deletions source/frontends/mariani/sdldummyframe.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// sdldummyframe.cpp
// Mariani
//
// Created by sh95014 on 1/2/22.
//

#include "StdAfx.h"
#include "sdldummyframe.hpp"

namespace sa2
{

SDLDummyFrame::SDLDummyFrame(const common2::EmulatorOptions & options)
: SDLFrame(options)
{
}

void SDLDummyFrame::Initialize(bool resetVideoState)
{
SDLFrame::Initialize(resetVideoState);
}

void SDLDummyFrame::VideoPresentScreen()
{
}

void SDLDummyFrame::GetRelativeMousePosition(const SDL_MouseMotionEvent & motion, double & x, double & y) const
{
}


}
36 changes: 36 additions & 0 deletions source/frontends/mariani/sdldummyframe.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// sdldummyframe.hpp
// Mariani
//
// Created by sh95014 on 1/2/22.
//

#pragma once

#include "sdlframe.h"

namespace common2
{
struct EmulatorOptions;
}

namespace sa2
{

class SDLDummyFrame : public SDLFrame
{
public:
SDLDummyFrame(const common2::EmulatorOptions & options);

void VideoPresentScreen() override;
void Initialize(bool resetVideoState) override;

protected:
void GetRelativeMousePosition(const SDL_MouseMotionEvent & motion, double & x, double & y) const override;

private:
// FIXME: without this hack the app crashes randomly elsewhere
Uint8 padding[1];
};

}
4 changes: 0 additions & 4 deletions source/frontends/sdl/renderer/sdlrendererframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace sa2
SDLRendererFrame::SDLRendererFrame(const common2::EmulatorOptions & options)
: SDLFrame(options)
{
#ifndef MARIANI
const common2::Geometry & geometry = options.geometry;

myWindow.reset(SDL_CreateWindow(g_pAppTitle.c_str(), geometry.x, geometry.y, geometry.width, geometry.height, SDL_WINDOW_RESIZABLE), SDL_DestroyWindow);
Expand All @@ -32,7 +31,6 @@ namespace sa2
}

printRendererInfo(std::cerr, myRenderer, ourFormat, options.sdlDriver);
#endif // MARIANI
}

void SDLRendererFrame::Initialize(bool resetVideoState)
Expand All @@ -56,11 +54,9 @@ namespace sa2

void SDLRendererFrame::VideoPresentScreen()
{
#ifdef MARIANI
SDL_UpdateTexture(myTexture.get(), nullptr, myFramebuffer.data(), myPitch);
SDL_RenderCopyEx(myRenderer.get(), myTexture.get(), &myRect, nullptr, 0.0, nullptr, SDL_FLIP_VERTICAL);
SDL_RenderPresent(myRenderer.get());
#endif // MARIANI
}

void SDLRendererFrame::GetRelativeMousePosition(const SDL_MouseMotionEvent & motion, double & x, double & y) const
Expand Down

0 comments on commit e00a81e

Please sign in to comment.