Subversion Repositories NedoOS

Rev

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

  1. ;Having chip 0 is mandatory for the player to detect YM2151,
  2. ;chip 1 is an optional second chip.
  3.  
  4. OPM0_REG = 0xf0c1 ;write: chip 0 address
  5. OPM0_DAT = 0xf1c1 ;write: chip 0 value, read: chip 0 status
  6. OPM1_REG = 0xf2c1 ;write: chip 1 address
  7. OPM1_DAT = 0xf3c1 ;write: chip 1 value, read: chip 1 status
  8.  
  9.         macro opm_write_reg reg,dat
  10. ;bc = data port
  11. ;e = register
  12. ;d = value
  13.         ld bc,dat
  14.         in f,(c)
  15.         jp m,$-2
  16.         ld bc,reg
  17.         out (c),e
  18.         ld bc,dat
  19.         in f,(c)
  20.         jp m,$-2
  21.         out (c),d
  22.         endm
  23.  
  24. opmwriteall
  25. ;e = register
  26. ;d = value
  27.         call opmwritechip1
  28. opmwritechip0
  29. ;e = register
  30. ;d = value
  31.         opm_write_reg OPM0_REG,OPM0_DAT
  32.         ret
  33.  
  34. opmwritechip1
  35. ;e = register
  36. ;d = value
  37.         opm_write_reg OPM1_REG,OPM1_DAT
  38.         ret
  39.  
  40. opmdisablechip1
  41.         ld a,0xc9 ;ret opcode
  42.         ld (opmwritechip1),a
  43.         ret
  44.  
  45.         macro opm_write_regs incr,incd
  46. ;e = base register
  47. ;d = value
  48. ;l = count
  49. .loop   call opmwriteall
  50.         IF incr
  51.         inc e
  52.         ENDIF
  53.         IF incd
  54.         inc d
  55.         ENDIF
  56.         dec l
  57.         jr nz,.loop
  58.         endm
  59.  
  60. opminit
  61.         ld l,0
  62.         ld de,0
  63.         opm_write_regs 1,0
  64.         ret
  65.  
  66. opmstoptimers
  67.         ld de,0x3014
  68.         call opmwriteall
  69.         ld de,0x0014
  70.         jp opmwriteall
  71.  
  72. opmmute
  73.         call opmstoptimers
  74. ;max release rate
  75.         ld l,0x20
  76.         ld de,0x0fe0
  77.         opm_write_regs 1,0
  78. ;min total level
  79.         ld l,0x20
  80.         ld de,0x7f60
  81.         opm_write_regs 1,0
  82. ;key off
  83.         ld l,0x08
  84.         ld de,0x0008
  85.         opm_write_regs 0,1
  86.         ret
  87.