Jump to content
IGNORED

Access DPC+ sound chip in ASM?


wallaby
 Share

Recommended Posts

Are there any examples of driving the DPC+ sound chip from ASM? I think the TIA was designed for sound effects mainly and its dashing my dreams of nice chiptunes for my game.

 

I've been searching around for a bit, but I haven't found any sound examples at all.

 

Another 3 voices would be a lot of fun to utilize.

Link to comment
Share on other sites

 

 

 

Yes, this demonstrates the sound, and is a great resource, but it is extremely difficult excise from the demo code. I don't have an ARM development environment so I can't compile the source and tinker with it there. Plus, some ASM commands seem incompatible with my version DASM and/or I lack the understanding on how to port it to an empty DPC+ project.

 

All I need is a demo of playing a single sound that I can duplicate for the other voices. This has a visualizer, and what looks like a tracker (which is cool, but beyond my current ability to re-use), and important data that is spread around the source. The variables at the top and wave data at the bottom (also very cool).

 

It's very tantalizing, but I can't get past weird compiler errors I'm getting and at a fundamental level I don't know what it is doing most of the time.

 

Assuming I already have a graphics loop, what is the smallest loop I can use to just play sounds? (No visualization)

Link to comment
Share on other sites

:? ARM code? There's no ARM source code. There is an ARM file, which contains the DPC+ driver. The driver is precompiled, you don't build it yourself.

 

 

Each demo is in its own 4K bank. The music demo is in "bank 1", starting at line 733.

The "visualizer" is just a super simple kernel:

KERNEL1:
	sta WSYNC
	lda AMPLITUDE
	sta AUDV0
	and #$0f
	tax
	lda ShowAmplitude0,x
	sta GRP0
	lda ShowAmplitude1,x
	sta GRP1
	dey
	bne KERNEL1




All it does is take the value for AMPLITUDE and display it graphically via the players. Changing it to this will remove the visualization:
KERNEL1:
	sta WSYNC
	lda AMPLITUDE
	sta AUDV0
	dey
	bne KERNEL1


The main thing with DPC+ music is you have to LOAD the value from AMPLITUDE and STORE it in AUDV0 once per scanline. Using A is not required, you can use LDX / STX or LDY / STY as needed.

 

While the demo is a bit dated*, you should be able to experiment with the code in Bank 1 to get an understanding on how DPC+ music works.

 

Posting "weird compiler errors" isn't very useful - nobody can help if you don't post the errors. Due note that my time is very limited for the next couple of weeks, so hopefully others can step up to help you resolve the problems. Also be sure to read DPCplus.h.

* nowadays we include the DPC+ Driver at compile time rather than manually merging it after running dasm.

Link to comment
Share on other sites

I agree what you're saying, but I found it difficult to isolate just the music code. When I attempt to compile the .asm with DASM, the errors I get are:

C:\Atari\DPCPlus>c:\atari\dasm dpcplus.asm
dpcplus.asm (6547): error: Unknown Mnemonic '35,'.
dpcplus.asm (6550): error: Unknown Mnemonic '$CA,'.
dpcplus.asm (6550): error: Unknown Mnemonic '$CA,'.
dpcplus.asm (6550): error: Unknown Mnemonic '$CA,'.
dpcplus.asm (6550): error: Unknown Mnemonic '$CA,'.
dpcplus.asm (6550): error: Unknown Mnemonic '$CA,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6554): error: Unknown Mnemonic '$F8,'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6558): error: Unknown Mnemonic '$C4'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6563): error: Unknown Mnemonic '$80,'.
dpcplus.asm (6568): error: Unknown Mnemonic '$8A,'.
dpcplus.asm (6568): error: Unknown Mnemonic '$8A,'.
dpcplus.asm (6568): error: Unknown Mnemonic '$8A,'.
dpcplus.asm (6568): error: Unknown Mnemonic '$8A,'.
dpcplus.asm (6568): error: Unknown Mnemonic '$8A,'.

Unrecoverable error(s) in pass, aborting assembly!
Complete.

But that's just the tip of the iceberg. So what I thought the best thing to do was isolate the code and slowly copy-paste it into a known working compile until it stops working. But there are some syntax that seem incompatible. I'll try to remove just the sound making part of this again to find out exactly what, if you like.

 

That's the main reason I asked for the most atomic example. Like the "hello world" of DPC+ sound.

 

I'll give it another shot.

Edited by wallaby
Link to comment
Share on other sites

 

ShowAmplitude0:
    .byte zz________
    .byte zzX_______
    .byte zzXX______
    .byte zzXXX_____
    .byte zzXXXX____
    .byte zzXXXXX___
    .byte zzXXXXXX__
    .byte zzXXXXXXX_
    .byte zzXXXXXXXX
    ds 8, zzXXXXXXXX
