Enchanted Land parallax scroll

All about ST/STE games

Moderators: simonsunnyboy, Mug UK, ICS, Doctor Bob Gordon, Moderator Team

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Enchanted Land parallax scroll

Postby Foxie » Fri Jan 12, 2018 5:38 pm

Apologies if this has been brought up already. Couldn't find any hard details with search.

How on earth did they do the parallax scrolling on the intro screen of Enchanted Land? Are they just brute-forcing it with a software blitter?

I can't see how you can do parallax scrolling with sync scroll without resorting to tricks like a single-plane background or palette cycling. Enchanted Land does neither.

Why don't they use the same technique in the game? I can only guess it must be a very dirty trick.

Also it works in all wakestates. Isn't that unusual for 1990? Are they just using a very conservative sync scroll that works every time? I don't think they knew how to detect all four wakestates in 1990?

User avatar
troed
Atari God
Atari God
Posts: 1380
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Enchanted Land parallax scroll

Postby troed » Fri Jan 12, 2018 5:50 pm

Foxie wrote:Also it works in all wakestates. Isn't that unusual for 1990? Are they just using a very conservative sync scroll that works every time? I don't think they knew how to detect all four wakestates in 1990?


It's _very_ conservative. It needs 20 scanlines, and uses only right overscan, right+left overscan and normal line (i.e, 3 combinations). They left out left overscan completely, likely because they couldn't stabilize the Shifter for the following non-overscan screen.

Enchanted Lands was thus more conservative than SoWatt which used 4 different lines (I don't think I've verified Cuddly, but it likely also uses 4).

A modern sync scroll, which needs to know about wakestates, has 12 possible line lengths and only needs 4 scanlines to reach all scroll positions.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Enchanted Land parallax scroll

Postby Foxie » Fri Jan 12, 2018 9:23 pm

troed wrote:It's _very_ conservative. It needs 20 scanlines, and uses only right overscan, right+left overscan and normal line (i.e, 3 combinations). They left out left overscan completely, likely because they couldn't stabilize the Shifter for the following non-overscan screen.


Interesting, thanks for the info. I don't think I understand entirely about stabilising the shifter. Of course I've seen stabilisation code in overscans before. I don't really know how that would interact with a non-overscanned line following.


troed wrote:A modern sync scroll, which needs to know about wakestates, has 12 possible line lengths and only needs 4 scanlines to reach all scroll positions.


I saw the slides you made describing that technique. Very impressive. ^.^

Do shifter wakestates come into this at all? I don't know much about wakestates really. From what I understand, shifter wakestate not GLUE-MMU is responsible for the Spectrum 512 dots? Can it ever affect scroll/overscan too?

User avatar
alien
Atari maniac
Atari maniac
Posts: 87
Joined: Sat May 01, 2004 4:01 am
Location: USA
Contact:

Re: Enchanted Land parallax scroll

Postby alien » Sat Jan 13, 2018 4:21 am

An amusing fact for Troed: If I recall correctly, they actually had adaptive code to vary the timing of the the resolution/frequency switches around, just in case there was an Atari out there that had different timings. They read the video counter to see whether the desired line lengths had been obtained. Of course that wouldn't help with the stabilizers. I think at that time, it was still all "magic" because we didn't understand what was happening inside the video chips.
Alien / ST-Connexion

mlynn1974
Captain Atari
Captain Atari
Posts: 177
Joined: Mon Mar 03, 2008 10:33 pm
Contact:

Re: Enchanted Land parallax scroll

Postby mlynn1974 » Sun Jan 14, 2018 1:55 pm

I never quite understood sync scroller. Paul from DigiTech and Neil from Flair tried to explain it to me, but I didn't quite understand it fully at the time (1991). There is also the fairly well documented sync scroller in the source code for the main menu of the Mindbomb demo. That's good.

I would expect the sync scroller in Enchanted Lands to be conservative and "safe" because it was a commercial product and they could only test it on a limited number of mmu\shifter combinations at the time.

In Enchanted Lands yes sync scrolling is amazing but they must still be blitting a heck of a lot for the overlaid message in the middle, the sprites and some of the layers.

One thing I don't get is that some people say that Grodan and the Kvack Kvack in the So Watt demo also used a sync scroller but when I ripped the graphics from it using Ultimate Ripper the screen line lengths weren't variable and the graphics could be ripped in normal video mode without stabilizers.

