58 Commits

Author SHA1 Message Date
Miro Kropacek 9bd91b4131 BACKENDS: ATARI: Remove atari_debug 2026-04-20 01:47:37 +02:00
Miro Kropacek 2dd0b13aa3 BACKENDS: ATARI: Fix overlay hiding when starting game from command line 2025-11-20 10:11:48 +10:00
Miro Kropacek 9a438b6492 BACKENDS: ATARI: Remove harmful assert
Cursor's srcSurface is formally PIXELFORMAT_CLUT8 but this is not true,
it's 4-bit or 8-bit bitplanes. On the other hand, AtariSurface is
PIXELFORMAT_CLUT8, PIXELFORMAT_RGB332 or PIXELFORMAT_RGB121 so these
can't be asserted for equality.
2025-07-04 14:14:46 +02:00
Miro Kropacek 3f47c7a8ce BACKENDS: ATARI: Let Cursor access only AtariSurface instead of Screen 2025-06-25 23:50:35 +02:00
Miro Kropacek e575d1360e BACKENDS: ATARI: Make purpose of _xOffset more explicit
This also cleans up Screen::reset() a bit.

Get rid of the reset cursor flag, it's not that useful in the overlay.
2025-06-25 23:50:35 +02:00
Miro Kropacek f27f045aac BACKENDS: ATARI: Remove references to AtariGraphicsManager from Screen and Cursor 2025-06-25 23:50:35 +02:00
Miro Kropacek ee437e2a42 BACKENDS: ATARI: Move alignRect from AtariGraphicsManager to AtariSurface
And make it static.
2025-06-25 23:50:35 +02:00
Miro Kropacek 0520570a7b BACKENDS: ATARI: Move getBitsPerPixel from AtariGraphicsManager to AtariSurface 2025-06-25 23:50:35 +02:00
Miro Kropacek 3dd96ec7c5 BACKENDS: ATARI: Use hardware-accelerated cursor blitting 2025-06-25 23:50:34 +02:00
Miro Kropacek b3074272da BACKENDS: ATARI: Separate SuperVidel code
- Introduce AtariSurface: a surface which represents either a
  bitplane-based or pixel-based surface (on SuperVidel, as an inherited
  SuperVidelSurface). Screen::surf / Screen::offsettedSurf are its
  instances.

- Graphics::Surface::create / free now handle all Atari-related surfaces
  via dlmalloc: ST RAM (TT/Falcon), VRAM (SuperVidel - 0xA0xxxxxx) and
  VRAM for generic surfaces (SuperBlitter - 0xA1xxxxxx or ST/TT RAM).
  This allowed me to remove all the hacky stuff from atari-graphics and
  atari-superblitter.h.

- blit-atari.cpp now contains only blitting code
  (SuperBlitter/move16/fallback), SV code is in
  atari-supervidel.{cpp,h}.

- Take advantage of Common::ScopedPtr and Graphics::ManagedSurface's
  dispose flag for Screen::surf as well Graphics::ManagedSurface's
  ownership for Screen::offsettedSurf.

- Improve recoverability if an error/assert happens in
  AtariGraphicsManager's c-tor/d-tor.
2025-06-25 23:50:34 +02:00
Miro Kropacek 28507ee8a7 BACKENDS: ATARI: Cleanup fillScreen()
The workaround for Eco Quest was misguided, I was updating whole screen
every time!
2025-06-25 23:50:34 +02:00
Miro Kropacek d452beff82 BACKENDS: ATARI: Remove g_unalignedPitch workaround
It causes more harm than good and I don't think it helps with
performance that much either. Its only semi-valid use case was C2P
direct rendering for sprites (which nobody uses). However, direct
rendering in its current form is about to be removed in a near future,
so...
2025-06-25 23:50:34 +02:00
Miro Kropacek a09a765580 BACKEND: ATARI: Fix cursor reset position 2025-05-07 17:53:54 +02:00
Miro Kropacek 6921062590 BACKENDS: ATARI: Fix for SCI32 games
After all, the issue wasn't the engine but not handling its palette
updates fast enough. Now it looks much better and the cursor moves fine
as well.
2025-05-07 17:53:54 +02:00
Miro Kropacek 264f67cb83 BACKENDS: ATARI: Fix a crash
If error() was called in (Atari)GraphicsManager's c-tor, its d-tor
wouldn't be called, leaving the VBL handler uninitialised.
2025-05-07 17:45:03 +02:00
Miro Kropacek 5680536655 BACKENDS: ATARI: Additional fixes for cursor background
- leftovers after highlighted dirty rectangle

- not updating _surface if moving to fast left/right from screen borders
  (_width == _srcRect.width())

- not drawing cursor if repeatedly intersecting with a refreshing dirty
  rect

- leftover rectangle when leaving game overlay to the launcher

