Star Wars Scroller Routine
Star Wars Scroller Routine
This function scrolls the screen in a 'Star Wars' style and can be called from BASIC.
Start by printing up to 16 characters of text in the top-left corner of the screen, hidden by using the same INK and PAPER colour, then call this routine 16 times. Print another line of text, and repeat.
It expands the text 2x, then scrolls it up the screen, squeezing as it goes. Note that it draws in the bottom two lines of the screen that you can't normally print on from BASIC, so you have to POKE the desired attributes in to those addresses before you run it (see the BASIC demo).
Demo and source code: http://railtron.com/files/spectrum/StarWarsScroller.zip
No doubt it can be optimised a lot. Also it could be tweaked to not always wipe out the same pair of doubled-up pixels quite so quickly (where some of the upright lines in the text vanish altogether too soon), but it's too hard for me to work out right now.
Start by printing up to 16 characters of text in the top-left corner of the screen, hidden by using the same INK and PAPER colour, then call this routine 16 times. Print another line of text, and repeat.
It expands the text 2x, then scrolls it up the screen, squeezing as it goes. Note that it draws in the bottom two lines of the screen that you can't normally print on from BASIC, so you have to POKE the desired attributes in to those addresses before you run it (see the BASIC demo).
Demo and source code: http://railtron.com/files/spectrum/StarWarsScroller.zip
No doubt it can be optimised a lot. Also it could be tweaked to not always wipe out the same pair of doubled-up pixels quite so quickly (where some of the upright lines in the text vanish altogether too soon), but it's too hard for me to work out right now.
Re: Star Wars Scroller Routine
This is great @Joefish! And thanks for making it available for general use—I'm already loosely thinking about Woot.
Re: Star Wars Scroller Routine
Great stuff....!
I would've 100% thought someone would've done this scroll before, but not sure I've seen one till now.
Ooh... Ooh... I wonder if it'd be possible to do this scrolling message while the game is loading..? That would've been awesome back in 87/88
(Oi - stop throwing things at me..! )
I would've 100% thought someone would've done this scroll before, but not sure I've seen one till now.
Ooh... Ooh... I wonder if it'd be possible to do this scrolling message while the game is loading..? That would've been awesome back in 87/88
(Oi - stop throwing things at me..! )
My Speccy site: thirdharmoniser.com
Re: Star Wars Scroller Routine
Now we just need the Star Wars tune as an AY track (don't suppose you fancy it @Lee Bee? )
Come to think of it, I can't think of any custom loaders that have even a regular text scroller. But if Joe Blade can have Pacman then this must be possible too.
- arkannoyed
- Manic Miner
- Posts: 438
- Joined: Mon Feb 05, 2018 9:56 am
- Location: Northamptonshire
Re: Star Wars Scroller Routine
Bobby Bearing
- Ast A. Moore
- Rick Dangerous
- Posts: 2641
- Joined: Mon Nov 13, 2017 3:16 pm
Re: Star Wars Scroller Routine
Vectron.
Every man should plant a tree, build a house, and write a ZX Spectrum game.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
- Lee Bee
- Dynamite Dan
- Posts: 1297
- Joined: Sat Nov 16, 2019 11:01 pm
- Location: Devon, England
- Contact:
Re: Star Wars Scroller Routine
Jason's scroller came about on @HEXdidnt's Empire Strikes Back thread, where I posted a (technically impossible) visual of how such a scroller could look, postulating that some whizz coder might actually be able to achieve something like this—which Jason proved correct! Much earlier in that thread, I also posted a Star wars tune. Only a work-in-progress, but I shall be completing it for HEX's upcoming slideshow
Re: Star Wars Scroller Routine
Takes up far too much CPU time to be used in a loader. It could be optimised; it's copying up whole pixel rows every time rather than narrowing its efforts as the text narrows. But it'd still be far too intensive.
I can maybe tweak it to better preserve the legibility of the text, and moving it up two rows would help with calling it from BASIC.
I can maybe tweak it to better preserve the legibility of the text, and moving it up two rows would help with calling it from BASIC.
Re: Star Wars Scroller Routine
Sick of browsers that refuse to even pull a sodding GIF off a site that doesn't have SSL. Bunch of gits.
And apparently I can't spell 'Fortresses'. Then again 16 letters on a line is not a lot. I guess you could do better with proportional printing.
https://cluster3.secure-staging.uk/rail ... roller.zip
And apparently I can't spell 'Fortresses'. Then again 16 letters on a line is not a lot. I guess you could do better with proportional printing.
https://cluster3.secure-staging.uk/rail ... roller.zip
Re: Star Wars Scroller Routine
Not sure how you're getting stray blank lines across that. It should copy each line up from the line below, before moving down to do the the next one. So even if there's raster tearing there shouldn't be any blank lines in the screen memory at any time.
Re: Star Wars Scroller Routine
Not sure why, but that happens when I BREAK into the BASIC near the start of the scrolling, and then RUN 40. If I wait for it to do a full loop it seems okay. I haven't used the asm listing yet.
- flatduckrecords
- Manic Miner
- Posts: 787
- Joined: Thu May 07, 2020 11:47 am
- Location: Oban, Scotland
- Contact:
Re: Star Wars Scroller Routine
I noticed that in Fuse. Emulator bug maybe?
- flatduckrecords
- Manic Miner
- Posts: 787
- Joined: Thu May 07, 2020 11:47 am
- Location: Oban, Scotland
- Contact:
Re: Star Wars Scroller Routine
Thanks for sharing this @Joefish, I've been having fun adapting it to SAM's screen MODE 3.
Each line that it operates on is now 384px wide (96 bytes at 2bpp) up from 256px (and 32 bytes at 1bpp). I've adjusted the loops and tripled each of the values (which gives the result pictured) but I'd like to make the angles *steeper* (i.e. make the upper rows narrower) so that the perspective looks correct. Can you give me any pointers?
Can you explain a wee bit about the squeezing, and in particular how you derived the numbers for the shift_table please?
Each line that it operates on is now 384px wide (96 bytes at 2bpp) up from 256px (and 32 bytes at 1bpp). I've adjusted the loops and tripled each of the values (which gives the result pictured) but I'd like to make the angles *steeper* (i.e. make the upper rows narrower) so that the perspective looks correct. Can you give me any pointers?
Re: Star Wars Scroller Routine
It was all vague guesswork.flatduckrecords wrote: ↑Wed Aug 23, 2023 1:15 pm Can you explain a wee bit about the squeezing, and in particular how you derived the numbers for the shift_table please?
The number indicates how many bytes, counting from the left, get rotated by 1 pixel to the right, before the rest are just copied up from the line below. On the next line, the same value is used, but this time counting in from the right. So it manages to lose a pixel somewhere along each line, but always at a byte boundary. Each value in the shift_table thus corresponds to two lines of the screen and thus two entries from the line address table. Note there are 80 entries in the shift_table, and the scroll works over 160 rows. The number in the table should be 15 or less, such that the point where a pixel is lost never crosses the centre of the screen.
First, you have to keep track of how wide the scroll is at each row, and make sure the number you've chosen extends as far as the remaining pixels. Or else it'll just take a pixel out of the empty space beside the scroller. You judge this because every 16 rows the scroll gets 16 pixels narrower, 8 in from the left and 8 in from the right. You could add an extra factor to the table to skip the blank space on a row first, if you'd like to optimise it a bit.
Then it's guesswork. I start from the bottom up; pick a number somewhere part-way along the row, from 0-15. Then another, and another. I try to distribute them evenly along the row, scattering back and forth, for 8 numbers picked from 1-15. That's the last group of numbers labelled with the ';1' comment.
The next row up, labelled ';2', the scroll is now a byte narrower, so the numbers must be from 2-15, and so-on, up to the top, where the numbers run from 10-15. The last few use '16' so everything shifts inward 1 pixel, to help with aligning the stipple that gets applied on the last few rows.
As I ran it, I found lots of cases where a pixel is removed, then because the lines move inward, the pixel right next to it gets taken out a few lines above, and so a 'doubled-up' pixel completely disappears, rather than all the doubles being gradually whittled away. I haven't figured out a way to predict and avoid this yet. You can try to track it happening - I put a grid of BRIGHT 0/1 white squares over the screen and watch it run to try to track the points these problems occur, then try an tweak the relevant number. But it's a painful process. It'd be easier if you could take out a specific pixel on each row, but I have to do it all at byte edges for speed.
Note also that the scroll up the screen shifts varying numbers of lines counting up from the bottom - not always the full 160. This means that as you go up the scroller, various lines get over-written by the one below and disappear entirely. This squeezes the text vertically. Again, I need to look at tweaking this so that doubled-up rows don't entirely disappear.
I'm trying to refine it for this version, but it's hard work.
- HEXdidnt
- Manic Miner
- Posts: 224
- Joined: Thu Mar 09, 2023 2:40 pm
- Location: Harrow, London, UK
- Contact:
Re: Star Wars Scroller Routine
Well, it's pretty frickin' impressive for guesswork!
Curious to see any refinements you make, as it's already looking amazing, considering the comparatively low screen resolution and low-definition fonts: 8 x 8 pixels (or 6 x 6 in most cases) really ain't a lot to work with!
...Dropping litter in the zen garden of your mind
The Hub of all things HEXdidn't... | HEXdidn't... on YouTube ...on ZXArt ...on deviantart
The Hub of all things HEXdidn't... | HEXdidn't... on YouTube ...on ZXArt ...on deviantart
- MatGubbins
- Dynamite Dan
- Posts: 1239
- Joined: Mon Nov 13, 2017 11:45 am
- Location: Kent, UK
Re: Star Wars Scroller Routine
Bloody brilliant!
During the early 90s I remember seeing an Atari ST demo in a shop performing the opening Star Wars scroller and wondered how it was done.
Now it's on the Spectrum....
Thank you indeed.
During the early 90s I remember seeing an Atari ST demo in a shop performing the opening Star Wars scroller and wondered how it was done.
Now it's on the Spectrum....
Thank you indeed.
Re: Star Wars Scroller Routine
I seem to remember seeing an ST one that had a few single columns of text going up the screen, not whole rows of text, but that sort of thing was always done with a fixed pattern of stripes in 8 colours, then redefining the colours per line to make the pattern look like text characters. Kind of like how the road in Roger The Pangolin works - the road edges are fixed, curved lines of pixels. It only manipulates the attributes line-by-line to make them appear different colours.
The Star Wars game did something like it, but with vector versions of the font so it was all done mathematically.
The Star Wars game did something like it, but with vector versions of the font so it was all done mathematically.
- flatduckrecords
- Manic Miner
- Posts: 787
- Joined: Thu May 07, 2020 11:47 am
- Location: Oban, Scotland
- Contact:
Re: Star Wars Scroller Routine
Thanks for the explanation @Joefish, that was really helpful.
The other change I made was to remove a pixel from *both* sides of each row, so the column of text narrows twice as quickly.
I've just sent @HEXdidnt a demonstration (so I won't spoil it with a screenshot here yet!)
I thought I'd try prime numbers for this. (I think it works because they aren't divisors of each other, so the distribution of discarded pixels is inherently even? I'm not sure, in any case it helped to get rid of the "warping" I was getting from just picking random numbers). I've got rows of 96 bytes, so I used primes in the range 1-47 and sort of interleaved them as you described bottom-to-top, and it seemed to work quite well.
The other change I made was to remove a pixel from *both* sides of each row, so the column of text narrows twice as quickly.
I've just sent @HEXdidnt a demonstration (so I won't spoil it with a screenshot here yet!)
- HEXdidnt
- Manic Miner
- Posts: 224
- Joined: Thu Mar 09, 2023 2:40 pm
- Location: Harrow, London, UK
- Contact:
Re: Star Wars Scroller Routine
The latest version is looking fantastic - thank you @flatduckrecords and @Joefish for making this happen!
Honestly, MODE 3 is amazing for this kind of effect.
Honestly, MODE 3 is amazing for this kind of effect.
...Dropping litter in the zen garden of your mind
The Hub of all things HEXdidn't... | HEXdidn't... on YouTube ...on ZXArt ...on deviantart
The Hub of all things HEXdidn't... | HEXdidn't... on YouTube ...on ZXArt ...on deviantart
Re: Star Wars Scroller Routine
Impressive and something I always wanted to do, but never could. My first experience was just an scroller from bottom to top, this I used in FUN PART DEMO (https://zxdemo.org/productions/13070/ last part ). Later then I had the idea of making a scroller from bottom and top at the same time. I made this in IRON-I ( https://zxdemo.org/productions/13205/ also last part). But all was just done because I couldn´t do the Star Wars scroller.
Will happily investigate the source code.
Will happily investigate the source code.
Re: Star Wars Scroller Routine
Actually, I've noticed a blank-line glitch in it too. It's mostly disguised amongst the blank rows you'll get from using the regular Speccy font, but it shows up if you use an 8-pixel high pattern.