Subversion Repositories NedoOS

Rev

Rev 2379 | 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.         call opnawritefm1
  84.         ld de,0x8010
  85.         jp opnawritefm2
  86.  
  87. opnamute
  88.         call opnastoptimers
  89. ;mute SSG
  90.         ld l,3
  91.         ld de,0x0008
  92.         opna_write_regs 1,1,0
  93.         ld l,14
  94.         ld de,0
  95.         opna_write_regs 1,1,0
  96. ;mute ADPCM
  97.         ld de,0x0100
  98.         call opnawritefm2
  99.         ld de,0x0001
  100.         call opnawritefm2
  101. ;mute rhythm
  102.         ld de,0xbf10
  103.         call opnawritefm1
  104. ;max release rate
  105.         ld l,16
  106.         ld de,0x0f80
  107.         opna_write_regs 0,1,0
  108. ;min total level
  109.         ld l,16
  110.         ld de,0x7f40
  111.         opna_write_regs 0,1,0
  112. ;key off
  113.         ld l,8
  114.         ld de,0x0028
  115.         opna_write_regs 1,0,1
  116.         ret
  117.