See who can recognize this tune

Chat about anything CX16 related that doesn't fit elsewhere
Post Reply
ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

See who can recognize this tune

Post by ZeroByte »


Here's a simple BASIC program that plays a tune on the YM2151. (requires emu r39 or later as the YM2151 address changed)


Quote




10 YA=$9F40:YD=YA+1

11 SP=700

20 FOR CH=0 TO 7 :GOSUB 10000 :NEXT CH

30 POKE YA,$28 :POKE YD,$2E :REM MIDDLE C

40 REM

41 REM

100 READ CH : IF CH>7 THEN 7000

110 IF CH<0 THEN 200

120 READ NO : IF NO = 0 THEN 140

130 GOSUB 9000

131 GOTO 100

140 GOSUB 9100

141 GOTO 100

200 IF CH <> -99 THEN 220

210 RESTORE :GOTO 100

220 FOR I=1 TO SP :NEXT I : GOTO 100

7000 FOR CH = 0 TO 7 :GOSUB 9100 : NEXT CH

7010 PRINT "BAD SONG DATA AT CH=";CH

7020 END

7100 FOR CH = 0 TO 7 :GOSUB 9100 :NEXT CH

7110 END

8000 DATA 0,$1E,-1,1,$21,-1,2,$23,-1,3,$28,-1

8001 DATA 0,$2E,-1,1,$31,-1,2,$33,-1,3,$38,-1

8002 DATA 0,$3E,-1,1,$41,-1,2,$43,-1,3,$48,-1

8003 DATA 0,$4E,-1,1,$51,-1,2,$53,-1,3,$58,-1

8004 DATA 0,$5E,-1,1,$58,-1,2,$53,-1,3,$51,-1

8005 DATA 0,$4E,-1,1,$48,-1,2,$43,-1,3,$41,-1

8006 DATA 0,$3E,-1,1,$38,-1,2,$33,-1,3,$31,-1

8007 DATA 0,$2E,-1,1,$28,-1,2,$23,-1,3,$21,-1

8008 DATA 0,$1E,-1,1,$21,-1,2,$23,-1,3,$28,-1

8009 DATA 0,$2E,-1,1,$31,-1,2,$33,-1,3,$38,-1

8010 DATA 0,$3E,-1,1,$41,-1,2,$43,-1,3,$48,-1

8011 DATA 0,$4E,-1,1,$51,-1,2,$53,-1,3,$58,-1

8012 DATA 0,$5E,-1,1,$58,-1,2,$53,-1,3,$51,-1

8013 DATA 0,$4E,-1,1,$48,-1,2,$43,-1,3,$41,-1

8014 DATA 0,$3E,-1,1,$38,-1,2,$33,-1,3,$31,-1

8015 DATA 0,$2E,-1,1,$28,-1,2,$23,-1,3,$21,-1

8016 DATA 0,$1A,-1,1,$1D,-1,2,$1E,-1,3,$24,-1

8017 DATA 0,$2A,-1,1,$2D,-1,2,$2E,-1,3,$34,-1

8018 DATA 0,$3A,-1,1,$3D,-1,2,$3E,-1,3,$44,-1

8019 DATA 0,$4A,-1,1,$4D,-1,2,$4E,-1,3,$54,-1

8020 DATA 0,$5A,-1,1,$54,-1,2,$4E,-1,3,$4D,-1

8021 DATA 0,$4A,-1,1,$44,-1,2,$3E,-1,3,$3D,-1

8022 DATA 0,$3A,-1,1,$34,-1,2,$2E,-1,3,$2D,-1

8023 DATA 0,$2A,-1,1,$24,-1,2,$1E,-1,3,$1D,-1

8024 DATA 0,$1A,-1,1,$1D,-1,2,$1E,-1,3,$24,-1

8025 DATA 0,$2A,-1,1,$2D,-1,2,$2E,-1,3,$34,-1

8026 DATA 0,$3A,-1,1,$3D,-1,2,$3E,-1,3,$44,-1

8027 DATA 0,$4A,-1,1,$4D,-1,2,$4E,-1,3,$54,-1

8028 DATA 0,$5A,-1,1,$54,-1,2,$4E,-1,3,$4D,-1

8029 DATA 0,$4A,-1,1,$44,-1,2,$3E,-1,3,$3D,-1

8030 DATA 0,$3A,-1,1,$34,-1,2,$2E,-1,3,$2D,-1

8031 DATA 0,$2A,-1,1,$24,-1,2,$1E,-1,3,$1D,-1

8999 DATA -99

9000 REM PLAY NOTE ON CHANNEL CH

9010 POKE YA,8 :POKE YD,CH :REM RELEASE KEY

9020 POKE YA,$28+CH :POKE YD,NO

9030 POKE YA,8 :POKE YD,$78+CH :REM KEY DOWN

9040 RETURN

9100 REM RELEASE CHANNEL CH

9110 POKE YA,8 :POKE YD,CH

9120 RETURN

10000 REM SET CH= VOICE NUMBER AND GOSUB HERE TO LOAD PATCH

10001 REM CRYSTAL-2

10002 POKE $9F40,$20+CH : POKE $9F41,$FC

10003 POKE $9F40,$38+CH : POKE $9F41,$00

10004 POKE $9F40,$40+CH : POKE $9F41,$3A

10005 POKE $9F40,$48+CH : POKE $9F41,$5A

10006 POKE $9F40,$50+CH : POKE $9F41,$32

10007 POKE $9F40,$58+CH : POKE $9F41,$42

10008 POKE $9F40,$60+CH : POKE $9F41,$1E

10009 POKE $9F40,$68+CH : POKE $9F41,$14

10010 POKE $9F40,$70+CH : POKE $9F41,$0A

10011 POKE $9F40,$78+CH : POKE $9F41,$0A

10012 POKE $9F40,$80+CH : POKE $9F41,$1F

10013 POKE $9F40,$88+CH : POKE $9F41,$1F

10014 POKE $9F40,$90+CH : POKE $9F41,$1E

10015 POKE $9F40,$98+CH : POKE $9F41,$1E

10016 POKE $9F40,$A0+CH : POKE $9F41,$0C

10017 POKE $9F40,$A8+CH : POKE $9F41,$0C

10018 POKE $9F40,$B0+CH : POKE $9F41,$0F

10019 POKE $9F40,$B8+CH : POKE $9F41,$0F

10020 POKE $9F40,$C0+CH : POKE $9F41,$0B

10021 POKE $9F40,$C8+CH : POKE $9F41,$0B

10022 POKE $9F40,$D0+CH : POKE $9F41,$0B

10023 POKE $9F40,$D8+CH : POKE $9F41,$0B

10024 POKE $9F40,$E0+CH : POKE $9F41,$34

10025 POKE $9F40,$E8+CH : POKE $9F41,$34

10026 POKE $9F40,$F0+CH : POKE $9F41,$66

10027 POKE $9F40,$F8+CH : POKE $9F41,$66

10028 RETURN



 



If you're still running R38, then you can fix it by changing $9F40 to $9FE0 and $9F41 to $9FE1

Enjoy!

ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

See who can recognize this tune

Post by ZeroByte »


For anyone having issues copy/pasting this into the emulator, here's the program as a .bas file.

 
prelude.bas
Post Reply