[Scummvm-git-logs] scummvm master -> d4d9307a6923dbed67c524988b2755321fa72018

mikrosk noreply at scummvm.org
Sun Sep 24 15:53:39 UTC 2023


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b510eff336 BACKENDS: ATARI: Implement aspect ratio correction
dcab5d3369 CONFIGURE: Add support for m68k-atari-mintelf
fb8528ac77 BACKENDS: ATARI: Various fixes
d4d9307a69 BACKENDS: ATARI: Use atari_sound_setup code


Commit: b510eff336ffd48d9262dca2c22c2ccab46580fb
    https://github.com/scummvm/scummvm/commit/b510eff336ffd48d9262dca2c22c2ccab46580fb
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-09-24T17:48:54+02:00

Commit Message:
BACKENDS: ATARI: Implement aspect ratio correction

Changed paths:
    backends/graphics/atari/atari-graphics.cpp
    backends/graphics/atari/atari-graphics.h
    backends/platform/atari/readme.txt


diff --git a/backends/graphics/atari/atari-graphics.cpp b/backends/graphics/atari/atari-graphics.cpp
index 17c522a5057..7c9c1ea2ded 100644
--- a/backends/graphics/atari/atari-graphics.cpp
+++ b/backends/graphics/atari/atari-graphics.cpp
@@ -78,7 +78,6 @@ static void VblHandler() {
 			   : (2 * MAX_HZ_SHAKE * bitsPerPixel / 8) / 2 - bitsPerPixel;
 		}
 
-
 		union { byte c[4]; uintptr p; } sptr;
 		sptr.p = p;
 
@@ -122,6 +121,34 @@ static uint32 UninstallVblHandler() {
 	return uninstalled;
 }
 
+static void shrinkVidelVisibleArea() {
+	// Active VGA screen area consists of 960 half-lines, i.e. 480 raster lines.
+	// In case of 320x240, the number is still 480 but data is fetched
+	// only for 240 lines so it doesn't make a difference to us.
+	Vsync();
+
+	if (hasSuperVidel()) {
+		const int vOffset = ((480 - 400) / 2) * 2;	// *2 because of half-lines
+
+		// VDB = VBE = VDB + paddding/2
+		*((volatile uint16*)0xFFFF82A8) = *((volatile uint16*)0xFFFF82A6) = *((volatile uint16*)0xFFFF82A8) + vOffset;
+		// VDE = VBB = VDE - padding/2
+		*((volatile uint16*)0xFFFF82AA) = *((volatile uint16*)0xFFFF82A4) = *((volatile uint16*)0xFFFF82AA) - vOffset;
+	} else {
+		// 31500/60.1 = 524 raster lines
+		// vft = 524 * 2 + 1 = 1049 half-lines
+		// 480 visible lines = 960 half-lines
+		// 1049 - 960 = 89 half-lines reserved for borders
+		// we want 400 visible lines = 800 half-lines
+		// vft = 800 + 89 = 889 half-lines in total ~ 70.1 Hz vertical frequency
+		int16 vft = *((volatile int16*)0xFFFF82A2);
+		int16 vss = *((volatile int16*)0xFFFF82AC);	// vss = vft - vss_sync
+		vss -= vft;	// -vss_sync
+		*((volatile int16*)0xFFFF82A2) = 889;
+		*((volatile int16*)0xFFFF82AC) = 889 + vss;
+	}
+}
+
 static int  s_oldRez = -1;
 static int  s_oldMode = -1;
 static void *s_oldPhysbase = nullptr;
@@ -134,6 +161,8 @@ void AtariGraphicsShutdown() {
 	} else if (s_oldMode != -1) {
 		// prevent setting video base address just on the VDB line
 		Vsync();
+		if (hasSuperVidel())
+			VsetMode(SVEXT | SVEXT_BASERES(0) | COL80 | BPS8C);	// resync to proper 640x480
 		VsetMode(s_oldMode);
 		VsetScreen(SCR_NOCHANGE, s_oldPhysbase, SCR_NOCHANGE, SCR_NOCHANGE);
 	}
@@ -227,7 +256,7 @@ bool AtariGraphicsManager::hasFeature(OSystem::Feature f) const {
 	switch (f) {
 	case OSystem::Feature::kFeatureAspectRatioCorrection:
 		//debug("hasFeature(kFeatureAspectRatioCorrection): %d", !_vgaMonitor);
-		return !_tt && !_vgaMonitor;
+		return !_tt;
 	case OSystem::Feature::kFeatureCursorPalette:
 		// FIXME: pretend to have cursor palette at all times, this function
 		// can get (and it is) called any time, before and after showOverlay()
@@ -249,7 +278,7 @@ void AtariGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
 		_aspectRatioCorrection = enable;
 		break;
 	default:
-		[[fallthrough]];
+		break;
 	}
 }
 
