	.ORG $7F80
	.DB "NESM", $1A
	.DB 1
	.DB 1
	.DB 1
	.DW $8000
	.DW START
	.DW EXECUTE
	;    0123456789ABCDEF0123456789ABCDEF
	.DB 'Dark Cre-dolls',0,'                ',0
	.DB 'Cover: x8o                     ',0
	.DB 'Orig: Nakahara M., Shimizu A.  ',0
	.DW $411D
	.DW 0,0,0,0
	.DW $411D
	.DB 0,0
	.DW 0,0

	.pad $8000, $00
 
 .MACRO BI x,y
 	.DB x+y*16
 .ENDM
 
 
Illegal EQU 1

;Variables
FrameCounter=0
DataCounter=1
EnvCounter=2


START:
EXECUTE:
	DEC FrameCounter
	BPL ProcessEnv
	LDA #$13
	STA FrameCounter
	INC DataCounter
	LDA DataCounter
-:
	BMI -
	CMP #19*2+64
	AND #255-64
	BCC +
	ADC #13*2-1
+:
	LSR
	TAX
	LDA Data,X
	BCC +
	LSR
	LSR
	LSR
	LSR
+:
	AND #$0F
	BEQ ProcessEnv
	TAX
	LDA FreqTbl-4,X
	ASL
	STA $4002
	STA $400A
	LDA #$28
	ROL
	STA $4008
	STA $4003
	STA $400B
	LDA #$90
	STA EnvCounter
ProcessEnv:
	INC EnvCounter
	LDA EnvCounter
	CMP #$A0
	BCC +
	EOR #$3F
+:
	STA $4000
	RTS
	
	
Silence=0
B2= $5
Cx3=$7
Dx3=$6
E3= $E
F3= $9
Fx3=$B
G3= $4
Gx3=$8
A3= $C
Ax3=$A
B3= $F
Cx4=$D

B2F=$DF
Cx3F=$C8
Dx3F=$B1 ;
E3F=$A8
F3F=$9E
Fx3F=$95
G3F=$8D  ;
Gx3F=$85 ;
A3F=$7D
Ax3F=$76 ;
B3F=$6F  ;
Cx4F=$64

FreqTbl:
	.DB G3F,B2F,Dx3F,Cx3F,Gx3F,F3F,Ax3F,Fx3F,A3F ;Cx4F,E3F,B3F 
  ;    4   5    6   7    8    9    A   B    C     D   E   F
Data: ;The first 3 bytes should be exactly 64,A8,6F, i.e. Cx4F,E3F,B3F
	BI G3,Dx3    ;0
	BI Gx3,Ax3
	BI B3,Dx3
	BI 0,0
	BI 0,Dx3
	BI Gx3,Ax3
	BI B3,E3
	BI 0,0
	BI 0,0
	BI 0,B3
	BI Ax3,B3
	BI Ax3,Gx3
	BI Fx3,0
	BI Gx3,Dx3
	BI 0,B2
	BI Dx3,Fx3
	BI A3,Gx3
	BI Fx3,Dx3
	BI E3,0
	BI E3,0
	BI Dx3,0    ;20
	BI E3,0
	BI Fx3,0
	BI B3,B3
	BI 0,0
	BI 0,0
	BI Gx3,0
	BI Gx3,Gx3
	BI Gx3,0
	BI G3,Gx3
	BI Ax3,E3   ;30
	BI Dx3,Gx3
	BI 0,E3     ;34
	BI Dx3,E3
	BI Dx3,Cx3
	BI B2,0
	BI Dx3,0
	BI Gx3,0
	BI 0,B3
	BI Cx4,B3
	BI Ax3,Gx3
	BI G3,0
	BI F3,G3
	BI Gx3,0
