Your AY playroutine Mike :)

This forum is about audio tools, including samplers, sound trackers, sound chip editors, how to do sound effects, etc...
User avatar
kamelito
Flying Officer
Posts: 182
Joined: Sun Jan 08, 2006 6:34 pm
Location: Nantes, France

Your AY playroutine Mike :)

Post by kamelito »

Hi Mike,

IIRC, you have a playroutine for AY muzak, it was used to play the Trust music. Can you give us the code and how to use it :)

Regards
Kamel
/kml
skype pseudo : kamelitoloveless
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Well, you are talking of the routine I made in 1997, that I used in two demo screens:
- The big scroller with 3 volume metters on top
- The big bouncing Oric logos in the first multiscreen demo I made

Well... this routine is crap, probably very bugged, not optimised, and I don't even have all the the parts of it. Accessorily it was programmed using the old SDK from Fabrice and Vagelis, with the FRASM (Frankestein Assembler) syntax.

Basicaly what I did was to replay Thrust music on my Atari ST, replacing the YM output by a write in memory in a big buffer, then I saved the buffer, and transformed it a bit to something more compact and usable on the Oric.

So this routine is just a 'AY register dump replayer' that loops after one minute or so.

I wanted to post the code as an attachment, but it seems this is not a standard feature of phpBB, and if there is an attachment "mod" available, it seems to suffer from serious security problems.

So well, in the mean time, here is the routine in "plain text":

Code: Select all

VIA_1	equ $30f
VIA_2	equ $30c

_MusicVolA	BYTE	0
_MusicVolB	BYTE	0
_MusicVolC	BYTE	0
_MusicAdress	WORD	0
_MusicPosition	BYTE	0
_MusicPattern	BYTE	0
_MusicLenght	BYTE	60

;
; 48*7=336
;
_InitMusic
	lda	#LOW(_TrustMusic)
	sta	_MusicAdress
	lda	#HIGH(_TrustMusic)
	sta	_MusicAdress+1

	lda	#0
	sta	_MusicPattern
	sta	_MusicPosition
	rts

_PlayMusic
	lda	_MusicAdress
	sta	tmp
	lda	_MusicAdress+1
	sta	tmp+1

playnote_loop
	ldy	#0
	lda	(tmp),y
	tax
	lda	#0
	jsr	VIA_select

	ldy	#1
	lda	(tmp),y
	tax
	lda	#2
	jsr	VIA_select

	ldy	#2
	lda	(tmp),y
	tax
	lda	#4
	jsr	VIA_select

	ldy	#3
	lda	(tmp),y
	tay
	and	#31
	tax
	lda	#6
	jsr	VIA_select
	tya
	lsr	a
	lsr	a
	lsr	a
	lsr	a
	lsr	a
	tay
	eor	#7
	asl	a
	asl	a
	asl	a
	sta	add_value+1
	tya
	clc
add_value
	adc	#0
	ora	#64
	tax
	lda	#7
	jsr	VIA_select

	ldy	#4
	lda	(tmp),y
	tay
	and	#$0f
	tax
	lda	#1
	jsr	VIA_select
	tya
	lsr	a
	lsr	a
	lsr	a
	lsr	a
	tax
	lda	#3
	jsr	VIA_select

	ldy	#5
	lda	(tmp),y
	tay
	and	#$0f
	tax
	lda	#5
	jsr	VIA_select
	tya
	lsr	a
	lsr	a
	lsr	a
	lsr	a
	tax
	stx	_MusicVolA
	lda	#8
	jsr	VIA_select

	ldy	#6
	lda	(tmp),y
	tay
	and	#$0f
	tax
	stx	_MusicVolB
	lda	#9
	jsr	VIA_select
	tya
	lsr	a
	lsr	a
	lsr	a
	lsr	a
	tax
	stx	_MusicVolC
	lda	#10
	jsr	VIA_select

	clc
	lda	tmp
	adc	#7
	sta	tmp
	lda	tmp+1
	adc	#0
	sta	tmp+1

	lda	tmp
	sta	_MusicAdress
	lda	tmp+1
	sta	_MusicAdress+1

	ldx	_MusicPosition
	inx
	cpx	#48
	bne	continue_pattern
next_pattern
	ldx	#0
	ldy	_MusicPattern
	iny
	cpy	#60
	bne	continue_music
	ldy	#0
	lda	#LOW(_TrustMusic)
	sta	_MusicAdress
	lda	#HIGH(_TrustMusic)
	sta	_MusicAdress+1
continue_music
	sty	_MusicPattern
