DECLARE SUB sboff () DECLARE SUB sbsetup () DECLARE SUB setupnotetable () DECLARE SUB sbnote (ch%, NOTE%, n%) DECLARE SUB sbout (r%, d%) DECLARE SUB writeaddr (b%) DECLARE SUB writedata (b%) DECLARE SUB resetsb () DIM keytable AS SHARED STRING DIM notetable(0 TO 50) AS SHARED INTEGER keytable$ = " Q2W3ER5T6Y7UI9O0P[=]" setupnotetable SCREEN 0 WIDTH 80, 25 CLS COLOR 10 PRINT "Simple adlib piano" COLOR 12 PRINT " C C# D D# E F F# G G# A A# B C Exit" PRINT PRINT " Q 2 W 3 E R 5 T 6 Y 7 U I X" resetsb sbout 1, &H10 'THAT IS WHAT I MISSED sbsetup DO pbin$ = UCASE$(INPUT$(1)) r% = notetable%(INSTR(keytable$, pbin$)) sbnote 1, r%, 1 LOOP UNTIL pbin$ = "X" sboff resetsb SUB resetsb FOR i% = 1 TO &HF5 writeaddr (i%) writedata (0) NEXT i% END SUB SUB sbnote (ch%, NOTE%, n%) IF NOTE% > 512 THEN F% = 2 ELSE F% = 1 IF NOTE% > 768 THEN F% = 3 sbout &HA0 + ch%, NOTE% AND 1279 sbout &HB0 + ch%, (&H20 * n%) OR &H10 OR F% END SUB SUB sboff writeaddr (&HB0) writedata (&H11) END SUB SUB sbout (r%, d%) writeaddr (r%) writedata (d%) END SUB SUB sbsetup sbout &H20, 1 sbout &H40, &H10 sbout &H60, &HF0 sbout &H80, &H77 sbout &HA0, &H98 sbout &H23, 1 sbout &H43, 0 sbout &H63, &HF0 sbout &H83, &H77 sbout &HB0, 0 END SUB SUB setupnotetable notetable%(0) = 0 notetable%(26) = &H157 'C notetable%(27) = &H16B 'C# notetable%(28) = &H181 'D notetable%(29) = &H198 'D# notetable%(30) = &H1B0 'E notetable%(31) = &H1CA 'F notetable%(32) = &H1E5 'F# notetable%(33) = &H202 'G notetable%(34) = &H220 'G# notetable%(35) = &H241 'A notetable%(36) = &H263 'A# notetable%(37) = &H287 'B notetable%(38) = &H2AE 'c notetable%(39) = &H2D6 'c# notetable%(40) = &H302 'd notetable%(41) = &H330 'd# notetable%(42) = &H360 'e notetable%(43) = &H394 'f notetable%(44) = &H3CA 'f# notetable%(45) = &H404 'g notetable%(46) = &H440 'g# notetable%(47) = &H482 'a notetable%(48) = &H4C6 'a# notetable%(49) = &H50E 'b notetable%(50) = &H55C 'C END SUB SUB writeaddr (b%) OUT &H388, b% 'FOR a% = 1 TO 6 x% = INP(&H388) 'NEXT a% END SUB SUB writedata (b%) OUT &H389, b% 'FOR a% = 1 TO &H34 x% = INP(&H389) 'NEXT a% END SUB