You are not logged in -
nap
CSDb User Forums
Forums
>
C64 Coding
>
problems w. opening sidebordes+sprites
2011-08-30
22:02
Norrland
Registered: Aug 2011
Posts: 14
problems w. opening sidebordes+sprites
Hi there! First post here, but bare with me, I'm gonna spam you with some questions on semi-newbie level for a while..
I'll start with my problems with opening the sideborder. I'm showing a bitmap picture and the plan is to have 4 sprites in the sideborder, in the middle of the screen, all on the same y-pos. I have managed to make a stable irqroutine and have set $d015 to #$f0 to enable sprites 4-7 (sprites in order, the ones with lowest prio). I've also made sure that sprites 0-3 have totally different y-pos than sprites 4-7.
Later down the screen, at the same position as the sprites, I open the border with dec/inc $d016 (cycle 56), and everything goes well for the normal lines, but on bad lines I'll be 3 cycles late (if I've understood everything right) even though I do dec/inc $d016 right after the last lines dec/inc.
I've tried to follow Christian Bauers (+codebase, c-hacking, posts here and others) texts about the vic, rastertiming and opening borders, but I don't understand what I do wrong. In my code I'll do 20 nops between the dec/inc, which in my head equals to 52 cycles including dec/inc, and if that is right, suggests that the vic uses 11 cycles (63-52=11) (2/sprite and 3 for BA signal??) for fetching spritedata for 4 sprites on non-badlines.
If my calculations are right, I don't understand why I have problems on badlines, were I should have 23 cycles(?). Even if I skip one sprite, I'm still one cycle late, and I've read that 4 sprites should be possible..
The code inside irq, and screenshot showing my timing:
dec $d021 ;row1
inc $d021
.byte $ea, $ea, $ea, $ea, $ea, $ea, $ea ;20 st (40 cycles)
.byte $ea, $ea, $ea, $ea, $ea, $ea, $ea
.byte $ea, $ea, $ea, $ea, $ea, $ea
dec $d021 ;row2 6 cycles
inc $d021 ; 6 cycles,tot 52
.byte $ea, $ea, $ea, $ea, $ea, $ea, $ea ;20 st (40 cycles)
.byte $ea, $ea, $ea, $ea, $ea, $ea, $ea
.byte $ea, $ea, $ea, $ea, $ea, $ea
dec $d021 ;row3 6 cycles
inc $d021 ; 6 cycles,tot 52
dec $d020 ;row 4 BADLINE hell breaks loose... (nåja)
inc $d020
http://i1120.photobucket.com/albums/l491/lordborak/kastabort.png
Is my understanding right? Do I need to consider/setup anything else than described above?
... 25 posts hidden. Click
here
to view all posts....
2011-09-01
21:25
Slammer
Registered: Feb 2004
Posts: 416
:pause #$2c
(From codebase, a bit down on the page)
Just put in your own optimizations.
2011-09-02
04:57
Oswald
Registered: Apr 2002
Posts: 5094
Quote:
plus you need to set $10 which will set you back 4 bytes ;-)
Trust me I gave it some thought^^
yeah, thats why you destroy A, plus $10 doesnt needs to be set each time, so in the long run it uses less mem anyway :)
2011-09-02
05:43
Martin Piper
Registered: Nov 2007
Posts: 722
I've often thought some kind of external tool that generates ASM would be good here. You tell the tool what registers/memory you want set to what value and the raster and cycle it should be set on. Then it figures out the necessary most optimal timed code including bad lines, sprite DMAs etc.
2011-09-02
06:23
Perplex
Registered: Feb 2009
Posts: 255
If you write a tool in some high level language to generate the timed code for you, better make it waste cycles in between the timing critical instructions by interleaving it with other useful code instead of just nops and the like.
2011-09-02
06:37
JackAsser
Registered: Jun 2002
Posts: 2014
Quote:
If you write a tool in some high level language to generate the timed code for you, better make it waste cycles in between the timing critical instructions by interleaving it with other useful code instead of just nops and the like.
That is exactly what the code multiplexer in
S:T Lars Meeting III - Invite
does. It has two code snippets, one that updates the 4x4-effect using A,X and Y registers. And one that opens the border. The multiplexer then replaces all NOPs in the timing critical code with the code from the 4x4-updater, keeping track of A,X and Y usage etc.
2011-09-02
11:47
TWW
Registered: Jul 2009
Posts: 545
Quote:
yeah, thats why you destroy A, plus $10 doesnt needs to be set each time, so in the long run it uses less mem anyway :)
A was 8 upon entry and is 8 upon exit.
lda #$08 <----- see, 8!
ldy #$00
OPEN DA BOOORDEEEERRZZZZZZZ!!!!!
Still 8 here!
You however, destroy X and add bytes ;-)
Come to think of it, one could probably use X as a counter to shorten this even further...
<-entrypoint (X set with badline offset $02 set with quantities of linesX8)
!: jsr delayXX
sta $d016
sty $d016
dex
bne !-
jsr delayXX-1
sta $d016
sty $d016
sta $d016,x
sty $d016
ldx #$07
jsr delayZZ
dec $02
bne !-+3
rts
Then again this is straig out of my ass^^
2011-09-02
12:59
Oswald
Registered: Apr 2002
Posts: 5094
cool, then I win by simply modifying my code to:
$10=6
delay44
3 ldx $10
2 dex ;
3 bne *-3 ;x5=25 cycles +when exits 4 cycles -> 29
6 rts
x needs to be 0, and my x wil be 0 :)
edit: you also need to be on a pagebreak, which is not a nice thing either :)
2011-09-02
13:50
Frantic
Registered: Mar 2003
Posts: 1648
Quote:
cool, then I win by simply modifying my code to:
$10=6
delay44
3 ldx $10
2 dex ;
3 bne *-3 ;x5=25 cycles +when exits 4 cycles -> 29
6 rts
x needs to be 0, and my x wil be 0 :)
edit: you also need to be on a pagebreak, which is not a nice thing either :)
...but is it stylish?
2011-09-02
15:36
Oswald
Registered: Apr 2002
Posts: 5094
it does achive what it was intended to: do it in less bytes. changing the goal later, isn't that unfair ? :)
2011-09-02
17:10
TWW
Registered: Jul 2009
Posts: 545
Quote:
cool, then I win by simply modifying my code to:
$10=6
delay44
3 ldx $10
2 dex ;
3 bne *-3 ;x5=25 cycles +when exits 4 cycles -> 29
6 rts
x needs to be 0, and my x wil be 0 :)
edit: you also need to be on a pagebreak, which is not a nice thing either :)
Fair enough. Pagebreak isn't cool, but a still somewhat if someone rips your code and don't think about it (hehe).
You still need to do: sta/y/x $10 "somewhere" to ensure $10 = 6. Thus adding 2 bytes (maybee 2 more unless you have a state of 6 in one of your regs) and yielding a total consumption of 8 bytes vs. my 7 bytes.
I guess you would use 3 cycles more overall due to the sta/sty/stx $10 aswell ;-D
Previous
-
1
|
2
|
3
| 4 - Next
Refresh
Subscribe to this thread:
You need to be logged in to post in the forum.
Search the forum:
Search
All forums
C64 Coding
C64 Composing
C64 Pixeling
C64 Productions
CSDb Bug Reports
CSDb Development
CSDb Discussions
CSDb Entries
CSDb Feedback
CSDb Info
CSDb moderators
CSDb Questions
Messages to moderators
Requests
for
in
Writer & text
Text
Writer
All times are CET.
Search CSDb
All
Releases
Groups
Sceners
Events
BBS
SIDs
-------
Forum
Comments
Advanced
Users Online
Scrap/Genesis Project
Majikeyric
Sulevi/Virtual Dreams
Guests online: 102
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
Triad
(9.3)
5
Censor Design
(9.3)
Top Original Suppliers
1
Derbyshire Ram
(9.7)
2
Fungus
(9.3)
3
Black Beard
(9.2)
4
Baracuda
(9.2)
5
hedning
(9.1)
Home
-
Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.049 sec.