@@ -574,7 +603,7 @@ void AtariGraphicsManager::updateScreen() {
 	_pendingScreenChange = kPendingScreenChangeNone;
 
 	if (_oldAspectRatioCorrection != _aspectRatioCorrection) {
-		if (!isOverlayVisible()) {
+		if (!isOverlayVisible() && _currentState.height == 200) {
 			if (!_vgaMonitor) {
 				short mode = VsetMode(VM_INQUIRE);
 				if (_aspectRatioCorrection) {
@@ -587,15 +616,82 @@ void AtariGraphicsManager::updateScreen() {
 					mode |= PAL;
 				}
 				VsetMode(mode);
-			} else if (hasSuperVidel()) {
-				// TODO: reduce to 200 scan lines?
-			} else if (!_tt) {
-				// TODO: increase vertical frequency?
+			} else if (hasSuperVidel() || !_tt) {
+				if (_aspectRatioCorrection) {
+					for (int screenId : { FRONT_BUFFER, BACK_BUFFER1, BACK_BUFFER2 }) {
+						Screen *screen = _screen[screenId];
+						Graphics::Surface *offsettedSurf = screen->offsettedSurf;
+
+						// erase old screen
+						offsettedSurf->fillRect(Common::Rect(offsettedSurf->w, offsettedSurf->h), 0);
+
+						// setup new screen
+						screen->oldScreenSurfaceWidth = screen->surf.w;
+						screen->oldScreenSurfaceHeight = screen->surf.h;
+						screen->oldScreenSurfacePitch = screen->surf.pitch;
+						screen->oldOffsettedSurfaceWidth = offsettedSurf->w;
+						screen->oldOffsettedSurfaceHeight = offsettedSurf->h;
+
+						screen->surf.w = 320 + 2 * MAX_HZ_SHAKE;
+						screen->surf.h = 200 + 2 * MAX_V_SHAKE;
+						screen->surf.pitch = screen->surf.w;
+
+						offsettedSurf->init(
+							320, 200, screen->surf.pitch,
+							screen->surf.getBasePtr((screen->surf.w - 320) / 2, (screen->surf.h - 200) / 2),
+							screen->surf.format);
+
+						screen->addDirtyRect(*lockScreen(), Common::Rect(offsettedSurf->w, offsettedSurf->h), _currentState.mode == GraphicsMode::DirectRendering);
+					}
+
+					Supexec(shrinkVidelVisibleArea);
+				} else {
+					for (int screenId : { FRONT_BUFFER, BACK_BUFFER1, BACK_BUFFER2 }) {
+						Screen *screen = _screen[screenId];
+						Graphics::Surface *offsettedSurf = screen->offsettedSurf;
+
+						assert(screen->oldScreenSurfaceWidth != -1);
+						assert(screen->oldScreenSurfaceHeight != -1);
+						assert(screen->oldScreenSurfacePitch != -1);
+						assert(screen->oldOffsettedSurfaceWidth != -1);
+						assert(screen->oldOffsettedSurfaceHeight != -1);
+
+						// erase old screen
+						offsettedSurf->fillRect(Common::Rect(offsettedSurf->w, offsettedSurf->h), 0);
+
+						// setup new screen
+						screen->surf.w = screen->oldScreenSurfaceWidth;
+						screen->surf.h = screen->oldScreenSurfaceHeight;
+						screen->surf.pitch = screen->oldScreenSurfacePitch;
+
+						offsettedSurf->init(
+							screen->oldOffsettedSurfaceWidth, screen->oldOffsettedSurfaceHeight, screen->surf.pitch,
+							screen->surf.getBasePtr(
+								(screen->surf.w - screen->oldOffsettedSurfaceWidth) / 2,
+								(screen->surf.h - screen->oldOffsettedSurfaceHeight) / 2),
+							screen->surf.format);
+
+						screen->oldScreenSurfaceWidth = -1;
+						screen->oldScreenSurfaceHeight = -1;
+						screen->oldScreenSurfacePitch = -1;
+						screen->oldOffsettedSurfaceWidth = -1;
+						screen->oldOffsettedSurfaceHeight = -1;
+
+						screen->addDirtyRect(*lockScreen(), Common::Rect(offsettedSurf->w, offsettedSurf->h), _currentState.mode == GraphicsMode::DirectRendering);
+					}
+
+					if (hasSuperVidel())
+						VsetMode(SVEXT | SVEXT_BASERES(0) | COL80 | BPS8C);	// resync to proper 640x480
+					VsetMode(_workScreen->mode);
+				}
 			} else {
 				// TODO: some tricks with TT's 480 lines?
 			}
 
 			_oldAspectRatioCorrection = _aspectRatioCorrection;
+
+			_pendingScreenChange |= kPendingScreenChangeScreen;
+			updateScreen();
 		} else {
 			// ignore new value in overlay
 			_aspectRatioCorrection = _oldAspectRatioCorrection;
diff --git a/backends/graphics/atari/atari-graphics.h b/backends/graphics/atari/atari-graphics.h
index e15805edb34..0ca1a5e2ce1 100644
--- a/backends/graphics/atari/atari-graphics.h
+++ b/backends/graphics/atari/atari-graphics.h
@@ -294,6 +294,12 @@ private:
 		int mode = -1;
 		Graphics::Surface *const offsettedSurf = &_offsettedSurf;
 
+		int oldScreenSurfaceWidth = -1;
+		int oldScreenSurfaceHeight = -1;
+		int oldScreenSurfacePitch = -1;
+		int oldOffsettedSurfaceWidth = -1;
+		int oldOffsettedSurfaceHeight = -1;
+
 	private:
 		static constexpr size_t ALIGN = 16;	// 16 bytes
 
diff --git a/backends/platform/atari/readme.txt b/backends/platform/atari/readme.txt
index 4984e216602..8821cba3cdf 100644
--- a/backends/platform/atari/readme.txt
+++ b/backends/platform/atari/readme.txt
@@ -213,6 +213,39 @@ means that if the SuperVidel is detected, it does the following:
   and makes a *huge* difference for 640x480 fullscreen updates.
 
 
+Aspect ratio correction
+-----------------------
+
+Please refer to the official documentation about its usage. Normally ScummVM
+implements this functionality using yet another fullscreen transformation of
+320x200 surface into a 320x240 one (there is even a selection of algorithms
+for this task, varying in performance and quality).
+
+Naturally, this would pose a terrible performance anchor on our backend so some
+cheating has been used:
+
+- on RGB, the vertical refresh rate frequency is set to 60 Hz, creating an
+  illusion of creating non-square pixels. Works best on CRT monitors.
+
+- on VGA, the vertical refresh rate frequency is set to 70 Hz, with more or
+  less the same effect as on RGB. Works best on CRT monitors.
+
+- on SuperVidel, video output is modified in such way that the DVI/HDMI monitor
+  receives a 320x200 image and if properly set/supported, it will automatically
+  stretch the image to 320x240 (this is usually a setting called "picture
+  expansion" or "picture stretch" -- make sure it isn't set to something like
+  "1:1" or "dot by dot")
+
+Yes, it's a hack. :) Owners of a CRT monitor can achieve the same effect by the
+analog knobs -- stretch and move the 320x200 picture unless black borders are
+no longer visible. This hack provides a more elegant and per-game
+functionality.
+
+Realtime aspect ratio correction (CTRL+ALT+a) should be used with caution in
+Direct rendering mode because there's no way to refresh the screen. So if you
+change the setting and there isn't any game screen update coming, screen will
+stay black.
+
 Audio mixing
 ------------
 
@@ -295,8 +328,9 @@ music (and therefore avoiding the expensive synthesis emulation) but beware, it
 doesn't affect CD (*.wav) playback at all! Same applies for speech and sfx.
 
 The least amount of cycles is spent when:
-- "No music" (or keep it default and choose a native MIDI device) is set in the
-   GUI options; this prevents MIDI sythesis of any kind
+- "No music" as "Preferred device": this prevents MIDI sythesis of any kind
+- "Subtitles" as "Text and speech": this prevents any sampled speech to be
+  mixed
 - all external audio files are deleted (typically *.wav); that way the mixer
   wont have anything to mix. However beware, this is not allowed in every game!
 
@@ -336,8 +370,6 @@ restricts features but also improves performance:
 Known issues
 ------------
 
-- aspect ratio correction works on RGB only (yet)
-
 - adding a game in TOS and loading it in FreeMiNT (and vice versa) generates
   incompatible paths. Either use only one system or edit scummvm.ini and set
   there only relative paths (mintlib bug/limitation).
@@ -349,6 +381,9 @@ Known issues
 - horizontal screen shaking doesn't work on TT because TT Shifter doesn't
   support fine scrolling. However it is "emulated" via vertical shaking.
 
+- aspect ratio correction has no effect on TT because is not possible to alter
+  its vertical screen refresh frequency.
+
 - tooltips in overlay are sometimes drawn with corrupted background.
 
 - the talkie version of MI1 needs to be merged from two sources: first generate
@@ -373,11 +408,15 @@ Known issues
 		- Engine GUI (for save/load/etc) does not support 8-bit screens
 		- https://wiki.scummvm.org/index.php?title=Hugo
 
+- Indy4 (the adventure) may have a bug in the screen when you K.O. the bouncer.
+  I was able to get a freeze when he fell to the ground but currently I am
+  unable to reproduce it. It may be related to the intensive mouse clicking
+  during that scene so feel free to use keypad for the fight and report whether
+  it has improved the situation.
+
 Future plans
 ------------
 
-- aspect ratio correction for TT/VGA/SuperVidel
-
 - unified file paths in scummvm.ini
 
 - DSP-based sample mixer (WAV, FLAC, MP2)


Commit: dcab5d3369a3ac3f2793cab8323964c57a0ef588
    https://github.com/scummvm/scummvm/commit/dcab5d3369a3ac3f2793cab8323964c57a0ef588
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-09-24T17:48:54+02:00

Commit Message:
CONFIGURE: Add support for m68k-atari-mintelf

This is basically the same as m68k-atari-mint host os but with a
different compiler/file format.

Changed paths:
  A backends/platform/atari/symbols.h
    backends/graphics/atari/atari-graphics-asm.S
    backends/graphics/atari/atari_c2p-asm.S
    backends/platform/atari/atari_200hz.S
    backends/platform/atari/atari_ikbd.S
    backends/platform/atari/build-release.sh
    backends/platform/atari/build-release030.sh
    configure
    graphics/blit/blit-atari.cpp
    ports.mk


diff --git a/backends/graphics/atari/atari-graphics-asm.S b/backends/graphics/atari/atari-graphics-asm.S
index 8629fc27f14..a20963db501 100644
--- a/backends/graphics/atari/atari-graphics-asm.S
+++ b/backends/graphics/atari/atari-graphics-asm.S
@@ -19,20 +19,22 @@
  *
  */
 
-	.global	_asm_screen_tt_save
-	.global	_asm_screen_falcon_save
+#include "../../platform/atari/symbols.h"
 
-	.global	_asm_screen_tt_restore
-	.global	_asm_screen_falcon_restore
+	.global	SYM(asm_screen_tt_save)
+	.global	SYM(asm_screen_falcon_save)
 
-	.global	_asm_draw_4bpl_sprite
-	.global	_asm_draw_8bpl_sprite
+	.global	SYM(asm_screen_tt_restore)
+	.global	SYM(asm_screen_falcon_restore)
+
+	.global	SYM(asm_draw_4bpl_sprite)
+	.global	SYM(asm_draw_8bpl_sprite)
 
 	.text
 
 | extern void asm_screen_tt_save(void);
 |
-_asm_screen_tt_save:
+SYM(asm_screen_tt_save):
 	bsr	wait_vbl			| avoid flickering
 
 	lea	0xffff8400.w,a0
@@ -51,7 +53,7 @@ tt_save_loop:
 
 | extern void asm_screen_falcon_save(void);
 |
-_asm_screen_falcon_save:
+SYM(asm_screen_falcon_save):
 	movem.l	d2-d7/a2,-(sp)
 
 	bsr	wait_vbl			| avoid flickering
@@ -99,7 +101,7 @@ falcon_save_loop:
 
 | extern void asm_screen_tt_restore(void);
 |
-_asm_screen_tt_restore:
+SYM(asm_screen_tt_restore):
 	bsr	wait_vbl			| avoid flickering
 
 	lea	save_video,a1
@@ -117,7 +119,7 @@ _asm_screen_tt_restore:
 
 | extern void asm_screen_falcon_restore(void);
 |
-_asm_screen_falcon_restore:
+SYM(asm_screen_falcon_restore):
 	movem.l	d2-d7/a2,-(sp)
 
 	bsr	wait_vbl			| avoid flickering
@@ -188,7 +190,7 @@ wait_vbl:
 | extern void asm_draw_4bpl_sprite(uint16 *dstBuffer, const uint16 *srcBuffer, const uint16 *srcMask,
 |				   uint destX, uint destY, uint dstPitch, uint w, uint h);
 |
-_asm_draw_4bpl_sprite:
+SYM(asm_draw_4bpl_sprite):
 	movem.l	d0-d7/a0-a2,-(sp)		| 11 longs
 
 	move.l	(4+11*4,sp),a2			| a2: dstBuffer
@@ -286,7 +288,7 @@ sprite4_xloop:
 | extern void asm_draw_8bpl_sprite(uint16 *dstBuffer, const uint16 *srcBuffer, const uint16 *srcMask,
 |				   uint destX, uint destY, uint dstPitch, uint w, uint h);
 |
-_asm_draw_8bpl_sprite:
+SYM(asm_draw_8bpl_sprite):
 	movem.l	d0-d7/a0-a2,-(sp)		| 11 longs
 
 	move.l	(4+11*4,sp),a2			| a2: dstBuffer
diff --git a/backends/graphics/atari/atari_c2p-asm.S b/backends/graphics/atari/atari_c2p-asm.S
index 32c4a0bf292..2da584648e8 100644
--- a/backends/graphics/atari/atari_c2p-asm.S
+++ b/backends/graphics/atari/atari_c2p-asm.S
@@ -19,20 +19,22 @@
  *
  */
 
+ #include "../../platform/atari/symbols.h"
+
 | C2P by Mikael Kalms (public domain)
 | See https://github.com/Kalmalyzer/kalms-c2p
 
-	.globl	_asm_c2p1x1_8
-	.globl	_asm_c2p1x1_8_tt
-	.globl	_asm_c2p1x1_8_rect
-	.globl	_asm_c2p1x1_4
-	.globl	_asm_c2p1x1_4_rect
+	.globl	SYM(asm_c2p1x1_8)
+	.globl	SYM(asm_c2p1x1_8_tt)
+	.globl	SYM(asm_c2p1x1_8_rect)
+	.globl	SYM(asm_c2p1x1_4)
+	.globl	SYM(asm_c2p1x1_4_rect)
 
 
 	.text
 
 | void asm_c2p1x1_8(const byte *pChunky, const byte *pChunkyEnd, byte *pScreen);
-_asm_c2p1x1_8:
+SYM(asm_c2p1x1_8):
 	move.l	(4,sp),a0				| chunky
 	move.l	(8,sp),d0				| chunky end
 	move.l	(12,sp),a1				| screen
@@ -229,7 +231,7 @@ c2p1x1_8_start:
 
 
 | void asm_c2p1x1_8_tt(const byte *pChunky, const byte *pChunkyEnd, byte *pScreen, uint32 screenPitch);
-_asm_c2p1x1_8_tt:
+SYM(asm_c2p1x1_8_tt):
 	movem.l	d2-d7/a2-a6,-(sp)			| 6 + 5 = 11 longs
 
 	move.l	(11*4+4,sp),a0				| a0: chunky
@@ -444,7 +446,7 @@ c2p1x1_8_tt_start:
 
 
 | void asm_c2p1x1_8_rect(const byte *pChunky, const byte *pChunkyEnd, uint32 chunkyWidth, uint32 chunkyPitch, byte *pScreen, uint32 screenPitch);
-_asm_c2p1x1_8_rect:
+SYM(asm_c2p1x1_8_rect):
 	movem.l	d2-d7/a2-a6,-(sp)			| 6 + 5 = 11 longs
 
 	move.l	(11*4+4,sp),a0				| a0: chunky
@@ -676,7 +678,7 @@ c2p1x1_8_rect_done:
 
 
 | void asm_c2p1x1_4(const byte *pChunky, const byte *pChunkyEnd, byte *pScreen);
-_asm_c2p1x1_4:
+SYM(asm_c2p1x1_4):
 	move.l	(4,sp),a0				| chunky
 	move.l	(8,sp),d0				| chunky end
 	move.l	(12,sp),a1				| screen
@@ -780,7 +782,7 @@ c2p1x1_4_start:
 
 
 | void asm_c2p1x1_4_rect(const byte *pChunky, const byte *pChunkyEnd, uint32 chunkyWidth, uint32 chunkyPitch, byte *pScreen, uint32 screenPitch);
-_asm_c2p1x1_4_rect:
+SYM(asm_c2p1x1_4_rect):
 	movem.l	d2-d7/a2-a6,-(sp)			| 6 + 5 = 11 longs
 
 	move.l	(11*4+4,sp),a0				| a0: chunky
diff --git a/backends/platform/atari/atari_200hz.S b/backends/platform/atari/atari_200hz.S
index 94adc452dd4..cec28f10c34 100644
--- a/backends/platform/atari/atari_200hz.S
+++ b/backends/platform/atari/atari_200hz.S
@@ -19,14 +19,16 @@
  *
  */
 
-	.globl	_atari_200hz_init
-	.globl	_atari_200hz_shutdown
+ #include "symbols.h"
 
-	.globl	_counter_200hz
+	.globl	SYM(atari_200hz_init)
+	.globl	SYM(atari_200hz_shutdown)
+
+	.globl	SYM(counter_200hz)
 
 	.text
 
-_atari_200hz_init:
+SYM(atari_200hz_init):
 	move	sr,-(sp)
 	or	#0x700,sr
 
@@ -36,7 +38,7 @@ _atari_200hz_init:
 	move	(sp)+,sr
 	rts
 
-_atari_200hz_shutdown:
+SYM(atari_200hz_shutdown):
 	move	sr,-(sp)
 	or	#0x700,sr
 
@@ -50,7 +52,7 @@ _atari_200hz_shutdown:
 old_200hz:
 	dc.l	0
 my_200hz:
-	addq.l	#1,_counter_200hz
+	addq.l	#1,SYM(counter_200hz)
 
 	move.l	old_200hz,-(sp)
 	rts
@@ -59,5 +61,5 @@ my_200hz:
 	.bss
 	.even
 
-_counter_200hz:
+SYM(counter_200hz):
 	ds.l	1
diff --git a/backends/platform/atari/atari_ikbd.S b/backends/platform/atari/atari_ikbd.S
index 57b44687175..7cba7e4bfcd 100644
--- a/backends/platform/atari/atari_ikbd.S
+++ b/backends/platform/atari/atari_ikbd.S
@@ -19,23 +19,25 @@
  *
  */
 
-	.global	_atari_kbdvec
-	.global	_atari_mousevec
-	.global	_atari_vkbderr
+ #include "symbols.h"
 
-	.extern	_g_atari_ikbd_mouse_buttons_state
-	.extern	_g_atari_ikbd_mouse_delta_x
-	.extern	_g_atari_ikbd_mouse_delta_y
+	.global	SYM(atari_kbdvec)
+	.global	SYM(atari_mousevec)
+	.global	SYM(atari_vkbderr)
 
-	.extern	_g_atari_ikbd_scancodes
-	.extern	_g_atari_ikbd_scancodes_mask
-	.extern	_g_atari_ikbb_scancodes_head
+	.extern	SYM(g_atari_ikbd_mouse_buttons_state)
+	.extern	SYM(g_atari_ikbd_mouse_delta_x)
+	.extern	SYM(_atari_ikbd_mouse_delta_y)
 
-	.extern	_g_atari_old_kbdvec
+	.extern	SYM(g_atari_ikbd_scancodes)
+	.extern	SYM(g_atari_ikbd_scancodes_mask)
+	.extern	SYM(g_atari_ikbb_scancodes_head)
+
+	.extern	SYM(g_atari_old_kbdvec)
 
 	.text
 
-_atari_kbdvec:
+SYM(atari_kbdvec):
 	tst.w	(vkbderr_count,pc)
 	bne.b	kbdvec_end
 
@@ -51,7 +53,7 @@ key_released:
 
 	| if we get a sudden release key event,
 	| let the original handler process it
-	move.l	_g_atari_old_kbdvec,a0
+	move.l	SYM(g_atari_old_kbdvec),a0
 	tst.l	a0
 	beq.b	kbdvec_end
 	jmp	(a0)
@@ -64,38 +66,38 @@ key_pressed:
 	addq.b	#1,(a0,d1.l)				| mark as pressed
 
 kbdvec_process:
-	lea	_g_atari_ikbd_scancodes,a0
-	move.w	_g_atari_ikbb_scancodes_head,d1
+	lea	SYM(g_atari_ikbd_scancodes),a0
+	move.w	SYM(g_atari_ikbb_scancodes_head),d1
 
 	| g_atari_ikbd_scancodes[g_atari_ikbb_scancodes_head] = scancode
 
 	move.b	d0,(0.b,a0,d1.w)
 
 	addq.l	#1,d1
-	and.w	_g_atari_ikbd_scancodes_mask,d1
-	move.w	d1,_g_atari_ikbb_scancodes_head
+	and.w	SYM(g_atari_ikbd_scancodes_mask),d1
+	move.w	d1,SYM(g_atari_ikbb_scancodes_head)
 
 kbdvec_end:
 	rts
 
 
-_atari_vkbderr:
+SYM(atari_vkbderr):
 	addq.w	#1,vkbderr_count
 	rts
 
 
-_atari_mousevec:
+SYM(atari_mousevec):
 	clr.w	vkbderr_count
 
-	move.b	(a0)+,_g_atari_ikbd_mouse_buttons_state
+	move.b	(a0)+,SYM(g_atari_ikbd_mouse_buttons_state)
 
 	move.b	(a0)+,d0
 	ext.w	d0
-	add.w	d0,_g_atari_ikbd_mouse_delta_x
+	add.w	d0,SYM(g_atari_ikbd_mouse_delta_x)
 
 	move.b	(a0)+,d0
 	ext.w	d0
-	add.w	d0,_g_atari_ikbd_mouse_delta_y
+	add.w	d0,SYM(g_atari_ikbd_mouse_delta_y)
 	rts
 
 // place it within reach of 32K (PC relative)
diff --git a/backends/platform/atari/build-release.sh b/backends/platform/atari/build-release.sh
index f3d0fdc935b..9e8bc33de22 100755
--- a/backends/platform/atari/build-release.sh
+++ b/backends/platform/atari/build-release.sh
@@ -6,15 +6,18 @@
 mkdir -p build-release
 cd build-release
 
+PLATFORM=m68k-atari-mintelf
+
 export ASFLAGS="-m68020-60"
 export CXXFLAGS="-m68020-60 -DUSE_MOVE16 -DUSE_SUPERVIDEL -DUSE_SV_BLITTER"
 export LDFLAGS="-m68020-60"
+export PKG_CONFIG_LIBDIR="$(${PLATFORM}-gcc -print-sysroot)/usr/lib/m68020-60/pkgconfig"
 
 if [ ! -f config.log ]
 then
 ../configure \
 	--backend=atari \
-	--host=m68k-atari-mint \
+	--host=${PLATFORM} \
 	--enable-release \
 	--disable-mt32emu \
 	--disable-lua \
@@ -35,6 +38,13 @@ make -j 16
 rm -rf dist-generic
 make dist-generic
 
+# make memory protection friendly
+${PLATFORM}-flags -S dist-generic/scummvm/scummvm.ttp
+
+# create symbol file and strip
+${PLATFORM}-nm -C dist-generic/scummvm/scummvm.ttp | grep -vF ' .L' | grep ' [TtWV] ' | ${PLATFORM}-c++filt | sort -u > dist-generic/scummvm/scummvm.sym
+${PLATFORM}-strip -s dist-generic/scummvm/scummvm.ttp
+
 # remove unused files; absent gui-icons.dat massively speeds up startup time (used for the grid mode)
 rm -f dist-generic/scummvm/data/{gui-icons,achievements,macgui,shaders}.dat
 
@@ -52,3 +62,9 @@ cd -
 # readme.txt
 cp ../backends/platform/atari/readme.txt dist-generic/scummvm
 unix2dos dist-generic/scummvm/readme.txt
+
+cd dist-generic
+zip -r -9 scummvm-fat.zip scummvm
+cd -
+
+mv dist-generic/scummvm-fat.zip ..
diff --git a/backends/platform/atari/build-release030.sh b/backends/platform/atari/build-release030.sh
index 05398ed9b6b..6d27a6d964f 100755
--- a/backends/platform/atari/build-release030.sh
+++ b/backends/platform/atari/build-release030.sh
@@ -6,15 +6,18 @@
 mkdir -p build-release030
 cd build-release030
 
+PLATFORM=m68k-atari-mintelf
+
 export ASFLAGS="-m68030"
 export CXXFLAGS="-m68030 -DDISABLE_FANCY_THEMES"
 export LDFLAGS="-m68030"
+export PKG_CONFIG_LIBDIR="$(${PLATFORM}-gcc -print-sysroot)/usr/lib/m68020-60/pkgconfig"
 
 if [ ! -f config.log ]
 then
 ../configure \
 	--backend=atari \
-	--host=m68k-atari-mint \
+	--host=${PLATFORM} \
 	--enable-release \
 	--disable-mt32emu \
 	--disable-lua \
@@ -36,9 +39,22 @@ make -j 16
 rm -rf dist-generic
 make dist-generic
 
+# make memory protection friendly
+${PLATFORM}-flags -S dist-generic/scummvm/scummvm.ttp
+
+# create symbol file and strip
+${PLATFORM}-nm -C dist-generic/scummvm/scummvm.ttp | grep -vF ' .L' | grep ' [TtWV] ' | ${PLATFORM}-c++filt | sort -u > dist-generic/scummvm/scummvm.sym
+${PLATFORM}-strip -s dist-generic/scummvm/scummvm.ttp
+
 # remove unused files
 rm -f dist-generic/scummvm/data/*.zip dist-generic/scummvm/data/{gui-icons,achievements,macgui,shaders}.dat
 
 # readme.txt
 cp ../backends/platform/atari/readme.txt dist-generic/scummvm
 unix2dos dist-generic/scummvm/readme.txt
+
+cd dist-generic
+zip -r -9 scummvm-slim.zip scummvm
+cd -
+
+mv dist-generic/scummvm-slim.zip ..
diff --git a/backends/platform/atari/symbols.h b/backends/platform/atari/symbols.h
new file mode 100644
index 00000000000..f0ab7921674
--- /dev/null
+++ b/backends/platform/atari/symbols.h
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// Atari a.out / ELF symbol handling by Thorsten Otto.
+// include in each of the .S files and put every global symbol into
+// SYM(<symbol name>).
+
+#ifndef __USER_LABEL_PREFIX__
+#define __USER_LABEL_PREFIX__ _
+#endif
+
+#ifndef __REGISTER_PREFIX__
+#define __REGISTER_PREFIX__
+#endif
+
+#ifndef __IMMEDIATE_PREFIX__
+#define __IMMEDIATE_PREFIX__ #
+#endif
+
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+/* Use the right prefix for global labels.  */
+
+#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
+
+#ifdef __ELF__
+#define FUNC(x) .type SYM(x),function
+#else
+/* The .proc pseudo-op is accepted, but ignored, by GAS.  We could just	
+   define this to the empty string for non-ELF systems, but defining it
+   to .proc means that the information is available to the assembler if
+   the need arises.  */
+#define FUNC(x) .proc
+#endif
+		
+#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
+
+#define IMM(x) CONCAT1 (__IMMEDIATE_PREFIX__, x)
+
+#define d0 REG(d0)
+#define d1 REG(d1)
+#define d2 REG(d2)
+#define d3 REG(d3)
+#define d4 REG(d4)
+#define d5 REG(d5)
+#define d6 REG(d6)
+#define d7 REG(d7)
+#define a0 REG(a0)
+#define a1 REG(a1)
+#define a2 REG(a2)
+#define a3 REG(a3)
+#define a4 REG(a4)
+#define a5 REG(a5)
+#define a6 REG(a6)
+#define a7 REG(a7)
+#define fp REG(fp)
+#define sp REG(sp)
+#define pc REG(pc)
+
+#define sr REG(sr)
diff --git a/configure b/configure
index 258ffad4ae5..71e355fea85 100755
--- a/configure
+++ b/configure
@@ -1738,10 +1738,10 @@ kos32)
 	_host_cpu=i686
 	_host_alias=kos32
 	;;
-m68k-atari-mint)
+m68k-atari-mint*)
 	_host_os=mint
 	_host_cpu=m68k
-	_host_alias=m68k-atari-mint
+	_host_alias=$_host
 	;;
 maemo)
 	_host_os=maemo
@@ -3704,12 +3704,12 @@ if test -n "$_host"; then
 			add_line_to_config_mk 'KOS32_SDK_DIR = '"${KOS32_SDK_DIR}"
 			_port_mk="backends/platform/sdl/kolibrios/kolibrios.mk"
 			;;
-		m68k-atari-mint)
+		m68k-atari-mint*)
 			# auto -> yes (overriden by $_release_build = yes)
