' Six bars - use ATM88 or above ' 0x3C = Block ' 0x3E = Half block $crystal = 20000000 $BAUD = 0 ' Reserve screen variable area at start of RAM ' Assembler interrupt code has two byte variables IN BETWEEN two word variables Dim ScreenAddr1 as word at $100 Dim RAMVar1 as byte at $102 Dim RAMVar2 as byte at $103 Dim ScreenAddr2 as word at $104 Dim ScreenRAM(600) as byte AT $106 Dim Addr As Word Dim NumChar as byte Dim MaxBar as byte Dim Bar as byte Dim I as byte Dim Colour as byte On Oc2a Tvinterrupt Nosave Goto Main !.org $100 $inc Tvinterrupt , Nosize , "tvinc.bin" Return Main: ' Set up clock division - only need to do this if DIV8 fuse not set, as default fuse setting is div. by 8 Config Clockdiv = 1 ' CLKPR=$80 ' CLKPR=0 ' Setup timer 2 TCCR2B=$02 OCR2A=158 OCR2B=160 TIMSK2=&b00000110 ' Now set up sleep mode [SMCR = Sleep Mode Control Register] - must be enabled or TV code cannot work accurately SMCR=1 ' Set PORTB to all outputs for video signal DDRB=$FF ' Enable & config SPI SPCR=$54 SPSR=1 ' Init RAM variables for interrupt code RAMVar1=0 RAMVar2=0 ScreenAddr1=$106 ScreenAddr2=$106 ENABLE OC2A ' ENABLE OC2B ENABLE INTERRUPTS ' Now continue with user code Do Addr=1 ' Set Addr to address of first screen location NumChar=$30 ' ASCII value for 0 ' Display three sets of alternately coloured bars GoSub TwoBars GoSub TwoBars GoSub TwoBars Incr Addr ScreenRAM(Addr)=13 ' Decimal {012} = $0C = END OF LINE MARKER ' Decimal {013} = $0D = END OF SCREEN MARKER ' Decimal {017} = $11 = Green on black ' Decimal {019} = $13 = Cyan on blue ' Decimal {020} = $14 = Yellow on red ' Decimal {022} = $16 = White on magenta Wait 1 Loop TwoBars: Incr NumChar Colour=19 GoSub DisplayBar Incr NumChar Colour=20 GoSub DisplayBar Return DisplayBar: ScreenRAM(Addr)="B" Incr Addr ScreenRAM(Addr)="a" Incr Addr ScreenRAM(Addr)="r" Incr Addr ScreenRAM(Addr)=" " Incr Addr ScreenRAM(Addr)=NumChar Incr Addr ScreenRAM(Addr)=":" Incr Addr ScreenRAM(Addr)=12 Incr Addr ' Display row of bar characters plus an end of line char MaxBar=45 Bar=RND(MaxBar) Incr Bar ' Make sure Bar is not zero, between 1 and 46 ScreenRAM(Addr)=Colour Incr Addr For I=1 to Bar ' Write a bar character for each unit in "Bar" ScreenRAM(Addr)=$3C Incr Addr Next I ScreenRAM(Addr)=" " ' Write a space Incr Addr Incr Bar ScreenRAM(Addr)=17 ' Write a green on black command to end bar Incr Addr Incr Bar For I=Bar to 50 ' Write number of spaces to make bars all the same length (makes screen steady) ScreenRAM(Addr)=" " Incr Addr Next I ScreenRAM(Addr)=12 ' Write end of line character Incr Addr Return End