Jump to content

[object List Refresh Method] Opinion


Matmook

Recommended Posts

Hi,

 

Rebuilding my GPU code from scratch because I now need to have a double object list... and have a clean code too (test + test + test == unreadable code :whistling: ).

Here is the object list refresh mechanism I'm going to do... Don't know if this is a good method so your opinion are welcome :D

 

Here is the context :

 

Each "sprite" is defined in a structured array (Pseudo-Strange code) :

Struct {

Phrase1; // 1st bitmap phrase (YPOS, DATA,LINK...)

Phrase2; // 2nd phrase (XPOS, FLAGS ,...)

Phrase3; // scaled bitmap phrase

PosX;

PosY;

Layer;

Mode;

...

} Sprite;

 

Each Sprite include space for a copy of the whole object (4 LONG for bitmap object and 6 for scaled object).

 

I used 2 different Object List (one currently displayed and one for modifications) :

- Branch OBJECT (before display start-> Stop)

- Branch OBJECT (after display end -> Stop)

- Bitmap

- Bitmap

- ... many bitmap...

- Stop

 

I use 2 pointer for those Object List :

@currentlist

@worklist

 

The OLP always use @currentlist for the display.

 

 

* The GPU is set to build the new list on each VBL (via the 68k interrupt) :

Use @worklist

Jump over the 2 legacy branch objet (@worklist = @worklist + 4 LONG)

For i in 0 to numsprite

{

load saved phrase from sprite struct (we must (at least) correct the LINK).

compute next link (ie +4 or +6 depending of the type)

change X, Y, zoom, ...

save phrase to @worklist

@worklist = @worklist + 4 LONG (or 6)

}

add stop object

swap @worklist / @currentlist

Set OLP use this new @worklist

stop GPU.

 

Is this a good method or not ?

 

 

 

Link to comment
Share on other sites

Look OK to me. There are probably ways to optimize this (only updating what's necessary instead of using "brute force"), but I wouldn't bother if your code runs in 1 VBL with the current method.

 

Don't forget that sprite objects must be aligned on a 16-byte boundary, and scaled sprite objects on a 32-byte boundary. So you can't just add 4 or 6 to compute the address of the following object in the list, you have to round up too.

Link to comment
Share on other sites

Look OK to me. There are probably ways to optimize this (only updating what's necessary instead of using "brute force"), but I wouldn't bother if your code runs in 1 VBL with the current method.

:yes:

The idea is to let the GPU make the new list using the "sprite struct list" (animation ...) in this case I need to copy "unchanged part" of the object :unsure: .

In the other hand, job not done on gpu must be done using the 68k and the GPU is faster than the 68k so :wacko:

 

I hope this method (x128 sprite for example) do not take too much GPU time ... I "just" want to manage my sprite list (adding, remove, "Z ording" ...) using the 68k.

 

I don't know :unsure: ... let's try it ... :D

 

Don't forget that sprite objects must be aligned on a 16-byte boundary, and scaled sprite objects on a 32-byte boundary. So you can't just add 4 or 6 to compute the address of the following object in the list, you have to round up too.

 

I've not test scaled bitmap for the moment but this is a really important information ... I must make space for those object or place them in another room to loose less memory (since there should be less scaled bitmap than normal one in a game...)

 

Thanks :lol:

 

 

Link to comment
Share on other sites

:yes:

The idea is to let the GPU make the new list using the "sprite struct list" (animation ...) in this case I need to copy "unchanged part" of the object :unsure: .

In the other hand, job not done on gpu must be done using the 68k and the GPU is faster than the 68k so :wacko:

 

I hope this method (x128 sprite for example) do not take too much GPU time ... I "just" want to manage my sprite list (adding, remove, "Z ording" ...) using the 68k.

 

I don't know :unsure: ... let's try it ... :D

 

 

 

I've not test scaled bitmap for the moment but this is a really important information ... I must make space for those object or place them in another room to loose less memory (since there should be less scaled bitmap than normal one in a game...)

 

Thanks :lol:

 

 

:yes::yes: It runs ... :D I can now add/remove sprite easily.

I need to learn how to use scaled bitmap... :) Let's go !

Link to comment
Share on other sites

  • 9 months later...

The way we do it in ProjectOne is:

 

Create a "shadow object list" with all objects 32 bytes apart regardless of what they are - this assures an object is always phrase aligned. The links in the shadow are computer for where the live list is.

 

Store the creation address of each object all in a table.

 

During the VBL, use the blitter to copy the shadow to the live.

 

During the game you can then work on the shadow patching x/y/bitmap addresses. If you dont want something, modify a branch to skip it (eg, change the branch before a long string of objects from always to never) or just move its x/y to offscreen (if you have enough objectlist time to do this)

 

If you are doing object culling (Y-sorting) - we do this for the bullets - then you can loop around the shadow list changing just the link addresses.

 

I can mail you the code if you like?

Link to comment
Share on other sites

Here is the method I currently use :

 

- My sprite list is defined in an array (X, Y, bitmap, animation ptr, transparency,.... and also a copy of the corresponding OLP object phrase)

- One active object list

- One secondary object list

 

For the moment I manage to modify my sprite list using 68k but I hope to swap GPU code for that in the future.

 

On VBL I do the following things :

- play music (SebRMV's player)

- set a flag in G_RAM to inform the GPU that the VBL is here (I think I can use GPU interrupt for this in the future).

 

On GPU I do the following things :

- clear my vblflag

- swap active and secondary object list (I display the last computed one)

- compute the next object list using my sprite list information (simply restore object's phrase if nothing has changed or compute the new object if change happened ... like animation ....)

- wait for the vblflag (in local ram) to be set again and loop

 

I don't know if it is the good method but it runs so I'm going to improve this one.

 

Next I need to create a chained list in my sprite list to simplify sprite deletion/replacement/move and build a tool to create all animation (done by hand for the moment).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...