#include "digirule2.h"

#if SAMPLE_PROGRAMS

static const uint8 sample_programs[8][256] __at( USER_FLASH ) =
{
	// Program 0 - "KILL THE BIT"
	{
		SPEED, 32,							// was 130
		COPYLR, 1, DataLEDRegAddr,
		SHIFTRL, DataLEDRegAddr,
		COPYRA, ButtonRegAddr,
		XORRA, DataLEDRegAddr,
		COPYAR, DataLEDRegAddr,
		JUMP, 5,
	},
	
	// Program 1 - "POV SMILEY FACE"
	{
		SPEED, 1,							// was 17
#if LEGACY_ADDRPC
		COPYLR, 2, 240,
#else
		COPYLR, 0, 240,
#endif
		CALL, 32,
		COPYAR, DataLEDRegAddr,
		COPYRA, 240,
		ADDLA, 2,
		COPYAR, 240,
		JUMP, 5,
				
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 

		ADDRPC, 240,
		RETLA, 126,
		RETLA, 129,
		RETLA, 165,
		RETLA, 129,
		RETLA, 165,
		RETLA, 153,
		RETLA, 129,
		RETLA, 126,
		NOP,
#if LEGACY_ADDRPC
		COPYLR, 2, 240,
#else
		COPYLR, 0, 240,
#endif
		JUMP, 32,
	},
	
	// Program 2 - "8-BIT COUNTER"
	{
		SPEED, 130,							// was 143
		COPYLR, 0, DataLEDRegAddr,
		INCR, DataLEDRegAddr,
		JUMP, 5,
	},
	
	// Program 3 - "16-BIT COUNTER"
	{
		SPEED, 13,							// was 129
		SBR, 2, StatusRegAddr,
		COPYLR, 0, DataLEDRegAddr,
		COPYLR, 0, AddressLEDRegAddr,
		INCRJZ, DataLEDRegAddr,
		JUMP, 11,
		INCR, AddressLEDRegAddr,
		JUMP, 11,
	},
	
	// Program 4 - "KNIGHTRIDER"
	{
		SPEED, 20,							// was 129
		COPYLR, 1, DataLEDRegAddr,
		SHIFTRL, DataLEDRegAddr,
		BCRSS, 7, DataLEDRegAddr,
		JUMP, 5,
		SHIFTRR, DataLEDRegAddr,
		BCRSS, 0, DataLEDRegAddr,
		JUMP, 12,
		JUMP, 5,
	},
	
	// Program 5 - "BUTTON TEST"
	{
		SPEED, 1,							// was 1
		COPYRR, ButtonRegAddr, DataLEDRegAddr,
		JUMP, 2,
	},
	
	// Program 6 - "TARGET PRACTICE"
	{
		SPEED, 17,							// was 129
		SBR, 2, StatusRegAddr,
		COPYLR, 0, AddressLEDRegAddr,
		COPYLR, 1, DataLEDRegAddr,		
		SHIFTRL, DataLEDRegAddr,
		CALL, 32,
		BCRSS, 7, DataLEDRegAddr,
		JUMP, 11,
		SHIFTRR, DataLEDRegAddr,
		CALL, 32,
		BCRSS, 0, DataLEDRegAddr,
		JUMP, 20,
		JUMP, 11,
				
		0,

		COPYRA, ButtonRegAddr,
		ADDLA, 0,
		BCRSC, 0, StatusRegAddr,
		RETURN,
		HALT,								// NOP in spreadsheet
		ANDRA, DataLEDRegAddr,
		BCRSC, 0, StatusRegAddr,
		JUMP, 0,
		INCR, AddressLEDRegAddr,
		RETURN,
	},
	
	// Program 7 - "POLICE FLASHER"
	{
		SPEED, 162,							// was 140 (134 in spreadsheet)
		SBR, 2, StatusRegAddr,
		COPYLR, 15, DataLEDRegAddr,
		COPYLR, 240, DataLEDRegAddr,
		NOP,								// added for symmetry with JUMP
		COPYLR, 15, AddressLEDRegAddr,
		COPYLR, 240, AddressLEDRegAddr,
		JUMP, 5,
	},
};

#endif
