/***********************************

126 bytes VIC-20 intro by
Andreas Gustafsson aka. Shadow/Noice
Written 2008-08-05 - 2008-08-08

Size breakdown:
  2 bytes PRG-file load address ($1001)
 47 bytes BASIC sinegen and startup
  8 bytes init-code
 25 bytes logo unpack and draw
 17 bytes swing effect
 27 bytes logo data
---
126 bytes 

************************************/

.var SINE=$1100

.pc = $1001 "Basic"

/*
BASIC code to generate sine and start program (47 bytes)
0 FORI=0TO255:POKE4352+I,80+50*SIN(I/40.7):NEXT:SYS4144
*/

.byte $2e,$10,$00,$00,$81,$49,$b2,$30
.byte $a4,$32,$35,$35,$3a,$97,$34,$33
.byte $35,$32,$aa,$49,$2c,$38,$30,$aa
.byte $35,$30,$ac,$bf,$28,$49,$ad,$34
.byte $30,$2e,$37,$29,$3a,$82,$3a,$9e
.byte $34,$31,$34,$34,$00,$00,$00


.pc = $1030 "Code"
	
/*
** Init part (8 bytes)
*/	
	// Clear screen	
	jsr $e55f 
	// Set bg/fg color to white
	lda #%00010001 
	sta $900f	
/*
** Unpack the logo from RLE and draw it (25 bytes)
*/
	ldx #27
logoloop:
	lda logo-1,x
	pha
	lsr
	lsr
	lsr
	tay
	pla
	and #$07
putchar:
	sta $9600
	inc putchar+1		
	dey
	bne putchar
	dex
	bne logoloop
/*
** Swing up and down (17 bytes)
*/	
start:	
	// Wait for rasterline
	lda $9004	
	bne start
	// Waste some cycles so we don't retrigger at same line
!wait:	
	dey			
	bne !wait- 
	// Set vertical cenetering  
pos:	
	lda SINE,x	
	sta $9001	
	inx
	bvc start

.pc=* "Logo"

/*
** 22x4 chars logo packed as very simple RLE data (27 bytes)
*/
logo:
	.byte $35,$11,$32,$11,$16,$11,$16, $21,$15,$11,$12,$11,$12,$11,$16,$11,$16, $41,$12,$31,$16,$21, $35,$11,$32,$11,$36
