SHARE
TWEET

MPU-401 Rhodes Demo

a guest May 26th, 2019 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DEFINT A-Z
  2. DECLARE FUNCTION MPUInit% ()
  3. DECLARE SUB MPUData (v%)
  4. DECLARE SUB MPUCmd (v%)
  5. DECLARE SUB PitchBendSensitivity (ch%, v%)
  6.  
  7.  
  8. DIM SHARED MPUPort AS INTEGER, MPUError AS INTEGER
  9. MPUPort = &H330
  10.  
  11. DIM SHARED keyMap(127)
  12. DATA 44,31,45,32,46,47,34,48,35,49,36,50,51,38,52,39,-1
  13. DATA 16,3,17,4,18,19,6,20,7,21,8,22,23,10,24,11,25,-1
  14. FOR i = 0 TO 127: keyMap(i) = -1: NEXT
  15. i = 0
  16. DO
  17.   READ j: IF j = -1 THEN EXIT DO
  18.   keyMap(j) = i: i = i + 1
  19. LOOP
  20. i = 12
  21. DO
  22.   READ j: IF j = -1 THEN EXIT DO
  23.   keyMap(j) = i: i = i + 1
  24. LOOP
  25.  
  26.  
  27.  
  28. ch = 0: oct = 5
  29.  
  30. CLS
  31. i = MPUInit
  32.  
  33. MPUData &HC0 + ch
  34. MPUData 4
  35. MPUData &HC0 + ch + 1
  36. MPUData 4
  37.  
  38.  
  39. PitchBendSensitivity ch, 12
  40. PitchBendSensitivity ch + 1, 12
  41.  
  42. MPUData &HE0 + ch
  43. MPUData 0
  44. MPUData 64
  45.  
  46. MPUData &HE0 + ch + 1
  47. MPUData 64
  48. MPUData 64
  49.  
  50. DO
  51.  
  52.   DEF SEG = 65: kF& = PEEK(8): kF& = (kF& * 256) + PEEK(7): DEF SEG
  53.   DO
  54.     kB = INP(96)
  55.     IF kB = kBLast THEN kB = 0: EXIT DO ELSE kBLast = kB
  56.  
  57.     k = kB AND 127
  58.     SELECT CASE k
  59.       CASE 1          ' ESC
  60.         GOTO quit
  61.       CASE 53         ' /
  62.         IF kB < 128 AND oct > 0 THEN oct = oct - 1
  63.       CASE 55         ' *
  64.         IF kB < 128 AND oct < 9 THEN oct = oct + 1
  65.       CASE ELSE
  66.         i = keyMap(k)
  67.         IF i >= 0 THEN
  68.           IF kB >= 128 THEN MPUData &H80 + ch ELSE MPUData &H90 + ch
  69.           MPUData ((oct * 12) + i)
  70.           MPUData 127
  71.  
  72.           IF kB >= 128 THEN MPUData &H80 + ch + 1 ELSE MPUData &H90 + ch + 1
  73.           MPUData ((oct * 12) + i)
  74.           MPUData 127
  75.  
  76.         ELSE
  77.           'PRINT kB
  78.         END IF
  79.     END SELECT
  80.  
  81.   LOOP
  82.  
  83. LOOP
  84.  
  85. quit:
  86. FOR j = ch TO ch + 1
  87.   FOR i = 0 TO 127
  88.     MPUData &H80 + j
  89.     MPUData i
  90.     MPUData 127
  91.   NEXT
  92. NEXT
  93.  
  94. SUB MPUCmd (v%)
  95.  
  96.   IF MPUError <> 0 THEN EXIT SUB
  97.  
  98.   t! = TIMER + 1
  99.   DO WHILE (INP(MPUPort + 1) AND &H40) <> 0
  100.     IF (INP(MPUPort + 1) AND &H80) = 0 THEN i = INP(MPUPort)
  101.     IF TIMER >= t! THEN MPUError = -1: EXIT SUB
  102.   LOOP
  103.  
  104.   OUT MPUPort + 1, v%
  105.  
  106.   t! = TIMER + 1
  107.   DO
  108.     DO WHILE (INP(MPUPort + 1) AND &H80) <> 0
  109.       IF TIMER >= t! THEN MPUError = -1: EXIT SUB
  110.     LOOP
  111.     IF TIMER >= t! THEN MPUError = -1: EXIT SUB
  112.   LOOP WHILE INP(MPUPort) <> &HFE
  113.  
  114. END SUB
  115.  
  116. SUB MPUData (v%)
  117.  
  118.   IF MPUError <> 0 THEN EXIT SUB
  119.  
  120.   t! = TIMER + 1
  121.   DO WHILE (INP(MPUPort + 1) AND &H40) <> 0
  122.     IF (INP(MPUPort + 1) AND &H80) = 0 THEN i = INP(MPUPort)
  123.     IF TIMER >= t! THEN MPUError = -1: EXIT SUB
  124.   LOOP
  125.  
  126.   OUT MPUPort, v%
  127.  
  128. END SUB
  129.  
  130. FUNCTION MPUInit%
  131.  
  132.   MPUCmd &HFF
  133.   MPUCmd &H3F
  134.   MPUInit% = MPUError
  135.  
  136. END FUNCTION
  137.  
  138. SUB PitchBendSensitivity (ch%, v%)
  139.  
  140.   MPUData &HB0 + ch%
  141.   MPUData 101
  142.   MPUData &H0
  143.   MPUData &HB0 + ch%
  144.   MPUData 100
  145.   MPUData &H0
  146.   MPUData &HB0 + ch%
  147.   MPUData &H6
  148.   MPUData v%
  149.   MPUData &HB0 + ch%
  150.   MPUData &H26
  151.   MPUData &H0
  152.  
  153. END SUB
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top