Skip to content

Enhancement - AGA Support.#268

Open
Vairn wants to merge 94 commits intoAmigaPorts:mainfrom
Vairn:AGA
Open

Enhancement - AGA Support.#268
Vairn wants to merge 94 commits intoAmigaPorts:mainfrom
Vairn:AGA

Conversation

@Vairn
Copy link
Copy Markdown
Contributor

@Vairn Vairn commented Apr 22, 2026

Description

This PR merges the AGA branch back into main.

It brings in:

  • new sprite/advanced sprite manager work
  • viewport/camera/scrollbuffer updates
  • palette/extview utility changes
  • related docs updates
  • the ability to create code targeting AGA chipsets, including support for screens up to 8bpp

AGA support is enabled by configuring CMake with -DACE_USE_AGA_FEATURES=ON.

Closes #151.

Motivation and Context

The AGA work is now broad enough that keeping it separate is slowing everything down.
Merging now keeps development on one branch and prevents further drift/conflicts.

How Has This Been Tested?

  • Clean configure + build succeeds
  • Updated modules compile together (sprite, advancedsprite, viewport, camera, palette, extview)
  • Manual runtime smoke test completed for sprite rendering and viewport scrolling behavior
  • Verified AGA-targeted build path using -DACE_USE_AGA_FEATURES=ON, including 8bpp screen support
  • Docs reviewed against current APIs

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Vairn and others added 30 commits June 3, 2021 10:24
UNTESTED but I loaded a 256 colour bitmap or 4.
Fixed bitshift for AGA Palette.
finished my comment...
This reverts commit 4468737.
Allocate the ram for the palette depending on the Depth,
AGA and ECS use different palette types.
Now Germz shows the correct colours again.

Free's the palette memory when the view gets destroyed.
removed union, use the two varibles.
Added a feof to mini_std. worked for my little test, probs not optimised.
Creating the View, you now need to specify if your using the AGA chipset.
Now you can use 24bit colours on all bit plane counts.

(in theory)
Added KILLEHB if viewport has AGA enabled and is 6 bpp.
Removed Extra AGA Palette field.
… to setup the display.

AGA needs more time so the value needs to be smaller.
This commit refactors the code in palette.cpp to support AGA Palette. Specifically, it adds a new else block that writes alpha and color values for AGA Palette.
The commit fixes a bug where the wrong variable was being passed to logWrite function. The variable name has been corrected to match the intended value.
This commit updates the value of s_pCopperWaitXByBitplanes[8] from 0xC6 to 0xA0. This change is made to optimize fetchmodes for AGA in 8bpp mode.
Enhance README.md to include information about AGA support and its setup. Add AGA support link in docs/README.md and provide build instructions for enabling AGA features in docs/installing/ace.md. Update docs/programming/view.md with details on AGA tags for view/viewport creation.
@tehKaiN
Copy link
Copy Markdown
Member

tehKaiN commented Apr 22, 2026

Great! I'll check if my games are breaking on this branch, and if not then we're more or less ready to go.

I also encourage all bystanders to do the same.

@kwn
Copy link
Copy Markdown
Contributor

kwn commented Apr 23, 2026

I want this PR to be merged so badly :D Thanks for adding it!!

@Vairn
Copy link
Copy Markdown
Contributor Author

Vairn commented Apr 23, 2026

I want this PR to be merged so badly :D Thanks for adding it!!

Well you can grab my fork of ACE and do some testing so we know it is stable enough to merge.

More testing faster merging.

https://github.com/Vairn/ACE/tree/AGA

@kwn
Copy link
Copy Markdown
Contributor

kwn commented Apr 23, 2026

The thing is, that I don't have anything to test yet ;) I was wondering if I should rewrite my game using ACE, as I'm struggling to make my scroller working without occasional glitches - however, the game uses AGA features. Up until now I didn't consider ACE, but with that PR I'd need to re-thing it.

Out of curiosity

  • Does fmode 1 and 3 work with infinite scroller?
  • Are all 8 hardware sprites available in fmode 1/3? Is it even possible with early DDF?

@Vairn
Copy link
Copy Markdown
Contributor Author

Vairn commented Apr 23, 2026 via email

@Vairn
Copy link
Copy Markdown
Contributor Author

Vairn commented Apr 23, 2026

Out of curiosity

  • Does fmode 1 and 3 work with infinite scroller? It should, infinite scrollers can have issues with timing and stuff even on Ocs/ECS.
  • Are all 8 hardware sprites available in fmode 1/3? Is it even possible with early DDF?
    Yes and no, yes it is possible, but you may have dma fetch issues with timing.

