Subversion Repositories NedoOS

Rev

Rev 2376 | Blame | Compare with Previous | Last modification | View Log | Download

  1. OPNA1_REG = 0xf4c1 ;write: SSG + FM 1-3 address, read: status_0
  2. OPNA1_DAT = 0xf5c1 ;write: SSG + FM 1-3 value, read: SSG value
  3. OPNA2_REG = 0xf6c1 ;write: ADPCM + FM 4-6 address, read: status_1
  4. OPNA2_DAT = 0xf7c1 ;write: ADPCM + FM 4-6 value, read: ADPCM value
  5.  
  6.         macro opna_write_reg reg,dat
  7. ;bc = address port
  8. ;e = register
  9. ;d = value
  10.         ld bc,reg
  11.         in f,(c)
  12.         jp m,$-2
  13.         out (c),e
  14.         in f,(c)
  15.         jp m,$-2
  16.         ld bc,dat
  17.         out (c),d
  18.         endm
  19.  
  20. opnawriteall
  21. ;e = register
  22. ;d = value
  23.         call opnawritefm2
  24. opnawritefm1
  25. ;e = register
  26. ;d = value
  27.         opna_write_reg OPNA1_REG,OPNA1_DAT
  28.         ret
  29.  
  30. opnawritefm2
  31. ;e = register
  32. ;d = value
  33.         opna_write_reg OPNA2_REG,OPNA2_DAT
  34.         ret
  35.  
  36.         macro opna_write_regs fm,incr,incd
  37. ;e = base register
  38. ;d = value
  39. ;l = count
  40. .loop   if fm == 1
  41.         call opnawritefm1
  42.         endif
  43.         if fm == 2
  44.         call opnawritefm2
  45.         endif
  46.         if fm == 0
  47.         call opnawriteall
  48.         endif
  49.         if incr
  50.         inc e
  51.         endif
  52.         if incd
  53.         inc d
  54.         endif
  55.         dec l
  56.         jr nz,.loop
  57.         endm
  58.  
  59. opnainit
  60.         ld l,0x83
  61.         ld de,0x0030
  62.         opna_write_regs 0,1,0
  63. ;panpots
  64.         ld l,3
  65.         ld de,0xc0b4
  66.         opna_write_regs 0,1,0
  67. ;6 voice mode
  68.         ld de,0x8029
  69.         call opnawritefm1
  70. ;ADPCM 1bit / DRAM / panpot
  71.         ld de,0xc001
  72.         call opnawritefm2
  73. ;limit address
  74.         ld de,0xff0c
  75.         call opnawritefm2
  76.         ld de,0xff0d
  77.         jp opnawritefm2
  78.  
  79. opnastoptimers
  80.         ld de,0x3027
  81.         call opnawritefm1
  82.         ld de,0x0027
  83.         jp opnawritefm1
  84.  
  85. opnamute
  86.         call opnastoptimers
  87. ;mute SSG
  88.         ld l,3
  89.         ld de,0x0008
  90.         opna_write_regs 1,1,0
  91.         ld l,14
  92.         ld de,0
  93.         opna_write_regs 1,1,0
  94. ;mute ADPCM
  95.         ld de,0x0100
  96.         call opnawritefm2
  97.         ld de,0x0001
  98.         call opnawritefm2
  99. ;mute rhythm
  100.         ld de,0xbf10
  101.         call opnawritefm1
  102. ;max release rate
  103.         ld l,16
  104.         ld de,0x0f80
  105.         opna_write_regs 0,1,0
  106. ;min total level
  107.         ld l,16
  108.         ld de,0x7f40
  109.         opna_write_regs 0,1,0
  110. ;key off
  111.         ld l,8
  112.         ld de,0x0028
  113.         opna_write_regs 1,0,1
  114.         ret
  115.