New 1bit PWM music engine for the CoCo and Dragon

Use this forum to submit new files for the download section of the archive. I will check each submission and upload it to the archive on a regular basis.
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by zephyr »

Changed the code so that the music length counter was no longer needed. Did some more code size/speed optimization.

EDIT: Attachment (Zephyr-modified_v7.zip) removed.
Last edited by zephyr on Wed Dec 04, 2013 11:32 pm, edited 1 time in total.
simon
Posts: 163
Joined: Wed Nov 27, 2013 8:56 pm

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by simon »

COOL !

I knew I wasn't flogging a dead horse with the 1bit routine for the coco / dragon....

I actually started off doing my own conversion af a c64 6502 1bit routine to 6809, but then i hooked up with John Kowalski to produce the direct z80 port.... (the 6502 code had been ported from z80, so my code was "3rd" hand)

/Simon :-)
simon
Posts: 163
Joined: Wed Nov 27, 2013 8:56 pm

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by simon »

zephyr wrote:Changed the code so that the music length counter was no longer needed. Did some more code size/speed optimization.

YOINK......

definately gonna use the new code in my demo.....

:twisted:
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by zephyr »

simon wrote:COOL !

I knew I wasn't flogging a dead horse with the 1bit routine for the coco / dragon....
Not at all! :) It must have been interesting working with John Kowalski (the legendary Sock Master)?
simon wrote: definately gonna use the new code in my demo.....
I look forward to the release of your demo. 8-) Let us know when its finished, and where we can download it.
simon
Posts: 163
Joined: Wed Nov 27, 2013 8:56 pm

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by simon »

John Kowalski converted the z80 code for me.... literally on a napkin....
i assembled it and made it play, sounded well skanky.....

then we set about debugging it over 2 days... i kept sending him .wav files of the players output and he tweaked the code a bit more until we got it right.....

very cool bloke indeed !


here are some of the "expiriments"

http://www.roust-it.dk/coco/sock1.wav
http://www.roust-it.dk/coco/sock2.wav
http://www.roust-it.dk/coco/sock3.wav
http://www.roust-it.dk/coco/sock4.wav
http://www.roust-it.dk/coco/sock5.wav
http://www.roust-it.dk/coco/1bit4.wav
http://www.roust-it.dk/coco/coco1bit.wav


/simon :D
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by zephyr »

Did some more code size/speed optimization. Changed pointers to 16-bit.
Attachments
Zephyr-modified_v8.zip
(10 KiB) Downloaded 224 times
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by zephyr »

Here's another demo tune using the above v8 player engine.
Attachments
MSD8.zip
(4.72 KiB) Downloaded 237 times
simon
Posts: 163
Joined: Wed Nov 27, 2013 8:56 pm

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by simon »

This would be the same engine with a couple of new speed tweaks:

https://www.youtube.com/watch?v=U68Ak1MJa2g

https://www.youtube.com/watch?v=MPp24XyMB30

theres roughly a 12% speed increase in the "inner loop".....

/Simon :-)
zephyr
Posts: 1474
Joined: Mon Jul 21, 2008 1:18 am

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by zephyr »

I made some more changes:

(1) Minor speed optimization.
(2) Added extra code to make the program DOS compatible.
(3) No longer uses the S register for writing to $FF20 (this modification was suggested by John).
(4) Removed the "anda #$C0" before writing to $FF20 (this modification was suggested by John and Simon).
Attachments
Zephyr-modified_v9.zip
(23.46 KiB) Downloaded 237 times
simon
Posts: 163
Joined: Wed Nov 27, 2013 8:56 pm

Re: New 1bit PWM music engine for the CoCo and Dragon

Post by simon »

zephyr wrote:I made some more changes:

(1) Minor speed optimization.
(2) Added extra code to make the program DOS compatible.
(3) No longer uses the S register for writing to $FF20 (this modification was suggested by John).
(4) Removed the "anda #$C0" before writing to $FF20 (this modification was suggested by John and Simon).

so, you want 8% more speed....

well here you go.... (i'm hard pressed for time so someone else will have to patch the .asm files and make new .wav/.cas files):

I had a good discussion with John Kowalski (Sock Master) about the routine, where he pointed out to be there was an single instruction inside the main 15 cycle loop that was redundant....

he would not tell me which one... (obvisously wanted to make me work for it)...., but after some single stepping of the code in EDTASM, i discovered that the lda <bord2+1 was getting loaded every pass without being used.... so, it needed to be moved (and repeated) to a less critical area....


so if your looking at code, this would be the new code:

bord2 adda #00
sta ,y
;*****************************************************************
; lda <bord2+1 ;WRONG POSITION (gets executed in critical loop without reason)
;*****************************************************************
dec <ch2count
bne l806d
;*****************************************************************
lda <bord2+1 ;NEW POSITION
;*****************************************************************

xore2 eora #00
sta <bord2+1
ch2freq ldb #00
stb <ch2count
ch2ix ldb #00
cmpb #$20
bcc l806d ; if A > $20 then this is not a drum effect, skip the INC D
inc <ch2freq+1 ; create the "fast falling pitch" percussion effect

l806d dec <ltemp2
bne l8073
;*****************************************************************
lda <bord2+1 ;NEW POSITION 2 (extra instruction)
;*****************************************************************

xore2b eora #00

by moving the lda <bord2+1 outside the critical loop we achive an 8% speed increase.... that, coupled with the removal of the anda #$c0 gives us a 12% speed increase inside the "core" loop, definately worth the effort....

result can be heard in the 2 previous youtube videos from my last post......

hopefully others will pitch in and make this the "definative" player for the coco /dragon.....

/Simon :-)
Post Reply