In FMODE 3:
Bitplane DMA tries to grab multiple adjacent slots
Sprites need specific exact slots
If bitplane DMA “locks” the bus too long: Sprite fetch misses its deadline window.

Even though priority says:
Sprites > Bitplanes
In reality:
FMODE 3 packs bitplane DMA tightly
Arbitration granularity isn't infinite
If timing margins are exceeded:
Later sprites lose fetch slots
Typical failure pattern:
Sprite
Stability
SPR0–2
Solid
SPR3–5
Risky
SPR6–7
First to break.

With everything Amiga there is always a compromise.

I normally think if you want fmode 3, then you might as well think you've lost the last two sprites.

But as with anything mileage may vary.

Btw, I haven't really tested fmode 1, just mode 3.

@kwn
Copy link
Copy Markdown
Contributor

kwn commented Apr 24, 2026

Thanks for the response. Based on my experience, even with fmode = 1 I'm only able to use up to 5 slots on both FS-UAE and real Amiga. The remaining ones don't get the DMA cycles due to the early DDF and pre-fetch.

Thanks for sharing the link to the Discord. I'm a real boomer and never managed to use it. I'll take a look.

Vairn and others added 2 commits April 25, 2026 15:10
…e UWORD

Change the parameter types from UBYTE to UWORD for maximum color length in paletteLoadFromPath, paletteLoadFromFd, paletteDim, and paletteDump functions. This improves consistency and allows for a broader range of color counts. Update related logic to accommodate the new types.
@kwn
Copy link
Copy Markdown
Contributor

kwn commented Apr 26, 2026

Hey @Vairn . I tried using the AGA branch in my project and I think I found a bug. I opened a PR with a fix. Would you mind taking a look and merge if it makes sense to you, please?

@Vairn
Copy link
Copy Markdown
Contributor Author

Vairn commented Apr 26, 2026

Hey @Vairn . I tried using the AGA branch in my project and I think I found a bug. I opened a PR with a fix. Would you mind taking a look and merge if it makes sense to you, please?

Awesome, I'll have a look later once I get to Work.

Vairn and others added 9 commits April 27, 2026 08:57
Added a new function to calculate DDF step based on the viewport's bitplane mode. Updated scroll buffer processing and reset logic to accommodate AGA features, ensuring correct handling for FMODE 1 and 2. Cleaned up whitespace in simple buffer initialization.
Updated the viewLoad function to streamline AGA feature support. Simplified the logic for setting bplcon0 and bplcon2 based on the viewport's bit depth, ensuring correct handling for 64-color modes. Removed redundant conditions and improved code clarity.
Refined the logic for setting bplcon0 and bplcon2 in the viewLoad function to improve AGA feature support. Added checks for VP_FLAG_HIRES and VP_FLAG_AGA to ensure correct configuration based on viewport flags and bit depth. This update enhances clarity and correctness in handling 64-color modes and AGA-specific settings.
…unctions

Updated the calculation for colour banks in viewUpdateGlobalPalette to ensure correct handling of bit depth. Enhanced comments in viewLoad to clarify the configuration of bplcon0 and bplcon2, specifically regarding VP_FLAG_HIRES and VP_FLAG_AGA. This improves the clarity and correctness of AGA feature support.
I was testing with AGA enabled, which also enabled ECS.
Copy link
Copy Markdown
Member

@tehKaiN tehKaiN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first minor and non-exhaustive review - I'd get rid of palette v1 support completely and at most leave detection of v1 and print the error on debug targets. User is expected to use latest convert tools at all times.

Not sure if we even need to document the old format. Having docs for new one is a nice to have.

Comment thread docs/programming/aga.md Outdated
Comment thread docs/programming/aga.md Outdated
Comment thread docs/programming/view.md Outdated
Comment thread src/ace/utils/palette.c Outdated
Vairn added 4 commits April 28, 2026 11:17
…ures

- Removed support for legacy (v1) `.plt` files; users must reconvert assets to v2 format.
- Updated documentation to reflect changes in palette loading and saving functions.
- Enhanced AGA palette handling in `palette_conv` and related functions to ensure compatibility with v2 formats only.
- Improved error handling for unsupported legacy formats in the palette loading process.
- Updated documentation for spriteSetOddColourPaletteBank and spriteSetEvenColourPaletteBank to improve clarity.
- Refined the logic for setting the palette banks in sprite functions to ensure correct handling of AGA features.
- Improved logging in viewCreate to include AGA-related flags for better debugging and visibility of feature usage.
- Fixed the deletion of the palette to check the views AGA flag, not the first VPORT.
Copy link
Copy Markdown
Member

