 |
|
| View previous topic :: View next topic |
| Author |
Message |
Groupie


Joined: 18 Jun 2002 Age: 27 Posts: 259 Location: Macedonia
|
Posted: Thu Jun 20, 2002 8:34 pm Post subject: Revealing the secrets: A real 2 layer scroll on C64. |
|
|
There are many games which contains 2 layer scroller. Mostly the back layer is just a simple graphics. But if you played 'Flimbo's Quest' you surelly know what a real 2 layer scroller is. I was really amazed by this and I couldn't figure out how the heck was this done. I was thinking for about a month, but nothing. One day I had enough of it and disassembled the god damn code. After few long nights with beer and drugs, I found the trick. (Actually, the only drug was cool music). I'll try to explain this 'cause I'm sure that most of you will be interested in it.
Let's first think about non smooth (whole character) scroll. We have two maps which one of it should overlap the other. Two pointers exist (one for each map) which holds the current position in the map. Lets suppose the scroller runs automaticly without reading the joystick (like in the high-scores). In each frame, the front layer pointer is increased by 1. But the back layer pointer is increased every second frame. Each time the screen should be reprinted, we copy the front map (from current position) to screen. This map contains characters with code 0 at all spots where the back layer should be printed. After this is done, the back layer characters are printed at all spots with chars 0.
So far so good. But, what about smooth scroll. Actually, there are four Caracter Sets. Yeah, I know you wonder why. Well, this is the most important part. All chars from the front layer are the same in all 4 charsets. This means if you have the picture on screen and you change between each charsets, the picture will be the same (e.g. Nothing moves in the front layer). But you can see the back layer moving by two pixels. Actually, the character layout is settled that way so the back layer moves when you change the charset.
In Flimbo actually, there is a different approach. The 0 chars I mentioned are in different map. There is one (16 bit) pointer for the map pos and one pointer for the X-Scroll (reg. $D016). When the game need to paint the map it first draws the front layer. Then it divides the pointer by 2 and uses this to draw the back layer. The X-Scroll is multiplied by 2 and then stored in $D016. So in each frame we scroll 2 pixels. In one frame the front and back layer move together by 2 pixels. Each second frame the back layer is moved 2 pixels in opposite direction (by selecting another charset) giving the effect that the back layer is not moved. Here is the process:
X - X-Scroll (going from 7 to 0)
B - X-Scroll * 2 (the actuall value written in $D016)
C - Charset
X=3, B=6, C=4,
X=2, B=4, C=4,
X=1, B=2, C=6,
X=0, B=0, C=6,
- Only the front layer moves by whole character now.
X=7, B=6, C=0,
X=6, B=4, C=0,
X=5, B=2, C=2,
X=4, B=0, C=2,
- Both layers move by whole character.
The process repeats now.
The charsets are setteled like this: C=0 (most left), C=6 (most right)
If you wonder why C always differs by 2, this is because the LSB of $D018 is unused.
If you want to experiment, here are the addresses I found when I was disassembling this (on 20 August 2001).
$7900 (30976) - The start address of the game.
$7CFD (31997) - Here starts the scroll routine in the high scores. Anything you change here will affect the high scores scroller.
$1000 (4096) - The routine that prints the characters of both layers on screen.
I also found the music addresses.
$5500 (Initialise music)
$5506 (Play music)
---------
If you think that something is wrong or I just missed something, please post it so we can all learn from each other.
Any other interesting effects are welcome.
p.s. Flimbo is the only game I saw which contains this trick. If you know another with similar trick, please name it. |
|
| Back to top |
|
 |
Groupie in Training


Joined: 23 Apr 2002 Age: 37 Posts: 60 Location: Italy
|
Posted: Fri Jun 21, 2002 10:57 pm Post subject: |
|
|
does "hawkeye" use a similar "flimbo's quest" trick ? |
|
| Back to top |
|
 |
C64 Enthusiast


Joined: 20 Jan 2002 Posts: 772 Location: Slovakia
|
Posted: Fri Jun 21, 2002 11:10 pm Post subject: |
|
|
Is that article from your own head Ristoski ?
If yes, it seems you have insight, maybe you could write tutorials for c64.sk It has article system and I'm still looking for editors.
Roman _________________ |
|
| Back to top |
|
 |
C64 Games Programmer


Joined: 07 Jan 2002 Posts: 2181 Location: Finland
|
|
| Back to top |
|
 |
