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.
Previous implementation had to create a new surface every time srcRect
has been changed and as a bonus, it would (harmlessly but still) do a
read-modify-write past the screen buffer.
- 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.
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...
- 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
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.
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).
- 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
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).
- 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
- 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
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.
- 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)
_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.
- 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
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.