Hi
I'm trying to play infinite simple music on 128K with the AY, but i don't know what is wrong with the loop
I tried this routine but doesn't work I don't know why
I tried some other stuff with the AY ports, but nothing worked
This is the simple routine if anyone want to help and fixit to do infinite loop
Only does:
A) Put IM2 ON
B) ISR play notes
C) When finish try to repeat at the begining of the notes ( this is the wrong part, i don't know why. I tried a lot of things)
Thanks in advance
; ROUTINE BEGINS
; Trying to do infinite music ( WITH PASMO ASSEMBLER)
org 8000h
; RSI JUMP ADDRESS
lowRSI equ (rsi % 256)
hiRSI equ (rsi - lowRSI)/256
begin
di
ld hl,$FEFF
ld (hl),lowRSI
inc hl
ld (hl), hiRSI
ld a,$FE
ld i,a
im 2 ; IM2 ON
ei
jr $ ; infinite loop only waits for play music
; RSI begin
rsi
ld hl,(pos)
loop
ld a,(hl)
or a
jr nz,waitSound
inc hl
ld a,(hl)
cp $FF
jr z,endMusic
cp $FE
jr z,jumpNotes
ld bc,$FFFD
out (c),a
inc hl
ld a,(hl)
ld b,$BF
out (c),a
inc hl
jr loop
waitSound
ld (pos),hl
dec a
ld (hl),a
ei
ret
jumpNotes
inc hl
inc hl
ld (pos),hl
ei
ret
; Here i must put something to begin again when the music ends
endMusic
; I tried this but doesn't work I don't know why
; I tried some other stuff with the AY ports but nothing worked
ld hl,notes
ld (pos),hl
ei
ret
; Music Pointer
pos dw notes
;Litle Music example
notes
db 000h, 007h, 038h, 000h, 008h, 000h, 000h, 009h, 000h
db 000h, 010h, 000h, 000h, 000h, 0fch, 000h, 001h, 000h
db 000h, 008h, 00fh, 019h, 000h, 07eh, 000h, 002h, 0fch
db 000h, 003h, 000h, 00dh, 000h, 0a8h, 000h, 002h, 07eh
db 000h, 004h, 0fch, 000h, 005h, 000h, 019h, 000h, 0fch
db 000h, 009h, 000h, 000h, 0ffh, 000h
END begin
;ROUTINE END
Help with infinite music on 128K with the AY
-
- Drutt
- Posts: 12
- Joined: Sat Jun 29, 2019 10:26 pm
- PROSM
- Manic Miner
- Posts: 476
- Joined: Fri Nov 17, 2017 7:18 pm
- Location: Sunderland, England
- Contact:
Re: Help with infinite music on 128K with the AY
I've assembled the code myself, and it looks like the problem is that you're keeping track of note length by altering the music data itself. This would be fine if you only intended to use it once, but by the time you repeat the music, all of your note lengths are set to zero, which causes your code to misunderstand them (since your code assumes that zeroes denote commands). Instead of decrementing the note lengths in the music data itself, when your code sees a delay, it should make a copy of this to a separate location and decrement the copy, then move on.
I've included a fixed version below. Note that I have inserted an additional zero in front of each delay value; it seemed that your code was using the zeroed out delay as a control code - again, fine if it is only played once, but disastrous if repeated:
(PS - I moved the interrupt jump address to the bottom of the code - I was getting weird "3-pass compilation" warnings when it was at the top, like in your original post)
I've included a fixed version below. Note that I have inserted an additional zero in front of each delay value; it seemed that your code was using the zeroed out delay as a control code - again, fine if it is only played once, but disastrous if repeated:
Code: Select all
; ROUTINE BEGINS
; Trying to do infinite music ( WITH PASMO ASSEMBLER)
org 8000h
begin
di
ld hl,$FEFF
ld (hl),lowRSI
inc hl
ld (hl), hiRSI
ld a,$FE
ld i,a
im 2 ; IM2 ON
ei
jr $ ; infinite loop only waits for play music
; RSI begin
rsi
ld a,(delay)
or a ; check if we need to wait longer
jr nz,waitSound
ld hl,(pos)
loop
ld a,(hl)
or a
jr nz,startDelay
inc hl
ld a,(hl)
cp $FF
jr z,endMusic
cp $FE
jr z,jumpNotes
ld bc,$FFFD
out (c),a
inc hl
ld a,(hl)
ld b,$BF
out (c),a
inc hl
jr loop
waitSound
ld hl,delay
ld a,(hl)
dec a
ld (hl),a
ei
ret
startDelay
inc hl ; advance to next piece of music data
ld (pos),hl ; set up delay variable
ld (delay),a
jr waitSound
jumpNotes
inc hl
inc hl
ld (pos),hl
ei
ret
; Here i must put something to begin again when the music ends
endMusic
; I tried this but doesn't work I don't know why
; I tried some other stuff with the AY ports but nothing worked
ld hl,notes
ld (pos),hl
ei
ret
; Music Pointer
pos dw notes
delay db 0
; RSI JUMP ADDRESS
lowRSI equ (rsi % 256)
hiRSI equ (rsi - lowRSI)/256
;Litle Music example
notes
db 000h, 007h, 038h, 000h, 008h, 000h, 000h, 009h, 000h
db 000h, 010h, 000h, 000h, 000h, 0fch, 000h, 001h, 000h
db 000h, 008h, 00fh, 019h, 000h, 000h, 07eh, 000h, 002h, 0fch
db 000h, 003h, 000h, 00dh, 000h, 000h, 0a8h, 000h, 002h, 07eh
db 000h, 004h, 0fch, 000h, 005h, 000h, 019h, 000h, 000h, 0fch
db 000h, 009h, 000h, 000h, 0ffh, 000h
END begin
All software to-date
Working on something, as always.
Working on something, as always.
-
- Drutt
- Posts: 12
- Joined: Sat Jun 29, 2019 10:26 pm
Re: Help with infinite music on 128K with the AY
----------------__________________________--------------------------
Many Thanks, that was the problem
Many Thanks, that was the problem