- massive simplification
2025-04-20 21:33:15 +02:00
Miro Kropacek 4afb49840e BACKENDS: ATARI: Initialize overlay cursor properly
showOverlay() and therefore _screen[kOverlayBuffer]->reset() isn't
called explicitly on init.
2025-04-20 21:33:15 +02:00
Miro Kropacek 3eb17e58e3 BACKENDS: ATARI: Don't attempt direct rendering with unsupported engines
If sprites with implicit pitch % 16 == 0 are corrupted in single/triple
buffering, it doesn't make sense to try them unaligned in direct
rendering.
2025-04-20 21:33:15 +02:00
Miro Kropacek 564c503c3d BACKENDS: ATARI: Allow width non-divisible by 16 if not direct rendering
This fixes Phantasmagoria demo which uses 630x450.
2025-04-20 21:33:15 +02:00
Miro Kropacek cca60feaca BACKENDS: ATARI: Fix isOverlayDirectRendering()
When leaving the overlay, ConfMan.getActiveDomain() is already set. Use
OSystem::engineInit and OSystem::engineDone in your favour.
2025-04-20 21:33:15 +02:00
Miro Kropacek 3ab84a2cf9 BACKENDS: ATARI: Fix incorrectly restored cursor background 2025-04-20 21:33:15 +02:00
Miro Kropacek 6a919c04ab BACKENDS: ATARI: Cleanup usage of bitsPerPixel 2025-04-20 21:33:15 +02:00
Miro Kropacek e53fc61ceb BACKENDS: ATARI: Move g_unalignedPitch check into OSystem::engineInit() 2025-04-20 21:33:15 +02:00
Miro Kropacek bbc922a870 BACKENDS: ATARI: Fix invisible cursor in themed launcher
Follow your own advice from atari-cursor.h:

// Global state consists of:
// - palette (used for the overlay only atm)
// - shape (surface, dimensions, hotspot, keycolor)
// - visibility
// These always get updates by ScummVM, no need to differentiate between
engines and the overlay.
2025-04-20 21:33:15 +02:00
Miro Kropacek a4ed12b04d BACKENDS: ATARI: Cleanup overlay code
Pretending that the manager starts in the overlay mode was really
confusing.