Sync scrolling is an amazing technique but even as a programmer I found it convoluted and not well documented.
Still got, still working: Atari 4Mb STe, 520STFM, 2.5Mb STF.
Hardware: Cumana CSA 354, Ultimate Ripper, Blitz Turbo, Synchro Express II (US and UK Versions).

User avatar
troed
Atari God
Atari God
Posts: 1380
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Enchanted Land parallax scroll

Postby troed » Sun Jan 14, 2018 3:24 pm

mlynn1974 wrote:I never quite understood sync scroller.


Hopefully (?) my little chapter on the subject in the Breakin' the Borders book helps a few more to understand how it works, even though I was pressed for space :)

Mostly what was important for Enchanted Lands was that the following scanlines were non fullscreen. That means any issue with left over words in the Shifter ("non stabilized") would affect the whole screen. Most sync scrollers are otherwise fullscreens where every line has its own stabilizer.

(I know this was a HUGE pain for me when I did the LoSTE demo, which additionally used a very advanced 1+3 line sync scroller)

alien wrote:An amusing fact for Troed: If I recall correctly, they actually had adaptive code to vary the timing of the the resolution/frequency switches around, just in case there was an Atari out there that had different timings. They read the video counter to see whether the desired line lengths had been obtained.


Thanks, yes, that piece of code has actually been studied in detail since it ... doesn't work :D By mistake when hunting for the left border position they trigger a "full" scanline by skipping hsync and since they obviously realized that wasn't the correct position they then add an empirically tested number of cycles ;)

From my studies of the "tv-snow" screen in SNYD1 I'm guessing Nick had a computer which mostly booted in WS2 (that's why the disting logo is only centered in that wakestate, it's off center in the others). WS2 is one nop off compared to the others for the left border so he probably assumed that position couldn't be relied upon always being the same between computers.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Enchanted Land parallax scroll

Postby Foxie » Mon Jan 22, 2018 12:08 am

I suppose that nobody knows how the parallax scroll on the title screen was achieved then?

I'd be fascinated to know how they did it, because it would seem to be impossible. Surely they don't have enough cycles to completely re-draw the foreground layer while sync scrolling the background? The foreground sometimes covers the entire screen, so that's a whole lot of copying.

Some games like James Pond II on the Amiga draw their parallax background on only a single plane to make it fast enough. But Enchanted Land doesn't do this - it looks like 16 colours in both foreground and background.

joska
Hardware Guru
Hardware Guru
Posts: 3997
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Enchanted Land parallax scroll

Postby joska » Mon Jan 22, 2018 9:39 am

I had a look at the intro now, and from what I can see only about 1/3 of the screen is parallax scolling. And the background looks like 2 bitplanes only. I believe they're syncscrolling the screen and redrawing the background. I'm not very familiar with syncscrolling - can you sync-scroll only parts of the screen? Because I noticed that the credits seems to be displayed in the two bitplanes not used by the background, and whenever there are credits on the screen there is no scrolling foreground in the same area. So it looks like only the part below the credits is scrolled.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Enchanted Land parallax scroll

Postby Foxie » Mon Jan 22, 2018 7:20 pm

joska wrote:I had a look at the intro now, and from what I can see only about 1/3 of the screen is parallax scolling. And the background looks like 2 bitplanes only. I believe they're syncscrolling the screen and redrawing the background. I'm not very familiar with syncscrolling - can you sync-scroll only parts of the screen?


I don't think it's possible to scroll only part of the screen, but I'm no expert on sync scrolling. AFAIK there's no way to reload the video address counter mid-frame, which is a shame because that precludes lots of effects. It would be wonderful if someone figured out a way of doing that. I think that latch is wired directly to the vsync signal, so you'd need some way of generating a false vsync mid-frame. I wonder if the 68k's reset instruction could be abused to force an MMU/glue/shifter reset mid-screen?

I've no idea how full-screen distorters work if they can't change the scrolling on each scanline. I've heard they use lots of different screens but I'm struggling to understand how that helps.

I suppose the Enchanted Land background could be two planes. The foreground looks like more though - all four? That means they can't "own" the two background planes like James Pond II does with its background plane. So they must be cleverly masking it when redrawing to avoid overwriting the foreground. I'm amazed that's even possible at 50fps!

