News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_zhulien

interesting walkthrough video coding a pet to play samples at 60khz

Started by zhulien, 18:18, 09 May 25

Previous topic - Next topic

Ygdrazil and 2 Guests are viewing this topic.

BSC

Quote from: McArti0 on Yesterday at 06:13OUTI  ;5
INC B ;1
NOP  ;1
NOP  ;1

1000/8=125kHz
I love your comprehensive style of posting. You clearly explain why you have a certain opinion, provide evidence or links to existing code, awesome - not! I strongly doubt that what you claim here is possible. I did my fair amount of experiments with the AY in the last 10ish years and it never occurred to me that what you claim here is possible. At least not without glitches, on a real machine. 
** My website ** Some music

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

McArti0

Quote from: BSC on Yesterday at 12:46 I strongly doubt that what you claim here is possible.
Are you talking about dithering?
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
One chip driver for 512kB(to640) extRAM 6128
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

BSC

Quote from: McArti0 on Yesterday at 13:57
Quote from: BSC on Yesterday at 12:46 I strongly doubt that what you claim here is possible.
Are you talking about dithering?
No, the code snippet containing OUTI. 
** My website ** Some music

My hardware: ** Schneider CPC 464 with colour screen, 64k extension, 3" and 5,25 drives and more ** Amstrad CPC 6128 with M4 board, GreaseWeazle.

andycadley

Quote from: McArti0 on Yesterday at 11:22
Quote from: Targhan on 20:15, 12 May 25
Quote from: andycadley on 12:38, 12 May 25I have a sneaking suspicion you may not get audio on a Plus machine if you don't,
Yup, you're right!
Does any emulator show this?
It would be a very absurd design. Blocking the F4 port to switch something in F6? After all, AY works the same way.

I don't think so, most emulators will quite happily ignore situations where a real Plus keyboard stops responding for example.

You have to remember there is no 8255 in a Plus at all, the ASIC mimics it's behaviour based on the spec and also has to be able to do things like write to the AY regardless of PPI state (because DMA sound). So it can be very finicky about doing things the way they were supposed to be done, rather than what necessarily could be gotten away with.

lightforce6128

Quote from: McArti0 on Yesterday at 11:22
Quote from: Targhan on 20:15, 12 May 25
Quote from: andycadley on 12:38, 12 May 25I have a sneaking suspicion you may not get audio on a Plus machine if you don't,
Yup, you're right!
Does any emulator show this?
It would be a very absurd design. Blocking the F4 port to switch something in F6? After all, AY works the same way.

I tried on WinAPE. Configured to 6128 and 6128 plus it did not show a difference. In both cases it works. Would be good to know how different actual hardware behave.

@Targhan : Does "Yup, you're right!" mean: "I got the same feeling. I agree with this." Or does it mean: "I tried this on real hardware. It did not work as expected."

lightforce6128

Quote from: BSC on Yesterday at 12:46I did my fair amount of experiments with the AY in the last 10ish years and it never occurred to me that what you claim here is possible. At least not without glitches, on a real machine.

If it is possible on real hardware to send values continuously, there will be glitches (I know the term hazard for this). E.g. while switching between register selection and register update, if the PPI is not programmed to stop it will send the next register index also as register value for the last register index. For operation in music trackers where all or at least several registers are updated in a row this clearly needs to be considered.

But while playing a sample, only a single register is changed. If there is a glitch/hazard in the value, there will be a minimal creaking in the output until the right volume value arrives. But here we are talking about microseconds. Is this audible?

One detail question we can think about: The tone frequency of a channel is divided into two registers. What happens if one updates the first register, but is not fast enough to update the second? Does the PSG stops counting during these operations? Or does it simply continue and possibly will output a wrong frequency until the second register is also updated? Usually the ICs used back then do not contain buffers, caches, or complex internal logic, but simply do their main work and rely on a bit good will of the surrounding (e.g. timing).

Maniac

Quote from: lightforce6128 on Today at 02:30
Quote from: McArti0 on Yesterday at 11:22
Quote from: Targhan on 20:15, 12 May 25
Quote from: andycadley on 12:38, 12 May 25I have a sneaking suspicion you may not get audio on a Plus machine if you don't,
Yup, you're right!
Does any emulator show this?
It would be a very absurd design. Blocking the F4 port to switch something in F6? After all, AY works the same way.

I tried on WinAPE. Configured to 6128 and 6128 plus it did not show a difference. In both cases it works. Would be good to know how different actual hardware behave.

@Targhan : Does "Yup, you're right!" mean: "I got the same feeling. I agree with this." Or does it mean: "I tried this on real hardware. It did not work as expected."

Don't count on WinAPE being accurate for this. When I was patching Split Personalities to work on the Plus the audio was fine on WinAPE. When I then tested on my Plus it has odd sound interference. The emulator seems to take a few shortcuts with this side of things.

Targhan

Quote from: lightforce6128 on Today at 02:30I tried on WinAPE. Configured to 6128 and 6128 plus it did not show a difference. In both cases it works.
To my knowledge, if you don't #f600 on CPC Plus, there is no sound.
Targhan/Arkos

Arkos Tracker 3.2.6 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

andycadley

Quote from: Maniac on Today at 08:42
Quote from: lightforce6128 on Today at 02:30
Quote from: McArti0 on Yesterday at 11:22
Quote from: Targhan on 20:15, 12 May 25
Quote from: andycadley on 12:38, 12 May 25I have a sneaking suspicion you may not get audio on a Plus machine if you don't,
Yup, you're right!
Does any emulator show this?
It would be a very absurd design. Blocking the F4 port to switch something in F6? After all, AY works the same way.

I tried on WinAPE. Configured to 6128 and 6128 plus it did not show a difference. In both cases it works. Would be good to know how different actual hardware behave.

@Targhan : Does "Yup, you're right!" mean: "I got the same feeling. I agree with this." Or does it mean: "I tried this on real hardware. It did not work as expected."

Don't count on WinAPE being accurate for this. When I was patching Split Personalities to work on the Plus the audio was fine on WinAPE. When I then tested on my Plus it has odd sound interference. The emulator seems to take a few shortcuts with this side of things.
WinAPE is a lovely emulator and it is great for playing the main cart releases. It's accuracy of Plus emulation is very buggy though in lots of ways, so I'd never rely on it for checking what real hardware does.

Longshot

Quote from: McArti0 on 22:24, 12 May 25org #4000

di
call init

ld d,#F5
ld bc,#F400

loop

  inc c
  out (c),c

vsync1
ld a,d : in a,(0) : rra : jr nc,vsync1
vsync2
ld a,d : in a,(0) : rra : jr c,vsync2

jr loop

ret

init
ld bc,#F782 ;PC set PA as OUT
OUT (c),c

ld bc,#F407 ;PA has R sel (vol A channel)
OUT (c),c

ld bc,#F6C0 ;PC move PA to sel R
OUT (c),c

ld bc,#F600 ;PC dis AY
OUT (c),c

ld bc,#F43e ;PA set
OUT (c),c

ld bc,#F680 ;PC open AY and connect PA with Rsel
OUT (c),c

ld bc,#F600 ;PC dis AY
OUT (c),c

; R8

ld bc,#F408 ;PA has R sel (vol A channel)
OUT (c),c

ld bc,#F6C0 ;PC move PA to sel R
OUT (c),c

ld bc,#F600 ;PC dis AY
OUT (c),c

ld bc,#F409 ;PA set
OUT (c),c

ld bc,#F680 ;PC open AY and connect PA with Rsel
OUT (c),c

ld bc,#F600 ;PC dis AY
OUT (c),c

; R0

ld bc,#F400 ;PA has R sel (vol A channel)
OUT (c),c

ld bc,#F6C0 ;PC move PA to sel R
OUT (c),c

ld bc,#F600 ;PC dis AY
OUT (c),c

ld bc,#F400 ;PA set 0
OUT (c),c

ld bc,#F680 ;PC open AY and connect PA with Rsel
OUT (c),c



ret

As Prodatron, Targhan and Bsc said, you must use 3 OUTs to send a value to an AY register, even if you don't change registers in the meantime.

So you have to enter the data on F4. Then on F6, select the type of data (bdir/bc1>>#10) and validate everything (bdir/bc1>>00).

Otherwise, the data in other AY registers becomes corrupted quite quickly. Lbb and I studied this in 1992. He deduced that if, after 1040 nops on his machine, there has been no validation, all the registers begin to be masked with an AND that is related to the last value sent to port A (F4). I think this can be explained by the way registers are assigned in these old circuits, often based on AND and OR.

If validation is done, your register is no longer in write mode. So you have to put #80 back in port C.

The example given by McArti0 doesn't work on my real machines (Plus or not). No sound.
Winape does generate a progressive sound with this code, but it's not the reference. :laugh:

In its settings/general menu, Winape has an option to enable (or not) the Plus's PPI emulation, but it's far from sufficient because there are several bugs.
For example, the read frequency registers return 16-bit values. Not to mention the lack of PPI lock for managing DMA sounds.

In my opinion, DMA sounds remain the only way to reach 125 kHz.
Rhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!

McArti0

I see here another problem of synchronizing the F4 change with the edges of the AY clock. To stiffen it, We would have to exit from the interrupt to handle AY.
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
One chip driver for 512kB(to640) extRAM 6128
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Powered by SMFPacks Menu Editor Mod