/*
 * Nibbled XEVIOUS (アセンブラ版)
 * -- GMC-4 で動く 4bit ゼビウス --
 *
 * 6番のLEDを上にして縦に置きます．
 * 0番のLEDの下にあるネジがソルバルウです．
 * 3番のLEDが光っているのはブラスターの照準だからです．
 * 4,5,6番のLEDはトーロイドです．
 * 何かキーを押すとザッパーを発射します．
 * スコアが数字LEDに表示されます．
 * 
 */


	TIY 0		# initialize music index Zr
	CH

START:

	TIY E		# screen scroll (screen <<= 1)
	MA
	M+
	AM

	KA		# if(inputKey())
	JUMP NOKEY
	TIA 1		#   screen = 1
	AM		

NOKEY:

	CAL DSPR	# show LED

	TIY D		# show score
	MA
	AO

	TIY F		# enemy reborn
	MA
	CIA 8
	JUMP NOREBORN
	TIA 7
	AM
NOREBORN:		
		
	TIY E		# screen == 8
	MA
	CIA 8
	JUMP NOHIT
	
	TIY F		# enemy dead (enemy <<= 1)
	MA
	M+		
	AM

	CIA 0		# enemy != 0 then score++
	JUMP NOALLDEAD
	JUMP NOHIT
NOALLDEAD:	
	TIY D		# score
	MA
	AIA 1
	AM
NOHIT:

	CH		# music
	MA
	CAL SUND
	AIY 1
	CIY 8
	JUMP NOMIRESET
	TIY 0
NOMIRESET:	
	CH

	JUMP START

	.align 50

	.nibble 3	# 0x50 music data
	.nibble A	# 0x51 music data
	.nibble 9	# 0x52 music data
	.nibble A	# 0x53 music data
	.nibble C	# 0x54 music data
	.nibble A	# 0x55 music data
	.nibble 9	# 0x56 music data
	.nibble A	# 0x57 music data
	.nibble 0	# 0x58
	.nibble 0	# 0x59
	.nibble 0	# 0x5A
	.nibble 0	# 0x5B
	.nibble 0	# 0x5C
	.nibble 0	# 0x5D score = 0
	.nibble 0	# 0x5E screen = 0
	.nibble 7	# 0x5F enemy = 7