Also there's some per-line scrolling on the floor. It might be possible to scroll 0, 4, 8, or 12 pixels on each line by switching to medium res? I'm not entirely sure. The "big" scrolling AFAIK can only be done at the top of the screen since it takes many scanlines to advance the video address counter to the desired position. I think Troed's method uses only four scanlines, but that's still four scanlines too many to do mid-screen (unless you cleverly arranged it with a break in the screen I suppose).

Come to think of it, perhaps you could put a sync-scroll mid-screen, and then cover up the four lines of artifacts by just blitting those lines.

The two weirdest things about Enchanted Land are that the parallax scroll doesn't happen in the game itself, and they didn't go fullscreen. Actually I can forgive them for not going full screen horizontally because of the need to write a blitter routine that's synced. But they could have easily gone vertical which would have looked nice.

joska
Hardware Guru
Hardware Guru
Posts: 3997
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: Enchanted Land parallax scroll

Postby joska » Mon Jan 22, 2018 8:43 pm

I suspect a lot of precalculation. That would work fine with the intro but not in the game where the playfield is a lot bigger.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
thomas3
Atari maniac
Atari maniac
Posts: 87
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Enchanted Land parallax scroll

Postby thomas3 » Mon Jan 22, 2018 10:37 pm

I seem to remember hearing somewhere that they used a four plane version of the background graphics when the text isn't displayed, but drop down to 2pl when it is.

fenarinarsa
Atari User
Atari User
Posts: 43
Joined: Sat Mar 15, 2014 11:23 pm

Re: Enchanted Land parallax scroll

Postby fenarinarsa » Tue Jan 23, 2018 12:40 am

First of all Enchanted Lands works on plain STF so you can forget about using the blitter and changing the video address counter mid screen since it's possible only on the STE.

So it's all software.

During the game it obviously uses the syncscroll technique. Syncscroll is mostly used to achieve vertical scrolling of the whole screen, you can't use it mid screen without displaying distorted or black lines. In addition as troed said, in EL it needs 20 scanlines to achieve the effect, so you would have 20 distorted or black lines in the middle of the screen. It's useless for the intro screen.