-			if test "$_debug_build" = "no"; then
-				# --disable-debug
-				append_var LDFLAGS "-s"
-			fi
+			#if test "$_debug_build" = "no"; then
+			#	# --disable-debug
+			#	append_var LDFLAGS "-s"
+			#fi
 
 			# auto -> no
 			if test "$_optimizations" = "yes"; then
@@ -3724,8 +3724,8 @@ if test -n "$_host"; then
 				# --enable-release
 				append_var DEFINES  "-DNDEBUG"
 				#append_var DEFINES  "-DDISABLE_TEXT_CONSOLE"
-				append_var CXXFLAGS "-I$HOME/gnu-tools/m68000/m68k-atari-mint/sys-root/opt/mintlib-dlmalloc/include"
-				append_var LDFLAGS  "-L$HOME/gnu-tools/m68000/m68k-atari-mint/sys-root/opt/mintlib-dlmalloc/lib/m68020-60"
+				append_var CXXFLAGS "-I$($_host_alias-gcc -print-sysroot)/opt/mintlib-dlmalloc/include"
+				append_var LDFLAGS  "-L$($_host_alias-gcc -print-sysroot)/opt/mintlib-dlmalloc/lib/m68020-60"
 			fi
 
 			_seq_midi=no
diff --git a/graphics/blit/blit-atari.cpp b/graphics/blit/blit-atari.cpp
index fcdf60b4011..f2fc16d48b9 100644
--- a/graphics/blit/blit-atari.cpp
+++ b/graphics/blit/blit-atari.cpp
@@ -202,15 +202,15 @@ void copyBlit(byte *dst, const byte *src,
 #ifdef USE_MOVE16
 		if (hasMove16() && ((uintptr)src & (ALIGN - 1)) == 0 && ((uintptr)dst & (ALIGN - 1)) == 0) {
 			__asm__ volatile(
-			"	move.l	%2,d0\n"
-			"	lsr.l	#4,d0\n"
+			"	move.l	%2,%%d0\n"
+			"	lsr.l	#4,%%d0\n"
 			"	beq.b	3f\n"
 
-			"	moveq	#0x0f,d1\n"
-			"	and.l	d0,d1\n"
-			"	neg.l	d1\n"
-			"	lsr.l	#4,d0\n"
-			"	jmp		(2f,pc,d1.l*4)\n"
+			"	moveq	#0x0f,%%d1\n"
+			"	and.l	%%d0,%%d1\n"
+			"	neg.l	%%d1\n"
+			"	lsr.l	#4,%%d0\n"
+			"	jmp		(2f,%%pc,%%d1.l*4)\n"
 			"1:\n"
 			"	move16	(%0)+,(%1)+\n"
 			"	move16	(%0)+,(%1)+\n"
@@ -229,14 +229,14 @@ void copyBlit(byte *dst, const byte *src,
 			"	move16	(%0)+,(%1)+\n"
 			"	move16	(%0)+,(%1)+\n"
 			"2:\n"
-			"	dbra	d0,1b\n"
+			"	dbra	%%d0,1b\n"
 			// handle also the unlikely case when 'dstPitch'
 			// is not divisible by 16 but 'src' and 'dst' are
 			"3:\n"
-			"	moveq	#0x0f,d0\n"
-			"	and.l	%2,d0\n"
-			"	neg.l	d0\n"
-			"	jmp		(4f,pc,d0.l*2)\n"
+			"	moveq	#0x0f,%%d0\n"
+			"	and.l	%2,%%d0\n"
+			"	neg.l	%%d0\n"
+			"	jmp		(4f,%%pc,%%d0.l*2)\n"
 			// only 15x move.b as 16 would be handled above
 			"	move.b	(%0)+,(%1)+\n"
 			"	move.b	(%0)+,(%1)+\n"
@@ -269,26 +269,26 @@ void copyBlit(byte *dst, const byte *src,
 		if (hasMove16() && ((uintptr)src & (ALIGN - 1)) == 0 && ((uintptr)dst & (ALIGN - 1)) == 0
 				&& (srcPitch & (ALIGN - 1)) == 0 && (dstPitch & (ALIGN - 1)) == 0) {
 			__asm__ volatile(
-			"	move.l	%2,d0\n"
+			"	move.l	%2,%%d0\n"
 
-			"	moveq	#0x0f,d1\n"
-			"	and.l	d0,d1\n"
-			"	neg.l	d1\n"
-			"	lea		(4f,pc,d1.l*2),a0\n"
-			"	move.l	a0,a1\n"
+			"	moveq	#0x0f,%%d1\n"
+			"	and.l	%%d0,%%d1\n"
+			"	neg.l	%%d1\n"
+			"	lea		(4f,%%pc,%%d1.l*2),%%a0\n"
+			"	move.l	%%a0,%%a1\n"
 
-			"	lsr.l	#4,d0\n"
+			"	lsr.l	#4,%%d0\n"
 			"	beq.b	3f\n"
 
-			"	moveq	#0x0f,d1\n"
-			"	and.l	d0,d1\n"
-			"	neg.l	d1\n"
-			"	lea		(2f,pc,d1.l*4),a0\n"
-			"	lsr.l	#4,d0\n"
-			"	move.l	d0,d1\n"
+			"	moveq	#0x0f,%%d1\n"
+			"	and.l	%%d0,%%d1\n"
+			"	neg.l	%%d1\n"
+			"	lea		(2f,%%pc,%%d1.l*4),%%a0\n"
+			"	lsr.l	#4,%%d0\n"
+			"	move.l	%%d0,%%d1\n"
 			"0:\n"
-			"	move.l	d1,d0\n"
-			"	jmp		(a0)\n"
+			"	move.l	%%d1,%%d0\n"
+			"	jmp		(%%a0)\n"
 			"1:\n"
 			"	move16	(%0)+,(%1)+\n"
 			"	move16	(%0)+,(%1)+\n"
@@ -307,10 +307,10 @@ void copyBlit(byte *dst, const byte *src,
 			"	move16	(%0)+,(%1)+\n"
 			"	move16	(%0)+,(%1)+\n"
 			"2:\n"
-			"	dbra	d0,1b\n"
+			"	dbra	%%d0,1b\n"
 			// handle (w * bytesPerPixel) % 16
 			"3:\n"
-			"	jmp		(a1)\n"
+			"	jmp		(%%a1)\n"
 			// only 15x move.b as 16 would be handled above
 			"	move.b	(%0)+,(%1)+\n"
 			"	move.b	(%0)+,(%1)+\n"
diff --git a/ports.mk b/ports.mk
index a2a66af379c..19f623f2a9d 100644
--- a/ports.mk
+++ b/ports.mk
@@ -61,9 +61,6 @@ dist-generic: $(EXECUTABLE) $(PLUGINS)
 	mkdir -p ./dist-generic/scummvm/doc
 	rm -f ./dist-generic/scummvm/$(EXECUTABLE)
 	cp $(EXECUTABLE) ./dist-generic/scummvm
-ifeq ($(BACKEND), atari)
-	m68k-atari-mint-flags -S ./dist-generic/scummvm/$(EXECUTABLE)
-endif
 	cp $(DIST_FILES_DOCS) ./dist-generic/scummvm/doc
 	cp $(DIST_FILES_THEMES) ./dist-generic/scummvm/data
 ifdef DIST_FILES_ENGINEDATA


Commit: fb8528ac77cb77e0a2c8fe9ddac2a0563595ccd9
    https://github.com/scummvm/scummvm/commit/fb8528ac77cb77e0a2c8fe9ddac2a0563595ccd9
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-09-24T17:48:54+02:00

Commit Message:
BACKENDS: ATARI: Various fixes

- composer unaligned pitch fix
- error() doesn't work while in OSystem_Atari c-tor
- when a crash occurs, restore at least the cursor
- fix a crash when "data" doesn't exist

Changed paths:
    backends/graphics/atari/atari-graphics.cpp
    backends/platform/atari/osystem_atari.cpp
    backends/platform/atari/osystem_atari.h


diff --git a/backends/graphics/atari/atari-graphics.cpp b/backends/graphics/atari/atari-graphics.cpp
index 7c9c1ea2ded..c77dbaabbca 100644
--- a/backends/graphics/atari/atari-graphics.cpp
+++ b/backends/graphics/atari/atari-graphics.cpp
@@ -495,7 +495,11 @@ void AtariGraphicsManager::updateScreen() {
 			// Surface::init() & delete[] Surface::getPixels() just use this hack.
 			const Common::String engineId = activeDomain->getValOrDefault("engineid");
 			const Common::String gameId = activeDomain->getValOrDefault("gameid");
-			if (engineId == "hypno"
+
+			debug("checking %s/%s", engineId.c_str(), gameId.c_str());
+
+			if (engineId == "composer"
+				|| engineId == "hypno"
 				|| engineId == "mohawk"
 				|| engineId == "parallaction"
 				|| engineId == "private"
diff --git a/backends/platform/atari/osystem_atari.cpp b/backends/platform/atari/osystem_atari.cpp
index 3001ce4b7aa..d1542c92e42 100644
--- a/backends/platform/atari/osystem_atari.cpp
+++ b/backends/platform/atari/osystem_atari.cpp
@@ -35,6 +35,8 @@
 #define FORBIDDEN_SYMBOL_EXCEPTION_stderr
 #define FORBIDDEN_SYMBOL_EXCEPTION_stdout
 #define FORBIDDEN_SYMBOL_EXCEPTION_time_h
+#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf
+#define FORBIDDEN_SYMBOL_EXCEPTION_exit
 
 #include "backends/platform/atari/osystem_atari.h"
 
@@ -75,6 +77,8 @@ extern void nf_init(void);
 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;
@@ -107,6 +111,10 @@ static void critical_restore() {
 	// somehow manipulates the same memory area used for the critical handler's stack
 	// what causes v_clsvwk() never returning and leading to a bus error (and another
 	// critical_restore() called...)
+	if (s_app_id != -1) {
+		// ok, restore mouse cursor at least
+		graf_mouse(M_ON, NULL);
+	}
 }
 
 // called on normal program termination (via exit() or returning from main())
@@ -134,7 +142,8 @@ OSystem_Atari::OSystem_Atari() {
 	vdo >>= 16;
 
 	if (vdo != VDO_TT && vdo != VDO_FALCON) {
-		error("ScummVM requires Atari TT/Falcon compatible video");
+		fprintf(stderr, "ScummVM requires Atari TT/Falcon compatible video\n");
+		exit(EXIT_FAILURE);
 	}
 
 	s_tt = (vdo == VDO_TT);
@@ -153,7 +162,8 @@ OSystem_Atari::OSystem_Atari() {
 	mch >>= 16;
 
 	if (mch == MCH_ARANYM && Getcookie(C_fVDI, NULL) == C_FOUND) {
-		error("Disable fVDI, ScummVM uses XBIOS video calls");
+		fprintf(stderr, "Disable fVDI, ScummVM uses XBIOS video calls\n");
+		exit(EXIT_FAILURE);
 	}
 
 	_KBDVECS *kbdvecs = Kbdvbase();
@@ -230,7 +240,7 @@ OSystem_Atari::~OSystem_Atari() {
 		g_atari_old_kbdvec = s_mousevec = nullptr;
 	}
 
-	if (_app_id != -1) {
+	if (s_app_id != -1) {
 		//wind_update(END_UPDATE);
 
 		// redraw screen
@@ -247,8 +257,8 @@ OSystem_Atari::~OSystem_Atari() {
 }
 
 void OSystem_Atari::initBackend() {
-	_app_id = appl_init();
-	if (_app_id != -1) {
+	s_app_id = appl_init();
+	if (s_app_id != -1) {
 		// get the ID of the current physical screen workstation
 		int16 dummy;
 		_vdi_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
@@ -392,9 +402,12 @@ void OSystem_Atari::logMessage(LogMessageType::Type type, const char *message) {
 void OSystem_Atari::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
 	{
 		Common::FSDirectory currentDirectory{ getFilesystemFactory()->makeCurrentDirectoryFileNode()->getPath() };
-		Common::FSNode dataNode = currentDirectory.getSubDirectory("data")->getFSNode();
-		if (dataNode.exists() && dataNode.isDirectory() && dataNode.isReadable()) {
-			s.addDirectory(dataNode.getPath(), dataNode, priority);
+		Common::FSDirectory *dataDirectory = currentDirectory.getSubDirectory("data");
+		if (dataDirectory) {
+			Common::FSNode dataNode = dataDirectory->getFSNode();
+			if (dataNode.exists() && dataNode.isDirectory() && dataNode.isReadable()) {
+				s.addDirectory(dataNode.getPath(), dataNode, priority);
+			}
 		}
 	}
 #ifdef DATA_PATH
diff --git a/backends/platform/atari/osystem_atari.h b/backends/platform/atari/osystem_atari.h
index 00ad5af1945..786ff6bf4b3 100644
--- a/backends/platform/atari/osystem_atari.h
+++ b/backends/platform/atari/osystem_atari.h
@@ -55,7 +55,6 @@ private:
 	bool _timerInitialized = false;
 	bool _useNullMixer = false;
 
-	int _app_id = -1;
 	int16 _vdi_handle;
 	int _vdi_width;
 	int _vdi_height;


Commit: d4d9307a6923dbed67c524988b2755321fa72018
    https://github.com/scummvm/scummvm/commit/d4d9307a6923dbed67c524988b2755321fa72018
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-09-24T17:48:54+02:00

Commit Message:
BACKENDS: ATARI: Use atari_sound_setup code

Changed paths:
    backends/mixer/atari/atari-mixer.cpp


diff --git a/backends/mixer/atari/atari-mixer.cpp b/backends/mixer/atari/atari-mixer.cpp
index 67d889ccbbb..8b500428089 100644
--- a/backends/mixer/atari/atari-mixer.cpp
+++ b/backends/mixer/atari/atari-mixer.cpp
@@ -22,7 +22,6 @@
 #include "backends/mixer/atari/atari-mixer.h"
 
 #include <math.h>
-#include <mint/cookie.h>
 #include <mint/falcon.h>
 #include <mint/osbind.h>
 #include <mint/ostruct.h>
@@ -30,12 +29,14 @@
 #include "common/config-manager.h"
 #include "common/debug.h"
 
+// see https://github.com/mikrosk/atari_sound_setup
+#include "../../../../atari_sound_setup.git/atari_sound_setup.h"
+
 #define DEFAULT_OUTPUT_RATE 24585
+#define DEFAULT_SAMPLES 2048	// 83ms
 
 void AtariAudioShutdown() {
-	Sndstatus(SND_RESET);
-	Soundcmd(ADDERIN, ADCIN);	// restore key click
-	Unlocksnd();
+	AtariSoundSetupDeinitXbios();
 }
 
 AtariMixerManager::AtariMixerManager() : MixerManager() {
@@ -66,142 +67,23 @@ AtariMixerManager::~AtariMixerManager() {
 }
 
 void AtariMixerManager::init() {
-    long cookie, stfa = 0;
-	bool useDevconnectReturnValue = Getcookie(C__SND, &cookie) == C_FOUND && (cookie & SND_EXT) != 0;
-
-	int clk;
-
-	if (Locksnd() < 0)
-		error("Sound system is locked");
-
-	// try XBIOS APIs which do not set SND_EXT in _SND
-    useDevconnectReturnValue |= (Getcookie(C_STFA, &stfa) == C_FOUND);	// STFA
-	useDevconnectReturnValue |= (Getcookie(C_McSn, &cookie) == C_FOUND);	// X-SOUND, MacSound
-
-    bool forceSoundCmd = false;
-    if (stfa) {
-        // see http://removers.free.fr/softs/stfa.php#STFA
-        struct STFA_control {
-            uint16 sound_enable;
-            uint16 sound_control;
-            uint16 sound_output;
-            uint32 sound_start;
-            uint32 sound_current;
-            uint32 sound_end;
-            uint16 version;
-            uint32 old_vbl;
-            uint32 old_timerA;
-            uint32 old_mfp_status;
-            uint32 stfa_vbl;
-            uint32 drivers_list;
-            uint32 play_stop;
-            uint16 timer_a_setting;
-            uint32 set_frequency;
-            uint16 frequency_treshold;
-            uint32 custom_freq_table;
-            int16 stfa_on_off;
-            uint32 new_drivers_list;
-            uint32 old_bit_2_of_cookie_snd;
-            uint32 it;
-        } __attribute__((packed));
-
-        STFA_control *stfaControl = (STFA_control *)stfa;
-        if (stfaControl->version < 0x0200) {
-            error("Your STFA version is too old, please upgrade to at least 2.00");
-        }
-        if (stfaControl->stfa_on_off == -1) {
-            // emulating 16-bit playback, force TT frequencies
-            enum {
-                MCH_ST = 0,
-                MCH_STE,
-                MCH_TT,
-                MCH_FALCON,
-                MCH_CLONE,
-                MCH_ARANYM
-            };
-
-            long mch = MCH_ST<<16;
-            Getcookie(C__MCH, &mch);
-            mch >>= 16;
-
-            if (mch == MCH_TT) {
-                debug("Forcing STE/TT compatible frequency");
-                forceSoundCmd = true;
-            }
-        }
-    }
-
-	// reset connection matrix (and other settings)
-	Sndstatus(SND_RESET);
-
-	int diff50, diff33, diff25, diff20, diff16, diff12, diff10, diff8, diff6;
-	diff50 = abs(49170 - (int)_outputRate);
-	diff33 = abs(32780 - (int)_outputRate);
-	diff25 = abs(24585 - (int)_outputRate);
-	diff20 = abs(19668 - (int)_outputRate);
-	diff16 = abs(16390 - (int)_outputRate);
-	diff12 = abs(12292 - (int)_outputRate);
-	diff10 = abs(9834  - (int)_outputRate);
-	diff8  = abs(8195  - (int)_outputRate);
-
-	if (diff50 < diff33) {
-		_outputRate = 49170;
-		clk = CLK50K;
-	} else if (diff33 < diff25) {
-		_outputRate = 32780;
-		clk = CLK33K;
-	} else if (diff25 < diff20) {
-		_outputRate = 24585;
-		clk = CLK25K;
-	} else if (diff20 < diff16) {
-		_outputRate = 19668;
-		clk = CLK20K;
-	} else if (diff16 < diff12) {
-		_outputRate = 16390;
-		clk = CLK16K;
-	} else if (diff12 < diff10) {
-		_outputRate = 12292;
-		clk = CLK12K;
-	} else if (diff10 < diff8) {
-		_outputRate = 9834;
-		clk = CLK10K;
-	} else {
-		_outputRate = 8195;
-		clk = CLK8K;
+	AudioSpec desired, obtained;
+
+	desired.frequency = _outputRate;
+	desired.channels = 2;
+	desired.format = AudioFormatSigned16MSB;
+	desired.samples = DEFAULT_SAMPLES;
+
+	if (!AtariSoundSetupInitXbios(&desired, &obtained)) {
+		error("Sound system is not available");
 	}
 
-	// first try to use Devconnect() with a Falcon prescaler
-    if (forceSoundCmd || Devconnect(DMAPLAY, DAC, CLK25M, clk, NO_SHAKE) != 0) {
-		// the return value is broken on Falcon
-		if (useDevconnectReturnValue) {
-			if (Devconnect(DMAPLAY, DAC, CLK25M, CLKOLD, NO_SHAKE) == 0) {
-				// calculate compatible prescaler
-				diff50 = abs(50066 - (int)_outputRate);
-				diff25 = abs(25033 - (int)_outputRate);
-				diff12 = abs(12517 - (int)_outputRate);
-				diff6  = abs(6258  - (int)_outputRate);
-
-				if (diff50 < diff25) {
-					_outputRate = 50066;
-					clk = PRE160;
-				} else if (diff25 < diff12) {
-					_outputRate = 25033;
-					clk = PRE320;
-				} else if (diff12 < diff6) {
-					_outputRate = 12517;
-					clk = PRE640;
-				} else {
-					_outputRate = 6258;
-					clk = PRE1280;
-				}
-
-				Soundcmd(SETPRESCALE, clk);
-			} else {
-				error("Devconnect() failed");
-			}
-		}
+	if (obtained.channels != 2 && obtained.format != AudioFormatSigned16MSB) {
+		error("Sound system currently supports only 16-bit signed stereo samples (big endian)");
 	}
 
+	_outputRate = obtained.frequency;
+
 	ConfMan.setInt("output_rate", _outputRate);
 	debug("setting %d Hz mixing frequency", _outputRate);
 
@@ -229,8 +111,6 @@ void AtariMixerManager::init() {
 	_atariPhysicalSampleBuffer = _atariSampleBuffer;
 	_atariLogicalSampleBuffer = _atariSampleBuffer + _atariSampleBufferSize;
 
-	Setmode(MODE_STEREO16);
-	Soundcmd(ADDERIN, MATIN);
 	Setbuffer(SR_PLAY, _atariSampleBuffer, _atariSampleBuffer + 2 * _atariSampleBufferSize);
 
 	_samplesBuf = new uint8[_samples * 4];
@@ -266,7 +146,7 @@ bool AtariMixerManager::notifyEvent(const Common::Event &event) {
 		debug("silencing the mixer");
 		return false;
 	default:
-		[[fallthrough]];
+		break;
 	}
 
 	return false;




More information about the Scummvm-git-logs mailing list