How to detect sound chips without Bios

Página 1/4
| 2 | 3 | 4

Por norakomi

Paladin (1003)

Imagen del norakomi

21-10-2019, 10:49

Hi all.

I am using MBPLAYER 1.4 to play moonblaster songs.
The songs I'm playing use msx-music and msx-audio together.

The replay code that comes with MBPLAYER 1.4 also has a piece of code to detect connected soundchips (SRCCHPSmile.
But I can't seem to get this code to work, because it's using Bios, and does slotswitching and other stuff that crashes the program for me.

There is a Bios call (call 024h - ENASLT), which doesn't return to my code after it finishes.

I am not using Bios at all ingame, and at boot-up I'm overwriting page 0 completely with the game engine,
and using my own interupt. So I try to call SRCCHP before that, with Bios still active.

Does anyone know how to detect the Fm-audio and Fm-Music chips without using the Bios ?

Login sesión o register para postear comentarios

Por NYYRIKKI

Enlighted (5396)

Imagen del NYYRIKKI

21-10-2019, 12:19

MSX-Audio detection is easy and should work out of the box.

MSX-MUSIC is a bit harder... It would not be without FM-PAC, but unlike other MSX-MUSICs FM-PAC needs to be "turned on" first... Details are explained here: https://www.msx.org/wiki/MSX-MUSIC_programming

Por Grauw

Ascended (8508)

Imagen del Grauw

21-10-2019, 14:21

NYYRIKKI wrote:

MSX-Audio detection is easy and should work out of the box.

If by the "easy MSX-AUDIO detection" you are referring to in a,(0C0H), cp 00000110B then actually that is a bad way of detection.

That’s because bits 1 and 2 are NOT set to 1 by the MSX-AUDIO (nor OPL or OPL2), but rather are not connected (hi-z). Therefore the value read from these bits can be either 0 or 1 depending entirely on whether the MSX computer’s bus has pull-up resistors (1), pull-down resistors (0), or is floating (randomly 0 or 1). Pull-up is the most common, and I don’t think there’s machines which pull-down, but a floating bus is not uncommon either especially on MSX1 machines and I think the 1chipMSX as well.

The simplest good way of detecting MSX-AUDIO is to write to bit 7 of ADPCM CONTROL register #7, and check if this is reflected in bit 0 of the status register. See example code.

MSX-MUSIC is mostly just ROM string matching but be aware that you’re supposed to detect internal FM-PACs first matching on the APRLOPLL string (also used by clones), and only after they’re not found do a broader search using the OPLL string. In case of the latter you need to enable the I/O by setting using the memory-mapped I/O flag at address #7FF6, or just use its memory-mapped I/O.

If you don’t follow this detection protocol the Panasoft FM-PAC will either 1. no produce sound, or 2. double up with internal MSX-MUSIC. (I’ve updated the wiki a bit just now.)

Por norakomi

Paladin (1003)

Imagen del norakomi

21-10-2019, 15:08

@grauw:
So I call MSXAudio_Detect:, then output carry means MSXAUDIO found. Seems straightforward.
What does the PROC mean in the source
MSXAudio_Detect: PROC ?

Do I need the entire code ?
Many things I don't understand, like
this:
super: Driver MSXAudio_name, MSXAudio_CLOCK, Driver_PrintInfoImpl
ix = this
SECTION RAM
MSXAudio_instance: MSXAudio
ENDS

Can I assemble that whole code with tniasm, or do I need something more for that.
What about the macros ?

Quote:

be aware that you’re supposed to detect internal FM-PACs first matching on the APRLOPLL string (also used by clones), and only after they’re not found do a broader search using the OPLL string. In case of the latter you need to enable the I/O by setting using the memory-mapped I/O flag at address #7FF6, or just use its memory-mapped I/O

This is complete Chinese to me. I didn't expect it to be that difficult to detect 2 sound chips.

Por Manel46

Champion (459)

Imagen del Manel46

21-10-2019, 16:55

Por norakomi

Paladin (1003)

Imagen del norakomi

21-10-2019, 17:13

O lot of info... but I'm just looking for some code ^__^
thanx anyway

Por Manel46

Champion (459)

Imagen del Manel46

21-10-2019, 17:24

DETFMPAC     
   di                
   xor    a          
   ld     (MFM2),a  
   ld     b,#04      
L4042:   push   bc         
   ld     a,#04      
   sub    b          
   ld     c,a        
   ld     hl,#fcc1   
   add    a,l        
   ld     l,a        
   ld     a,(hl)     
   add    a,a        
   jr     nc,L406C ;#406c   
   ld     b,#04      
L4052:   push   bc         
   ld     a,#24      
   sub    b          
   rlca              
   rlca              
   or     c          
   ld     (MFM1),a  
   call   L407C ;#407c      
   ld     a,(MFM2)  
   or     a          
   pop    bc         
   jr     nz,L407A ;#407a   
   djnz   L4052 ;#4052      
L4068:   pop    bc         
   djnz   L4042  ;#4042      
   ret
;?               
L406C:   ld     a,c        
  ld     (MFM1),a  
  call   L407C  ;#407c      
  ld     a,(MFM2)  
  or     a          
  jp     z,L4068 ;#4068    
L407A:   pop    bc         
  ret 
;BIT 0 A 1 SI FMPAC              
L407C:   ld     b,#08      
  ld     hl,L40C2 ;#40c2   
  ld     de,#4018   
  call   L40A6 ;#40a6      
  ret    nc         
  ld     b,#04      
  ld     hl,L40C2+4  ;L40C6 ;#40c6   
  ld     de,#401c   
  call   L40A6 ;#40a6      
  ret    c          
  ld     hl,#7ff6   
  push   af         
  push   hl         
  call   #000c      
  or     #01        
  ld     e,a        
  pop    hl         
  pop    af         
  call   #0014      
  or     a          
  ret 
;VERIFICA CADENA              
L40A6:   ld     a,(MFM1)  
  ld     c,a        
L40AA:   push   bc         
  push   hl         
  push   de         
  ld     a,c        
  ex     de,hl      
  call   #000c      
  pop    de         
  pop    hl         
  pop    bc         
  cp     (hl)       
  scf               
  ret    nz         
  inc    hl         
  inc    de         
  djnz   L40AA  ;#40aa      
  ld     a,c        
  ld     (MFM2),a  
  or     a          
  ret
;CADENA               
L40C2:
 DB "APRLOPLL"

External FMpac detection and activation.

Por zPasi

Champion (473)

Imagen del zPasi

21-10-2019, 17:50

norakomi wrote:

There is a Bios call (call 024h - ENASLT), which doesn't return to my code after it finishes.

If your code is on page 1 (4000h-7FFFh) and you switch something else to that page, of course it doesn't return to your code. It does return, but the code on that location has been changed...

Por norakomi

Paladin (1003)

Imagen del norakomi

21-10-2019, 18:23

zPasi wrote:

If your code is on page 1 (4000h-7FFFh) and you switch something else to that page, of course it doesn't return to your code. It does return, but the code on that location has been changed...

Yeah, thats exactly my issue. After that I tried running my code from another page (i tried page 3), but I also didnt get a return.

Por norakomi

Paladin (1003)

Imagen del norakomi

21-10-2019, 18:27

@Manel.
Thanks for that code,
but it only detects extrernal FMpac, it doesn't detect internal FMpac.
And how to I readout if there is an external FMPac with that code ? There is no explanation anywhere.
There are 2 bytes written, MFM1 and MFM2. They give me info about FMPac present ?
I see this bit of text : ;BIT 0 A 1 SI FMPAC
Does that refer to the MFM1 and MFM2 ??

Por norakomi

Paladin (1003)

Imagen del norakomi

21-10-2019, 18:31

@Manel,
I also see this call in the code: call #000c. That's a Readslot Bios call.....
Sad I am trying to avoid using the Bios.....

Página 1/4
| 2 | 3 | 4