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 > 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?
2011-08-30 23:17
TWW

Registered: Jul 2009
Posts: 541
sty $d016
sta $d016,x
sty $d016
sta $d016

Just those few cycles less you need i recon :-)
2011-08-31 06:21
Mr. SID

Registered: Jan 2003
Posts: 421
What TWW said.
Also a little tip for timing. Put this in your code somewhere:

delay64:	nop
delay62:	nop
delay60:	nop
delay58:	nop
delay56:	nop
delay54:	nop
delay52:	nop
delay50:	nop
delay48:	nop
delay46:	nop
delay44:	nop
delay42:	nop
delay40:	nop
delay38:	nop
delay36:	nop
delay34:	nop
delay32:	nop			
delay30:	nop
delay28:	nop
delay26:	nop
delay24:	nop
delay22:	nop
delay20:	nop
delay18:	nop
delay16:	nop
delay14:	nop
delay12:	rts


delay63:	nop
delay61:	nop
delay59:	nop
delay57:	nop
delay55:	nop
delay53:	nop
delay51:	nop
delay49:	nop
delay47:	nop
delay45:	nop
delay43:	nop
delay41:	nop
delay39:	nop
delay37:	nop
delay35:	nop			
delay33:	nop
delay31:	nop
delay29:	nop
delay27:	nop
delay25:	nop
delay23:	nop
delay21:	nop
delay19:	nop
delay17:	nop
delay15:	.byte $04, $00	; NOOP $00 = 3 cycles
		rts


Then just do a jsr delay40 in your code instead of putting 20 nops into it. That way you'll make sure that changing your timing delays is not going to push your code around. Otherwise a branch might end up crossing a page border and you'll lose a cycle somewhere which usually takes a long time to find.
2011-08-31 08:01
MagerValp

Registered: Dec 2001
Posts: 1059
Quoting Mr. SID
Otherwise a branch might end up crossing a page border and you'll lose a cycle somewhere which usually takes a long time to find.


.assert >* = >delay, error, "delay loop crosses page boundary"

Though I wish ca65 had the ability to warn on branches across a page boundary.
2011-08-31 12:50
TWW

Registered: Jul 2009
Posts: 541
OR you could be cool and use Kickass and the following Pseudo-Commands (Unless RAM is hurting):

irq2:
    :IRQ_LeadIn #1
    ldx #$07
    dex
    bne *-1

    bit $ffff
    nop
    ldx #$00
d16:
    ldy #$00
    :SET_GRAPHICS_BANKS($4400,$5800)
    lda #$1b
    sta $d011
    
    lda #$0f

    sty x
    sta x,x  //32
    sty x
    sta x    //33
    :timer1  //34
    :timer1  //35
    :timer1  //36
    :timer1  //37
    :timer1  //38
    :timer1  //39
    :timer2  //3a & 3b
    :timer1  //3c
    :timer1  //3d
    :timer1  //3e
    :timer1  //3f
    :timer1  //40
    :timer1  //41
    :timer2  //42 & 43
    :timer1  //44
    :timer1  //45
    :timer1  //46
    ldx #106+21
    stx $d009
    stx $d00b
    stx $d00d
    stx $d00f
    ldx #$41
    stx $47fc
    ldx #$45
    stx $47fd
    ldx #$50
    stx $47fe
    ldx #$50
    stx $47ff
    ldx #$00    
    sty x
    sta x
    :timer1
    :timer1
    :timer2
    :timer1
    :timer1
    :timer1
    :timer1
    :timer1
    :timer1
    :timer2
    :timer1
    :timer1
    :timer1
    :timer1
    :timer1
    :timer1
    :timer2
    ldx #106+42
    stx $d009
    stx $d00b
    stx $d00d
    stx $d00f
    ldx #$42
    stx $47fc
    ldx #$46
    stx $47fd
    ldx #$50
    stx $47fe
    ldx #$50
    stx $47ff
    ldx #$00    
    sty x
    sta x
    :timer1
    :timer1
    :timer1
    :timer1
    :timer1



.pseudocommand timer1 {

    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    
    sty x
    sta x
}
.pseudocommand timer2 {
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    bit $ffff
    sty x
    sta x,x
    sty x
    sta x

}


This should open 6 chars with sprites with the initial raster triggering before the 1st badline (adjust timing as necessary!) Here you also can cotrol $d016 HW scrolling aswell.

Cheers. Buy me a beer anytime!
2011-08-31 13:28
Mr. SID

Registered: Jan 2003
Posts: 421
I think this is cooler:
#pybegin
badline_offset = 2
for i in range(16):
    if i%8 == badline_offset:
        # bad line
        print "sta $d016,y"
    else:
        print "jsr delay44"
        print "sta $d016"
    print "stx $d016"
#pyend

:)
2011-08-31 14:22
JackAsser

Registered: Jun 2002
Posts: 1989
Using 3 bytes to waste 4 cycles is just wrong, when you can use 2 bytes to waste 7 cycles. :) (bit $ffff, vs pha+pla)
2011-08-31 15:05
Frantic

Registered: Mar 2003
Posts: 1628
Yes, it is important to waste cycles with style.
2011-08-31 16:14
TWW

Registered: Jul 2009
Posts: 541
Alright, then this is the coolest :-)


    :open_border (2,16)

.macro open_border(badline_offset,total_lines) {
  .for (i=0;i<total_lines;i++) {
    jsr delay44
    .if i&7 == badline_offset:
      stx $d016
      sta $d016,y
    }
    stx $d016
    sta $d016
  }
}

Delay44:
    .for (i=0;i<4;i++) { pha pla }
    nop
    nop
    rts


+ it wastes cycles with style^^

ps. Untested and might be bugged!
2011-08-31 16:17
Mr. SID

Registered: Jan 2003
Posts: 421
Now we're getting somewhere... ;)
2011-08-31 19:44
TWW

Registered: Jul 2009
Posts: 541
Minor Bugfix 8-D

.var i = 0

    :open_border(2,16)

.macro open_border(badline_offset,total_lines) {
  .for (i=0;i<total_lines;i++) {
    jsr Delay44
    stx $d016
    .if([i&7] == badline_offset) {
      sta $d016,y
      stx $d016
    }
    sta $d016
  }
}

Delay44:
    .for (i=0;i<4;i++) { pha pla }
    nop
    nop
    rts


Looks ok when compiled. Not done any real test though so might need some cycle adjustment if my math is off.
 
... 25 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
Mike
DeMOSic/HF^MS^BCC^LSD
Unlock/Padua/Albion
Higgie/Kraze/Onslaught
Guests online: 91
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Fullscreen Graphicians
1 Carrion  (9.8)
2 Joe  (9.8)
3 Duce  (9.8)
4 Mirage  (9.7)
5 Facet  (9.7)

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