Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > help needed for simple demo
2014-09-29 07:46
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?
2014-09-29 08:18
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
2014-09-29 08:48
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.
2014-09-29 09:01
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?
2014-09-29 10:30
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.
2014-09-29 12:13
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.
2014-09-29 12:53
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
2014-09-29 12:55
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?
2014-09-29 13:01
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.
2014-09-29 15:21
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
2014-09-29 15:58
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
hedning/G★P
iAN CooG/HVSC
Trap/Bonzai
MCM/ONSLAUGHT
pcollins/Quantum
radius75
ptoing
Røly/Mayday!
LightSide
rambo/Therapy/ Resou..
Scooby/G★P/Light
Beast/Crescent
Guests online: 223
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.6)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Sprite Bukkake 2  (9.6)
9 Uncensored  (9.6)
10 Comaland 100%  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 Morph  (9.5)
7 Dawnfall V1.1  (9.5)
8 Libertongo  (9.5)
9 Katzen-Video.mp4  (9.5)
10 Onscreen 5k  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Fairlight  (9.3)
5 Triad  (9.3)
Top Logo Graphicians
1 t0m3000  (10)
2 Sander  (9.8)
3 Mermaid  (9.5)
4 Shine  (9.4)
5 Pal  (9.4)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.042 sec.