don't click here

Animated Third Parallax

Discussion in 'Engineering & Reverse Engineering' started by MarkeyJester, Mar 6, 2011.

Thread Status:
Not open for further replies.
  1. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,205
    432
    63
    Japan
    This being one of the many greatest effects used in early console history, and having mastered, abused and experimented with the idea of it myself for 2 years now, I thought it would be great to see other hacks use this effect and see what creative designs people can come up with.

    For those of you who are still unsure as to what an “Animated Third Parallax” is, allow me to give a brief explanation, the Mega Drive/Genesis (using this console specifically as an example, not to say other consoles haven't experienced the same thing) has only two map/scroll planes that are beneficial enough for level depth graphics, one for the foreground, and another for the background, however, you may feel the sudden urge to want more planes to give some extreme depth to a level.

    This of course is not possible if you're following the standard machine's rules, however, programmers have before bent the rules of the limitations (such as limited planes) by providing alternate solutions, if you've ever played Sonic 3, you may have noticed that some backgrounds to levels “appear” (in brackets here) to have more planes or even show 3D effects that the machine prohibits possible, most of these are done through a technique known as “Animated Tiles”.

    “Animated Tiles” opens up a whole new level to the meaning of “Graphics”, they alter art/mappings in V-Ram on the fly based on a time/counter or a screen position. Certain BG effects can animate showing one of several pre-designed BG scroll frames based on the X or Y position, and showing one of them each time the screen is moving can give the illusion of more planes, and that is the key we'll be going for here.

    Now there is NO set rule, syntax, script or anything like that and the difference based around the number of frames, the speed of scrolling, etc, this means that a “unique” routine will have to be made specifically “for” your desired effect, I'll be providing a VERY simple one, nothing too complex (believe me, the more unique the effect is, the more difficult it'll be to program without risking lag (slowdown) on the machine).

    Note: This effect can be quite lag-ful is not used responsibly. We'll be using SonED 2 for this, and we'll be basing it on Sonic 1.

    Step one - having a design we want this effect to be based on:

    [​IMG]

    This is obviously the SYZ background, I felt this level would be good for the effect because it's one of the very few that do NOT use animated tiles anyway. I've roughly put in some simple pillars here (excuse the crudity, this isn't supposed to be lovely looking =P):

    [​IMG]

    The point in these is that I would like something to look like it's scrolling “behind” those pillars, I'm going to make a very small and simple repeating tile that will appear behind them:

    [​IMG]

    It's simple, but I like it, now in order for this to work, we need to create several frames/tiles, each one “looking” like it's moved a pixel to the left or right. I've done mine like this:

    [​IMG] [​IMG] [​IMG] [​IMG] [​IMG] [​IMG] [​IMG] [​IMG]

    And when in animation, should look like this:

    [​IMG]

    This looks as though an endless set of green things are moving to the left over and over again.
    Now, due to the way I'm programming this, you'll need all of those tile frames together (in order) one by one in one tile file. I've provided “mine” here.

    Step two - Choosing a tile to animate on

    First thing though will be to open up a tile to use (in SonED 2) for our animation, now, while you can use almost any space in V-Ram for animated tiles, I find it's much easier to “insert” a tile at the very beginning of the art-set in SonED 2, this means that all animated tiles are near the beginning of V-Ram and that by altering/inserting/changing the rest of the level's tile will NOT fuck up the animated tiles.

    So, in our tile-set, selecting tile 1 like so:

    [​IMG]

    We'll hover our mouse over the tile and using SonED 2's provided “insert” feature, holding CTRL and pressing the “I” key will put a duplicate tile in place like so:

    [​IMG]

    Now let's change the design a bit so it's different and stands out more:

    [​IMG]

    That's better, now we know that's our animated tile, we're gonna place rows of this in-between the pillars in the background:

    [​IMG]

    There we are, all in a row.

    Step three - Programming

    The next thing to do will be to get programming the tile writing routine.

    In “sonic1.asm” at routine “AniArt_Load:”, you'll find there are several routines in an index, each one is designed for each level, but you'll find that a few of them don't have any routines (and as I said, SYZ had no animated level tiles, so we need to make a routine for it).

    Code (ASM):
    1.         dc.w AniArt_none-AniArt_Index, AniArt_SBZ-AniArt_Index
    The first one “AniArt_none” we'll need to change to “AniArt_SYZ”, next we'll need to “create” this routine, we'll place it somewhere just after “locret_1C1EA:” so change from:

    Code (ASM):
    1.  locret_1C1EA:
    2.         rts
    3. ; ===========================================================================
    4. ; ---------------------------------------------------------------------------
    5. ; Animated pattern routine - Scrap Brain
    6. ; ---------------------------------------------------------------------------
    To:

    Code (ASM):
    1.  locret_1C1EA:
    2.         rts
    3.  
    4. ; ===========================================================================
    5. ; ---------------------------------------------------------------------------
    6. ; Animated pattern routine - Spring Yard
    7. ; ---------------------------------------------------------------------------
    8.  
    9. AniArt_SYZ:
    10.         rts
    11.  
    12. ; ===========================================================================
    13. ; ---------------------------------------------------------------------------
    14. ; Animated pattern routine - Scrap Brain
    15. ; ---------------------------------------------------------------------------
    We'll then need to include our animated tile-set file (The one I linked as an example), named “AniExample.bin” and put inside the “artunc” folder, then in the source we include this:

    Code (ASM):
    1.  locret_1C1EA:
    2.         rts
    3.  
    4. ; ===========================================================================
    5. ; ---------------------------------------------------------------------------
    6. ; Animated pattern routine - Spring Yard
    7. ; ---------------------------------------------------------------------------
    8.  
    9. AniArt_SYZ:
    10.         rts
    11.  
    12. ; ===========================================================================
    13. ; ---------------------------------------------------------------------------
    14. AniExample: incbin  "artunc\AniExample.bin"
    15.         even
    16. ; ---------------------------------------------------------------------------
    17. ; ===========================================================================
    18. ; ---------------------------------------------------------------------------
    19. ; Animated pattern routine - Scrap Brain
    20. ; ---------------------------------------------------------------------------
    Now how this routine I've written below works is all down to how the machine's VDP works really and it's suggested that you read up on both the programming language and the VDP's formats/accessing for references:

    Code (ASM):
    1.  AniArt_SYZ:
    2.         lea ($C00000).l,a5              ; load VDP data port address to a5
    3.         lea $04(a5),a6              ; load VDP address port address to a6
    4.         lea AniExample(pc),a4           ; load animated tile frames address
    5.         move.w  ($FFFFF700).w,d0            ; load screen's X position
    6.         add.w   d0,d0                   ; multiply by 2
    7.         neg.w   d0                  ; negate to negative (for opposite direction)
    8.         andi.w  #$00E0,d0               ; keep in multiples of 20 and in range of 100 (100 / 20 = 8 tiles)
    9.         adda.w  d0,a4                   ; add to frame address (To get the address of the correct tile frame)
    10.         move.l  #$40200000,(a6)             ; set VDP mode and address (to the first tile we made)
    11.         move.l  (a4)+,(a5)              ; Dump tile to V-Ram space
    12.         move.l  (a4)+,(a5)              ; ''
    13.         move.l  (a4)+,(a5)              ; ''
    14.         move.l  (a4)+,(a5)              ; ''
    15.         move.l  (a4)+,(a5)              ; ''
    16.         move.l  (a4)+,(a5)              ; ''
    17.         move.l  (a4)+,(a5)              ; ''
    18.         move.l  (a4)+,(a5)              ; ''
    19.         rts                     ; return
    It's quite a simple procedure and only depends on “logic” really. But here's what SYZ is like when the effect is put into action here..

    I hope this guide will offer enough help for more interesting results, which you might be able to pull off.
     
  2. PsychoSk8r

    PsychoSk8r

    PsychedelAnt | Tone Turner Oldbie
    2,642
    57
    28
    Birmingham, UK
    30 Day Project: Revisited.A New Release!
    Awesome, I look forward to seeing what this results in! Thanks very much for sharing. =P
     
  3. Infiniti

    Infiniti

    ↑ & ↓ & ↻ Member
    476
    0
    0
    UK
    It's a great effect, but it effected several other tiles...
    [​IMG]
     
  4. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,205
    432
    63
    Japan
    The reason behind that is that unlike all the other levels, SYZ just so happens to have it's object art in the level's main art itself, insted of having it loaded via a seperate PLC entry, so SYZ was probably a bad choice to show the example on =(

    Considering though that the first few tiles in SYZ aren't used like that "Let's go" sign, you could just simply overwrite those tiles insted of "inserting", as I said, you can have the animated tiles anywhere in V-Ram really, though the "inserting" method would work perfectly for the other levels that do not have their object art in the level main entry.

    Thanks for reporting this though =)

    Well I'm glad at least the two of you here appreciate the gesture, was getting worried there for a moment, thanks =)
     
  5. Hodgy

    Hodgy

    Member
    797
    0
    16
    UK
    Games programming :)
    Awesome work as always MJ :)
     
Thread Status:
Not open for further replies.