fix compiler warnings; remove some DSL dependencies; use F keys for paddle buttons
This commit is contained in:
parent
9781f55963
commit
7d94161653
|
@ -292,7 +292,7 @@ bool E2wxApp::OnCmdLineParsed(wxCmdLineParser& parser) {
|
||||||
|
|
||||||
this->opt_config_from_prefs_only = parser.Found("p");
|
this->opt_config_from_prefs_only = parser.Found("p");
|
||||||
|
|
||||||
const int n = parser.GetParamCount();
|
const int n = (int)parser.GetParamCount();
|
||||||
|
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
this->arg_configfile = path_from_string(parser.GetParam(0));
|
this->arg_configfile = path_from_string(parser.GetParam(0));
|
||||||
|
|
|
@ -54,7 +54,7 @@ static bool is_key_down(const wxKeyEvent& keyEvent) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take real-world keystrokes from SDL and filter them to emulate the Apple ][ keyboard
|
// Take real-world keystrokes and filter them to emulate the Apple ][ keyboard
|
||||||
static bool translate_key(const wxKeyEvent& keyEvent, unsigned char* key) {
|
static bool translate_key(const wxKeyEvent& keyEvent, unsigned char* key) {
|
||||||
const int keycode = keyEvent.GetKeyCode();
|
const int keycode = keyEvent.GetKeyCode();
|
||||||
|
|
||||||
|
@ -79,8 +79,7 @@ static bool translate_key(const wxKeyEvent& keyEvent, unsigned char* key) {
|
||||||
*key -= 32;
|
*key -= 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from SDL 1.2 to 2.0, we can't use UNICODE so we need to
|
// TODO can't we use UNICODE instead of applying shift and control modifiers ourselves
|
||||||
// apply shift and control modifiers ourselves
|
|
||||||
if (keyEvent.ShiftDown()) {
|
if (keyEvent.ShiftDown()) {
|
||||||
if (keycode == '`') *key = '~';
|
if (keycode == '`') *key = '~';
|
||||||
else if (keycode == '1') *key = '!';
|
else if (keycode == '1') *key = '!';
|
||||||
|
@ -155,8 +154,6 @@ void KeyEventHandler::dispatchKeyDown(const wxKeyEvent& keyEvent) {
|
||||||
|
|
||||||
const int sym = keyEvent.GetKeyCode();
|
const int sym = keyEvent.GetKeyCode();
|
||||||
|
|
||||||
//printf("keydown: mod: %04X sym: %08X scan:%04X name:%s\n", mod, sym, scan, SDL_GetKeyName(sym));
|
|
||||||
|
|
||||||
if (is_key_down(keyEvent)) {
|
if (is_key_down(keyEvent)) {
|
||||||
++this->keysDown;
|
++this->keysDown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int get(const int i) const { return this->cb[i]; }
|
int get(const int i) const { return this->cb[i]; }
|
||||||
int length() const { return this->cb.size(); }
|
int length() const { return (int)this->cb.size(); }
|
||||||
void getPhase(double phase[]) const
|
void getPhase(double phase[]) const
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates
|
||||||
slts(gui),
|
slts(gui),
|
||||||
kbd(keypresses, buffered),
|
kbd(keypresses, buffered),
|
||||||
keyrepeater(keypresses),
|
keyrepeater(keypresses),
|
||||||
|
paddles(&gui),
|
||||||
rom(AddressBus::MOTHERBOARD_ROM_SIZ),
|
rom(AddressBus::MOTHERBOARD_ROM_SIZ),
|
||||||
ram(revision),
|
ram(revision),
|
||||||
cassetteIn(gui),
|
cassetteIn(gui),
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <SDL_audio.h>
|
|
||||||
#include <SDL_log.h>
|
|
||||||
#include "cassetteout.h"
|
#include "cassetteout.h"
|
||||||
#include "e2const.h"
|
#include "e2const.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -22,7 +22,7 @@ Disk2Drive::Disk2Drive(double p_random_ones_rate):
|
||||||
pulse(false),
|
pulse(false),
|
||||||
bitBufferRead(0),
|
bitBufferRead(0),
|
||||||
random_ones_rate(p_random_ones_rate),
|
random_ones_rate(p_random_ones_rate),
|
||||||
generator(std::chrono::system_clock::now().time_since_epoch().count()),
|
generator((unsigned int)std::chrono::system_clock::now().time_since_epoch().count()),
|
||||||
distribution(0.0,1.0) {
|
distribution(0.0,1.0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
@ -43,8 +41,7 @@ Emulator::Emulator() :
|
||||||
videoStatic(display),
|
videoStatic(display),
|
||||||
apple2(keypresses, paddleButtonStates, display, buffered, screenImage),
|
apple2(keypresses, paddleButtonStates, display, buffered, screenImage),
|
||||||
keyEventHandler(keypresses, apple2.keyrepeater),
|
keyEventHandler(keypresses, apple2.keyrepeater),
|
||||||
timable(nullptr), // No ticked object (NULL pointer)
|
timable(nullptr) {// No ticked object (NULL pointer)
|
||||||
prev_ms(SDL_GetTicks()) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Emulator::~Emulator() {
|
Emulator::~Emulator() {
|
||||||
|
@ -61,7 +58,7 @@ void Emulator::config(E2Config& cfg) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// How many emulation ticks between asking SDL if there is any new input
|
// How many emulation ticks between asking if there is any new input
|
||||||
// from the user or other GUI events.
|
// from the user or other GUI events.
|
||||||
// This is also how often we shall update the estimate of the emulator's
|
// This is also how often we shall update the estimate of the emulator's
|
||||||
// actual speed performance
|
// actual speed performance
|
||||||
|
@ -76,9 +73,6 @@ void Emulator::tick50ms() {
|
||||||
this->timable->tick(); // this runs the emulator!
|
this->timable->tick(); // this runs the emulator!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->screenImage.displayHz((1000*CHECK_EVERY_CYCLE)/(SDL_GetTicks() - this->prev_ms));
|
|
||||||
this->prev_ms = SDL_GetTicks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "KeyRepeatHandler.h"
|
#include "KeyRepeatHandler.h"
|
||||||
#include "KeyEventHandler.h"
|
#include "KeyEventHandler.h"
|
||||||
#include "clipboardhandler.h"
|
#include "clipboardhandler.h"
|
||||||
#include <SDL.h>
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
|
||||||
class Timable;
|
class Timable;
|
||||||
|
@ -47,8 +46,6 @@ class Emulator {
|
||||||
|
|
||||||
Timable* timable;
|
Timable* timable;
|
||||||
|
|
||||||
Uint32 prev_ms;
|
|
||||||
|
|
||||||
void powerOnComputer();
|
void powerOnComputer();
|
||||||
void powerOffComputer();
|
void powerOffComputer();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include <SDL.h>
|
|
||||||
#include <wx/app.h>
|
#include <wx/app.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
#include "paddlebuttonstates.h"
|
#include "paddlebuttonstates.h"
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <wx/utils.h>
|
||||||
|
|
||||||
const int PaddleButtonStates::PADDLE_COUNT(3);
|
const int PaddleButtonStates::PADDLE_COUNT(3);
|
||||||
|
|
||||||
|
@ -35,10 +35,12 @@ bool PaddleButtonStates::isDown(const int paddle)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
unsigned char btn = SDL_GetMouseState(0,0);
|
|
||||||
|
|
||||||
|
// TODO clean up paddle button F keys
|
||||||
if (paddle==0)
|
if (paddle==0)
|
||||||
return btn&SDL_BUTTON_LMASK;
|
return wxGetKeyState(wxKeyCode::WXK_F3);
|
||||||
if (paddle==1)
|
if (paddle==1)
|
||||||
return btn&SDL_BUTTON_RMASK;
|
return wxGetKeyState(wxKeyCode::WXK_F9);
|
||||||
return btn&SDL_BUTTON_MMASK;
|
return wxGetKeyState(wxKeyCode::WXK_F12);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,20 +17,17 @@
|
||||||
*/
|
*/
|
||||||
#include "e2const.h"
|
#include "e2const.h"
|
||||||
#include "paddles.h"
|
#include "paddles.h"
|
||||||
|
#include "screenimage.h"
|
||||||
|
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
Paddles::Paddles(ScreenImage* gui) : scrn(gui), rTick(PADDLE_COUNT) {
|
||||||
|
|
||||||
Paddles::Paddles() : rTick(PADDLE_COUNT) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Paddles::~Paddles() {
|
Paddles::~Paddles() {
|
||||||
|
@ -52,10 +49,13 @@ void Paddles::startTimers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static wxPoint current_mouse_position() {
|
wxPoint Paddles::current_mouse_position() {
|
||||||
int x, y;
|
const auto p = ::wxGetMousePosition();
|
||||||
SDL_GetMouseState(&x, &y);
|
|
||||||
return wxPoint(x, y);
|
int x,y;
|
||||||
|
this->scrn->getPos(&x,&y);
|
||||||
|
|
||||||
|
return p-wxPoint(x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Paddles::tryStartPaddleTimers() {
|
void Paddles::tryStartPaddleTimers() {
|
||||||
|
|
|
@ -18,20 +18,25 @@
|
||||||
#ifndef PADDLES_H
|
#ifndef PADDLES_H
|
||||||
#define PADDLES_H
|
#define PADDLES_H
|
||||||
|
|
||||||
|
#include <wx/utils.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class ScreenImage;
|
||||||
|
|
||||||
class Paddles
|
class Paddles
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
ScreenImage* scrn;
|
||||||
std::vector<int> rTick;
|
std::vector<int> rTick;
|
||||||
|
|
||||||
enum { PADDLE_COUNT = 4 };
|
enum { PADDLE_COUNT = 4 };
|
||||||
enum { PADDLE_CYCLES = 2805 }; // TODO: document where PADDLE_CYCLES==2805 came from
|
enum { PADDLE_CYCLES = 2805 }; // TODO: document where PADDLE_CYCLES==2805 came from
|
||||||
|
|
||||||
void tryStartPaddleTimers();
|
void tryStartPaddleTimers();
|
||||||
|
wxPoint current_mouse_position();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Paddles();
|
Paddles(ScreenImage* gui);
|
||||||
~Paddles();
|
~Paddles();
|
||||||
void tick();
|
void tick();
|
||||||
void startTimers();
|
void startTimers();
|
||||||
|
|
|
@ -193,7 +193,7 @@ void ScreenImage::drawSlot(int slot, int r, int c) {
|
||||||
drawChar(':', r, c++);
|
drawChar(':', r, c++);
|
||||||
drawChar(' ', r, c++);
|
drawChar(' ', r, c++);
|
||||||
drawText(this->slotnames[slot], r, c);
|
drawText(this->slotnames[slot], r, c);
|
||||||
const int len = this->slotnames[slot].length();
|
const int len = (int)this->slotnames[slot].length();
|
||||||
if (len < 100) {
|
if (len < 100) {
|
||||||
drawText(std::string(100 - len, ' '), r, c + len);
|
drawText(std::string(100 - len, ' '), r, c + len);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ void ScreenImage::drawCassette() {
|
||||||
drawText("CASSETTE: IN<-", r, c);
|
drawText("CASSETTE: IN<-", r, c);
|
||||||
c += 15;
|
c += 15;
|
||||||
drawText(this->cassInName, r, c);
|
drawText(this->cassInName, r, c);
|
||||||
int len = this->cassInName.length();
|
int len = (int)this->cassInName.length();
|
||||||
if (len < 40) {
|
if (len < 40) {
|
||||||
drawText(std::string(40 - len, ' '), r, c + len);
|
drawText(std::string(40 - len, ' '), r, c + len);
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ void ScreenImage::drawCassette() {
|
||||||
drawText("OUT->", r, c);
|
drawText("OUT->", r, c);
|
||||||
c += 5;
|
c += 5;
|
||||||
drawText(this->cassOutName, r, c);
|
drawText(this->cassOutName, r, c);
|
||||||
len = this->cassOutName.length();
|
len = (int)this->cassOutName.length();
|
||||||
if (len < 40) {
|
if (len < 40) {
|
||||||
drawText(std::string(40 - len, ' '), r, c + len);
|
drawText(std::string(40 - len, ' '), r, c + len);
|
||||||
}
|
}
|
||||||
|
@ -302,12 +302,6 @@ void ScreenImage::drawChar(const char ch, int row, int col, int color, int bgcol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenImage::displayHz(int hz) {
|
|
||||||
char s[20];
|
|
||||||
sprintf(s, "%5.3f MHz ", hz / 1e6);
|
|
||||||
drawText(s, 3, 141);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenImage::drawPower(bool on) {
|
void ScreenImage::drawPower(bool on) {
|
||||||
unsigned int* pn = this->pixels;
|
unsigned int* pn = this->pixels;
|
||||||
pn += (HEIGHT + 35)*SCRW + 5;
|
pn += (HEIGHT + 35)*SCRW + 5;
|
||||||
|
@ -388,10 +382,10 @@ void ScreenImage::setDiskFile(int slot, int drive, const std::filesystem::path &
|
||||||
int c(37 + 32 * drive);
|
int c(37 + 32 * drive);
|
||||||
drawText(f, r, c);
|
drawText(f, r, c);
|
||||||
|
|
||||||
const int dlen = 12 - f.length();
|
const int dlen = 12 - (int)f.length();
|
||||||
if (dlen > 0) {
|
if (dlen > 0) {
|
||||||
std::string d(dlen, ' ');
|
std::string d(dlen, ' ');
|
||||||
drawText(d, r, c + f.length());
|
drawText(d, r, c + (int)f.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->slotnames[slot].replace(c - 20, 12, 12, ' ');
|
this->slotnames[slot].replace(c - 20, 12, 12, ' ');
|
||||||
|
@ -467,10 +461,10 @@ void ScreenImage::setCassetteInFile(const std::filesystem::path& filepath) {
|
||||||
int c(85 + 11);
|
int c(85 + 11);
|
||||||
drawText(f, r, c);
|
drawText(f, r, c);
|
||||||
|
|
||||||
const int dlen = 12 - f.length();
|
const int dlen = 12 - (int)f.length();
|
||||||
if (dlen > 0) {
|
if (dlen > 0) {
|
||||||
std::string d(dlen, ' ');
|
std::string d(dlen, ' ');
|
||||||
drawText(d, r, c + f.length());
|
drawText(d, r, c + (int)f.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->cassInName.replace(c - 94, 12, 12, ' ');
|
this->cassInName.replace(c - 94, 12, 12, ' ');
|
||||||
|
@ -483,10 +477,10 @@ void ScreenImage::setCassetteOutFile(const std::filesystem::path& filepath) {
|
||||||
int c(85 + 11);
|
int c(85 + 11);
|
||||||
drawText(f, r, c);
|
drawText(f, r, c);
|
||||||
|
|
||||||
const int dlen = 12 - f.length();
|
const int dlen = 12 - (int)f.length();
|
||||||
if (dlen > 0) {
|
if (dlen > 0) {
|
||||||
std::string d(dlen, ' ');
|
std::string d(dlen, ' ');
|
||||||
drawText(d, r, c + f.length());
|
drawText(d, r, c + (int)f.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->cassOutName.replace(c - 94, 12, 12, ' ');
|
this->cassOutName.replace(c - 94, 12, 12, ' ');
|
||||||
|
@ -569,3 +563,7 @@ void ScreenImage::OnKeyDown(wxKeyEvent &evt) {
|
||||||
void ScreenImage::OnKeyUp(wxKeyEvent &evt) {
|
void ScreenImage::OnKeyUp(wxKeyEvent &evt) {
|
||||||
this->keyEventHandler.dispatchKeyUp(evt);
|
this->keyEventHandler.dispatchKeyUp(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenImage::getPos(int* px, int* py) {
|
||||||
|
this->sdl->GetScreenPosition(px,py);
|
||||||
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@ public:
|
||||||
void drawFnKeys();
|
void drawFnKeys();
|
||||||
void toggleKdbBufferLabel();
|
void toggleKdbBufferLabel();
|
||||||
void cycleDisplayLabel();
|
void cycleDisplayLabel();
|
||||||
void displayHz(int hz);
|
|
||||||
void toggleFillLinesLabel();
|
void toggleFillLinesLabel();
|
||||||
void invertText(int row, int begincol, int endcol);
|
void invertText(int row, int begincol, int endcol);
|
||||||
void drawDisplayLabel();
|
void drawDisplayLabel();
|
||||||
|
@ -110,6 +109,8 @@ public:
|
||||||
void setFirmCard(int slot, bool bank, bool F8);
|
void setFirmCard(int slot, bool bank, bool F8);
|
||||||
|
|
||||||
void saveBMP();
|
void saveBMP();
|
||||||
|
|
||||||
|
void getPos(int* px, int* py);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,7 @@ VideoStaticGenerator::VideoStaticGenerator(AnalogTV& display):
|
||||||
hpos(0)
|
hpos(0)
|
||||||
{
|
{
|
||||||
this->display.signal = sig;
|
this->display.signal = sig;
|
||||||
srand(time(0));
|
srand((unsigned int)time(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue