SAGA Coding Tricks | page 1 2
|
---|
|
---|
| | Gunnar von Boehn (Apollo Team Member) Posts 6254 29 Apr 2020 09:30
| A1200 coder wrote:
| Gunnar von Boehn wrote:
| A1200 coder wrote:
| Unfortunately, if I remember correctly, nobody ever wrote a good game programming book for Amiga in english, which is only about asm+hardware. |
Actually the hardware reference manual contains all info you need. It explains with example how to use the Copper. It explains with example how to display a screen. It explains with example how to play audio. It explains with example how to use Sprites. It explains VBL IRQ and Joystick and mouse. What else do you need to know to write a game? |
Well, you often need a mousedriver and a keyboard routine that works. Not so easy to make from scratch and there are no such things in HW ref manual. And then of course some scrolling methods, which doesn't update whole screen. |
I think Joy, Mouse, Keyboard registers are all explained. BPLCON1 for smooth scrolling is also explained. All you need to know to write a small game like Centipede, or write the battle sequences in Archon is in the book. I think for starting to learn how to develop a game this is enough already.I think its important to keep realistic goals. Playing a complete music song is easy with Amiga/SAGA only 6-7 instructions are needed. Checking Joystick is very easy, just a few instructions are needed. Moving some Sprites around is also very easy. Using the Hardware Collision Detection is very easy to. With literally just a few lines of code, you can write a PONG game. Learning how to write such game is a realistic target. Also little more complex game like Space Invader are realistic targets people can learn quickly.
| |
| | Peeri the Sunlight
Posts 72 29 Apr 2020 10:26
| A1200 coder wrote:
| It's called "Amigan pelintekijän opas".
|
Thumbs up. It is really great book with combination of Amiga 3 Bittikirjat. Harware reference manual is great add on. But Pelintekijän opas tells things in practical level.
| |
| | Kamelito Loveless
Posts 261 29 Apr 2020 11:41
| The difficulty is to be compatible with all Amiga configurations. Look at All the fixes done by the WHDload team.
| |
| | Peeri the Sunlight
Posts 72 29 Apr 2020 13:39
| Kamelito Loveless wrote:
| The difficulty is to be compatible with all Amiga configurations. Look at All the fixes done by the WHDload team.
|
If we assume that address $4 is always pointer to exec base... we can code with system functions combatible code, Horray... Tell me if I'm wrong but CIA is $BFExxx and Hardware registers are $dffxxx for every Commodore Amigas and Vampires at least. With these we can make quite stable (not necssecary most combatible for AROS x86, Morphos, OS4 etc...) and system "friendly" code at least code what runs most real amigas and vampires. (Who cares if powerbutton is the exit button :D ) My personal opinion: We have wonderfull Vampire and lets benefit and rip all of it! It was most funniest part to find tricks and find some odd behavor from undocumented areas...
| |
| | Gunnar von Boehn (Apollo Team Member) Posts 6254 29 Apr 2020 13:44
| Kamelito Loveless wrote:
| The difficulty is to be compatible with all Amiga configurations. Look at All the fixes done by the WHDload team.
|
I think WHLOAD mostly fixed "typos" bugs in Code which came in on accident, and which the developer did not noticed in his configuration he used. Most of these bugs would have been found by the coder if he would have had access to different Amigas e.g. an A500 and A4000 at the same time to test his code. I think that its not difficult to write good code which runs on each Amiga. But that its very difficult is find a typo if your test-system "ignores" it. The rules for coding AMIGA are always the same. Its just that some AMIGA systems not crash if you not follow the rules correctly - while other might crash. This unfortunately means that a "bug" can slip in and stay unnoticed - depending on your test system.
| |
| | Kamelito Loveless
Posts 261 29 Apr 2020 17:28
| A1200 coder wrote:
|
Kamelito Loveless wrote:
| Do you remember the name of that book? |
Yes, I'm not sure if it's useful for you, because it's written entirely in finnish and its only for OCS Amigas. It's called "Amigan pelintekijän opas". If you google for this title, you should find it as a pdf download. But yeah, some good short code examples there still, also for audio programming. Unfortunately, if I remember correctly, nobody ever wrote a good game programming book for Amiga in english, which is only about asm+hardware.
|
Maybe that new book EXTERNAL LINK
| |
| | Olivier Landemarre
Posts 147 12 Jun 2020 21:21
| Hello looking at this code for 22050 Hz value for AUD0PER ($DFF0A4) should not be 3579546/22050 = 162 ? Not very different. On V4 can we acheive 25175Hz or even better 32000 Hz ? I suppose 1 buffer per channel, no way to have interleaved data for stereo ? Olivier Gunnar von Boehn wrote:
| The other day my son Arne (12) was coding his first Amiga ASM game. Lets us show some small SAGA coding tricks he used. 1) How to play a Game music with few lines of code move.l #musik,$DFF0A0 ; We play one 2.5 Min PCM music file 22khz move.w #5670,$DFF0A4 ; Length low bits move.w #158,$DFF0A6 ; Sample rate 22050 move.w #27,$DFF0AE ; Length high bits move.w #64,$DFF0A8 ; Volume move.w #64,$DFF0AC ; Volume Far Side move.w #$8001,$DFF096 ; Turn AUDIO DMA on for Channel 0 incbin "SpyVsSpy.aiff" ; 3.5 MB music file
The music PCM file is a converted MP3. Its mono, 8bit, 22050 Khz, and about 2.5 minute long. As you see with just a few MOVE instructions a complete background music can be played. The Amiga Audio chipset will automatically loop the music. SAGA Audio Hardware allow to position a channel. We use this and play this it back with max Volume of 64 on both sides LEFT and RIGHT
|
| |
| | Gunnar von Boehn (Apollo Team Member) Posts 6254 13 Jun 2020 06:44
| Olivier Landemarre wrote:
| On V4 can we acheive 25175Hz or even better 32000 Hz ?
|
Yes you can reach a lot more. 44100 KHz 48000 KHz 56000 KHz even 62000 Khz Olivier Landemarre wrote:
| I suppose 1 buffer per channel, no way to have interleaved data for stereo ?
|
Yes you are right. For stereo you need two voices.You can position each voice. This means for example an explosion sound in a game you can to play LEFT and RIGHT in parallel - using just one voice. You have 16 voices available to use in parallel.
| |
| | Kef Emzy
Posts 50 13 Jun 2020 14:56
| Gunnar von Boehn wrote:
| You have 16 voices available to use in parallel.
|
16? I thought SAGA supported only 8 channels? 16 channels would be awesome for tracker music!
| |
| | Gunnar von Boehn (Apollo Team Member) Posts 6254 13 Jun 2020 15:24
| Kef Emzy wrote:
|
Gunnar von Boehn wrote:
| You have 16 voices available to use in parallel. |
16? I thought SAGA supported only 8 channels? 16 channels would be awesome for tracker music!
|
Yes the recent SAGA cores support 16 audio channel. 16 voices
| |
| | Kef Emzy
Posts 50 13 Jun 2020 15:51
| Gunnar von Boehn wrote:
| Yes the recent SAGA cores support 16 audio channel. 16 voices
|
That is great news! Thank you so much for this. I'll get a V4 soon to play with.
| |
| | Olivier Landemarre
Posts 147 13 Jun 2020 20:07
| Gunnar von Boehn wrote:
|
Olivier Landemarre wrote:
| On V4 can we acheive 25175Hz or even better 32000 Hz ? |
Yes you can reach a lot more. 44100 KHz 48000 KHz 56000 KHz even 62000 Khz Olivier Landemarre wrote:
| I suppose 1 buffer per channel, no way to have interleaved data for stereo ? |
Yes you are right. For stereo you need two voices. You can position each voice. This means for example an explosion sound in a game you can to play LEFT and RIGHT in parallel - using just one voice. You have 16 voices available to use in parallel.
|
Ok thanks for information. Good news for frequency, bad news for data, Atari side use interleaved data sound for stereo. I have perhaps a small unperfect idea for 8 bits data, 16 bits I don't know how I can do. No PCM in 32 bits ?! Thanks
| |
| | Gunnar von Boehn (Apollo Team Member) Posts 6254 14 Jun 2020 06:34
| Olivier Landemarre wrote:
| I have perhaps a small unperfect idea for 8 bits data, 16 bits I don't know how I can do. No PCM in 32 bits ?!
|
Let me explain the SAGA Audio features. - 16 individual DMA driven audio voices - each Voice can play at a fully independent sample rate - each voice can play 8bit or 16bit samples (you can set each voice fully independent) - each voice has independent 8bit Volume for LEFT and for RIGHT This means each voice can be placed between LEFT/RIGHT speaker where you want. - The Audio dynamic is 24bit (16bit sample * 8bit Volume) - All 512 MB of Memory can be used for audio sample space - Each voice can either play in ONE-SHOT or ENDLESS mode ENDLESS is great for music , ONE-SHOT is great for SND FX I think that today: 8bit samples are still very usefull for SND-FX. While 16bit samples are perfect for Music. As 16bit is already CD quality, I personally can not see any benefit in 32bit samples for home use.
| |
| | Olivier Landemarre
Posts 147 14 Jun 2020 10:52
| Gunnar von Boehn wrote:
|
Olivier Landemarre wrote:
| I have perhaps a small unperfect idea for 8 bits data, 16 bits I don't know how I can do. No PCM in 32 bits ?! |
Let me explain the SAGA Audio features. - 16 individual DMA driven audio voices - each Voice can play at a fully independent sample rate - each voice can play 8bit or 16bit samples (you can set each voice fully independent) - each voice has independent 8bit Volume for LEFT and for RIGHT This means each voice can be placed between LEFT/RIGHT speaker where you want. - The Audio dynamic is 24bit (16bit sample * 8bit Volume) - All 512 MB of Memory can be used for audio sample space - Each voice can either play in ONE-SHOT or ENDLESS mode ENDLESS is great for music , ONE-SHOT is great for SND FX I think that today: 8bit samples are still very usefull for SND-FX. While 16bit samples are perfect for Music. As 16bit is already CD quality, I personally can not see any benefit in 32bit samples for home use.
|
I understand very well all is logical as you explain. My issue is only Atari side for stereo PCM are interleaved so 1 value for the left then one value for the right in memory etc.. Amiga is far more clever!, so if I want emulate stereo sound from Atari side I need each time translate to separate in 2 distinct canal, in some case it will be possible but dont think it will possible for all case. I'm checking if there is other sound protocol for Atari, I'm not very familliar with sound on Atari. Thanks Olivier
| |
|