@tehKaiN tehKaiN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks kinda okay, now needs testing in my games.

The diff would be way way smaller if you haven't wrecked the formatting. Please fix it - extra spaces near parentheses are okay if you feel attached to them, other stuff must go.

print("\tplt\tACE palette (default)\n");
print("\tpng\tPalette preview\n");
print("extraOpts:\n");
print("\t-cc\tConvert colors. Truncate non-OCS colors to OCS precision if necessary\n");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's required to stay. The intended behavior is that palette_conv for ocs catches bad colors in input palette and only if you don't care about them you add a switch that will auto-downgrade colors to 12-bit.

This is due to bitmap_conv not auto-fitting the images to palette, and you want to catch bad colors where they really are - with auto-fixed palette bitmap_conv will complain about palette-image color mismatch even though the image might be correctly 12-bit rgb.

print("\t-cc\tConvert colors. Truncate non-OCS colors to OCS precision if necessary\n");
}

int main(int lArgCount, const char *pArgs[])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really need to create a clangformat thingy. Plz minimize the diff. Extra whitespace is okay but "stickiness" of ptr/ref should be the same.

Comment thread .gitignore
tools/*/*.png
tools/*/*.bm
tools/*/*.plt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this for?

Comment thread include/ace/utils/palette.h Outdated
/** First byte of .plt v2: ECS/OCS packed entries (2 bytes per colour). */
#define PLT_NEW_ECS 0
/** First byte of .plt v2: AGA entries (4 bytes per colour, alpha+R+G+B). */
#define PLT_NEW_AGA 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it need to be in .h file and visible in other files that include them? or can we just have it in palette.c?

Comment thread include/ace/utils/palette.h Outdated
* @brief Saves ECS/OCS palette into .plt v2 file (PLT_NEW_ECS + BE count + packed colours).
*/
void paletteSave(UWORD *pPalette, UBYTE ubColorCnt, char *szPath);
void paletteSave(const UWORD *pPalette, UWORD uwColorCnt, char *szPath);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void paletteSave(const UWORD *pPalette, UWORD uwColorCnt, char *szPath);
void paletteSaveOcs(const UWORD *pPalette, UWORD uwColorCnt, char *szPath);

Comment thread src/ace/utils/palette.c Outdated
Comment thread src/mini_std/stdio_file.c Outdated
@@ -92,7 +92,17 @@ long ftell(FILE *pStream) {

int feof(UNUSED_ARG FILE *pStream) {
// FIXME: implement
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's fixme'd, you can now remove this comment.

Have you confirmed that it returns true only after the last byte was read?

Comment thread src/mini_std/stdio_file.c Outdated
Comment on lines +96 to +99
LONG lPos = Seek((BPTR)pStream, 0L, OFFSET_CURRENT);
Seek((BPTR)pStream, 0L, OFFSET_END);

LONG lEnd = Seek((BPTR)pStream, 0L, OFFSET_CURRENT);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ain't Seek() return the current position at all times?

Suggested change
LONG lPos = Seek((BPTR)pStream, 0L, OFFSET_CURRENT);
Seek((BPTR)pStream, 0L, OFFSET_END);
LONG lEnd = Seek((BPTR)pStream, 0L, OFFSET_CURRENT);
LONG lPos = Seek((BPTR)pStream, 0L, OFFSET_END);
LONG lEnd = Seek((BPTR)pStream, 0L, OFFSET_CURRENT);

Comment thread src/mini_std/stdio_file.c Outdated
Comment on lines +102 to +105
if (lPos == lEnd)
return 1;

return 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (lPos == lEnd)
return 1;
return 0;
return lPos == lEnd;

Comment thread tools/src/common/palette.cpp Outdated
constexpr std::uint8_t PLT_NEW_ECS = 0;
constexpr std::uint8_t PLT_NEW_AGA = 1;

static void writeUwordBE(std::ofstream &Dest, std::uint16_t uwValue) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as in main ace code - how about reading/writing a 2-byte thingy and using endian.h fns to swap them?

American spelling of Color where I use the  Colour version.
Fixes for badly formatted code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WIP AGA Support

4 participants