This tutorial corresponds to file “C64/DemoMaker/demo_part5.ras” in the TRSE tutorials folder.
In this final part, we’ll be adding some transitions to both the image shower effect and that funky character sqrt/atan2 thingy. Smooth transitions will make everything look better, because having a “turn on / turn off” transition as in the current setup of our demo looks somewhat harsh. Transitions in itself can be quite advanced, blending effects together and will improve the overall quality of the demo.
Example of simple C64 transitions:
- Fading colours to / from dark
- Vertical/horizontal sliding black “carpet”
- Slowly filling the current character set with zero
Example of some more advanced C64 transitions:
- Blending two effects by having them run simultaneously on two banks and timing the raster to go from one effect to the other
- fading clors/from dark with a pattern (like circles, lines etc)
In this tutorial, we will focus on two very simple types of transitions: some horizontal/vertical “black carpet” when displaying our image, and filling/copying data from the current character set in that sqrt/atan2 charset effect. Let’s define intro transitions to be transitions when a scene is starting – and transitionMode = 0, while outro transitions end-scene transitions when the transitionMode variable is set to 1.
Let’s take a look at a simple image transitioning method.
Image transitions
First, we added a transition variable “tVal” to our list of variables. This value will typically contain the “transiton counter value”, which will start at a value (say 0) and end up at another value (say 25, the number of lines on the screen). We’ll also be using another variable aptly named “b” that keeps track of the outro transition. Here’s a transition method for scene 1:
procedure TransitionScene1();
begin
if (transitionMode=0) then begin
// Transition IN : Copy colors to screen at y=tVal
// Copy color $4400 data
if (tVal>25) then return();
moveto(0,tVal, $48);
zp1:=screenmemory;
inczp(zp1,2);
moveto(0,tVal, $44);
memcpy(zp1, 0, screenmemory, 40);
// Copy color $D800 data
inczp(zp1,250);
inczp(zp1,250);
inczp(zp1,250);
inczp(zp1,250);
moveto(0,tVal, $D8);
memcpy(zp1, 0, screenmemory, 40);
if (time&1=0) then
inc(tVal);
end
else
begin
if (b<21) then begin
moveto(0,0,$44);
zp1:=screenmemory;
moveto(0,0,$D8);
for i:=0 to 25 do begin
zp1[b]:=0;
zp1[39-b]:=0;
screenmemory[b]:=0;
screenmemory[39-b]:=0;
inczp(zp1,40);
inczp(screenmemory,40);
end;
if (time&1=0) then
inc(b);
end;
end;
end;
Intro Explanation:
- First of all, we start with all the image data located at $6000 – but in the *initScene1()* method, instead of copying the color data to color ram at $4400 and $D800 – we just fill the space with black as such clearscreen(0,^$4400);clearscreen(0,^$D800);
- When transitionMode is 0, that is, during the intro transition, we basically set the y-position to “tVal” on screen memory ($4400+40*tVal) and copy 40 bytes of color information. We then increase 1000 bytes to the $D800-value in the data, and copy the 40 lines to color ram.
- When done, increase tVal
- if tVal>25 (number of rows in the screen), no more transitions – the image has been “rolled out”
Outro Explanation:
- The outro transition is only called whenever transitionMode is set to 1 (outro transition is triggered)
- We use the variable “b” as our outro variable. It initializes at zero
- For each time the outro transition is called, we basically just set the color memory (in $4400 and $D800) to black in column [b] and column[39-b]
- By clearing columns from both sides of the screen, it looks like a “carpet” is closing in on the scene.
Scene 2 transitions
In scene2, we’ll perform a different form of transition. Since the demo effect is based on 16 8-byte characters from our user-definde character set, the easiest way is to start out is by copying the original charset to a fixed memory address and then clearing (setting to all zeros) the original 16*8=128 bytes of data. This will ensure that the effect starts out completely black. Our intro method therefore now contains
tVal:=0;
// Copy 16*8 byte charset to somewhere else
memcpy(^$6800+^@scene2charval*^8,0,^$7000,128);
// Fill charset blank
fill(^$6800+^@scene2charval*^8,0,128);
where we have chosen $7000 as the memory address to store the original 128 bytes of 16 chars. Let’s take a look at the transition procedure:
procedure TransitionScene2();
begin
if (transitionMode=0) then begin
if (tVal>16) then begin tVal:=24;return(); end;
p1:=$7000;
p2:=$6800+^@scene2charval*^8;
if (tVal<>0) then begin
inczp(p1,tVal*8);
end;
memcpy(p1,0,p2,8); // Copy single character
inc(tVal);
end
else
begin
if (tVal>127) then return();
moveto(0,tVal,$44);
fill(screenmemory,$20,40);
dec(tVal);
end;
end;
Intro transition explanation:
- As in the scene1, we reuse “tVal” as our transition value variable, here initialized at 0.
- During the intro transition (transitionMode=0), we copy a single character (8 bytes) from the temporary storage at $7000 + 8*tVal to the first character in the active charset memory position. Since the charset is constantly “shifting” each frame (that is, we shift the 16 characters by 1 char each frame), we only need to copy to the first position.
- When all values have been copied (tVal>16), we just prepare tVal for the outro transition mode by setting it to 24 (number of lines on the screen
Outro transition:
- When the outro initializes (transitionMode becomes 1), tVal should be set to 24.
- We then move the screen cursor to x=0, y=tVal and fill 40 chars with spaces.
- if tVal is negative (>127) then the screen has been cleared, if not, decrease tVal and wait for next raster to clean the next line.
And that’s it! Some simple demo transitions.