Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprite not displaying nor giving error when bitmaps are malformed #246

Open
youenchene opened this issue Feb 2, 2025 · 15 comments
Open

Comments

@youenchene
Copy link
Contributor

Hi,

Another issue on my side.

I am trying to display some sprite (simple for the moment). My end goal is to display 16 colors 32px wide sprites. (easy to do in Blitz Basic 2).

Here it is ,my not working example : https://github.com/youenchene/amiga-test-ace-sprites

I don't know what I missed.

May be palette, may be something else.

TX in advance for your help.

@Vairn
Copy link
Contributor

Vairn commented Feb 2, 2025

I have pushed a pull request to your code to fix why it wasn't working.

@tehKaiN, do sprites need to be interleaved data? They never work for me otherwise, and can you share the same bitmap between two sprites? with some magic?

@tehKaiN tehKaiN changed the title Sprite not displaying Sprite not displaying nor giving error when bitmaps are malformed Feb 3, 2025
@tehKaiN
Copy link
Member

tehKaiN commented Feb 3, 2025

sprite hardware is designed so that it expects interleaved data. Unfortunately, since sprite's chain mode requires you to put control words before and after the data, the default way of using it will require you duplicating bitmaps. A way around it is to use copper to control the sprite hardware, of which we have proof of concept in Battle Squadron 2 code, but it needs a bit more adjusting and making sure it works properly at the beginning of display lines.

From now on, I'll use this issue to track missing errors on passing bitmaps which are malformed (non-interleaved, width exceeding 16px). I'll fix that soon.

@tehKaiN
Copy link
Member

tehKaiN commented Feb 3, 2025

Hm, it appears that the checks are already in place. I've updated sprite tutorial a bit to make sharing data note more visible. I've also added info on wider sprites and missing BMF_INTERLEAVED flag.

@youenchene
Copy link
Contributor Author

youenchene commented Feb 3, 2025

Tx for the updates.

2 questions :

1/ Why my sprite is behind the simple buffer ? (--> pBack or -->pFront).

Image

Image

2/ I don't understand how you manage a 4bpp sprite aka attachedSprite?

I saw in another issue that it's already working .

@Vairn
Copy link
Contributor

Vairn commented Feb 3, 2025

With attached sprites you need to do them in pairs, 0,1 2,3 etc

And you have to tell the odd sprite that it is an attached sprite.

spriteSetAttached(1,1); for example.
After you enable it.

@youenchene
Copy link
Contributor Author

mmmh...

I would need a full example :

  s_pSprite0Data = bitmapCreate(16, 34, 4, BMF_CLEAR|BMF_INTERLEAVED); // 16x32 2BPP
  blitRect(s_pSprite0Data,0, 0, 16, 4, 0);
  blitRect(s_pSprite0Data,0, 4, 16, 4, 1);
  blitRect(s_pSprite0Data,0, 8, 16, 4, 2);
  blitRect(s_pSprite0Data,0, 12, 16, 4, 3);
  blitRect(s_pSprite0Data,0, 16, 16, 4, 4);
  blitRect(s_pSprite0Data,0, 20, 16, 4, 5);
  blitRect(s_pSprite0Data,0, 24, 16, 4, 6);
  blitRect(s_pSprite0Data,0, 28, 16, 4, 7);


  s_pSprite0 = spriteAdd(0, s_pSprite0Data); // Add sprite to channel

  s_pSprite0 = spriteAdd(1, // what  do I put here? //);

  spriteSetAttached(s_pSprite01,1);
  
  s_pSprite0->wX=100;
  s_pSprite0->wY=100;
  spriteSetEnabled(s_pSprite0,1);
  spriteSetEnabled(s_pSprite1,1);

```

@Vairn
Copy link
Contributor

Vairn commented Feb 3, 2025

https://github.com/Vairn/SmitACE/blob/main/src/misc/mouse_pointer.c

Here is my mouse pointer code, which is an attached sprite.

@youenchene
Copy link
Contributor Author

Ok got it, I was afraid it was this kind of solution.

May be, I would do a contribution on the sprite.c in ACE (ok for you @tehKaiN ?)

On the sprite behind the simpleBuffer any idea why?

@Vairn
Copy link
Contributor

Vairn commented Feb 3, 2025

The BPLCON2 register controls the order of sprites/playfields.

http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_guide/node0159.html

There is no easy way to change this atm.

@tehKaiN sounds like a task needs to be created.

@youenchene
Copy link
Contributor Author

Yeah tx. In blitz you can set it easily (I remember you from the gamejam ;-) )

@Vairn
Copy link
Contributor

Vairn commented Feb 3, 2025

And by easy, I mean no function to let you do it.
you can always access it by

g_pCustom->bplcon2 = whatever, where whatever is the value from the table on that link.

after each time a view is set, cause the setting of a viewport sets this flag back to 0.

Yeah, you have to remember Blitz is a finished programming language. While ACE gets features as people get need it.

@youenchene
Copy link
Contributor Author

youenchene commented Feb 5, 2025

Of course.

But it's open source so I can contribute : #250

@tehKaiN should I close this issue.

@tehKaiN
Copy link
Member

tehKaiN commented Feb 5, 2025

Not yet, I'm not sure where the drawing beneath the bitplanes came from. This definitely shouldn't be the default behavior.

@youenchene
Copy link
Contributor Author

@youenchene
Copy link
Contributor Author

@Vairn here it is a proposition of an advancedSpritesManager - inpired by your code : https://github.com/youenchene/amiga-test-ace-sprites/tree/16colors-sprite

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

No branches or pull requests

3 participants