I got bored so I started on this
the left in right might be switched, I don't know which ring goes to which.

Code:
Start:
   ;;insert code to start the interrupt here
   di
   exx
   ld bc,MusicStartLeft
   ld de,MuxicStartRight
   call NextNoteLeft
   call NextNoteRight
   exx
   ei

StartMain:
Main:
   ld hl, (righttimer)
   dec hl
   ld (righttimer),hl
   ld a,h
   or l
   call z, FlipRight

   ld hl, (lefttimer)
   dec hl
   ld (lefttimer),hl
   ld a,h
   or l
   call z, FlipLeft
   
   jp Main

Interrupt:
   ex af, af'
   exx
   
   ld hl,(NoteLengthLeft)
   dec hl
   ld (NoteLengthLeft),hl
   ld a,h
   or l
   call z, NextNoteLeft
   
   ld hl,(NoteLengthRight)
   dec hl
   ld (NoteLengthRight),hl
   ld a,h
   or l
   call z, NextNoteRight

   ex af,af'
   exx
   reti
   
NextNoteLeft:
   ld l,(bc)
   inc bc
   ld h,(bc)
   ld (NoteLengthLeft),hl
   inc bc
   ld l,(bc)
   inc bc
   ld h,(bc)
   ld (lefttimermax),hl
   inc bc
   ret   
   
NextNoteRight:
   ld l,(de)
   inc de
   ld h,(de)
   ld (NoteLengthRight),hl
   inc de
   ld l,(de)
   inc de
   ld h,de
   ld (righttimermax),hl
   inc de
   ret
   
InterruptEnd:
   
FlipLeft:

   ld a,e
   ld hl,(lefttimermax)
   ld (lefttimer),hl
   xor %00000001
   ld e,a
   out (0),a
   ret

FlipRight:

   ld a,e
   ld hl,(righttimermax)
   ld (righttimer),hl
   xor %00000010
   ld e,a
   out (0),a
   ret

.dw MusicAddressRight
.dw MusicAddressLeft
.dw NoteLengthRight
.dw NoteLengthLeft
.dw righttimer
.dw lefttimer
.dw righttimermax
.dw lefttimermax

;; .dw length
;; .dw pitch
Will_W, nice idea, but regarding the interrupt:


Code:
[12:23:28] <+KermM> the only problem is that the interrupt firing is going to make your notes not change for the duration of the interrupt
[12:23:41] <Will_W> that could be a problem
[12:23:49] <+KermM> so you'lll have weird audio artifacts from the line stopping oscillating
[12:23:51] <Will_W> but I'll have to take that into account for the frequencies
[12:24:03] <+KermM> but you can't predict when it will fire...
It turned out to be useless, but it was fun.
The 128ish interrupts per second really kill any sort of pitch you try to make.

Code:

;#DEFINE TASM8X ; uncomment if you are using asm8x
;note, don't use asm8x for this code.  It doesn't like it.

#IFNDEF TASM8X
.org 9d93h
    .db $BB, $6D
#ENDIF

Start:
    ld hl, 0
    push hl
    di              ;disable interrupts (don't want an interrupt before we're ready)
    ld  hl,$9900        ;start of interrupt table
    ld  de,$9901        ;start of interrupt table +1
    ld  bc,256          ;257 - 1 bytes to copy
    ld  (hl),$9a        ;load $9a into (hl)
    ldir                ;ld (hl) into (de), inc hl and de, ld (hl) into (de)...

    ;now you have a 257 byte table starting at $9900 filled with $9a

    ld  hl,Interrupt            ;\
    ld  de,$9a9a                ; | copy interrupt routine to $9a9a
    ld  bc,InterruptEnd-Interrupt   ; |
    ldir                        ;/
    ld  a,$99
    ld  i,a         ;load $99 into I

    ;;insert code to start the interrupt here
    ex af, af'
    exx
    ld bc,MusicStartLeft
    ld de,MusicStartRight
    call NextNoteLeft
    call NextNoteRight
    exx
    ex af, af'

StartMain:
   ld hl,righttimer
   ld de,(righttimermax)
   ld (hl),e
   inc hl
   ld (hl),d
   
   ld hl,lefttimer
   ld de,(lefttimermax)
   ld (hl),e
   inc hl
   ld (hl),d
   
   
   
   im 2
   ei
Main:
    ld hl, (righttimer)
    dec hl
    ld (righttimer),hl
    ld a,h
    or l
    call z, FlipRight

    ld hl, (lefttimer)
    dec hl
    ld (lefttimer),hl
    ld a,h
    or l
    call z, FlipLeft
   
    jp Main

Interrupt:
    ex af, af'
    exx
   
    ld hl,(NoteLengthLeft)
    dec hl
    ld (NoteLengthLeft),hl
    ld a,h
    or l
    call z, NextNoteLeft
   
    ld hl,(NoteLengthRight)
    dec hl
    ld (NoteLengthRight),hl
    ld a,h
    or l
    call z, NextNoteRight

    ex af,af'
    exx
    im 2
    ei
    reti
   
NextNoteLeft:
    ld h,b
    ld l,c
    ld c,(hl)
    inc hl
    ld b,(hl)
    ld (NoteLengthLeft),bc
    inc hl
    ld c,(hl)
    inc hl
    ld b,(hl)
    ld (lefttimermax),bc
    inc hl
    ld b,h
    ld c,l
    ret
   
NextNoteRight:
    ex de,hl
    ld e,(hl)
    inc hl
    ld d,(hl)
    ld (NoteLengthRight),de
    inc hl
    ld e,(hl)
    inc hl
    ld d,(hl)
    ld (righttimermax),de
    inc hl
    ex de,hl
    ld a,h
    or l
    ret nz
   
    jp Quit
   
InterruptEnd:
   
FlipLeft:

    ld a,e
    ld hl,(lefttimermax)
    ld (lefttimer),hl
    xor %00000001
    ld e,a
    out (0),a
    ret

FlipRight:

    ld a,e
    ld hl,(righttimermax)
    ld (righttimer),hl
    xor %00000010
    ld e,a
    out (0),a
    ret
   
Quit:
    di
    im 1
    pop hl
    ld a,h
    or l
    jp nz,Quit
    ei
    ret

MusicAddressRight:
    .dw 0
MusicAddressLeft:
    .dw 0
NoteLengthRight:
    .dw 0
NoteLengthLeft:
    .dw 0
righttimer:
    .dw 0
lefttimer:
    .dw 0
righttimermax:
    .dw 0
lefttimermax:
    .dw 0
   
   
MusicStartLeft:
    .dw $FFFF
    .dw 262
    .dw $FFFF
    .dw 100
    .dw $FFAA,50
    .dw 0
    .dw 0
MusicStartRight:
    .dw $FFFF
    .dw 100
    .dw $FFFF
    .dw 262
    .dw $FFAA,75
    .dw 0
    .dw 0
   
   
.end

;; .dw length
;; .dw pitch
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement