Sonic and Sega Retro Message Board: Animated Third Parallax - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Loading News Feed...
 
Page 1 of 1

Animated Third Parallax Basic Tutorial

#1 User is online MarkeyJester 

Posted 06 March 2011 - 01:44 PM

  • A word in your shell-like, pal
  • Posts: 1304
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
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:



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):



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:



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:



And when in animation, should look like this:



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:



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:



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



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:



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).

Syntax Highlighted Code: ASM
		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:

Syntax Highlighted Code: ASM
 locret_1C1EA:
rts
; ===========================================================================
; ---------------------------------------------------------------------------
; Animated pattern routine - Scrap Brain
; ---------------------------------------------------------------------------

To:

Syntax Highlighted Code: ASM
 locret_1C1EA:
rts
 
; ===========================================================================
; ---------------------------------------------------------------------------
; Animated pattern routine - Spring Yard
; ---------------------------------------------------------------------------
 
AniArt_SYZ:
rts
 
; ===========================================================================
; ---------------------------------------------------------------------------
; Animated pattern routine - Scrap Brain
; ---------------------------------------------------------------------------

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:

Syntax Highlighted Code: ASM
 locret_1C1EA:
rts
 
; ===========================================================================
; ---------------------------------------------------------------------------
; Animated pattern routine - Spring Yard
; ---------------------------------------------------------------------------
 
AniArt_SYZ:
rts
 
; ===========================================================================
; ---------------------------------------------------------------------------
AniExample: incbin "artunc\AniExample.bin"
even
; ---------------------------------------------------------------------------
; ===========================================================================
; ---------------------------------------------------------------------------
; Animated pattern routine - Scrap Brain
; ---------------------------------------------------------------------------

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:

Syntax Highlighted Code: ASM
 AniArt_SYZ:
lea ($C00000).l,a5 ; load VDP data port address to a5
lea $04(a5),a6 ; load VDP address port address to a6
lea AniExample(pc),a4 ; load animated tile frames address
move.w ($FFFFF700).w,d0 ; load screen's X position
add.w d0,d0 ; multiply by 2
neg.w d0 ; negate to negative (for opposite direction)
andi.w #$00E0,d0 ; keep in multiples of 20 and in range of 100 (100 / 20 = 8 tiles)
adda.w d0,a4 ; add to frame address (To get the address of the correct tile frame)
move.l #$40200000,(a6) ; set VDP mode and address (to the first tile we made)
move.l (a4)+,(a5) ; Dump tile to V-Ram space
move.l (a4)+,(a5) ; ''
move.l (a4)+,(a5) ; ''
move.l (a4)+,(a5) ; ''
move.l (a4)+,(a5) ; ''
move.l (a4)+,(a5) ; ''
move.l (a4)+,(a5) ; ''
move.l (a4)+,(a5) ; ''
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 User is offline PsychoSk8r 

Posted 06 March 2011 - 02:59 PM

  • HighKnights
  • Posts: 2524
  • Joined: 11-July 07
  • Gender:Male
  • Location:Walsall, UK
  • Project:30 Day Project: Revisited.A New Release!
  • Wiki edits:19
Awesome, I look forward to seeing what this results in! Thanks very much for sharing. =P

#3 User is offline Infiniti 

Posted 08 March 2011 - 06:20 AM

  • ↑ & ↓ & ↻
  • Posts: 418
  • Joined: 24-August 03
  • Gender:Male
  • Location:UK
It's a great effect, but it effected several other tiles...


#4 User is online MarkeyJester 

Posted 08 March 2011 - 07:47 AM

  • A word in your shell-like, pal
  • Posts: 1304
  • Joined: 22-July 08
  • Gender:Male
  • Location:Japan
  • Wiki edits:16
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 =)

QUOTE (PsychoSk8r @ Mar 6 2011, 07:59 PM)
Awesome, I look forward to seeing what this results in! Thanks very much for sharing. =P

Well I'm glad at least the two of you here appreciate the gesture, was getting worried there for a moment, thanks =)
This post has been edited by MarkeyJester: 08 March 2011 - 08:14 AM

#5 User is offline Hodgy 

Posted 08 March 2011 - 08:56 AM

  • Posts: 748
  • Joined: 25-July 08
  • Gender:Male
  • Location:UK
  • Project:Learning Stuff
Awesome work as always MJ smile.png

Page 1 of 1
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users