[Scummvm-git-logs] scummvm master -> 01a2d2edab760f5902423c5b08fbb80188d5d3cc
mikrosk
noreply at scummvm.org
Sat Feb 24 02:55:23 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fda1ce1672 BACKENDS: ATARI: Change dma playback to interrupt-driven
f41a678ba1 GRAPHICS: ATARI: Utilize dlmalloc
01a2d2edab BACKENDS: ATARI: Call original keyboard/mouse routines
Commit: fda1ce167253e0284a783c724e713eb23c633b1b
https://github.com/scummvm/scummvm/commit/fda1ce167253e0284a783c724e713eb23c633b1b
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2024-02-24T03:54:54+01:00
Commit Message:
BACKENDS: ATARI: Change dma playback to interrupt-driven
This not only decreases the amount of XBIOS calls but also avoids
repeating the sample buffer in case of a heavier CPU load.
Also clean up the mixer code.
Changed paths:
backends/mixer/atari/atari-mixer.cpp
backends/mixer/atari/atari-mixer.h
diff --git a/backends/mixer/atari/atari-mixer.cpp b/backends/mixer/atari/atari-mixer.cpp
index c6f86aa5647..7647e5acbb7 100644
--- a/backends/mixer/atari/atari-mixer.cpp
+++ b/backends/mixer/atari/atari-mixer.cpp
@@ -37,26 +37,44 @@
#define DEFAULT_SAMPLES 2048 // 83ms
void AtariAudioShutdown() {
+ Jdisint(MFP_TIMERA);
AtariSoundSetupDeinitXbios();
}
+static volatile bool muted;
+static volatile bool endOfPlayback;
+static void __attribute__((interrupt)) timerA(void)
+{
+ if (endOfPlayback && !muted) {
+ *((volatile unsigned char *)0xFFFF8901L) &= 0xFC; // disable playback/repeat (and triggers another interrupt)
+ muted = true;
+ }
+
+ endOfPlayback = true;
+
+ *((volatile byte *)0xFFFFFA0FL) &= ~(1<<5); // clear in service bit
+}
+
AtariMixerManager::AtariMixerManager() : MixerManager() {
debug("AtariMixerManager()");
- _audioSuspended = true;
+ suspendAudio();
ConfMan.registerDefault("output_rate", DEFAULT_OUTPUT_RATE);
-
_outputRate = ConfMan.getInt("output_rate");
if (_outputRate <= 0)
_outputRate = DEFAULT_OUTPUT_RATE;
ConfMan.registerDefault("output_channels", DEFAULT_OUTPUT_CHANNELS);
-
_outputChannels = ConfMan.getInt("output_channels");
if (_outputChannels <= 0 || _outputChannels > 2)
_outputChannels = DEFAULT_OUTPUT_CHANNELS;
+ ConfMan.registerDefault("audio_buffer_size", DEFAULT_SAMPLES);
+ _samples = ConfMan.getInt("audio_buffer_size");
+ if (_samples <= 0)
+ _samples = DEFAULT_SAMPLES;
+
g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false);
}
@@ -71,6 +89,7 @@ AtariMixerManager::~AtariMixerManager() {
_atariSampleBuffer = _atariPhysicalSampleBuffer = _atariLogicalSampleBuffer = nullptr;
delete[] _samplesBuf;
+ _samplesBuf = nullptr;
}
void AtariMixerManager::init() {
@@ -79,7 +98,7 @@ void AtariMixerManager::init() {
desired.frequency = _outputRate;
desired.channels = _outputChannels;
desired.format = AudioFormatSigned16MSB;
- desired.samples = DEFAULT_SAMPLES;
+ desired.samples = _samples;
if (!AtariSoundSetupInitXbios(&desired, &obtained)) {
error("Sound system is not available");
@@ -89,67 +108,57 @@ void AtariMixerManager::init() {
error("Sound system currently supports only 8/16-bit signed big endian samples");
}
+ // don't use the recommended number of samples
+ obtained.samples = desired.samples;
+ obtained.size = obtained.size * desired.samples / obtained.samples;
+
_outputRate = obtained.frequency;
_outputChannels = obtained.channels;
+ _samples = obtained.samples;
+ _downsample = (obtained.format == AudioFormatSigned8);
ConfMan.setInt("output_rate", _outputRate);
ConfMan.setInt("output_channels", _outputChannels);
+ ConfMan.setInt("audio_buffer_size", _samples);
debug("setting %d Hz mixing frequency (%d-bit, %s)",
_outputRate, obtained.format == AudioFormatSigned8 ? 8 : 16, _outputChannels == 1 ? "mono" : "stereo");
-
- _samples = 8192;
- while (_samples * 16 > _outputRate * 2)
- _samples >>= 1;
-
- ConfMan.registerDefault("audio_buffer_size", (int)_samples);
-
- int samples = ConfMan.getInt("audio_buffer_size");
- if (samples > 0)
- _samples = samples;
-
- ConfMan.setInt("audio_buffer_size", (int)_samples);
debug("sample buffer size: %d", _samples);
ConfMan.flushToDisk();
- size_t atariSampleBufferSize = _samples * _outputChannels * 2; // 16-bit by default
- if (obtained.format == AudioFormatSigned8) {
- atariSampleBufferSize /= 2;
- _downsample = true;
- }
-
- _atariSampleBuffer = (byte*)Mxalloc(atariSampleBufferSize * 2, MX_STRAM);
+ _atariSampleBuffer = (byte*)Mxalloc(obtained.size * 2, MX_STRAM);
if (!_atariSampleBuffer)
error("Failed to allocate memory in ST RAM");
_atariPhysicalSampleBuffer = _atariSampleBuffer;
- _atariLogicalSampleBuffer = _atariSampleBuffer + atariSampleBufferSize;
+ _atariLogicalSampleBuffer = _atariSampleBuffer + obtained.size;
- Setbuffer(SR_PLAY, _atariSampleBuffer, _atariSampleBuffer + 2 * atariSampleBufferSize);
+ Setinterrupt(SI_TIMERA, SI_PLAY);
+ Xbtimer(XB_TIMERA, 1<<3, 1, timerA); // event count mode, count to '1'
+ Jenabint(MFP_TIMERA);
_samplesBuf = new uint8[_samples * _outputChannels * 2]; // always 16-bit
_mixer = new Audio::MixerImpl(_outputRate, _outputChannels == 2, _samples);
_mixer->setReady(true);
- _audioSuspended = false;
+ resumeAudio();
}
void AtariMixerManager::suspendAudio() {
debug("suspendAudio");
- stopPlayback(kPlaybackStopped);
-
+ Buffoper(0x00);
+ muted = true;
_audioSuspended = true;
}
int AtariMixerManager::resumeAudio() {
debug("resumeAudio");
- update();
-
_audioSuspended = false;
+ update();
return 0;
}
@@ -157,8 +166,11 @@ bool AtariMixerManager::notifyEvent(const Common::Event &event) {
switch (event.type) {
case Common::EVENT_QUIT:
case Common::EVENT_RETURN_TO_LAUNCHER:
- stopPlayback(kPlaybackStopped);
- debug("silencing the mixer");
+ if (!muted) {
+ Buffoper(0x00);
+ muted = true;
+ debug("silencing the mixer");
+ }
return false;
default:
break;
@@ -167,18 +179,6 @@ bool AtariMixerManager::notifyEvent(const Common::Event &event) {
return false;
}
-void AtariMixerManager::startPlayback(PlaybackState playbackState) {
- Buffoper(SB_PLA_ENA | SB_PLA_RPT);
- _playbackState = playbackState;
- debug("playback started");
-}
-
-void AtariMixerManager::stopPlayback(PlaybackState playbackState) {
- Buffoper(0x00);
- _playbackState = playbackState;
- debug("playback stopped");
-}
-
void AtariMixerManager::update() {
if (_audioSuspended) {
return;
@@ -186,119 +186,67 @@ void AtariMixerManager::update() {
assert(_mixer);
- int processed = 0;
- if (_playbackState == kPlaybackStopped) {
- // playback stopped means that we are not playing anything (DMA
- // pointer is not updating) but the mixer may have something available
+ int processed = -1;
+
+ if (muted || endOfPlayback) {
+ endOfPlayback = false;
processed = _mixer->mixCallback(_samplesBuf, _samples * _outputChannels * 2);
+ }
- if (processed > 0) {
- if (_downsample) {
- // use the trick with move.b (a7)+,dx which skips two bytes at once
- // basically supplying move.w (src)+,dx; asr.w #8,dx; move.b dx,(dst)+
- __asm__ volatile(
- " move.l %%a7,%%d0\n"
- " move.l %0,%%a7\n"
- " moveq #0x0f,%%d1\n"
- " and.l %2,%%d1\n"
- " neg.l %%d1\n"
- " lsr.l #4,%2\n"
- " jmp (2f,%%pc,%%d1.l*2)\n"
- "1: move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- "2: dbra %2,1b\n"
- " move.l %%d0,%%a7\n"
- : // outputs
- : "g"(_samplesBuf), "a"(_atariPhysicalSampleBuffer), "d"(processed * _outputChannels * 2/2) // inputs
- : "d0", "d1", "cc" AND_MEMORY
+ if (processed > 0) {
+ byte* tmp = _atariPhysicalSampleBuffer;
+ _atariPhysicalSampleBuffer = _atariLogicalSampleBuffer;
+ _atariLogicalSampleBuffer = tmp;
+
+ if (_downsample) {
+ // use the trick with move.b (a7)+,dx which skips two bytes at once
+ // basically supplying move.w (src)+,dx; asr.w #8,dx; move.b dx,(dst)+
+ __asm__ volatile(
+ " move.l %%a7,%%d0\n"
+ " move.l %0,%%a7\n"
+ " moveq #0x0f,%%d1\n"
+ " and.l %2,%%d1\n"
+ " neg.l %%d1\n"
+ " lsr.l #4,%2\n"
+ " jmp (2f,%%pc,%%d1.l*2)\n"
+ "1: move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ " move.b (%%a7)+,(%1)+\n"
+ "2: dbra %2,1b\n"
+ " move.l %%d0,%%a7\n"
+ : // outputs
+ : "g"(_samplesBuf), "a"(_atariPhysicalSampleBuffer), "d"(processed * _outputChannels * 2/2) // inputs
+ : "d0", "d1", "cc" AND_MEMORY
);
- memset(_atariPhysicalSampleBuffer + processed * _outputChannels * 2/2, 0, (_samples - processed) * _outputChannels * 2/2);
- } else {
- memcpy(_atariPhysicalSampleBuffer, _samplesBuf, processed * _outputChannels * 2);
- memset(_atariPhysicalSampleBuffer + processed * _outputChannels * 2, 0, (_samples - processed) * _outputChannels * 2);
- }
- startPlayback(kPlayingFromPhysicalBuffer);
- }
- } else {
- SndBufPtr sPtr;
- if (Buffptr(&sPtr) != 0) {
- warning("Buffptr() failed");
- return;
- }
-
- byte *buf = nullptr;
-
- if (_playbackState == kPlayingFromPhysicalBuffer) {
- if ((byte*)sPtr.play < _atariLogicalSampleBuffer) {
- buf = _atariLogicalSampleBuffer;
- _playbackState = kPlayingFromLogicalBuffer;
- }
- } else if (_playbackState == kPlayingFromLogicalBuffer) {
- if ((byte*)sPtr.play >= _atariLogicalSampleBuffer) {
- buf = _atariPhysicalSampleBuffer;
- _playbackState = kPlayingFromPhysicalBuffer;
- }
+ memset(_atariPhysicalSampleBuffer + processed * _outputChannels * 2/2, 0, (_samples - processed) * _outputChannels * 2/2);
+ Setbuffer(SR_PLAY, _atariPhysicalSampleBuffer, _atariPhysicalSampleBuffer + _samples * _outputChannels * 2/2);
+ } else {
+ memcpy(_atariPhysicalSampleBuffer, _samplesBuf, processed * _outputChannels * 2);
+ memset(_atariPhysicalSampleBuffer + processed * _outputChannels * 2, 0, (_samples - processed) * _outputChannels * 2);
+ Setbuffer(SR_PLAY, _atariPhysicalSampleBuffer, _atariPhysicalSampleBuffer + _samples * _outputChannels * 2);
}
- if (buf) {
- processed = _mixer->mixCallback(_samplesBuf, _samples * _outputChannels * 2);
- if (processed > 0) {
- if (_downsample) {
- // use the trick with move.b (a7)+,dx which skips two bytes at once
- // basically supplying move.w (src)+,dx; asr.w #8,dx; move.b dx,(dst)+
- __asm__ volatile(
- " move.l %%a7,%%d0\n"
- " move.l %0,%%a7\n"
- " moveq #0x0f,%%d1\n"
- " and.l %2,%%d1\n"
- " neg.l %%d1\n"
- " lsr.l #4,%2\n"
- " jmp (2f,%%pc,%%d1.l*2)\n"
- "1: move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- " move.b (%%a7)+,(%1)+\n"
- "2: dbra %2,1b\n"
- " move.l %%d0,%%a7\n"
- : // outputs
- : "g"(_samplesBuf), "a"(buf), "d"(processed * _outputChannels * 2/2) // inputs
- : "d0", "d1", "cc" AND_MEMORY
- );
- memset(buf + processed * _outputChannels * 2/2, 0, (_samples - processed) * _outputChannels * 2/2);
- } else {
- memcpy(buf, _samplesBuf, processed * _outputChannels * 2);
- memset(buf + processed* _outputChannels * 2, 0, (_samples - processed) * _outputChannels * 2);
- }
- } else {
- stopPlayback(kPlaybackStopped);
- }
+ if (muted) {
+ Buffoper(SB_PLA_ENA | SB_PLA_RPT);
+ endOfPlayback = true;
+ muted = false;
}
+ } else if (processed == 0 && !muted) {
+ Buffoper(0x00);
+ muted = true;
}
if (processed > 0 && processed != _samples) {
diff --git a/backends/mixer/atari/atari-mixer.h b/backends/mixer/atari/atari-mixer.h
index 146a5600e7f..3957759137c 100644
--- a/backends/mixer/atari/atari-mixer.h
+++ b/backends/mixer/atari/atari-mixer.h
@@ -43,15 +43,6 @@ public:
bool notifyEvent(const Common::Event &event) override;
private:
- enum PlaybackState {
- kPlaybackStopped,
- kPlayingFromPhysicalBuffer,
- kPlayingFromLogicalBuffer
- };
-
- void startPlayback(PlaybackState playbackState);
- void stopPlayback(PlaybackState playbackState);
-
int _outputRate = 0;
int _outputChannels = 0;
int _samples = 0;
@@ -61,8 +52,6 @@ private:
byte *_atariPhysicalSampleBuffer = nullptr;
byte *_atariLogicalSampleBuffer = nullptr;
bool _downsample = false;
-
- PlaybackState _playbackState = kPlaybackStopped;
};
#endif
Commit: f41a678ba165d35cf3030c8cacb96e9ee40eb0d1
https://github.com/scummvm/scummvm/commit/f41a678ba165d35cf3030c8cacb96e9ee40eb0d1
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2024-02-24T03:54:54+01:00
Commit Message:
GRAPHICS: ATARI: Utilize dlmalloc
- every malloc is now aligned on 16 bytes
- no need for the hidden pointers
- ct60_vmalloc() is called only once, the rest is handled
by dlmalloc (SV XBIOS' vmalloc is pretty fragile)
Changed paths:
backends/graphics/atari/atari-graphics-supervidel.h
backends/graphics/atari/atari-graphics.cpp
backends/platform/atari/dlmalloc.h
graphics/blit/blit-atari.cpp
diff --git a/backends/graphics/atari/atari-graphics-supervidel.h b/backends/graphics/atari/atari-graphics-supervidel.h
index ca7816a80a5..898473c0be2 100644
--- a/backends/graphics/atari/atari-graphics-supervidel.h
+++ b/backends/graphics/atari/atari-graphics-supervidel.h
@@ -28,6 +28,16 @@
#include <mint/osbind.h>
+#ifdef USE_SV_BLITTER
+#include <mint/trap14.h>
+#define ct60_vm(mode, value) (long)trap_14_wwl((short)0xc60e, (short)(mode), (long)(value))
+#define ct60_vmalloc(value) ct60_vm(0, value)
+#define ct60_vmfree(value) ct60_vm(1, value)
+
+#include "backends/platform/atari/dlmalloc.h"
+extern mspace g_mspace;
+#endif
+
#include "backends/graphics/atari/atari-graphics-superblitter.h"
#include "common/debug.h" // error() & warning()
#include "common/scummsys.h"
@@ -46,6 +56,17 @@ public:
else
warning("SV_XBIOS has the pmmu boost disabled, set 'pmmu_boost = true' in C:\\SV.INF");
+#ifdef USE_SV_BLITTER
+ size_t vramSize = ct60_vmalloc(-1) - (16 * 1024 * 1024); // SV XBIOS seems to forget the initial 16 MB ST RAM mirror
+ _vramBase = vramSize > 0 ? (void *)ct60_vmalloc(vramSize) : nullptr;
+ if (_vramBase) {
+ g_mspace = create_mspace_with_base(_vramBase, vramSize, 0);
+ debug("Allocated VRAM at %p (%ld bytes)", _vramBase, vramSize);
+ }
+
+ if (!g_mspace)
+ warning("VRAM allocation failed");
+#endif
// using virtual methods so must be done here
allocateSurfaces();
}
@@ -53,6 +74,16 @@ public:
~AtariSuperVidelManager() {
// using virtual methods so must be done here
freeSurfaces();
+
+#ifdef USE_SV_BLITTER
+ if (_vramBase) {
+ destroy_mspace(g_mspace);
+ g_mspace = nullptr;
+
+ ct60_vmfree(_vramBase);
+ _vramBase = nullptr;
+ }
+#endif
}
private:
@@ -140,6 +171,10 @@ private:
return ret;
}
+
+#ifdef USE_SV_BLITTER
+ void *_vramBase = nullptr;
+#endif
};
#endif // USE_SUPERVIDEL
diff --git a/backends/graphics/atari/atari-graphics.cpp b/backends/graphics/atari/atari-graphics.cpp
index dc648fee33e..08ac79d8a69 100644
--- a/backends/graphics/atari/atari-graphics.cpp
+++ b/backends/graphics/atari/atari-graphics.cpp
@@ -31,6 +31,7 @@
#include "backends/graphics/atari/atari-graphics-superblitter.h"
#include "backends/keymapper/action.h"
#include "backends/keymapper/keymap.h"
+#include "backends/platform/atari/dlmalloc.h"
#include "common/config-manager.h"
#include "common/str.h"
@@ -46,6 +47,7 @@
#define MAX_V_SHAKE 16
bool g_unalignedPitch = false;
+mspace g_mspace = nullptr;
static const Graphics::PixelFormat PIXELFORMAT_CLUT8 = Graphics::PixelFormat::createFormatCLUT8();
static const Graphics::PixelFormat PIXELFORMAT_RGB332 = Graphics::PixelFormat(1, 3, 3, 2, 0, 5, 2, 0, 0);
diff --git a/backends/platform/atari/dlmalloc.h b/backends/platform/atari/dlmalloc.h
index d4177997179..eb8232c946d 100644
--- a/backends/platform/atari/dlmalloc.h
+++ b/backends/platform/atari/dlmalloc.h
@@ -29,6 +29,7 @@
#define NO_MALLOC_STATS 1
#define LACKS_TIME_H /* time(0) calls malloc... */
#define MSPACES 1
+#define MALLOC_ALIGNMENT ((size_t)16U) /* 16B cache line */
/*
Copyright 2023 Doug Lea
diff --git a/graphics/blit/blit-atari.cpp b/graphics/blit/blit-atari.cpp
index f2fc16d48b9..168bfc6db15 100644
--- a/graphics/blit/blit-atari.cpp
+++ b/graphics/blit/blit-atari.cpp
@@ -21,16 +21,12 @@
#include "graphics/blit.h"
#include "graphics/surface.h"
+#include "backends/platform/atari/dlmalloc.h"
#include <cstdlib> // malloc
#include <cstring> // memcpy, memset
#include <mint/cookie.h>
-#include <mint/trap14.h>
-#define ct60_vm(mode, value) (long)trap_14_wwl((short)0xc60e, (short)(mode), (long)(value))
-#define ct60_vmalloc(value) ct60_vm(0, value)
-#define ct60_vmfree(value) ct60_vm(1, value)
-
#include "backends/graphics/atari/atari-graphics-superblitter.h"
#include "common/textconsole.h" // error
@@ -98,6 +94,7 @@ void unlockSuperBlitter() {
// see atari-graphics.cpp
extern bool g_unalignedPitch;
+extern mspace g_mspace;
namespace Graphics {
@@ -119,41 +116,34 @@ void Surface::create(int16 width, int16 height, const PixelFormat &f) {
if (width && height) {
#ifdef USE_SV_BLITTER
- if (hasSuperVidel() && w >= 64 && h >= 64) {
- pixels = (void *)ct60_vmalloc(height * pitch);
+ if (g_mspace) {
+ pixels = mspace_calloc(g_mspace, height * pitch, f.bytesPerPixel);
if (!pixels)
- error("Not enough SVRAM to allocate a surface");
-
- assert((uintptr)pixels >= 0xA0000000);
+ error("Not enough memory to allocate a surface");
+ else if (pixels <= (void *)0xA0000000)
+ warning("SuperVidel surface allocated in regular memory");
} else {
#else
{
#endif
- // align buffer to a 16-byte boundary for move16 or C2P conversion
- void *pixelsUnaligned = ::malloc(sizeof(uintptr) + (height * pitch) + ALIGN - 1);
-
- if (!pixelsUnaligned)
+ pixels = ::calloc(height * pitch, f.bytesPerPixel);
+ if (!pixels)
error("Not enough memory to allocate a surface");
-
- pixels = (void *)(((uintptr)pixelsUnaligned + sizeof(uintptr) + ALIGN - 1) & (-ALIGN));
-
- // store the unaligned pointer for later free()
- *((uintptr *)pixels - 1) = (uintptr)pixelsUnaligned;
+ else
+ assert(((uintptr)pixels & (ALIGN - 1)) == 0);
}
-
- memset(pixels, 0, height * pitch);
}
}
void Surface::free() {
#ifdef USE_SV_BLITTER
- if (((uintptr)pixels & 0xFF000000) >= 0xA0000000)
- ct60_vmfree(pixels);
+ if (g_mspace)
+ mspace_free(g_mspace, pixels);
else
#endif
if (pixels)
- ::free((void *)*((uintptr *)pixels - 1));
+ ::free(pixels);
pixels = nullptr;
w = h = pitch = 0;
Commit: 01a2d2edab760f5902423c5b08fbb80188d5d3cc
https://github.com/scummvm/scummvm/commit/01a2d2edab760f5902423c5b08fbb80188d5d3cc
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2024-02-24T03:54:54+01:00
Commit Message:
BACKENDS: ATARI: Call original keyboard/mouse routines
This helps to solve the issue when one pushes 'Return' immediately after
Hatari's start. This issue appeared after introducing the
interrupt-driven audio mixer.
Not sure whether this was a real bug but it's much cleaner
implementation now anyway.
Changed paths:
backends/platform/atari/atari_ikbd.S
backends/platform/atari/osystem_atari.cpp
diff --git a/backends/platform/atari/atari_ikbd.S b/backends/platform/atari/atari_ikbd.S
index 7cba7e4bfcd..88850f6a95f 100644
--- a/backends/platform/atari/atari_ikbd.S
+++ b/backends/platform/atari/atari_ikbd.S
@@ -23,7 +23,9 @@
.global SYM(atari_kbdvec)
.global SYM(atari_mousevec)
- .global SYM(atari_vkbderr)
+
+ .global SYM(atari_old_kbdvec)
+ .global SYM(atari_old_mousevec)
.extern SYM(g_atari_ikbd_mouse_buttons_state)
.extern SYM(g_atari_ikbd_mouse_delta_x)
@@ -33,39 +35,15 @@
.extern SYM(g_atari_ikbd_scancodes_mask)
.extern SYM(g_atari_ikbb_scancodes_head)
- .extern SYM(g_atari_old_kbdvec)
-
.text
+ .ascii "XBRA"
+ .ascii "SCUM"
+SYM(atari_old_kbdvec):
+ dc.l 0
SYM(atari_kbdvec):
- tst.w (vkbderr_count,pc)
- bne.b kbdvec_end
-
- lea pressed_keys,a0
- clr.l d1
- move.b d0,d1
- bpl.b key_pressed | bit 7 cleared
-
-key_released:
- and.b #0x7f,d1
- tst.b (a0,d1.l) | pressed before?
- bne.b key_released_ok
-
- | if we get a sudden release key event,
- | let the original handler process it
- move.l SYM(g_atari_old_kbdvec),a0
- tst.l a0
- beq.b kbdvec_end
- jmp (a0)
-
-key_released_ok:
- clr.b (a0,d1.l) | mark as released
- bra.b kbdvec_process
-
-key_pressed:
- addq.b #1,(a0,d1.l) | mark as pressed
-
-kbdvec_process:
+ movem.l d1/a0,-(sp)
+
lea SYM(g_atari_ikbd_scancodes),a0
move.w SYM(g_atari_ikbb_scancodes_head),d1
@@ -77,17 +55,17 @@ kbdvec_process:
and.w SYM(g_atari_ikbd_scancodes_mask),d1
move.w d1,SYM(g_atari_ikbb_scancodes_head)
-kbdvec_end:
- rts
-
-
-SYM(atari_vkbderr):
- addq.w #1,vkbderr_count
+ movem.l (sp)+,d1/a0
+ move.l (atari_old_kbdvec,pc),-(sp)
rts
+ .ascii "XBRA"
+ .ascii "SCUM"
+SYM(atari_old_mousevec):
+ dc.l 0
SYM(atari_mousevec):
- clr.w vkbderr_count
+ movem.l d0/a0,-(sp)
move.b (a0)+,SYM(g_atari_ikbd_mouse_buttons_state)
@@ -98,14 +76,7 @@ SYM(atari_mousevec):
move.b (a0)+,d0
ext.w d0
add.w d0,SYM(g_atari_ikbd_mouse_delta_y)
- rts
-
-// place it within reach of 32K (PC relative)
-vkbderr_count:
- dc.w 0
-
- .bss
-
-pressed_keys:
- ds.b 128
+ movem.l (sp)+,d0/a0
+ move.l (atari_old_mousevec,pc),-(sp)
+ rts
diff --git a/backends/platform/atari/osystem_atari.cpp b/backends/platform/atari/osystem_atari.cpp
index e1cb98cfad9..8547b00db03 100644
--- a/backends/platform/atari/osystem_atari.cpp
+++ b/backends/platform/atari/osystem_atari.cpp
@@ -66,7 +66,9 @@
extern "C" void atari_kbdvec(void *);
extern "C" void atari_mousevec(void *);
-extern "C" void atari_vkbderr(void);
+typedef void (*KBDVEC)(void *);
+extern "C" KBDVEC atari_old_kbdvec;
+extern "C" KBDVEC atari_old_mousevec;
extern "C" void atari_200hz_init();
extern "C" void atari_200hz_shutdown();
@@ -78,11 +80,6 @@ extern void nf_print(const char* msg);
static bool s_tt = false;
static int s_app_id = -1;
-typedef void (*KBDVEC)(void *);
-KBDVEC g_atari_old_kbdvec = nullptr;
-static void (*s_vkbderr)(void) = nullptr;
-static KBDVEC s_mousevec = nullptr;
-
static bool exit_already_called = false;
static void critical_restore() {
@@ -98,12 +95,11 @@ static void critical_restore() {
Supexec(asm_screen_falcon_restore);
Supexec(atari_200hz_shutdown);
- if (g_atari_old_kbdvec && s_vkbderr && s_mousevec) {
+ if (atari_old_kbdvec && atari_old_mousevec) {
_KBDVECS *kbdvecs = Kbdvbase();
- ((uintptr *)kbdvecs)[-1] = (uintptr)g_atari_old_kbdvec;
- kbdvecs->vkbderr = s_vkbderr;
- kbdvecs->mousevec = s_mousevec;
- g_atari_old_kbdvec = s_mousevec = nullptr;
+ ((uintptr *)kbdvecs)[-1] = (uintptr)atari_old_kbdvec;
+ kbdvecs->mousevec = atari_old_mousevec;
+ atari_old_kbdvec = atari_old_mousevec = nullptr;
}
// don't call GEM cleanup in the critical handler: it seems that v_clsvwk()
@@ -166,12 +162,10 @@ OSystem_Atari::OSystem_Atari() {
}
_KBDVECS *kbdvecs = Kbdvbase();
- g_atari_old_kbdvec = (KBDVEC)(((uintptr *)kbdvecs)[-1]);
- s_vkbderr = kbdvecs->vkbderr;
- s_mousevec = kbdvecs->mousevec;
+ atari_old_kbdvec = (KBDVEC)(((uintptr *)kbdvecs)[-1]);
+ atari_old_mousevec = kbdvecs->mousevec;
((uintptr *)kbdvecs)[-1] = (uintptr)atari_kbdvec;
- kbdvecs->vkbderr = atari_vkbderr;
kbdvecs->mousevec = atari_mousevec;
Supexec(atari_200hz_init);
@@ -231,12 +225,11 @@ OSystem_Atari::~OSystem_Atari() {
_timerInitialized = false;
}
- if (g_atari_old_kbdvec && s_vkbderr && s_mousevec) {
+ if (atari_old_kbdvec && atari_old_mousevec) {
_KBDVECS *kbdvecs = Kbdvbase();
- ((uintptr *)kbdvecs)[-1] = (uintptr)g_atari_old_kbdvec;
- kbdvecs->vkbderr = s_vkbderr;
- kbdvecs->mousevec = s_mousevec;
- g_atari_old_kbdvec = s_mousevec = nullptr;
+ ((uintptr *)kbdvecs)[-1] = (uintptr)atari_old_kbdvec;
+ kbdvecs->mousevec = atari_old_mousevec;
+ atari_old_kbdvec = atari_old_mousevec = nullptr;
}
if (s_app_id != -1) {
More information about the Scummvm-git-logs
mailing list