[MO6][demo] Bitmap16 Sprite handling

Cette catégorie traite de développements récents pour nos vieilles machines, applications, jeux ou démos... Amis programmeurs, c'est ici que vous pourrez enfin devenir célèbres!

Modérateurs : Papy.G, fneck, Carl

Garland_Raven
Messages : 25
Inscription : 19 juin 2017 19:00

[MO6][demo] Bitmap16 Sprite handling

Message par Garland_Raven »

First of all, i would thank you for your help so far, i came here one week ago knowing nothing about asm and i had a great time praticing on 6809 and MO6.

Now i would choose a resolution to attempt my game and of course i'm strongly tempted by 160x200. What really scares me is the video memory splitting between RAM A and B so you don't have contiguous columns. I know 320x200 4 or 16 dont have such tricky feature so it would be easier to code on that resolution (yeah there's color clash and limitations but its always a matter of costs and revenues).

Lets focus on 160x200 for now.

Sprites: best thing to me should be load 'em from external files, so i don't have to code-in directly. It would result in a shorter code, and drawing sprites with a tool makes it a lot easier as you know. While im pretty sure i could use even MSPaint and then export to 16color format, i'd need to port the sprite atlas files on MO6 dev environment :) Or should also use a inner paint tool (i recall Colorpaint but it was slow as hell :D).

The tricky part however would be on drawing and moving. Thanks to double buffer, i would avoid flickering or erasement tricks. But having two columns per ram per address is gonna give me headache. I should write a routine to split each sprite in chunks to send to respective A and B buffers, and what for movements? What to determine which chunk you should send to which buffer by checking the position of a moveable sprite? And how to move it by just one pixel instead of the entire memory cell ?

I learned a lot from the Nyan Cat (awesome) source code so it gave me a nice idea about bit16. But that was just a single animation, while having moveable sprites is totally another story.

Before to continue on my evaluation about what resolution to use, i'd like to know some suggestions or tricks by you.

(Feel free to answer me in french as well) :)

Thanks guys! :)
Dernière modification par Garland_Raven le 02 juil. 2017 17:33, modifié 4 fois.
Garland_Raven
Messages : 25
Inscription : 19 juin 2017 19:00

Re: [MO6] Bitmap16 Sprite Handling

Message par Garland_Raven »

I made this tiny demo in bitmap16. (GALAGA.asm)
Its the Galaga spaceship which you can move left/right with arrow keys, feature double buffering for transictions.

Image

I wonder now how to make some vertical scrolling (stars for instance) having the RAM swap in the middle of the page :roll:
I'd also need to load sprites from external files, can't have 'em hard coded.

And i would move the ship by one pixel instead on an entire mem address (which is four pixels) ..

Any feedback on the code is appreciated. Keep in mind im a beginner and there's a lot of room for improvement here.

Merci pour votre aide dans les derniers jours, j'ai appris beaucoup!
Pièces jointes
galg.zip
(2.71 Kio) Téléchargé 155 fois
__sam__
Messages : 7923
Inscription : 18 sept. 2010 12:08
Localisation : Brest et parfois les Flandres

Re: [MO6][demo] Bitmap16 Sprite handling

Message par __sam__ »

Bit shifting by 4 is rather slow for the 6809. Instead You can make the ship move by steps of 2px.

To for this simply draw the ship in rama then ramb at some offset from the start of the buffer. Then start at the same offset in ramb and go on with drawing the next column of the ship in rama at offset+1.

I'm probably not very clear but the idea is very simple:start drawing from rama first then from ramb to move 2px horizontally.
Samuel.
A500 Vampire V2+ ^8^, A1200 (030@50mhz/fpu/64mb/cf 8go),
A500 GVP530(MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.Démos
Garland_Raven
Messages : 25
Inscription : 19 juin 2017 19:00

Re: [MO6][demo] Bitmap16 Sprite handling

Message par Garland_Raven »

Quite clear, so instead of moving by 1 memory block i'll use ram exchange.

How long can be a single program code? I'm about 300 rows and it doesn't compile anymore it seems because of the length. I suppose i have to split it in some macros :)

Merci!
__sam__
Messages : 7923
Inscription : 18 sept. 2010 12:08
Localisation : Brest et parfois les Flandres

Re: [MO6][demo] Bitmap16 Sprite handling

Message par __sam__ »

The code can be quite big but the trick is to put the big code on disk (say file big.asm) and keep in memory a small file (say small.asm) that uses the INCLUD directive to actually compile the big one.

Code : Tout sélectionner

INCLUD big
END
Another option is to still keep big.asm in memory but instead of compiling to ram, You can compile to a disk file (compiling with "Abig" instead of "A" should produce big.BIN on disk without memory clash or corruption.)

A third option is to do cross-development using the C6809 compiler from the PULS site (see my signature). This is what I do since this is a fast&easy way to do things (pc environment is much productive than the old 8bits ones).
Samuel.
A500 Vampire V2+ ^8^, A1200 (030@50mhz/fpu/64mb/cf 8go),
A500 GVP530(MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.Démos
Répondre