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 > wonder for delay routine
2010-05-03 10:26
Dr.j

Registered: Feb 2003
Posts: 277
wonder for delay routine

i use this delay routine.

when i replace BPL command to BNE command it don't
work properly. i trying to figure why and i really don't know. i guess it may brake the Stack order and then
don't get back from the place i called this JSR.

bigdelay:
txa
pha
tya
pha
ldx #$ff
r1:ldy #$ff
!: dey
bpl !-
dex
bpl r1
pla
tay
pla
tax
rts



 
... 10 posts hidden. Click here to view all posts....
 
2010-05-03 15:04
Skate

Registered: Jul 2003
Posts: 494
even if we didn't get the actual problem, I think The Dr.j already diagnosed the problem himself. it's stack related and self modifying code should be the solution without changing his method. replace these "txa pha tya pha ... pla tay pla tax" with "sta sta ... lda lda" and it's solved.
2010-05-03 15:05
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
i fucked up my code. that code wont work as intended, and now i look like a fool :D
2010-05-03 15:08
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Quote: even if we didn't get the actual problem, I think The Dr.j already diagnosed the problem himself. it's stack related and self modifying code should be the solution without changing his method. replace these "txa pha tya pha ... pla tay pla tax" with "sta sta ... lda lda" and it's solved.

he just forgot to do a pha FIRST and a PLA last, thats the only bug.. :D
2010-05-03 15:29
Skate

Registered: Jul 2003
Posts: 494
@Jan Harries: Martin Piper already mentioned that and I'm not sure if it is the only problem.

Thing is, if you are not trying to optimize by code length, always use self modifying code. Only exception can be branched irq structures (which is usually a rare case for my coding style). Correct me if I'm wrong.
2010-05-05 07:34
Devia

Registered: Oct 2004
Posts: 401
Quoting Skate
Thing is, if you are not trying to optimize by code length, always use self modifying code. Only exception can be branched irq structures (which is usually a rare case for my coding style). Correct me if I'm wrong.

Do you mean nested IRQs? - If so, then storing the regs along with the opcodes that loads them at their correct places will make nesting IRQs work like a charm.
If you indeed mean "branched" IRQ structures, I have no idea what you are referring to ;-)
2010-05-05 10:08
Skate

Registered: Jul 2003
Posts: 494
I mean when an irq starts at some point but ends conditionally in different points without sharing the same irq exit routine. I always prefer using the same irq exit routine but this can be needed when you don't have enough cycles for even a single JMP opcode. That's a rare but possible case.
2010-05-05 10:44
Oswald

Registered: Apr 2002
Posts: 5094
more usual case: effect is running at a fixed frame rate, and what's left for the 'main program' can be used for loading:


irq:

pha
txa
pha
tya
pha

...

lda running
bne itsrunning

inc running
cli <-- if effect runs for many frames more of this irq still may occur
jsr effect
dec running

itsrunning

...

pla
tay
pla
tax
pla
rti
2010-05-05 15:49
Skate

Registered: Jul 2003
Posts: 494
of course there is still a chance to store a,x,y at zeropage (or any other available memory location) but stack is fine too :)
Previous - 1 | 2 - 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
Peacemaker/CENSOR/Hi..
Fungus/Nostalgia
WVL/Xenon
t0m3000/hf^boom!^ibx
Matt
marley
ged/Samar
rexbeng
Technotron/I-I F
Guests online: 114
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.171 sec.