IMO it's only preshift and lots of bitplanes tricks. The background seems to be a looping 1 pixel scroll in 2 bitplanes 320 pixels wide so I guess it's preshifted 16x (on Amiga it's 4 bitplanes, no need to preshift). For the foreground I'm not so sure, it looks like it's a 4 bits scrolling from the timing, so maybe it's tiles that are preshifted 2x and then uses movep to add 8 bit shift or something like that? I'm sure some people had already checked the code...

What you can see clearly anyway is that the foreground is not used when text appear, so they use the same bitplanes/"layer".

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Enchanted Land parallax scroll

Postby Foxie » Tue Jan 23, 2018 2:02 am

fenarinarsa wrote:Syncscroll is mostly used to achieve vertical scrolling of the whole screen, you can't use it mid screen without displaying distorted or black lines. In addition as troed said, in EL it needs 20 scanlines to achieve the effect, so you would have 20 distorted or black lines in the middle of the screen. It's useless for the intro screen.


I'm pretty sure the entire screen is scrolling using sync scroll even on the intro screen. I've heard it said that there's insufficient time to redraw the entire four bitplanes at 50fps. Although doing a rough calculation, it looks like you can move about 40KB per frame with movem which might be enough.

They must at a minimum be redrawing the background only, or the foreground only. The foreground looks like four planes, and it covers the entire screen at one point. So I'm not sure if they're drawing that in software. But the background could be. Two planes plus complex masking is a lot to ask for.

I don't see why you couldn't do a sync scroll mid-screen, it's just that you'd need to blit over the distorted lines. Since the distortion is absolutely predictable, you could adjust your blitting positions so it appears in the right place on-screen. But of course that only gives you control over the low 8 bits of the video counter. The others are only latched during vsync.

I did notice that the floor pattern is a short repeating pattern, so they might be able to live with only a small amount of shift for that. From what I understand of sync scroll, to go down to 4 pixel resolution you need to switch into medium resolution briefly. Does this need to be done at the start of the screen? Or every single scanline? I'm thinking they might use this trick on each scanline to get a small displacement of each line?

User avatar
thomas3
Atari maniac
Atari maniac
Posts: 87
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Enchanted Land parallax scroll

Postby thomas3 » Tue Jan 23, 2018 7:17 am

Sync scroll works by using various combinations of overscanned scanlines to produce an offset into screen data which then doesn't have to be a 256 byte multiple. In other words, it basically simulates a screen address. So you need to be synclocked for those lines (i.e. you need a sync line), and wouldn't be able to draw over them, as the line length of these would likely change every frame.

Basically, it's a hardscroll method (i.e. creates illusion of whole screen scrolling by changing a simulated screen address).

User avatar
troed
Atari God
Atari God
Posts: 1380
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Enchanted Land parallax scroll

Postby troed » Tue Jan 23, 2018 8:36 am

(and TCB used a very basic sync scroller for Enchanted Land, due to a non-fullscreen not automatically stabilizing itself in the lines that follow. Additionally, no non-fullscreen 4 pixel sync scroller was known then - it's not even fully working today - and since we didn't know about wakestates back then everybody was fully convinced that any use of advanced demo-sync tricks was likely not working on a lot of machines that possible buyers of the game could have)

trivia: For a dual playfield optimized 1+3-line non-fullscreen horisontal sync scroll, see SYNC's LoSTE demo. In there I use the most current knowledge to scroll "mid screen". It took _ages_ to test all combinations and wakestates and even then I'm sure it's flaky on some Shifters/wakeups.

fenarinarsa
Atari User
Atari User
Posts: 43
Joined: Sat Mar 15, 2014 11:23 pm

Re: Enchanted Land parallax scroll

Postby fenarinarsa » Wed Jan 24, 2018 12:34 am

Okay I'm no syncscroll master like you troed or others great people, but I did a quick check of the intro with Steem SSE debug and from what I could see the foreground is indeed achieved with syncscroll (that was an easy find by modifying the colors or by tracing the hbl interrupt).

Since the 4-bit syncscroll technique is certainly not used here, my guess is that it's doing an 16-bit horizontal syncscroll with 4 buffers in which the foreground is written, shifted by 0,4,8,12 pixels. You can actually see this by removing the movep at address $3964 and setting for instance $ff8201=$06 and $ff8203=$10.

The background seems to be written on the displayed buffer, and it's indeed 2 bitplanes, as are the credits & sprite, using generated code.

The buffers go higher and higher in memory because of the scrolling, so I guess that's why the intro stops after a while :)
Last edited by fenarinarsa on Wed Jan 24, 2018 6:59 am, edited 1 time in total.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Enchanted Land parallax scroll

Postby Foxie » Wed Jan 24, 2018 2:14 am

fenarinarsa wrote:The background seems to be written on the displayed buffer, and it's indeed 2 bitplanes, as are the credits & sprite, using generated code.


Any idea how it's masking the background to avoid overwriting the foreground? I'd have thought that would be extremely slow. Wouldn't you need to read all four planes and do some logical operations to determine which pixels are safe to write?

fenarinarsa wrote:The buffers go higher and higher in memory because of the scrolling, so I guess that's why the intro stops after a while :)


I suppose they could have solved that by making two identical frame buffers on top of each other and flipping back to the top when they reach the bottom. But they might not have been able to afford twice the blitting.

It's pretty amazing it runs in 512K. Must be lots of preshifting for the background.

User avatar
thomas3
Atari maniac
Atari maniac
Posts: 87
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Enchanted Land parallax scroll

Postby thomas3 » Wed Jan 24, 2018 11:53 am

fenarinarsa wrote:Okay I'm no syncscroll master like you troed or others great people, but I did a quick check of the intro with Steem SSE debug and from what I could see the foreground is indeed achieved with syncscroll (that was an easy find by modifying the colors or by tracing the hbl interrupt).

Since the 4-bit syncscroll technique is certainly not used here, my guess is that it's doing an 16-bit horizontal syncscroll with 4 buffers in which the foreground is written, shifted by 0,4,8,12 pixels. You can actually see this by removing the movep at address $3964 and setting for instance $ff8201=$06 and $ff8203=$10.


Good work, dude! :)

Based on this discussion, I just fired Enchanted Lands up (probably for the first time in about 20 years!) in an old version of Steem, and interestingly the sync is messed right up under this version of the emulator - which very clearly exposes that four buffers are being used.

