don't click here

Question on Genesis audio

Discussion in 'Technical Discussion' started by smkd, Jul 4, 2008.

  1. smkd

    smkd

    Member
    3
    0
    0
    Hi.

    I'm picking up 68k along with the hardware and I've messed with it long enough to get a hang of the graphics end of things. I tried to take the example found in the Sega2 manual towards the end of the document (the table with register/offset) but it will only play on Gens, not Kega Fusion. I'm doing everything from the 68k.

    Code (Text):
    1.     lea $a04000, a0;register
    2.     lea $a04001, a1;data
    3.  
    4. ;each step
    5.     move.b #$22, (a0);LFO off
    6.     move.b #$00, (a1)
    7.     jsr YMRdy
    8.         ...
    I wrote each byte in the table but nothing is heard on Kega. YMRdy tests the busy bit between writes. Can someone tell me what other step I need to do or provide some other 68k code to init the 2612? Any input much appreciated. Thanks.
     
  2. TmEE

    TmEE

    Master of OPL3-SA2/3 Tech Member
    1,726
    2
    18
    Estonia, Rapla City
    T-04YBSC-A !
    You have to request Z80 bus before accessing YM2612 on the 68K side, in Gens, default when you boot the ROM is Bus Requested, but in Fusion and real hardware it is Z80 having the bus. There's a reg for it, I'm not sure but I think it is $A11000 or $A12000... I don't remember.
     
  3. It's $A11100 - the code to request the bus (taken from Xeno's stopZ80 macro) would be:
    Code (ASM):
    1.     move.w  #$100,($A11100).l ; stop the Z80
    2. @waitForZ80:
    3.     btst    #0,($A11100).l
    4.     bne.s   @waitForZ80 ; loop until it says it's stopped
    (assuming your assembler uses @ for local labels)
     
  4. smkd

    smkd

    Member
    3
    0
    0
    Thanks for the replies.

    I read in Sega2 that the 68k has the bus on reset, so I guess I'll avoid assumptions like that in the future. I've tried the code you've posted shobiz but it just seems to lockup the program on Kega (Gens still works as it did before). The waitForZ80 loop is never broken. Any ideas?
     
  5. That happened to me once, I believe it's because of the Z80 reset being held high at console start-up. Instead of using the code I posted in the above post, try
    Code (ASM):
    1.     move.w  #$100,($A11100).l ; stop the Z80
    2.     move.w  #$100,($A11200).l ; release Z80 reset
    3. @waitForZ80:
    4.     btst    #0,($A11100).l
    5.     bne.s   @waitForZ80 ; loop until it says it's stopped
     
  6. TmEE

    TmEE

    Master of OPL3-SA2/3 Tech Member
    1,726
    2
    18
    Estonia, Rapla City
    T-04YBSC-A !
    I usually don't check if the request/reset happened... no trouble on real hardware, no trouble on emulators.

    Code (Text):
    1.  MOVE.B #$01, ($A11200); Stop Z80 reset
    2.  MOVE.B #$01, ($A11100); request Z80 bus
    This is all required... that's what I do in the beginning on my MD WAV player.

    And if you want to have Z80 in the action too, you do this :

    Code (Text):
    1.  MOVE.B #$01, ($A11200); Stop Z80 reset
    2.  MOVE.B #$01, ($A11100); request Z80 bus
    3.  
    4.  MOVE.W #447, D0
    5.  LEA    Z80prog, A0
    6.  MOVE.L #$A00000, A1
    7. Z80loadLoop:
    8.  MOVE.B (A0)+, (A1)+
    9.  DBRA   D0, Z80LoadLoop
    10.  
    11.  MOVE.B #$00, ($A11200); Start Z80 reset
    12.  MOVE.B #$00, ($A11100); unrequest Z80 bus
    13.  MOVE.B #$01, ($A11200); Stop Z80 reset
    You will have to request and then release Z80 bus everytime you want to access YM2612 on 68K side.
     
  7. smkd

    smkd

    Member
    3
    0
    0
    shobiz: That did the trick. Thanks.

    TmEE: I'll keep that in mind in the case I feel like switching to the Z80.