ShowAmplitude1:
      ds 8, zz________
    .byte zz________
    .byte zzX_______
    .byte zzXX______
    .byte zzXXX_____
    .byte zzXXXX____
    .byte zzXXXXX___
    .byte zzXXXXXX__
    .byte zzXXXXXXX_
    .byte zzXXXXXXXX
    
  ALIGN 256
 
MusicData0:
; Bar 0
  DC.B  C4
  DC.B  0
  DC.B  0
  DC.B  0
  DC.B  E4
  DC.B  0
  DC.B  0
  DC.B  0
  DC.B  G4
  DC.B  0
  DC.B  0
  DC.B  0

 

The showamplitude data won't compile. (A different type of byte definition syntax?)

 

The music data compiles but crashes the game.

 

Even if I just put DC.B C4 on a line on its own, the game crashes.

 

What is DC.B? A special kind of datatype? It looks like C4, G4, E4 are types of notes and not hex?

 

I can get sound coming out, but it doesn't sound nice and it's only possible if I set NOTE0 to #3. But it just sounds like the normal Atari TIA.

Link to comment
Share on other sites

 

 

I suppose you are using Windows (like me), because I get the same errors.

 

Yes! That was it. Thank you for that.

 

So now it compiles, but it crashes Stella. I'm guessing because DPC+ has changed since it was written?

 

I wonder if those other errors were the result of copying Linux LFs into my code. Back to try again.

Link to comment
Share on other sites

Okay, I understand. I'm using 50% bB and %50 ASM for my game and I incorrectly assumed it was supported in the bB DPC+ kernel. I think I'll have to pass on it for now. There isn't enough space to add it to bB's DPC+ bank. It's strange though, the waveforms are in the kernel.

 

If I were to add LDA AMPLITUDE and STA AUDV0 to each blank, I think it would throw the timing off.

Link to comment
Share on other sites

I'm on a Mac, which is Unix based. End of line is just a Line Feed while Windows wants Carriage Return + Line Feed. Without the Carriage Return the programs on Windows think all the text is on a single line. You can use the tool Thomas posted, or just open the files in WordPad and save them. Run all the source files through the process, not just the asm file:

  • DPC_frequencies.h
  • DPCplus.asm
  • DPCplus.h
  • graphics.h
  • macro.h
  • VCS.h

 

Link to comment
Share on other sites

 

  sta AUDV0
  lda (MPTR2),Y

 

Whenever you run into something like that try searching the source for the variable. You'll find MPTR2 defined on line 218. MPTR2 is a RAM variable, so it's not defined as part of the ROM in bank 1 but rather with all the other RAM variables beginning at line 194. The variables are broken out by demo, the music ones start on line 210.

 

 

 

ShowAmplitude0:
    .byte zz________
    .byte zzX_______
    .byte zzXX______
    .byte zzXXX_____
    .byte zzXXXX____
    .byte zzXXXXX___
    .byte zzXXXXXX__
    .byte zzXXXXXXX_
    .byte zzXXXXXXXX
    ds 8, zzXXXXXXXX
ShowAmplitude1:
      ds 8, zz________
    .byte zz________
    .byte zzX_______
    .byte zzXX______
    .byte zzXXX_____
    .byte zzXXXX____
    .byte zzXXXXX___
    .byte zzXXXXXX__
    .byte zzXXXXXXX_
    .byte zzXXXXXXXX

The showamplitude data won't compile. (A different type of byte definition syntax?)

 

The music data compiles but crashes the game.

 

Even if I just put DC.B C4 on a line on its own, the game crashes.

 

What is DC.B? A special kind of datatype? It looks like C4, G4, E4 are types of notes and not hex?

 

I can get sound coming out, but it doesn't sound nice and it's only possible if I set NOTE0 to #3. But it just sounds like the normal Atari TIA.

 

The values like zzXXXXXXXX are defined in graphics.h, just need to run it through your end-of-line converter. Likewise C4 and such are in DPC_frequencies.h which probably also needs to be run through the converter.

 

DC.B is an alternate way of defining a byte value. Most likely they weren't happy if DPC_frequencies.h had the wrong end-of-line for Windows.

 

Yes! That was it. Thank you for that.

 

So now it compiles, but it crashes Stella. I'm guessing because DPC+ has changed since it was written?

 

I wonder if those other errors were the result of copying Linux LFs into my code. Back to try again.

I just downloaded the source and compiled it. It ran just fine in Stella, so something with your conversion to Windows is the problem.

Link to comment
Share on other sites

Okay, I understand. I'm using 50% bB and %50 ASM for my game and I incorrectly assumed it was supported in the bB DPC+ kernel. I think I'll have to pass on it for now. There isn't enough space to add it to bB's DPC+ bank. It's strange though, the waveforms are in the kernel.

 

If I were to add LDA AMPLITUDE and STA AUDV0 to each blank, I think it would throw the timing off.

Ah - based on the topic title, and not being in the bB forum, I thought you were doing an assembly only project. If you're trying to use this with bB then you will get very scratchy sound because bB isn't doing the load AMPLITUDE and store AUDV0 that's required on every scanline.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...