| |
Technotron
Registered: Sep 2014 Posts: 23 |
help needed for simple demo
hi all,
first of all I have to tell that I'm pretty newbie in the scene, so bear with me.
I have coded a simple scroller in assembler located at $c000 and it works. now I would like to add some music located at $1003 but I don't know how to proceed. I need a small routine that could be called with JSR and that returns to the scroller after some bits of music is played.
I have tried with the following routine but it doesn't work since it continues playing without returning to the scroller:
c010 lda $d012
cmp #$80
bne $c010
inc $d020
jsr $1003
dec $d020
rts
can anybody help me? |
|
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: hi all,
first of all I have to tell that I'm pretty newbie in the scene, so bear with me.
I have coded a simple scroller in assembler located at $c000 and it works. now I would like to add some music located at $1003 but I don't know how to proceed. I need a small routine that could be called with JSR and that returns to the scroller after some bits of music is played.
I have tried with the following routine but it doesn't work since it continues playing without returning to the scroller:
c010 lda $d012
cmp #$80
bne $c010
inc $d020
jsr $1003
dec $d020
rts
can anybody help me?
Have you initialized the music routine at the start of the demo with
lda #0
tax
tay
jsr $1000 |
| |
Technotron
Registered: Sep 2014 Posts: 23 |
hi, thanks for your reply.
no I didn't initialized the music routine. but my problem is not with playing music but returning to the scroller after some bits of music have been played. I can't just return. |
| |
Conrad
Registered: Nov 2006 Posts: 849 |
How are you calling the code you wrote at $c010? If it's JMP rather than JSR then it wouldn't return from that subroutine.
Can you post the code where you call $c010? |
| |
Oswald
Registered: Apr 2002 Posts: 5095 |
if you already have a wait for d012 for the scroller, then just try a simple jsr $1003 after the scroller code finished, as no further waits is necessary. best would be to see the src tho. |
| |
Technotron
Registered: Sep 2014 Posts: 23 |
this is the source code for the scroller:
c000 ldx #$4f
stx $fb
ldx #$c0
stx $fc
c008 ldy #$00
c00a ldx #$00
c00c lda $0401,x
sta $0400,x
inx
cpx #$27
bne $c00c
lda ($fb),y
cmp #$2a
beq $c000
sta $0427
sty $c100
ldx #$30
c025 ldy #$ff
c027 dey
jsr $c100
bne $c027
ldy #$ff
c02f dey
jsr $c100
bne $c02f
ldy #$ff
c037 dey
jsr $c100
bne $c037
dex
bne $c025
ldy $c100
iny
cpy #$ff
bne $c00a
sec
lda $fb
adc #$ff
sta $fb
lda $fc
adc #$00
sta $fc
jmp $c008
inside the routine there are the calls to the music routine at $c100 (actually $c1oo and not $c010, my bad)
and this is the music routine:
c100 lda $d012
cmp #$80
bne $c100
inc $d020
jsr $1003
dec $d020
rts
I don't understand what's wrong with the code. |
| |
Conrad
Registered: Nov 2006 Posts: 849 |
This part...
ldy #$ff
dey
jsr $c100
bne $c027
... makes me assume that the branch condition (BNE) is checking if Y is not 0? If so, then you need to put code in to remember the Y register state
before it calls $1003. 99% of music routines will be using all A, X and Y registers.
Try this:
c100:
sty $03
lda $d012
cmp #$80
bne $c100
inc $d020
jsr $1003
dec $d020
ldy $03
rts
|
| |
The Phantom
Registered: Jan 2004 Posts: 360 |
I'm a bit confused, but that's my life story. I'm ALWAYS confused ;)
sei
start
lda #$32
cmp $d012
bne *-3
jsr scroll
lda #$70
cmp #$d012
bne *-3
jsr music ($1003)
jmp start
Does that help? |
| |
Oswald
Registered: Apr 2002 Posts: 5095 |
also:
c008 ldy #$00
sty $c100
jsr $c100
this will put a BRK at c100, and then jsr it. not good.
also why jsr to $c100 in several loops which run for 255 times?
dont waste cycles in loops (esp. not if they call the music), simply wait for d012 if you need to catch a raster position. |
| |
robo
Registered: Nov 2012 Posts: 9 |
your code looks really strange to me, you must call the music player only once per frame.
this is basically what you have to do:
init music (lda #0 : jsr $1000)
loop:
setup scrolltext-vector ($fb/$fc)
loop1:
wait for rasterline ($d012 = #80)
bne loop1
call music player (jsr $1003)
loop2:
shift screenline left (39 chars)
bne loop2
ldy #0
lda ($fb),y ; read next char
(escape-char found --> reset scrolltext with jmp loop)
sta $0427 ; print char on screen
inc scrolltext-vector ($fb/$fc)
jmp loop1 |
| |
Technotron
Registered: Sep 2014 Posts: 23 |
thanks to all those who replied.
@Conrad
Quote:... makes me assume that the branch condition (BNE) is checking if Y is not 0? If so, then you need to put code in to remember the Y register state
before it calls $1003. 99% of music routines will be using all A, X and Y registers.
yes that makes sense. I've added the lines you showed me but to no avail. I can't return from the sound routine.
@Oswald
Quote:also:
c008 ldy #$00
sty $c100
jsr $c100
this will put a BRK at c100, and then jsr it. not good.
also why jsr to $c100 in several loops which run for 255 times?
yes you are right. so, I put the sound routine to $0801 instead of $c100 but the problem is always that I cannot return to the scroller routine from the music routine.
@ The Phantom
I don't understand exactly what you mean. could you please write the full code in plain assembler so that I can write it to Hexmon? I use Hexmon to insert code in the c64.
@ Robo
Quote:
your code looks really strange to me, you must call the music player only once per frame.
I'm sorry for that, but like I said, I'm a newbie in the C=64 scene. Could you please write the full code in a manner that I could insert it in Hexmon? |
... 29 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 | 4 - Next |