A downloadable project

Ten Line Demoscene Program Explanation

1) Setup the display settings: screen 1, doublesize sprites, etc.  Define all variables as integers and turn off the on-screen key shortcuts.

Next, POKE&HF3B1 with the value 25. This is the memory register that defines the number of lines of text that you can print to. The default is 24, but I set it to 25 so that I can print to the entire screen without the text scrolling up at line 23. This will be reset back to 24 in line 6.

The FOR I=520 to 727 loop is what makes the text bold. Basically, it reads the data from vram and then OR's it with itself divided by 2, which bit-shifts the pixels to the right by 1 and when OR'd with the original graphic creates the bold effect. It's amazingly clever, which is why I copied it from Jos'B's 2020 10-liner Waterworm.

The next FOR loop is a nested loop which then reads the bold text from vram and pokes the graphics into the sprite table while doubling each line vertically to make extra tall text.

2) Dimension array Q() (used for the sine effect)

The nested FOR loop redefines the characters for the outer rows of animating tiles (Characters 40 through 63)

The next nested FOR loop redefines the characters for the middle row of animating tiles (Characters 33 through 36)

Define a few strings that will be used to print the animating rows.

Dimension array N() and fill it with values for the musical notes.

3) This line is where we fill the 4 seperate pages with graphics to create the scrolling animation.

In screen mode 1, you can have up to 6 seperate screens predefined with characters. By poking 63779 with 4, 8, 12, 16, 20 or 24, you can switch between which of the 6 pages to print to.

In this FOR loop, the middle row of the animation gets printed across pages 1 through 4.

Next, a bunch of variables get defined and we GOSUB to line 9 where the other rows of the animation get printed.

The last FOR loop sets the character colors for the sine animation (line 8)

4) String S$ is the text for the text scroller

String M$ is the first part of the music data. 0=silent, 1 to 8 = C4 through C5

5) The nested FOR loop reads the data for the characters that will be printed to screen for the sinewave effect and then duplicates them 3 times. Why 3 times? well, it makes it easier to swap the colors around when the waves move from the inner to outer positions. To do that, I just increase the character # to print by 8 which changes to the next set of identical characters, but in a different color.

The next FOR loop reads the sinewave data and converts it into a list of which characters are to be printed and stores it in array Q()

Z$ is the rest of the music note data, which gets combined with M$ and then put in array M$() for quick access. 

6) Set the colors for the scrolling animation's characters... I probably could have shortened this with a FOR loop, but I didn't.

Set some default sound values.

Positioning sprite 0 horizontally at 32 allows the sprites to wrap around the screen properly. Setting the vertical position to -1 prevents the sprites from getting put at 208 and 216, which would cause them to flicker.

Restore the system to using 24 rows of text instead of the 25 that got set in line 1.

7) This is where the magic happens!  I'd like to thank thegps and his 2020 10-liner SeuTen for showing me how to use / switch the pages, it's very useful for something like this.

Increment V by 1, this will be used as the animation index.

Increment U by 1, this will be used for music timing.

VDP(2) is used to switch which page is displayed. This is different from poking 63779, as that changes which page is being printed to. Setting VDP(2) to 1 through 6 will set which page is currently displayed.

The FOR loop is what makes the text scroll. This is the most efficient way I could come up with, but it has strict limitations. By stepping the sprites by 31 pixels, this positions the sprites 31 pixels after the last moved sprite. Since there are 8 double sized sprites being moved together, and the sprite positions wrap around, this results in an 8 pixel movement of the entire row of sprites and creates a seamless loop.

One thing to note is the Z=(Z+1)MOD192. 192 is the length of the text string. This MUST be a multiple of 8 otherwise the text will get messed up.

Increment Y, which is used as a timing index for the text.

Gosub to 10 to check if it's time to play a sound.

If Y=0 then it's time to update the text.

Start by incrementing M, which is used as a timer to switch between the scrolling effect and the sinewave effect.

Next, increment Z which is our text index value.

Change the sprite that is currently offscreen by using a formula that would probably have been a bit faster if I had precalculated it to an array first. Then continue with line 7

Otherwise if the M index is lower than 64 then continue with line 7

Otherwise if M=64 then change the current print page to page 5, Clear the screen and then show page 5, reset M to 0 and then goto line 8 (Sine effect).

8) This is the sinewave effect.

The FOR loop is for my pseudo sine table which is 34 characters long.

Increment U for the music player.

Value P is used to set the sinewaves near or far apart.

Q(I,0) is the horizontal print location.

G is used to swap which color is being printed when the sinewaves move apart.

Q(I,1)contains which character gets printed.

Locate and print again, but offset by 17 positions in the Q() array.

Gosub to 10 to play music.

H is used to increment P and G.

M is used to count how many times the sine animation plays, and checks if it's time to jump back to the text scroll animation.

9) The FOR loop is where most of the 4 page scrolling animation is printed to the screen.

By using the values that were set in line 3, the locate and print instruction is customized to print most of the animation.

The DATA is mostly for the sinewave effect.

10) This is the music player. I used the SOUND command instead of PLAY because PLAY would introduce large pauses into the program.

If U is not 0 then RETURN, otherwise increment W.

Sound13,0 is the envelope shape of the sounds. Sound1,6 is the tone frequency for the percussion, this switches between a higher and lower tone every 4 beats.

On every beat, set Sound9 to either 12 or 0 depending on the current note value. This is the volume for the note channel. Sound2 and Sound3 are set to the preset values held in N(). To save data, an expression is used to set Sound3 to either 1 or 0 based on the current note frequency.

Increment T to play the next note from the array M() the next time this line is called. 

Download

Download
TenLineDemo.dsk 720 kB
Download
TenLineDemoexplained.bas 6.4 kB
Download
TenLineDemoInstruction.txt 441 bytes
Download
TenLineDemoListing.txt 2.2 kB

Install instructions

Instructions:

To begin, type LOAD"10LDEMO.BAS", and then RUN the program.

Wait about 50 seconds and the demo will begin.

To return to the main screen, type RUN.

Due to the way the program works, it's best to exit the program when the sine wave is diaplayed, otherwise you won't be able to see anything you type. If you do happen to exit the program during the text scroller, you'll need to type VDP(2)=5 or SCREEN0 to fix things.

Leave a comment

Log in with itch.io to leave a comment.