K65 Tutorial 1

From KK's Wiki
Jump to: navigation, search

This is Tutorial 1 for K65 compiler.

Note that this tutorial uses Alternate VCS definitions file.


/*
*	Tutorial 01 - simple raster bar animation
*
*
*/
 
var anim = 0x80;	// RAM address alias
 
 
 
// entry point block is declared with "main"
main {
	init	// function/inline call (defined in _defs.k65)
 
	{
		sync1				// enter overscan (yes, we start here from end of display)
 
		// some free time here
 
		sync2				// trigger VSYNC
 
		// more free time here
 
		sync3				// display field start
 
		x=224				// that's LDX
		y=anim				// and that's LDY
		{
			wsync			// inline again, this time wait for horizontal blank
			cbg=y			// STY
			y++				// INY
			x--				// DEX
		}!=					// repeat (jump) if not zero/not equal (flag Z=0)
		cbg=a=0				// "p=q=r" is a shortcut for "q=r p=q" for any p/q/r
 
		anim++				// INC
 
	} always	// loop forever (jump)
}