This tutorial corresponds to file “C64/DemoMaker/demo_part4.ras” in the TRSE tutorials folder.
In this tutorial (covering demo_part4.ras), we will add simple demo effect. Actually, in order to not complicate things, the effect is the same as in the original single-file examples (tutorial_23_sqrt.ras), which calculates either “circles” or “lines” on the screen, and then simply shifts the character set in order to create the illusion of movement.
As in the previous example, we’ll start by adding “scene2” to the main file (in this case, demo_part4.ras)
RasterWait and main loop initialization
In RasterWaiter(), make sure that you point to the new scene
procedure InitSceneRaster(); begin if (nextScene=@scene1) then RasterIRQ(RasterScene1(),0,@useKernal); if (nextScene=@scene2) then RasterIRQ(RasterScene2(),0,@useKernal); end; procedure MainLoopInitScene(); begin if (nextScene=@scene1) then InitScene1(); if (nextScene=@scene2) then InitScene2(); end;
Next, let’s check out the scene 2 initialization routine:
procedure InitScene2(); begin SCREEN_BG_COL:=BLACK; SCREEN_FG_COL:=BLACK; setbank(VIC_BANK1); // Use the 3rd column of the timestamp to specify effect color i:=timeStamps[currentPart*4+2]; // Use the 4th column of the timestamp to specify effect type, 0=lines 1 = circles o:=timeStamps[currentPart*4+3]; clearscreen(i,^$D800); enableallram(); decrunch(charset_c); poke(^$01, 0, keep01); RenderScene2Effect(); setcharsetlocation($6800); settextmode(); setregularcolormode(); end;
- As with scene1, we need to access $D000-$DFFF to decrunch the data, so we enable all ram. Remember to restore the memory config with keep01 afterwards.
- We use column 3 of the timeStamp array (or user data #1) to decide the color of the screen
- Column 4 of the timeStamp array (user data #2) decides whether we calculate a screen of “lines (0)” or “circles (1)”. The actual procedure that performs this task is called RenderScene2Effect(), and is covered in tutorial 23.
- Proceed by setting textmode and point character set pointer to $6800.
The raster interrupt of scene2 is somewhat simple:
procedure ShiftCharsetData(); begin memcpy(^$6800+^@scene2charval*^8, 0, ^$6800+^@scene2charval*^8+^128,8); memcpy(^$6800+^@scene2charval*^8+^8, 0, ^$6800+^@scene2charval*^8,^128); end; interrupt RasterScene2(); begin startirq(@useKernal); ProgressTracker(); ShiftCharsetData(); closeIRQ(); end;
The only two notable things that happen are:
- Calling the progress tracker
- Shifting charset with 8 bytes to create the illusion of movement (works as well with circles as with lines)
Finally, all we need to to is update the timeStamp array;
timeStamps: array of byte = ( @scene1, $6, 0,0, @scene2, $A, 4,0, @scene1, $10,2,0 @scene2, $14, 5,1,
Note that we first display image 1, then display “lines (0)” with color 4 = violet, then image 2 and “circles(1)” with color 5 = green.
In the next tutorial, we will add transitions to these effects.