continue_pattern
	stx	_MusicPosition
	rts

;
; A -> Soundchip register number (0-13)
; X -> Value to write
;
VIA_select
	sta	VIA_1
	txa

	pha
	lda	VIA_2
	ora	#$EE		; $EE	238	11101110
	sta	VIA_2

	and	#$11		; $11	17	00010001
	ora	#$CC		; $CC	204	11001100
	sta	VIA_2

	tax
	pla
	sta	VIA_1
	txa
	ora	#$EC		; $EC	236	11101100
	sta	VIA_2

	and	#$11		; $11	17	00010001
	ora	#$CC		; $CC	204	11001100
	sta	VIA_2
	rts

_TrustMusic
    BYTE    $30,$ee,$de,$57,$e2,$fe,$0f
    BYTE    $28,$ee,$de,$5f,$e2,$fe,$0f
    BYTE    $20,$ee,$ee,$57,$e2,$fe,$0e
    BYTE    $20,$ee,$fe,$5f,$e2,$fe,$0d
    BYTE    $28,$ee,$fe,$57,$e2,$fe,$0c
    BYTE    $30,$ee,$ee,$5f,$e2,$fe,$0b
   ; Some more data
As you can see, this is not particularly elegant code... and for it to work correctly, interrupts have to be disabled.
User avatar
carlsson
Pilot Officer
Posts: 127
Joined: Thu Jan 12, 2006 11:26 pm
Location: Västerås, Sweden

Post by carlsson »

A lot of shifting! Some day, I'll look into how to access the PSG via VIA (heh) and port my VIC-20 music player to Oric. Perhaps I will add a few music effects to it first. There should be other VIC/Atari/BBC (?) players out there which could be adopted too.
User avatar
Euphoric
Game master
Posts: 99
Joined: Mon Jan 09, 2006 11:33 am
Location: France

Post by Euphoric »

Hello Anders, is this a recent photograph of you, or are trying to have us believe you're that young ;-)

Nice to see we are beginning to convert a VIC-20 to the Oric :-D
Do you have an Atmos ? I could try to repair one of those faulty Atmos'es I have here and send one to you...

Cheers,

Fabrice
User avatar
Euphoric
Game master
Posts: 99
Joined: Mon Jan 09, 2006 11:33 am
Location: France

Post by Euphoric »

Nice to see we are beginning to convert a VIC-20 to the Oric
I meant "a VIC-20 fan/supporter", you guessed it... :-)
User avatar
carlsson
Pilot Officer
Posts: 127
Joined: Thu Jan 12, 2006 11:26 pm
Location: Västerås, Sweden

Post by carlsson »

The picture is maybe one or two years ago. I'm 30, but may look younger.

I've been a bit of a Oric fan for years, but not really got the incentive to try some programming. I put some bids on the Oric Atmos in Dimitri's sales, but it went a bit too expensive for my taste. I guess reading some tech articles (I know all of your sites) and try out in Euphoric would be a good start.
Anders Carlsson
JamesD
Flight Lieutenant
Posts: 358
Joined: Tue Nov 07, 2006 7:38 am

Post by JamesD »

Pardon my lack of ORIC knowledge but what are the VIA references here?
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

VIA 6522, the IO chip in the Oric.
You can see it here:

http://www.defence-force.org/computing/ ... /index.htm

There are also numerous data sheets on the net :)
JamesD
Flight Lieutenant
Posts: 358
Joined: Tue Nov 07, 2006 7:38 am

Post by JamesD »

I kinda figured that's what it was going to be.
Then the registers for the sound chip aren't directly memory mapped but mapped through the VIA chip. Isn't that kinda slow?
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Well, check the VIA_select routine in the source code at the beggining :)
JamesD
Flight Lieutenant
Posts: 358
Joined: Tue Nov 07, 2006 7:38 am

Post by JamesD »

Beginning? Funny, it looks like it's all over in the code.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Well yes, there is one single routine called from everywhere, for each single YM register you need to select the right IO stuff and write the right value to send to the YM processor.
JamesD
Flight Lieutenant
Posts: 358
Joined: Tue Nov 07, 2006 7:38 am

Post by JamesD »

What did you use to edit the music?
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

From the second message in the thread:
Basicaly what I did was to replay Thrust music on my Atari ST, replacing the YM output by a write in memory in a big buffer, then I saved the buffer, and transformed it a bit to something more compact and usable on the Oric.

So this routine is just a 'AY register dump replayer' that loops after one minute or so.
I never edited this music. It's only a rip from some other musician play routine.
Post Reply