Also, the concept of _workScreen seemed great in theory but lead to
various subtle errors which were very hard to debug (related to cursor
handling, resolution changing etc).
2024-12-30 18:37:55 +01:00
Miro Kropacek b779b2038f JANITORIAL: ATARI: Unify enum names 2024-12-30 18:37:54 +01:00
Miro Kropacek feef4e1bf1 BACKENDS: ATARI: Final screen resolution changes
- seamless resolution/palette switching (at least in theory, it still
  isn't artifact-free, no clue why)

- bugfixes (shake offset, some s_screenSurf corner cases)

- simplification the triple-buffering code
2024-11-21 11:31:25 +01:00
Miro Kropacek 10665fb723 BACKENDS: ATARI: Use DISABLE_TEXT_CONSOLE for release builds
This shaves off a good 800 KB from all the engines. However, do keep
local atari debug messages for diagnostic purposes.

Also, use natfeats for debug output when possible else the classic
stdout/stderr (not both as before).
2024-11-21 11:31:25 +01:00
Miro Kropacek 8bbc31aa6d BACKENDS: ATARI: Bugfixes
- optimize fillScreen(): Eco Quest calls it way too often with 1x1 rects

- don't disable Cursor::isChanged() flags on !isVisible(), that leads to
  skipping of _surface creation in some cases

- handle properly any number of parameters between beginGFXTransaction
  and endGFXTransaction

- clear the work buffer when exiting a game to avoid showing it when
  next game shows an error upon startup
2024-11-13 21:41:01 +01:00
Miro Kropacek 16dcfb7a69 BACKENDS: ATARI: Fix _checkUnalignedPitch
It wasn't set / checked properly after the refactor.
2024-11-13 21:41:01 +01:00
Miro Kropacek dd49c9e3ce BACKENDS: ATARI: QoL improvements
- fixed aspect ratio correction (overlay destroyed
  its state, keyboard shortcut didn't always work),
  as well as significantly sped it up on VGA and
  SuperVidel

- smoother transitions between video modes

- reduce the number of video mode changes

- fixed a few extreme cases when triple buffering
  could lose an update

- lighter ST RAM usage in the lite build

- removed hardware accessing init/deinit routines
2024-07-15 19:42:51 +02:00
Miro Kropacek 0c77d67845 BACKENDS: ATARI: Make Cursor Screen's property
Instead of having one globally in AtariGraphicsManager. This simplifies
code and cleans up a lot of dark corners in AtariGraphicsManager.

A slight disadvantage is that now the cursor surface has be to converted
for each buffer.
2024-07-15 19:42:51 +02:00
Miro Kropacek c7bc03d4f4 BACKENDS: ATARI: Move Screen outside AtariGraphicsManager 2024-07-15 19:42:51 +02:00
Miro Kropacek 957aa15e7e BACKENDS: ATARI: Move Cursor outside AtariGraphicsManager 2024-07-15 19:42:51 +02:00
Miro Kropacek f41a678ba1 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)
2024-02-24 03:54:54 +01:00
Miro Kropacek 276103b0aa BACKENDS: ATARI: Fix a crash
_offsettedSurf must have the original screen dimensions, similar as done in
AtariGraphicsManager::Screen::reset().

Strangely, this bug was reproducible only in MagiC and not in FreeMiNT+MP.
2024-01-28 21:59:13 +01:00
Le Philousophe bfc61439fb COMMON: Make themepath a Path object 2023-12-24 13:19:25 +01:00
Miro Kropacek fb8528ac77 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
2023-09-24 17:48:54 +02:00
Miro Kropacek b510eff336 BACKENDS: ATARI: Implement aspect ratio correction 2023-09-24 17:48:54 +02:00
Miro Kropacek 46939cca9b BACKENDS: ATARI: Fix regression in unlockScreen() 2023-08-12 17:38:49 +02:00
Miro Kropacek 7e3b9cceec BACKENDS: ATARI: Direct rendering support
Similar to SuperVidel's but requires an additional C2P pass.

Also, a few optimizations added like cursor is being assumed to be in
a persistent memory so we don't copy it over. And it's using a mask
instead of key.

This graphics mode is not perfect though and works reliably only with
source surfaces allocated via Surface::init() otherwise wrong memory
location is being read.

Still, can gain quite a few CPU cycles, especially on 640x480 screens.
2023-08-12 17:38:49 +02:00
Cameron Cawley d8cca29783 BACKENDS: Allow filling part of the screen with OSystem::fillScreen 2023-08-06 23:03:46 +02:00
Miro Kropacek d9a5de0fe6 BACKEND: ATARI: Screen shaking and some fixes
- surface setup for optimized 4-bit C2P routine wasn't properly detected

- STFA pretends to support Falcon sampling frequencies on TT leading to
  suboptimal sample mixing

- delayMillis() should check also for other events (fixes Future Wars)
  but avoid doing it for SCI as its MIDI timer would call itself in a
  recursive loop

- SuperVidel doesn't need to use VsetScreen() in VBL anymore

- Wetlands, Teen Agent, Shivers and Private Eye need non-aligned
  surface  widths

- However Wetlands and Private Eye use setCursorPalette, see
  https://bugs.scummvm.org/ticket/14524

- Added warning for Phantasmagoria's 630x450, nothing can be done there
  as the game also requires non-aligned surfaces and at the same time
  the buffer has to be aligned on 16 bytes.

- BDF scaling disabled by default
2023-07-19 22:22:11 +02:00
Miro Kropacek d9eee7906a BACKENDS: ATARI: Use unordered_set for dirty rects
This allows efficient redraw of surfaces which don't change their
position too much.
2023-06-15 22:58:13 +02:00
Miro Kropacek 5537759c53 BACKENDS: ATARI: Rework
- Atari TT support
- all video and audio is now handled via XBIOS
- reworked IKBD handling using Kbdvbase vectors, esp. Kbdvec()
- video uses proper triple buffer
- arbitrary game screen size support
- many fixes and optimizations
2023-06-15 22:57:55 +02:00
Miro Kropacek 62d3a3c16e BACKENDS: ATARI: work around engines with unaligned pitch
Too complex to investigate so don't align every 8-bit surface on a
16-byte boundary there.
2023-06-10 23:27:57 +02:00
Miro Kropacek a6a5b8ab42 BACKENDS: ATARI: Handle themes in installation script
- "fat" version uses repacked (zip -0) archives; also separate "data"
  and "themes" folders
- "slim" version doesn't use any external themes (for speed reasons)
2023-05-11 00:03:44 +02:00
Miro Kropacek aa8935e447 BACKENDS: ATARI: grabOverlay() uses accelerated blitting 2023-05-10 22:59:56 +02:00
Miro Kropacek 1870433daf BACKENDS: ATARI: Refactor & optimize dirty rects
This was long overdue. From my observation dirty rects don't need much
care, usually game engines already prepare them in a good shape (no
overlapping).

Also the overhead of calling the rect version of C2P isn't as big as I
was fearing, 256 64x64 rectangles are blitted roughly as quickly
as blitting one 1 MB block.

Removal of the rects traversal significantly speeds up Eco Quest for
instance.
2023-04-08 20:27:44 +02:00
Miro Kropacek a4e85dab01 BACKENDS: ATARI: Remove double buffering & vsync
ScummVM engines are not built for synchronous screen locking (i.e.
updateScreen() can't be really used for any sort of blocking updates
otherwise performance suffers).

Single buffering now means deliberate tearing as a speed optimization
and triple buffering provides a tearingless picture with slight overhead.
2023-04-08 20:27:43 +02:00