mirror of
https://github.com/LIV2/amiberry.git
synced 2025-12-05 22:22:44 +00:00
Reduce compiler warnings (#1566)
* refactor: fix compiler and clang-tidy warnings * minor code improvements and modernization * refactor: fix sprintf is deperecated warnings * refactor: convert gfxboard encoding to UTF-8
This commit is contained in:
parent
b9c5e60031
commit
2c39559952
8
external/capsimage/src/Core/DiskFile.cpp
vendored
8
external/capsimage/src/Core/DiskFile.cpp
vendored
@ -68,15 +68,13 @@ int CDiskFile::OpenAny(char **name, unsigned int mode)
|
||||
// return the path index 0...n on the first successful attempt, -1 if all failed
|
||||
int CDiskFile::OpenAnyPath(char **path, const char *name, unsigned int mode)
|
||||
{
|
||||
int pos;
|
||||
|
||||
// if name and path list are valid
|
||||
if (name && path) {
|
||||
// try each path entry in order
|
||||
for (pos=0; path[pos]; pos++) {
|
||||
for (int pos = 0; path[pos]; pos++) {
|
||||
// append name to current path entry
|
||||
int len=sprintf(tempname, "%s", path[pos]);
|
||||
sprintf(tempname+len, "%s", name);
|
||||
const int len=snprintf(tempname, sizeof tempname, "%s", path[pos]);
|
||||
snprintf(tempname+len, sizeof tempname, "%s", name);
|
||||
|
||||
// open the file, return the name index position on success
|
||||
if (!Open(tempname, mode))
|
||||
|
||||
@ -124,9 +124,9 @@ bool ArduinoFloppyDiskBridge::openInterface(std::string& errorMessage) {
|
||||
// Must be at least V1.8
|
||||
char buf[20];
|
||||
#ifdef _WIN32
|
||||
sprintf_s(buf, "%i.%i.%i", fv.major, fv.minor, fv.buildNumber);
|
||||
snprintf_s(buf, sizeof buf, "%i.%i.%i", fv.major, fv.minor, fv.buildNumber);
|
||||
#else
|
||||
sprintf(buf, "%i.%i.%i", fv.major, fv.minor, fv.buildNumber);
|
||||
snprintf(buf, sizeof buf, "%i.%i.%i", fv.major, fv.minor, fv.buildNumber);
|
||||
#endif
|
||||
errorMessage = "DrawBridge aka Arduino Floppy Reader/Writer Firmware is Out Of Date\n\nWinUAE requires V1.8 (and ideally with the modded circuit design).\n\n";
|
||||
errorMessage += "You are currently using V" + std::string(buf) + ". Please update the firmware.";
|
||||
|
||||
10
external/floppybridge/src/ArduinoInterface.cpp
vendored
10
external/floppybridge/src/ArduinoInterface.cpp
vendored
@ -837,21 +837,21 @@ DiagnosticResponse ArduinoInterface::selectTrack(const unsigned char trackIndex,
|
||||
char flags = (int)searchSpeed;
|
||||
if (!ignoreDiskInsertCheck) flags |= 4;
|
||||
#ifdef _WIN32
|
||||
sprintf_s(buf, "%c%02i%c", COMMAND_GOTOTRACK_REPORT, trackIndex, flags);
|
||||
snprintf_s(buf, sizeof buf, "%c%02i%c", COMMAND_GOTOTRACK_REPORT, trackIndex, flags);
|
||||
#else
|
||||
sprintf(buf, "%c%02i%c", COMMAND_GOTOTRACK_REPORT, trackIndex, flags);
|
||||
snprintf(buf, sizeof buf, "%c%02i%c", COMMAND_GOTOTRACK_REPORT, trackIndex, flags);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#ifdef _WIN32
|
||||
sprintf_s(buf, "%c%02i", COMMAND_GOTOTRACK, trackIndex);
|
||||
snprintf_s(buf, sizeof buf, "%c%02i", COMMAND_GOTOTRACK, trackIndex);
|
||||
#else
|
||||
sprintf(buf, "%c%02i", COMMAND_GOTOTRACK, trackIndex);
|
||||
snprintf(buf, sizeof buf, "%c%02i", COMMAND_GOTOTRACK, trackIndex);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Send track number.
|
||||
if (!deviceWrite(buf, (unsigned int)strlen(buf))) {
|
||||
if (!deviceWrite(buf, static_cast<unsigned int>(strlen(buf)))) {
|
||||
m_lastError = DiagnosticResponse::drSendFailed;
|
||||
return m_lastError;
|
||||
}
|
||||
|
||||
108
external/floppybridge/src/CommonBridgeTemplate.h
vendored
108
external/floppybridge/src/CommonBridgeTemplate.h
vendored
@ -185,11 +185,11 @@ private:
|
||||
// Current disk cache history
|
||||
struct MFMCaches {
|
||||
// Currently being read by WinUAE version of this track
|
||||
MFMCache current;
|
||||
MFMCache current{};
|
||||
// The last buffer we swapped out. We keep several buffers on the go to combat 'weak transitions' and also help with disk errors
|
||||
MFMCache last;
|
||||
MFMCache last{};
|
||||
// The track we're about to read in
|
||||
MFMCache next;
|
||||
MFMCache next{};
|
||||
// For tracking what the index looks like
|
||||
RotationExtractor::IndexSequenceMarker startBitPatterns;
|
||||
};
|
||||
@ -301,11 +301,11 @@ private:
|
||||
void mainThread();
|
||||
|
||||
// Add a command for the thread to process
|
||||
void queueCommand(const QueueCommand command, const bool optionB, const bool shouldAbortStreaming = true);
|
||||
void queueCommand(const QueueCommand command, const int optionI = 0, const bool shouldAbortStreaming = true);
|
||||
void queueCommand(QueueCommand command, bool optionB, bool shouldAbortStreaming = true);
|
||||
void queueCommand(QueueCommand command, int optionI = 0, bool shouldAbortStreaming = true);
|
||||
|
||||
// Push a specific message onto the queue
|
||||
void pushOntoQueue(const QueueInfo& info, const bool shouldAbortStreaming = true, bool insertAtStart = false);
|
||||
void pushOntoQueue(const QueueInfo& info, bool shouldAbortStreaming = true, bool insertAtStart = false);
|
||||
|
||||
// Handle processing the command
|
||||
void processCommand(const QueueInfo& info);
|
||||
@ -320,16 +320,16 @@ private:
|
||||
void terminate();
|
||||
|
||||
// Handle disk side change
|
||||
void switchDiskSide(const bool side);
|
||||
void switchDiskSide(bool side);
|
||||
|
||||
// Process the queue. Return TRUE if the thread should quit
|
||||
bool processQueue();
|
||||
|
||||
// This is called to switch to a different copy of the track so multiple revolutions can ve read
|
||||
void internalSwitchCylinder(const int cylinder, const DiskSurface side);
|
||||
void internalSwitchCylinder(int cylinder, DiskSurface side);
|
||||
|
||||
// Save a new disk side and switch it in if it can be
|
||||
void saveNextBuffer(const int cylinder, const DiskSurface side);
|
||||
void saveNextBuffer(int cylinder, DiskSurface side);
|
||||
|
||||
// Reset and clear out any data we have received thus far
|
||||
void resetWriteBuffer();
|
||||
@ -338,7 +338,7 @@ private:
|
||||
void internalCheckDiskDensity(bool newDiskInserted);
|
||||
|
||||
// Scans the MFM data to see if this track should allow smart speed or not based on timing data
|
||||
void checkSmartSpeed(const int cylinder, const DiskSurface side, MFMCache& track);
|
||||
void checkSmartSpeed(int cylinder, DiskSurface side, MFMCache& track);
|
||||
|
||||
// Check if the motor should be turned off
|
||||
void checkMotorOff();
|
||||
@ -351,7 +351,7 @@ protected:
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Return the number of milliseconds required for the disk to spin up. You *may* need to override this
|
||||
virtual const unsigned int getDriveSpinupTime() { return 500; }
|
||||
virtual unsigned int getDriveSpinupTime() { return 500; }
|
||||
|
||||
// Called when a disk is inserted so that you can (re)populate the response to _getDriveTypeID()
|
||||
virtual void checkDiskType() {}
|
||||
@ -370,7 +370,7 @@ protected:
|
||||
|
||||
// If the above is TRUE then this is called to get the status of the DiskChange line. Basically, this is TRUE if there is a disk in the drive.
|
||||
// If force is true you should re-check, if false, then you are allowed to return a cached value from the last disk operation (eg: seek)
|
||||
virtual bool getDiskChangeStatus(const bool forceCheck) = 0;
|
||||
virtual bool getDiskChangeStatus(bool forceCheck) = 0;
|
||||
|
||||
// Called when the class is about to shut down
|
||||
virtual void closeInterface() = 0;
|
||||
@ -380,7 +380,7 @@ protected:
|
||||
|
||||
// Called to ask the drive what the current write protect status is - return true if its write protected. If forceCheck is true you should actually check the drive,
|
||||
// else use the last status checked which was probably from a SEEK setCurrentCylinder call. If you can ONLY get this information here then you should always force check
|
||||
virtual bool checkWriteProtectStatus(const bool forceCheck) = 0;
|
||||
virtual bool checkWriteProtectStatus(bool forceCheck) = 0;
|
||||
|
||||
// Get the name of the drive
|
||||
virtual const BridgeDriver* _getDriverInfo() = 0;
|
||||
@ -389,13 +389,13 @@ protected:
|
||||
virtual const DriveTypeID _getDriveTypeID() = 0;
|
||||
|
||||
// Called to switch which head is being used right now. Returns success or not
|
||||
virtual bool setActiveSurface(const DiskSurface activeSurface) = 0;
|
||||
virtual bool setActiveSurface(DiskSurface activeSurface) = 0;
|
||||
|
||||
// Set the status of the motor on the drive. The motor should maintain this status until switched off or reset. This should *NOT* wait for the motor to spin up
|
||||
virtual bool setMotorStatus(const bool switchedOn) = 0;
|
||||
virtual bool setMotorStatus(bool switchedOn) = 0;
|
||||
|
||||
// Trigger a seek to the requested cylinder, this can block until complete
|
||||
virtual bool setCurrentCylinder(const unsigned int cylinder) = 0;
|
||||
virtual bool setCurrentCylinder(unsigned int cylinder) = 0;
|
||||
|
||||
// If we're on track 0, this is the emulator trying to seek to track -1. We catch this as a special case.
|
||||
// Should perform the same operations as setCurrentCylinder in terms of disk change etc but without changing the current cylinder
|
||||
@ -409,8 +409,8 @@ protected:
|
||||
// indexMarker: Used by rotationExtractor if you use it, to help be consistent where the INDEX position is read back at
|
||||
// onRotation: A function you should call for each complete revolution received. If the function returns FALSE then you should abort reading, else keep sending revolutions
|
||||
// Returns: ReadResponse, explains its self
|
||||
virtual ReadResponse readData(PLL::BridgePLL& pll, const unsigned int maxBufferSize, RotationExtractor::MFMSample* buffer, RotationExtractor::IndexSequenceMarker& indexMarker,
|
||||
std::function<bool(RotationExtractor::MFMSample* mfmData, const unsigned int dataLengthInBits)> onRotation) = 0;
|
||||
virtual ReadResponse readData(PLL::BridgePLL& pll, unsigned int maxBufferSize, RotationExtractor::MFMSample* buffer, RotationExtractor::IndexSequenceMarker& indexMarker,
|
||||
std::function<bool(RotationExtractor::MFMSample* mfmData, unsigned int dataLengthInBits)> onRotation) = 0;
|
||||
|
||||
// Called for a direct read. This does not match up a rotation and should be used with the pll initialized with the LinearExtractor
|
||||
// pll: required
|
||||
@ -423,7 +423,7 @@ protected:
|
||||
// writeFromIndex If an attempt should be made to write this from the INDEX pulse rather than just a random position
|
||||
// suggestUsingPrecompensation A suggestion that you might want to use write pre-compensation, optional
|
||||
// Returns TRUE if success, or false if it fails. Largely doesn't matter as most stuff should verify with a read straight after
|
||||
virtual bool writeData(const unsigned char* rawMFMData, const unsigned int numBits, const bool writeFromIndex, const bool suggestUsingPrecompensation) = 0;
|
||||
virtual bool writeData(const unsigned char* rawMFMData, unsigned int numBits, bool writeFromIndex, bool suggestUsingPrecompensation) = 0;
|
||||
|
||||
// A manual way to check for disk change. This is simulated by issuing a read message and seeing if there's any data. Returns TRUE if data or an INDEX pulse was detected
|
||||
// It's virtual as the default method issues a read and looks for data. If you have a better implementation then override this
|
||||
@ -436,7 +436,7 @@ public:
|
||||
//
|
||||
// Flags from WINUAE
|
||||
CommonBridgeTemplate(FloppyBridge::BridgeMode bridgeMode, FloppyBridge::BridgeDensityMode bridgeDensity, bool shouldAutoCache, bool useSmartSpeed);
|
||||
virtual ~CommonBridgeTemplate();
|
||||
~CommonBridgeTemplate() override;
|
||||
|
||||
// Change to a different bridge-mode (in real-time)
|
||||
void changeBridgeMode(FloppyBridge::BridgeMode bridgeMode);
|
||||
@ -445,109 +445,109 @@ public:
|
||||
void changeBridgeDensity(FloppyBridge::BridgeDensityMode bridgeDensity);
|
||||
|
||||
// Call to start the system up
|
||||
virtual bool initialise() override final;
|
||||
bool initialise() final;
|
||||
|
||||
// This is called prior to closing down, but should reverse initialise
|
||||
virtual void shutdown() override final;
|
||||
void shutdown() final;
|
||||
|
||||
// Returns the name of interface. This pointer should remain valid after the class is destroyed
|
||||
virtual const BridgeDriver* getDriverInfo() override final { return _getDriverInfo(); }
|
||||
const BridgeDriver* getDriverInfo() final { return _getDriverInfo(); }
|
||||
|
||||
// Return the type of disk connected
|
||||
virtual DriveTypeID getDriveTypeID() override final { return _getDriveTypeID(); }
|
||||
DriveTypeID getDriveTypeID() final { return _getDriveTypeID(); }
|
||||
|
||||
// Call to get the last error message. If the string is empty there was no error
|
||||
virtual const char* getLastErrorMessage() override final;
|
||||
const char* getLastErrorMessage() final;
|
||||
|
||||
// Return TRUE if the drive is currently on cylinder 0
|
||||
virtual bool isAtCylinder0() override final { return m_currentTrack == 0; }
|
||||
bool isAtCylinder0() final { return m_currentTrack == 0; }
|
||||
|
||||
// Return the number of cylinders the drive supports.
|
||||
virtual unsigned char getMaxCylinder() override final { return MAX_CYLINDER_BRIDGE; }
|
||||
unsigned char getMaxCylinder() final { return MAX_CYLINDER_BRIDGE; }
|
||||
|
||||
// Return true if the motor is spinning
|
||||
virtual bool isMotorRunning() override final { return m_isMotorRunning; }
|
||||
bool isMotorRunning() final { return m_isMotorRunning; }
|
||||
|
||||
// Returns TRUE when the last command requested has completed
|
||||
virtual bool isReady() override;
|
||||
bool isReady() override;
|
||||
|
||||
// Return TRUE if there is a disk in the drive, else return false. Some drives don't detect this until the head moves once
|
||||
virtual bool isDiskInDrive() override final { return m_diskInDrive; }
|
||||
bool isDiskInDrive() final { return m_diskInDrive; }
|
||||
|
||||
// Check if the disk has changed. Basically returns FALSE if there's no disk in the drive
|
||||
virtual bool hasDiskChanged() override final { return !m_diskInDrive; }
|
||||
bool hasDiskChanged() final { return !m_diskInDrive; }
|
||||
|
||||
// Returns the currently selected side
|
||||
virtual bool getCurrentSide() override final { return m_floppySide == DiskSurface::dsUpper; }
|
||||
bool getCurrentSide() final { return m_floppySide == DiskSurface::dsUpper; }
|
||||
|
||||
// Return the current track number we're on
|
||||
virtual unsigned char getCurrentCylinderNumber() override final { return m_currentTrack; }
|
||||
unsigned char getCurrentCylinderNumber() final { return m_currentTrack; }
|
||||
|
||||
// Return TRUE if the currently inserted disk is write protected
|
||||
virtual bool isWriteProtected() override final { return m_writeProtected; }
|
||||
bool isWriteProtected() final { return m_writeProtected; }
|
||||
|
||||
// Get the speed at this position. 1000=100%.
|
||||
virtual int getMFMSpeed(const int mfmPositionBits) override final;
|
||||
int getMFMSpeed(int mfmPositionBits) final;
|
||||
|
||||
// Returns TRUE if data is ready and available
|
||||
virtual bool isMFMDataAvailable() override final;
|
||||
bool isMFMDataAvailable() final;
|
||||
|
||||
// Requests an entire track of data. Returns 0 if the track is not available
|
||||
// The return value is the wrap point in bits (last byte is shifted to MSB)
|
||||
virtual int getMFMTrack(bool side, unsigned int track, bool resyncRotation, const int bufferSizeInBytes, void* output) override final;
|
||||
int getMFMTrack(bool side, unsigned int track, bool resyncRotation, int bufferSizeInBytes, void* output) final;
|
||||
|
||||
// write data to the MFM track buffer to be written to disk - poll isWriteComplete to check for completion
|
||||
virtual bool writeMFMTrackToBuffer(bool side, unsigned int track, bool writeFromIndex, int sizeInBytes, void* mfmData) override final;
|
||||
bool writeMFMTrackToBuffer(bool side, unsigned int track, bool writeFromIndex, int sizeInBytes, void* mfmData) final;
|
||||
|
||||
// A special mode that DISABLES FloppyBridge from auto-reading tracks and allows writeMFMTrackToBuffer and getMFMTrack to operate directly.
|
||||
virtual bool setDirectMode(bool directModeEnable) override final;
|
||||
bool setDirectMode(bool directModeEnable) final;
|
||||
|
||||
// While not doing anything else, the library should be continuously streaming the current track if the motor is on. mfmBufferPosition is in BITS
|
||||
virtual bool getMFMBit(const int mfmPositionBits) override final;
|
||||
bool getMFMBit(int mfmPositionBits) final;
|
||||
|
||||
// Set the status of the motor.
|
||||
virtual void setMotorStatus(bool side, bool turnOn) override final;
|
||||
void setMotorStatus(bool side, bool turnOn) final;
|
||||
|
||||
// Return the maximum size of the internal track buffer in BITS
|
||||
virtual int maxMFMBitPosition() override final;
|
||||
int maxMFMBitPosition() final;
|
||||
|
||||
// This is called to switch to a different copy of the track so multiple revolutions can ve read
|
||||
virtual void mfmSwitchBuffer(bool side) override final;
|
||||
void mfmSwitchBuffer(bool side) final;
|
||||
|
||||
// Quick confirmation from UAE that we're actually on the same side
|
||||
virtual void setSurface(bool side) override final;
|
||||
void setSurface(bool side) final;
|
||||
|
||||
// Seek to a specific track
|
||||
virtual void gotoCylinder(int trackNumber, bool side) override final;
|
||||
void gotoCylinder(int trackNumber, bool side) final;
|
||||
|
||||
// Handle the drive stepping to track -1 - this is used to 'no-click' detect the disk
|
||||
virtual void handleNoClickStep(bool side) override final;
|
||||
void handleNoClickStep(bool side) final;
|
||||
|
||||
// Submits a single WORD of data received during a DMA transfer to the disk buffer. This needs to be saved. It is usually flushed when commitWriteBuffer is called
|
||||
// You should reset this buffer if side or track changes. mfmPosition is provided purely for any index sync you may wish to do
|
||||
virtual void writeShortToBuffer(bool side, unsigned int track, unsigned short mfmData, int mfmPosition) override final;
|
||||
void writeShortToBuffer(bool side, unsigned int track, unsigned short mfmData, int mfmPosition) final;
|
||||
|
||||
// Requests that any data received via writeShortToBuffer be saved to disk. The side and track should match against what you have been collected
|
||||
// and the buffer should be reset upon completion. You should return the new track length (maxMFMBitPosition) with optional padding if needed
|
||||
virtual unsigned int commitWriteBuffer(bool side, unsigned int track) override final;
|
||||
unsigned int commitWriteBuffer(bool side, unsigned int track) final;
|
||||
|
||||
// Returns TRUE if commitWriteBuffer has been called but not written to disk yet
|
||||
virtual bool isWritePending() override final;
|
||||
bool isWritePending() final;
|
||||
|
||||
// Returns TRUE if a write is no longer pending. This should only return TRUE the first time, and then should reset
|
||||
virtual bool isWriteComplete() override final;
|
||||
bool isWriteComplete() final;
|
||||
|
||||
// Return TRUE if there is data ready to be committed to disk
|
||||
virtual bool isReadyToWrite() override final;
|
||||
bool isReadyToWrite() final;
|
||||
|
||||
// Return TRUE if we're at the INDEX marker
|
||||
virtual bool isMFMPositionAtIndex(int mfmPositionBits) override final;
|
||||
bool isMFMPositionAtIndex(int mfmPositionBits) final;
|
||||
|
||||
// Reset the drive. This should reset it to the state it would be at power up
|
||||
virtual bool resetDrive(int trackNumber) override final;
|
||||
bool resetDrive(int trackNumber) final;
|
||||
|
||||
// Set to TRUE if turbo writing is allowed (this is a sneaky DMA bypass trick)
|
||||
virtual bool canTurboWrite() { return true; }
|
||||
bool canTurboWrite() override { return true; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
11
external/floppybridge/src/FloppyBridge.cpp
vendored
11
external/floppybridge/src/FloppyBridge.cpp
vendored
@ -630,7 +630,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
if (errorMessage)
|
||||
if (strlen(bridgeDriverHandle->lastMessage)) *errorMessage = bridgeDriverHandle->lastMessage; else *errorMessage = NULL;
|
||||
{
|
||||
if (strlen(bridgeDriverHandle->lastMessage))
|
||||
{
|
||||
*errorMessage = bridgeDriverHandle->lastMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
*errorMessage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
// Restore virtual drive
|
||||
|
||||
2
external/floppybridge/src/SerialIO.cpp
vendored
2
external/floppybridge/src/SerialIO.cpp
vendored
@ -47,7 +47,7 @@ DEFINE_GUID(GUID_DEVINTERFACE_COMPORT,0x86e0d1e0, 0x8089, 0x11d0, 0x9c, 0xe4, 0x
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <term.h>
|
||||
#include <sys/termios.h>
|
||||
|
||||
@ -95,7 +95,7 @@ namespace gcn
|
||||
* only use SDL and plan sticking with SDL you can safely ignore this
|
||||
* function as it in the SDL case does nothing.
|
||||
*/
|
||||
virtual void _pollInput() { }
|
||||
void _pollInput() override { }
|
||||
|
||||
|
||||
// Inherited from Input
|
||||
|
||||
4
external/libguisan/include/guisan/widget.hpp
vendored
4
external/libguisan/include/guisan/widget.hpp
vendored
@ -1135,7 +1135,7 @@ namespace gcn
|
||||
* @see remove, clear
|
||||
* @since 1.1.0
|
||||
*/
|
||||
void add(Widget* widget);
|
||||
virtual void add(Widget* widget);
|
||||
|
||||
/**
|
||||
* Removes a child from the widget.
|
||||
@ -1186,7 +1186,7 @@ namespace gcn
|
||||
* @return A list of the widgets children.
|
||||
* @since 1.1.0
|
||||
*/
|
||||
const std::list<Widget*>& getChildren() const;
|
||||
virtual const std::list<Widget*>& getChildren() const;
|
||||
|
||||
/**
|
||||
* Holds the mouse listeners of the widget.
|
||||
|
||||
@ -103,7 +103,7 @@ namespace gcn
|
||||
* @param opaque True if the container should be opaque, false otherwise.
|
||||
* @see isOpaque
|
||||
*/
|
||||
void setOpaque(bool opaque);
|
||||
virtual void setOpaque(bool opaque);
|
||||
|
||||
/**
|
||||
* Checks if the container is opaque or not.
|
||||
@ -111,7 +111,7 @@ namespace gcn
|
||||
* @return True if the container is opaque, false otherwise.
|
||||
* @see setOpaque
|
||||
*/
|
||||
bool isOpaque() const;
|
||||
[[nodiscard]] bool isOpaque() const;
|
||||
|
||||
/**
|
||||
* Adds a widget to the container.
|
||||
@ -119,7 +119,7 @@ namespace gcn
|
||||
* @param widget The widget to add.
|
||||
* @see remove, clear
|
||||
*/
|
||||
virtual void add(Widget* widget);
|
||||
void add(Widget* widget) override;
|
||||
|
||||
/**
|
||||
* Adds a widget to the container and also specifies the widget's
|
||||
@ -141,14 +141,14 @@ namespace gcn
|
||||
* container.
|
||||
* @see add, clear
|
||||
*/
|
||||
virtual void remove(Widget* widget);
|
||||
void remove(Widget* widget) override;
|
||||
|
||||
/**
|
||||
* Clears the container of all widgets.
|
||||
*
|
||||
* @see add, remove
|
||||
*/
|
||||
virtual void clear();
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* Finds a widget given an id.
|
||||
@ -158,7 +158,7 @@ namespace gcn
|
||||
* is found.
|
||||
* @see Widget::setId
|
||||
*/
|
||||
virtual Widget* findWidgetById(const std::string &id);
|
||||
Widget* findWidgetById(const std::string &id) override;
|
||||
|
||||
/**
|
||||
* Adds a container listener to the container. When a widget is
|
||||
@ -183,12 +183,12 @@ namespace gcn
|
||||
*
|
||||
* @return The children of the container.
|
||||
*/
|
||||
const std::list<Widget*>& getChildren() const;
|
||||
[[nodiscard]] const std::list<Widget*>& getChildren() const override;
|
||||
|
||||
/**
|
||||
* Resizes the Container's size to fit te content exactly.
|
||||
*/
|
||||
void resizeToContent();
|
||||
virtual void resizeToContent();
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ namespace gcn
|
||||
*
|
||||
* @param caption the caption of the window.
|
||||
*/
|
||||
Window(const std::string& caption);
|
||||
explicit Window(const std::string& caption);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
@ -104,7 +104,7 @@ namespace gcn
|
||||
* @return the caption of the window.
|
||||
* @see setCaption
|
||||
*/
|
||||
const std::string& getCaption() const;
|
||||
[[nodiscard]] const std::string& getCaption() const;
|
||||
|
||||
/**
|
||||
* Sets the alignment of the caption.
|
||||
@ -120,7 +120,7 @@ namespace gcn
|
||||
* @return The alignment of caption.
|
||||
* @see setAlignment, Graphics
|
||||
*/
|
||||
Graphics::Alignment getAlignment() const;
|
||||
[[nodiscard]] Graphics::Alignment getAlignment() const;
|
||||
|
||||
/**
|
||||
* Sets the padding of the window. The padding is the distance between the
|
||||
@ -138,7 +138,7 @@ namespace gcn
|
||||
* @return The padding of the window.
|
||||
* @see setPadding
|
||||
*/
|
||||
unsigned int getPadding() const;
|
||||
[[nodiscard]] unsigned int getPadding() const;
|
||||
|
||||
/**
|
||||
* Sets the title bar height.
|
||||
@ -170,7 +170,7 @@ namespace gcn
|
||||
* @return True if the window is movable, false otherwise.
|
||||
* @see setMovable
|
||||
*/
|
||||
bool isMovable() const;
|
||||
[[nodiscard]] bool isMovable() const;
|
||||
|
||||
/**
|
||||
* Sets the window to be opaque or not. An opaque window will draw its background
|
||||
@ -179,7 +179,7 @@ namespace gcn
|
||||
* @param opaque True if the window should be opaque, false otherwise.
|
||||
* @see isOpaque
|
||||
*/
|
||||
void setOpaque(bool opaque);
|
||||
void setOpaque(bool opaque) override;
|
||||
|
||||
/**
|
||||
* Checks if the window is opaque.
|
||||
@ -192,7 +192,7 @@ namespace gcn
|
||||
/**
|
||||
* Resizes the window to fit the content.
|
||||
*/
|
||||
virtual void resizeToContent();
|
||||
void resizeToContent() override;
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
|
||||
2
external/mt32emu/src/MidiStreamParser.cpp
vendored
2
external/mt32emu/src/MidiStreamParser.cpp
vendored
@ -191,7 +191,7 @@ Bit32u MidiStreamParserImpl::parseShortMessageDataBytes(const Bit8u stream[], Bi
|
||||
} else if (dataByte < 0xF8) {
|
||||
// Discard invalid bytes and start over
|
||||
char s[128];
|
||||
sprintf(s, "parseShortMessageDataBytes: Invalid short message: status %02x, expected length %i, actual %i -> ignored", *streamBuffer, shortMessageLength, streamBufferSize);
|
||||
snprintf(s, sizeof s, "parseShortMessageDataBytes: Invalid short message: status %02x, expected length %i, actual %i -> ignored", *streamBuffer, shortMessageLength, streamBufferSize);
|
||||
midiReporter.printDebug(s);
|
||||
streamBufferSize = 0; // Clear streamBuffer
|
||||
return parsedLength;
|
||||
|
||||
2
external/mt32emu/src/Part.cpp
vendored
2
external/mt32emu/src/Part.cpp
vendored
@ -54,7 +54,7 @@ Part::Part(Synth *useSynth, unsigned int usePartNum) {
|
||||
// Nasty hack for rhythm
|
||||
timbreTemp = NULL;
|
||||
} else {
|
||||
sprintf(name, "Part %d", partNum + 1);
|
||||
snprintf(name, sizeof name, "Part %d", partNum + 1);
|
||||
timbreTemp = &synth->mt32ram.timbreTemp[partNum];
|
||||
}
|
||||
currentInstr[0] = 0;
|
||||
|
||||
@ -141,7 +141,7 @@ static int load_rom8 (const TCHAR *xpath, uae_u8 *mem, int extra, const TCHAR *e
|
||||
|
||||
extra &= 3;
|
||||
memset (tmp, 0xff, 131072);
|
||||
_stprintf (path, _T("%s%s%s"), xpath, extra == 3 ? _T("-hi") : (extra == 2 ? _T("hi") : (extra == 1 ? _T("h") : _T(""))), bin);
|
||||
_sntprintf (path, sizeof path, _T("%s%s%s"), xpath, extra == 3 ? _T("-hi") : (extra == 2 ? _T("hi") : (extra == 1 ? _T("h") : _T(""))), bin);
|
||||
if (ext)
|
||||
_tcscat(path, ext);
|
||||
if (exts) {
|
||||
@ -156,7 +156,7 @@ static int load_rom8 (const TCHAR *xpath, uae_u8 *mem, int extra, const TCHAR *e
|
||||
if (zfile_fread (tmp, 65536, 1, zf) == 0)
|
||||
goto end;
|
||||
zfile_fclose (zf);
|
||||
_stprintf (path, _T("%s%s%s"), xpath, extra == 3 ? _T("-lo") : (extra == 2 ? _T("lo") : (extra == 1 ? _T("l") : _T(""))), bin);
|
||||
_sntprintf (path, sizeof path, _T("%s%s%s"), xpath, extra == 3 ? _T("-lo") : (extra == 2 ? _T("lo") : (extra == 1 ? _T("l") : _T(""))), bin);
|
||||
if (ext)
|
||||
_tcscat(path, ext);
|
||||
if (exts)
|
||||
@ -242,10 +242,10 @@ static int load_roms (struct arcadiarom *rom)
|
||||
i = 0;
|
||||
for (;;) {
|
||||
if (rom->extra & 4)
|
||||
_stprintf (path, _T("%s%d"), xpath, i + 1);
|
||||
_sntprintf (path, sizeof path, _T("%s%d"), xpath, i + 1);
|
||||
else
|
||||
_tcscpy (path, xpath);
|
||||
if (!load_rom8 (path, arbmemory + 2 * 65536 * i + offset, rom->extra, rom->ext, rom->exts && rom->exts[0] ? &rom->exts[i * 2] : NULL)) {
|
||||
if (!load_rom8 (path, arbmemory + 2 * 65536 * i + offset, rom->extra, rom->ext, rom->exts[0] ? &rom->exts[i * 2] : NULL)) {
|
||||
if (i == 0)
|
||||
write_log (_T("Arcadia: %s rom load failed ('%s')\n"), rom->type == ARCADIA_BIOS ? _T("bios") : _T("game"), path);
|
||||
break;
|
||||
@ -1767,10 +1767,10 @@ int touch_serial_write(void)
|
||||
y = 999 - y;
|
||||
|
||||
*p++ = 0x01;
|
||||
sprintf((char*)p, "%03d", x);
|
||||
_sntprintf((char*)p, sizeof p, "%03d", x);
|
||||
p += 3;
|
||||
*p++ = ',';
|
||||
sprintf((char*)p, "%03d", y);
|
||||
_sntprintf((char*)p, sizeof p, "%03d", y);
|
||||
p += 3;
|
||||
*p++ = 0x0d;
|
||||
touch_write_buf_offset = addrdiff(p, touch_data_w);
|
||||
|
||||
@ -682,7 +682,7 @@ void init_header(char *name, struct stat *v_stat, LzHeader *hdr)
|
||||
hdr->original_size = 0;
|
||||
len = readlink(name, lkname, 256);
|
||||
lkname[len] = (char)'\0';
|
||||
sprintf(hdr->name, "%s|%s", hdr->name, lkname);
|
||||
_sntprintf(hdr->name, sizeof hdr->name, "%s|%s", hdr->name, lkname);
|
||||
}
|
||||
#endif
|
||||
if (generic_format)
|
||||
|
||||
@ -279,7 +279,7 @@ void audio_sampleripper (int mode)
|
||||
cfgfile_resolve_path_load(name, sizeof(name) / sizeof(TCHAR), type);
|
||||
namesplit (name);
|
||||
_tcscpy (extension, _T("wav"));
|
||||
_stprintf (filename, _T("%s%s%s%03d.%s"), path, name, underline, cnt, extension);
|
||||
_sntprintf (filename, sizeof filename, _T("%s%s%s%03d.%s"), path, name, underline, cnt, extension);
|
||||
wavfile = zfile_fopen (filename, _T("wb"), 0);
|
||||
if (wavfile) {
|
||||
int freq = rs->per > 0 ? (currprefs.ntscmode ? 3579545 : 3546895 / rs->per) : 8000;
|
||||
|
||||
@ -607,7 +607,7 @@ void rtarea_init(void)
|
||||
rtarea_init_mem ();
|
||||
memset (rtarea_bank.baseaddr, 0, RTAREA_SIZE);
|
||||
|
||||
_stprintf (uaever, _T("uae-%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
|
||||
_sntprintf (uaever, sizeof uaever, _T("uae-%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
|
||||
|
||||
EXPANSION_uaeversion = ds (uaever);
|
||||
EXPANSION_explibname = ds (_T("expansion.library"));
|
||||
|
||||
@ -408,7 +408,7 @@ static int get_standard_cd_unit2 (struct uae_prefs *p, cd_standard_unit csu)
|
||||
#endif
|
||||
if (isaudio) {
|
||||
TCHAR vol[100];
|
||||
_stprintf (vol, _T("%c:\\"), isaudio);
|
||||
_sntprintf (vol, sizeof vol, _T("%c:\\"), isaudio);
|
||||
if (sys_command_open_internal (unitnum, vol, csu))
|
||||
return unitnum;
|
||||
}
|
||||
|
||||
@ -2220,7 +2220,7 @@ static struct device_info *info_device (int unitnum, struct device_info *di, int
|
||||
_tcscpy (di->label, _T("IMG:<EMPTY>"));
|
||||
}
|
||||
_tcscpy (di->vendorid, _T("UAE"));
|
||||
_stprintf (di->productid, _T("SCSICD%d"), unitnum);
|
||||
_sntprintf (di->productid, sizeof di->productid, _T("SCSICD%d"), unitnum);
|
||||
_tcscpy (di->revision, _T("1.0"));
|
||||
di->backend = _T("IMAGE");
|
||||
return di;
|
||||
|
||||
@ -1799,7 +1799,7 @@ static uae_u32 REGPARAM2 bsdsocklib_init(TrapContext *ctx)
|
||||
SockLibBase = tmp1;
|
||||
|
||||
/* Install error strings in Amiga memory */
|
||||
_stprintf(verStr, _T("UAE %d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
|
||||
_sntprintf(verStr, sizeof verStr, _T("UAE %d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
|
||||
tmp1 = 0;
|
||||
for (i = number_sys_error; i--;)
|
||||
tmp1 += uaetcslen (errortexts[i]) + 1;
|
||||
|
||||
10
src/calc.cpp
10
src/calc.cpp
@ -292,7 +292,7 @@ static TCHAR *stacktostring(struct calcstack *st)
|
||||
}
|
||||
double v = parsedvaluesd[st->s[0] - 'a'];
|
||||
TCHAR tmp[256];
|
||||
_stprintf(tmp, _T("%d"), (int)v);
|
||||
_sntprintf(tmp, sizeof tmp, _T("%d"), (int)v);
|
||||
xfree(st->vals);
|
||||
st->vals = my_strdup(tmp);
|
||||
xfree(st->s);
|
||||
@ -302,7 +302,7 @@ static TCHAR *stacktostring(struct calcstack *st)
|
||||
}
|
||||
if (!st->vals || !st->vals[0]) {
|
||||
TCHAR tmp[256];
|
||||
_stprintf(tmp, _T("%d"), (int)st->val);
|
||||
_sntprintf(tmp, sizeof tmp, _T("%d"), (int)st->val);
|
||||
xfree(st->vals);
|
||||
st->vals = my_strdup(tmp);
|
||||
}
|
||||
@ -511,7 +511,7 @@ static bool execution_order(const TCHAR *input, double *outval, TCHAR *outstring
|
||||
}
|
||||
// Otherwise, the token is an operator (operator here includes both operators, and functions).
|
||||
else if(is_operator(c) || is_function(c)) {
|
||||
_stprintf(res, _T("_%02d"), rn);
|
||||
_sntprintf(res, sizeof res, _T("_%02d"), rn);
|
||||
calc_log ((_T("%s = "), res));
|
||||
++rn;
|
||||
// It is known a priori that the operator takes n arguments.
|
||||
@ -587,10 +587,10 @@ static bool execution_order(const TCHAR *input, double *outval, TCHAR *outstring
|
||||
if (outval)
|
||||
*outval = val;
|
||||
if (outstring) {
|
||||
if (vals && _tcslen(vals) >= maxlen) {
|
||||
if (vals[0] && _tcslen(vals) >= maxlen) {
|
||||
vals[maxlen] = 0;
|
||||
}
|
||||
_tcscpy(outstring, vals ? vals : _T(""));
|
||||
_tcscpy(outstring, vals[0] ? vals : _T(""));
|
||||
}
|
||||
ok = true;
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ int caps_loadimage (struct zfile *zf, int drv, int *num_tracks)
|
||||
ret = pCAPSLoadImage(caps_cont[drv], caps_flags);
|
||||
caps_revolution_hack[drv] = type == citCTRaw;
|
||||
cdt = &ci.crdt;
|
||||
_stprintf (s1, _T("%d.%d.%d %d:%d:%d"), cdt->day, cdt->month, cdt->year, cdt->hour, cdt->min, cdt->sec);
|
||||
_sntprintf (s1, sizeof s1, _T("%d.%d.%d %d:%d:%d"), cdt->day, cdt->month, cdt->year, cdt->hour, cdt->min, cdt->sec);
|
||||
write_log (_T("caps: type:%d imagetype:%d date:%s rel:%d rev:%d\n"), ci.type, type, s1, ci.release, ci.revision);
|
||||
return 1;
|
||||
}
|
||||
|
||||
1235
src/cfgfile.cpp
1235
src/cfgfile.cpp
File diff suppressed because it is too large
Load Diff
@ -2487,18 +2487,18 @@ static void fixserial(struct uae_prefs *p, uae_u8 *rom, int size)
|
||||
else
|
||||
value3 = 'A';
|
||||
seroffset = 19;
|
||||
sprintf(serial, "%04X", serialnum);
|
||||
_sntprintf(serial, sizeof serial, "%04X", serialnum);
|
||||
type = 1;
|
||||
} else if (ISCPUBOARDP(p, BOARD_CYBERSTORM, BOARD_CYBERSTORM_SUB_PPC)) {
|
||||
value1 = 'D';
|
||||
value2 = 'B';
|
||||
sprintf(serial, "%05X", serialnum);
|
||||
_sntprintf(serial, sizeof serial, "%05X", serialnum);
|
||||
value3 = 0;
|
||||
seroffset = 18;
|
||||
type = 0;
|
||||
} else if (ISCPUBOARDP(p, BOARD_CYBERSTORM, BOARD_CYBERSTORM_SUB_MK3)) {
|
||||
value1 = 'F';
|
||||
sprintf(serial, "%05X", serialnum);
|
||||
_sntprintf(serial, sizeof serial, "%05X", serialnum);
|
||||
value2 = value3 = 0;
|
||||
} else {
|
||||
return;
|
||||
|
||||
@ -350,7 +350,7 @@ const TCHAR *get_sha1_txt (void *vinput, int len)
|
||||
p = outtxt;
|
||||
get_sha1 (input, len, out);
|
||||
for (i = 0; i < SHA1_SIZE; i++) {
|
||||
_stprintf (p, _T("%02X"), out[i]);
|
||||
_sntprintf (p, sizeof p, _T("%02X"), out[i]);
|
||||
p += 2;
|
||||
}
|
||||
*p = 0;
|
||||
|
||||
@ -938,7 +938,7 @@ static int checkvaltype(TCHAR **cp, uae_u32 *val, int *size, TCHAR def)
|
||||
}
|
||||
*val = v;
|
||||
// stupid but works!
|
||||
_stprintf(p, _T("%u"), v);
|
||||
_sntprintf(p, sizeof p, _T("%u"), v);
|
||||
p += _tcslen (p);
|
||||
*p = 0;
|
||||
if (peekchar(cp) == '.') {
|
||||
@ -1188,14 +1188,14 @@ uaecptr dumpmem2 (uaecptr addr, TCHAR *out, int osize)
|
||||
|
||||
if (osize <= (9 + cols * 5 + 1 + 2 * cols))
|
||||
return addr;
|
||||
_stprintf (out, _T("%08X "), addr);
|
||||
_sntprintf (out, sizeof out, _T("%08X "), addr);
|
||||
for (i = 0; i < cols; i++) {
|
||||
uae_u8 b1, b2;
|
||||
b1 = b2 = 0;
|
||||
if (debug_safe_addr (addr, 1)) {
|
||||
b1 = get_byte_debug (addr + 0);
|
||||
b2 = get_byte_debug (addr + 1);
|
||||
_stprintf (out + 9 + i * 5, _T("%02X%02X "), b1, b2);
|
||||
_sntprintf (out + 9 + i * 5, sizeof out, _T("%02X%02X "), b1, b2);
|
||||
out[9 + cols * 5 + 1 + i * 2 + 0] = b1 >= 32 && b1 < 127 ? b1 : '.';
|
||||
out[9 + cols * 5 + 1 + i * 2 + 1] = b2 >= 32 && b2 < 127 ? b2 : '.';
|
||||
} else {
|
||||
@ -1289,9 +1289,9 @@ static void dump_custom_regs(bool aga, bool ext)
|
||||
if (ext) {
|
||||
struct custom_store *cs;
|
||||
cs = &custom_storage[addr1 >> 1];
|
||||
_stprintf(extra1, _T("\t%04X %08X %s"), cs->value, cs->pc & ~1, (cs->pc & 1) ? _T("COP") : _T("CPU"));
|
||||
_sntprintf(extra1, sizeof extra1, _T("\t%04X %08X %s"), cs->value, cs->pc & ~1, (cs->pc & 1) ? _T("COP") : _T("CPU"));
|
||||
cs = &custom_storage[addr2 >> 1];
|
||||
_stprintf(extra2, _T("\t%04X %08X %s"), cs->value, cs->pc & ~1, (cs->pc & 1) ? _T("COP") : _T("CPU"));
|
||||
_sntprintf(extra2, sizeof extra2, _T("\t%04X %08X %s"), cs->value, cs->pc & ~1, (cs->pc & 1) ? _T("COP") : _T("CPU"));
|
||||
}
|
||||
console_out_f (_T("%03X %s\t%04X%s\t%03X %s\t%04X%s\n"),
|
||||
addr1, custd[cnt1].name, v1, extra1,
|
||||
@ -1839,7 +1839,7 @@ static void heatmap_stats(TCHAR **c)
|
||||
|
||||
TCHAR tmp[100];
|
||||
double pct = totalcnt / max * 100.0;
|
||||
_stprintf(tmp, _T("%03d: %08x - %08x %08x (%d) %.5f%%\n"), lines + 1,
|
||||
_sntprintf(tmp, sizeof tmp, _T("%03d: %08x - %08x %08x (%d) %.5f%%\n"), lines + 1,
|
||||
firstaddress, lastaddress + HEATMAP_DIV - 1,
|
||||
lastaddress - firstaddress + HEATMAP_DIV - 1,
|
||||
lastaddress - firstaddress + HEATMAP_DIV - 1,
|
||||
@ -2477,7 +2477,7 @@ static bool get_record_dma_info(struct dma_rec *drs, struct dma_rec *dr, TCHAR *
|
||||
chcnt = br + 1;
|
||||
}
|
||||
if (dr->cf_reg != 0xffff) {
|
||||
_stprintf(srtext, _T("!%03x"), dr->cf_reg);
|
||||
_sntprintf(srtext, sizeof srtext, _T("!%03x"), dr->cf_reg);
|
||||
chcnt = -1;
|
||||
regsize--;
|
||||
} else {
|
||||
@ -2496,11 +2496,11 @@ static bool get_record_dma_info(struct dma_rec *drs, struct dma_rec *dr, TCHAR *
|
||||
}
|
||||
}
|
||||
if (ipl >= 0) {
|
||||
_stprintf(l1, _T("[%02X %03X %d]"), hpos, dhpos, ipl);
|
||||
_sntprintf(l1, sizeof l1, _T("[%02X %03X %d]"), hpos, dhpos, ipl);
|
||||
} else if (ipl == -2) {
|
||||
_stprintf(l1, _T("[%02X %03X -]"), hpos, dhpos);
|
||||
_sntprintf(l1, sizeof l1, _T("[%02X %03X -]"), hpos, dhpos);
|
||||
} else {
|
||||
_stprintf(l1, _T("[%02X %03X ]"), hpos, dhpos);
|
||||
_sntprintf(l1, sizeof l1, _T("[%02X %03X ]"), hpos, dhpos);
|
||||
}
|
||||
if (l4) {
|
||||
_tcscpy(l4, _T(" "));
|
||||
@ -2535,34 +2535,34 @@ static bool get_record_dma_info(struct dma_rec *drs, struct dma_rec *dr, TCHAR *
|
||||
} else {
|
||||
if (chcnt >= 0) {
|
||||
if (regsize == 3)
|
||||
_stprintf(l2, _T("%3s%d %03X"), srtext, chcnt, r);
|
||||
_sntprintf(l2, sizeof l2, _T("%3s%d %03X"), srtext, chcnt, r);
|
||||
else if (regsize == 2)
|
||||
_stprintf(l2, _T("%4s%d %02X"), srtext, chcnt, r);
|
||||
_sntprintf(l2, sizeof l2, _T("%4s%d %02X"), srtext, chcnt, r);
|
||||
else
|
||||
_stprintf(l2, _T("%5s%d %02X"), srtext, chcnt, r);
|
||||
_sntprintf(l2, sizeof l2, _T("%5s%d %02X"), srtext, chcnt, r);
|
||||
} else {
|
||||
if (regsize == 3)
|
||||
_stprintf(l2, _T("%4s %03X"), srtext, r);
|
||||
_sntprintf(l2, sizeof l2, _T("%4s %03X"), srtext, r);
|
||||
else if (regsize == 2)
|
||||
_stprintf(l2, _T("%5s %02X"), srtext, r);
|
||||
_sntprintf(l2, sizeof l2, _T("%5s %02X"), srtext, r);
|
||||
else
|
||||
_stprintf(l2, _T("%6s %02X"), srtext, r);
|
||||
_sntprintf(l2, sizeof l2, _T("%6s %02X"), srtext, r);
|
||||
}
|
||||
}
|
||||
if (l3 && !noval) {
|
||||
uae_u64 v = dr->dat;
|
||||
if (longsize == 4) {
|
||||
_stprintf(l3, _T("%08X"), (uae_u32)v);
|
||||
_sntprintf(l3, sizeof l3, _T("%08X"), (uae_u32)v);
|
||||
} else if (longsize == 8) {
|
||||
_stprintf(l3, _T("%08X"), (uae_u32)(v >> 32));
|
||||
_sntprintf(l3, sizeof l3, _T("%08X"), (uae_u32)(v >> 32));
|
||||
extra64 = true;
|
||||
extraval = (uae_u32)v;
|
||||
} else {
|
||||
_stprintf(l3, _T(" %04X"), (uae_u32)(v & 0xffff));
|
||||
_sntprintf(l3, sizeof l3, _T(" %04X"), (uae_u32)(v & 0xffff));
|
||||
}
|
||||
}
|
||||
if (l4 && dr->addr != 0xffffffff)
|
||||
_stprintf (l4, _T("%08X"), dr->addr & 0x00ffffff);
|
||||
_sntprintf (l4, sizeof l4, _T("%08X"), dr->addr & 0x00ffffff);
|
||||
}
|
||||
if (l3) {
|
||||
int cl2 = 0;
|
||||
@ -2665,7 +2665,7 @@ static bool get_record_dma_info(struct dma_rec *drs, struct dma_rec *dr, TCHAR *
|
||||
if (l5) {
|
||||
if (dr->ciaphase) {
|
||||
if (dr->ciamask) {
|
||||
_stprintf(l5, _T("%c%s%X %04X"), dr->ciarw ? 'W' : 'R',
|
||||
_sntprintf(l5, sizeof l5, _T("%c%s%X %04X"), dr->ciarw ? 'W' : 'R',
|
||||
dr->ciamask == 1 ? _T("A") : (dr->ciamask == 2 ? _T("B") : _T("X")),
|
||||
dr->ciareg, dr->ciavalue);
|
||||
} else {
|
||||
@ -2673,7 +2673,7 @@ static bool get_record_dma_info(struct dma_rec *drs, struct dma_rec *dr, TCHAR *
|
||||
if (ph >= 100) {
|
||||
_tcscpy(l5, _T(" - "));
|
||||
} else {
|
||||
_stprintf(l5, _T(" %u "), ph - 1);
|
||||
_sntprintf(l5, sizeof l5, _T(" %u "), ph - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2686,14 +2686,14 @@ static bool get_record_dma_info(struct dma_rec *drs, struct dma_rec *dr, TCHAR *
|
||||
if (ret) {
|
||||
xtra = '+';
|
||||
}
|
||||
_stprintf(l6, _T("%c%03X %03X"), xtra, ras, cas);
|
||||
_sntprintf(l6, sizeof l6, _T("%c%03X %03X"), xtra, ras, cas);
|
||||
} else {
|
||||
l6[0] = 0;
|
||||
}
|
||||
}
|
||||
if (extra64) {
|
||||
_tcscpy(l6, l4);
|
||||
_stprintf(l4, _T("%08X"), extraval);
|
||||
_sntprintf(l4, sizeof l4, _T("%08X"), extraval);
|
||||
}
|
||||
return got;
|
||||
}
|
||||
@ -2751,17 +2751,17 @@ static void decode_dma_record(int hpos, int vpos, int count, int toggle, bool lo
|
||||
get_record_dma_info(dr_start, dr, l1l, l2l, l3l, l4l, l5l, l6l, &split, &ipl);
|
||||
|
||||
TCHAR *p = l1 + _tcslen(l1);
|
||||
_stprintf(p, _T("%11s "), l1l);
|
||||
_sntprintf(p, sizeof p, _T("%11s "), l1l);
|
||||
p = l2 + _tcslen(l2);
|
||||
_stprintf(p, _T("%11s "), l2l);
|
||||
_sntprintf(p, sizeof p, _T("%11s "), l2l);
|
||||
p = l3 + _tcslen(l3);
|
||||
_stprintf(p, _T("%11s "), l3l);
|
||||
_sntprintf(p, sizeof p, _T("%11s "), l3l);
|
||||
p = l4 + _tcslen(l4);
|
||||
_stprintf(p, _T("%11s "), l4l);
|
||||
_sntprintf(p, sizeof p, _T("%11s "), l4l);
|
||||
p = l5 + _tcslen(l5);
|
||||
_stprintf(p, _T("%11s "), l5l);
|
||||
_sntprintf(p, sizeof p, _T("%11s "), l5l);
|
||||
p = l6 + _tcslen(l6);
|
||||
_stprintf(p, _T("%11s "), l6l);
|
||||
_sntprintf(p, sizeof p, _T("%11s "), l6l);
|
||||
|
||||
if (split != 0xffffffff) {
|
||||
if (split < 0x10000) {
|
||||
@ -2894,7 +2894,7 @@ static uaecptr decode_copper_insn(FILE *file, uae_u16 mword1, uae_u16 mword2, ua
|
||||
TCHAR record[] = _T(" ");
|
||||
|
||||
if ((cr = find_copper_records(addr))) {
|
||||
_stprintf(record, _T(" [%03x %03x]"), cr->vpos, cr->hpos);
|
||||
_sntprintf(record, sizeof record, _T(" [%03x %03x]"), cr->vpos, cr->hpos);
|
||||
insn = (cr->w1 << 16) | cr->w2;
|
||||
} else {
|
||||
insn = (mword1 << 16) | mword2;
|
||||
@ -4299,7 +4299,7 @@ static void memwatch_remap (uaecptr addr)
|
||||
return;
|
||||
if (!newbank) {
|
||||
TCHAR tmp[200];
|
||||
_stprintf (tmp, _T("%s [D]"), bank->name);
|
||||
_sntprintf (tmp, sizeof tmp, _T("%s [D]"), bank->name);
|
||||
ms->addr = bank;
|
||||
ms->banknr = banknr;
|
||||
newbank = &ms->newbank;
|
||||
@ -5005,7 +5005,7 @@ static void memory_map_dump_3(UaeMemoryMap *map, int log)
|
||||
size_out /= 1024;
|
||||
size_ext = 'M';
|
||||
}
|
||||
_stprintf (txt, _T("%08X %7d%c/%d = %7d%c %s%s%c %s %s"), (j << 16) | bankoffset, size_out, size_ext,
|
||||
_sntprintf (txt, sizeof txt, _T("%08X %7d%c/%d = %7d%c %s%s%c %s %s"), (j << 16) | bankoffset, size_out, size_ext,
|
||||
mirrored, mirrored ? size_out / mirrored : size_out, size_ext,
|
||||
(a1->flags & ABFLAG_CACHE_ENABLE_INS) ? _T("I") : _T("-"),
|
||||
(a1->flags & ABFLAG_CACHE_ENABLE_DATA) ? _T("D") : _T("-"),
|
||||
@ -5019,7 +5019,7 @@ static void memory_map_dump_3(UaeMemoryMap *map, int log)
|
||||
if (a1->check(((j << 16) | bankoffset), (size * 1024) / mirrored))
|
||||
crc = get_crc32 (a1->xlateaddr((j << 16) | bankoffset), (size * 1024) / mirrored);
|
||||
struct romdata *rd = getromdatabycrc (crc);
|
||||
_stprintf (p, _T(" (%08X)"), crc);
|
||||
_sntprintf (p, sizeof p, _T(" (%08X)"), crc);
|
||||
if (rd) {
|
||||
tmp[0] = '=';
|
||||
getromname (rd, tmp + 1);
|
||||
@ -5047,8 +5047,8 @@ static void memory_map_dump_3(UaeMemoryMap *map, int log)
|
||||
r->alias = j << 16;
|
||||
r->flags |= UAE_MEMORY_REGION_ALIAS | UAE_MEMORY_REGION_MIRROR;
|
||||
}
|
||||
_stprintf(r->name, _T("%s"), name);
|
||||
_stprintf(r->rom_name, _T("%s"), tmp);
|
||||
_sntprintf(r->name, sizeof r->name, _T("%s"), name);
|
||||
_sntprintf(r->rom_name, sizeof r->rom_name, _T("%s"), tmp);
|
||||
map->num_regions += 1;
|
||||
}
|
||||
}
|
||||
@ -6479,7 +6479,7 @@ static void dma_disasm(int frames, int vp, int hp, int frames_end, int vp_end, i
|
||||
TCHAR l1[16], l2[16], l3[16], l4[16];
|
||||
if (get_record_dma_info(drs, dr, l1, l2, l3, l4, NULL, NULL, NULL, NULL)) {
|
||||
TCHAR tmp[256];
|
||||
_stprintf(tmp, _T(" - %02d %02X %s"), dr->ipl, dr->hpos, l2);
|
||||
_sntprintf(tmp, sizeof tmp, _T(" - %02d %02X %s"), dr->ipl, dr->hpos, l2);
|
||||
while (_tcslen(tmp) < 20) {
|
||||
_tcscat(tmp, _T(" "));
|
||||
}
|
||||
@ -7012,14 +7012,14 @@ static bool debug_line (TCHAR *input)
|
||||
}
|
||||
TCHAR buf[200];
|
||||
TCHAR *pbuf;
|
||||
_stprintf(buf, _T("0 dff000 200 NONE"));
|
||||
_sntprintf(buf, sizeof buf, _T("0 dff000 200 NONE"));
|
||||
pbuf = buf;
|
||||
memwatch(&pbuf);
|
||||
_stprintf(buf, _T("1 0 %08x NONE"), currprefs.chipmem.size);
|
||||
_sntprintf(buf, sizeof buf, _T("1 0 %08x NONE"), currprefs.chipmem.size);
|
||||
pbuf = buf;
|
||||
memwatch(&pbuf);
|
||||
if (currprefs.bogomem.size) {
|
||||
_stprintf(buf, _T("2 c00000 %08x NONE"), currprefs.bogomem.size);
|
||||
_sntprintf(buf, sizeof buf, _T("2 c00000 %08x NONE"), currprefs.bogomem.size);
|
||||
pbuf = buf;
|
||||
memwatch(&pbuf);
|
||||
}
|
||||
@ -7583,7 +7583,7 @@ const TCHAR *debuginfo (int mode)
|
||||
{
|
||||
static TCHAR txt[100];
|
||||
uae_u32 pc = M68K_GETPC;
|
||||
_stprintf (txt, _T("PC=%08X INS=%04X %04X %04X"),
|
||||
_sntprintf (txt, sizeof txt, _T("PC=%08X INS=%04X %04X %04X"),
|
||||
pc, get_word_debug (pc), get_word_debug (pc + 2), get_word_debug (pc + 4));
|
||||
return txt;
|
||||
}
|
||||
|
||||
@ -1136,14 +1136,14 @@ static bool loadcodefiledata(struct debugcodefile *cf)
|
||||
struct zfile *zf = zfile_fopen(fpath, _T("rb"));
|
||||
if (!zf) {
|
||||
console_out_f(_T("Couldn't open source file '%s'\n"), fpath);
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
int length;
|
||||
uae_u8 *data2 = zfile_getdata(zf, 0, -1, &length);
|
||||
if (!data2) {
|
||||
zfile_fclose(zf);
|
||||
console_out_f(_T("Couldn't read source file '%s'\n"), fpath);
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
uae_u8 *data = xcalloc(uae_u8, length + 1);
|
||||
memcpy(data, data2, length);
|
||||
@ -1291,7 +1291,7 @@ static void parse_stabs(void)
|
||||
// wsl path
|
||||
if (!_tcsnicmp(path, _T("/mnt/"), 5)) {
|
||||
TCHAR path2[MAX_DPATH];
|
||||
_stprintf(path2, _T("%c:/%s"), path[5], path + 7);
|
||||
_sntprintf(path2, sizeof path2, _T("%c:/%s"), path[5], path + 7);
|
||||
f = s->string;
|
||||
p = path2;
|
||||
}
|
||||
@ -1299,21 +1299,21 @@ static void parse_stabs(void)
|
||||
// cygwin path
|
||||
if (!_tcsnicmp(path, _T("/cygdrive/"), 10)) {
|
||||
TCHAR path2[MAX_DPATH];
|
||||
_stprintf(path2, _T("%c:/%s"), path[10], path + 12);
|
||||
_sntprintf(path2, sizeof path2, _T("%c:/%s"), path[10], path + 12);
|
||||
f = s->string;
|
||||
p = path2;
|
||||
}
|
||||
} else if (pm == 3) {
|
||||
// pathprefix + path + file
|
||||
if (pathprefix) {
|
||||
_stprintf(path2, _T("%s%s"), pathprefix, path);
|
||||
_sntprintf(path2, sizeof path2, _T("%s%s"), pathprefix, path);
|
||||
f = s->string;
|
||||
p = path2;
|
||||
}
|
||||
} else if (pm == 2) {
|
||||
// pathprefix + file
|
||||
if (pathprefix) {
|
||||
_stprintf(path2, _T("%s%s"), pathprefix, s->string);
|
||||
_sntprintf(path2, sizeof path2, _T("%s%s"), pathprefix, s->string);
|
||||
f = path2;
|
||||
}
|
||||
} else if (pm == 1) {
|
||||
@ -1951,19 +1951,19 @@ static void scan_library_list(uaecptr v, int *cntp)
|
||||
for (int i = 0; i < libnamecnt; i++) {
|
||||
struct libname *name = &libnames[i];
|
||||
char n[256];
|
||||
sprintf(n, "%s.library", name->aname);
|
||||
_sntprintf(n, sizeof n, "%s.library", name->aname);
|
||||
if (!strcmp((char*)p, n)) {
|
||||
name->base = v;
|
||||
found = name;
|
||||
break;
|
||||
}
|
||||
sprintf(n, "%s.device", name->aname);
|
||||
_sntprintf(n, sizeof n, "%s.device", name->aname);
|
||||
if (!strcmp((char*)p, n)) {
|
||||
name->base = v;
|
||||
found = name;
|
||||
break;
|
||||
}
|
||||
sprintf(n, "%s.resource", name->aname);
|
||||
_sntprintf(n, sizeof n, "%s.resource", name->aname);
|
||||
if (!strcmp((char*)p, n)) {
|
||||
name->base = v;
|
||||
found = name;
|
||||
@ -2002,7 +2002,7 @@ bool debugger_get_library_symbol(uaecptr base, uaecptr addr, TCHAR *out)
|
||||
struct libsymbol *lvo = &libsymbols[j];
|
||||
if (lvo->lib == name) {
|
||||
if (lvo->value == addr) {
|
||||
_stprintf(out, _T("%s/%s"), name->name, lvo->name);
|
||||
_sntprintf(out, sizeof out, _T("%s/%s"), name->name, lvo->name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -3758,7 +3758,7 @@ int debugmem_get_sourceline(uaecptr addr, TCHAR *out, int maxsize)
|
||||
if (last_codefile != cf) {
|
||||
TCHAR txt[256];
|
||||
last_codefile = cf;
|
||||
_stprintf(txt, _T("Source file: %s\n"), cf->name);
|
||||
_sntprintf(txt, sizeof txt, _T("Source file: %s\n"), cf->name);
|
||||
if (maxsize > uaetcslen(txt)) {
|
||||
_tcscat(out, txt);
|
||||
maxsize -= uaetcslen(txt);
|
||||
@ -3770,7 +3770,7 @@ int debugmem_get_sourceline(uaecptr addr, TCHAR *out, int maxsize)
|
||||
TCHAR txt[256];
|
||||
TCHAR *s = au((uae_char*)cf->lineptr[j]);
|
||||
if (maxsize > 6 + uaetcslen(s) + 2) {
|
||||
_stprintf(txt, _T("%5d %s\n"), j, s);
|
||||
_sntprintf(txt, sizeof txt, _T("%5d %s\n"), j, s);
|
||||
_tcscat(out, txt);
|
||||
maxsize -= uaetcslen(txt) + 2;
|
||||
}
|
||||
@ -3797,9 +3797,9 @@ int debugmem_get_segment(uaecptr addr, bool *exact, bool *ext, TCHAR *out, TCHAR
|
||||
if (exact && alloc->start + 8 + debugmem_bank.start == addr)
|
||||
*exact = true;
|
||||
if (out)
|
||||
_stprintf(out, _T("[%06X]"), ((addr - debugmem_bank.start) - (alloc->start + 8)) & 0xffffff);
|
||||
_sntprintf(out, sizeof out, _T("[%06X]"), ((addr - debugmem_bank.start) - (alloc->start + 8)) & 0xffffff);
|
||||
if (name)
|
||||
_stprintf(name, _T("Segment %d: %08x %08x-%08x"),
|
||||
_sntprintf(name, sizeof name, _T("Segment %d: %08x %08x-%08x"),
|
||||
alloc->id, alloc->idtype, alloc->start + debugmem_bank.start, alloc->start + alloc->size - 1 + debugmem_bank.start);
|
||||
if (ext)
|
||||
*ext = false;
|
||||
@ -3809,9 +3809,9 @@ int debugmem_get_segment(uaecptr addr, bool *exact, bool *ext, TCHAR *out, TCHAR
|
||||
struct debugsegtracker *seg = findsegment(addr, &alloc);
|
||||
if (seg) {
|
||||
if (out)
|
||||
_stprintf(out, _T("[%06X]"), ((addr - debugmem_bank.start) - (alloc->start + 8)) & 0xffffff);
|
||||
_sntprintf(out, sizeof out, _T("[%06X]"), ((addr - debugmem_bank.start) - (alloc->start + 8)) & 0xffffff);
|
||||
if (name)
|
||||
_stprintf(name, _T("Segment %d ('%s') %08x %08x-%08x"),
|
||||
_sntprintf(name, sizeof name, _T("Segment %d ('%s') %08x %08x-%08x"),
|
||||
alloc->internalid, seg->name, alloc->idtype, alloc->start, alloc->start + alloc->size - 1);
|
||||
if (ext)
|
||||
*ext = true;
|
||||
|
||||
238
src/disasm.cpp
238
src/disasm.cpp
@ -232,9 +232,9 @@ static void showea_val(TCHAR *buffer, uae_u16 opcode, uaecptr addr, int size)
|
||||
if (cached)
|
||||
v2 = get_byte_debug(addr);
|
||||
if (v != v2) {
|
||||
_stprintf(buffer, _T(" [%02x:%02x]"), v, v2);
|
||||
_sntprintf(buffer, sizeof buffer, _T(" [%02x:%02x]"), v, v2);
|
||||
} else {
|
||||
_stprintf(buffer, _T(" [%s%02x]"), cached ? _T("*") : _T(""), v);
|
||||
_sntprintf(buffer, sizeof buffer, _T(" [%s%02x]"), cached ? _T("*") : _T(""), v);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -245,9 +245,9 @@ static void showea_val(TCHAR *buffer, uae_u16 opcode, uaecptr addr, int size)
|
||||
if (cached)
|
||||
v2 = get_word_debug(addr);
|
||||
if (v != v2) {
|
||||
_stprintf(buffer, _T(" [%04x:%04x]"), v, v2);
|
||||
_sntprintf(buffer, sizeof buffer, _T(" [%04x:%04x]"), v, v2);
|
||||
} else {
|
||||
_stprintf(buffer, _T(" [%s%04x]"), cached ? _T("*") : _T(""), v);
|
||||
_sntprintf(buffer, sizeof buffer, _T(" [%s%04x]"), cached ? _T("*") : _T(""), v);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -258,9 +258,9 @@ static void showea_val(TCHAR *buffer, uae_u16 opcode, uaecptr addr, int size)
|
||||
if (cached)
|
||||
v2 = get_long_debug(addr);
|
||||
if (v != v2) {
|
||||
_stprintf(buffer, _T(" [%08x:%08x]"), v, v2);
|
||||
_sntprintf(buffer, sizeof buffer, _T(" [%08x:%08x]"), v, v2);
|
||||
} else {
|
||||
_stprintf(buffer, _T(" [%s%08x]"), cached ? _T("*") : _T(""), v);
|
||||
_sntprintf(buffer, sizeof buffer, _T(" [%s%08x]"), cached ? _T("*") : _T(""), v);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -268,25 +268,25 @@ static void showea_val(TCHAR *buffer, uae_u16 opcode, uaecptr addr, int size)
|
||||
{
|
||||
fpdata fp;
|
||||
fpp_to_single(&fp, get_long_debug(addr));
|
||||
_stprintf(buffer, _T("[%s]"), fpp_print(&fp, 0));
|
||||
_sntprintf(buffer, sizeof buffer, _T("[%s]"), fpp_print(&fp, 0));
|
||||
}
|
||||
break;
|
||||
case sz_double:
|
||||
{
|
||||
fpdata fp;
|
||||
fpp_to_double(&fp, get_long_debug(addr), get_long_debug(addr + 4));
|
||||
_stprintf(buffer, _T("[%s]"), fpp_print(&fp, 0));
|
||||
_sntprintf(buffer, sizeof buffer, _T("[%s]"), fpp_print(&fp, 0));
|
||||
}
|
||||
break;
|
||||
case sz_extended:
|
||||
{
|
||||
fpdata fp;
|
||||
fpp_to_exten(&fp, get_long_debug(addr), get_long_debug(addr + 4), get_long_debug(addr + 8));
|
||||
_stprintf(buffer, _T("[%s]"), fpp_print(&fp, 0));
|
||||
_sntprintf(buffer, sizeof buffer, _T("[%s]"), fpp_print(&fp, 0));
|
||||
break;
|
||||
}
|
||||
case sz_packed:
|
||||
_stprintf(buffer, _T("[%08x%08x%08x]"), get_long_debug(addr), get_long_debug(addr + 4), get_long_debug(addr + 8));
|
||||
_sntprintf(buffer, sizeof buffer, _T("[%08x%08x%08x]"), get_long_debug(addr), get_long_debug(addr + 4), get_long_debug(addr + 8));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -294,7 +294,7 @@ skip:
|
||||
for (int i = 0; i < size; i++) {
|
||||
TCHAR name[256];
|
||||
if (debugmem_get_symbol(addr + i, name, sizeof(name) / sizeof(TCHAR))) {
|
||||
_stprintf(buffer + _tcslen(buffer), _T(" %s"), name);
|
||||
_sntprintf(buffer + _tcslen(buffer), sizeof buffer, _T(" %s"), name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -335,7 +335,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
// Full format extension (68020+)
|
||||
|
||||
if (m > 1 && buffer) {
|
||||
_stprintf(mult, _T("*%d"), m);
|
||||
_sntprintf(mult, sizeof mult, _T("*%d"), m);
|
||||
}
|
||||
|
||||
if (dp & 0x80) { // BS (base register suppress)
|
||||
@ -344,7 +344,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
name = NULL;
|
||||
}
|
||||
if (buffer)
|
||||
_stprintf(dr, _T("%c%d.%c"), dp & 0x8000 ? disasm_areg : disasm_dreg, (int)r, dp & 0x800 ? disasm_long : disasm_word);
|
||||
_sntprintf(dr, sizeof dr, _T("%c%d.%c"), dp & 0x8000 ? disasm_areg : disasm_dreg, (int)r, dp & 0x800 ? disasm_long : disasm_word);
|
||||
if (dp & 0x40) { // IS (index suppress)
|
||||
dispreg = 0;
|
||||
dr[0] = 0;
|
||||
@ -356,16 +356,16 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
|
||||
if (dp & 3) {
|
||||
// indirect
|
||||
_stprintf(p, _T("["));
|
||||
_sntprintf(p, sizeof p, _T("["));
|
||||
p += _tcslen(p);
|
||||
} else {
|
||||
// (an,dn,word/long)
|
||||
if (name) {
|
||||
_stprintf(p, _T("%s,"), name);
|
||||
_sntprintf(p, sizeof p, _T("%s,"), name);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
if (dr[0]) {
|
||||
_stprintf(p, _T("%s%s,"), dr, mult);
|
||||
_sntprintf(p, sizeof p, _T("%s%s,"), dr, mult);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
}
|
||||
@ -374,7 +374,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
if ((dp & 0x30) == 0x20) { // BD SIZE = 2 (WORD)
|
||||
disp = (uae_s32)(uae_s16)get_iword_debug(pc);
|
||||
if (buffer) {
|
||||
_stprintf(p, disasm_lc_hex(_T("$%04X,")), (uae_s16)disp);
|
||||
_sntprintf(p, sizeof p, disasm_lc_hex(_T("$%04X,")), (uae_s16)disp);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
pc += 2;
|
||||
@ -382,7 +382,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
} else if ((dp & 0x30) == 0x30) { // BD SIZE = 3 (LONG)
|
||||
disp = get_ilong_debug(pc);
|
||||
if (buffer) {
|
||||
_stprintf(p, disasm_lc_hex(_T("$%08X,")), disp);
|
||||
_sntprintf(p, sizeof p, disasm_lc_hex(_T("$%08X,")), disp);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
pc += 4;
|
||||
@ -391,25 +391,25 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
|
||||
if ((dp & 3) && buffer) {
|
||||
if (name) {
|
||||
_stprintf(p, _T("%s,"), name);
|
||||
_sntprintf(p, sizeof p, _T("%s,"), name);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
|
||||
if (!(dp & 0x04)) {
|
||||
if (dr[0]) {
|
||||
_stprintf(p, _T("%s%s,"), dr, mult);
|
||||
_sntprintf(p, sizeof p, _T("%s%s,"), dr, mult);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (p[-1] == ',')
|
||||
p--;
|
||||
_stprintf(p, _T("],"));
|
||||
_sntprintf(p, sizeof p, _T("],"));
|
||||
p += _tcslen(p);
|
||||
|
||||
if ((dp & 0x04)) {
|
||||
if (dr[0]) {
|
||||
_stprintf(p, _T("%s%s,"), dr, mult);
|
||||
_sntprintf(p, sizeof p, _T("%s%s,"), dr, mult);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
}
|
||||
@ -419,14 +419,14 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
if ((dp & 0x03) == 0x02) {
|
||||
outer = (uae_s32)(uae_s16)get_iword_debug(pc);
|
||||
if (buffer) {
|
||||
_stprintf(p, disasm_lc_hex(_T("$%04X,")), (uae_s16)outer);
|
||||
_sntprintf(p, sizeof p, disasm_lc_hex(_T("$%04X,")), (uae_s16)outer);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
pc += 2;
|
||||
} else if ((dp & 0x03) == 0x03) {
|
||||
outer = get_ilong_debug(pc);
|
||||
if (buffer) {
|
||||
_stprintf(p, disasm_lc_hex(_T("$%08X,")), outer);
|
||||
_sntprintf(p, sizeof p, disasm_lc_hex(_T("$%08X,")), outer);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
pc += 4;
|
||||
@ -435,7 +435,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
if (buffer) {
|
||||
if (p[-1] == ',')
|
||||
p--;
|
||||
_stprintf(p, _T(")"));
|
||||
_sntprintf(p, sizeof p, _T(")"));
|
||||
p += _tcslen(p);
|
||||
}
|
||||
|
||||
@ -450,7 +450,7 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
|
||||
if (buffer) {
|
||||
if (disasm_flags & (DISASM_FLAG_VAL_FORCE | DISASM_FLAG_VAL)) {
|
||||
_stprintf(p, disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
_sntprintf(p, sizeof p, disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
p += _tcslen(p);
|
||||
}
|
||||
}
|
||||
@ -462,26 +462,26 @@ uaecptr ShowEA_disp(uaecptr *pcp, uaecptr base, TCHAR *buffer, const TCHAR *name
|
||||
|
||||
if (m > 1 && buffer) {
|
||||
if (currprefs.cpu_model < 68020) {
|
||||
_stprintf(mult, _T("[*%d]"), m);
|
||||
_sntprintf(mult, sizeof mult, _T("[*%d]"), m);
|
||||
} else {
|
||||
_stprintf(mult, _T("*%d"), m);
|
||||
_sntprintf(mult, sizeof mult, _T("*%d"), m);
|
||||
}
|
||||
}
|
||||
regstr[0] = 0;
|
||||
_stprintf(regstr, _T(",%c%d.%c"), dp & 0x8000 ? disasm_areg : disasm_dreg, (int)r, dp & 0x800 ? disasm_long : disasm_word);
|
||||
_sntprintf(regstr, sizeof regstr, _T(",%c%d.%c"), dp & 0x8000 ? disasm_areg : disasm_dreg, (int)r, dp & 0x800 ? disasm_long : disasm_word);
|
||||
addr = base + (uae_s32)((uae_s8)disp8) + dispreg;
|
||||
if (buffer) {
|
||||
if (pcrel) {
|
||||
if (disasm_flags & (DISASM_FLAG_VAL_FORCE | DISASM_FLAG_VAL)) {
|
||||
_stprintf(buffer, _T("(%s%s%s,$%02x=$%08x) == $%08x"), name, regstr, mult, (uae_u8)disp8, (*pcp) += disp8, addr);
|
||||
_sntprintf(buffer, sizeof buffer, _T("(%s%s%s,$%02x=$%08x) == $%08x"), name, regstr, mult, (uae_u8)disp8, (*pcp) += disp8, addr);
|
||||
} else {
|
||||
_stprintf(buffer, _T("(%s%s%s,$%02x=$%08x)"), name, regstr, mult, (uae_u8)disp8, (*pcp) += disp8);
|
||||
_sntprintf(buffer, sizeof buffer, _T("(%s%s%s,$%02x=$%08x)"), name, regstr, mult, (uae_u8)disp8, (*pcp) += disp8);
|
||||
}
|
||||
} else {
|
||||
if (disasm_flags & (DISASM_FLAG_VAL_FORCE | DISASM_FLAG_VAL)) {
|
||||
_stprintf(buffer, _T("(%s%s%s,$%02x) == $%08x"), name, regstr, mult, (uae_u8)disp8, addr);
|
||||
_sntprintf(buffer, sizeof buffer, _T("(%s%s%s,$%02x) == $%08x"), name, regstr, mult, (uae_u8)disp8, addr);
|
||||
} else {
|
||||
_stprintf(buffer, _T("(%s%s%s,$%02x)"), name, regstr, mult, (uae_u8)disp8);
|
||||
_sntprintf(buffer, sizeof buffer, _T("(%s%s%s,$%02x)"), name, regstr, mult, (uae_u8)disp8);
|
||||
}
|
||||
}
|
||||
if (((dp & 0x0100) || m != 1) && currprefs.cpu_model < 68020) {
|
||||
@ -511,36 +511,36 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
buffer[0] = 0;
|
||||
switch (mode){
|
||||
case Dreg:
|
||||
_stprintf(buffer, _T("%c%d"), disasm_dreg, reg);
|
||||
_sntprintf(buffer, sizeof buffer, _T("%c%d"), disasm_dreg, reg);
|
||||
if (actualea)
|
||||
*actualea = 0;
|
||||
break;
|
||||
case Areg:
|
||||
_stprintf(buffer, _T("%c%d"), disasm_areg, reg);
|
||||
_sntprintf(buffer, sizeof buffer, _T("%c%d"), disasm_areg, reg);
|
||||
if (actualea)
|
||||
*actualea = 0;
|
||||
break;
|
||||
case Aind:
|
||||
_stprintf(buffer, _T("(%c%d)"), disasm_areg, reg);
|
||||
_sntprintf(buffer, sizeof buffer, _T("(%c%d)"), disasm_areg, reg);
|
||||
addr = regs.regs[reg + 8];
|
||||
if (disasm_flags & DISASM_FLAG_VAL_FORCE) {
|
||||
_stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
_sntprintf(buffer + _tcslen(buffer), sizeof buffer, disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
}
|
||||
showea_val(buffer, opcode, addr, size);
|
||||
break;
|
||||
case Aipi:
|
||||
_stprintf(buffer, _T("(%c%d)+"), disasm_areg, reg);
|
||||
_sntprintf(buffer, sizeof buffer, _T("(%c%d)+"), disasm_areg, reg);
|
||||
addr = regs.regs[reg + 8];
|
||||
if (disasm_flags & DISASM_FLAG_VAL_FORCE) {
|
||||
_stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
_sntprintf(buffer + _tcslen(buffer), sizeof buffer, disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
}
|
||||
showea_val(buffer, opcode, addr, size);
|
||||
break;
|
||||
case Apdi:
|
||||
_stprintf(buffer, _T("-(%c%d)"), disasm_areg, reg);
|
||||
_sntprintf(buffer, sizeof buffer, _T("-(%c%d)"), disasm_areg, reg);
|
||||
addr = regs.regs[reg + 8] - datasizes[size];
|
||||
if (disasm_flags & DISASM_FLAG_VAL_FORCE) {
|
||||
_stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
_sntprintf(buffer + _tcslen(buffer), sizeof buffer, disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
}
|
||||
showea_val(buffer, opcode, addr, size);
|
||||
break;
|
||||
@ -549,13 +549,13 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
TCHAR offtxt[32];
|
||||
disp16 = get_iword_debug (pc); pc += 2;
|
||||
if (disp16 < 0)
|
||||
_stprintf (offtxt, disasm_lc_hex(_T("-$%04X")), -disp16);
|
||||
_sntprintf (offtxt, sizeof offtxt, disasm_lc_hex(_T("-$%04X")), -disp16);
|
||||
else
|
||||
_stprintf (offtxt, disasm_lc_hex(_T("$%04X")), disp16);
|
||||
_sntprintf (offtxt, sizeof offtxt, disasm_lc_hex(_T("$%04X")), disp16);
|
||||
addr = m68k_areg (regs, reg) + disp16;
|
||||
_stprintf(buffer, _T("(%c%d,%s)"), disasm_areg, reg, offtxt);
|
||||
_sntprintf(buffer, sizeof buffer, _T("(%c%d,%s)"), disasm_areg, reg, offtxt);
|
||||
if (disasm_flags & (DISASM_FLAG_VAL_FORCE | DISASM_FLAG_VAL)) {
|
||||
_stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
_sntprintf(buffer + _tcslen(buffer), sizeof buffer, disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
}
|
||||
showea_val(buffer, opcode, addr, size);
|
||||
}
|
||||
@ -563,7 +563,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
case Ad8r:
|
||||
{
|
||||
TCHAR name[10];
|
||||
_stprintf(name, _T("%c%d"), disasm_areg, reg);
|
||||
_sntprintf(name, sizeof name, _T("%c%d"), disasm_areg, reg);
|
||||
addr = ShowEA_disp(&pc, m68k_areg(regs, reg), buffer, name, false);
|
||||
showea_val(buffer, opcode, addr, size);
|
||||
}
|
||||
@ -571,10 +571,10 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
case PC16:
|
||||
disp16 = get_iword_debug (pc); pc += 2;
|
||||
addr += (uae_s16)disp16;
|
||||
_stprintf(buffer, _T("(%s"), disasm_pcreg);
|
||||
_stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(",$%04X)")), disp16 & 0xffff);
|
||||
_sntprintf(buffer, sizeof buffer, _T("(%s"), disasm_pcreg);
|
||||
_sntprintf(buffer + _tcslen(buffer), sizeof buffer, disasm_lc_hex(_T(",$%04X)")), disp16 & 0xffff);
|
||||
if (disasm_flags & (DISASM_FLAG_VAL_FORCE | DISASM_FLAG_VAL)) {
|
||||
_stprintf(buffer + _tcslen(buffer), disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
_sntprintf(buffer + _tcslen(buffer), sizeof buffer, disasm_lc_hex(_T(" == $%08X")), addr);
|
||||
}
|
||||
showea_val(buffer, opcode, addr, size);
|
||||
break;
|
||||
@ -589,11 +589,11 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
addr = (uae_s32)(uae_s16)get_iword_debug (pc);
|
||||
uae_s16 saddr = (uae_s16)addr;
|
||||
if (absshort_long) {
|
||||
_stprintf(buffer, disasm_lc_hex(_T("$%08X.%c")), addr, disasm_word);
|
||||
_sntprintf(buffer, sizeof buffer, disasm_lc_hex(_T("$%08X.%c")), addr, disasm_word);
|
||||
} else if (saddr < 0) {
|
||||
_stprintf(buffer, disasm_lc_hex(_T("-$%04X.%c")), -saddr, disasm_word);
|
||||
_sntprintf(buffer, sizeof buffer, disasm_lc_hex(_T("-$%04X.%c")), -saddr, disasm_word);
|
||||
} else {
|
||||
_stprintf(buffer, disasm_lc_hex(_T("$%04X.%c")), saddr, disasm_word);
|
||||
_sntprintf(buffer, sizeof buffer, disasm_lc_hex(_T("$%04X.%c")), saddr, disasm_word);
|
||||
}
|
||||
pc += 2;
|
||||
showea_val(buffer, opcode, addr, size);
|
||||
@ -601,7 +601,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
break;
|
||||
case absl:
|
||||
addr = get_ilong_debug (pc);
|
||||
_stprintf (buffer, disasm_lc_hex(_T("$%08X")), addr);
|
||||
_sntprintf (buffer, sizeof buffer, disasm_lc_hex(_T("$%08X")), addr);
|
||||
pc += 4;
|
||||
showea_val(buffer, opcode, addr, size);
|
||||
break;
|
||||
@ -610,22 +610,22 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
*actualea = 0;
|
||||
switch (size){
|
||||
case sz_byte:
|
||||
_stprintf (buffer, disasm_lc_hex(_T("#$%02X")), (get_iword_debug (pc) & 0xff));
|
||||
_sntprintf (buffer, sizeof buffer, disasm_lc_hex(_T("#$%02X")), (get_iword_debug (pc) & 0xff));
|
||||
pc += 2;
|
||||
break;
|
||||
case sz_word:
|
||||
_stprintf (buffer, disasm_lc_hex(_T("#$%04X")), (get_iword_debug (pc) & 0xffff));
|
||||
_sntprintf (buffer, sizeof buffer, disasm_lc_hex(_T("#$%04X")), (get_iword_debug (pc) & 0xffff));
|
||||
pc += 2;
|
||||
break;
|
||||
case sz_long:
|
||||
_stprintf(buffer, disasm_lc_hex(_T("#$%08X")), (get_ilong_debug(pc)));
|
||||
_sntprintf(buffer, sizeof buffer, disasm_lc_hex(_T("#$%08X")), (get_ilong_debug(pc)));
|
||||
pc += 4;
|
||||
break;
|
||||
case sz_single:
|
||||
{
|
||||
fpdata fp;
|
||||
fpp_to_single(&fp, get_ilong_debug(pc));
|
||||
_stprintf(buffer, _T("#%s"), fpp_print(&fp, 0));
|
||||
_sntprintf(buffer, sizeof buffer, _T("#%s"), fpp_print(&fp, 0));
|
||||
pc += 4;
|
||||
}
|
||||
break;
|
||||
@ -633,7 +633,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
{
|
||||
fpdata fp;
|
||||
fpp_to_double(&fp, get_ilong_debug(pc), get_ilong_debug(pc + 4));
|
||||
_stprintf(buffer, _T("#%s"), fpp_print(&fp, 0));
|
||||
_sntprintf(buffer, sizeof buffer, _T("#%s"), fpp_print(&fp, 0));
|
||||
pc += 8;
|
||||
}
|
||||
break;
|
||||
@ -641,12 +641,12 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
{
|
||||
fpdata fp;
|
||||
fpp_to_exten(&fp, get_ilong_debug(pc), get_ilong_debug(pc + 4), get_ilong_debug(pc + 8));
|
||||
_stprintf(buffer, _T("#%s"), fpp_print(&fp, 0));
|
||||
_sntprintf(buffer, sizeof buffer, _T("#%s"), fpp_print(&fp, 0));
|
||||
pc += 12;
|
||||
break;
|
||||
}
|
||||
case sz_packed:
|
||||
_stprintf(buffer, disasm_lc_hex(_T("#$%08X%08X%08X")), get_ilong_debug(pc), get_ilong_debug(pc + 4), get_ilong_debug(pc + 8));
|
||||
_sntprintf(buffer, sizeof buffer, disasm_lc_hex(_T("#$%08X%08X%08X")), get_ilong_debug(pc), get_ilong_debug(pc + 4), get_ilong_debug(pc + 8));
|
||||
pc += 12;
|
||||
break;
|
||||
default:
|
||||
@ -655,7 +655,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
break;
|
||||
case imm0:
|
||||
offset = (uae_s32)(uae_s8)get_iword_debug (pc);
|
||||
_stprintf (buffer, disasm_lc_hex(_T("#$%02X")), (uae_u32)(offset & 0xff));
|
||||
_sntprintf (buffer, sizeof buffer, disasm_lc_hex(_T("#$%02X")), (uae_u32)(offset & 0xff));
|
||||
addr = pc + 2 + offset;
|
||||
if ((opcode & 0xf000) == 0x6000) {
|
||||
showea_val(buffer, opcode, addr, 1);
|
||||
@ -667,7 +667,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
case imm1:
|
||||
offset = (uae_s32)(uae_s16)get_iword_debug (pc);
|
||||
buffer[0] = 0;
|
||||
_stprintf (buffer, disasm_lc_hex(_T("#$%04X")), (uae_u32)(offset & 0xffff));
|
||||
_sntprintf (buffer, sizeof buffer, disasm_lc_hex(_T("#$%04X")), (uae_u32)(offset & 0xffff));
|
||||
addr = pc + offset;
|
||||
if ((opcode & 0xf000) == 0x6000) {
|
||||
showea_val(buffer, opcode, addr, 2);
|
||||
@ -678,7 +678,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
break;
|
||||
case imm2:
|
||||
offset = (uae_s32)get_ilong_debug (pc);
|
||||
_stprintf (buffer, disasm_lc_hex(_T("#$%08X")), (uae_u32)offset);
|
||||
_sntprintf (buffer, sizeof buffer, disasm_lc_hex(_T("#$%08X")), (uae_u32)offset);
|
||||
addr = pc + offset;
|
||||
if ((opcode & 0xf000) == 0x6000) {
|
||||
showea_val(buffer, opcode, addr, 4);
|
||||
@ -689,7 +689,7 @@ uaecptr ShowEA(void *f, uaecptr pc, uae_u16 opcode, int reg, amodes mode, wordsi
|
||||
break;
|
||||
case immi:
|
||||
offset = (uae_s32)(uae_s8)(reg & 0xff);
|
||||
_stprintf (buffer, disasm_lc_hex(_T("#$%02X")), (uae_u8)offset);
|
||||
_sntprintf (buffer, sizeof buffer, disasm_lc_hex(_T("#$%02X")), (uae_u8)offset);
|
||||
addr = pc + offset;
|
||||
if (actualea)
|
||||
*actualea = 0;
|
||||
@ -924,7 +924,7 @@ static void addmovemreg(TCHAR *out, int *prevreg, int *lastreg, int *first, int
|
||||
if (disasm_flags & DISASM_FLAG_LC_REG) {
|
||||
to_lower(s, -1);
|
||||
}
|
||||
_stprintf (p, _T("%s%s"), (*first) ? _T("") : _T("/"), s);
|
||||
_sntprintf (p, sizeof p, _T("%s%s"), (*first) ? _T("") : _T("/"), s);
|
||||
p = p + _tcslen (p);
|
||||
if (*lastreg != *prevreg) {
|
||||
_tcscpy(s, movemregs[*prevreg]);
|
||||
@ -932,9 +932,9 @@ static void addmovemreg(TCHAR *out, int *prevreg, int *lastreg, int *first, int
|
||||
to_lower(s, -1);
|
||||
}
|
||||
if ((*lastreg) + 2 == reg) {
|
||||
_stprintf(p, _T("/%s"), s);
|
||||
_sntprintf(p, sizeof p, _T("/%s"), s);
|
||||
} else if ((*lastreg) != (*prevreg)) {
|
||||
_stprintf(p, _T("-%s"), s);
|
||||
_sntprintf(p, sizeof p, _T("-%s"), s);
|
||||
}
|
||||
}
|
||||
*lastreg = reg;
|
||||
@ -1325,7 +1325,7 @@ static bool m68k_asm_parse_movec(TCHAR *s, TCHAR *d)
|
||||
v |= (asm_isdreg(d) << 12);
|
||||
else
|
||||
return false;
|
||||
_stprintf(s, _T("#%X"), v);
|
||||
_sntprintf(s, sizeof s, _T("#%X"), v);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1375,7 +1375,7 @@ static bool m68k_asm_parse_movem(TCHAR *s, int dir)
|
||||
}
|
||||
}
|
||||
if (ret)
|
||||
_stprintf(d, _T("#%X"), regmask);
|
||||
_sntprintf(d, sizeof d, _T("#%X"), regmask);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1702,7 +1702,7 @@ static void resolve_if_jmp(TCHAR *s, uae_u32 addr)
|
||||
TCHAR *p = s + _tcslen(s);
|
||||
uae_u32 addr2 = get_long_debug(addr + 2);
|
||||
if (disasm_flags & (DISASM_FLAG_VAL_FORCE | DISASM_FLAG_VAL)) {
|
||||
_stprintf(p, disasm_lc_hex(_T(" == $%08X ")), addr2);
|
||||
_sntprintf(p, sizeof p, disasm_lc_hex(_T(" == $%08X ")), addr2);
|
||||
|
||||
}
|
||||
showea_val(p + _tcslen(p), opcode, addr2, 4);
|
||||
@ -1721,10 +1721,10 @@ static bool mmu_op30_helper_get_fc(uae_u16 extra, TCHAR *out)
|
||||
{
|
||||
switch (extra & 0x0018) {
|
||||
case 0x0010:
|
||||
_stprintf(out, _T("#%d"), extra & 7);
|
||||
_sntprintf(out, sizeof out, _T("#%d"), extra & 7);
|
||||
return true;
|
||||
case 0x0008:
|
||||
_stprintf(out, _T("%c%d"), disasm_dreg, extra & 7);
|
||||
_sntprintf(out, sizeof out, _T("%c%d"), disasm_dreg, extra & 7);
|
||||
return true;
|
||||
case 0x0000:
|
||||
if (extra & 1) {
|
||||
@ -1835,9 +1835,9 @@ static uaecptr disasm_mmu030(uaecptr pc, uae_u16 opcode, uae_u16 extra, struct i
|
||||
break;
|
||||
if (!mmu_op30_helper_get_fc(extra, fc))
|
||||
break;
|
||||
_stprintf(instrname, _T("PLOAD%c"), mode == 0 ? 'W' : 'R');
|
||||
_sntprintf(instrname, sizeof instrname, _T("PLOAD%c"), mode == 0 ? 'W' : 'R');
|
||||
disasm_lc_mnemo(instrname);
|
||||
_stprintf(instrname + _tcslen(instrname), _T(" %s,"), fc);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, _T(" %s,"), fc);
|
||||
pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr2, actualea, safemode);
|
||||
break;
|
||||
case 0x04: // PFLUSHA
|
||||
@ -1851,7 +1851,7 @@ static uaecptr disasm_mmu030(uaecptr pc, uae_u16 opcode, uae_u16 extra, struct i
|
||||
break;
|
||||
_tcscpy(instrname, _T("PFLUSH"));
|
||||
disasm_lc_mnemo(instrname);
|
||||
_stprintf(instrname + _tcslen(instrname), _T(" %s,%d"), fc, fc_mask);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, _T(" %s,%d"), fc, fc_mask);
|
||||
break;
|
||||
case 0x18: // FC + EA
|
||||
if (mmu_op30_invea(opcode))
|
||||
@ -1860,7 +1860,7 @@ static uaecptr disasm_mmu030(uaecptr pc, uae_u16 opcode, uae_u16 extra, struct i
|
||||
break;
|
||||
_tcscpy(instrname, _T("PFLUSH"));
|
||||
disasm_lc_mnemo(instrname);
|
||||
_stprintf(instrname + _tcslen(instrname), _T(" %s,%d"), fc, fc_mask);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, _T(" %s,%d"), fc, fc_mask);
|
||||
_tcscat(instrname, _T(","));
|
||||
pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr2, actualea, safemode);
|
||||
break;
|
||||
@ -1882,13 +1882,13 @@ static uaecptr disasm_mmu030(uaecptr pc, uae_u16 opcode, uae_u16 extra, struct i
|
||||
break;
|
||||
if (!level && a)
|
||||
break;
|
||||
_stprintf(instrname, _T("PTEST%c"), rw ? 'R' : 'W');
|
||||
_sntprintf(instrname, sizeof instrname, _T("PTEST%c"), rw ? 'R' : 'W');
|
||||
disasm_lc_mnemo(instrname);
|
||||
_stprintf(instrname + _tcslen(instrname), _T(" %s,"), fc);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, _T(" %s,"), fc);
|
||||
pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr2, actualea, safemode);
|
||||
_stprintf(instrname + _tcslen(instrname), _T(",#%d"), level);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, _T(",#%d"), level);
|
||||
if (a)
|
||||
_stprintf(instrname + _tcslen(instrname), _T(",%c%d"), disasm_areg, areg);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, _T(",%c%d"), disasm_areg, areg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -2017,7 +2017,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
if (m2cregs[j].regno == creg)
|
||||
break;
|
||||
}
|
||||
_stprintf(regs, _T("%c%d"), r >= 8 ? disasm_areg : disasm_dreg, r >= 8 ? r - 8 : r);
|
||||
_sntprintf(regs, sizeof regs, _T("%c%d"), r >= 8 ? disasm_areg : disasm_dreg, r >= 8 ? r - 8 : r);
|
||||
if (m2cregs[j].regname)
|
||||
cname = m2cregs[j].regname;
|
||||
if (lookup->mnemo == i_MOVE2C) {
|
||||
@ -2045,16 +2045,16 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 2);
|
||||
pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &seaddr2, &actualea_src, safemode);
|
||||
p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T(",%c%d"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7);
|
||||
_sntprintf(p, sizeof p, _T(",%c%d"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7);
|
||||
} else if (lookup->mnemo == i_CAS) {
|
||||
TCHAR *p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T("%c%d,%c%d,"), disasm_dreg, extra & 7, disasm_dreg, (extra >> 6) & 7);
|
||||
_sntprintf(p, sizeof p, _T("%c%d,%c%d,"), disasm_dreg, extra & 7, disasm_dreg, (extra >> 6) & 7);
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 2);
|
||||
pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &deaddr2, &actualea_dst, safemode);
|
||||
} else if (lookup->mnemo == i_CAS2) {
|
||||
TCHAR *p = instrname + _tcslen(instrname);
|
||||
uae_u16 extra2 = get_word_debug(pc + 2);
|
||||
_stprintf(p, _T("%c%d:%c%d,%c%d,%c%d,(%c%d):(%c%d)"),
|
||||
_sntprintf(p, sizeof p, _T("%c%d:%c%d,%c%d,%c%d,(%c%d):(%c%d)"),
|
||||
disasm_dreg, extra & 7, disasm_dreg, extra2 & 7, disasm_dreg, (extra >> 6) & 7, disasm_dreg, (extra2 >> 6) & 7,
|
||||
(extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7,
|
||||
(extra2 & 0x8000) ? disasm_areg : disasm_dreg, (extra2 >> 12) & 7);
|
||||
@ -2105,19 +2105,19 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &seaddr2, &actualea_src, safemode);
|
||||
p = instrname + _tcslen(instrname);
|
||||
if (extra & 0x0400)
|
||||
_stprintf(p, _T(",%c%d:%c%d"), disasm_dreg, extra & 7, disasm_dreg, (extra >> 12) & 7);
|
||||
_sntprintf(p, sizeof p, _T(",%c%d:%c%d"), disasm_dreg, extra & 7, disasm_dreg, (extra >> 12) & 7);
|
||||
else
|
||||
_stprintf(p, _T(",%c%d"), disasm_dreg, (extra >> 12) & 7);
|
||||
_sntprintf(p, sizeof p, _T(",%c%d"), disasm_dreg, (extra >> 12) & 7);
|
||||
} else if (lookup->mnemo == i_MOVES) {
|
||||
TCHAR *p;
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 2);
|
||||
if (!(extra & 0x0800)) {
|
||||
pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &deaddr2, &actualea_dst, safemode);
|
||||
p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T(",%c%d"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7);
|
||||
_sntprintf(p, sizeof p, _T(",%c%d"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7);
|
||||
} else {
|
||||
p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T("%c%d,"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7);
|
||||
_sntprintf(p, sizeof p, _T("%c%d,"), (extra & 0x8000) ? disasm_areg : disasm_dreg, (extra >> 12) & 7);
|
||||
pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &seaddr2, &actualea_src, safemode);
|
||||
}
|
||||
} else if (lookup->mnemo == i_BFEXTS || lookup->mnemo == i_BFEXTU ||
|
||||
@ -2132,24 +2132,24 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
if (lookup->mnemo == i_BFEXTS || lookup->mnemo == i_BFEXTU || lookup->mnemo == i_BFFFO || lookup->mnemo == i_BFINS)
|
||||
reg = (extra >> 12) & 7;
|
||||
if (lookup->mnemo == i_BFINS)
|
||||
_stprintf(p, _T("%c%d,"), disasm_dreg, reg);
|
||||
_sntprintf(p, sizeof p, _T("%c%d,"), disasm_dreg, reg);
|
||||
pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &seaddr2, &actualea_src, safemode);
|
||||
_tcscat(instrname, _T(" {"));
|
||||
p = instrname + _tcslen(instrname);
|
||||
if (extra & 0x0800)
|
||||
_stprintf(p, _T("%c%d"), disasm_dreg, (extra >> 6) & 7);
|
||||
_sntprintf(p, sizeof p, _T("%c%d"), disasm_dreg, (extra >> 6) & 7);
|
||||
else
|
||||
_stprintf(p, _T("%d"), (extra >> 6) & 31);
|
||||
_sntprintf(p, sizeof p, _T("%d"), (extra >> 6) & 31);
|
||||
_tcscat(instrname, _T(":"));
|
||||
p = instrname + _tcslen(instrname);
|
||||
if (extra & 0x0020)
|
||||
_stprintf(p, _T("%c%d"), disasm_dreg, extra & 7);
|
||||
_sntprintf(p, sizeof p, _T("%c%d"), disasm_dreg, extra & 7);
|
||||
else
|
||||
_stprintf(p, _T("%d"), extra & 31);
|
||||
_sntprintf(p, sizeof p, _T("%d"), extra & 31);
|
||||
_tcscat(instrname, _T("}"));
|
||||
p = instrname + _tcslen(instrname);
|
||||
if (lookup->mnemo == i_BFFFO || lookup->mnemo == i_BFEXTS || lookup->mnemo == i_BFEXTU)
|
||||
_stprintf(p, _T(",%c%d"), disasm_dreg, reg);
|
||||
_sntprintf(p, sizeof p, _T(",%c%d"), disasm_dreg, reg);
|
||||
} else if (lookup->mnemo == i_CPUSHA || lookup->mnemo == i_CPUSHL || lookup->mnemo == i_CPUSHP ||
|
||||
lookup->mnemo == i_CINVA || lookup->mnemo == i_CINVL || lookup->mnemo == i_CINVP) {
|
||||
if ((opcode & 0xc0) == 0xc0)
|
||||
@ -2162,12 +2162,12 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
_tcscat(instrname, _T("?"));
|
||||
if (lookup->mnemo == i_CPUSHL || lookup->mnemo == i_CPUSHP || lookup->mnemo == i_CINVL || lookup->mnemo == i_CINVP) {
|
||||
TCHAR *p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T(",(%c%d)"), disasm_areg, opcode & 7);
|
||||
_sntprintf(p, sizeof p, _T(",(%c%d)"), disasm_areg, opcode & 7);
|
||||
}
|
||||
} else if (lookup->mnemo == i_MOVE16) {
|
||||
TCHAR *p = instrname + _tcslen(instrname);
|
||||
if (opcode & 0x20) {
|
||||
_stprintf(p, _T("(%c%d)+,(%c%d)+"), disasm_areg, opcode & 7, disasm_areg, (extra >> 12) & 7);
|
||||
_sntprintf(p, sizeof p, _T("(%c%d)+,(%c%d)+"), disasm_areg, opcode & 7, disasm_areg, (extra >> 12) & 7);
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 2);
|
||||
} else {
|
||||
uae_u32 addr = get_long_debug(pc);
|
||||
@ -2176,16 +2176,16 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
switch ((opcode >> 3) & 3)
|
||||
{
|
||||
case 0:
|
||||
_stprintf(p, _T("(%c%d)+,$%08x"), disasm_areg, ay, addr);
|
||||
_sntprintf(p, sizeof p, _T("(%c%d)+,$%08x"), disasm_areg, ay, addr);
|
||||
break;
|
||||
case 1:
|
||||
_stprintf(p, _T("$%08x,(%c%d)+"), addr, disasm_areg, ay);
|
||||
_sntprintf(p, sizeof p, _T("$%08x,(%c%d)+"), addr, disasm_areg, ay);
|
||||
break;
|
||||
case 2:
|
||||
_stprintf(p, _T("(%c%d),$%08x"), disasm_areg, ay, addr);
|
||||
_sntprintf(p, sizeof p, _T("(%c%d),$%08x"), disasm_areg, ay, addr);
|
||||
break;
|
||||
case 3:
|
||||
_stprintf(p, _T("$%08x,(%c%d)"), addr, disasm_areg, ay);
|
||||
_sntprintf(p, sizeof p, _T("$%08x,(%c%d)"), addr, disasm_areg, ay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2194,24 +2194,24 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
_tcscat(instrname, _T(","));
|
||||
pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, dp->size, instrname, &deaddr2, &actualea_dst, safemode);
|
||||
extra = get_word_debug(pc);
|
||||
_stprintf(instrname + _tcslen(instrname), disasm_lc_hex(_T(",#$%04X")), extra);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, disasm_lc_hex(_T(",#$%04X")), extra);
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 2);
|
||||
} else if (lookup->mnemo == i_LPSTOP) {
|
||||
if (extra == 0x01c0) {
|
||||
uae_u16 extra2 = get_word_debug(pc + 2);
|
||||
_tcscpy(instrname, _T("LPSTOP"));
|
||||
disasm_lc_mnemo(instrname);
|
||||
_stprintf(instrname + _tcslen(instrname), disasm_lc_hex(_T(" #$%04X")), extra2);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, disasm_lc_hex(_T(" #$%04X")), extra2);
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 4);
|
||||
} else {
|
||||
_tcscpy(instrname, _T("ILLG"));
|
||||
disasm_lc_mnemo(instrname);
|
||||
_stprintf(instrname + _tcslen(instrname), disasm_lc_hex(_T(" #$%04X")), extra);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, disasm_lc_hex(_T(" #$%04X")), extra);
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 2);
|
||||
}
|
||||
} else if (lookup->mnemo == i_CALLM) {
|
||||
TCHAR *p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T("#%d,"), extra & 255);
|
||||
_sntprintf(p, sizeof p, _T("#%d,"), extra & 255);
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 2);
|
||||
pc = ShowEA(NULL, pc, opcode, dp->sreg, dp->smode, dp->size, instrname, &seaddr2, &actualea_src, safemode);
|
||||
} else if (lookup->mnemo == i_FDBcc) {
|
||||
@ -2239,7 +2239,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
fpu_get_constant(&fp, extra & 0x7f);
|
||||
_tcscpy(instrname, _T("FMOVECR.X"));
|
||||
disasm_lc_mnemo(instrname);
|
||||
_stprintf(instrname + _tcslen(instrname), _T(" #0x%02x [%s],%s%d"), extra & 0x7f, fpp_print(&fp, 0), disasm_fpreg, (extra >> 7) & 7);
|
||||
_sntprintf(instrname + _tcslen(instrname), sizeof instrname, _T(" #0x%02x [%s],%s%d"), extra & 0x7f, fpp_print(&fp, 0), disasm_fpreg, (extra >> 7) & 7);
|
||||
} else if ((extra & 0x8000) == 0x8000) { // FMOVEM or FMOVE control register
|
||||
int dr = (extra >> 13) & 1;
|
||||
int mode;
|
||||
@ -2272,7 +2272,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
p = instrname + _tcslen(instrname);
|
||||
if (dr) {
|
||||
if (mode & 1)
|
||||
_stprintf(p, _T("%c%d"), disasm_dreg, dreg);
|
||||
_sntprintf(p, sizeof p, _T("%c%d"), disasm_dreg, dreg);
|
||||
else
|
||||
movemout(p, regmask, dp->dmode, fpmode, false);
|
||||
_tcscat(instrname, _T(","));
|
||||
@ -2289,7 +2289,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
_tcscat(p, _T("/"));
|
||||
entry = true;
|
||||
p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, disasm_lc_hex(_T("#$%08X")), get_ilong_debug(pc));
|
||||
_sntprintf(p, sizeof p, disasm_lc_hex(_T("#$%08X")), get_ilong_debug(pc));
|
||||
add_disasm_word(&pc, &bufpc, &bufpcsize, 4);
|
||||
}
|
||||
}
|
||||
@ -2298,7 +2298,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
}
|
||||
p = instrname + _tcslen(instrname);
|
||||
if (mode & 1)
|
||||
_stprintf(p, _T(",%c%d"), disasm_dreg, dreg);
|
||||
_sntprintf(p, sizeof p, _T(",%c%d"), disasm_dreg, dreg);
|
||||
else
|
||||
movemout(p, regmask, dp->dmode, fpmode, true);
|
||||
}
|
||||
@ -2306,7 +2306,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
if (fpuopcodes[ins]) {
|
||||
_tcscpy(instrname, fpuopcodes[ins]);
|
||||
} else {
|
||||
_stprintf(instrname, _T("%s?%02X"), disasm_lc_reg(_T("F")), ins);
|
||||
_sntprintf(instrname, sizeof instrname, _T("%s?%02X"), disasm_lc_reg(_T("F")), ins);
|
||||
}
|
||||
disasm_lc_mnemo(instrname);
|
||||
if ((extra & (0x8000 | 0x4000 | 0x2000)) == (0x4000 | 0x2000)) { // FMOVE to memory/data register
|
||||
@ -2316,15 +2316,15 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
disasm_lc_mnemo(instrname);
|
||||
_tcscat(instrname, _T(" "));
|
||||
p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T("%s%d,"), disasm_fpreg, (extra >> 7) & 7);
|
||||
_sntprintf(p, sizeof p, _T("%s%d,"), disasm_fpreg, (extra >> 7) & 7);
|
||||
pc = ShowEA(NULL, pc, opcode, dp->dreg, dp->dmode, fpsizeconv[size], instrname, &deaddr2, &actualea_dst, safemode);
|
||||
p = instrname + _tcslen(instrname);
|
||||
if (size == 7) {
|
||||
_stprintf(p, _T(" {%c%d}"), disasm_dreg, (kfactor >> 4));
|
||||
_sntprintf(p, sizeof p, _T(" {%c%d}"), disasm_dreg, (kfactor >> 4));
|
||||
} else if (kfactor) {
|
||||
if (kfactor & 0x40)
|
||||
kfactor |= ~0x3f;
|
||||
_stprintf(p, _T(" {%d}"), kfactor);
|
||||
_sntprintf(p, sizeof p, _T(" {%d}"), kfactor);
|
||||
}
|
||||
} else if ((extra & (0x8000 | 0x2000)) == 0) {
|
||||
if (extra & 0x4000) { // source is EA
|
||||
@ -2336,17 +2336,17 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
p = instrname + _tcslen(instrname);
|
||||
_tcscat(p, disasm_lc_reg(_T(".X")));
|
||||
p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T(" %s%d"), disasm_fpreg, (extra >> 10) & 7);
|
||||
_sntprintf(p, sizeof p, _T(" %s%d"), disasm_fpreg, (extra >> 10) & 7);
|
||||
}
|
||||
p = instrname + _tcslen(instrname);
|
||||
if (ins >= 0x30 && ins < 0x38) { // FSINCOS
|
||||
p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T(",%s%d"), disasm_fpreg, extra & 7);
|
||||
_sntprintf(p, sizeof p, _T(",%s%d"), disasm_fpreg, extra & 7);
|
||||
p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T(",%s%d"), disasm_fpreg, (extra >> 7) & 7);
|
||||
_sntprintf(p, sizeof p, _T(",%s%d"), disasm_fpreg, (extra >> 7) & 7);
|
||||
} else {
|
||||
if ((extra & 0x4000) || (((extra >> 7) & 7) != ((extra >> 10) & 7))) {
|
||||
_stprintf(p, _T(",%s%d"), disasm_fpreg, (extra >> 7) & 7);
|
||||
_sntprintf(p, sizeof p, _T(",%s%d"), disasm_fpreg, (extra >> 7) & 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2373,7 +2373,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
TCHAR sname[256];
|
||||
if (debugger_get_library_symbol(m68k_areg(regs, 6), 0xffff0000 | extra, sname)) {
|
||||
TCHAR *p = instrname + _tcslen(instrname);
|
||||
_stprintf(p, _T(" %s"), sname);
|
||||
_sntprintf(p, sizeof p, _T(" %s"), sname);
|
||||
resolve_if_jmp(instrname, m68k_areg(regs, 6) + (uae_s16)extra);
|
||||
}
|
||||
}
|
||||
@ -2395,7 +2395,7 @@ uae_u32 m68k_disasm_2(TCHAR *buf, int bufsize, uaecptr pc, uae_u16 *bufpc, int b
|
||||
a += 2;
|
||||
}
|
||||
if (disasm_flags & DISASM_FLAG_EA) {
|
||||
_stprintf(eas, disasm_lc_hex(_T(" == $%08X")), get_ilong_debug(a));
|
||||
_sntprintf(eas, sizeof eas, disasm_lc_hex(_T(" == $%08X")), get_ilong_debug(a));
|
||||
}
|
||||
_tcscat(instrname, eas);
|
||||
}
|
||||
@ -2556,7 +2556,7 @@ void sm68k_disasm (TCHAR *instrname, TCHAR *instrcode, uaecptr addr, uaecptr *ne
|
||||
int i;
|
||||
for (i = 0; i < (pc - oldpc) / 2; i++)
|
||||
{
|
||||
_stprintf (instrcode, _T("%04x "), get_iword_debug (oldpc + i * 2));
|
||||
_sntprintf (instrcode, sizeof instrcode, _T("%04x "), get_iword_debug (oldpc + i * 2));
|
||||
instrcode += _tcslen (instrcode);
|
||||
}
|
||||
}
|
||||
|
||||
12
src/disk.cpp
12
src/disk.cpp
@ -3379,7 +3379,7 @@ static void floppybridge_getsetprofile(int i)
|
||||
if (sub - 1 < bridgeprofiles.size()) {
|
||||
int nsub = sub - 1;
|
||||
TCHAR tmp[32];
|
||||
_stprintf(tmp, _T("%d:%s"), bridgeprofiles.at(nsub).profileID, bridgeprofiles.at(nsub).name);
|
||||
_sntprintf(tmp, sizeof tmp, _T("%d:%s"), bridgeprofiles.at(nsub).profileID, bridgeprofiles.at(nsub).name);
|
||||
currprefs.floppyslots[i].dfxsubtype = changed_prefs.floppyslots[i].dfxsubtype = sub;
|
||||
_tcscpy(changed_prefs.floppyslots[i].dfxsubtypeid, tmp);
|
||||
_tcscpy(currprefs.floppyslots[i].dfxsubtypeid, changed_prefs.floppyslots[i].dfxsubtypeid);
|
||||
@ -5409,7 +5409,7 @@ static void floppybridge_init2(struct uae_prefs *p)
|
||||
TCHAR *terrorMessage = au(errorMessage);
|
||||
TCHAR *tname = au(name);
|
||||
TCHAR formattedMessage[512];
|
||||
_stprintf(formattedMessage, _T("Floppy Disk Bridge Error\n\nUnable to replace DF%i: using %s\n\n%s.\n\nDrive DF%i: will be disabled and ignored."), dr, tname, terrorMessage, dr);
|
||||
_sntprintf(formattedMessage, sizeof formattedMessage, _T("Floppy Disk Bridge Error\n\nUnable to replace DF%i: using %s\n\n%s.\n\nDrive DF%i: will be disabled and ignored."), dr, tname, terrorMessage, dr);
|
||||
gui_message(formattedMessage);
|
||||
xfree(tname);
|
||||
xfree(terrorMessage);
|
||||
@ -5656,12 +5656,12 @@ static void get_floppybridgeinfo(struct uae_prefs *prefs, TCHAR *infotext, int n
|
||||
_tcscat(p, bridgeinfo.about);
|
||||
p += _tcslen(p);
|
||||
if (bridgeinfo.isUpdateAvailable) {
|
||||
_stprintf(p, _T(" v%u.%u (v%u.%u) "), bridgeinfo.majorVersion, bridgeinfo.minorVersion, bridgeinfo.updateMajorVersion, bridgeinfo.updateMinorVersion);
|
||||
_sntprintf(p, sizeof p, _T(" v%u.%u (v%u.%u) "), bridgeinfo.majorVersion, bridgeinfo.minorVersion, bridgeinfo.updateMajorVersion, bridgeinfo.updateMinorVersion);
|
||||
} else {
|
||||
_stprintf(p, _T(" v%u.%u "), bridgeinfo.majorVersion, bridgeinfo.minorVersion);
|
||||
_sntprintf(p, sizeof p, _T(" v%u.%u "), bridgeinfo.majorVersion, bridgeinfo.minorVersion);
|
||||
}
|
||||
p += _tcslen(p);
|
||||
_stprintf(p, _T("(%s)"), bridgeinfo.url);
|
||||
_sntprintf(p, sizeof p, _T("(%s)"), bridgeinfo.url);
|
||||
_tcscat(p, _T("\r\n\r\n"));
|
||||
p += _tcslen(p);
|
||||
if (bridge_driver[num]) {
|
||||
@ -5669,7 +5669,7 @@ static void get_floppybridgeinfo(struct uae_prefs *prefs, TCHAR *infotext, int n
|
||||
TCHAR *name = au(bd->name);
|
||||
TCHAR *man = au(bd->manufacturer);
|
||||
TCHAR *url = au(bd->url);
|
||||
_stprintf(p, _T("%s, %s (%s)\r\n"), name, man, url);
|
||||
_sntprintf(p, sizeof p, _T("%s, %s (%s)\r\n"), name, man, url);
|
||||
xfree(url);
|
||||
xfree(man);
|
||||
xfree(name);
|
||||
|
||||
@ -196,21 +196,21 @@ void driveclick_init (void)
|
||||
for (int j = 0; j < CLICK_TRACKS; j++)
|
||||
drvs[i][DS_CLICK].lengths[j] = drvs[i][DS_CLICK].len;
|
||||
get_plugin_path (path2, sizeof path2 / sizeof (TCHAR), _T("floppysounds"));
|
||||
_stprintf (tmp, _T("%sdrive_click_%s"),
|
||||
_sntprintf (tmp, sizeof tmp, _T("%sdrive_click_%s"),
|
||||
path2, fs->dfxclickexternal);
|
||||
v = loadsample (tmp, &drvs[i][DS_CLICK]);
|
||||
if (v)
|
||||
processclicks (&drvs[i][DS_CLICK]);
|
||||
_stprintf (tmp, _T("%sdrive_spin_%s"),
|
||||
_sntprintf (tmp, sizeof tmp, _T("%sdrive_spin_%s"),
|
||||
path2, fs->dfxclickexternal);
|
||||
v += loadsample (tmp, &drvs[i][DS_SPIN]);
|
||||
_stprintf (tmp, _T("%sdrive_spinnd_%s"),
|
||||
_sntprintf (tmp, sizeof tmp, _T("%sdrive_spinnd_%s"),
|
||||
path2, fs->dfxclickexternal);
|
||||
v += loadsample (tmp, &drvs[i][DS_SPINND]);
|
||||
_stprintf (tmp, _T("%sdrive_startup_%s"),
|
||||
_sntprintf (tmp, sizeof tmp, _T("%sdrive_startup_%s"),
|
||||
path2, fs->dfxclickexternal);
|
||||
v += loadsample (tmp, &drvs[i][DS_START]);
|
||||
_stprintf (tmp, _T("%sdrive_snatch_%s"),
|
||||
_sntprintf (tmp, sizeof tmp, _T("%sdrive_snatch_%s"),
|
||||
path2, fs->dfxclickexternal);
|
||||
v += loadsample (tmp, &drvs[i][DS_SNATCH]);
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ static int enforcer_decode_hunk_and_offset (TCHAR *buf, uae_u32 pc)
|
||||
} else {
|
||||
native_name = my_strdup (_T("Unknown"));
|
||||
}
|
||||
_stprintf (buf, _T("----> %08x - \"%s\" Hunk %04x Offset %08x\n"), pc, native_name, hunk, offset);
|
||||
_sntprintf (buf, sizeof buf, _T("----> %08x - \"%s\" Hunk %04x Offset %08x\n"), pc, native_name, hunk, offset);
|
||||
xfree (native_name);
|
||||
return 1;
|
||||
}
|
||||
@ -207,7 +207,7 @@ static int enforcer_decode_hunk_and_offset (TCHAR *buf, uae_u32 pc)
|
||||
uae_u32 offset = pc - (get_long (node + 8) << 2);
|
||||
uaecptr mod = get_long (node + 20);
|
||||
native_name = au ((char*)amiga2native (mod + 24, 100));
|
||||
_stprintf (buf, _T("----> %08x - \"%s\" Hunk %04x Offset %08x\n"), pc, native_name, hunk, offset);
|
||||
_sntprintf (buf, sizeof buf, _T("----> %08x - \"%s\" Hunk %04x Offset %08x\n"), pc, native_name, hunk, offset);
|
||||
xfree (native_name);
|
||||
return 1;
|
||||
}
|
||||
@ -259,18 +259,18 @@ static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr
|
||||
_tcscpy (enforcer_buf_ptr, _T("Enforcer Hit! Bad program\n"));
|
||||
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
|
||||
|
||||
_stprintf (buf, _T("Illegal %s: %08x"), addressmode, addr);
|
||||
_stprintf (enforcer_buf_ptr, _T("%-48sPC: %08x\n"), buf, pc);
|
||||
_sntprintf (buf, sizeof buf, _T("Illegal %s: %08x"), addressmode, addr);
|
||||
_sntprintf (enforcer_buf_ptr, sizeof enforcer_buf_ptr, _T("%-48sPC: %08x\n"), buf, pc);
|
||||
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
|
||||
|
||||
/* Data registers */
|
||||
_stprintf (enforcer_buf_ptr, _T("Data: %08x %08x %08x %08x %08x %08x %08x %08x\n"),
|
||||
_sntprintf (enforcer_buf_ptr, sizeof enforcer_buf_ptr, _T("Data: %08x %08x %08x %08x %08x %08x %08x %08x\n"),
|
||||
m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_dreg (regs, 2), m68k_dreg (regs, 3),
|
||||
m68k_dreg (regs, 4), m68k_dreg (regs, 5), m68k_dreg (regs, 6), m68k_dreg (regs, 7));
|
||||
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
|
||||
|
||||
/* Address registers */
|
||||
_stprintf (enforcer_buf_ptr, _T("Addr: %08x %08x %08x %08x %08x %08x %08x %08x\n"),
|
||||
_sntprintf (enforcer_buf_ptr, sizeof enforcer_buf_ptr, _T("Addr: %08x %08x %08x %08x %08x %08x %08x %08x\n"),
|
||||
m68k_areg (regs, 0), m68k_areg (regs, 1), m68k_areg (regs, 2), m68k_areg (regs, 3),
|
||||
m68k_areg (regs, 4), m68k_areg (regs, 5), m68k_areg (regs, 6), m68k_areg (regs, 7));
|
||||
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
|
||||
@ -283,7 +283,7 @@ static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr
|
||||
_tcscpy (enforcer_buf_ptr, _T("Stck:"));
|
||||
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
|
||||
}
|
||||
_stprintf (enforcer_buf_ptr, _T(" %08x"),get_long (a7));
|
||||
_sntprintf (enforcer_buf_ptr, sizeof enforcer_buf_ptr, _T(" %08x"),get_long (a7));
|
||||
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
|
||||
|
||||
if (i%8 == 7)
|
||||
@ -384,7 +384,7 @@ static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr
|
||||
}
|
||||
|
||||
sm68k_disasm (buf, instrcode, bestpc, NULL, 0xffffffff);
|
||||
_stprintf (lines[i], _T("%08x : %-20s %s\n"), bestpc, instrcode, buf);
|
||||
_sntprintf (lines[i], sizeof lines[i], _T("%08x : %-20s %s\n"), bestpc, instrcode, buf);
|
||||
temppc = bestpc;
|
||||
}
|
||||
|
||||
@ -398,7 +398,7 @@ static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr
|
||||
temppc = pc;
|
||||
for (i = 0; i < (INSTRUCTIONLINES + 1) / 2; i++) {
|
||||
sm68k_disasm (buf, instrcode, temppc, &nextpc, 0xffffffff);
|
||||
_stprintf (enforcer_buf_ptr, _T("%08x : %s %-20s %s\n"), temppc,
|
||||
_sntprintf (enforcer_buf_ptr, sizeof enforcer_buf_ptr, _T("%08x : %s %-20s %s\n"), temppc,
|
||||
(i == 0 ? _T("*") : _T(" ")), instrcode, buf);
|
||||
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
|
||||
temppc = nextpc;
|
||||
@ -406,7 +406,7 @@ static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr
|
||||
|
||||
if (!native_task_name)
|
||||
native_task_name = my_strdup(_T("Unknown"));
|
||||
_stprintf (enforcer_buf_ptr, _T("Name: \"%s\"\n\n"), native_task_name);
|
||||
_sntprintf (enforcer_buf_ptr, sizeof enforcer_buf_ptr, _T("Name: \"%s\"\n\n"), native_task_name);
|
||||
enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
|
||||
|
||||
console_out (enforcer_buf);
|
||||
|
||||
@ -3132,7 +3132,7 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
|
||||
}
|
||||
if (aci->devnum > 0) {
|
||||
TCHAR *s = label + _tcslen(label);
|
||||
_stprintf(s, _T(" [%d]"), aci->devnum + 1);
|
||||
_sntprintf(s, sizeof s, _T(" [%d]"), aci->devnum + 1);
|
||||
}
|
||||
|
||||
if ((aci->zorro == 1 || aci->zorro == 2 || aci->zorro == 3) && aci->addrbank != &expamem_none && (aci->autoconfig_raw[0] != 0xff || aci->autoconfigp)) {
|
||||
@ -5030,10 +5030,10 @@ void ethernet_updateselection(void)
|
||||
TCHAR mac[20];
|
||||
mac[0] = 0;
|
||||
if (ndd[i]->type == UAENET_SLIRP || ndd[i]->type == UAENET_SLIRP_INBOUND) {
|
||||
_stprintf(mac, _T(" xx:xx:xx:%02X:%02X:%02X"),
|
||||
_sntprintf(mac, sizeof mac, _T(" xx:xx:xx:%02X:%02X:%02X"),
|
||||
ndd[i]->mac[3], ndd[i]->mac[4], ndd[i]->mac[5]);
|
||||
}
|
||||
_stprintf(p1, _T("%s%s"), ndd[i]->desc, mac[0] ? mac : _T(""));
|
||||
_sntprintf(p1, sizeof p1, _T("%s%s"), ndd[i]->desc, mac[0] ? mac : _T(""));
|
||||
p1 += _tcslen(p1) + 1;
|
||||
_tcscpy(p2, ndd[i]->name);
|
||||
p2 += _tcslen(p2) + 1;
|
||||
|
||||
@ -830,7 +830,7 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, struct
|
||||
return nvol;
|
||||
}
|
||||
|
||||
if ((!volname || uaetcslen (volname) == 0) && path && archivehd >= 0) {
|
||||
if ((!volname || uaetcslen (volname) == 0) && path[0] && archivehd >= 0) {
|
||||
p = my_strdup (path);
|
||||
for (i = uaetcslen (p) - 1; i >= 0; i--) {
|
||||
TCHAR c = p[i];
|
||||
@ -1361,7 +1361,7 @@ static void initialize_mountinfo (void)
|
||||
for (int i = 0; i < 32; i++) {
|
||||
if (mask & (1 << i)) {
|
||||
struct uaedev_config_info ci = { 0 };
|
||||
_stprintf (ci.devname, _T("CD%d"), i);
|
||||
_sntprintf (ci.devname, sizeof ci.devname, _T("CD%d"), i);
|
||||
cd_unit_number++;
|
||||
_tcscpy (ci.rootdir, _T("/"));
|
||||
ci.readonly = true;
|
||||
@ -1453,10 +1453,10 @@ int sprintf_filesys_unit (TCHAR *buffer, int num)
|
||||
UnitInfo *uip = mountinfo.ui;
|
||||
|
||||
if (uip[num].volname != 0)
|
||||
_stprintf (buffer, _T("(DH%d:) Filesystem, %s: %s %s"), num, uip[num].volname,
|
||||
_sntprintf (buffer, sizeof buffer, _T("(DH%d:) Filesystem, %s: %s %s"), num, uip[num].volname,
|
||||
uip[num].rootdir, uip[num].readonly ? _T("ro") : _T(""));
|
||||
else
|
||||
_stprintf (buffer, _T("(DH%d:) Hardfile, \"%s\", size %d Mbytes"), num,
|
||||
_sntprintf (buffer, sizeof buffer, _T("(DH%d:) Hardfile, \"%s\", size %d Mbytes"), num,
|
||||
uip[num].rootdir, (int)(uip[num].hf.virtsize / (1024 * 1024)));
|
||||
return 0;
|
||||
}
|
||||
@ -2247,7 +2247,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf
|
||||
// inserted >= 2: drag&drop insert, do not replace existing normal drives
|
||||
if (inserted < 2 && ui->rootdir && !memcmp (ui->rootdir, rootdir, uaetcslen (rootdir)) && uaetcslen (rootdir) + 3 >= uaetcslen (ui->rootdir)) {
|
||||
if (filesys_isvolume(u) && inserted) {
|
||||
if (uci)ctx,
|
||||
if (uci)ctx,
|
||||
filesys_delayed_change (u, 50, rootdir, uci->ci.volname, uci->ci.readonly, 0);
|
||||
return 0;
|
||||
}
|
||||
@ -2317,7 +2317,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf
|
||||
if (uci)
|
||||
_tcscpy (devname, uci->ci.devname);
|
||||
else
|
||||
_stprintf (devname, _T("RDH%d"), autocreatedunit++);
|
||||
_sntprintf (devname, sizeof devname, _T("RDH%d"), autocreatedunit++);
|
||||
_tcscpy (ci.devname, devname);
|
||||
_tcscpy (ci.volname, volptr);
|
||||
_tcscpy (ci.rootdir, rootdir);
|
||||
@ -4994,7 +4994,7 @@ static void inject_icons_to_directory(Unit *unit, a_inode *base)
|
||||
if (len >= 5 && !_tcsicmp(aino->aname + len - 5, _T(".info")))
|
||||
continue;
|
||||
TCHAR tmp[256];
|
||||
_stprintf(tmp, _T("%s.info"), aino->aname);
|
||||
_sntprintf(tmp, sizeof tmp, _T("%s.info"), aino->aname);
|
||||
bool match = false;
|
||||
for (a_inode *aino2 = base->child; aino2; aino2 = aino2->sibling) {
|
||||
if (!_tcsicmp(aino2->aname, tmp))
|
||||
@ -8275,7 +8275,7 @@ static const TCHAR *dostypes(TCHAR *dt, uae_u32 dostype)
|
||||
dt[j++] = c;
|
||||
} else {
|
||||
dt[j++] = '\\';
|
||||
_stprintf (&dt[j], _T("%d"), c);
|
||||
_sntprintf (&dt[j], sizeof &dt[j], _T("%d"), c);
|
||||
j += uaetcslen (&dt[j]);
|
||||
}
|
||||
}
|
||||
@ -8342,7 +8342,7 @@ static void dumprdbblock(const uae_u8 *buf, int block)
|
||||
TCHAR outbuf[81];
|
||||
for (int j = 0; j < w; j++) {
|
||||
uae_u8 v = buf[i + j];
|
||||
_stprintf(outbuf + 2 * j, _T("%02X"), v);
|
||||
_sntprintf(outbuf + 2 * j, sizeof outbuf, _T("%02X"), v);
|
||||
outbuf[2 * w + 1 + j] = (v >= 32 && v <= 126) ? v : '.';
|
||||
}
|
||||
outbuf[2 * w] = ' ';
|
||||
@ -8418,7 +8418,7 @@ static void get_new_device (TrapContext *ctx, int type, uaecptr parmpacket, TCHA
|
||||
if (*devname == 0 || uaetcslen (*devname) == 0) {
|
||||
int un = unit_no;
|
||||
for (;;) {
|
||||
_stprintf (buffer, type == FILESYS_CD ? _T("CD%d") : _T("DH%d"), un++);
|
||||
_sntprintf (buffer, sizeof buffer, type == FILESYS_CD ? _T("CD%d") : _T("DH%d"), un++);
|
||||
if (type == FILESYS_CD)
|
||||
*devname = my_strdup (buffer);
|
||||
if (!device_isdup(ctx, expbase, buffer))
|
||||
@ -9551,7 +9551,7 @@ void filesys_install_code (void)
|
||||
TCHAR *s = au(UAEFS_VERSION);
|
||||
int y, m, d;
|
||||
target_getdate(&y, &m, &d);
|
||||
_stprintf(buf, _T("%s (%d.%d.%d)\r\n"), s, d, m, y);
|
||||
_sntprintf(buf, sizeof buf, _T("%s (%d.%d.%d)\r\n"), s, d, m, y);
|
||||
uaecptr idstring = ds(buf);
|
||||
xfree(s);
|
||||
|
||||
@ -9714,7 +9714,7 @@ static TCHAR *makenativepath (UnitInfo *ui, TCHAR *apath)
|
||||
TCHAR *pn;
|
||||
/* create native path. FIXME: handle 'illegal' characters */
|
||||
pn = xcalloc (TCHAR, uaetcslen (apath) + 1 + uaetcslen (ui->rootdir) + 1);
|
||||
_stprintf (pn, _T("%s/%s"), ui->rootdir, apath);
|
||||
_sntprintf (pn, sizeof pn, _T("%s/%s"), ui->rootdir, apath);
|
||||
if (FSDB_DIR_SEPARATOR != '/') {
|
||||
for (int i = 0; i < uaetcslen (pn); i++) {
|
||||
if (pn[i] == '/')
|
||||
@ -9898,7 +9898,7 @@ static uae_u8 *restore_notify (UnitInfo *ui, Unit *u, uae_u8 *src)
|
||||
n->notifyrequest = restore_u32 ();
|
||||
s = restore_string ();
|
||||
n->fullname = xmalloc (TCHAR, uaetcslen (ui->volname) + 2 + uaetcslen (s) + 1);
|
||||
_stprintf (n->fullname, _T("%s:%s"), ui->volname, s);
|
||||
_sntprintf (n->fullname, sizeof n->fullname, _T("%s:%s"), ui->volname, s);
|
||||
xfree(s);
|
||||
s = _tcsrchr (n->fullname, '/');
|
||||
if (s)
|
||||
@ -10391,9 +10391,9 @@ static uae_u32 filesys_shellexecute2_process(int mode, TrapContext *ctx)
|
||||
if (se2->bin) {
|
||||
xfree(se2->file);
|
||||
if (oldks) {
|
||||
sprintf(tmp, "cd \"%s\"\nT:__uae_out_%08X_%08x", se2->currentdir, se2->process, se2->id);
|
||||
_sntprintf(tmp, sizeof tmp, "cd \"%s\"\nT:__uae_out_%08X_%08x", se2->currentdir, se2->process, se2->id);
|
||||
} else {
|
||||
sprintf(tmp, "T:__uae_bin_%08X_%08x", se2->process, se2->id);
|
||||
_sntprintf(tmp, sizeof tmp, "T:__uae_bin_%08X_%08x", se2->process, se2->id);
|
||||
}
|
||||
se2->file = strdup(tmp);
|
||||
}
|
||||
@ -10431,7 +10431,7 @@ static uae_u32 filesys_shellexecute2_process(int mode, TrapContext *ctx)
|
||||
trap_put_long(ctx, se2->buffer + 4, dptr);
|
||||
if (se2->bin) {
|
||||
xfree(se2->file);
|
||||
sprintf(tmp, "T:__uae_bin_%08X_%08x", se2->process, se2->id);
|
||||
_sntprintf(tmp, sizeof tmp, "T:__uae_bin_%08X_%08x", se2->process, se2->id);
|
||||
se2->file = strdup(tmp);
|
||||
trap_put_long(ctx, se2->buffer + 52, dptr);
|
||||
}
|
||||
@ -10443,7 +10443,7 @@ static uae_u32 filesys_shellexecute2_process(int mode, TrapContext *ctx)
|
||||
|
||||
trap_put_long(ctx, se2->buffer + 16, dptr);
|
||||
if (oldks) {
|
||||
sprintf(tmp, "cd \"%s\"\n%s", se2->currentdir, se2->file);
|
||||
_sntprintf(tmp, sizeof tmp, "cd \"%s\"\n%s", se2->currentdir, se2->file);
|
||||
} else {
|
||||
strcpy(tmp, se2->file);
|
||||
}
|
||||
@ -10455,7 +10455,7 @@ static uae_u32 filesys_shellexecute2_process(int mode, TrapContext *ctx)
|
||||
|
||||
if (se2->flags & 2) {
|
||||
trap_put_long(ctx, se2->buffer + 44, dptr);
|
||||
sprintf(tmp, "T:__uae_out_%08X_%08x", se2->process, se2->id);
|
||||
_sntprintf(tmp, sizeof tmp, "T:__uae_out_%08X_%08x", se2->process, se2->id);
|
||||
dptr += trap_put_string(ctx, tmp, dptr, -1) + 1;
|
||||
se2->aoutbuf = dptr;
|
||||
trap_put_long(ctx, se2->buffer + 48, dptr);
|
||||
|
||||
@ -577,21 +577,21 @@ static const TCHAR *fp_print(fpdata *fpd, int mode)
|
||||
if (mode < 0) {
|
||||
uae_u32 w1, w2, w3;
|
||||
fp_from_exten(fpd, &w1, &w2, &w3);
|
||||
_stprintf(fsout, _T("%04X-%08X-%08X"), w1 >> 16, w2, w3);
|
||||
_sntprintf(fsout, sizeof fsout, _T("%04X-%08X-%08X"), w1 >> 16, w2, w3);
|
||||
return fsout;
|
||||
}
|
||||
|
||||
n = signbit(fpd->fp) ? 1 : 0;
|
||||
|
||||
if(isinf(fpd->fp)) {
|
||||
_stprintf(fsout, _T("%c%s"), n ? '-' : '+', _T("inf"));
|
||||
_sntprintf(fsout, sizeof fsout, _T("%c%s"), n ? '-' : '+', _T("inf"));
|
||||
} else if(isnan(fpd->fp)) {
|
||||
_stprintf(fsout, _T("%c%s"), n ? '-' : '+', _T("nan"));
|
||||
_sntprintf(fsout, sizeof fsout, _T("%c%s"), n ? '-' : '+', _T("nan"));
|
||||
} else {
|
||||
#ifdef USE_LONG_DOUBLE
|
||||
_stprintf(fsout, _T("#%Le"), fpd->fp);
|
||||
_sntprintf(fsout, sizeof fsout, _T("#%Le"), fpd->fp);
|
||||
#else
|
||||
_stprintf(fsout, _T("#%e"), fpd->fp);
|
||||
_sntprintf(fsout, sizeof fsout, _T("#%e"), fpd->fp);
|
||||
#endif
|
||||
}
|
||||
if (mode == 0 || mode > _tcslen(fsout))
|
||||
@ -1101,9 +1101,9 @@ static void fp_from_pack (fpdata *src, uae_u32 *wrd, int kfactor)
|
||||
fp_to_native(&fp, src);
|
||||
|
||||
#ifdef USE_LONG_DOUBLE
|
||||
sprintf (str, "%#.17Le", fp);
|
||||
_sntprintf (str, sizeof str, "%#.17Le", fp);
|
||||
#else
|
||||
sprintf (str, "%#.17e", fp);
|
||||
_sntprintf (str, sizeof str, "%#.17e", fp);
|
||||
#endif
|
||||
|
||||
// get exponent
|
||||
|
||||
@ -1417,7 +1417,7 @@ static void initsramattr (int size, int readonly)
|
||||
strcpy ((char*)p, "68000");
|
||||
}
|
||||
p += strlen ((char*)p) + 1;
|
||||
sprintf ((char*)p, "Generic Emulated %dKB PCMCIA SRAM Card", size >> 10);
|
||||
_sntprintf ((char*)p, sizeof p, "Generic Emulated %dKB PCMCIA SRAM Card", size >> 10);
|
||||
p += strlen ((char*)p) + 1;
|
||||
*p++= 0xff;
|
||||
*rp = addrdiff(p, rp) - 1;
|
||||
|
||||
@ -163,28 +163,28 @@ static const struct gfxboard boards[] =
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_PICCOLO_Z2,
|
||||
_T("Piccolo [Zorro II]"), _T("Ingenieurbüro Helfrich"), _T("Piccolo_Z2"),
|
||||
_T("Piccolo [Zorro II]"), _T("Ingenieurbüro Helfrich"), _T("Piccolo_Z2"),
|
||||
BOARD_MANUFACTURER_PICCOLO, BOARD_MODEL_MEMORY_PICCOLO, BOARD_MODEL_REGISTERS_PICCOLO, 0,
|
||||
0x00000000, 0x00100000, 0x00200000, 0x00200000, CIRRUS_ID_CLGD5426, 2, 6, true, true,
|
||||
0, 0, NULL, &gd5426_swapped_device
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_PICCOLO_Z3,
|
||||
_T("Piccolo [Zorro III]"), _T("Ingenieurbüro Helfrich"), _T("Piccolo_Z3"),
|
||||
_T("Piccolo [Zorro III]"), _T("Ingenieurbüro Helfrich"), _T("Piccolo_Z3"),
|
||||
BOARD_MANUFACTURER_PICCOLO, BOARD_MODEL_MEMORY_PICCOLO, BOARD_MODEL_REGISTERS_PICCOLO, 0,
|
||||
0x00000000, 0x00100000, 0x00200000, 0x00200000, CIRRUS_ID_CLGD5426, 3, 6, true, true,
|
||||
0, 0, NULL, &gd5426_swapped_device
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_SD64_Z2,
|
||||
_T("Piccolo SD64 [Zorro II]"), _T("Ingenieurbüro Helfrich"), _T("PiccoloSD64_Z2"),
|
||||
_T("Piccolo SD64 [Zorro II]"), _T("Ingenieurbüro Helfrich"), _T("PiccoloSD64_Z2"),
|
||||
BOARD_MANUFACTURER_PICCOLO, BOARD_MODEL_MEMORY_PICCOLO64, BOARD_MODEL_REGISTERS_PICCOLO64, 0,
|
||||
0x00000000, 0x00200000, 0x00400000, 0x00400000, CIRRUS_ID_CLGD5434, 2, 6, true, true,
|
||||
0, 0, NULL, &gd5434_vlb_swapped_device
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_SD64_Z3,
|
||||
_T("Piccolo SD64 [Zorro III]"), _T("Ingenieurbüro Helfrich"), _T("PiccoloSD64_Z3"),
|
||||
_T("Piccolo SD64 [Zorro III]"), _T("Ingenieurbüro Helfrich"), _T("PiccoloSD64_Z3"),
|
||||
BOARD_MANUFACTURER_PICCOLO, BOARD_MODEL_MEMORY_PICCOLO64, BOARD_MODEL_REGISTERS_PICCOLO64, 0,
|
||||
0x00000000, 0x00200000, 0x00400000, 0x00400000, CIRRUS_ID_CLGD5434, 3, 6, true, true,
|
||||
0, 0, NULL, &gd5434_vlb_swapped_device
|
||||
@ -286,14 +286,14 @@ static const struct gfxboard boards[] =
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_GRAFFITY_Z2,
|
||||
_T("Graffity [Zorro II]"), _T("Atéo Concepts"), _T("GraffityZ2"),
|
||||
_T("Graffity [Zorro II]"), _T("Atéo Concepts"), _T("GraffityZ2"),
|
||||
2092, 34, 33, 0,
|
||||
0x00000000, 0x00100000, 0x00200000, 0x00200000, CIRRUS_ID_CLGD5428, 2, 2, false, true,
|
||||
0, 0, NULL, &gd5428_device
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_GRAFFITY_Z3,
|
||||
_T("Graffity [Zorro III]"), _T("Atéo Concepts"), _T("GraffityZ3"),
|
||||
_T("Graffity [Zorro III]"), _T("Atéo Concepts"), _T("GraffityZ3"),
|
||||
2092, 33, 0, 0,
|
||||
0x00000000, 0x00100000, 0x00200000, 0x01000000, CIRRUS_ID_CLGD5428, 3, 2, false, true,
|
||||
0, 0, NULL, &gd5428_device
|
||||
@ -314,7 +314,7 @@ static const struct gfxboard boards[] =
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_RAINBOWIII,
|
||||
_T("Rainbow III [Zorro III]"), _T("Ingenieurbüro Helfrich"), _T("RainbowIII"),
|
||||
_T("Rainbow III [Zorro III]"), _T("Ingenieurbüro Helfrich"), _T("RainbowIII"),
|
||||
2145, 33, 0, 0,
|
||||
0x00000000, 0x00400000, 0x00400000, 0x02000000, 0, 3, 6, false, false,
|
||||
0, 0, NULL, &inmos_rainbow3_z3_device
|
||||
@ -328,7 +328,7 @@ static const struct gfxboard boards[] =
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_PIXEL64,
|
||||
_T("Pixel64 [AteoBus]"), _T("Atéo Concepts"), _T("Pixel64"),
|
||||
_T("Pixel64 [AteoBus]"), _T("Atéo Concepts"), _T("Pixel64"),
|
||||
2026, 255, 254, 0, // 255: type=$c7 flags=$40, 254: type=$c2 flags=$40 128k, 252: type=$c2 flags=$40, 128k
|
||||
0x00000000, 0x00200000, 0x00200000, 0x00400000, CIRRUS_ID_CLGD5434, 2, 0, false, false,
|
||||
0, 0, NULL, &gd5434_vlb_device
|
||||
@ -356,7 +356,7 @@ static const struct gfxboard boards[] =
|
||||
},
|
||||
{
|
||||
GFXBOARD_ID_RAINBOWII,
|
||||
_T("Rainbow II [Zorro II]"), _T("Ingenieurbüro Helfrich"), _T("RainbowII"),
|
||||
_T("Rainbow II [Zorro II]"), _T("Ingenieurbüro Helfrich"), _T("RainbowII"),
|
||||
2145, 32, 0, 0,
|
||||
0x00000000, 0x00200000, 0x00200000, 0x00200000, 0, 0, 0, false, false,
|
||||
ROMTYPE_RAINBOWII, 0xc6, &rainbowii_func
|
||||
@ -408,7 +408,6 @@ static const struct gfxboard boards[] =
|
||||
ROMTYPE_x86_VGA
|
||||
},
|
||||
{
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
@ -1119,6 +1118,7 @@ static int GetBytesPerPixel(RGBFTYPE RGBfmt)
|
||||
case RGBFB_B5G6R5PC:
|
||||
case RGBFB_B5G5R5PC:
|
||||
return 2;
|
||||
default: return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -4880,11 +4880,11 @@ bool gfxboard_init_memory (struct autoconfig_info *aci)
|
||||
only_gfx_board = gb;
|
||||
|
||||
|
||||
_stprintf(gb->memorybankname, _T("%s VRAM"), gb->board->name);
|
||||
_stprintf(gb->memorybanknamenojit, _T("%s VRAM NOJIT"), gb->board->name);
|
||||
_stprintf(gb->wbsmemorybankname, _T("%s VRAM WORDSWAP"), gb->board->name);
|
||||
_stprintf(gb->lbsmemorybankname, _T("%s VRAM LONGSWAP"), gb->board->name);
|
||||
_stprintf(gb->regbankname, _T("%s REG"), gb->board->name);
|
||||
_sntprintf(gb->memorybankname, sizeof gb->memorybankname, _T("%s VRAM"), gb->board->name);
|
||||
_sntprintf(gb->memorybanknamenojit, sizeof gb->memorybanknamenojit, _T("%s VRAM NOJIT"), gb->board->name);
|
||||
_sntprintf(gb->wbsmemorybankname, sizeof gb->wbsmemorybankname, _T("%s VRAM WORDSWAP"), gb->board->name);
|
||||
_sntprintf(gb->lbsmemorybankname, sizeof gb->lbsmemorybankname, _T("%s VRAM LONGSWAP"), gb->board->name);
|
||||
_sntprintf(gb->regbankname, sizeof gb->regbankname, _T("%s REG"), gb->board->name);
|
||||
|
||||
memcpy(&gb->gfxboard_bank_memory, &tmpl_gfxboard_bank_memory, sizeof (addrbank));
|
||||
memcpy(&gb->gfxboard_bank_wbsmemory, &tmpl_gfxboard_bank_wbsmemory, sizeof(addrbank));
|
||||
|
||||
@ -523,7 +523,7 @@ static void ide_identity_buffer(struct ide_hdf *ide)
|
||||
if (ide->atapi)
|
||||
_tcscpy (tmp, _T("UAE-ATAPI"));
|
||||
else
|
||||
_stprintf (tmp, _T("UAE-IDE %s"), ide->hdhfd.hfd.product_id);
|
||||
_sntprintf (tmp, sizeof tmp, _T("UAE-IDE %s"), ide->hdhfd.hfd.product_id);
|
||||
ps(ide, 27, tmp, 40); /* model */
|
||||
pw(ide, 47, ide->max_multiple_mode ? (0x8000 | (ide->max_multiple_mode >> (ide->blocksize / 512 - 1))) : 0); /* max sectors in multiple mode */
|
||||
pw(ide, 48, 1);
|
||||
|
||||
@ -135,7 +135,7 @@ extern int fsdb_fill_file_attrs (a_inode *, a_inode *);
|
||||
extern int fsdb_set_file_attrs (a_inode *);
|
||||
extern int fsdb_mode_representable_p (const a_inode *, int);
|
||||
extern int fsdb_mode_supported (const a_inode *);
|
||||
extern TCHAR *fsdb_create_unique_nname (a_inode *base, const TCHAR *);
|
||||
extern TCHAR *fsdb_create_unique_nname (const a_inode *base, const TCHAR *);
|
||||
|
||||
struct my_opendir_s;
|
||||
struct my_openfile_s;
|
||||
@ -168,7 +168,7 @@ extern bool my_existsdir (const TCHAR *name);
|
||||
extern FILE *my_opentext (const TCHAR*);
|
||||
|
||||
extern bool my_stat (const TCHAR *name, struct mystat *ms);
|
||||
extern bool my_utime (const TCHAR *name, struct mytimeval *tv);
|
||||
extern bool my_utime (const TCHAR *name, const struct mytimeval *tv);
|
||||
extern bool my_chmod (const TCHAR *name, uae_u32 mode);
|
||||
extern bool my_resolveshortcut(TCHAR *linkfile, int size);
|
||||
extern bool my_resolvessymboliclink(TCHAR *linkfile, int size);
|
||||
|
||||
@ -1139,8 +1139,8 @@ extern bool is_error_log(void);
|
||||
|
||||
extern void default_prefs(struct uae_prefs*, bool, int);
|
||||
extern void discard_prefs(struct uae_prefs*, int);
|
||||
extern void copy_prefs(struct uae_prefs* src, struct uae_prefs* dst);
|
||||
extern void copy_inputdevice_prefs(struct uae_prefs *src, struct uae_prefs *dst);
|
||||
extern void copy_prefs(const struct uae_prefs* src, struct uae_prefs* dst);
|
||||
extern void copy_inputdevice_prefs(const struct uae_prefs *src, struct uae_prefs *dst);
|
||||
|
||||
#ifdef AMIBERRY
|
||||
extern int bip_a500(struct uae_prefs* p, int rom);
|
||||
|
||||
@ -54,7 +54,7 @@ extern void uaeser_clearbuffers (void*);
|
||||
extern void enet_writeser (uae_u16);
|
||||
extern int enet_readseravail (void);
|
||||
extern int enet_readser (uae_u16 *buffer);
|
||||
extern int enet_open (TCHAR *name);
|
||||
extern int enet_open (const TCHAR *name);
|
||||
extern void enet_close (void);
|
||||
|
||||
#endif /* UAE_SERIAL_H */
|
||||
|
||||
@ -23,7 +23,7 @@ struct uae_shmid_ds {
|
||||
|
||||
void *uae_shmat(addrbank *ab, int shmid, void *shmaddr, int shmflg, struct uae_mman_data *md);
|
||||
int uae_shmdt(const void *shmaddr);
|
||||
int uae_shmget(uae_key_t key, addrbank *ab, int shmflg);
|
||||
int uae_shmget(uae_key_t key, const addrbank *ab, int shmflg);
|
||||
int uae_shmctl(int shmid, int cmd, struct uae_shmid_ds *buf);
|
||||
|
||||
#define UAE_IPC_PRIVATE 0x01
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include <SDL.h>
|
||||
|
||||
#include "uae/types.h"
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Make sure the real _tcs* functions are already declared before we
|
||||
@ -34,8 +34,7 @@
|
||||
#define _tcscspn strcspn
|
||||
#define _tcsdup SDL_strdup
|
||||
#define _tcsftime strftime
|
||||
#define _tcsftime strftime
|
||||
#define _tcsicmp strcasecmp
|
||||
#define _tcsicmp SDL_strcasecmp
|
||||
#define _tcslen SDL_strlen
|
||||
#define uaestrlen SDL_strlen
|
||||
#define uaetcslen SDL_strlen
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
// Clipboard functions
|
||||
|
||||
char* uae_clipboard_get_text(void);
|
||||
void uae_clipboard_free_text(char* text);
|
||||
void uae_clipboard_free_text(const char* text);
|
||||
void uae_clipboard_put_text(const char* text);
|
||||
|
||||
#endif // LIBAMIGA_LIBAMIGA_H_
|
||||
10
src/ini.cpp
10
src/ini.cpp
@ -125,14 +125,14 @@ void ini_addnewstring(struct ini_data *ini, const TCHAR *section, const TCHAR *k
|
||||
void ini_addnewval(struct ini_data *ini, const TCHAR *section, const TCHAR *key, uae_u32 v)
|
||||
{
|
||||
TCHAR tmp[MAX_DPATH];
|
||||
_stprintf(tmp, _T("%08X ; %u"), v, v);
|
||||
_sntprintf(tmp, sizeof tmp, _T("%08X ; %u"), v, v);
|
||||
ini_addnewstring(ini, section, key, tmp);
|
||||
}
|
||||
|
||||
void ini_addnewval64(struct ini_data *ini, const TCHAR *section, const TCHAR *key, uae_u64 v)
|
||||
{
|
||||
TCHAR tmp[MAX_DPATH];
|
||||
_stprintf(tmp, _T("%016llX ; %llu"), v, v);
|
||||
_sntprintf(tmp, sizeof tmp, _T("%016llX ; %llu"), v, v);
|
||||
ini_addnewstring(ini, section, key, tmp);
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ void ini_addnewdata(struct ini_data *ini, const TCHAR *section, const TCHAR *key
|
||||
_tcscat(s, _T(" \\\n"));
|
||||
TCHAR *p = s + _tcslen(s);
|
||||
for (int j = 0; j < w && j + i < len; j++) {
|
||||
_stprintf (p, _T("%02X"), data[i + j]);
|
||||
_sntprintf (p, sizeof p, _T("%02X"), data[i + j]);
|
||||
p += 2;
|
||||
}
|
||||
*p = 0;
|
||||
@ -203,7 +203,7 @@ struct ini_data *ini_load(const TCHAR *path, bool sort)
|
||||
struct ini_line *il = ini.inidata[c];
|
||||
if (il && !_tcscmp(il->section, section)) {
|
||||
section_id++;
|
||||
_stprintf(section + _tcslen(section), _T("|%d"), section_id);
|
||||
_sntprintf(section + _tcslen(section), sizeof section, _T("|%d"), section_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -317,7 +317,7 @@ bool ini_nextsection(struct ini_data *ini, TCHAR *section)
|
||||
const TCHAR *s = _tcschr(nextsect, '|');
|
||||
if (s) {
|
||||
int sectionid = _tstol(s + 1);
|
||||
_stprintf(nextsect + (s - nextsect) + 1, _T("%d"), sectionid + 1);
|
||||
_sntprintf(nextsect + (s - nextsect) + 1, sizeof nextsect, _T("%d"), sectionid + 1);
|
||||
} else {
|
||||
_tcscpy(nextsect + _tcslen(nextsect), _T("|2"));
|
||||
}
|
||||
|
||||
@ -722,7 +722,7 @@ static bool isemptykey(int keyboard, int scancode)
|
||||
static void out_config (struct zfile *f, int id, int num, const TCHAR *s1, const TCHAR *s2)
|
||||
{
|
||||
TCHAR tmp[MAX_DPATH];
|
||||
_stprintf (tmp, _T("input.%d.%s%d"), id, s1, num);
|
||||
_sntprintf (tmp, sizeof tmp, _T("input.%d.%s%d"), id, s1, num);
|
||||
cfgfile_write_str (f, tmp, s2);
|
||||
}
|
||||
|
||||
@ -743,7 +743,7 @@ static bool write_config_head (struct zfile *f, int idnum, int devnum, const TCH
|
||||
else if (devnum < idf->get_num ())
|
||||
s = idf->get_friendlyname (devnum);
|
||||
if (s) {
|
||||
_stprintf (tmp2, _T("input.%d.%s.%d.friendlyname"), idnum + 1, name, devnum);
|
||||
_sntprintf (tmp2, sizeof tmp2, _T("input.%d.%s.%d.friendlyname"), idnum + 1, name, devnum);
|
||||
cfgfile_write_str (f, tmp2, s);
|
||||
}
|
||||
|
||||
@ -753,27 +753,27 @@ static bool write_config_head (struct zfile *f, int idnum, int devnum, const TCH
|
||||
else if (devnum < idf->get_num ())
|
||||
s = idf->get_uniquename (devnum);
|
||||
if (s) {
|
||||
_stprintf (tmp2, _T("input.%d.%s.%d.name"), idnum + 1, name, devnum);
|
||||
_sntprintf (tmp2, sizeof tmp2, _T("input.%d.%s.%d.name"), idnum + 1, name, devnum);
|
||||
cfgfile_write_str (f, tmp2, s);
|
||||
}
|
||||
|
||||
if (!isdevice (id)) {
|
||||
_stprintf (tmp2, _T("input.%d.%s.%d.empty"), idnum + 1, name, devnum);
|
||||
_sntprintf (tmp2, sizeof tmp2, _T("input.%d.%s.%d.empty"), idnum + 1, name, devnum);
|
||||
cfgfile_write_bool (f, tmp2, true);
|
||||
if (id->enabled) {
|
||||
_stprintf (tmp2, _T("input.%d.%s.%d.disabled"), idnum + 1, name, devnum);
|
||||
_sntprintf (tmp2, sizeof tmp2, _T("input.%d.%s.%d.disabled"), idnum + 1, name, devnum);
|
||||
cfgfile_write_bool (f, tmp2, id->enabled ? false : true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (idnum == GAMEPORT_INPUT_SETTINGS) {
|
||||
_stprintf (tmp2, _T("input.%d.%s.%d.custom"), idnum + 1, name, devnum);
|
||||
_sntprintf (tmp2, sizeof tmp2, _T("input.%d.%s.%d.custom"), idnum + 1, name, devnum);
|
||||
cfgfile_write_bool (f, tmp2, true);
|
||||
} else {
|
||||
_stprintf (tmp2, _T("input.%d.%s.%d.empty"), idnum + 1, name, devnum);
|
||||
_sntprintf (tmp2, sizeof tmp2, _T("input.%d.%s.%d.empty"), idnum + 1, name, devnum);
|
||||
cfgfile_write_bool (f, tmp2, false);
|
||||
_stprintf (tmp2, _T("input.%d.%s.%d.disabled"), idnum + 1, name, devnum);
|
||||
_sntprintf (tmp2, sizeof tmp2, _T("input.%d.%s.%d.disabled"), idnum + 1, name, devnum);
|
||||
cfgfile_write_bool (f, tmp2, id->enabled ? false : true);
|
||||
}
|
||||
return true;
|
||||
@ -788,10 +788,10 @@ static bool write_slot (TCHAR *p, struct uae_input_device *uid, int i, int j)
|
||||
}
|
||||
uae_u64 flags = uid->flags[i][j];
|
||||
if (uid->custom[i][j] && uid->custom[i][j][0] != '\0') {
|
||||
_stprintf (p, _T("'%s'.%d"), uid->custom[i][j], (int)(flags & ID_FLAG_SAVE_MASK_CONFIG));
|
||||
_sntprintf (p, sizeof p, _T("'%s'.%d"), uid->custom[i][j], (int)(flags & ID_FLAG_SAVE_MASK_CONFIG));
|
||||
ok = true;
|
||||
} else if (uid->eventid[i][j] > 0) {
|
||||
_stprintf (p, _T("%s.%d"), events[uid->eventid[i][j]].confname, (int)(flags & ID_FLAG_SAVE_MASK_CONFIG));
|
||||
_sntprintf (p, sizeof p, _T("%s.%d"), events[uid->eventid[i][j]].confname, (int)(flags & ID_FLAG_SAVE_MASK_CONFIG));
|
||||
ok = true;
|
||||
} else {
|
||||
_tcscpy (p, _T("NULL"));
|
||||
@ -802,9 +802,9 @@ static bool write_slot (TCHAR *p, struct uae_input_device *uid, int i, int j)
|
||||
for (int k = 0; k < MAX_INPUT_QUALIFIERS * 2; k++) {
|
||||
if ((ID_FLAG_QUALIFIER1 << k) & flags) {
|
||||
if (k & 1)
|
||||
_stprintf (p2, _T("%c"), 'a' + k / 2);
|
||||
_sntprintf (p2, sizeof p2, _T("%c"), 'a' + k / 2);
|
||||
else
|
||||
_stprintf (p2, _T("%c"), 'A' + k / 2);
|
||||
_sntprintf (p2, sizeof p2, _T("%c"), 'A' + k / 2);
|
||||
p2++;
|
||||
}
|
||||
}
|
||||
@ -863,7 +863,7 @@ static void write_config2 (struct zfile *f, int idnum, int i, int offset, const
|
||||
if (ok) {
|
||||
if (id->port[io][slotorder[j]] > 0 && id->port[io][slotorder[j]] < MAX_JPORTS + 1) {
|
||||
int pnum = id->port[io][slotorder[j]] - 1;
|
||||
_stprintf (p, _T(".%d"), pnum);
|
||||
_sntprintf (p, sizeof p, _T(".%d"), pnum);
|
||||
p += _tcslen (p);
|
||||
if (idnum != GAMEPORT_INPUT_SETTINGS && j == 0 && id->port[io][SPARE_SUB_EVENT] && slotorder == slotorder1) {
|
||||
*p++ = '.';
|
||||
@ -874,7 +874,7 @@ static void write_config2 (struct zfile *f, int idnum, int i, int offset, const
|
||||
}
|
||||
}
|
||||
if (p > tmp2) {
|
||||
_stprintf (tmp3, _T("input.%d.%s%d"), idnum + 1, extra, i);
|
||||
_sntprintf (tmp3, sizeof tmp3, _T("input.%d.%s%d"), idnum + 1, extra, i);
|
||||
cfgfile_write_str (f, tmp3, tmp2);
|
||||
}
|
||||
}
|
||||
@ -971,7 +971,7 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae
|
||||
if (ok) {
|
||||
// save port number + SPARE SLOT if needed
|
||||
if (kbr->port[i][slotorder[j]] > 0 && (kbr->flags[i][slotorder[j]] & ID_FLAG_GAMEPORTSCUSTOM_MASK)) {
|
||||
_stprintf (p, _T(".%d"), kbr->port[i][slotorder[j]] - 1);
|
||||
_sntprintf (p, sizeof p, _T(".%d"), kbr->port[i][slotorder[j]] - 1);
|
||||
p += _tcslen (p);
|
||||
if (idnum != GAMEPORT_INPUT_SETTINGS && j == 0 && kbr->port[i][SPARE_SUB_EVENT] && !isdefaultspare && slotorder == slotorder1) {
|
||||
*p++ = '.';
|
||||
@ -982,10 +982,10 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae
|
||||
}
|
||||
}
|
||||
idf->get_widget_type (devnum, i, tmp5, NULL);
|
||||
_stprintf (tmp3, _T("%d%s%s"), kbr->extra[i], tmp5[0] ? _T(".") : _T(""), tmp5[0] ? tmp5 : _T(""));
|
||||
_sntprintf (tmp3, sizeof tmp3, _T("%d%s%s"), kbr->extra[i], tmp5[0] ? _T(".") : _T(""), tmp5[0] ? tmp5 : _T(""));
|
||||
kbrlabel (tmp3);
|
||||
_stprintf (tmp1, _T("keyboard.%d.button.%s"), devnum, tmp3);
|
||||
_stprintf (tmp4, _T("input.%d.%s"), idnum + 1, tmp1);
|
||||
_sntprintf (tmp1, sizeof tmp1, _T("keyboard.%d.button.%s"), devnum, tmp3);
|
||||
_sntprintf (tmp4, sizeof tmp4, _T("input.%d.%s"), idnum + 1, tmp1);
|
||||
cfgfile_write_str (f, tmp4, tmp2[0] ? tmp2 : _T("NULL"));
|
||||
i++;
|
||||
}
|
||||
@ -999,10 +999,10 @@ static void write_config (struct zfile *f, int idnum, int devnum, const TCHAR *n
|
||||
if (!write_config_head (f, idnum, devnum, name, id, idf))
|
||||
return;
|
||||
|
||||
_stprintf (tmp1, _T("%s.%d.axis."), name, devnum);
|
||||
_sntprintf (tmp1, sizeof tmp1, _T("%s.%d.axis."), name, devnum);
|
||||
for (i = 0; i < ID_AXIS_TOTAL; i++)
|
||||
write_config2 (f, idnum, i, ID_AXIS_OFFSET, tmp1, id);
|
||||
_stprintf (tmp1, _T("%s.%d.button.") ,name, devnum);
|
||||
_sntprintf (tmp1, sizeof tmp1, _T("%s.%d.button.") ,name, devnum);
|
||||
for (i = 0; i < ID_BUTTON_TOTAL; i++)
|
||||
write_config2 (f, idnum, i, ID_BUTTON_OFFSET, tmp1, id);
|
||||
}
|
||||
@ -1961,26 +1961,26 @@ static void generate_jport_custom_item(struct uae_input_device *uid, int num, in
|
||||
if (out[0])
|
||||
*p++= ' ';
|
||||
if (devtype == IDTYPE_KEYBOARD) {
|
||||
_stprintf(p, _T("k.%d.b.%d"), num, uid2->extra[i]);
|
||||
_sntprintf(p, sizeof p, _T("k.%d.b.%d"), num, uid2->extra[i]);
|
||||
} else if (devtype == IDTYPE_JOYSTICK || devtype == IDTYPE_MOUSE) {
|
||||
TCHAR type = devtype == IDTYPE_JOYSTICK ? 'j' : 'm';
|
||||
if (i >= ID_BUTTON_OFFSET && i < ID_BUTTON_OFFSET + ID_BUTTON_TOTAL) {
|
||||
_stprintf(p, _T("%c.%d.b.%d"), type, num, i - ID_BUTTON_OFFSET);
|
||||
_sntprintf(p, sizeof p, _T("%c.%d.b.%d"), type, num, i - ID_BUTTON_OFFSET);
|
||||
} else if (i >= ID_AXIS_OFFSET && i < ID_AXIS_OFFSET + ID_AXIS_TOTAL) {
|
||||
_stprintf(p, _T("%c.%d.a.%d"), type, num, i - ID_AXIS_OFFSET);
|
||||
_sntprintf(p, sizeof p, _T("%c.%d.a.%d"), type, num, i - ID_AXIS_OFFSET);
|
||||
}
|
||||
}
|
||||
TCHAR *p3 = p + _tcslen(p);
|
||||
_stprintf(p3, _T(".%d"), (int)(flags & (ID_FLAG_AUTOFIRE | ID_FLAG_TOGGLE | ID_FLAG_INVERTTOGGLE | ID_FLAG_INVERT)));
|
||||
_sntprintf(p3, sizeof p3, _T(".%d"), (int)(flags & (ID_FLAG_AUTOFIRE | ID_FLAG_TOGGLE | ID_FLAG_INVERTTOGGLE | ID_FLAG_INVERT)));
|
||||
if (flags & ID_FLAG_SAVE_MASK_QUALIFIERS) {
|
||||
TCHAR *p2 = p + _tcslen(p);
|
||||
*p2++ = '.';
|
||||
for (int k = 0; k < MAX_INPUT_QUALIFIERS * 2; k++) {
|
||||
if ((ID_FLAG_QUALIFIER1 << k) & flags) {
|
||||
if (k & 1)
|
||||
_stprintf(p2, _T("%c"), 'a' + k / 2);
|
||||
_sntprintf(p2, sizeof p2, _T("%c"), 'a' + k / 2);
|
||||
else
|
||||
_stprintf(p2, _T("%c"), 'A' + k / 2);
|
||||
_sntprintf(p2, sizeof p2, _T("%c"), 'A' + k / 2);
|
||||
p2++;
|
||||
}
|
||||
}
|
||||
@ -6102,7 +6102,7 @@ static int switchdevice (struct uae_input_device *id, int num, bool buttonmode)
|
||||
|
||||
if (newslot >= 0) {
|
||||
TCHAR cust[100];
|
||||
_stprintf(cust, _T("custom%d"), newslot);
|
||||
_sntprintf(cust, sizeof cust, _T("custom%d"), newslot);
|
||||
inputdevice_joyport_config(&changed_prefs, cust, cust, newport, -1, -1, 0, true);
|
||||
} else {
|
||||
inputdevice_joyport_config(&changed_prefs, name, name, newport, -1, -1, 1, true);
|
||||
@ -8322,7 +8322,7 @@ bool inputdevice_devicechange (struct uae_prefs *prefs)
|
||||
bool found = true;
|
||||
if (jportscustom[i] >= 0) {
|
||||
TCHAR tmp[10];
|
||||
_stprintf(tmp, _T("custom%d"), jportscustom[i]);
|
||||
_sntprintf(tmp, sizeof tmp, _T("custom%d"), jportscustom[i]);
|
||||
found = inputdevice_joyport_config(prefs, tmp, NULL, i, jportsmode[i], jportssubmode[i], 0, true) != 0;
|
||||
} else if ((jports_name[i] && jports_name[i][0]) || (jports_configname[i] && jports_configname[i][0])) {
|
||||
if (!inputdevice_joyport_config (prefs, jports_name[i], jports_configname[i], i, jportsmode[i], jportssubmode[i], 1, true)) {
|
||||
@ -8333,7 +8333,7 @@ bool inputdevice_devicechange (struct uae_prefs *prefs)
|
||||
}
|
||||
} else if (jportskb[i] >= 0) {
|
||||
TCHAR tmp[10];
|
||||
_stprintf (tmp, _T("kbd%d"), jportskb[i] + 1);
|
||||
_sntprintf (tmp, sizeof tmp, _T("kbd%d"), jportskb[i] + 1);
|
||||
found = inputdevice_joyport_config (prefs, tmp, NULL, i, jportsmode[i], jportssubmode[i], 0, true) != 0;
|
||||
|
||||
}
|
||||
@ -9123,7 +9123,7 @@ int inputdevice_get_widget_type (int devnum, int num, TCHAR *name, bool inccode)
|
||||
if (r && inccode && &idev[IDTYPE_KEYBOARD] == idf) {
|
||||
TCHAR *p = name + _tcslen(name);
|
||||
if (_tcsncmp(name, _T("KEY_"), 4))
|
||||
_stprintf(p, _T(" [0x%02X]"), code);
|
||||
_sntprintf(p, sizeof p, _T(" [0x%02X]"), code);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@ -9142,7 +9142,7 @@ int inputdevice_config_change_test (void)
|
||||
return v;
|
||||
}
|
||||
|
||||
static void copy_inputdevice_settings(struct uae_input_device *src, struct uae_input_device *dst)
|
||||
static void copy_inputdevice_settings(const struct uae_input_device *src, struct uae_input_device *dst)
|
||||
{
|
||||
for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) {
|
||||
for (int i = 0; i < MAX_INPUT_SUB_EVENT_ALL; i++) {
|
||||
@ -9155,7 +9155,7 @@ static void copy_inputdevice_settings(struct uae_input_device *src, struct uae_i
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_inputdevice_settings_free(struct uae_input_device *src, struct uae_input_device *dst)
|
||||
static void copy_inputdevice_settings_free(const struct uae_input_device *src, struct uae_input_device *dst)
|
||||
{
|
||||
for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) {
|
||||
for (int i = 0; i < MAX_INPUT_SUB_EVENT_ALL; i++) {
|
||||
@ -10027,9 +10027,9 @@ static bool fixjport(struct jport *port, int add, bool always)
|
||||
_tcsncpy(port->idc.name, inputdevice_get_device_name (IDTYPE_MOUSE, vv - JSEM_MICE), MAX_JPORT_NAME - 1);
|
||||
_tcsncpy(port->idc.configname, inputdevice_get_device_unique_name (IDTYPE_MOUSE, vv - JSEM_MICE), MAX_JPORT_CONFIG - 1);
|
||||
} else if (vv >= JSEM_KBDLAYOUT && vv < JSEM_CUSTOM) {
|
||||
_stprintf(port->idc.shortid, _T("kbd%d"), vv - JSEM_KBDLAYOUT + 1);
|
||||
_sntprintf(port->idc.shortid, sizeof port->idc.shortid, _T("kbd%d"), vv - JSEM_KBDLAYOUT + 1);
|
||||
} else if (vv >= JSEM_CUSTOM && vv < JSEM_JOYS) {
|
||||
_stprintf(port->idc.shortid, _T("custom%d"), vv - JSEM_CUSTOM);
|
||||
_sntprintf(port->idc.shortid, sizeof port->idc.shortid, _T("custom%d"), vv - JSEM_CUSTOM);
|
||||
}
|
||||
port->idc.name[MAX_JPORT_NAME - 1] = 0;
|
||||
port->idc.configname[MAX_JPORT_CONFIG - 1] = 0;
|
||||
@ -10378,7 +10378,7 @@ void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig)
|
||||
struct jport_custom *jpc = &p->jports_custom[i];
|
||||
if (!_tcscmp(jpc->custom, _T("#"))) {
|
||||
TCHAR tmp[16];
|
||||
_stprintf(tmp, _T("custom%d"), i);
|
||||
_sntprintf(tmp, sizeof tmp, _T("custom%d"), i);
|
||||
inputdevice_joyport_config(p, tmp, NULL, i, -1, -1, 0, userconfig);
|
||||
inputdevice_generate_jport_custom(p, i);
|
||||
}
|
||||
|
||||
@ -959,7 +959,7 @@ void inprec_getstatus (TCHAR *title)
|
||||
_tcscat (title, _T(" "));
|
||||
p = title + _tcslen (title);
|
||||
int mvp = current_maxvpos ();
|
||||
_stprintf (p, _T("%03d %02d:%02d:%02d/%02d:%02d:%02d"), replaypos,
|
||||
_sntprintf (p, sizeof p, _T("%03d %02d:%02d:%02d/%02d:%02d:%02d"), replaypos,
|
||||
(int)(lasthsync / (vblank_hz * mvp * 60)), ((int)(lasthsync / (vblank_hz * mvp)) % 60), (lasthsync / mvp) % (int)vblank_hz,
|
||||
(int)(endhsync / (vblank_hz * mvp * 60)), ((int)(endhsync / (vblank_hz * mvp)) % 60), (endhsync / mvp) % (int)vblank_hz);
|
||||
p += _tcslen (p);
|
||||
|
||||
@ -2226,7 +2226,7 @@ static int get_acorn_filename(struct iso_directory_record *de, char *retname, st
|
||||
*retname = '!';
|
||||
if (((de->flags[0] & 2) == 0) && (chr[13] == 0xff) && ((chr[12] & 0xf0) == 0xf0)) {
|
||||
retname[retnamlen] = ',';
|
||||
sprintf(retname+retnamlen+1, "%3.3x",
|
||||
_sntprintf(retname+retnamlen+1, sizeof retname, "%3.3x",
|
||||
((chr[12] & 0xf) << 8) | chr[11]);
|
||||
retnamlen += 4;
|
||||
}
|
||||
@ -2461,7 +2461,7 @@ bool isofs_mediainfo(void *sbp, struct isofs_info *ii)
|
||||
uae_u32 totalblocks = 0;
|
||||
ii->media = true;
|
||||
di.cylinders = 0;
|
||||
_stprintf (ii->devname, _T("CD%d"), sb->unitnum);
|
||||
_sntprintf (ii->devname, sizeof ii->devname, _T("CD%d"), sb->unitnum);
|
||||
if (sys_command_info (sb->unitnum, &di, true)) {
|
||||
totalblocks = di.cylinders * di.sectorspertrack * di.trackspercylinder;
|
||||
uae_tcslcpy (ii->devname, di.label, sizeof (ii->devname));
|
||||
|
||||
20
src/main.cpp
20
src/main.cpp
@ -76,7 +76,7 @@
|
||||
#include "keyboard.h"
|
||||
|
||||
// Special version string so that AmigaOS can detect it
|
||||
static const char __ver[40] = "$VER: Amiberry v6.3.5 (2024-09-20)";
|
||||
static constexpr char __ver[40] = "$VER: Amiberry v7.0 (2025-01-02)";
|
||||
|
||||
long int version = 256 * 65536L * UAEMAJOR + 65536L * UAEMINOR + UAESUBREV;
|
||||
|
||||
@ -96,7 +96,7 @@ static TCHAR optionsfile[MAX_DPATH];
|
||||
static uae_u32 randseed;
|
||||
|
||||
static uae_u32 xorshiftstate;
|
||||
static uae_u32 xorshift32(void)
|
||||
static uae_u32 xorshift32()
|
||||
{
|
||||
uae_u32 x = xorshiftstate;
|
||||
x ^= x << 13;
|
||||
@ -106,7 +106,7 @@ static uae_u32 xorshift32(void)
|
||||
return xorshiftstate;
|
||||
}
|
||||
|
||||
uae_u32 uaerand(void)
|
||||
uae_u32 uaerand()
|
||||
{
|
||||
if (xorshiftstate == 0) {
|
||||
xorshiftstate = randseed;
|
||||
@ -119,7 +119,7 @@ uae_u32 uaerand(void)
|
||||
return r;
|
||||
}
|
||||
|
||||
uae_u32 uaerandgetseed(void)
|
||||
uae_u32 uaerandgetseed()
|
||||
{
|
||||
if (!randseed) {
|
||||
randseed = 1;
|
||||
@ -879,7 +879,7 @@ void usage()
|
||||
|
||||
static void parse_cmdline_2 (int argc, TCHAR **argv)
|
||||
{
|
||||
cfgfile_addcfgparam (0);
|
||||
cfgfile_addcfgparam (nullptr);
|
||||
for (auto i = 1; i < argc; i++) {
|
||||
if (_tcsncmp(argv[i], _T("-cfgparam="), 10) == 0) {
|
||||
cfgfile_addcfgparam(argv[i] + 10);
|
||||
@ -917,7 +917,7 @@ static void parse_diskswapper (const TCHAR *s)
|
||||
p2 = _tcstok(p1, delim);
|
||||
if (!p2)
|
||||
break;
|
||||
p1 = NULL;
|
||||
p1 = nullptr;
|
||||
if (num >= MAX_SPARE_DRIVES)
|
||||
break;
|
||||
if (!zfile_zopen (p2, diskswapper_cb, &num)) {
|
||||
@ -946,7 +946,7 @@ static TCHAR *parsetext (const TCHAR *s)
|
||||
static TCHAR *parsetextpath (const TCHAR *s)
|
||||
{
|
||||
auto* const s2 = parsetext (s);
|
||||
auto* const s3 = target_expand_environment (s2, NULL, 0);
|
||||
auto* const s3 = target_expand_environment (s2, nullptr, 0);
|
||||
xfree(s2);
|
||||
return s3;
|
||||
}
|
||||
@ -1201,9 +1201,9 @@ static void parse_cmdline (int argc, TCHAR **argv)
|
||||
std::string filename = p.filename().string();
|
||||
|
||||
std::string config_extension = "uae";
|
||||
const std::size_t pos = filename.find_last_of(".");
|
||||
const std::size_t pos = filename.find_last_of('.');
|
||||
if (pos != std::string::npos) {
|
||||
filename = filename.substr(0, pos) + "." + config_extension;
|
||||
filename = filename.substr(0, pos).append(".").append(config_extension);
|
||||
}
|
||||
else {
|
||||
// No extension found
|
||||
@ -1538,7 +1538,7 @@ static int real_main2 (int argc, TCHAR **argv)
|
||||
#ifdef NATMEM_OFFSET
|
||||
if (!init_shm ()) {
|
||||
if (currprefs.start_gui)
|
||||
uae_restart(&currprefs, -1, NULL);
|
||||
uae_restart(&currprefs, -1, nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1936,22 +1936,22 @@ static struct zfile *get_kickstart_filehandle(struct uae_prefs *p)
|
||||
// don't check default paths if romfile is empty
|
||||
if (p->romfile[0] != 0) {
|
||||
#endif
|
||||
_stprintf(tmprom2, _T("%s/%s"), home_dir.c_str(), p->romfile);
|
||||
_sntprintf(tmprom2, sizeof tmprom2, _T("%s/%s"), home_dir.c_str(), p->romfile);
|
||||
f = rom_fopen(tmprom2, _T("rb"), ZFD_NORMAL);
|
||||
#ifdef AMIBERRY
|
||||
}
|
||||
#endif
|
||||
if (f == NULL) {
|
||||
_stprintf(tmprom2, _T("%s/roms/kick.rom"), home_dir.c_str());
|
||||
_sntprintf(tmprom2, sizeof tmprom2, _T("%s/roms/kick.rom"), home_dir.c_str());
|
||||
f = rom_fopen(tmprom2, _T("rb"), ZFD_NORMAL);
|
||||
if (f == NULL) {
|
||||
_stprintf(tmprom2, _T("%s/kick.rom"), home_dir.c_str());
|
||||
_sntprintf(tmprom2, sizeof tmprom2, _T("%s/kick.rom"), home_dir.c_str());
|
||||
f = rom_fopen(tmprom2, _T("rb"), ZFD_NORMAL);
|
||||
if (f == NULL) {
|
||||
_stprintf(tmprom2, _T("%s/../shared/rom/kick.rom"), home_dir.c_str());
|
||||
_sntprintf(tmprom2, sizeof tmprom2, _T("%s/../shared/rom/kick.rom"), home_dir.c_str());
|
||||
f = rom_fopen(tmprom2, _T("rb"), ZFD_NORMAL);
|
||||
if (f == NULL) {
|
||||
_stprintf(tmprom2, _T("%s/../System/rom/kick.rom"), home_dir.c_str());
|
||||
_sntprintf(tmprom2, sizeof tmprom2, _T("%s/../System/rom/kick.rom"), home_dir.c_str());
|
||||
f = rom_fopen(tmprom2, _T("rb"), ZFD_NORMAL);
|
||||
if (f == NULL) {
|
||||
f = read_rom_name_guess(tmprom, tmprom2);
|
||||
@ -3926,7 +3926,7 @@ uae_u8 *save_rom(int first, size_t *len, uae_u8 *dstptr)
|
||||
mem_start += ROM_SIZE_256;
|
||||
}
|
||||
version = get_long(mem_start + 12); /* version+revision */
|
||||
_stprintf (tmpname, _T("Kickstart %d.%d"), get_word(mem_start + 12), get_word(mem_start + 14));
|
||||
_sntprintf (tmpname, sizeof tmpname, _T("Kickstart %d.%d"), get_word(mem_start + 12), get_word(mem_start + 14));
|
||||
break;
|
||||
case 1: /* Extended ROM */
|
||||
if (!extendedkickmem_type)
|
||||
@ -3938,7 +3938,7 @@ uae_u8 *save_rom(int first, size_t *len, uae_u8 *dstptr)
|
||||
version = get_long(mem_start + 12); /* version+revision */
|
||||
if (version == 0xffffffff)
|
||||
version = get_long(mem_start + 16);
|
||||
_stprintf (tmpname, _T("Extended"));
|
||||
_sntprintf (tmpname, sizeof tmpname, _T("Extended"));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
||||
510
src/newcpu.cpp
510
src/newcpu.cpp
File diff suppressed because it is too large
Load Diff
@ -17,12 +17,12 @@
|
||||
|
||||
#if defined(AHI)
|
||||
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <cctype>
|
||||
#include <cassert>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
|
||||
#include "options.h"
|
||||
#include "audio.h"
|
||||
@ -75,7 +75,7 @@ struct winuae //this struct is put in a6 if you call
|
||||
};
|
||||
static struct winuae uaevar;
|
||||
|
||||
void ahi_close_sound(void)
|
||||
void ahi_close_sound()
|
||||
{
|
||||
if (!ahi_on)
|
||||
return;
|
||||
@ -146,7 +146,7 @@ void ahi_updatesound(int force)
|
||||
|
||||
if (currprefs.sound_stereo_swap_ahi) {
|
||||
int i;
|
||||
uae_s16 *p = (uae_s16*)ahisndbuffer;
|
||||
auto p = reinterpret_cast<uae_s16*>(ahisndbuffer);
|
||||
for (i = 0; i < dwBytes1 / 2; i += 2) {
|
||||
uae_s16 tmp;
|
||||
tmp = p[i + 0];
|
||||
@ -173,13 +173,13 @@ void ahi_updatesound(int force)
|
||||
}
|
||||
|
||||
|
||||
void ahi_finish_sound_buffer (void)
|
||||
void ahi_finish_sound_buffer ()
|
||||
{
|
||||
sound_flushes2++;
|
||||
ahi_updatesound(2);
|
||||
}
|
||||
|
||||
static int ahi_init_record (void)
|
||||
static int ahi_init_record ()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
HRESULT hr;
|
||||
@ -219,9 +219,9 @@ static int ahi_init_record (void)
|
||||
desired.format = AUDIO_S16SYS;
|
||||
desired.channels = sound_channels_ahi;
|
||||
desired.samples = amigablksize * 4 * RECORDBUFFER;
|
||||
desired.callback = NULL; // We'll use SDL_QueueAudio and SDL_DequeueAudio instead of a callback
|
||||
desired.callback = nullptr; // We'll use SDL_QueueAudio and SDL_DequeueAudio instead of a callback
|
||||
|
||||
ahi_dev_rec = SDL_OpenAudioDevice(NULL, 1, &desired, &obtained, 0);
|
||||
ahi_dev_rec = SDL_OpenAudioDevice(nullptr, 1, &desired, &obtained, 0);
|
||||
if (ahi_dev_rec == 0) {
|
||||
write_log(_T("AHI: SDL_OpenAudioDevice() failure: %s\n"), SDL_GetError());
|
||||
record_enabled = -1;
|
||||
@ -254,7 +254,7 @@ void setvolume_ahi (int vol)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int ahi_init_sound(void)
|
||||
static int ahi_init_sound()
|
||||
{
|
||||
if (ahi_dev)
|
||||
return 0;
|
||||
@ -301,7 +301,7 @@ static int ahi_init_sound(void)
|
||||
return sound_freq_ahi;
|
||||
}
|
||||
|
||||
int ahi_open_sound (void)
|
||||
int ahi_open_sound ()
|
||||
{
|
||||
int rate;
|
||||
|
||||
@ -390,10 +390,9 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
|
||||
|
||||
case 2:
|
||||
{
|
||||
int i;
|
||||
uaecptr addr = m68k_areg (regs, 0);
|
||||
for (i = 0; i < amigablksize * 4; i += 4)
|
||||
*ahisndbufpt++ = get_long (addr + i);
|
||||
for (int i = 0; i < amigablksize * 4; i += 4)
|
||||
*ahisndbufpt++ = static_cast<int>(get_long(addr + i));
|
||||
ahi_finish_sound_buffer();
|
||||
}
|
||||
return amigablksize;
|
||||
@ -454,9 +453,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
|
||||
lpDSB2r->Unlock(pos1, byte1, pos2, byte2);
|
||||
return (todo - t) / t;
|
||||
#else
|
||||
uaecptr addr;
|
||||
int i, todo;
|
||||
Uint32 byte1, byte2;
|
||||
Uint32 byte1, byte2;
|
||||
|
||||
if (!ahi_on)
|
||||
return -2;
|
||||
@ -465,16 +462,16 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
|
||||
if (record_enabled < 0)
|
||||
return -2;
|
||||
|
||||
todo = SDL_GetQueuedAudioSize(ahi_dev_rec);
|
||||
auto todo = SDL_GetQueuedAudioSize(ahi_dev_rec);
|
||||
if (todo < amigablksize * 4) //if no complete buffer ready exit
|
||||
return -1;
|
||||
|
||||
addr = m68k_areg(regs, 0);
|
||||
uae_u16* sndbufrecpt = (uae_u16*)malloc(todo);
|
||||
uaecptr addr = m68k_areg(regs, 0);
|
||||
auto* sndbufrecpt = static_cast<uae_u16*>(malloc(todo));
|
||||
SDL_DequeueAudio(ahi_dev_rec, sndbufrecpt, todo);
|
||||
|
||||
todo /= 4;
|
||||
for (i = 0; i < todo; i++) {
|
||||
for (int i = 0; i < todo; i++) {
|
||||
uae_u32 s1, s2;
|
||||
if (currprefs.sound_stereo_swap_ahi) {
|
||||
s1 = sndbufrecpt[1];
|
||||
@ -496,10 +493,9 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
|
||||
|
||||
case 4:
|
||||
{
|
||||
int i;
|
||||
if (!ahi_on)
|
||||
return -2;
|
||||
i = intcount;
|
||||
int i = intcount;
|
||||
intcount = 0;
|
||||
return i;
|
||||
}
|
||||
@ -536,7 +532,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
|
||||
|
||||
case 12:
|
||||
{
|
||||
TCHAR* s = au((char*)get_real_address(m68k_areg(regs, 0)));
|
||||
TCHAR* s = au(reinterpret_cast<char*>(get_real_address(m68k_areg(regs, 0))));
|
||||
if (SDL_SetClipboardText(s) != 0) {
|
||||
// handle error
|
||||
write_log("Unable to set clipboard text: %s\n", SDL_GetError());
|
||||
@ -608,9 +604,9 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
|
||||
{
|
||||
struct timespec ts {};
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
const auto time = int64_t(ts.tv_sec) * 1000000000 + ts.tv_nsec;
|
||||
put_long(m68k_areg(regs, 0), uae_u32(time & 0xffffffff));
|
||||
put_long(m68k_areg(regs, 0) + 4, uae_u32(time >> 32));
|
||||
const auto time = static_cast<int64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec;
|
||||
put_long(m68k_areg(regs, 0), static_cast<uae_u32>(time & 0xffffffff));
|
||||
put_long(m68k_areg(regs, 0) + 4, static_cast<uae_u32>(time >> 32));
|
||||
}
|
||||
return 1;
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
extern void ahi_updatesound(int force);
|
||||
extern uae_u32 REGPARAM2 ahi_demux (TrapContext*);
|
||||
extern int ahi_open_sound (void);
|
||||
extern void ahi_close_sound (void);
|
||||
extern void ahi_finish_sound_buffer (void);
|
||||
extern int ahi_open_sound ();
|
||||
extern void ahi_close_sound ();
|
||||
extern void ahi_finish_sound_buffer ();
|
||||
extern void init_ahi();
|
||||
extern void ahi_hsync();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -887,7 +887,7 @@ void filesys_host_init()
|
||||
int target_get_volume_name(struct uaedev_mount_info* mtinf, struct uaedev_config_info* ci, bool inserted,
|
||||
bool fullcheck, int cnt)
|
||||
{
|
||||
sprintf(ci->volname, "DH_%c", ci->rootdir[0]);
|
||||
_sntprintf(ci->volname, sizeof ci->volname, "DH_%c", ci->rootdir[0]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@ -720,7 +720,7 @@ static void addmode(struct MultiDisplay* md, SDL_DisplayMode* dm, int rawmode)
|
||||
md->DisplayModes[i].refresh[1] = 0;
|
||||
md->DisplayModes[i].colormodes = ct;
|
||||
md->DisplayModes[i + 1].depth = -1;
|
||||
_stprintf(md->DisplayModes[i].name, _T("%dx%d%s, %d-bit"),
|
||||
_sntprintf(md->DisplayModes[i].name, sizeof md->DisplayModes[i].name, _T("%dx%d%s, %d-bit"),
|
||||
md->DisplayModes[i].res.width, md->DisplayModes[i].res.height,
|
||||
lace ? _T("i") : _T(""),
|
||||
md->DisplayModes[i].depth * 8);
|
||||
@ -847,7 +847,7 @@ void sortdisplays()
|
||||
Displays[0].rect.w = bounds.w;
|
||||
Displays[0].rect.h = bounds.h;
|
||||
|
||||
sprintf(tmp, "%s (%d*%d)", "Display", Displays[0].rect.w, Displays[0].rect.h);
|
||||
_sntprintf(tmp, sizeof tmp, "%s (%d*%d)", "Display", Displays[0].rect.w, Displays[0].rect.h);
|
||||
Displays[0].fullname = my_strdup(tmp);
|
||||
Displays[0].monitorname = my_strdup("Display");
|
||||
|
||||
|
||||
@ -57,18 +57,16 @@ static struct uae_driveinfo uae_drives[MAX_FILESYSTEM_UNITS];
|
||||
static void rdbdump(FILE* h, uae_u64 offset, uae_u8* buf, int blocksize)
|
||||
{
|
||||
static int cnt = 1;
|
||||
int i, blocks;
|
||||
char name[100];
|
||||
FILE* f;
|
||||
|
||||
blocks = (buf[132] << 24) | (buf[133] << 16) | (buf[134] << 8) | (buf[135] << 0);
|
||||
int blocks = (buf[132] << 24) | (buf[133] << 16) | (buf[134] << 8) | (buf[135] << 0);
|
||||
if (blocks < 0 || blocks > 100000)
|
||||
return;
|
||||
_stprintf(name, "rdb_dump_%d.rdb", cnt);
|
||||
f = uae_tfopen(name, "wb");
|
||||
_sntprintf(name, sizeof name, "rdb_dump_%d.rdb", cnt);
|
||||
auto f = uae_tfopen(name, "wb");
|
||||
if (!f)
|
||||
return;
|
||||
for (i = 0; i <= blocks; i++) {
|
||||
for (int i = 0; i <= blocks; i++) {
|
||||
if (_fseeki64(h, offset, SEEK_SET) != 0)
|
||||
break;
|
||||
int outlen = fread(buf, 1, blocksize, h);
|
||||
@ -84,25 +82,23 @@ static void rdbdump(FILE* h, uae_u64 offset, uae_u8* buf, int blocksize)
|
||||
}
|
||||
|
||||
static int ismounted(FILE* f) {
|
||||
int mounted;
|
||||
//mounted = 1;
|
||||
mounted = 0;
|
||||
int mounted = 0;
|
||||
return mounted;
|
||||
}
|
||||
|
||||
#define CA "Commodore\0Amiga\0"
|
||||
static int safetycheck(FILE* h, const char* name, uae_u64 offset, uae_u8* buf, int blocksize)
|
||||
{
|
||||
int i, j, blocks = 63, empty = 1;
|
||||
long outlen;
|
||||
int blocks = 63, empty = 1;
|
||||
|
||||
for (j = 0; j < blocks; j++) {
|
||||
for (int j = 0; j < blocks; j++) {
|
||||
if (_fseeki64(h, offset, SEEK_SET) != 0) {
|
||||
write_log("hd ignored, SetFilePointer failed, error %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
memset(buf, 0xaa, blocksize);
|
||||
outlen = fread(buf, 1, blocksize, h);
|
||||
auto outlen = fread(buf, 1, blocksize, h);
|
||||
if (outlen != blocksize) {
|
||||
write_log("hd ignored, read error %d!\n", errno);
|
||||
return 2;
|
||||
@ -128,7 +124,7 @@ static int safetycheck(FILE* h, const char* name, uae_u64 offset, uae_u8* buf, i
|
||||
return -2;
|
||||
}
|
||||
if (j == 0) {
|
||||
for (i = 0; i < blocksize; i++) {
|
||||
for (int i = 0; i < blocksize; i++) {
|
||||
if (buf[i])
|
||||
empty = 0;
|
||||
}
|
||||
@ -136,8 +132,7 @@ static int safetycheck(FILE* h, const char* name, uae_u64 offset, uae_u8* buf, i
|
||||
offset += blocksize;
|
||||
}
|
||||
if (!empty) {
|
||||
int mounted;
|
||||
mounted = ismounted(h);
|
||||
int mounted = ismounted(h);
|
||||
if (!mounted) {
|
||||
write_log("hd accepted, not empty and not mounted in Windows\n");
|
||||
return -8;
|
||||
@ -157,9 +152,7 @@ static int safetycheck(FILE* h, const char* name, uae_u64 offset, uae_u8* buf, i
|
||||
|
||||
static int isharddrive(const TCHAR* name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < hdf_getnumharddrives(); i++) {
|
||||
for (int i = 0; i < hdf_getnumharddrives(); i++) {
|
||||
if (!_tcscmp(uae_drives[i].device_name, name))
|
||||
return i;
|
||||
}
|
||||
@ -170,10 +163,9 @@ static const TCHAR *hdz[] = { _T("hdz"), _T("zip"), _T("7z"), nullptr };
|
||||
|
||||
int hdf_open_target(struct hardfiledata *hfd, const TCHAR *pname)
|
||||
{
|
||||
FILE *h = INVALID_HANDLE_VALUE;
|
||||
FILE *h = nullptr;
|
||||
int i;
|
||||
char* name = my_strdup(pname);
|
||||
TCHAR* ext;
|
||||
int zmode = 0;
|
||||
|
||||
hfd->flags = 0;
|
||||
@ -189,11 +181,12 @@ int hdf_open_target(struct hardfiledata *hfd, const TCHAR *pname)
|
||||
goto end;
|
||||
}
|
||||
hfd->handle = xcalloc(struct hardfilehandle, 1);
|
||||
hfd->handle->h = INVALID_HANDLE_VALUE;
|
||||
hfd->handle->h = nullptr;
|
||||
write_log(_T("hfd attempting to open: '%s'\n"), name);
|
||||
|
||||
char* ext;
|
||||
ext = _tcsrchr(name, '.');
|
||||
if (ext != NULL) {
|
||||
if (ext != nullptr) {
|
||||
ext++;
|
||||
for (i = 0; hdz[i]; i++) {
|
||||
if (!_tcsicmp(ext, hdz[i]))
|
||||
@ -201,9 +194,9 @@ int hdf_open_target(struct hardfiledata *hfd, const TCHAR *pname)
|
||||
}
|
||||
}
|
||||
h = uae_tfopen(name, hfd->ci.readonly ? "rb" : "r+b");
|
||||
if (h == INVALID_HANDLE_VALUE && !hfd->ci.readonly) {
|
||||
if (h == nullptr && !hfd->ci.readonly) {
|
||||
h = uae_tfopen(name, "rb");
|
||||
if (h != INVALID_HANDLE_VALUE)
|
||||
if (h != nullptr)
|
||||
hfd->ci.readonly = true;
|
||||
}
|
||||
hfd->handle->h = h;
|
||||
@ -217,7 +210,7 @@ int hdf_open_target(struct hardfiledata *hfd, const TCHAR *pname)
|
||||
}
|
||||
_tcscpy(hfd->vendor_id, _T("UAE"));
|
||||
_tcscpy(hfd->product_rev, _T("0.4"));
|
||||
if (h != INVALID_HANDLE_VALUE) {
|
||||
if (h != nullptr) {
|
||||
uae_s64 pos = _ftelli64(h);
|
||||
_fseeki64(h, 0, SEEK_END);
|
||||
uae_s64 size = _ftelli64(h);
|
||||
@ -233,7 +226,7 @@ int hdf_open_target(struct hardfiledata *hfd, const TCHAR *pname)
|
||||
if (hfd->physsize < 64 * 1024 * 1024 && zmode) {
|
||||
write_log("HDF '%s' re-opened in zfile-mode\n", name);
|
||||
fclose(h);
|
||||
hfd->handle->h = INVALID_HANDLE_VALUE;
|
||||
hfd->handle->h = nullptr;
|
||||
hfd->handle->zf = zfile_fopen(name, _T("rb"), ZFD_NORMAL);
|
||||
hfd->handle->zfile = 1;
|
||||
if (!hfd->handle->zf)
|
||||
@ -250,7 +243,7 @@ int hdf_open_target(struct hardfiledata *hfd, const TCHAR *pname)
|
||||
|
||||
if (hfd->handle_valid || hfd->drive_empty) {
|
||||
write_log("HDF '%s' opened, size=%dK mode=%d empty=%d\n",
|
||||
name, (int)(hfd->physsize / 1024), hfd->handle_valid, hfd->drive_empty);
|
||||
name, static_cast<int>(hfd->physsize / 1024), hfd->handle_valid, hfd->drive_empty);
|
||||
return 1;
|
||||
}
|
||||
end:
|
||||
@ -263,12 +256,12 @@ static void freehandle(struct hardfilehandle* h)
|
||||
{
|
||||
if (!h)
|
||||
return;
|
||||
if (!h->zfile && h->h != 0)
|
||||
if (!h->zfile && h->h != nullptr)
|
||||
fclose(h->h);
|
||||
if (h->zfile && h->zf)
|
||||
zfile_fclose(h->zf);
|
||||
h->zf = NULL;
|
||||
h->h = 0;
|
||||
h->zf = nullptr;
|
||||
h->h = nullptr;
|
||||
h->zfile = 0;
|
||||
}
|
||||
|
||||
@ -277,15 +270,15 @@ void hdf_close_target(struct hardfiledata* hfd) {
|
||||
freehandle (hfd->handle);
|
||||
xfree(hfd->handle);
|
||||
xfree(hfd->emptyname);
|
||||
hfd->emptyname = NULL;
|
||||
hfd->handle = NULL;
|
||||
hfd->emptyname = nullptr;
|
||||
hfd->handle = nullptr;
|
||||
hfd->handle_valid = 0;
|
||||
if (hfd->cache)
|
||||
xfree(hfd->cache);
|
||||
xfree(hfd->virtual_rdb);
|
||||
hfd->virtual_rdb = 0;
|
||||
hfd->virtual_rdb = nullptr;
|
||||
hfd->virtual_size = 0;
|
||||
hfd->cache = 0;
|
||||
hfd->cache = nullptr;
|
||||
hfd->cache_valid = 0;
|
||||
hfd->drive_empty = 0;
|
||||
hfd->dangerous = 0;
|
||||
@ -299,7 +292,7 @@ int hdf_dup_target(struct hardfiledata* dhfd, const struct hardfiledata* shfd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int hdf_seek(struct hardfiledata *hfd, uae_u64 offset)
|
||||
static int hdf_seek(const struct hardfiledata *hfd, uae_u64 offset)
|
||||
{
|
||||
if (hfd->handle_valid == 0)
|
||||
{
|
||||
@ -327,7 +320,7 @@ static int hdf_seek(struct hardfiledata *hfd, uae_u64 offset)
|
||||
|
||||
if (hfd->handle_valid == HDF_HANDLE_LINUX)
|
||||
{
|
||||
auto ret = _fseeki64(hfd->handle->h, offset, SEEK_SET);
|
||||
const auto ret = _fseeki64(hfd->handle->h, offset, SEEK_SET);
|
||||
if (ret != 0)
|
||||
{
|
||||
write_log("hdf_seek failed\n");
|
||||
@ -336,19 +329,18 @@ static int hdf_seek(struct hardfiledata *hfd, uae_u64 offset)
|
||||
}
|
||||
else if (hfd->handle_valid == HDF_HANDLE_ZFILE)
|
||||
{
|
||||
zfile_fseek(hfd->handle->zf, long(offset), SEEK_SET);
|
||||
zfile_fseek(hfd->handle->zf, offset, SEEK_SET);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void poscheck(struct hardfiledata *hfd, int len)
|
||||
static void poscheck(const struct hardfiledata *hfd, int len)
|
||||
{
|
||||
int ret;
|
||||
uae_u64 pos = -1;
|
||||
|
||||
if (hfd->handle_valid == HDF_HANDLE_LINUX)
|
||||
{
|
||||
ret = _fseeki64(hfd->handle->h, 0, SEEK_CUR);
|
||||
const int ret = _fseeki64(hfd->handle->h, 0, SEEK_CUR);
|
||||
if (ret)
|
||||
{
|
||||
write_log(_T("hd: poscheck failed. seek failure"));
|
||||
@ -387,18 +379,18 @@ static void poscheck(struct hardfiledata *hfd, int len)
|
||||
}
|
||||
}
|
||||
|
||||
static int isincache(struct hardfiledata *hfd, uae_u64 offset, int len)
|
||||
static int isincache(const struct hardfiledata *hfd, uae_u64 offset, int len)
|
||||
{
|
||||
if (!hfd->cache_valid)
|
||||
return -1;
|
||||
if (offset >= hfd->cache_offset && offset + len <= hfd->cache_offset + CACHE_SIZE)
|
||||
return int(offset - hfd->cache_offset);
|
||||
return static_cast<int>(offset - hfd->cache_offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int hdf_read_2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
|
||||
{
|
||||
auto outlen = 0;
|
||||
size_t outlen = 0;
|
||||
|
||||
if (offset == 0)
|
||||
hfd->cache_valid = 0;
|
||||
@ -436,7 +428,7 @@ static int hdf_read_2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, in
|
||||
int hdf_read_target(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
|
||||
{
|
||||
int got = 0;
|
||||
uae_u8 *p = (uae_u8*)buffer;
|
||||
auto p = static_cast<uae_u8*>(buffer);
|
||||
|
||||
if (hfd->drive_empty)
|
||||
return 0;
|
||||
@ -444,7 +436,7 @@ int hdf_read_target(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int
|
||||
while (len > 0)
|
||||
{
|
||||
int maxlen;
|
||||
int ret = 0;
|
||||
size_t ret = 0;
|
||||
if (hfd->physsize < CACHE_SIZE)
|
||||
{
|
||||
hfd->cache_valid = 0;
|
||||
@ -478,9 +470,9 @@ int hdf_read_target(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int
|
||||
return got;
|
||||
}
|
||||
|
||||
static int hdf_write_2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
|
||||
static int hdf_write_2(struct hardfiledata *hfd, const void *buffer, uae_u64 offset, int len)
|
||||
{
|
||||
auto outlen = 0;
|
||||
size_t outlen = 0;
|
||||
|
||||
if (hfd->ci.readonly)
|
||||
return 0;
|
||||
@ -500,14 +492,14 @@ static int hdf_write_2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, i
|
||||
const auto* const name = hfd->emptyname == nullptr ? _T("<unknown>") : hfd->emptyname;
|
||||
if (offset == 0)
|
||||
{
|
||||
const auto tmplen = 512;
|
||||
constexpr auto tmplen = 512;
|
||||
auto* const tmp = (uae_u8*)xmalloc(uae_u8, tmplen);
|
||||
if (tmp)
|
||||
{
|
||||
int cmplen = tmplen > len ? len : tmplen;
|
||||
memset(tmp, 0xa1, tmplen);
|
||||
hdf_seek(hfd, offset);
|
||||
int outlen2 = fread(tmp, 1, tmplen, hfd->handle->h);
|
||||
auto outlen2 = fread(tmp, 1, tmplen, hfd->handle->h);
|
||||
if (memcmp(hfd->cache, tmp, cmplen) != 0 || outlen != len)
|
||||
gui_message(_T("\"%s\"\n\nblock zero write failed!"), name);
|
||||
xfree(tmp);
|
||||
@ -516,13 +508,13 @@ static int hdf_write_2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, i
|
||||
}
|
||||
else if (hfd->handle_valid == HDF_HANDLE_ZFILE)
|
||||
outlen = zfile_fwrite(hfd->cache, 1, len, hfd->handle->zf);
|
||||
return outlen;
|
||||
return static_cast<int>(outlen);
|
||||
}
|
||||
|
||||
int hdf_write_target(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
|
||||
{
|
||||
auto got = 0;
|
||||
auto* p = (uae_u8*)buffer;
|
||||
auto* p = static_cast<uae_u8*>(buffer);
|
||||
|
||||
if (hfd->drive_empty || hfd->physsize == 0)
|
||||
return 0;
|
||||
@ -586,12 +578,12 @@ static int hdf_init2(int force)
|
||||
return num_drives;
|
||||
}
|
||||
|
||||
int hdf_init_target(void)
|
||||
int hdf_init_target()
|
||||
{
|
||||
return hdf_init2(0);
|
||||
}
|
||||
|
||||
int hdf_getnumharddrives(void)
|
||||
int hdf_getnumharddrives()
|
||||
{
|
||||
return num_drives;
|
||||
}
|
||||
|
||||
@ -39,8 +39,8 @@ struct didata di_joystick[MAX_INPUT_DEVICES];
|
||||
|
||||
static int num_mouse = 1, num_keyboard = 1, num_joystick = 0, num_retroarch_kbdjoy = 0;
|
||||
static int joystick_inited, retroarch_inited;
|
||||
const auto analog_upper_bound = 32767;
|
||||
const auto analog_lower_bound = -analog_upper_bound;
|
||||
constexpr auto analog_upper_bound = 32767;
|
||||
constexpr auto analog_lower_bound = -analog_upper_bound;
|
||||
|
||||
static int isrealbutton(const struct didata* did, const int num)
|
||||
{
|
||||
@ -354,7 +354,7 @@ static int keyboard_german;
|
||||
int keyhack (const int scancode, const int pressed, const int num)
|
||||
{
|
||||
static unsigned char backslashstate, apostrophstate;
|
||||
const Uint8* state = SDL_GetKeyboardState(NULL);
|
||||
const Uint8* state = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
// release mouse if TAB and ALT is pressed (but only if option is enabled)
|
||||
if (currprefs.alt_tab_release)
|
||||
@ -448,7 +448,7 @@ static void di_dev_free(struct didata* did)
|
||||
cleardid(did);
|
||||
}
|
||||
|
||||
static void di_free(void)
|
||||
static void di_free()
|
||||
{
|
||||
for (auto i = 0; i < MAX_INPUT_DEVICES; i++) {
|
||||
di_dev_free(&di_joystick[i]);
|
||||
@ -457,12 +457,12 @@ static void di_free(void)
|
||||
}
|
||||
}
|
||||
|
||||
int is_touch_lightpen(void)
|
||||
int is_touch_lightpen()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_tablet(void)
|
||||
int is_tablet()
|
||||
{
|
||||
//return (tablet || os_touch) ? 1 : 0;
|
||||
return 0;
|
||||
@ -506,7 +506,6 @@ static int acquire_mouse(const int num, int flags)
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct AmigaMonitor* mon = &AMonitors[0];
|
||||
struct didata* did = &di_mouse[num];
|
||||
did->acquired = 1;
|
||||
return did->acquired > 0 ? 1 : 0;
|
||||
@ -519,7 +518,6 @@ static void unacquire_mouse(int num)
|
||||
}
|
||||
|
||||
struct didata* did = &di_mouse[num];
|
||||
struct AmigaMonitor* mon = &AMonitors[0];
|
||||
did->acquired = 0;
|
||||
}
|
||||
|
||||
@ -739,7 +737,7 @@ static int init_kb()
|
||||
std::string retroarch_file = get_retroarch_file();
|
||||
if (my_existsfile2(retroarch_file.c_str()))
|
||||
{
|
||||
// Add as many keyboards as joysticks that are setup
|
||||
// Add as many keyboards as joysticks that are set up
|
||||
// on arcade machines, you could have a 4 player ipac using all keyboard buttons
|
||||
// so you want to have at least 4 keyboards to choose from!
|
||||
// once one config is missing, simply stop adding them!
|
||||
@ -758,7 +756,7 @@ static void close_kb()
|
||||
{
|
||||
}
|
||||
|
||||
void release_keys(void)
|
||||
void release_keys()
|
||||
{
|
||||
// Special handling in case Alt-Tab was still stuck in pressed state
|
||||
if (currprefs.alt_tab_release && key_altpressed())
|
||||
@ -767,14 +765,14 @@ void release_keys(void)
|
||||
my_kbd_handler(0, SDL_SCANCODE_TAB, 0, true);
|
||||
}
|
||||
|
||||
const Uint8* state = SDL_GetKeyboardState(NULL);
|
||||
const Uint8* state = SDL_GetKeyboardState(nullptr);
|
||||
SDL_Event event;
|
||||
|
||||
for (int i = 0; i < SDL_NUM_SCANCODES; ++i) {
|
||||
if (state[i]) {
|
||||
event.type = SDL_KEYUP;
|
||||
event.key.keysym.scancode = (SDL_Scancode)i;
|
||||
event.key.keysym.sym = SDL_GetKeyFromScancode((SDL_Scancode)i);
|
||||
event.key.keysym.scancode = static_cast<SDL_Scancode>(i);
|
||||
event.key.keysym.sym = SDL_GetKeyFromScancode(static_cast<SDL_Scancode>(i));
|
||||
event.key.keysym.mod = 0;
|
||||
event.key.state = SDL_RELEASED;
|
||||
SDL_PushEvent(&event);
|
||||
@ -786,7 +784,6 @@ void release_keys(void)
|
||||
|
||||
static int acquire_kb(const int num, int flags)
|
||||
{
|
||||
struct AmigaMonitor* mon = &AMonitors[0];
|
||||
struct didata* did = &di_keyboard[num];
|
||||
did->acquired = 1;
|
||||
return did->acquired > 0 ? 1 : 0;
|
||||
@ -795,7 +792,6 @@ static int acquire_kb(const int num, int flags)
|
||||
static void unacquire_kb(const int num)
|
||||
{
|
||||
struct didata* did = &di_keyboard[num];
|
||||
struct AmigaMonitor* mon = &AMonitors[0];
|
||||
did->acquired = 0;
|
||||
}
|
||||
|
||||
@ -803,7 +799,7 @@ static void read_kb()
|
||||
{
|
||||
}
|
||||
|
||||
void wait_keyrelease(void)
|
||||
void wait_keyrelease()
|
||||
{
|
||||
release_keys();
|
||||
}
|
||||
@ -1204,25 +1200,25 @@ static int get_joystick_widget_type(const int joy, const int num, TCHAR* name, u
|
||||
switch (num)
|
||||
{
|
||||
case FIRST_JOY_BUTTON:
|
||||
sprintf(name, "Button X/CD32 red");
|
||||
_sntprintf(name, sizeof name, "Button X/CD32 red");
|
||||
break;
|
||||
case FIRST_JOY_BUTTON + 1:
|
||||
sprintf(name, "Button B/CD32 blue");
|
||||
_sntprintf(name, sizeof name, "Button B/CD32 blue");
|
||||
break;
|
||||
case FIRST_JOY_BUTTON + 2:
|
||||
sprintf(name, "Button A/CD32 green");
|
||||
_sntprintf(name, sizeof name, "Button A/CD32 green");
|
||||
break;
|
||||
case FIRST_JOY_BUTTON + 3:
|
||||
sprintf(name, "Button Y/CD32 yellow");
|
||||
_sntprintf(name, sizeof name, "Button Y/CD32 yellow");
|
||||
break;
|
||||
case FIRST_JOY_BUTTON + 4:
|
||||
sprintf(name, "CD32 start");
|
||||
_sntprintf(name, sizeof name, "CD32 start");
|
||||
break;
|
||||
case FIRST_JOY_BUTTON + 5:
|
||||
sprintf(name, "CD32 ffw");
|
||||
_sntprintf(name, sizeof name, "CD32 ffw");
|
||||
break;
|
||||
case FIRST_JOY_BUTTON + 6:
|
||||
sprintf(name, "CD32 rwd");
|
||||
_sntprintf(name, sizeof name, "CD32 rwd");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1235,11 +1231,11 @@ static int get_joystick_widget_type(const int joy, const int num, TCHAR* name, u
|
||||
if (name)
|
||||
{
|
||||
if (num == 0)
|
||||
sprintf(name, "X Axis");
|
||||
_sntprintf(name, sizeof name, "X Axis");
|
||||
else if (num == 1)
|
||||
sprintf(name, "Y Axis");
|
||||
_sntprintf(name, sizeof name, "Y Axis");
|
||||
else
|
||||
sprintf(name, "Axis %d", num + 1);
|
||||
_sntprintf(name, sizeof name, "Axis %d", num + 1);
|
||||
}
|
||||
return IDEV_WIDGET_AXIS;
|
||||
}
|
||||
@ -1453,6 +1449,7 @@ void read_joystick_hat(const int id, int hat, const int value)
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
|
||||
state = value & SDL_HAT_RIGHT;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
setjoybuttonstate(id, button, state);
|
||||
}
|
||||
@ -1476,7 +1473,7 @@ struct inputdevice_functions inputdevicefunc_joystick = {
|
||||
// We use setid to set up custom events
|
||||
int input_get_default_joystick(struct uae_input_device* uid, int i, int port, int af, int mode, bool gp, bool joymouseswap, bool default_osk)
|
||||
{
|
||||
struct didata* did = NULL;
|
||||
struct didata* did = nullptr;
|
||||
int h, v;
|
||||
|
||||
if (joymouseswap) {
|
||||
|
||||
@ -91,12 +91,12 @@ static void* VirtualAlloc(void* lpAddress, size_t dwSize, int flAllocationType,
|
||||
write_log(" WARNING: unknown protection\n");
|
||||
}
|
||||
|
||||
void* address = NULL;
|
||||
void* address = nullptr;
|
||||
|
||||
if (flAllocationType == MEM_COMMIT && lpAddress == NULL) {
|
||||
if (flAllocationType == MEM_COMMIT && lpAddress == nullptr) {
|
||||
write_log("NATMEM: Allocated non-reserved memory size %zu\n", dwSize);
|
||||
void* memory = uae_vm_alloc(dwSize, 0, UAE_VM_READ_WRITE);
|
||||
if (memory == NULL) {
|
||||
if (memory == nullptr) {
|
||||
write_log("memory allocated failed errno %d\n", errno);
|
||||
}
|
||||
return memory;
|
||||
@ -143,14 +143,13 @@ static int VirtualProtect(void* lpAddress, int dwSize, int flNewProtect,
|
||||
|
||||
static bool VirtualFree(void* lpAddress, size_t dwSize, int dwFreeType)
|
||||
{
|
||||
int result = 0;
|
||||
if (dwFreeType == MEM_DECOMMIT) {
|
||||
return uae_vm_decommit(lpAddress, dwSize);
|
||||
}
|
||||
else if (dwFreeType == MEM_RELEASE) {
|
||||
if (dwFreeType == MEM_RELEASE) {
|
||||
return uae_vm_free(lpAddress, dwSize);
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int GetLastError()
|
||||
@ -158,7 +157,7 @@ static int GetLastError()
|
||||
return errno;
|
||||
}
|
||||
|
||||
static int my_getpagesize(void)
|
||||
static int my_getpagesize()
|
||||
{
|
||||
return uae_vm_page_size();
|
||||
}
|
||||
@ -212,7 +211,7 @@ bool can_have_1gb()
|
||||
|
||||
static uae_u8 *virtualallocwithlock (LPVOID addr, SIZE_T size, unsigned int allocationtype, unsigned int protect)
|
||||
{
|
||||
uae_u8 *p = (uae_u8*)VirtualAlloc (addr, size, allocationtype, protect);
|
||||
auto p = static_cast<uae_u8*>(VirtualAlloc(addr, size, allocationtype, protect));
|
||||
return p;
|
||||
}
|
||||
static void virtualfreewithlock (LPVOID addr, SIZE_T size, unsigned int freetype)
|
||||
@ -220,7 +219,7 @@ static void virtualfreewithlock (LPVOID addr, SIZE_T size, unsigned int freetype
|
||||
VirtualFree(addr, size, freetype);
|
||||
}
|
||||
|
||||
static uae_u32 lowmem (void)
|
||||
static uae_u32 lowmem ()
|
||||
{
|
||||
uae_u32 change = 0;
|
||||
return change;
|
||||
@ -228,16 +227,16 @@ static uae_u32 lowmem (void)
|
||||
|
||||
static uae_u64 size64;
|
||||
|
||||
static void clear_shm (void)
|
||||
static void clear_shm ()
|
||||
{
|
||||
shm_start = NULL;
|
||||
for (int i = 0; i < MAX_SHMID; i++) {
|
||||
memset (&shmids[i], 0, sizeof(struct uae_shmid_ds));
|
||||
shmids[i].key = -1;
|
||||
shm_start = nullptr;
|
||||
for (auto & shmid : shmids) {
|
||||
memset (&shmid, 0, sizeof(struct uae_shmid_ds));
|
||||
shmid.key = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool preinit_shm (void)
|
||||
bool preinit_shm ()
|
||||
{
|
||||
uae_u64 total64;
|
||||
uae_u64 totalphys64;
|
||||
@ -246,16 +245,15 @@ bool preinit_shm (void)
|
||||
GLOBALMEMORYSTATUSEX pGlobalMemoryStatusEx;
|
||||
MEMORYSTATUSEX memstatsex;
|
||||
#endif
|
||||
uae_u32 max_allowed_mman;
|
||||
|
||||
if (natmem_reserved)
|
||||
VirtualFree (natmem_reserved, 0, MEM_RELEASE);
|
||||
|
||||
natmem_reserved = NULL;
|
||||
natmem_offset = NULL;
|
||||
natmem_reserved = nullptr;
|
||||
natmem_offset = nullptr;
|
||||
|
||||
GetSystemInfo (&si);
|
||||
max_allowed_mman = 512 + 256;
|
||||
uae_u32 max_allowed_mman = 512 + 256;
|
||||
if (os_64bit) {
|
||||
// Higher than 2G to support G-REX PCI VRAM
|
||||
max_allowed_mman = 2560;
|
||||
@ -290,7 +288,7 @@ bool preinit_shm (void)
|
||||
// FIXME: check 64-bit compat
|
||||
mib[1] = HW_MEMSIZE; /* gives a 64 bit int */
|
||||
len = sizeof(totalphys64);
|
||||
sysctl(mib, 2, &totalphys64, &len, NULL, 0);
|
||||
sysctl(mib, 2, &totalphys64, &len, nullptr, 0);
|
||||
total64 = (uae_u64) totalphys64;
|
||||
#else
|
||||
totalphys64 = sysconf (_SC_PHYS_PAGES) * (uae_u64)getpagesize();
|
||||
@ -315,12 +313,12 @@ bool preinit_shm (void)
|
||||
max_allowed_mman = 256;
|
||||
}
|
||||
} else if (maxmem > 0) {
|
||||
size64 = (uae_u64)maxmem * 1024 * 1024;
|
||||
size64 = static_cast<uae_u64>(maxmem) * 1024 * 1024;
|
||||
}
|
||||
if (size64 < 8 * 1024 * 1024)
|
||||
size64 = 8 * 1024 * 1024;
|
||||
if ((uae_u64)max_allowed_mman * 1024 * 1024 > size64)
|
||||
max_allowed_mman = (uae_u32)(size64 / (1024 * 1024));
|
||||
if (static_cast<uae_u64>(max_allowed_mman) * 1024 * 1024 > size64)
|
||||
max_allowed_mman = static_cast<uae_u32>(size64 / (1024 * 1024));
|
||||
|
||||
uae_u32 natmem_size = (max_allowed_mman + 1) * 1024 * 1024;
|
||||
if (natmem_size < 17 * 1024 * 1024)
|
||||
@ -339,7 +337,7 @@ bool preinit_shm (void)
|
||||
write_log(_T("MMAN: Attempting to reserve: %u MB\n"), natmem_size >> 20);
|
||||
|
||||
#if 1
|
||||
natmem_reserved = (uae_u8 *) uae_vm_reserve(natmem_size, UAE_VM_32BIT | UAE_VM_WRITE_WATCH);
|
||||
natmem_reserved = static_cast<uae_u8*>(uae_vm_reserve(natmem_size, UAE_VM_32BIT | UAE_VM_WRITE_WATCH));
|
||||
#else
|
||||
natmem_size = 0x20000000;
|
||||
natmem_reserved = (uae_u8 *) uae_vm_reserve_fixed(
|
||||
@ -350,7 +348,7 @@ bool preinit_shm (void)
|
||||
if (natmem_size <= 768 * 1024 * 1024) {
|
||||
uae_u32 p = 0x78000000 - natmem_size;
|
||||
for (;;) {
|
||||
natmem_reserved = (uae_u8*) VirtualAlloc((void*)(intptr_t)p, natmem_size, MEM_RESERVE | MEM_WRITE_WATCH, PAGE_READWRITE);
|
||||
natmem_reserved = static_cast<uae_u8*>(VirtualAlloc(reinterpret_cast<void*>(static_cast<intptr_t>(p)), natmem_size, MEM_RESERVE | MEM_WRITE_WATCH, PAGE_READWRITE));
|
||||
if (natmem_reserved)
|
||||
break;
|
||||
p -= 128 * 1024 * 1024;
|
||||
@ -362,14 +360,14 @@ bool preinit_shm (void)
|
||||
if (!natmem_reserved) {
|
||||
unsigned int vaflags = MEM_RESERVE | MEM_WRITE_WATCH;
|
||||
for (;;) {
|
||||
natmem_reserved = (uae_u8*)VirtualAlloc (NULL, natmem_size, vaflags, PAGE_READWRITE);
|
||||
natmem_reserved = static_cast<uae_u8*>(VirtualAlloc(nullptr, natmem_size, vaflags, PAGE_READWRITE));
|
||||
if (natmem_reserved)
|
||||
break;
|
||||
natmem_size -= 64 * 1024 * 1024;
|
||||
if (!natmem_size) {
|
||||
write_log (_T("MMAN: Can't allocate 257M of virtual address space!?\n"));
|
||||
natmem_size = 17 * 1024 * 1024;
|
||||
natmem_reserved = (uae_u8*)VirtualAlloc (NULL, natmem_size, vaflags, PAGE_READWRITE);
|
||||
natmem_reserved = static_cast<uae_u8*>(VirtualAlloc(nullptr, natmem_size, vaflags, PAGE_READWRITE));
|
||||
if (!natmem_size) {
|
||||
write_log (_T("MMAN: Can't allocate 17M of virtual address space!? Something is seriously wrong\n"));
|
||||
notify_user(NUMSG_NOMEMORY);
|
||||
@ -393,21 +391,17 @@ bool preinit_shm (void)
|
||||
|
||||
clear_shm ();
|
||||
|
||||
canbang = 1;
|
||||
canbang = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void resetmem (bool decommit)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!shm_start)
|
||||
return;
|
||||
for (i = 0; i < MAX_SHMID; i++) {
|
||||
struct uae_shmid_ds *s = &shmids[i];
|
||||
for (auto & shmid : shmids) {
|
||||
struct uae_shmid_ds *s = &shmid;
|
||||
int size = s->size;
|
||||
uae_u8 *shmaddr;
|
||||
uae_u8 *result;
|
||||
|
||||
if (!s->attached)
|
||||
continue;
|
||||
@ -415,13 +409,13 @@ static void resetmem (bool decommit)
|
||||
continue;
|
||||
if (s->fake)
|
||||
continue;
|
||||
if (!decommit && ((uae_u8*)s->attached - (uae_u8*)s->natmembase) >= 0x10000000)
|
||||
if (!decommit && (static_cast<uae_u8*>(s->attached) - static_cast<uae_u8*>(s->natmembase)) >= 0x10000000)
|
||||
continue;
|
||||
shmaddr = natmem_offset + ((uae_u8*)s->attached - (uae_u8*)s->natmembase);
|
||||
uae_u8* shmaddr = natmem_offset + (static_cast<uae_u8*>(s->attached) - static_cast<uae_u8*>(s->natmembase));
|
||||
if (decommit) {
|
||||
VirtualFree (shmaddr, size, MEM_DECOMMIT);
|
||||
} else {
|
||||
result = virtualallocwithlock (shmaddr, size, decommit ? MEM_DECOMMIT : MEM_COMMIT, PAGE_READWRITE);
|
||||
const uae_u8* result = virtualallocwithlock(shmaddr, size, decommit ? MEM_DECOMMIT : MEM_COMMIT, PAGE_READWRITE);
|
||||
if (result != shmaddr)
|
||||
write_log (_T("MMAN: realloc(%p-%p,%d,%d,%s) failed, err=%d\n"), shmaddr, shmaddr + size, size, s->mode, s->name, GetLastError ());
|
||||
else
|
||||
@ -432,9 +426,7 @@ static void resetmem (bool decommit)
|
||||
|
||||
static uae_u8 *va (uae_u32 offset, uae_u32 len, unsigned int alloc, unsigned int protect)
|
||||
{
|
||||
uae_u8 *addr;
|
||||
|
||||
addr = (uae_u8*)VirtualAlloc (natmem_offset + offset, len, alloc, protect);
|
||||
auto* addr = static_cast<uae_u8*>(VirtualAlloc(natmem_offset + offset, len, alloc, protect));
|
||||
if (addr) {
|
||||
write_log (_T("VA(%p - %p, %4uM, %s)\n"),
|
||||
natmem_offset + offset, natmem_offset + offset + len, len >> 20, (alloc & MEM_WRITE_WATCH) ? _T("WATCH") : _T("RESERVED"));
|
||||
@ -442,14 +434,11 @@ static uae_u8 *va (uae_u32 offset, uae_u32 len, unsigned int alloc, unsigned int
|
||||
}
|
||||
write_log (_T("VA(%p - %p, %4uM, %s) failed %d\n"),
|
||||
natmem_offset + offset, natmem_offset + offset + len, len >> 20, (alloc & MEM_WRITE_WATCH) ? _T("WATCH") : _T("RESERVED"), GetLastError ());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int doinit_shm (void)
|
||||
static int doinit_shm ()
|
||||
{
|
||||
uae_u32 totalsize, totalsize_z3;
|
||||
uae_u32 align;
|
||||
uae_u32 z3rtgmem_size;
|
||||
struct rtgboardconfig *rbc = &changed_prefs.rtgboards[0];
|
||||
struct rtgboardconfig *crbc = &currprefs.rtgboards[0];
|
||||
uae_u32 extra = 65536;
|
||||
@ -459,18 +448,18 @@ static int doinit_shm (void)
|
||||
set_expamem_z3_hack_mode(0);
|
||||
expansion_scan_autoconfig(&currprefs, true);
|
||||
|
||||
canbang = 1;
|
||||
canbang = true;
|
||||
natmem_offset = natmem_reserved;
|
||||
|
||||
align = 16 * 1024 * 1024 - 1;
|
||||
totalsize = 0x01000000;
|
||||
uae_u32 align = 16 * 1024 * 1024 - 1;
|
||||
uae_u32 totalsize = 0x01000000;
|
||||
|
||||
z3rtgmem_size = gfxboard_get_configtype(rbc) == 3 ? rbc->rtgmem_size : 0;
|
||||
uae_u32 z3rtgmem_size = gfxboard_get_configtype(rbc) == 3 ? rbc->rtgmem_size : 0;
|
||||
|
||||
if (p->cpu_model >= 68020)
|
||||
totalsize = 0x10000000;
|
||||
totalsize += (p->z3chipmem.size + align) & ~align;
|
||||
totalsize_z3 = totalsize;
|
||||
uae_u32 totalsize_z3 = totalsize;
|
||||
|
||||
start_rtg = 0;
|
||||
end_rtg = 0;
|
||||
@ -573,8 +562,8 @@ static int doinit_shm (void)
|
||||
break;
|
||||
addrbank *ab = aci->addrbank;
|
||||
// disable JIT direct from Z3 boards that are outside of natmem
|
||||
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
|
||||
if (&z3fastmem_bank[i] == ab) {
|
||||
for (auto & i : z3fastmem_bank) {
|
||||
if (&i == ab) {
|
||||
ab->flags &= ~ABFLAG_ALLOCINDIRECT;
|
||||
ab->jit_read_flag = 0;
|
||||
ab->jit_write_flag = 0;
|
||||
@ -594,7 +583,7 @@ static int doinit_shm (void)
|
||||
write_log(_T("MMAN: Our special area: %p-%p (0x%08x %dM)\n"),
|
||||
natmem_offset, (uae_u8*)natmem_offset + totalsize,
|
||||
totalsize, totalsize / (1024 * 1024));
|
||||
canbang = jit_direct_compatible_memory ? 1 : 0;
|
||||
canbang = jit_direct_compatible_memory;
|
||||
}
|
||||
|
||||
return canbang;
|
||||
@ -606,7 +595,7 @@ static uae_u32 oz3chipmem_size;
|
||||
static uae_u32 ortgmem_size[MAX_RTG_BOARDS];
|
||||
static int ortgmem_type[MAX_RTG_BOARDS];
|
||||
|
||||
bool init_shm(void)
|
||||
bool init_shm()
|
||||
{
|
||||
auto changed = false;
|
||||
|
||||
@ -649,12 +638,12 @@ bool init_shm(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void free_shm (void)
|
||||
void free_shm ()
|
||||
{
|
||||
resetmem (true);
|
||||
clear_shm ();
|
||||
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
|
||||
ortgmem_type[i] = -1;
|
||||
for (int & i : ortgmem_type) {
|
||||
i = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -664,7 +653,7 @@ void mapped_free (addrbank *ab)
|
||||
bool rtgmem = (ab->flags & ABFLAG_RTG) != 0;
|
||||
|
||||
ab->flags &= ~ABFLAG_MAPPED;
|
||||
if (ab->baseaddr == NULL)
|
||||
if (ab->baseaddr == nullptr)
|
||||
return;
|
||||
|
||||
if (ab->flags & ABFLAG_INDIRECT) {
|
||||
@ -674,17 +663,17 @@ void mapped_free (addrbank *ab)
|
||||
shmids[shmid].key = -1;
|
||||
shmids[shmid].name[0] = '\0';
|
||||
shmids[shmid].size = 0;
|
||||
shmids[shmid].attached = 0;
|
||||
shmids[shmid].attached = nullptr;
|
||||
shmids[shmid].mode = 0;
|
||||
shmids[shmid].natmembase = 0;
|
||||
shmids[shmid].natmembase = nullptr;
|
||||
if (!(ab->flags & ABFLAG_NOALLOC)) {
|
||||
xfree(ab->baseaddr);
|
||||
ab->baseaddr = NULL;
|
||||
ab->baseaddr = nullptr;
|
||||
}
|
||||
}
|
||||
x = x->next;
|
||||
}
|
||||
ab->baseaddr = NULL;
|
||||
ab->baseaddr = nullptr;
|
||||
ab->flags &= ~ABFLAG_DIRECTMAP;
|
||||
ab->allocated_size = 0;
|
||||
write_log(_T("mapped_free indirect %s\n"), ab->name);
|
||||
@ -695,7 +684,7 @@ void mapped_free (addrbank *ab)
|
||||
if (!(ab->flags & ABFLAG_NOALLOC)) {
|
||||
xfree(ab->baseaddr);
|
||||
}
|
||||
ab->baseaddr = NULL;
|
||||
ab->baseaddr = nullptr;
|
||||
ab->allocated_size = 0;
|
||||
write_log(_T("mapped_free nondirect %s\n"), ab->name);
|
||||
return;
|
||||
@ -708,23 +697,22 @@ void mapped_free (addrbank *ab)
|
||||
}
|
||||
x = shm_start;
|
||||
while(x) {
|
||||
struct uae_shmid_ds blah;
|
||||
uae_shmid_ds blah{};
|
||||
if (ab->baseaddr == x->native_address) {
|
||||
if (uae_shmctl (x->id, UAE_IPC_STAT, &blah) == 0)
|
||||
uae_shmctl (x->id, UAE_IPC_RMID, &blah);
|
||||
}
|
||||
x = x->next;
|
||||
}
|
||||
ab->baseaddr = NULL;
|
||||
ab->baseaddr = nullptr;
|
||||
ab->allocated_size = 0;
|
||||
write_log(_T("mapped_free direct %s\n"), ab->name);
|
||||
}
|
||||
|
||||
static uae_key_t get_next_shmkey (void)
|
||||
static uae_key_t get_next_shmkey ()
|
||||
{
|
||||
uae_key_t result = -1;
|
||||
int i;
|
||||
for (i = 0; i < MAX_SHMID; i++) {
|
||||
for (int i = 0; i < MAX_SHMID; i++) {
|
||||
if (shmids[i].key == -1) {
|
||||
shmids[i].key = i;
|
||||
result = i;
|
||||
@ -746,7 +734,7 @@ STATIC_INLINE uae_key_t find_shmkey (uae_key_t key)
|
||||
bool uae_mman_info(addrbank* ab, struct uae_mman_data* md)
|
||||
{
|
||||
auto got = false;
|
||||
bool readonly = false, maprom = false;
|
||||
bool readonly = false;
|
||||
bool directsupport = true;
|
||||
uaecptr start;
|
||||
auto size = ab->reserved_size;
|
||||
@ -968,6 +956,7 @@ bool uae_mman_info(addrbank* ab, struct uae_mman_data* md)
|
||||
}
|
||||
if (got)
|
||||
{
|
||||
bool maprom = false;
|
||||
md->start = start;
|
||||
md->size = size;
|
||||
md->readonly = readonly;
|
||||
@ -992,10 +981,10 @@ bool uae_mman_info(addrbank* ab, struct uae_mman_data* md)
|
||||
|
||||
void *uae_shmat (addrbank *ab, int shmid, void *shmaddr, int shmflg, struct uae_mman_data *md)
|
||||
{
|
||||
void *result = (void *)-1;
|
||||
bool got = false, readonly = false, maprom = false;
|
||||
void *result = reinterpret_cast<void*>(-1);
|
||||
bool readonly = false, maprom = false;
|
||||
int p96special = FALSE;
|
||||
struct uae_mman_data md2;
|
||||
struct uae_mman_data md2{};
|
||||
|
||||
#ifdef NATMEM_OFFSET
|
||||
|
||||
@ -1011,10 +1000,10 @@ void *uae_shmat (addrbank *ab, int shmid, void *shmaddr, int shmflg, struct uae_
|
||||
return shmids[shmid].attached;
|
||||
}
|
||||
|
||||
if ((uae_u8*)shmaddr < natmem_offset) {
|
||||
if (static_cast<uae_u8*>(shmaddr) < natmem_offset) {
|
||||
if (!md) {
|
||||
if (!uae_mman_info(ab, &md2))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
md = &md2;
|
||||
}
|
||||
if (!shmaddr) {
|
||||
@ -1023,12 +1012,11 @@ void *uae_shmat (addrbank *ab, int shmid, void *shmaddr, int shmflg, struct uae_
|
||||
readonlysize = md->readonlysize;
|
||||
readonly = md->readonly;
|
||||
maprom = md->maprom;
|
||||
got = true;
|
||||
}
|
||||
}
|
||||
|
||||
uintptr_t natmem_end = (uintptr_t) natmem_reserved + natmem_reserved_size;
|
||||
if (md && md->hasbarrier && (uintptr_t) shmaddr + size > natmem_end && (uintptr_t)shmaddr <= natmem_end) {
|
||||
uintptr_t natmem_end = reinterpret_cast<uintptr_t>(natmem_reserved) + natmem_reserved_size;
|
||||
if (md && md->hasbarrier && reinterpret_cast<uintptr_t>(shmaddr) + size > natmem_end && reinterpret_cast<uintptr_t>(shmaddr) <= natmem_end) {
|
||||
/* We cannot add a barrier beyond the end of the reserved memory. */
|
||||
//assert((uintptr_t) shmaddr + size - natmem_end == BARRIER);
|
||||
write_log(_T("NATMEM: Removing barrier (%d bytes) beyond reserved memory\n"), BARRIER);
|
||||
@ -1048,30 +1036,30 @@ void *uae_shmat (addrbank *ab, int shmid, void *shmaddr, int shmflg, struct uae_
|
||||
if (shmaddr)
|
||||
virtualfreewithlock (shmaddr, size, MEM_DECOMMIT);
|
||||
result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
if (result == NULL)
|
||||
if (result == nullptr)
|
||||
virtualfreewithlock (shmaddr, 0, MEM_DECOMMIT);
|
||||
result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
if (result == NULL) {
|
||||
result = (void*)-1;
|
||||
if (result == nullptr) {
|
||||
result = reinterpret_cast<void*>(-1);
|
||||
error_log (_T("Memory %s (%s) failed to allocate %p: VA %08X - %08X %x (%dk). Error %d."),
|
||||
shmids[shmid].name, ab ? ab->name : _T("?"), shmaddr,
|
||||
(uae_u8*)shmaddr - natmem_offset, (uae_u8*)shmaddr - natmem_offset + size,
|
||||
static_cast<uae_u8*>(shmaddr) - natmem_offset, static_cast<uae_u8*>(shmaddr) - natmem_offset + size,
|
||||
size, size >> 10, GetLastError ());
|
||||
} else {
|
||||
shmids[shmid].attached = result;
|
||||
write_log (_T("%p: VA %08lX - %08lX %x (%dk) ok (%p)%s\n"),
|
||||
shmaddr, (uae_u8*)shmaddr - natmem_offset, (uae_u8*)shmaddr - natmem_offset + size,
|
||||
shmaddr, static_cast<uae_u8*>(shmaddr) - natmem_offset, static_cast<uae_u8*>(shmaddr) - natmem_offset + size,
|
||||
size, size >> 10, shmaddr, p96special ? _T(" RTG") : _T(""));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void unprotect_maprom(void)
|
||||
void unprotect_maprom()
|
||||
{
|
||||
bool protect = false;
|
||||
for (int i = 0; i < MAX_SHMID; i++) {
|
||||
struct uae_shmid_ds *shm = &shmids[i];
|
||||
for (auto & shmid : shmids) {
|
||||
struct uae_shmid_ds *shm = &shmid;
|
||||
if (shm->mode != PAGE_READONLY)
|
||||
continue;
|
||||
if (!shm->attached || !shm->rosize)
|
||||
@ -1082,7 +1070,7 @@ void unprotect_maprom(void)
|
||||
unsigned int old;
|
||||
if (!VirtualProtect (shm->attached, shm->rosize, protect ? PAGE_READONLY : PAGE_READWRITE, &old)) {
|
||||
write_log (_T("unprotect_maprom VP %08lX - %08lX %x (%dk) failed %d\n"),
|
||||
(uae_u8*)shm->attached - natmem_offset, (uae_u8*)shm->attached - natmem_offset + shm->size,
|
||||
static_cast<uae_u8*>(shm->attached) - natmem_offset, static_cast<uae_u8*>(shm->attached) - natmem_offset + shm->size,
|
||||
shm->size, shm->size >> 10, GetLastError ());
|
||||
}
|
||||
}
|
||||
@ -1095,8 +1083,8 @@ void protect_roms(bool protect)
|
||||
if (!currprefs.cachesize || currprefs.comptrustbyte || currprefs.comptrustword || currprefs.comptrustlong)
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < MAX_SHMID; i++) {
|
||||
struct uae_shmid_ds *shm = &shmids[i];
|
||||
for (auto & shmid : shmids) {
|
||||
struct uae_shmid_ds *shm = &shmid;
|
||||
if (shm->mode != PAGE_READONLY)
|
||||
continue;
|
||||
if (!shm->attached || !shm->rosize)
|
||||
@ -1106,11 +1094,11 @@ void protect_roms(bool protect)
|
||||
unsigned int old;
|
||||
if (!VirtualProtect (shm->attached, shm->rosize, protect ? PAGE_READONLY : PAGE_READWRITE, &old)) {
|
||||
write_log (_T("protect_roms VP %08lX - %08lX %x (%dk) failed %d\n"),
|
||||
(uae_u8*)shm->attached - natmem_offset, (uae_u8*)shm->attached - natmem_offset + shm->rosize,
|
||||
static_cast<uae_u8*>(shm->attached) - natmem_offset, static_cast<uae_u8*>(shm->attached) - natmem_offset + shm->rosize,
|
||||
shm->rosize, shm->rosize >> 10, GetLastError ());
|
||||
} else {
|
||||
write_log(_T("ROM VP %08lX - %08lX %x (%dk) %s\n"),
|
||||
(uae_u8*)shm->attached - natmem_offset, (uae_u8*)shm->attached - natmem_offset + shm->rosize,
|
||||
static_cast<uae_u8*>(shm->attached) - natmem_offset, static_cast<uae_u8*>(shm->attached) - natmem_offset + shm->rosize,
|
||||
shm->rosize, shm->rosize >> 10, protect ? _T("WPROT") : _T("UNPROT"));
|
||||
}
|
||||
}
|
||||
@ -1175,7 +1163,7 @@ int uae_shmdt (const void *shmaddr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int uae_shmget (uae_key_t key, addrbank *ab, int shmflg)
|
||||
int uae_shmget (uae_key_t key, const addrbank *ab, int shmflg)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
@ -1207,10 +1195,12 @@ int uae_shmctl (int shmid, int cmd, struct uae_shmid_ds *buf)
|
||||
shmids[shmid].key = -1;
|
||||
shmids[shmid].name[0] = '\0';
|
||||
shmids[shmid].size = 0;
|
||||
shmids[shmid].attached = 0;
|
||||
shmids[shmid].attached = nullptr;
|
||||
shmids[shmid].mode = 0;
|
||||
result = 0;
|
||||
break;
|
||||
default: /* Invalid command */
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -66,7 +66,7 @@ struct sermap_buffer
|
||||
volatile uae_u32 write_offset;
|
||||
volatile uae_u32 data[SERMAP_SIZE];
|
||||
};
|
||||
static struct sermap_buffer* sermap1, * sermap2;
|
||||
static sermap_buffer* sermap1, * sermap2;
|
||||
static void* sermap_handle;
|
||||
static uae_u8* sermap_data;
|
||||
static bool sermap_master;
|
||||
@ -86,12 +86,10 @@ static int receive_buf_size, receive_buf_count;
|
||||
|
||||
static void shmem_serial_send(uae_u32 data)
|
||||
{
|
||||
uae_u32 v;
|
||||
|
||||
sermap1->active_write = true;
|
||||
if (!sermap1->active_read)
|
||||
return;
|
||||
v = sermap1->write_offset;
|
||||
uae_u32 v = sermap1->write_offset;
|
||||
if (((v + 1) & (SERMAP_SIZE - 1)) == sermap1->read_offset) {
|
||||
write_log(_T("Shared serial port memory overflow!\n"));
|
||||
return;
|
||||
@ -101,24 +99,22 @@ static void shmem_serial_send(uae_u32 data)
|
||||
v &= (SERMAP_SIZE - 1);
|
||||
sermap1->write_offset = v;
|
||||
}
|
||||
static uae_u32 shmem_serial_receive(void)
|
||||
static uae_u32 shmem_serial_receive()
|
||||
{
|
||||
uae_u32 v;
|
||||
uae_u32 data;
|
||||
sermap2->active_read = true;
|
||||
if (!sermap2->active_write)
|
||||
return 0xffffffff;
|
||||
v = sermap2->read_offset;
|
||||
uae_u32 v = sermap2->read_offset;
|
||||
if (v == sermap2->write_offset)
|
||||
return 0xffffffff;
|
||||
data = sermap2->data[v];
|
||||
const uae_u32 data = sermap2->data[v];
|
||||
v++;
|
||||
v &= (SERMAP_SIZE - 1);
|
||||
sermap2->read_offset = v;
|
||||
return data;
|
||||
}
|
||||
|
||||
static void sermap_deactivate(void)
|
||||
static void sermap_deactivate()
|
||||
{
|
||||
sermap_enabled = false;
|
||||
sermap_flags = 0;
|
||||
@ -132,7 +128,7 @@ static void sermap_deactivate(void)
|
||||
}
|
||||
}
|
||||
|
||||
int shmem_serial_state(void)
|
||||
int shmem_serial_state()
|
||||
{
|
||||
if (!sermap_handle)
|
||||
return 0;
|
||||
@ -141,23 +137,23 @@ int shmem_serial_state(void)
|
||||
return 2;
|
||||
}
|
||||
|
||||
void shmem_serial_delete(void)
|
||||
void shmem_serial_delete()
|
||||
{
|
||||
sermap_deactivate();
|
||||
sermap_master = false;
|
||||
if (sermap_data) {
|
||||
munmap(sermap_data, sizeof(struct sermap_buffer) * 2);
|
||||
munmap(sermap_data, sizeof(sermap_buffer) * 2);
|
||||
}
|
||||
if (sermap_handle) {
|
||||
shm_unlink(SER_MEMORY_MAPPING);
|
||||
}
|
||||
sermap_data = NULL;
|
||||
sermap_handle = NULL;
|
||||
sermap1 = sermap2 = NULL;
|
||||
sermap_data = nullptr;
|
||||
sermap_handle = nullptr;
|
||||
sermap1 = sermap2 = nullptr;
|
||||
}
|
||||
|
||||
|
||||
bool shmem_serial_create(void)
|
||||
bool shmem_serial_create()
|
||||
{
|
||||
shmem_serial_delete();
|
||||
|
||||
@ -175,13 +171,13 @@ bool shmem_serial_create(void)
|
||||
write_log("Found already existing serial port shared memory\n");
|
||||
}
|
||||
|
||||
if (ftruncate(fd, sizeof(struct sermap_buffer) * 2) == -1) {
|
||||
if (ftruncate(fd, sizeof(sermap_buffer) * 2) == -1) {
|
||||
perror("Failed to set size of shared memory");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
sermap_data = (uae_u8*)mmap(NULL, sizeof(struct sermap_buffer) * 2, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
sermap_data = static_cast<uae_u8*>(mmap(nullptr, sizeof(sermap_buffer) * 2, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));
|
||||
if (sermap_data == MAP_FAILED) {
|
||||
perror("Shared serial port memory mmap() failed");
|
||||
close(fd);
|
||||
@ -191,14 +187,14 @@ bool shmem_serial_create(void)
|
||||
close(fd);
|
||||
|
||||
if (sermap_master) {
|
||||
sermap1 = (struct sermap_buffer*)sermap_data;
|
||||
sermap2 = (struct sermap_buffer*)(sermap_data + sizeof(struct sermap_buffer));
|
||||
sermap1 = reinterpret_cast<sermap_buffer*>(sermap_data);
|
||||
sermap2 = reinterpret_cast<sermap_buffer*>(sermap_data + sizeof(sermap_buffer));
|
||||
sermap1->version = version;
|
||||
sermap2->version = version;
|
||||
}
|
||||
else {
|
||||
sermap2 = (struct sermap_buffer*)sermap_data;
|
||||
sermap1 = (struct sermap_buffer*)(sermap_data + sizeof(struct sermap_buffer));
|
||||
sermap2 = reinterpret_cast<sermap_buffer*>(sermap_data);
|
||||
sermap1 = reinterpret_cast<sermap_buffer*>(sermap_data + sizeof(sermap_buffer));
|
||||
if (sermap2->version != version || sermap1->version != version) {
|
||||
write_log("Shared serial port memory version mismatch %08x != %08x\n", sermap1->version, version);
|
||||
shmem_serial_delete();
|
||||
@ -245,13 +241,13 @@ int serial_enet;
|
||||
static bool seriallog_lf;
|
||||
extern int consoleopen;
|
||||
|
||||
void serial_open (void);
|
||||
void serial_close (void);
|
||||
void serial_open ();
|
||||
void serial_close ();
|
||||
|
||||
uae_u16 serper, serdat, serdatr;
|
||||
static bool serper_set = false;
|
||||
|
||||
static const int allowed_baudrates[] =
|
||||
static constexpr int allowed_baudrates[] =
|
||||
{
|
||||
0, 110, 300, 600, 1200, 2400, 4800, 9600, 14400,
|
||||
19200, 31400, 38400, 57600, 115200, 128000, 256000, -1
|
||||
@ -281,7 +277,7 @@ static SOCKET serialsocket = UAE_SOCKET_INVALID;
|
||||
static SOCKET serialconn = UAE_SOCKET_INVALID;
|
||||
static BOOL tcpserial;
|
||||
|
||||
static bool tcp_is_connected (void)
|
||||
static bool tcp_is_connected ()
|
||||
{
|
||||
if (serialsocket == UAE_SOCKET_INVALID) {
|
||||
return false;
|
||||
@ -297,7 +293,7 @@ static bool tcp_is_connected (void)
|
||||
return serialconn != UAE_SOCKET_INVALID;
|
||||
}
|
||||
|
||||
static void tcp_disconnect (void)
|
||||
static void tcp_disconnect ()
|
||||
{
|
||||
if (serialconn == UAE_SOCKET_INVALID) {
|
||||
return;
|
||||
@ -307,7 +303,7 @@ static void tcp_disconnect (void)
|
||||
write_log(_T("TCP: Serial disconnect\n"));
|
||||
}
|
||||
|
||||
static void closetcp (void)
|
||||
static void closetcp ()
|
||||
{
|
||||
if (serialconn != UAE_SOCKET_INVALID) {
|
||||
uae_socket_close(serialconn);
|
||||
@ -353,7 +349,7 @@ int openser (const TCHAR *sername)
|
||||
if (sp_open(port, SP_MODE_READ_WRITE) != SP_OK) {
|
||||
write_log("Error opening serial port %s\n", sername);
|
||||
sp_free_port(port);
|
||||
port = NULL;
|
||||
port = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -387,14 +383,14 @@ void closeser ()
|
||||
midi_emu_close();
|
||||
}
|
||||
#endif
|
||||
if (port != NULL) {
|
||||
if (port != nullptr) {
|
||||
sp_close(port);
|
||||
sp_free_port(port);
|
||||
port = NULL;
|
||||
port = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void serial_rx_irq(void)
|
||||
static void serial_rx_irq()
|
||||
{
|
||||
int delay = 9;
|
||||
// Data in receive buffer
|
||||
@ -431,7 +427,7 @@ bool serreceive_external(uae_u16 v)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void receive_next_buffered(void)
|
||||
static void receive_next_buffered()
|
||||
{
|
||||
if (receive_buf && receive_buf_count > 0 && !(intreq & (1 << 11))) {
|
||||
uae_u16 v = receive_buf[0];
|
||||
@ -443,7 +439,7 @@ static void receive_next_buffered(void)
|
||||
}
|
||||
}
|
||||
|
||||
void serial_rethink(void)
|
||||
void serial_rethink()
|
||||
{
|
||||
if (data_in_serdatr) {
|
||||
int sdr = data_in_serdatr;
|
||||
@ -547,13 +543,13 @@ int readser(int* buffer)
|
||||
}
|
||||
}
|
||||
|
||||
void flushser(void)
|
||||
void flushser()
|
||||
{
|
||||
if (port) {
|
||||
sp_flush(port, SP_BUF_INPUT);
|
||||
}
|
||||
else {
|
||||
while (readseravail(NULL)) {
|
||||
while (readseravail(nullptr)) {
|
||||
int data;
|
||||
if (readser(&data) <= 0)
|
||||
break;
|
||||
@ -602,7 +598,7 @@ int readseravail(bool* breakcond)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool canreceive(void)
|
||||
static bool canreceive()
|
||||
{
|
||||
// don't replace data in SERDATR until interrupt is cleared in safe receive mode
|
||||
if (safe_receive) {
|
||||
@ -636,7 +632,7 @@ static bool canreceive(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void checkreceive_enet(void)
|
||||
static void checkreceive_enet()
|
||||
{
|
||||
#ifdef SERIAL_ENET
|
||||
uae_u16 recdata;
|
||||
@ -659,7 +655,7 @@ static void checkreceive_enet(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void checkreceive_serial (void)
|
||||
static void checkreceive_serial ()
|
||||
{
|
||||
#ifdef SERIAL_PORT
|
||||
static int ninebitdata;
|
||||
@ -795,7 +791,7 @@ static void checkreceive_serial (void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void outser(void)
|
||||
static void outser()
|
||||
{
|
||||
if (datainoutput <= 0)
|
||||
return;
|
||||
@ -812,7 +808,7 @@ static void outser(void)
|
||||
datainoutput = 0;
|
||||
}
|
||||
|
||||
void writeser_flush(void)
|
||||
void writeser_flush()
|
||||
{
|
||||
outser();
|
||||
}
|
||||
@ -822,19 +818,19 @@ void writeser(int c)
|
||||
if (tcpserial) {
|
||||
if (tcp_is_connected()) {
|
||||
char buf[1];
|
||||
buf[0] = (char) c;
|
||||
buf[0] = static_cast<char>(c);
|
||||
if (uae_socket_write(serialconn, buf, 1) != 1) {
|
||||
tcp_disconnect();
|
||||
}
|
||||
}
|
||||
#ifdef WITH_MIDIEMU
|
||||
} else if (midi_emu) {
|
||||
uae_u8 b = (uae_u8)c;
|
||||
auto b = static_cast<uae_u8>(c);
|
||||
midi_emu_parse(&b, 1);
|
||||
#endif
|
||||
#ifdef WITH_MIDI
|
||||
} else if (midi_ready) {
|
||||
midi_send_byte((uint8_t) c);
|
||||
midi_send_byte(static_cast<uint8_t>(c));
|
||||
#endif
|
||||
} else {
|
||||
if (!port || !currprefs.use_serial)
|
||||
@ -865,9 +861,9 @@ int checkserwrite(int spaceneeded)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void serdatcopy(void);
|
||||
static void serdatcopy();
|
||||
|
||||
static void checksend(void)
|
||||
static void checksend()
|
||||
{
|
||||
if (data_in_sershift != 1 && data_in_sershift != 2) {
|
||||
return;
|
||||
@ -939,7 +935,7 @@ end:
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool checkshiftempty(void)
|
||||
static bool checkshiftempty()
|
||||
{
|
||||
writeser_flush();
|
||||
checksend();
|
||||
@ -976,7 +972,7 @@ static void sersend_ce(uae_u32 v)
|
||||
}
|
||||
}
|
||||
|
||||
static void serdatcopy(void)
|
||||
static void serdatcopy()
|
||||
{
|
||||
if (data_in_sershift || !data_in_serdat)
|
||||
return;
|
||||
@ -997,7 +993,7 @@ static void serdatcopy(void)
|
||||
write_log(_T("%s:"), ts);
|
||||
seriallog_lf = false;
|
||||
}
|
||||
TCHAR ch = docharlog(serdatshift_masked);
|
||||
const TCHAR ch = docharlog(serdatshift_masked);
|
||||
write_log(_T("%c"), ch);
|
||||
if (ch == 10)
|
||||
seriallog_lf = true;
|
||||
@ -1056,7 +1052,7 @@ static void serdatcopy(void)
|
||||
|
||||
if (lastbitcycle_active_hsyncs) {
|
||||
// if last bit still transmitting, add remaining time.
|
||||
int extraper = (int)((lastbitcycle - get_cycles()) / CYCLE_UNIT);
|
||||
int extraper = static_cast<int>((lastbitcycle - get_cycles()) / CYCLE_UNIT);
|
||||
per += extraper;
|
||||
}
|
||||
|
||||
@ -1073,7 +1069,7 @@ static void serdatcopy(void)
|
||||
checksend();
|
||||
}
|
||||
|
||||
void serial_hsynchandler (void)
|
||||
void serial_hsynchandler ()
|
||||
{
|
||||
// We handle this in ahi_hsync() instead
|
||||
#ifndef AMIBERRY
|
||||
@ -1087,7 +1083,7 @@ void serial_hsynchandler (void)
|
||||
#ifdef ARCADIA
|
||||
if (alg_flag || currprefs.genlock_image >= 7) {
|
||||
if (can) {
|
||||
int ch = ld_serial_write();
|
||||
const int ch = ld_serial_write();
|
||||
if (ch >= 0) {
|
||||
serdatr = ch | 0x100;
|
||||
serial_rx_irq();
|
||||
@ -1105,7 +1101,7 @@ void serial_hsynchandler (void)
|
||||
}
|
||||
}
|
||||
if (seriallog > 1 && !data_in_serdatr && gotlogwrite) {
|
||||
int ch = read_log();
|
||||
const int ch = read_log();
|
||||
if (ch > 0) {
|
||||
serdatr = ch | 0x100;
|
||||
serial_rx_irq();
|
||||
@ -1122,7 +1118,7 @@ void serial_hsynchandler (void)
|
||||
break;
|
||||
}
|
||||
if (!(v & 0xffff0000)) {
|
||||
serdatr = (uae_u16)v;
|
||||
serdatr = static_cast<uae_u16>(v);
|
||||
serial_rx_irq();
|
||||
break;
|
||||
} else if ((v & 0x80000000) == 0x80000000) {
|
||||
@ -1327,10 +1323,10 @@ void SERPER(uae_u16 w)
|
||||
evt_t c = get_cycles();
|
||||
evt_t n = serper_tx_evt + serper_tx_cycles * CYCLE_UNIT;
|
||||
if (n > c) {
|
||||
int cycles_transmitted = (int)((c - serper_tx_evt) / CYCLE_UNIT);
|
||||
const int cycles_transmitted = static_cast<int>((c - serper_tx_evt) / CYCLE_UNIT);
|
||||
serper_tx_cycles -= cycles_transmitted;
|
||||
if (serper_tx_cycles >= 0) {
|
||||
int serper_tx_cycles_mod = serper_tx_cycles % serper_tx_per;
|
||||
const int serper_tx_cycles_mod = serper_tx_cycles % serper_tx_per;
|
||||
serper_tx_cycles /= serper_tx_per;
|
||||
serper_tx_per = (serper & 0x7fff) + 1;
|
||||
serper_tx_cycles *= serper_tx_per;
|
||||
@ -1344,7 +1340,7 @@ void SERPER(uae_u16 w)
|
||||
|
||||
static void SERDAT_send(uae_u32 v)
|
||||
{
|
||||
uae_u16 w = (uae_u16)v;
|
||||
auto w = static_cast<uae_u16>(v);
|
||||
#if SERIALDEBUG > 2
|
||||
write_log(_T("SERIAL: SERDAT write 0x%04x (%c) PC=%x\n"), w, dochar(w), M68K_GETPC);
|
||||
#endif
|
||||
@ -1383,7 +1379,7 @@ static void SERDAT_send(uae_u32 v)
|
||||
}
|
||||
}
|
||||
|
||||
uae_u16 SERDATR(void)
|
||||
uae_u16 SERDATR()
|
||||
{
|
||||
serdatr &= 0x03ff;
|
||||
if (!data_in_serdat && (!ser_accurate || (ser_accurate && get_cycles() >= data_in_serdat_delay))) {
|
||||
@ -1406,7 +1402,7 @@ uae_u16 SERDATR(void)
|
||||
if (break_in_serdatr < 0) {
|
||||
serdatr |= 0x0800;
|
||||
} else if (diff > 0) {
|
||||
int bit = (int)(c - serdatshift_start) / per;
|
||||
const int bit = static_cast<int>(c - serdatshift_start) / per;
|
||||
if (bit > 0 && !(serdatshift & (1 << (bit - 1)))) {
|
||||
serdatr |= 0x0800;
|
||||
}
|
||||
@ -1447,7 +1443,7 @@ void serial_rbf_change(bool set)
|
||||
ovrun = set;
|
||||
}
|
||||
|
||||
void serial_dtr_on(void)
|
||||
void serial_dtr_on()
|
||||
{
|
||||
#if SERIALHSDEBUG > 0
|
||||
write_log("SERIAL: DTR on\n");
|
||||
@ -1465,7 +1461,7 @@ void serial_dtr_on(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_dtr_off(void)
|
||||
void serial_dtr_off()
|
||||
{
|
||||
#if SERIALHSDEBUG > 0
|
||||
write_log("SERIAL: DTR off\n");
|
||||
@ -1483,7 +1479,7 @@ void serial_dtr_off(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_flush_buffer (void)
|
||||
void serial_flush_buffer ()
|
||||
{
|
||||
}
|
||||
|
||||
@ -1716,7 +1712,7 @@ uae_u8 serial_writestatus(uae_u8 newstate, uae_u8 dir)
|
||||
return oldserbits;
|
||||
}
|
||||
|
||||
static int enet_is(TCHAR* name)
|
||||
static int enet_is(const TCHAR* name)
|
||||
{
|
||||
return !_tcsnicmp(name, _T("ENET:"), 5);
|
||||
}
|
||||
@ -1727,7 +1723,7 @@ void serial_open()
|
||||
if (serdev)
|
||||
return;
|
||||
serper = 0;
|
||||
if (0) {
|
||||
if (false) {
|
||||
#ifdef SERIAL_ENET
|
||||
}
|
||||
else if (enet_is(currprefs.sername)) {
|
||||
@ -1771,7 +1767,7 @@ void serial_open()
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_close(void)
|
||||
void serial_close()
|
||||
{
|
||||
#ifdef SERIAL_PORT
|
||||
closeser();
|
||||
@ -1790,7 +1786,7 @@ void serial_close(void)
|
||||
#endif
|
||||
if (receive_buf) {
|
||||
xfree(receive_buf);
|
||||
receive_buf = NULL;
|
||||
receive_buf = nullptr;
|
||||
}
|
||||
receive_buf_size = 0;
|
||||
receive_buf_count = 0;
|
||||
@ -1803,7 +1799,7 @@ void serial_close(void)
|
||||
data_in_serdat_delay = 0;
|
||||
}
|
||||
|
||||
void serial_init(void)
|
||||
void serial_init()
|
||||
{
|
||||
#ifdef SERIAL_PORT
|
||||
if (!currprefs.use_serial)
|
||||
@ -1813,7 +1809,7 @@ void serial_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_exit (void)
|
||||
void serial_exit ()
|
||||
{
|
||||
#ifdef SERIAL_PORT
|
||||
serial_close();
|
||||
@ -1886,12 +1882,11 @@ static void enet_service(int serveronly)
|
||||
{
|
||||
ENetEvent evt;
|
||||
ENetAddress address;
|
||||
int got;
|
||||
|
||||
if (enetmode == 0)
|
||||
return;
|
||||
|
||||
got = 1;
|
||||
int got = 1;
|
||||
while (got) {
|
||||
got = 0;
|
||||
if (enetmode > 0) {
|
||||
@ -1904,7 +1899,7 @@ static void enet_service(int serveronly)
|
||||
write_log(_T("ENET_SERVER: connect from %d.%d.%d.%d:%u\n"),
|
||||
(address.host >> 0) & 0xff, (address.host >> 8) & 0xff, (address.host >> 16) & 0xff, (address.host >> 24) & 0xff,
|
||||
address.port);
|
||||
evt.peer->data = 0;
|
||||
evt.peer->data = nullptr;
|
||||
break;
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
{
|
||||
@ -1925,6 +1920,7 @@ static void enet_service(int serveronly)
|
||||
(address.host >> 0) & 0xff, (address.host >> 8) & 0xff, (address.host >> 16) & 0xff, (address.host >> 24) & 0xff,
|
||||
address.port);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1965,39 +1961,38 @@ static void enet_disconnect(ENetPeer* peer)
|
||||
|
||||
case ENET_EVENT_TYPE_DISCONNECT:
|
||||
write_log(_T("ENET_CLIENT: disconnection succeeded\n"));
|
||||
enetpeer = NULL;
|
||||
enetpeer = nullptr;
|
||||
return;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
write_log(_T("ENET_CLIENT: disconnection forced\n"));
|
||||
enet_peer_reset(enetpeer);
|
||||
enetpeer = NULL;
|
||||
enetpeer = nullptr;
|
||||
}
|
||||
|
||||
void enet_close(void)
|
||||
void enet_close()
|
||||
{
|
||||
enet_disconnect(enetpeer);
|
||||
if (enetclient)
|
||||
enet_host_destroy(enetclient);
|
||||
enetclient = NULL;
|
||||
enetclient = nullptr;
|
||||
if (enethost)
|
||||
enet_host_destroy(enethost);
|
||||
enethost = NULL;
|
||||
enethost = nullptr;
|
||||
serial_enet = 0;
|
||||
enetmode = 0;
|
||||
}
|
||||
|
||||
int enet_open(TCHAR* name)
|
||||
int enet_open(const TCHAR* name)
|
||||
{
|
||||
ENetAddress address;
|
||||
ENetPacket* p;
|
||||
static int initialized;
|
||||
uae_u8 data[16];
|
||||
int cnt;
|
||||
|
||||
if (!initialized) {
|
||||
int err = enet_initialize();
|
||||
const int err = enet_initialize();
|
||||
if (err) {
|
||||
write_log(_T("ENET: initialization failed: %d\n"), err);
|
||||
return 0;
|
||||
@ -2011,7 +2006,7 @@ int enet_open(TCHAR* name)
|
||||
address.host = ENET_HOST_ANY;
|
||||
address.port = 1234;
|
||||
enethost = enet_host_create(&address, 2, 0, 0, 0);
|
||||
if (enethost == NULL) {
|
||||
if (enethost == nullptr) {
|
||||
write_log(_T("ENET_SERVER: enet_host_create(server) failed\n"));
|
||||
enet_close();
|
||||
return 0;
|
||||
@ -2022,8 +2017,8 @@ int enet_open(TCHAR* name)
|
||||
else {
|
||||
enetmode = -1;
|
||||
}
|
||||
enetclient = enet_host_create(NULL, 1, 0, 0, 0);
|
||||
if (enetclient == NULL) {
|
||||
enetclient = enet_host_create(nullptr, 1, 0, 0, 0);
|
||||
if (enetclient == nullptr) {
|
||||
write_log(_T("ENET_CLIENT: enet_host_create(client) failed\n"));
|
||||
enet_close();
|
||||
return 0;
|
||||
@ -2032,15 +2027,15 @@ int enet_open(TCHAR* name)
|
||||
enet_address_set_host(&address, enetmode > 0 ? "127.0.0.1" : "192.168.0.10");
|
||||
address.port = 1234;
|
||||
enetpeer = enet_host_connect(enetclient, &address, 2, 0);
|
||||
if (enetpeer == NULL) {
|
||||
if (enetpeer == nullptr) {
|
||||
write_log(_T("ENET_CLIENT: connection to host %d.%d.%d.%d:%d failed\n"),
|
||||
(address.host >> 0) & 0xff, (address.host >> 8) & 0xff, (address.host >> 16) & 0xff, (address.host >> 24) & 0xff, address.port);
|
||||
enet_host_destroy(enetclient);
|
||||
enetclient = NULL;
|
||||
enetclient = nullptr;
|
||||
}
|
||||
write_log(_T("ENET_CLIENT: connecting to %d.%d.%d.%d:%d...\n"),
|
||||
(address.host >> 0) & 0xff, (address.host >> 8) & 0xff, (address.host >> 16) & 0xff, (address.host >> 24) & 0xff, address.port);
|
||||
cnt = 10 * 5;
|
||||
int cnt = 10 * 5;
|
||||
while (cnt-- > 0) {
|
||||
ENetEvent evt;
|
||||
enet_service(0);
|
||||
@ -2055,7 +2050,7 @@ int enet_open(TCHAR* name)
|
||||
return 0;
|
||||
}
|
||||
memcpy(data, "UAE_HELLO", 10);
|
||||
p = enet_packet_create(data, sizeof data, ENET_PACKET_FLAG_RELIABLE);
|
||||
ENetPacket* p = enet_packet_create(data, sizeof data, ENET_PACKET_FLAG_RELIABLE);
|
||||
enet_peer_send(enetpeer, 0, p);
|
||||
enet_host_flush(enetclient);
|
||||
write_log(_T("ENET: connected\n"));
|
||||
@ -2065,19 +2060,18 @@ int enet_open(TCHAR* name)
|
||||
|
||||
void enet_writeser(uae_u16 w)
|
||||
{
|
||||
ENetPacket* p;
|
||||
uae_u8 data[16];
|
||||
|
||||
memcpy(data, "UAE_", 4);
|
||||
data[4] = w >> 8;
|
||||
data[5] = w >> 0;
|
||||
write_log(_T("W=%04X "), w);
|
||||
p = enet_packet_create(data, 6, ENET_PACKET_FLAG_RELIABLE);
|
||||
ENetPacket* p = enet_packet_create(data, 6, ENET_PACKET_FLAG_RELIABLE);
|
||||
enet_peer_send(enetpeer, 0, p);
|
||||
enet_host_flush(enetclient);
|
||||
}
|
||||
|
||||
int enet_readseravail(void)
|
||||
int enet_readseravail()
|
||||
{
|
||||
enet_service(0);
|
||||
return enet_receive_off_r != enet_receive_off_w;
|
||||
|
||||
@ -17,7 +17,7 @@ void ethernet_pause(int pause)
|
||||
ethernet_paused = pause;
|
||||
}
|
||||
|
||||
void ethernet_reset(void)
|
||||
void ethernet_reset()
|
||||
{
|
||||
ethernet_paused = 0;
|
||||
}
|
||||
@ -616,7 +616,7 @@ void set_compatibility_settings(uae_prefs* prefs, const game_hardware_options& g
|
||||
parse_cfg_line(prefs, line_string);
|
||||
}
|
||||
|
||||
// CPU 68000/010 [requires a600 rom)]
|
||||
// CPU 68000/010 (requires a600 rom)
|
||||
else if ((strcmpi(game_detail.cpu.c_str(), "68000") == 0 || strcmpi(game_detail.cpu.c_str(), "68010") == 0) && a600_available)
|
||||
{
|
||||
line_string = "cpu_type=";
|
||||
|
||||
@ -50,13 +50,13 @@ cda_audio::cda_audio(int num_sectors, int sectorsize, int samplerate)
|
||||
|
||||
bufsize = num_sectors * sectorsize;
|
||||
this->sectorsize = sectorsize;
|
||||
for (auto i = 0; i < 2; i++) {
|
||||
buffers[i] = xcalloc(uae_u8, num_sectors * ((bufsize + 4095) & ~4095));
|
||||
for (auto & buffer : buffers) {
|
||||
buffer = xcalloc(uae_u8, num_sectors * ((bufsize + 4095) & ~4095));
|
||||
}
|
||||
this->num_sectors = num_sectors;
|
||||
|
||||
auto devname = sound_devices[currprefs.soundcard]->name;
|
||||
const Uint8 channels = 2;
|
||||
constexpr Uint8 channels = 2;
|
||||
SDL_AudioSpec cdda_want, cdda_have;
|
||||
SDL_zero(cdda_want);
|
||||
cdda_want.freq = samplerate;
|
||||
|
||||
@ -10,12 +10,12 @@ private:
|
||||
int bufsize;
|
||||
int num_sectors;
|
||||
int sectorsize;
|
||||
int volume[2];
|
||||
int volume[2]{};
|
||||
bool playing;
|
||||
bool active;
|
||||
|
||||
public:
|
||||
uae_u8* buffers[2];
|
||||
uae_u8* buffers[2]{};
|
||||
|
||||
cda_audio(int num_sectors, int sectorsize, int samplerate);
|
||||
~cda_audio();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include <ctype.h>
|
||||
#include <cctype>
|
||||
#include "sysdeps.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
// Amiberry and fs-uae uses only chars / UTF-8 internally, so TCHAR is typedefed to
|
||||
// char (WinUAE uses wchar_t internally).
|
||||
|
||||
@ -189,12 +189,12 @@ static TCHAR* amigatopc(const char* txt)
|
||||
#endif
|
||||
if (c == 0x9b)
|
||||
{
|
||||
i = parsecsi(txt, int(i) + 1, int(len));
|
||||
i = parsecsi(txt, static_cast<int>(i) + 1, static_cast<int>(len));
|
||||
continue;
|
||||
}
|
||||
if (c == 0x1b && i + 1 < len && txt[i + 1] == '[')
|
||||
{
|
||||
i = parsecsi(txt, int(i) + 2, int(len));
|
||||
i = parsecsi(txt, static_cast<int>(i) + 2, static_cast<int>(len));
|
||||
continue;
|
||||
}
|
||||
txt2[j++] = c;
|
||||
@ -207,16 +207,12 @@ static TCHAR* amigatopc(const char* txt)
|
||||
static void to_iff_text(TrapContext* ctx, const TCHAR* pctxt)
|
||||
{
|
||||
uae_u8 b[] = {'F', 'O', 'R', 'M', 0, 0, 0, 0, 'F', 'T', 'X', 'T', 'C', 'H', 'R', 'S', 0, 0, 0, 0};
|
||||
uae_u32 size;
|
||||
int txtlen;
|
||||
uae_char* txt;
|
||||
char* s;
|
||||
|
||||
s = ua(pctxt);
|
||||
txt = pctoamiga(s);
|
||||
txtlen = strlen(txt);
|
||||
auto s = ua(pctxt);
|
||||
uae_char* txt = pctoamiga(s);
|
||||
int txtlen = strlen(txt);
|
||||
xfree(to_amiga);
|
||||
size = txtlen + sizeof b + (txtlen & 1) - 8;
|
||||
uae_u32 size = txtlen + sizeof b + (txtlen & 1) - 8;
|
||||
b[4] = size >> 24;
|
||||
b[5] = size >> 16;
|
||||
b[6] = size >> 8;
|
||||
@ -255,7 +251,13 @@ static void from_iff_text(uae_u8* addr, uae_u32 len)
|
||||
{
|
||||
const auto prevsize = txtsize;
|
||||
txtsize += csize;
|
||||
txt = xrealloc(char, txt, txtsize + 1);
|
||||
char* new_txt = xrealloc(char, txt, txtsize + 1);
|
||||
if (!new_txt)
|
||||
{
|
||||
xfree(txt);
|
||||
return;
|
||||
}
|
||||
txt = new_txt;
|
||||
memcpy(txt + prevsize, addr + 8, csize);
|
||||
txt[txtsize] = 0;
|
||||
}
|
||||
@ -743,7 +745,7 @@ static void from_iff(TrapContext* ctx, uaecptr data, uae_u32 len)
|
||||
trap_get_bytes(ctx, buf, data, int(len + 3) & ~3);
|
||||
|
||||
if (clipboard_debug)
|
||||
debugwrite(ctx, _T("clipboard_a2p"), data, int(len));
|
||||
debugwrite(ctx, _T("clipboard_a2p"), data, static_cast<int>(len));
|
||||
if (!memcmp("FORM", buf, 4))
|
||||
{
|
||||
if (!memcmp("FTXT", buf + 8, 4))
|
||||
@ -873,7 +875,7 @@ static void clipboard_read(TrapContext* ctx, int hwnd, bool keyboardinject)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void clipboard_free_delayed(void)
|
||||
static void clipboard_free_delayed()
|
||||
{
|
||||
if (clipboard_delayed_data == nullptr)
|
||||
return;
|
||||
@ -1103,7 +1105,7 @@ static uae_u32 clipboard_vsync_cb(TrapContext* ctx, void* ud)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void clipboard_vsync(void)
|
||||
void clipboard_vsync()
|
||||
{
|
||||
if (!filesys_heartbeat())
|
||||
return;
|
||||
@ -1132,7 +1134,7 @@ void clipboard_vsync(void)
|
||||
}
|
||||
}
|
||||
|
||||
void clipboard_reset(void)
|
||||
void clipboard_reset()
|
||||
{
|
||||
write_log(_T("clipboard: reset (%08x)\n"), clipboard_data);
|
||||
clipboard_unsafeperiod();
|
||||
@ -1152,7 +1154,7 @@ void clipboard_reset(void)
|
||||
}
|
||||
|
||||
#ifdef AMIBERRY
|
||||
void clipboard_init(void)
|
||||
void clipboard_init()
|
||||
{
|
||||
chwnd = 1; // fake window handle
|
||||
write_log(_T("clipboard_init\n"));
|
||||
@ -1170,7 +1172,7 @@ void clipboard_init (HWND hwnd)
|
||||
#endif
|
||||
}
|
||||
|
||||
void target_paste_to_keyboard(void)
|
||||
void target_paste_to_keyboard()
|
||||
{
|
||||
#ifdef AMIBERRY
|
||||
write_log("target_paste_to_keyboard (clipboard)\n");
|
||||
@ -1178,8 +1180,8 @@ void target_paste_to_keyboard(void)
|
||||
clipboard_read(nullptr, chwnd, true);
|
||||
}
|
||||
|
||||
// force 2 second delay before accepting new data
|
||||
void clipboard_unsafeperiod(void)
|
||||
// force 2-second delay before accepting new data
|
||||
void clipboard_unsafeperiod()
|
||||
{
|
||||
vdelay2 = 100;
|
||||
if (vdelay < 60)
|
||||
@ -1200,7 +1202,7 @@ char* uae_clipboard_get_text()
|
||||
return text;
|
||||
}
|
||||
|
||||
void uae_clipboard_free_text(char* text)
|
||||
void uae_clipboard_free_text(const char* text)
|
||||
{
|
||||
if (text)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
float DPIHandler::get_scale() {
|
||||
constexpr int display_index{0};
|
||||
const float default_dpi{96.0F};
|
||||
constexpr float default_dpi{96.0F};
|
||||
float dpi{default_dpi};
|
||||
|
||||
SDL_GetDisplayDPI(display_index, nullptr, &dpi, nullptr);
|
||||
|
||||
@ -60,7 +60,7 @@ static char* aname_to_nname(const char* aname, const int ascii)
|
||||
if (a == 'N' && b == 'U' && c == 'L') ll = 3; // NUL
|
||||
if (a == 'L' && b == 'P' && c == 'T' && (d >= '0' && d <= '9')) ll = 4; // LPT#
|
||||
if (a == 'C' && b == 'O' && c == 'M' && (d >= '0' && d <= '9')) ll = 4; // COM#
|
||||
// AUX.anything, CON.anything etc.. are also illegal names in Windows
|
||||
// AUX.anything, CON.anything etc... are also illegal names in Windows
|
||||
if (ll && (len == ll || (len > ll && aname[ll] == '.'))) {
|
||||
repl_1 = 2;
|
||||
}
|
||||
@ -177,12 +177,12 @@ int fsdb_exists(const TCHAR* nname)
|
||||
return fs_path_exists(nname);
|
||||
}
|
||||
|
||||
bool my_utime(const char* name, struct mytimeval* tv)
|
||||
bool my_utime(const char* name, const struct mytimeval* tv)
|
||||
{
|
||||
struct mytimeval mtv {};
|
||||
struct timeval times[2];
|
||||
|
||||
if (tv == NULL) {
|
||||
if (tv == nullptr) {
|
||||
struct timeval time {};
|
||||
struct timezone tz {};
|
||||
|
||||
@ -298,7 +298,7 @@ int fsdb_mode_representable_p(const a_inode* aino, int amigaos_mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
TCHAR* fsdb_create_unique_nname(a_inode* base, const TCHAR* suggestion)
|
||||
TCHAR* fsdb_create_unique_nname(const a_inode* base, const TCHAR* suggestion)
|
||||
{
|
||||
char* nname = aname_to_nname(suggestion, 0);
|
||||
TCHAR* p = build_nname(base->nname, nname);
|
||||
|
||||
@ -89,7 +89,7 @@ static struct
|
||||
{ 91, -20, 180.0, MARKER_AXIS, "Left Trigger"}, /* SDL_CONTROLLER_BINDING_AXIS_TRIGGERLEFT */
|
||||
{ 375, -20, 180.0, MARKER_AXIS, "Right Trigger"}, /* SDL_CONTROLLER_BINDING_AXIS_TRIGGERRIGHT */
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(s_arrBindingDisplay, SDL_arraysize(s_arrBindingDisplay) == BINDING_COUNT);
|
||||
SDL_COMPILE_TIME_ASSERT(s_arrBindingDisplay, std::size(s_arrBindingDisplay) == BINDING_COUNT);
|
||||
|
||||
static int s_arrBindingOrder[BINDING_COUNT] = {
|
||||
SDL_CONTROLLER_BUTTON_A,
|
||||
@ -126,7 +126,7 @@ static int s_arrBindingOrder[BINDING_COUNT] = {
|
||||
SDL_CONTROLLER_BUTTON_TOUCHPAD,
|
||||
#endif
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(s_arrBindingOrder, SDL_arraysize(s_arrBindingOrder) == BINDING_COUNT);
|
||||
SDL_COMPILE_TIME_ASSERT(s_arrBindingOrder, std::size(s_arrBindingOrder) == BINDING_COUNT);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -287,7 +287,6 @@ StandardizeAxisValue(int nValue)
|
||||
static void
|
||||
SetCurrentBinding(int iBinding)
|
||||
{
|
||||
int iIndex;
|
||||
SDL_GameControllerExtendedBind* pBinding;
|
||||
|
||||
if (iBinding < 0)
|
||||
@ -320,7 +319,7 @@ SetCurrentBinding(int iBinding)
|
||||
pBinding = &s_arrBindings[s_arrBindingOrder[s_iCurrentBinding]];
|
||||
SDL_zerop(pBinding);
|
||||
|
||||
for (iIndex = 0; iIndex < s_nNumAxes; ++iIndex)
|
||||
for (int iIndex = 0; iIndex < s_nNumAxes; ++iIndex)
|
||||
{
|
||||
s_arrAxisState[iIndex].m_nFarthestValue = s_arrAxisState[iIndex].m_nStartingValue;
|
||||
}
|
||||
@ -348,10 +347,10 @@ BBindingContainsBinding(const SDL_GameControllerExtendedBind* pBindingA,
|
||||
return SDL_FALSE;
|
||||
}
|
||||
{
|
||||
int minA = SDL_min(pBindingA->value.axis.axis_min, pBindingA->value.axis.axis_max);
|
||||
int maxA = SDL_max(pBindingA->value.axis.axis_min, pBindingA->value.axis.axis_max);
|
||||
int minB = SDL_min(pBindingB->value.axis.axis_min, pBindingB->value.axis.axis_max);
|
||||
int maxB = SDL_max(pBindingB->value.axis.axis_min, pBindingB->value.axis.axis_max);
|
||||
const int minA = SDL_min(pBindingA->value.axis.axis_min, pBindingA->value.axis.axis_max);
|
||||
const int maxA = SDL_max(pBindingA->value.axis.axis_min, pBindingA->value.axis.axis_max);
|
||||
const int minB = SDL_min(pBindingB->value.axis.axis_min, pBindingB->value.axis.axis_max);
|
||||
const int maxB = SDL_max(pBindingB->value.axis.axis_min, pBindingB->value.axis.axis_max);
|
||||
return (minA <= minB && maxA >= maxB);
|
||||
}
|
||||
/* Not reached */
|
||||
@ -364,11 +363,10 @@ static void
|
||||
ConfigureBinding(const SDL_GameControllerExtendedBind* pBinding)
|
||||
{
|
||||
SDL_GameControllerExtendedBind* pCurrent;
|
||||
int iIndex;
|
||||
int iCurrentElement = s_arrBindingOrder[s_iCurrentBinding];
|
||||
const int iCurrentElement = s_arrBindingOrder[s_iCurrentBinding];
|
||||
|
||||
/* Do we already have this binding? */
|
||||
for (iIndex = 0; iIndex < SDL_arraysize(s_arrBindings); ++iIndex)
|
||||
for (int iIndex = 0; iIndex < std::size(s_arrBindings); ++iIndex)
|
||||
{
|
||||
pCurrent = &s_arrBindings[iIndex];
|
||||
if (BBindingContainsBinding(pCurrent, pBinding))
|
||||
@ -413,22 +411,19 @@ ConfigureBinding(const SDL_GameControllerExtendedBind* pBinding)
|
||||
pCurrent = &s_arrBindings[iCurrentElement];
|
||||
if (pCurrent->bindType != SDL_CONTROLLER_BINDTYPE_NONE)
|
||||
{
|
||||
bool bNativeDPad, bCurrentDPad;
|
||||
bool bNativeAxis, bCurrentAxis;
|
||||
|
||||
bNativeDPad = (iCurrentElement == SDL_CONTROLLER_BUTTON_DPAD_UP ||
|
||||
const bool bNativeDPad = (iCurrentElement == SDL_CONTROLLER_BUTTON_DPAD_UP ||
|
||||
iCurrentElement == SDL_CONTROLLER_BUTTON_DPAD_DOWN ||
|
||||
iCurrentElement == SDL_CONTROLLER_BUTTON_DPAD_LEFT ||
|
||||
iCurrentElement == SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
|
||||
bCurrentDPad = (pCurrent->bindType == SDL_CONTROLLER_BINDTYPE_HAT);
|
||||
const bool bCurrentDPad = (pCurrent->bindType == SDL_CONTROLLER_BINDTYPE_HAT);
|
||||
if (bNativeDPad && bCurrentDPad)
|
||||
{
|
||||
/* We already have a binding of the type we want, ignore the new one */
|
||||
return;
|
||||
}
|
||||
|
||||
bNativeAxis = (iCurrentElement >= SDL_CONTROLLER_BUTTON_MAX);
|
||||
bCurrentAxis = (pCurrent->bindType == SDL_CONTROLLER_BINDTYPE_AXIS);
|
||||
const bool bNativeAxis = (iCurrentElement >= SDL_CONTROLLER_BUTTON_MAX);
|
||||
const bool bCurrentAxis = (pCurrent->bindType == SDL_CONTROLLER_BINDTYPE_AXIS);
|
||||
if (bNativeAxis == bCurrentAxis &&
|
||||
(pBinding->bindType != SDL_CONTROLLER_BINDTYPE_AXIS ||
|
||||
pBinding->value.axis.axis != pCurrent->value.axis.axis))
|
||||
@ -475,7 +470,7 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
{
|
||||
AmigaMonitor* mon = &AMonitors[0];
|
||||
SDL_Texture* button, *axis, *marker;
|
||||
const char* name = NULL;
|
||||
const char* name = nullptr;
|
||||
SDL_Event event;
|
||||
SDL_Rect dst;
|
||||
Uint8 alpha = 200, alpha_step = -1;
|
||||
@ -601,7 +596,7 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
case SDL_JOYAXISMOTION:
|
||||
if (event.jaxis.which == nJoystickID)
|
||||
{
|
||||
const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */
|
||||
constexpr int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */
|
||||
AxisState* pAxisState = &s_arrAxisState[event.jaxis.axis];
|
||||
int nValue = event.jaxis.value;
|
||||
int nCurrentDistance, nFarthestDistance;
|
||||
@ -733,7 +728,7 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
int iIndex;
|
||||
char pszElement[12];
|
||||
|
||||
SDL_strlcpy(trimmed_name, name, SDL_arraysize(trimmed_name));
|
||||
SDL_strlcpy(trimmed_name, name, std::size(trimmed_name));
|
||||
while (SDL_isspace(trimmed_name[0]))
|
||||
{
|
||||
SDL_memmove(&trimmed_name[0], &trimmed_name[1], SDL_strlen(trimmed_name));
|
||||
@ -748,15 +743,15 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
}
|
||||
|
||||
/* Initialize mapping with GUID and name */
|
||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), mapping, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, trimmed_name, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "platform:", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, SDL_GetPlatform(), SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), mapping, std::size(mapping));
|
||||
SDL_strlcat(mapping, ",", std::size(mapping));
|
||||
SDL_strlcat(mapping, trimmed_name, std::size(mapping));
|
||||
SDL_strlcat(mapping, ",", std::size(mapping));
|
||||
SDL_strlcat(mapping, "platform:", std::size(mapping));
|
||||
SDL_strlcat(mapping, SDL_GetPlatform(), std::size(mapping));
|
||||
SDL_strlcat(mapping, ",", std::size(mapping));
|
||||
|
||||
for (iIndex = 0; iIndex < SDL_arraysize(s_arrBindings); ++iIndex)
|
||||
for (iIndex = 0; iIndex < std::size(s_arrBindings); ++iIndex)
|
||||
{
|
||||
SDL_GameControllerExtendedBind* pBinding = &s_arrBindings[iIndex];
|
||||
if (pBinding->bindType == SDL_CONTROLLER_BINDTYPE_NONE)
|
||||
@ -767,7 +762,7 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
if (iIndex < SDL_CONTROLLER_BUTTON_MAX)
|
||||
{
|
||||
auto eButton = static_cast<SDL_GameControllerButton>(iIndex);
|
||||
SDL_strlcat(mapping, SDL_GameControllerGetStringForButton(eButton), SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, SDL_GameControllerGetStringForButton(eButton), std::size(mapping));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -777,45 +772,45 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
case SDL_CONTROLLER_BINDING_AXIS_LEFTX_NEGATIVE:
|
||||
if (!BMergeAxisBindings(iIndex))
|
||||
{
|
||||
SDL_strlcat(mapping, "-", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "-", std::size(mapping));
|
||||
}
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_LEFTX);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDING_AXIS_LEFTX_POSITIVE:
|
||||
SDL_strlcat(mapping, "+", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "+", std::size(mapping));
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_LEFTX);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDING_AXIS_LEFTY_NEGATIVE:
|
||||
if (!BMergeAxisBindings(iIndex))
|
||||
{
|
||||
SDL_strlcat(mapping, "-", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "-", std::size(mapping));
|
||||
}
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_LEFTY);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDING_AXIS_LEFTY_POSITIVE:
|
||||
SDL_strlcat(mapping, "+", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "+", std::size(mapping));
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_LEFTY);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDING_AXIS_RIGHTX_NEGATIVE:
|
||||
if (!BMergeAxisBindings(iIndex))
|
||||
{
|
||||
SDL_strlcat(mapping, "-", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "-", std::size(mapping));
|
||||
}
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_RIGHTX);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDING_AXIS_RIGHTX_POSITIVE:
|
||||
SDL_strlcat(mapping, "+", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "+", std::size(mapping));
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_RIGHTX);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDING_AXIS_RIGHTY_NEGATIVE:
|
||||
if (!BMergeAxisBindings(iIndex))
|
||||
{
|
||||
SDL_strlcat(mapping, "-", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "-", std::size(mapping));
|
||||
}
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_RIGHTY);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDING_AXIS_RIGHTY_POSITIVE:
|
||||
SDL_strlcat(mapping, "+", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, "+", std::size(mapping));
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_RIGHTY);
|
||||
break;
|
||||
case SDL_CONTROLLER_BINDING_AXIS_TRIGGERLEFT:
|
||||
@ -824,10 +819,13 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
case SDL_CONTROLLER_BINDING_AXIS_TRIGGERRIGHT:
|
||||
pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
|
||||
break;
|
||||
default: /* Shouldn't happen */
|
||||
pszAxisName = "Unknown";
|
||||
break;
|
||||
}
|
||||
SDL_strlcat(mapping, pszAxisName, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, pszAxisName, std::size(mapping));
|
||||
}
|
||||
SDL_strlcat(mapping, ":", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ":", std::size(mapping));
|
||||
|
||||
pszElement[0] = '\0';
|
||||
switch (pBinding->bindType)
|
||||
@ -852,7 +850,7 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
if (pBinding->value.axis.axis_min > pBinding->value.axis.axis_max)
|
||||
{
|
||||
/* Invert the axis */
|
||||
SDL_strlcat(pszElement, "~", SDL_arraysize(pszElement));
|
||||
SDL_strlcat(pszElement, "~", std::size(pszElement));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -864,8 +862,8 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
SDL_assert(!"Unknown bind type");
|
||||
break;
|
||||
}
|
||||
SDL_strlcat(mapping, pszElement, SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, ",", SDL_arraysize(mapping));
|
||||
SDL_strlcat(mapping, pszElement, std::size(mapping));
|
||||
SDL_strlcat(mapping, ",", std::size(mapping));
|
||||
}
|
||||
|
||||
write_log("Mapping:\n\n%s\n\n", mapping);
|
||||
@ -882,10 +880,9 @@ WatchJoystick(SDL_Joystick* joystick)
|
||||
std::string
|
||||
show_controller_map(int device, bool map_touchpad)
|
||||
{
|
||||
AmigaMonitor* mon = &AMonitors[0];
|
||||
const AmigaMonitor* mon = &AMonitors[0];
|
||||
|
||||
const char* name;
|
||||
int i;
|
||||
SDL_Joystick* joystick;
|
||||
bind_touchpad = map_touchpad;
|
||||
|
||||
@ -914,7 +911,7 @@ show_controller_map(int device, bool map_touchpad)
|
||||
#ifdef DEBUG
|
||||
/* Print information about the joysticks */
|
||||
write_log("There are %d joysticks attached\n", SDL_NumJoysticks());
|
||||
for (i = 0; i < SDL_NumJoysticks(); ++i)
|
||||
for (int i = 0; i < SDL_NumJoysticks(); ++i)
|
||||
{
|
||||
name = SDL_JoystickNameForIndex(i);
|
||||
write_log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
|
||||
|
||||
@ -140,7 +140,6 @@ static void InitCreateFilesysHardfile()
|
||||
cmdPath->addActionListener(createFilesysHardfileActionListener);
|
||||
|
||||
int posY = DISTANCE_BORDER;
|
||||
int posX = DISTANCE_BORDER;
|
||||
|
||||
wndCreateFilesysHardfile->add(lblPath, DISTANCE_BORDER, posY);
|
||||
wndCreateFilesysHardfile->add(txtPath, DISTANCE_BORDER + lblPath->getWidth() + 8, posY);
|
||||
|
||||
@ -553,7 +553,6 @@ bool EditFilesysHardDrive(const int unit_no)
|
||||
const AmigaMonitor* mon = &AMonitors[0];
|
||||
|
||||
mountedinfo mi{};
|
||||
uaedev_config_data* uci;
|
||||
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
@ -584,7 +583,7 @@ bool EditFilesysHardDrive(const int unit_no)
|
||||
|
||||
if (unit_no >= 0)
|
||||
{
|
||||
uci = &changed_prefs.mountconfig[unit_no];
|
||||
uaedev_config_data* uci = &changed_prefs.mountconfig[unit_no];
|
||||
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
|
||||
|
||||
current_hfdlg.forcedcylinders = uci->ci.highcyl;
|
||||
|
||||
@ -74,7 +74,7 @@ static gcn::TextField *txtSectors;
|
||||
static gcn::Label *lblBlocksize;
|
||||
static gcn::TextField *txtBlocksize;
|
||||
|
||||
static void sethd(void)
|
||||
static void sethd()
|
||||
{
|
||||
const bool rdb = is_hdf_rdb();
|
||||
const bool enablegeo = !rdb;
|
||||
@ -99,7 +99,7 @@ static void sethardfiletypes()
|
||||
cboHdfFeatureLevel->setSelected(current_hfdlg.ci.unit_feature_level);
|
||||
}
|
||||
|
||||
static void sethardfile(void)
|
||||
static void sethardfile()
|
||||
{
|
||||
std::string rootdir, filesys, strdevname;
|
||||
char tmp[32];
|
||||
@ -107,7 +107,7 @@ static void sethardfile(void)
|
||||
auto ide = current_hfdlg.ci.controller_type >= HD_CONTROLLER_TYPE_IDE_FIRST && current_hfdlg.ci.controller_type <= HD_CONTROLLER_TYPE_IDE_LAST;
|
||||
bool scsi = current_hfdlg.ci.controller_type >= HD_CONTROLLER_TYPE_SCSI_FIRST && current_hfdlg.ci.controller_type <= HD_CONTROLLER_TYPE_SCSI_LAST;
|
||||
auto rdb = is_hdf_rdb();
|
||||
auto disables = !rdb || (rdb && current_hfdlg.ci.controller_type == HD_CONTROLLER_TYPE_UAE);
|
||||
auto disables = !rdb || current_hfdlg.ci.controller_type == HD_CONTROLLER_TYPE_UAE;
|
||||
bool rdsk = current_hfdlg.rdb;
|
||||
|
||||
sethd();
|
||||
@ -1018,7 +1018,6 @@ bool EditFilesysHardfile(const int unit_no)
|
||||
const AmigaMonitor* mon = &AMonitors[0];
|
||||
|
||||
mountedinfo mi{};
|
||||
uaedev_config_data *uci;
|
||||
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
@ -1049,7 +1048,7 @@ bool EditFilesysHardfile(const int unit_no)
|
||||
|
||||
if (unit_no >= 0)
|
||||
{
|
||||
uci = &changed_prefs.mountconfig[unit_no];
|
||||
uaedev_config_data* uci = &changed_prefs.mountconfig[unit_no];
|
||||
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
|
||||
|
||||
current_hfdlg.forcedcylinders = uci->ci.highcyl;
|
||||
|
||||
@ -89,7 +89,7 @@ public:
|
||||
if (!tmp.empty())
|
||||
{
|
||||
txtPath->setText(tmp);
|
||||
TCHAR* s = filesys_createvolname(NULL, tmp.c_str(), NULL, _T("Harddrive"));
|
||||
TCHAR* s = filesys_createvolname(nullptr, tmp.c_str(), nullptr, _T("Harddrive"));
|
||||
txtVolume->setText(std::string(s));
|
||||
default_fsvdlg(¤t_fsvdlg);
|
||||
if (current_fsvdlg.ci.devname[0] == 0)
|
||||
@ -564,7 +564,6 @@ bool EditFilesysVirtual(const int unit_no)
|
||||
const AmigaMonitor* mon = &AMonitors[0];
|
||||
|
||||
mountedinfo mi{};
|
||||
uaedev_config_data* uci;
|
||||
std::string strdevname, strvolname;
|
||||
char tmp[32];
|
||||
|
||||
@ -575,7 +574,7 @@ bool EditFilesysVirtual(const int unit_no)
|
||||
|
||||
if (unit_no >= 0)
|
||||
{
|
||||
uci = &changed_prefs.mountconfig[unit_no];
|
||||
uaedev_config_data* uci = &changed_prefs.mountconfig[unit_no];
|
||||
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
|
||||
memcpy(¤t_fsvdlg.ci, uci, sizeof(uaedev_config_info));
|
||||
}
|
||||
|
||||
@ -193,7 +193,6 @@ static void InitEditTapeDrive()
|
||||
cboTapeDriveUnit->addActionListener(tapeDriveActionListener);
|
||||
|
||||
int posY = DISTANCE_BORDER;
|
||||
int posX = DISTANCE_BORDER;
|
||||
|
||||
wndEditTapeDrive->add(lblTapeDrivePath, DISTANCE_BORDER, posY);
|
||||
wndEditTapeDrive->add(txtTapeDrivePath, lblTapeDrivePath->getX() + lblTapeDrivePath->getWidth() + 8, posY);
|
||||
@ -507,7 +506,6 @@ bool EditTapeDrive(const int unit_no)
|
||||
const AmigaMonitor* mon = &AMonitors[0];
|
||||
|
||||
mountedinfo mi{};
|
||||
uaedev_config_data* uci;
|
||||
|
||||
dialogResult = false;
|
||||
dialogFinished = false;
|
||||
@ -528,7 +526,7 @@ bool EditTapeDrive(const int unit_no)
|
||||
|
||||
if (unit_no >= 0)
|
||||
{
|
||||
uci = &changed_prefs.mountconfig[unit_no];
|
||||
uaedev_config_data* uci = &changed_prefs.mountconfig[unit_no];
|
||||
get_filesys_unitconfig(&changed_prefs, unit_no, &mi);
|
||||
memcpy(¤t_tapedlg.ci, uci, sizeof(uaedev_config_info));
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ static gcn::StringListModel cpu_freq_list(cpu_freq_values);
|
||||
static float getcpufreq(int m)
|
||||
{
|
||||
const float f = changed_prefs.ntscmode ? 28636360.0f : 28375160.0f;
|
||||
return f * float(m >> 8) / 8.0f;
|
||||
return f * static_cast<float>(m >> 8) / 8.0f;
|
||||
}
|
||||
|
||||
class CPUActionListener : public gcn::ActionListener
|
||||
@ -283,7 +283,7 @@ public:
|
||||
if (changed_prefs.cpu_cycle_exact || changed_prefs.cpu_compatible) {
|
||||
TCHAR txt[20];
|
||||
const auto f = getcpufreq(changed_prefs.cpu_clock_multiplier);
|
||||
_stprintf(txt, _T("%.6f"), f / 1000000.0);
|
||||
_sntprintf(txt, sizeof txt, _T("%.6f"), f / 1000000.0);
|
||||
lblCPUFrequencyMHz->setCaption(txt);
|
||||
}
|
||||
else {
|
||||
@ -293,13 +293,13 @@ public:
|
||||
else if (changed_prefs.cpu_cycle_exact) {
|
||||
const auto& txt = lblCPUFrequencyMHz->getCaption();
|
||||
changed_prefs.cpu_clock_multiplier = 0;
|
||||
changed_prefs.cpu_frequency = (int)(_tstof(txt.c_str()) * 1000000.0);
|
||||
changed_prefs.cpu_frequency = static_cast<int>((_tstof(txt.c_str()) * 1000000.0));
|
||||
if (changed_prefs.cpu_frequency < 1 * 1000000)
|
||||
changed_prefs.cpu_frequency = 0;
|
||||
if (changed_prefs.cpu_frequency >= 99 * 1000000)
|
||||
changed_prefs.cpu_frequency = 0;
|
||||
if (!changed_prefs.cpu_frequency) {
|
||||
changed_prefs.cpu_frequency = (int)(getcpufreq(m) * 1000000.0);
|
||||
changed_prefs.cpu_frequency = static_cast<int>(getcpufreq(m) * 1000000.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -776,13 +776,13 @@ void RefreshPanelCPU()
|
||||
cboCPUFrequency->setSelected(idx);
|
||||
if (!changed_prefs.cpu_clock_multiplier) {
|
||||
TCHAR txt[20];
|
||||
_stprintf(txt, _T("%.6f"), changed_prefs.cpu_frequency / 1000000.0);
|
||||
_sntprintf(txt, sizeof txt, _T("%.6f"), changed_prefs.cpu_frequency / 1000000.0);
|
||||
lblCPUFrequencyMHz->setCaption(txt);
|
||||
}
|
||||
else {
|
||||
TCHAR txt[20];
|
||||
double f = getcpufreq(changed_prefs.cpu_clock_multiplier);
|
||||
_stprintf(txt, _T("%.6f"), f / 1000000.0);
|
||||
_sntprintf(txt, sizeof txt, _T("%.6f"), f / 1000000.0);
|
||||
lblCPUFrequencyMHz->setCaption(txt);
|
||||
}
|
||||
|
||||
|
||||
@ -70,9 +70,9 @@ public:
|
||||
//-----------------------------------------------
|
||||
// Save current configuration
|
||||
//-----------------------------------------------
|
||||
char filename[MAX_DPATH];
|
||||
if (!txtName->getText().empty())
|
||||
{
|
||||
char filename[MAX_DPATH];
|
||||
get_configuration_path(filename, MAX_DPATH);
|
||||
strncat(filename, txtName->getText().c_str(), MAX_DPATH - 1);
|
||||
strncat(filename, ".uae", MAX_DPATH - 1);
|
||||
@ -89,10 +89,10 @@ public:
|
||||
//-----------------------------------------------
|
||||
// Delete selected config
|
||||
//-----------------------------------------------
|
||||
char msg[256];
|
||||
i = lstConfigs->getSelected();
|
||||
if (i >= 0 && ConfigFilesList[i]->Name[0] != '\0')
|
||||
{
|
||||
char msg[256];
|
||||
(void)snprintf(msg, 256, "Do you want to delete '%s' ?", ConfigFilesList[i]->Name);
|
||||
if (ShowMessage("Delete Configuration", msg, "", "", "Yes", "No"))
|
||||
{
|
||||
@ -326,7 +326,7 @@ bool HelpPanelConfig(std::vector<std::string>& helptext)
|
||||
helptext.emplace_back("immediately using that configuration.");
|
||||
helptext.emplace_back(" ");
|
||||
helptext.emplace_back("To create/save a new configuration, set all emulator options as required, then enter");
|
||||
helptext.emplace_back("a new \"Name\", optionally provide a short description, and then click on the \"Save\"");
|
||||
helptext.emplace_back(R"(a new "Name", optionally provide a short description, and then click on the "Save")");
|
||||
helptext.emplace_back("button. When trying to Save a configuration, if the supplied filename already exists,");
|
||||
helptext.emplace_back("it will be automatically renamed to \"configuration.backup\", to keep as a backup.");
|
||||
helptext.emplace_back(" ");
|
||||
@ -334,7 +334,7 @@ bool HelpPanelConfig(std::vector<std::string>& helptext)
|
||||
helptext.emplace_back("with floppy disk images and whdload archives. The auto-config logic in Amiberry will");
|
||||
helptext.emplace_back("scan for a configuration file of the same \"Name\" as the disk image or .lha archive");
|
||||
helptext.emplace_back("being loaded. After you load a floppy disk image or whdload archive, and Start the ");
|
||||
helptext.emplace_back("emulation, you can use the \"F12\" key to show the GUI, and in this panel the \"Name\"");
|
||||
helptext.emplace_back(R"(emulation, you can use the "F12" key to show the GUI, and in this panel the "Name")");
|
||||
helptext.emplace_back("field for the configuartion will be filled correctly. Do not change this, as it will");
|
||||
helptext.emplace_back("stop auto-config from working. You may change the description if you desire.");
|
||||
helptext.emplace_back(" ");
|
||||
|
||||
@ -229,7 +229,6 @@ void InitPanelDiskSwapper(const config_category& category)
|
||||
{
|
||||
int row, column;
|
||||
auto posY = DISTANCE_BORDER / 2;
|
||||
char tmp[20];
|
||||
|
||||
diskSwapperAddActionListener = new DiskSwapperAddActionListener();
|
||||
diskSwapperDelActionListener = new DiskSwapperDelActionListener();
|
||||
@ -241,6 +240,7 @@ void InitPanelDiskSwapper(const config_category& category)
|
||||
|
||||
for (row = 0; row < MAX_SPARE_DRIVES; ++row)
|
||||
{
|
||||
char tmp[20];
|
||||
diskSwapperListEntry[row] = new gcn::Container();
|
||||
diskSwapperListEntry[row]->setSize(category.panel->getWidth() - 2 * DISTANCE_BORDER, SMALL_BUTTON_HEIGHT + 4);
|
||||
diskSwapperListEntry[row]->setBaseColor(gui_base_color);
|
||||
@ -370,7 +370,7 @@ void RefreshPanelDiskSwapper()
|
||||
const int drv = disk_in_drive(row);
|
||||
tmp[0] = 0;
|
||||
if (drv >= 0)
|
||||
_stprintf(tmp, _T("DF%d:"), drv);
|
||||
_sntprintf(tmp, sizeof tmp, _T("DF%d:"), drv);
|
||||
cmdDiskSwapperListDrive[row]->setCaption(tmp);
|
||||
}
|
||||
else
|
||||
|
||||
@ -138,7 +138,7 @@ public:
|
||||
strncpy(label, label_string.c_str(), sizeof(label) - 1);
|
||||
label[sizeof(label) - 1] = '\0';
|
||||
|
||||
struct chipset_refresh* cr;
|
||||
struct chipset_refresh* cr = nullptr;
|
||||
for (int i = 0; i < MAX_CHIPSET_REFRESH_TOTAL; i++) {
|
||||
cr = &changed_prefs.cr[i];
|
||||
if (!_tcscmp(label, cr->label) || (cr->label[0] == 0 && label[0] == ':' && _tstol(label + 1) == i)) {
|
||||
@ -177,7 +177,9 @@ public:
|
||||
// Round the rate to 6 decimal places
|
||||
rate = std::round(rate * 1e6) / 1e6;
|
||||
|
||||
cr->rate = static_cast<float>(rate);
|
||||
if (cr != nullptr) {
|
||||
cr->rate = static_cast<float>(rate);
|
||||
}
|
||||
}
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
@ -187,10 +189,13 @@ public:
|
||||
write_log("Out of range FPS argument in text box, ignoring value\n");
|
||||
}
|
||||
|
||||
TCHAR buffer[20];
|
||||
_stprintf(buffer, _T("%.6f"), cr->rate);
|
||||
txtFpsAdj->setText(std::string(buffer));
|
||||
sldFpsAdj->setValue(cr->rate);
|
||||
if (cr != nullptr)
|
||||
{
|
||||
TCHAR buffer[20];
|
||||
_sntprintf(buffer, sizeof buffer, _T("%.6f"), cr->rate);
|
||||
txtFpsAdj->setText(std::string(buffer));
|
||||
sldFpsAdj->setValue(cr->rate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,7 +209,6 @@ class AmigaScreenActionListener : public gcn::ActionListener
|
||||
public:
|
||||
void action(const gcn::ActionEvent& actionEvent) override
|
||||
{
|
||||
AmigaMonitor* mon = &AMonitors[0];
|
||||
auto source = actionEvent.getSource();
|
||||
|
||||
if (source == chkManualCrop)
|
||||
@ -275,7 +279,7 @@ public:
|
||||
strncpy(label, label_string.c_str(), sizeof(label) - 1);
|
||||
label[sizeof(label) - 1] = '\0';
|
||||
|
||||
struct chipset_refresh* cr;
|
||||
struct chipset_refresh* cr = nullptr;
|
||||
for (i = 0; i < MAX_CHIPSET_REFRESH_TOTAL; i++) {
|
||||
cr = &changed_prefs.cr[i];
|
||||
if (!_tcscmp(label, cr->label) || (cr->label[0] == 0 && label[0] == ':' && _tstol(label + 1) == i)) {
|
||||
@ -306,7 +310,7 @@ public:
|
||||
}
|
||||
if (cr->locked) {
|
||||
if (actionEvent.getSource() == sldFpsAdj) {
|
||||
i = sldFpsAdj->getValue();//xSendDlgItemMessage(hDlg, IDC_FRAMERATE2, TBM_GETPOS, 0, 0);
|
||||
i = static_cast<int>(sldFpsAdj->getValue());//xSendDlgItemMessage(hDlg, IDC_FRAMERATE2, TBM_GETPOS, 0, 0);
|
||||
if (i != static_cast<int>(cr->rate))
|
||||
cr->rate = static_cast<float>(i);
|
||||
updaterate = true;
|
||||
@ -330,7 +334,7 @@ public:
|
||||
}
|
||||
if (updaterate) {
|
||||
TCHAR buffer[20];
|
||||
_stprintf(buffer, _T("%.6f"), cr->rate);
|
||||
_sntprintf(buffer, sizeof buffer, _T("%.6f"), cr->rate);
|
||||
txtFpsAdj->setText(std::string(buffer));
|
||||
}
|
||||
if (updateslider) {
|
||||
@ -1108,12 +1112,12 @@ static void refresh_fps_options()
|
||||
if (cr->rate > 0) {
|
||||
_tcscpy(buffer, cr->label);
|
||||
if (!buffer[0])
|
||||
_stprintf(buffer, _T(":%d"), i);
|
||||
_sntprintf(buffer, sizeof buffer, _T(":%d"), i);
|
||||
fps_options.emplace_back(buffer);
|
||||
double d = changed_prefs.chipset_refreshrate;
|
||||
if (abs(d) < 1)
|
||||
d = currprefs.ntscmode ? 60.0 : 50.0;
|
||||
if (selectcr && selectcr->index == cr->index)
|
||||
if (selectcr->index == cr->index)
|
||||
changed_prefs.cr_selected = i;
|
||||
rates[i] = v;
|
||||
v++;
|
||||
@ -1125,7 +1129,7 @@ static void refresh_fps_options()
|
||||
selectcr = &changed_prefs.cr[changed_prefs.cr_selected];
|
||||
cboFpsRate->setSelected(rates[changed_prefs.cr_selected]);
|
||||
sldFpsAdj->setValue(selectcr->rate + 0.5);
|
||||
_stprintf(buffer, _T("%.6f"), selectcr->rate);
|
||||
_sntprintf(buffer, sizeof buffer, _T("%.6f"), selectcr->rate);
|
||||
txtFpsAdj->setText(std::string(buffer));
|
||||
chkFpsAdj->setSelected(selectcr->locked);
|
||||
|
||||
@ -1135,8 +1139,6 @@ static void refresh_fps_options()
|
||||
|
||||
void RefreshPanelDisplay()
|
||||
{
|
||||
AmigaMonitor* mon = &AMonitors[0];
|
||||
|
||||
chkFrameskip->setSelected(changed_prefs.gfx_framerate > 1);
|
||||
sldRefresh->setEnabled(chkFrameskip->isSelected());
|
||||
sldRefresh->setValue(changed_prefs.gfx_framerate);
|
||||
|
||||
@ -88,7 +88,7 @@ static void gui_add_string(int* table, gcn::StringListModel* item, int id, const
|
||||
*table = -1;
|
||||
item->add(str);
|
||||
}
|
||||
static void gui_set_string_cursor(int* table, gcn::DropDown* item, int id)
|
||||
static void gui_set_string_cursor(const int* table, const gcn::DropDown* item, const int id)
|
||||
{
|
||||
int idx = 0;
|
||||
while (*table >= 0) {
|
||||
@ -100,7 +100,7 @@ static void gui_set_string_cursor(int* table, gcn::DropDown* item, int id)
|
||||
table++;
|
||||
}
|
||||
}
|
||||
static int gui_get_string_cursor(int* table, gcn::DropDown* item)
|
||||
static int gui_get_string_cursor(const int* table, const gcn::DropDown* item)
|
||||
{
|
||||
int posn = item->getSelected();
|
||||
if (posn < 0)
|
||||
@ -108,18 +108,17 @@ static int gui_get_string_cursor(int* table, gcn::DropDown* item)
|
||||
return table[posn];
|
||||
}
|
||||
|
||||
static void getromfile(gcn::DropDown* d, TCHAR* path, int size)
|
||||
static void getromfile(gcn::DropDown* d, TCHAR* path, const int size)
|
||||
{
|
||||
auto val = d->getSelected();
|
||||
const auto val = d->getSelected();
|
||||
|
||||
romdata* rd;
|
||||
auto tmp1 = d->getListModel()->getElementAt(val);
|
||||
const auto tmp1 = d->getListModel()->getElementAt(val);
|
||||
path[0] = 0;
|
||||
rd = getromdatabyname(tmp1.c_str());
|
||||
const romdata* rd = getromdatabyname(tmp1.c_str());
|
||||
if (rd) {
|
||||
romlist* rl = getromlistbyromdata(rd);
|
||||
const romlist* rl = getromlistbyromdata(rd);
|
||||
if (rd->configname)
|
||||
_stprintf(path, _T(":%s"), rd->configname);
|
||||
_sntprintf(path, sizeof path, _T(":%s"), rd->configname);
|
||||
else if (rl)
|
||||
_tcsncpy(path, rl->path, size);
|
||||
}
|
||||
@ -367,10 +366,9 @@ static void get_expansionrom_gui(expansionrom_gui* eg)
|
||||
if (!eg->expansionrom_gui_ebs)
|
||||
return;
|
||||
|
||||
int val;
|
||||
int settings = eg->expansionrom_gui_settings;
|
||||
|
||||
val = eg->expansionrom_gui_itemselector->getSelected();
|
||||
int val = eg->expansionrom_gui_itemselector->getSelected();
|
||||
if (val != -1 && val != eg->expansionrom_gui_item) {
|
||||
eg->expansionrom_gui_item = val;
|
||||
create_expansionrom_gui(eg, eg->expansionrom_gui_ebs, eg->expansionrom_gui_settings, eg->expansionrom_gui_string,
|
||||
@ -405,7 +403,7 @@ static void get_expansionrom_gui(expansionrom_gui* eg)
|
||||
static struct netdriverdata* ndd[MAX_TOTAL_NET_DEVICES + 1];
|
||||
static int net_enumerated;
|
||||
|
||||
struct netdriverdata** target_ethernet_enumerate(void)
|
||||
struct netdriverdata** target_ethernet_enumerate()
|
||||
{
|
||||
if (net_enumerated)
|
||||
return ndd;
|
||||
@ -428,7 +426,6 @@ static void init_expansion2(bool init)
|
||||
for (;;)
|
||||
{
|
||||
bool matched = false;
|
||||
int* idtab;
|
||||
int total = 0;
|
||||
scsirom_select_list.clear();
|
||||
scsiromselect_table[0] = -1;
|
||||
@ -436,7 +433,7 @@ static void init_expansion2(bool init)
|
||||
{
|
||||
total++;
|
||||
}
|
||||
idtab = xcalloc(int, total * 2);
|
||||
int* idtab = xcalloc(int, total * 2);
|
||||
int idcnt = 0;
|
||||
for (int i = 0; expansionroms[i].name; i++) {
|
||||
if (expansionroms[i].romtype & ROMTYPE_CPUBOARD)
|
||||
@ -477,7 +474,7 @@ static void init_expansion2(bool init)
|
||||
if (cnt == 1)
|
||||
_tcscat(name, _T("* "));
|
||||
else if (cnt > 1)
|
||||
_stprintf(name + _tcslen(name), _T("[%d] "), cnt);
|
||||
_sntprintf(name + _tcslen(name), sizeof name, _T("[%d] "), cnt);
|
||||
_tcscat(name, expansionroms[id].friendlyname);
|
||||
_tcscat(cname, expansionroms[id].friendlyname);
|
||||
if (expansionroms[id].friendlymanufacturer) {
|
||||
@ -545,7 +542,7 @@ static void init_expansion2(bool init)
|
||||
if (brc && ert && ert->id_jumper) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
TCHAR tmp[10];
|
||||
_stprintf(tmp, _T("%d"), i);
|
||||
_sntprintf(tmp, sizeof tmp, _T("%d"), i);
|
||||
scsi_romid_list.add(tmp);
|
||||
}
|
||||
}
|
||||
@ -587,7 +584,7 @@ static void values_to_expansion2dlg_sub()
|
||||
}
|
||||
for (int i = 0; i < MAX_AVAILABLE_DUPLICATE_EXPANSION_BOARDS; i++) {
|
||||
TCHAR tmp[10];
|
||||
_stprintf(tmp, _T("%d"), i + 1);
|
||||
_sntprintf(tmp, sizeof tmp, _T("%d"), i + 1);
|
||||
scsirom_selectnum_list.add(tmp);
|
||||
}
|
||||
cboScsiRomSelectNum->setSelected(scsiromselectednum);
|
||||
@ -677,10 +674,9 @@ static void values_to_expansion2_expansion_roms(UAEREG* fkey)
|
||||
{
|
||||
int index;
|
||||
bool keyallocated = false;
|
||||
boardromconfig* brc;
|
||||
|
||||
if (!fkey) {
|
||||
fkey = regcreatetree(NULL, _T("DetectedROMs"));
|
||||
fkey = regcreatetree(nullptr, _T("DetectedROMs"));
|
||||
keyallocated = true;
|
||||
}
|
||||
if (scsiromselected) {
|
||||
@ -689,7 +685,7 @@ static void values_to_expansion2_expansion_roms(UAEREG* fkey)
|
||||
int romtype_extra = static_cast<int>(ert->romtype_extra);
|
||||
int deviceflags = ert->deviceflags;
|
||||
|
||||
brc = get_device_rom(&changed_prefs, romtype, scsiromselectednum, &index);
|
||||
boardromconfig* brc = get_device_rom(&changed_prefs, romtype, scsiromselectednum, &index);
|
||||
if (brc && ert->subtypes) {
|
||||
const expansionsubromtype* esrt = &ert->subtypes[brc->roms[index].subtype];
|
||||
if (esrt->romtype) {
|
||||
@ -751,10 +747,10 @@ static void values_to_expansion2_expansion_roms(UAEREG* fkey)
|
||||
static void values_to_expansion2_expansion_settings()
|
||||
{
|
||||
int index;
|
||||
boardromconfig* brc;
|
||||
if (scsiromselected) {
|
||||
const expansionromtype* ert = &expansionroms[scsiromselected];
|
||||
brc = get_device_rom(&changed_prefs, static_cast<int>(expansionroms[scsiromselected].romtype), scsiromselectednum, &index);
|
||||
boardromconfig* brc = get_device_rom(&changed_prefs, static_cast<int>(expansionroms[scsiromselected].romtype),
|
||||
scsiromselectednum, &index);
|
||||
if (brc) {
|
||||
if (brc->roms[index].romfile[0])
|
||||
chkScsiRomFileAutoboot->setEnabled(ert->autoboot_jumper);
|
||||
@ -843,7 +839,6 @@ static void expansion2dlgproc()
|
||||
static void values_to_expansion2dlg()
|
||||
{
|
||||
int index;
|
||||
boardromconfig* brc;
|
||||
|
||||
chkBSDSocket->setSelected(changed_prefs.socket_emu);
|
||||
chkScsi->setSelected(changed_prefs.scsi == 1);
|
||||
@ -852,15 +847,15 @@ static void values_to_expansion2dlg()
|
||||
// We don't really need Catweasel support in Amiberry, let's disable it
|
||||
changed_prefs.catweasel = 0;
|
||||
|
||||
UAEREG* fkey = regcreatetree(NULL, _T("DetectedROMs"));
|
||||
load_keyring(&changed_prefs, NULL);
|
||||
UAEREG* fkey = regcreatetree(nullptr, _T("DetectedROMs"));
|
||||
load_keyring(&changed_prefs, nullptr);
|
||||
|
||||
values_to_expansion2_expansion_roms(fkey);
|
||||
values_to_expansion2_expansion_settings();
|
||||
|
||||
if (changed_prefs.cpuboard_type) {
|
||||
const cpuboardsubtype* cst = &cpuboards[changed_prefs.cpuboard_type].subtypes[changed_prefs.cpuboard_subtype];
|
||||
brc = get_device_rom(&changed_prefs, ROMTYPE_CPUBOARD, 0, &index);
|
||||
boardromconfig* brc = get_device_rom(&changed_prefs, ROMTYPE_CPUBOARD, 0, &index);
|
||||
addromfiles(fkey, cboCpuBoardRomFile, brc ? brc->roms[index].romfile : nullptr,
|
||||
static_cast<int>(cst->romtype), cst->romtype_extra);
|
||||
}
|
||||
@ -891,8 +886,9 @@ public:
|
||||
int val = gui_get_string_cursor(scsiromselect_table, cboScsiRomFile);
|
||||
if (val != -1) {
|
||||
int index;
|
||||
struct boardromconfig* brc;
|
||||
brc = get_device_rom_new(&changed_prefs, static_cast<int>(expansionroms[scsiromselected].romtype), scsiromselectednum, &index);
|
||||
struct boardromconfig* brc = get_device_rom_new(&changed_prefs,
|
||||
static_cast<int>(expansionroms[scsiromselected].romtype),
|
||||
scsiromselectednum, &index);
|
||||
_tcscpy(brc->roms[index].romfile, full_path.c_str());
|
||||
fullpath(brc->roms[index].romfile, MAX_DPATH);
|
||||
}
|
||||
@ -967,7 +963,7 @@ public:
|
||||
else if (source == cboScsiRomSubSelect)
|
||||
{
|
||||
values_from_expansion2dlg();
|
||||
values_to_expansion2_expansion_roms(NULL);
|
||||
values_to_expansion2_expansion_roms(nullptr);
|
||||
values_to_expansion2_expansion_settings();
|
||||
}
|
||||
else if (source == cboScsiRomSelectCat)
|
||||
@ -978,7 +974,7 @@ public:
|
||||
scsiromselectedcatnum = val;
|
||||
scsiromselected = 0;
|
||||
init_expansion2(false);
|
||||
values_to_expansion2_expansion_roms(NULL);
|
||||
values_to_expansion2_expansion_roms(nullptr);
|
||||
values_to_expansion2_expansion_settings();
|
||||
values_to_expansion2dlg_sub();
|
||||
}
|
||||
@ -993,7 +989,7 @@ public:
|
||||
if (val != -1)
|
||||
{
|
||||
scsiromselected = val;
|
||||
values_to_expansion2_expansion_roms(NULL);
|
||||
values_to_expansion2_expansion_roms(nullptr);
|
||||
values_to_expansion2_expansion_settings();
|
||||
values_to_expansion2dlg_sub();
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
if (dfxtype == DRV_FB)
|
||||
{
|
||||
TCHAR tmp[32];
|
||||
_stprintf(tmp, _T("%d:%s"), selectedType - 5, drivebridgeModes[selectedType - 6].data());
|
||||
_sntprintf(tmp, sizeof tmp, _T("%d:%s"), selectedType - 5, drivebridgeModes[selectedType - 6].data());
|
||||
_tcscpy(changed_prefs.floppyslots[i].dfxsubtypeid, tmp);
|
||||
}
|
||||
else
|
||||
@ -334,10 +334,10 @@ public:
|
||||
if (actionEvent.getSource() == cmdCreateDDDisk)
|
||||
{
|
||||
// Create 3.5" DD Disk
|
||||
char diskname[MAX_DPATH];
|
||||
tmp = SelectFile("Create 3.5\" DD disk file", current_dir, diskfile_filter, true);
|
||||
if (!tmp.empty())
|
||||
{
|
||||
char diskname[MAX_DPATH];
|
||||
extract_filename(tmp.c_str(), diskname);
|
||||
remove_file_extension(diskname);
|
||||
diskname[31] = '\0';
|
||||
@ -352,10 +352,10 @@ public:
|
||||
else if (actionEvent.getSource() == cmdCreateHDDisk)
|
||||
{
|
||||
// Create 3.5" HD Disk
|
||||
char diskname[MAX_DPATH];
|
||||
tmp = SelectFile("Create 3.5\" HD disk file", current_dir, diskfile_filter, true);
|
||||
if (!tmp.empty())
|
||||
{
|
||||
char diskname[MAX_DPATH];
|
||||
extract_filename(tmp.c_str(), diskname);
|
||||
remove_file_extension(diskname);
|
||||
diskname[31] = '\0';
|
||||
|
||||
@ -63,7 +63,7 @@ static gcn::Button* cmdCDEject;
|
||||
static gcn::Button* cmdCDSelectFile;
|
||||
static gcn::CheckBox* chkCDTurbo;
|
||||
|
||||
static void harddisktype(TCHAR* s, struct uaedev_config_info* ci)
|
||||
static void harddisktype(TCHAR* s, const struct uaedev_config_info* ci)
|
||||
{
|
||||
switch (ci->type)
|
||||
{
|
||||
@ -366,7 +366,6 @@ void InitPanelHD(const config_category& category)
|
||||
{
|
||||
int row, col;
|
||||
auto posY = DISTANCE_BORDER / 2;
|
||||
std::string id_string;
|
||||
|
||||
RefreshCDListModel();
|
||||
|
||||
@ -390,7 +389,7 @@ void InitPanelHD(const config_category& category)
|
||||
listCmdProps[row]->setBaseColor(gui_base_color);
|
||||
listCmdProps[row]->setForegroundColor(gui_foreground_color);
|
||||
listCmdProps[row]->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
|
||||
id_string = "cmdProp" + to_string(row);
|
||||
std::string id_string = "cmdProp" + to_string(row);
|
||||
listCmdProps[row]->setId(id_string);
|
||||
listCmdProps[row]->addActionListener(hdEditActionListener);
|
||||
|
||||
@ -605,26 +604,23 @@ static void AdjustDropDownControls()
|
||||
|
||||
void RefreshPanelHD()
|
||||
{
|
||||
char tmp[32];
|
||||
TCHAR size_str[32];
|
||||
TCHAR blocksize_str[32];
|
||||
TCHAR devname_str[256];
|
||||
TCHAR volname_str[256];
|
||||
TCHAR bootpri_str[32];
|
||||
|
||||
AdjustDropDownControls();
|
||||
|
||||
for (auto row = 0; row < MAX_HD_DEVICES; ++row)
|
||||
{
|
||||
if (row < changed_prefs.mountitems)
|
||||
{
|
||||
TCHAR bootpri_str[32];
|
||||
TCHAR volname_str[256];
|
||||
TCHAR devname_str[256];
|
||||
TCHAR size_str[32];
|
||||
TCHAR blocksize_str[32];
|
||||
auto* uci = &changed_prefs.mountconfig[row];
|
||||
auto* const ci = &uci->ci;
|
||||
int nosize = 0, type, ctype;
|
||||
struct mountedinfo mi;
|
||||
TCHAR* rootdir, * rootdirp;
|
||||
int nosize = 0;
|
||||
struct mountedinfo mi{};
|
||||
|
||||
type = get_filesys_unitconfig(&changed_prefs, row, &mi);
|
||||
int type = get_filesys_unitconfig(&changed_prefs, row, &mi);
|
||||
if (type < 0)
|
||||
{
|
||||
type = ci->type == UAEDEV_HDF || ci->type == UAEDEV_CD || ci->type == UAEDEV_TAPE ? FILESYS_HARDFILE : FILESYS_VIRTUAL;
|
||||
@ -632,8 +628,8 @@ void RefreshPanelHD()
|
||||
}
|
||||
if (mi.size < 0)
|
||||
nosize = 1;
|
||||
rootdir = my_strdup(mi.rootdir);
|
||||
rootdirp = rootdir;
|
||||
TCHAR* rootdir = my_strdup(mi.rootdir);
|
||||
TCHAR* rootdirp = rootdir;
|
||||
if (!_tcsncmp(rootdirp, _T("HD_"), 3))
|
||||
rootdirp += 3;
|
||||
if (rootdirp[0] == ':') {
|
||||
@ -646,28 +642,28 @@ void RefreshPanelHD()
|
||||
if (nosize)
|
||||
_tcscpy(size_str, _T("n/a"));
|
||||
else if (mi.size >= 1024 * 1024 * 1024)
|
||||
_stprintf(size_str, _T("%.1fG"), ((double)(uae_u32)(mi.size / (1024 * 1024))) / 1024.0);
|
||||
_sntprintf(size_str, sizeof size_str, _T("%.1fG"), static_cast<double>(static_cast<uae_u32>(mi.size / (1024 * 1024))) / 1024.0);
|
||||
else if (mi.size < 10 * 1024 * 1024)
|
||||
_stprintf(size_str, _T("%lldK"), mi.size / 1024);
|
||||
_sntprintf(size_str, sizeof size_str, _T("%lldK"), mi.size / 1024);
|
||||
else
|
||||
_stprintf(size_str, _T("%.1fM"), ((double)(uae_u32)(mi.size / (1024))) / 1024.0);
|
||||
_sntprintf(size_str, sizeof size_str, _T("%.1fM"), static_cast<double>(static_cast<uae_u32>(mi.size / (1024))) / 1024.0);
|
||||
|
||||
ctype = ci->controller_type;
|
||||
int ctype = ci->controller_type;
|
||||
if (ctype >= HD_CONTROLLER_TYPE_IDE_FIRST && ctype <= HD_CONTROLLER_TYPE_IDE_LAST) {
|
||||
const struct expansionromtype* ert = get_unit_expansion_rom(ctype);
|
||||
const TCHAR* idedevs[] = {
|
||||
_T("IDE:%d"),
|
||||
_T("A600/A1200/A4000:%d"),
|
||||
};
|
||||
_stprintf(blocksize_str, _T("%d"), ci->blocksize);
|
||||
_sntprintf(blocksize_str, sizeof blocksize_str, _T("%d"), ci->blocksize);
|
||||
if (ert) {
|
||||
if (ci->controller_type_unit == 0)
|
||||
_stprintf(devname_str, _T("%s:%d"), ert->friendlyname, ci->controller_unit);
|
||||
_sntprintf(devname_str, sizeof devname_str, _T("%s:%d"), ert->friendlyname, ci->controller_unit);
|
||||
else
|
||||
_stprintf(devname_str, _T("%s:%d/%d"), ert->friendlyname, ci->controller_unit, ci->controller_type_unit + 1);
|
||||
_sntprintf(devname_str, sizeof devname_str, _T("%s:%d/%d"), ert->friendlyname, ci->controller_unit, ci->controller_type_unit + 1);
|
||||
}
|
||||
else {
|
||||
_stprintf(devname_str, idedevs[ctype - HD_CONTROLLER_TYPE_IDE_FIRST], ci->controller_unit);
|
||||
_sntprintf(devname_str, sizeof devname_str, idedevs[ctype - HD_CONTROLLER_TYPE_IDE_FIRST], ci->controller_unit);
|
||||
}
|
||||
harddisktype(volname_str, ci);
|
||||
_tcscpy(bootpri_str, _T("n/a"));
|
||||
@ -686,16 +682,16 @@ void RefreshPanelHD()
|
||||
else if (ci->controller_unit == 8 && ert && !_tcscmp(ert->name, _T("a2090a")))
|
||||
_tcscpy(sid, _T("ST-506"));
|
||||
else
|
||||
_stprintf(sid, _T("%d"), ci->controller_unit);
|
||||
_stprintf(blocksize_str, _T("%d"), ci->blocksize);
|
||||
_sntprintf(sid, sizeof sid, _T("%d"), ci->controller_unit);
|
||||
_sntprintf(blocksize_str, sizeof blocksize_str, _T("%d"), ci->blocksize);
|
||||
if (ert) {
|
||||
if (ci->controller_type_unit == 0)
|
||||
_stprintf(devname_str, _T("%s:%s"), ert->friendlyname, sid);
|
||||
_sntprintf(devname_str, sizeof devname_str, _T("%s:%s"), ert->friendlyname, sid);
|
||||
else
|
||||
_stprintf(devname_str, _T("%s:%s/%d"), ert->friendlyname, sid, ci->controller_type_unit + 1);
|
||||
_sntprintf(devname_str, sizeof devname_str, _T("%s:%s/%d"), ert->friendlyname, sid, ci->controller_type_unit + 1);
|
||||
}
|
||||
else {
|
||||
_stprintf(devname_str, scsidevs[ctype - HD_CONTROLLER_TYPE_SCSI_FIRST], sid);
|
||||
_sntprintf(devname_str, sizeof devname_str, scsidevs[ctype - HD_CONTROLLER_TYPE_SCSI_FIRST], sid);
|
||||
}
|
||||
harddisktype(volname_str, ci);
|
||||
_tcscpy(bootpri_str, _T("n/a"));
|
||||
@ -703,33 +699,33 @@ void RefreshPanelHD()
|
||||
else if (ctype >= HD_CONTROLLER_TYPE_CUSTOM_FIRST && ctype <= HD_CONTROLLER_TYPE_CUSTOM_LAST) {
|
||||
TCHAR sid[8];
|
||||
const struct expansionromtype* ert = get_unit_expansion_rom(ctype);
|
||||
_stprintf(sid, _T("%d"), ci->controller_unit);
|
||||
_sntprintf(sid, sizeof sid, _T("%d"), ci->controller_unit);
|
||||
if (ert) {
|
||||
if (ci->controller_type_unit == 0)
|
||||
_stprintf(devname_str, _T("%s:%s"), ert->friendlyname, sid);
|
||||
_sntprintf(devname_str, sizeof devname_str, _T("%s:%s"), ert->friendlyname, sid);
|
||||
else
|
||||
_stprintf(devname_str, _T("%s:%s/%d"), ert->friendlyname, sid, ci->controller_type_unit + 1);
|
||||
_sntprintf(devname_str, sizeof devname_str, _T("%s:%s/%d"), ert->friendlyname, sid, ci->controller_type_unit + 1);
|
||||
}
|
||||
else {
|
||||
_stprintf(devname_str, _T("PCMCIA"));
|
||||
_sntprintf(devname_str, sizeof devname_str, _T("PCMCIA"));
|
||||
}
|
||||
harddisktype(volname_str, ci);
|
||||
_tcscpy(bootpri_str, _T("n/a"));
|
||||
}
|
||||
else if (type == FILESYS_HARDFILE) {
|
||||
_stprintf(blocksize_str, _T("%d"), ci->blocksize);
|
||||
_sntprintf(blocksize_str, sizeof blocksize_str, _T("%d"), ci->blocksize);
|
||||
_tcscpy(devname_str, ci->devname);
|
||||
_tcscpy(volname_str, _T("n/a"));
|
||||
_stprintf(bootpri_str, _T("%d"), ci->bootpri);
|
||||
_sntprintf(bootpri_str, sizeof bootpri_str, _T("%d"), ci->bootpri);
|
||||
}
|
||||
else if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE || ci->controller_type != HD_CONTROLLER_TYPE_UAE) {
|
||||
_stprintf(blocksize_str, _T("%d"), ci->blocksize);
|
||||
_stprintf(devname_str, _T("UAE:%d"), ci->controller_unit);
|
||||
_sntprintf(blocksize_str, sizeof blocksize_str, _T("%d"), ci->blocksize);
|
||||
_sntprintf(devname_str, sizeof devname_str, _T("UAE:%d"), ci->controller_unit);
|
||||
_tcscpy(volname_str, _T("n/a"));
|
||||
_tcscpy(bootpri_str, _T("n/a"));
|
||||
}
|
||||
else if (type == FILESYS_TAPE) {
|
||||
_stprintf(blocksize_str, _T("%d"), ci->blocksize);
|
||||
_sntprintf(blocksize_str, sizeof blocksize_str, _T("%d"), ci->blocksize);
|
||||
_tcscpy(devname_str, _T("UAE"));
|
||||
harddisktype(volname_str, ci);
|
||||
_tcscpy(bootpri_str, _T("n/a"));
|
||||
@ -739,7 +735,7 @@ void RefreshPanelHD()
|
||||
_tcscpy(devname_str, ci->devname);
|
||||
_tcscpy(volname_str, ci->volname);
|
||||
_tcscpy(size_str, _T("n/a"));
|
||||
_stprintf(bootpri_str, _T("%d"), ci->bootpri);
|
||||
_sntprintf(bootpri_str, sizeof bootpri_str, _T("%d"), ci->bootpri);
|
||||
}
|
||||
if (!mi.ismedia) {
|
||||
_tcscpy(blocksize_str, _T("n/a"));
|
||||
@ -784,7 +780,7 @@ void RefreshPanelHD()
|
||||
}
|
||||
}
|
||||
|
||||
int count_HDs(uae_prefs* p)
|
||||
int count_HDs(const uae_prefs* p)
|
||||
{
|
||||
return p->mountitems;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ void RefreshPanelHWInfo()
|
||||
if (!aci && highest_expamem <= Z3BASE_UAE)
|
||||
break;
|
||||
if (aci && aci->zorro >= 1 && aci->zorro <= 3)
|
||||
_stprintf(tmp, _T("Z%d"), aci->zorro);
|
||||
_sntprintf(tmp, sizeof tmp, _T("Z%d"), aci->zorro);
|
||||
else
|
||||
_tcscpy(tmp, _T("-"));
|
||||
|
||||
@ -84,25 +84,25 @@ void RefreshPanelHWInfo()
|
||||
if (aci)
|
||||
{
|
||||
if (aci->start != 0xffffffff)
|
||||
_stprintf(tmp, _T("0x%08x"), aci->start);
|
||||
_sntprintf(tmp, sizeof tmp, _T("0x%08x"), aci->start);
|
||||
else
|
||||
_tcscpy(tmp, _T("-"));
|
||||
listCells[row][COL_START]->setText(tmp);
|
||||
|
||||
if (aci->size != 0)
|
||||
_stprintf(tmp, _T("0x%08x"), aci->start + aci->size - 1);
|
||||
_sntprintf(tmp, sizeof tmp, _T("0x%08x"), aci->start + aci->size - 1);
|
||||
else
|
||||
_tcscpy(tmp, _T("-"));
|
||||
listCells[row][COL_END]->setText(tmp);
|
||||
|
||||
if (aci->size != 0)
|
||||
_stprintf(tmp, _T("0x%08x"), aci->size);
|
||||
_sntprintf(tmp, sizeof tmp, _T("0x%08x"), aci->size);
|
||||
else
|
||||
_tcscpy(tmp, _T("-"));
|
||||
listCells[row][COL_SIZE]->setText(tmp);
|
||||
|
||||
if (aci->autoconfig_bytes[0] != 0xff)
|
||||
_stprintf(tmp, _T("0x%04x/0x%02x"),
|
||||
_sntprintf(tmp, sizeof tmp, _T("0x%04x/0x%02x"),
|
||||
(aci->autoconfig_bytes[4] << 8) | aci->autoconfig_bytes[5], aci->autoconfig_bytes[1]);
|
||||
else
|
||||
_tcscpy(tmp, _T("-"));
|
||||
@ -110,7 +110,7 @@ void RefreshPanelHWInfo()
|
||||
}
|
||||
else
|
||||
{
|
||||
_stprintf(tmp, _T("0x%08x"), highest_expamem);
|
||||
_sntprintf(tmp, sizeof tmp, _T("0x%08x"), highest_expamem);
|
||||
listCells[row][COL_START]->setText(tmp);
|
||||
listCells[row][COL_END]->setText("");
|
||||
listCells[row][COL_SIZE]->setText("");
|
||||
|
||||
@ -64,7 +64,7 @@ public:
|
||||
else
|
||||
{
|
||||
const auto port_name = serial_ports_list.getElementAt(selected);
|
||||
if (port_name.find(SERIAL_INTERNAL) != std::string::npos)
|
||||
if (port_name.find(SERIAL_INTERNAL) != std::string::npos)
|
||||
{
|
||||
_sntprintf(changed_prefs.sername, 256, "%s", SERIAL_INTERNAL);
|
||||
}
|
||||
@ -151,7 +151,7 @@ void InitPanelIO(const config_category& category)
|
||||
for (int card = 0; card < MAX_SOUND_DEVICES && record_devices[card]; card++) {
|
||||
int type = record_devices[card]->type;
|
||||
TCHAR tmp[MAX_DPATH];
|
||||
_stprintf(tmp, _T("%s: %s"),
|
||||
_sntprintf(tmp, sizeof tmp, _T("%s: %s"),
|
||||
type == SOUND_DEVICE_SDL2 ? _T("SDL2") : type == SOUND_DEVICE_DS ? _T("DSOUND") : type == SOUND_DEVICE_AL ? _T("OpenAL") : type == SOUND_DEVICE_PA ? _T("PortAudio") : _T("WASAPI"),
|
||||
record_devices[card]->name);
|
||||
if (type == SOUND_DEVICE_SDL2)
|
||||
@ -175,6 +175,7 @@ void InitPanelIO(const config_category& category)
|
||||
case 2:
|
||||
tmp += " [Slave]";
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
serial_ports_list.add(tmp);
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ static amigamodels amodels[] = {
|
||||
{-1}
|
||||
};
|
||||
|
||||
static const int numModels = 13;
|
||||
static constexpr int numModels = 13;
|
||||
static int numModelConfigs = 0;
|
||||
static bool bIgnoreListChange = true;
|
||||
|
||||
@ -588,7 +588,7 @@ public:
|
||||
if (dfxtype == DRV_FB)
|
||||
{
|
||||
TCHAR tmp[32];
|
||||
_stprintf(tmp, _T("%d:%s"), selectedType - 5, drivebridgeModes[selectedType - 6].data());
|
||||
_sntprintf(tmp, sizeof tmp, _T("%d:%s"), selectedType - 5, drivebridgeModes[selectedType - 6].data());
|
||||
_tcscpy(changed_prefs.floppyslots[i].dfxsubtypeid, tmp);
|
||||
}
|
||||
else
|
||||
@ -683,7 +683,6 @@ static QSDiskActionListener* qs_diskActionListener;
|
||||
|
||||
void InitPanelQuickstart(const config_category& category)
|
||||
{
|
||||
int posX;
|
||||
int posY = DISTANCE_BORDER;
|
||||
|
||||
amigaModelList.clear();
|
||||
@ -884,7 +883,7 @@ void InitPanelQuickstart(const config_category& category)
|
||||
|
||||
for (auto i = 0; i < 2; ++i)
|
||||
{
|
||||
posX = DISTANCE_BORDER;
|
||||
int posX = DISTANCE_BORDER;
|
||||
category.panel->add(chkqsDFx[i], posX, posY);
|
||||
posX += chkqsDFx[i]->getWidth() + DISTANCE_NEXT_X;
|
||||
category.panel->add(cboqsDFxType[i], posX, posY);
|
||||
|
||||
@ -92,7 +92,7 @@ static MemorySliderActionListener* memorySliderActionListener;
|
||||
void InitPanelRAM(const config_category& category)
|
||||
{
|
||||
memorySliderActionListener = new MemorySliderActionListener();
|
||||
const int sld_width = 150;
|
||||
constexpr int sld_width = 150;
|
||||
int marker_length = 20;
|
||||
|
||||
lblChipmem = new gcn::Label("Chip:");
|
||||
|
||||
@ -58,15 +58,14 @@ static void getromfile(gcn::DropDown* d, TCHAR* path, int size)
|
||||
d->setSelected(val);
|
||||
}
|
||||
else {
|
||||
struct romdata* rd;
|
||||
auto listmodel = d->getListModel();
|
||||
std::string tmp1 = listmodel->getElementAt(val);
|
||||
path[0] = 0;
|
||||
rd = getromdatabyname(tmp1.c_str());
|
||||
struct romdata* rd = getromdatabyname(tmp1.c_str());
|
||||
if (rd) {
|
||||
struct romlist* rl = getromlistbyromdata(rd);
|
||||
if (rd->configname)
|
||||
_stprintf(path, _T(":%s"), rd->configname);
|
||||
_sntprintf(path, sizeof path, _T(":%s"), rd->configname);
|
||||
else if (rl)
|
||||
_tcsncpy(path, rl->path, size);
|
||||
}
|
||||
@ -267,9 +266,9 @@ void ExitPanelROM()
|
||||
|
||||
void RefreshPanelROM()
|
||||
{
|
||||
UAEREG* fkey = regcreatetree(NULL, _T("DetectedROMs"));
|
||||
UAEREG* fkey = regcreatetree(nullptr, _T("DetectedROMs"));
|
||||
|
||||
load_keyring(&changed_prefs, NULL);
|
||||
load_keyring(&changed_prefs, nullptr);
|
||||
|
||||
addromfiles(fkey, cboMainROM, changed_prefs.romfile,
|
||||
ROMTYPE_KICK | ROMTYPE_KICKCD32, 0);
|
||||
|
||||
@ -57,7 +57,6 @@ class RTGActionListener : public gcn::ActionListener
|
||||
public:
|
||||
void action(const gcn::ActionEvent& action_event) override
|
||||
{
|
||||
int v;
|
||||
uae_u32 mask = changed_prefs.picasso96_modeflags;
|
||||
|
||||
if (action_event.getSource() == cboBoard)
|
||||
@ -125,7 +124,7 @@ public:
|
||||
|
||||
mask &= ~RGBFF_CLUT;
|
||||
mask |= RGBFF_CLUT;
|
||||
v = cboRtg16bitModes->getSelected();
|
||||
int v = cboRtg16bitModes->getSelected();
|
||||
mask &= ~(RGBFF_R5G6B5PC | RGBFF_R5G5B5PC | RGBFF_R5G6B5 | RGBFF_R5G5B5 | RGBFF_B5G6R5PC | RGBFF_B5G5R5PC);
|
||||
if (v == 1)
|
||||
mask |= RGBFF_R5G6B5PC | RGBFF_R5G5B5PC | RGBFF_R5G6B5 | RGBFF_R5G5B5 | RGBFF_B5G6R5PC | RGBFF_B5G5R5PC;
|
||||
@ -155,7 +154,7 @@ public:
|
||||
if (v == 5)
|
||||
mask |= RGBFF_B8G8R8A8;
|
||||
|
||||
changed_prefs.picasso96_modeflags = int(mask);
|
||||
changed_prefs.picasso96_modeflags = static_cast<int>(mask);
|
||||
|
||||
RefreshPanelRTG();
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ static std::string get_file_timestamp(const TCHAR* filename)
|
||||
localtime_r(&st.st_mtime, &tm);
|
||||
char date_string[256];
|
||||
strftime(date_string, sizeof(date_string), "%c", &tm);
|
||||
return std::string(date_string);
|
||||
return {date_string};
|
||||
}
|
||||
|
||||
class SavestateActionListener : public gcn::ActionListener
|
||||
@ -50,7 +50,7 @@ public:
|
||||
const auto it = std::find(radioButtons.begin(), radioButtons.end(), actionEvent.getSource());
|
||||
if (it != radioButtons.end())
|
||||
{
|
||||
current_state_num = std::distance(radioButtons.begin(), it);
|
||||
current_state_num = static_cast<int>(std::distance(radioButtons.begin(), it));
|
||||
}
|
||||
else if (actionEvent.getSource() == cmdLoadState)
|
||||
{
|
||||
@ -102,7 +102,7 @@ public:
|
||||
//------------------------------------------
|
||||
// Save current state
|
||||
//------------------------------------------
|
||||
if (emulating && (!unsafe || unsafe && unsafe_confirmed))
|
||||
if (emulating && (!unsafe || unsafe_confirmed))
|
||||
{
|
||||
savestate_initsave(savestate_fname, 1, true, true);
|
||||
save_state(savestate_fname, "...");
|
||||
|
||||
@ -63,7 +63,7 @@ static gcn::DropDown* cboSwapChannels;
|
||||
static int curr_separation_idx;
|
||||
static int curr_stereodelay_idx;
|
||||
static int numdevs;
|
||||
static const int sndbufsizes[] = { 1024, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 32768, 65536, -1 };
|
||||
static constexpr int sndbufsizes[] = { 1024, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 32768, 65536, -1 };
|
||||
|
||||
static gcn::StringListModel soundcard_list;
|
||||
|
||||
@ -302,7 +302,7 @@ void InitPanelSound(const config_category& category)
|
||||
for (int card = 0; card < numdevs; card++) {
|
||||
TCHAR tmp[MAX_DPATH];
|
||||
int type = sound_devices[card]->type;
|
||||
_stprintf(tmp, _T("%s: %s"),
|
||||
_sntprintf(tmp, sizeof tmp, _T("%s: %s"),
|
||||
type == SOUND_DEVICE_SDL2 ? _T("SDL2") : (type == SOUND_DEVICE_DS ? _T("DSOUND") : (type == SOUND_DEVICE_AL ? _T("OpenAL") : (type == SOUND_DEVICE_PA ? _T("PortAudio") : (type == SOUND_DEVICE_WASAPI ? _T("WASAPI") : _T("WASAPI EX"))))),
|
||||
sound_devices[card]->name);
|
||||
soundcard_list.add(tmp);
|
||||
|
||||
@ -83,33 +83,33 @@ class ThemesActionListener : public gcn::ActionListener
|
||||
gui_theme.font_name = font;
|
||||
}
|
||||
}
|
||||
else if (source == cmdThemeReset)
|
||||
{
|
||||
load_default_theme();
|
||||
}
|
||||
else if (source == cmdThemeSave)
|
||||
{
|
||||
gui_theme.font_size = std::stoi(txtThemeFontSize->getText());
|
||||
save_theme(amiberry_options.gui_theme);
|
||||
}
|
||||
else if (source == cmdThemeSaveAs)
|
||||
{
|
||||
gui_theme.font_size = std::stoi(txtThemeFontSize->getText());
|
||||
else if (source == cmdThemeReset)
|
||||
{
|
||||
load_default_theme();
|
||||
}
|
||||
else if (source == cmdThemeSave)
|
||||
{
|
||||
gui_theme.font_size = std::stoi(txtThemeFontSize->getText());
|
||||
save_theme(amiberry_options.gui_theme);
|
||||
}
|
||||
else if (source == cmdThemeSaveAs)
|
||||
{
|
||||
gui_theme.font_size = std::stoi(txtThemeFontSize->getText());
|
||||
const char* filter[] = { ".theme", "\0" };
|
||||
const std::string theme = SelectFile("Save theme", get_themes_path(), filter, true);
|
||||
if (!theme.empty())
|
||||
{
|
||||
std::string filename = extract_filename(theme);
|
||||
save_theme(filename);
|
||||
if (!theme.empty())
|
||||
{
|
||||
std::string filename = extract_filename(theme);
|
||||
save_theme(filename);
|
||||
populate_themes_list();
|
||||
}
|
||||
}
|
||||
else if (source == cmdThemeUse)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (source == cmdThemeUse)
|
||||
{
|
||||
gui_theme.font_size = std::stoi(txtThemeFontSize->getText());
|
||||
apply_theme();
|
||||
apply_theme();
|
||||
apply_theme_extras();
|
||||
}
|
||||
}
|
||||
else if (source == cboThemePreset)
|
||||
{
|
||||
const auto selected_theme = cboThemePreset->getSelected();
|
||||
@ -117,19 +117,19 @@ class ThemesActionListener : public gcn::ActionListener
|
||||
{
|
||||
const auto theme = themes_list.getElementAt(selected_theme);
|
||||
|
||||
if (std::strcmp(theme.c_str(), amiberry_options.gui_theme) != 0)
|
||||
if (std::strcmp(theme.c_str(), amiberry_options.gui_theme) != 0)
|
||||
{
|
||||
std::strcpy(amiberry_options.gui_theme, theme.c_str());
|
||||
std::strcpy(amiberry_options.gui_theme, theme.c_str());
|
||||
load_theme(theme);
|
||||
apply_theme();
|
||||
apply_theme_extras();
|
||||
apply_theme();
|
||||
apply_theme_extras();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleSliderAction(source);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleSliderAction(source);
|
||||
}
|
||||
|
||||
RefreshPanelThemes();
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ class EnumListModel : public gcn::ListModel
|
||||
private:
|
||||
std::vector<std::pair<T,std::string>> m_values{};
|
||||
public:
|
||||
explicit EnumListModel(const std::vector<std::pair<T,std::string>> values)
|
||||
explicit EnumListModel(const std::vector<std::pair<T,std::string>>& values)
|
||||
: m_values(values)
|
||||
{
|
||||
}
|
||||
@ -103,11 +103,11 @@ public:
|
||||
return m_values.size();
|
||||
}
|
||||
|
||||
void add(const std::string& elem)
|
||||
void add(const std::string& elem) override
|
||||
{
|
||||
}
|
||||
|
||||
void clear()
|
||||
void clear() override
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
|
||||
int getNumberOfElements() override
|
||||
{
|
||||
return dirs.size() + files.size();
|
||||
return static_cast<int>(dirs.size() + files.size());
|
||||
}
|
||||
|
||||
void add(const std::string& elem) override
|
||||
@ -88,7 +88,7 @@ public:
|
||||
FilterFiles(&files, filefilter);
|
||||
}
|
||||
|
||||
bool isDir(unsigned int i) const
|
||||
[[nodiscard]] bool isDir(unsigned int i) const
|
||||
{
|
||||
return (i < dirs.size());
|
||||
}
|
||||
|
||||
@ -53,12 +53,12 @@ public:
|
||||
return static_cast<int>(dirs.size());
|
||||
}
|
||||
|
||||
void add(const std::string& elem)
|
||||
void add(const std::string& elem) override
|
||||
{
|
||||
dirs.push_back(elem);
|
||||
}
|
||||
|
||||
void clear()
|
||||
void clear() override
|
||||
{
|
||||
dirs.clear();
|
||||
}
|
||||
@ -82,11 +82,11 @@ static SelectDirListModel dirList(".");
|
||||
|
||||
static void checkfoldername(const std::string& current)
|
||||
{
|
||||
char actualpath [MAX_DPATH];
|
||||
DIR* dir;
|
||||
|
||||
if ((dir = opendir(current.c_str())))
|
||||
{
|
||||
char actualpath [MAX_DPATH];
|
||||
dirList = current;
|
||||
auto* const ptr = realpath(current.c_str(), actualpath);
|
||||
workingDir = std::string(ptr);
|
||||
|
||||
@ -29,7 +29,7 @@ namespace gcn
|
||||
void setInactiveColor(Color color);
|
||||
void setActiveColor(Color color);
|
||||
void setActive(bool active);
|
||||
bool getActive() const;
|
||||
[[nodiscard]] bool getActive() const;
|
||||
|
||||
void widgetResized(const Event& event) override;
|
||||
|
||||
|
||||
@ -106,7 +106,6 @@ static ShowCustomFieldsActionListener* showCustomFieldsActionListener;
|
||||
|
||||
void create_custom_field(custom_widget& widget, const int number, const std::string& caption, const whdload_custom& custom_field, int& pos_y, const int custom_list_index)
|
||||
{
|
||||
constexpr int textfield_width = 300;
|
||||
constexpr int pos_x1 = DISTANCE_BORDER;
|
||||
|
||||
for (int i = 0; i < number; i++) {
|
||||
@ -149,6 +148,7 @@ void create_custom_field(custom_widget& widget, const int number, const std::str
|
||||
break;
|
||||
}
|
||||
case list_type: {
|
||||
constexpr int textfield_width = 300;
|
||||
label->setCaption(custom_field.caption);
|
||||
label->adjustSize();
|
||||
pos_x2 = textfield_width + 15;
|
||||
|
||||
@ -336,7 +336,7 @@ void RefreshPanelThemes();
|
||||
bool HelpPanelThemes(std::vector<std::string>& helptext);
|
||||
|
||||
void refresh_all_panels();
|
||||
void focus_bug_workaround(gcn::Window* wnd);
|
||||
void focus_bug_workaround(const gcn::Window* wnd);
|
||||
void disable_resume();
|
||||
|
||||
bool ShowMessage(const std::string& title, const std::string& line1, const std::string& line2, const std::string& line3,
|
||||
|
||||
@ -212,7 +212,7 @@ void gui_restart()
|
||||
gui_running = false;
|
||||
}
|
||||
|
||||
void focus_bug_workaround(gcn::Window* wnd)
|
||||
void focus_bug_workaround(const gcn::Window* wnd)
|
||||
{
|
||||
// When modal dialog opens via mouse, the dialog will not
|
||||
// have the focus unless there is a mouse click. We simulate the click...
|
||||
@ -247,7 +247,7 @@ void cap_fps(Uint64 start)
|
||||
const auto elapsed_ms = static_cast<float>(end - start) / static_cast<float>(SDL_GetPerformanceFrequency()) * 1000.0f;
|
||||
|
||||
const int refresh_rate = std::clamp(sdl_mode.refresh_rate, 50, 60);
|
||||
const float frame_time = 1000.0f / refresh_rate;
|
||||
const float frame_time = 1000.0f / static_cast<float>(refresh_rate);
|
||||
const float delay_time = frame_time - elapsed_ms;
|
||||
|
||||
if (delay_time > 0.0f)
|
||||
@ -303,8 +303,8 @@ void amiberry_gui_init()
|
||||
{
|
||||
write_log("Creating Amiberry GUI window...\n");
|
||||
Uint32 mode;
|
||||
if (!kmsdrm_detected)
|
||||
{
|
||||
if (!kmsdrm_detected)
|
||||
{
|
||||
// Only enable Windowed mode if we're running under x11
|
||||
mode = SDL_WINDOW_RESIZABLE;
|
||||
}
|
||||
@ -743,8 +743,8 @@ void check_input()
|
||||
touch_event.button.button = SDL_BUTTON_LEFT;
|
||||
touch_event.button.state = SDL_PRESSED;
|
||||
|
||||
touch_event.button.x = gui_graphics->getTarget()->w * int(gui_event.tfinger.x);
|
||||
touch_event.button.y = gui_graphics->getTarget()->h * int(gui_event.tfinger.y);
|
||||
touch_event.button.x = gui_graphics->getTarget()->w * static_cast<int>(gui_event.tfinger.x);
|
||||
touch_event.button.y = gui_graphics->getTarget()->h * static_cast<int>(gui_event.tfinger.y);
|
||||
|
||||
gui_input->pushInput(touch_event);
|
||||
break;
|
||||
@ -757,8 +757,8 @@ void check_input()
|
||||
touch_event.button.button = SDL_BUTTON_LEFT;
|
||||
touch_event.button.state = SDL_RELEASED;
|
||||
|
||||
touch_event.button.x = gui_graphics->getTarget()->w * int(gui_event.tfinger.x);
|
||||
touch_event.button.y = gui_graphics->getTarget()->h * int(gui_event.tfinger.y);
|
||||
touch_event.button.x = gui_graphics->getTarget()->w * static_cast<int>(gui_event.tfinger.x);
|
||||
touch_event.button.y = gui_graphics->getTarget()->h * static_cast<int>(gui_event.tfinger.y);
|
||||
|
||||
gui_input->pushInput(touch_event);
|
||||
break;
|
||||
@ -770,8 +770,8 @@ void check_input()
|
||||
touch_event.motion.which = 0;
|
||||
touch_event.motion.state = 0;
|
||||
|
||||
touch_event.motion.x = gui_graphics->getTarget()->w * int(gui_event.tfinger.x);
|
||||
touch_event.motion.y = gui_graphics->getTarget()->h * int(gui_event.tfinger.y);
|
||||
touch_event.motion.x = gui_graphics->getTarget()->w * static_cast<int>(gui_event.tfinger.x);
|
||||
touch_event.motion.y = gui_graphics->getTarget()->h * static_cast<int>(gui_event.tfinger.y);
|
||||
|
||||
gui_input->pushInput(touch_event);
|
||||
break;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "sysdeps.h"
|
||||
#include "options.h"
|
||||
@ -328,11 +328,11 @@ void setcapslockstate(int state)
|
||||
capslockstate = state;
|
||||
}
|
||||
|
||||
int getcapslock(void)
|
||||
int getcapslock()
|
||||
{
|
||||
int capstable[7];
|
||||
|
||||
// this returns bogus state if caps change when in exclusive mode..
|
||||
// this returns bogus state if caps change when in exclusive mode...
|
||||
host_capslockstate = SDL_GetModState() & KMOD_CAPS;
|
||||
host_numlockstate = SDL_GetModState() & KMOD_NUM;
|
||||
host_scrolllockstate = 0; //SDL_GetModState() & ;
|
||||
@ -352,7 +352,7 @@ void clearallkeys()
|
||||
inputdevice_updateconfig(&changed_prefs, &currprefs);
|
||||
}
|
||||
|
||||
static const int np[] = {
|
||||
static constexpr int np[] = {
|
||||
SDL_SCANCODE_KP_0, 0, SDL_SCANCODE_KP_PERIOD, 0, SDL_SCANCODE_KP_1, 1, SDL_SCANCODE_KP_2, 2,
|
||||
SDL_SCANCODE_KP_3, 3, SDL_SCANCODE_KP_4, 4, SDL_SCANCODE_KP_5, 5, SDL_SCANCODE_KP_6, 6, SDL_SCANCODE_KP_7, 7,
|
||||
SDL_SCANCODE_KP_8, 8, SDL_SCANCODE_KP_9, 9, -1 };
|
||||
@ -483,8 +483,7 @@ bool my_kbd_handler(int keyboard, int scancode, int newstate, bool alwaysrelease
|
||||
swapperdrive = 0;
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (!_tcscmp(currprefs.floppyslots[i].df, currprefs.dfxlist[num]))
|
||||
changed_prefs.floppyslots[i].df[0] = 0;
|
||||
}
|
||||
@ -518,11 +517,12 @@ bool my_kbd_handler(int keyboard, int scancode, int newstate, bool alwaysrelease
|
||||
special = true;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
if (code) {
|
||||
inputdevice_add_inputcode(code, 1, NULL);
|
||||
inputdevice_add_inputcode(code, 1, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ bool my_kbd_handler(int keyboard, int scancode, int newstate, bool alwaysrelease
|
||||
return inputdevice_translatekeycode(keyboard, scancode, newstate, alwaysrelease) != 0;
|
||||
}
|
||||
|
||||
void keyboard_settrans(void)
|
||||
void keyboard_settrans()
|
||||
{
|
||||
inputdevice_setkeytranslation(keytrans, kbmaps);
|
||||
}
|
||||
|
||||
@ -59,14 +59,14 @@ msg_buffer_t *in_buf;
|
||||
|
||||
static msg_buffer_t *buffer_init(int size)
|
||||
{
|
||||
msg_buffer_t *buf = (msg_buffer_t *)malloc(sizeof(msg_buffer_t));
|
||||
if(buf == NULL) {
|
||||
return NULL;
|
||||
const auto buf = static_cast<msg_buffer_t*>(malloc(sizeof(msg_buffer_t)));
|
||||
if(buf == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
buf->buffer = (PmMessage *)malloc(sizeof(PmMessage) * size);
|
||||
if(buf->buffer == NULL) {
|
||||
buf->buffer = static_cast<PmMessage*>(malloc(sizeof(PmMessage) * size));
|
||||
if(buf->buffer == nullptr) {
|
||||
free(buf);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
buf->sem = nullptr;
|
||||
uae_sem_init(&buf->sem, 0, 1);
|
||||
@ -96,10 +96,10 @@ static int buffer_add_msg(msg_buffer_t *buf, PmMessage msg)
|
||||
return overflow;
|
||||
}
|
||||
|
||||
static int buffer_has_msg(msg_buffer_t *buf)
|
||||
static int buffer_has_msg(const msg_buffer_t *buf)
|
||||
{
|
||||
uae_sem_wait(&buf->sem);
|
||||
int res = buf->rd_off != buf->wr_off;
|
||||
const int res = buf->rd_off != buf->wr_off;
|
||||
uae_sem_post(&buf->sem);
|
||||
return res;
|
||||
}
|
||||
@ -120,12 +120,11 @@ static int buffer_get_msg(msg_buffer_t *buf, PmMessage *msg)
|
||||
// timer callback
|
||||
static void timer_callback(PtTimestamp timestamp, void *userData)
|
||||
{
|
||||
if(timer_active && (in != NULL)) {
|
||||
if(timer_active && (in != nullptr)) {
|
||||
// read incoming midi command
|
||||
if(Pm_Poll(in) == TRUE) {
|
||||
PmEvent ev;
|
||||
int err;
|
||||
err = Pm_Read(in, &ev, 1);
|
||||
const int err = Pm_Read(in, &ev, 1);
|
||||
if(err == 1) {
|
||||
TRACE((_T("<- midi_in: %08x\n"),ev.message));
|
||||
// add to in queue
|
||||
@ -140,7 +139,7 @@ static void timer_callback(PtTimestamp timestamp, void *userData)
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_config(uae_prefs *cfg)
|
||||
static void parse_config(const uae_prefs *cfg)
|
||||
{
|
||||
// set defaults
|
||||
in_dev_id = Pm_GetDefaultInputDeviceID();
|
||||
@ -169,16 +168,15 @@ static void parse_config(uae_prefs *cfg)
|
||||
|
||||
}
|
||||
|
||||
static PortMidiStream *open_out_stream(void)
|
||||
static PortMidiStream *open_out_stream()
|
||||
{
|
||||
PortMidiStream *out;
|
||||
PmError err;
|
||||
|
||||
if(out_dev_id == pmNoDevice) {
|
||||
write_log(_T("MIDI OUT: ERROR: no device found!\n"));
|
||||
} else {
|
||||
err = Pm_OpenOutput(&out, out_dev_id, NULL, OUT_QUEUE_SIZE,
|
||||
NULL, NULL, 0);
|
||||
const PmError err = Pm_OpenOutput(&out, out_dev_id, nullptr, OUT_QUEUE_SIZE,
|
||||
nullptr, nullptr, 0);
|
||||
if(err != pmNoError) {
|
||||
write_log(_T("MIDI OUT: ERROR: can't open device #%d! code=%d\n"),
|
||||
out_dev_id, err);
|
||||
@ -187,19 +185,18 @@ static PortMidiStream *open_out_stream(void)
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static PortMidiStream *open_in_stream(void)
|
||||
static PortMidiStream *open_in_stream()
|
||||
{
|
||||
PortMidiStream *in;
|
||||
PmError err;
|
||||
|
||||
if(in_dev_id == pmNoDevice) {
|
||||
write_log(_T("MIDI IN: ERROR: no device found!\n"));
|
||||
} else {
|
||||
err = Pm_OpenInput(&in, in_dev_id, NULL, IN_QUEUE_SIZE,
|
||||
NULL, NULL);
|
||||
const PmError err = Pm_OpenInput(&in, in_dev_id, nullptr, IN_QUEUE_SIZE,
|
||||
nullptr, nullptr);
|
||||
if(err != pmNoError) {
|
||||
write_log(_T("MIDI IN: ERROR: can't open device #%d! code=%d\n"),
|
||||
in_dev_id, err);
|
||||
@ -208,15 +205,15 @@ static PortMidiStream *open_in_stream(void)
|
||||
return in;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static int midi_open_with_config(uae_prefs *cfg)
|
||||
static int midi_open_with_config(const uae_prefs *cfg)
|
||||
{
|
||||
write_log(_T("midi_open()\n"));
|
||||
|
||||
// setup timer
|
||||
PtError err = Pt_Start(1, timer_callback, NULL);
|
||||
PtError err = Pt_Start(1, timer_callback, nullptr);
|
||||
if(err != ptNoError) {
|
||||
write_log(_T("MIDI: ERROR: no timer!\n"));
|
||||
return 0;
|
||||
@ -224,7 +221,7 @@ static int midi_open_with_config(uae_prefs *cfg)
|
||||
|
||||
// setup input buffer
|
||||
in_buf = buffer_init(MY_IN_QUEUE_SIZE);
|
||||
if(in_buf == NULL) {
|
||||
if(in_buf == nullptr) {
|
||||
write_log(_T("MIDI: ERROR: no buffer!\n"));
|
||||
return 0;
|
||||
}
|
||||
@ -241,7 +238,7 @@ static int midi_open_with_config(uae_prefs *cfg)
|
||||
timer_active = 1;
|
||||
|
||||
// ok if any direction was opened
|
||||
if((out != NULL) || (in != NULL)) {
|
||||
if((out != nullptr) || (in != nullptr)) {
|
||||
write_log(_T("midi_open(): ok\n"));
|
||||
return 1;
|
||||
} else {
|
||||
@ -250,12 +247,12 @@ static int midi_open_with_config(uae_prefs *cfg)
|
||||
}
|
||||
}
|
||||
|
||||
int midi_open(void)
|
||||
int midi_open()
|
||||
{
|
||||
return midi_open_with_config(&currprefs);
|
||||
}
|
||||
|
||||
void midi_close(void)
|
||||
void midi_close()
|
||||
{
|
||||
write_log(_T("midi_close()\n"));
|
||||
|
||||
@ -264,21 +261,21 @@ void midi_close(void)
|
||||
Pt_Stop();
|
||||
|
||||
// close output
|
||||
if(out != NULL) {
|
||||
if(out != nullptr) {
|
||||
Pm_Close(out);
|
||||
out = NULL;
|
||||
out = nullptr;
|
||||
}
|
||||
// close input
|
||||
if(in != NULL) {
|
||||
if(in != nullptr) {
|
||||
Pm_Close(in);
|
||||
in = NULL;
|
||||
in = nullptr;
|
||||
}
|
||||
|
||||
Pm_Terminate();
|
||||
|
||||
// free input buffer
|
||||
buffer_free(in_buf);
|
||||
in_buf = NULL;
|
||||
in_buf = nullptr;
|
||||
|
||||
write_log(_T("midi_close(): done\n"));
|
||||
}
|
||||
@ -323,7 +320,7 @@ static void out_add_sysex_byte(uint8_t data)
|
||||
}
|
||||
}
|
||||
|
||||
static void out_flush_sysex(void)
|
||||
static void out_flush_sysex()
|
||||
{
|
||||
if(out_sysex_bits != 0) {
|
||||
write_msg(out_sysex_msg);
|
||||
@ -415,7 +412,7 @@ static int in_msg_bits;
|
||||
|
||||
static int in_sysex_mode;
|
||||
|
||||
int midi_has_byte(void)
|
||||
int midi_has_byte()
|
||||
{
|
||||
// still have to send parameter bytes
|
||||
if(in_msg_bytes > 0) {
|
||||
@ -468,7 +465,7 @@ int midi_recv_byte(uint8_t *ch)
|
||||
int res = 0;
|
||||
// sitll have to send parameter bytes
|
||||
if(in_msg_bytes > 0) {
|
||||
*ch = (uint8_t)(in_msg >> in_msg_bits);
|
||||
*ch = static_cast<uint8_t>(in_msg >> in_msg_bits);
|
||||
in_msg_bits += 8;
|
||||
in_msg_bytes--;
|
||||
res = 1;
|
||||
@ -516,17 +513,17 @@ int midi_recv_byte(uint8_t *ch)
|
||||
// The Midi_Parse function has not been tested yet, so this might not work
|
||||
// correctly.
|
||||
|
||||
int Midi_Open(void)
|
||||
int Midi_Open()
|
||||
{
|
||||
return midi_open();
|
||||
}
|
||||
|
||||
void Midi_Close(void)
|
||||
void Midi_Close()
|
||||
{
|
||||
midi_close();
|
||||
}
|
||||
|
||||
void Midi_Reopen(void)
|
||||
void Midi_Reopen()
|
||||
{
|
||||
if (midi_ready) {
|
||||
Midi_Close();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "sysdeps.h"
|
||||
|
||||
@ -30,12 +30,10 @@ static int mp3_samplesperframe[] = {
|
||||
};
|
||||
|
||||
mp3decoder::~mp3decoder()
|
||||
{
|
||||
}
|
||||
= default;
|
||||
|
||||
mp3decoder::mp3decoder()
|
||||
{
|
||||
}
|
||||
= default;
|
||||
|
||||
uae_u8* mp3decoder::get(struct zfile* zf, uae_u8* outbuf, int maxsize)
|
||||
{
|
||||
@ -70,7 +68,7 @@ uae_u8* mp3decoder::get(struct zfile* zf, uae_u8* outbuf, int maxsize)
|
||||
if (mpg123_open_feed(mh) == MPG123_OK)
|
||||
{
|
||||
zfile_fseek(zf, 0, SEEK_SET);
|
||||
for (; outoffset < maxsize;)
|
||||
while (outoffset < maxsize)
|
||||
{
|
||||
size_t count = zfile_fread(mp3buf, 1, MP3_BLOCK_SIZE, zf);
|
||||
if (count != MP3_BLOCK_SIZE)
|
||||
@ -171,9 +169,9 @@ uae_u32 mp3decoder::getsize(struct zfile* zf)
|
||||
uae_u8* data = p + 10;
|
||||
data[size] = 0;
|
||||
if (data[0] == 0)
|
||||
timelen = atol((char*)(data + 1));
|
||||
timelen = atol(reinterpret_cast<char*>(data + 1));
|
||||
else
|
||||
timelen = _tstol((char*)(data + 1));
|
||||
timelen = _tstol(reinterpret_cast<char*>(data + 1));
|
||||
}
|
||||
}
|
||||
size += 10;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
#pragma once
|
||||
class mp3decoder
|
||||
{
|
||||
void *g_mp3stream;
|
||||
void *g_mp3stream{};
|
||||
public:
|
||||
mp3decoder();
|
||||
~mp3decoder();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user