Forum Junkie


Joined: 06 Feb 2002 Posts: 484 Location: Home
|
Posted: Sat Jun 22, 2002 5:46 am Post subject: |
|
|
Yeah, Hawkeye uses the same trick.
Another way to do it is to rotate the character data from one char to the next (like rotating a font through sprites to get a text scroller), which although it takes up a lot of processor time, saves the space you need to have the pre-rotated char-sets. |
|
| Back to top |
|
 |
Groupie


Joined: 18 Jun 2002 Age: 27 Posts: 259 Location: Macedonia
|
Posted: Sat Jun 22, 2002 9:28 am Post subject: ... |
|
|
| JCB wrote: | Yeah, Hawkeye uses the same trick.
Another way to do it is to rotate the character data from one char to the next (like rotating a font through sprites to get a text scroller), which although it takes up a lot of processor time, saves the space you need to have the pre-rotated char-sets. |
You are right. Rotating character data would steel a lot of processor time.
This would work with simple graphics, but there is no way to use this in Flimbo.
About HawkEye. Although I heard about this game, I've never seen it. Any links you could provide?
p.s. I'm sure I could find HawkEye on http://www.c64.com but I have some problems connecting on this site. Any other links? |
|
| Back to top |
|
 |
Groupie


Joined: 18 Jun 2002 Age: 27 Posts: 259 Location: Macedonia
|
Posted: Sat Jun 22, 2002 9:49 am Post subject: Tutorials... |
|
|
| CreaMD wrote: | Is that article from your own head Ristoski ?
If yes, it seems you have insight, maybe you could write tutorials for c64.sk It has article system and I'm still looking for editors.
Roman |
I'm glad you like my article.
Actually, all of this came from the head of 'Laurens Van Der Donk', the guy who coded Flimbo's Quest.
I just made a disassembly and tried to think like he did.
I'm really honoured you asked me to write a tutorial. I'm pretty busy, but I'll try to do something. Any special effects you like? |
|
| Back to top |
|
 |
Groupie


Joined: 18 Jun 2002 Age: 27 Posts: 259 Location: Macedonia
|
Posted: Sat Jun 22, 2002 5:19 pm Post subject: Hawkeye |
|
|
Yeah, I found the game. Actually, I did connect on http://www.c64.com successfully.
JCB was right when said that Hawkeye uses a similar trick. I made a disassembly (which took me about 2 hours) and here is what I found:
Hawkeye uses a simplified method. The non-moving back layer explains this. The back layer is never moving in screen memory, except with the charsets. There are 4 charsets just like in Flimbo. The front layer is moving by 2 pixels each frame (when walking, of course).
The dependence between $D018 and $D016 looks like this.
$D016 = 6, $D018 = 0
$D016 = 4, $D018 = 2
$D016 = 2, $D018 = 4
$D016 = 0, $D018 = 6
For $D018 assumed: 0-most left, 6-most right
---------
And the music:
Init: LDX #x : JSR $7B5A
Play: JSR $7B98
X = 0 to 6 (the song number) |
|
| Back to top |
|
 |
Master of C64


Joined: 28 Dec 2001 Age: 38 Posts: 1261 Location: 6502
|
Posted: Sun Jun 23, 2002 9:15 pm Post subject: xxx |
|
|
Why do you need 2 hours to disassemble????
wondering...
use a cartridge image (.crt) with in-built monitor like Action Replay |
|
| Back to top |
|
 |
Groupie

Joined: 18 Apr 2002 Posts: 298 Location: Sweden
|
Posted: Sun Jun 23, 2002 9:52 pm Post subject: |
|
|
I'm sure he meant disassembling and "reading" the code  _________________ Splatform Addict |
|
| Back to top |
|
 |
Groupie


Joined: 18 Jun 2002 Age: 27 Posts: 259 Location: Macedonia
|
Posted: Mon Jun 24, 2002 6:52 am Post subject: |
|
|
| Mr ho wrote: | I'm sure he meant disassembling and "reading" the code  |
You are right Mr ho. I ment disassembling, reading and understanding the code, of course.
Actually, I used CCS64's built in monitor. This is a really cool monitor, indeed. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Tip: Get C64 Forever for super-comfy C64 emulation with pre-installed games, demos and other goodies!
Powered by phpBB © 2001, 2005 phpBB Group
|