In terms of drawing the foreground efficiently - as I understand it, Nic/TCB was somewhat of an innovator in using self-modifying/generated code, so I would guess that this would provide part of the solution - I would bet that the draw routines are optimised to only handle transparency when necessary.

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: Enchanted Land parallax scroll

Postby Foxie » Thu Jan 25, 2018 12:10 am

thomas3 wrote:In terms of drawing the foreground efficiently - as I understand it, Nic/TCB was somewhat of an innovator in using self-modifying/generated code, so I would guess that this would provide part of the solution - I would bet that the draw routines are optimised to only handle transparency when necessary.


That kind of thing blows my mind. But as far as I understand, it's difficult to get huge speed gains by self-modifying sprite code because of the planar display?

I guess they could break the screen into tiles, and only draw the background transparently on half-filled tiles? It doesn't really explain how the floor scrolling is done. I think the floor is only a few planes. Or they might be using the four framebuffers as an animation loop?

User avatar
thomas3
Atari maniac
Atari maniac
Posts: 87
Joined: Tue Apr 11, 2017 8:57 pm
Location: the people's republic of south yorkshire, uk.

Re: Enchanted Land parallax scroll

Postby thomas3 » Thu Jan 25, 2018 9:54 am

Foxie wrote:That kind of thing blows my mind. But as far as I understand, it's difficult to get huge speed gains by self-modifying sprite code because of the planar display?


Tbh, this is now way past my pay grade :). However, as far as I understand it, you can make some pretty huge gains with these methods. (They're on my "to try" list for this year!).

But also, and whilst this is kind of a lame response, I think this also has to be accepted as a product of the genius of Nic... I don't think I appreciated at the time just how innovative and "far ahead" his stuff was. Looking at something like the Spreadpoint screen from the Cuddly Demos - so, so much going on AND digisound - just amazing when you consider what other people were doing at the time, and the very rapid evolution of TCB demos over those few years.

fenarinarsa
Atari User
Atari User
Posts: 43
Joined: Sat Mar 15, 2014 11:23 pm

Re: Enchanted Land parallax scroll

Postby fenarinarsa » Fri Jan 26, 2018 12:21 am

I didn't go that far. But if you use Steem SSE's debugger you will quickly see that the code is quite easy to read and there's a lot of jump to subroutines (jsr) to pointers like jsr (a0). You can replace them with nops ($4e71) and immediately see what you disabled.

That's the way I found out the texte is written by code that is generated once at the beginning of each text display. You can see the code buffer contents change with time. The drawing/restore of the main sprite is done by a static subroutine.

The subroutines are called from various locations so sometimes you disable only 1 screen buffer out of 4, or sometimes a part of the screen.

I don't really know how the parallax floor is done but some parts might be static (you can get 2-frames or 4-frames loop with static contents over the 4 buffers) and some parts in the background are obviously redrawn each time.


Generated code is indeed very powerful when there is a known content to write in memory with few data. For this intro's text a regular blit would copy a whole block including the empty spaces, but the generated code draws only needed areas with instructions like move.w #xxxx,yyyy(a1) where xxx=graphic data and yyy=where to put it, and very easy to change in 68000 opcode.
Generated code often loses its interests for whole 4bpp blocks where multiple movem are faster (often used to clear screen for instance).
And of course if you're on STE/Mega ST you can use the blitter, which is at least the same speed or faster with less memory used (except for very small blocks). Sometimes the code is so optimized it won't change anything, like in Wings of Death in which the blitter option does nothing except messing with the player inputs :)

User avatar
Frank B
Atari Super Hero
Atari Super Hero
Posts: 961
Joined: Wed Jan 04, 2006 1:28 am
Location: Boston

Re: Enchanted Land parallax scroll

Postby Frank B » Fri Jan 26, 2018 3:33 pm

fenarinarsa wrote: Sometimes the code is so optimized it won't change anything, like in Wings of Death in which the blitter option does nothing except messing with the player inputs :)



Wings of death is frame locked at 3 vbl like Lethal Xcess. Even at 60 hz. Try the fast 25 fps L.E cheat with and without a blitter. One mode drops to 3 vbl far less often ;) It might be fun to nobble the frame lock on wings of death. It runs at a constant 3 vbl in 50/60 hz. See if that makes a difference.

TL/DR : The blitter makes a significant difference on LX compared to pre shifted CPU sprites.


Social Media

     

Return to “Games - General”

Who is online

Users browsing this forum: No registered users and 2 guests