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


Forums > C64 Coding > Open Sideborder on badline with sprites 4-7
2013-08-12 18:07
Six

Registered: Apr 2002
Posts: 224
Open Sideborder on badline with sprites 4-7

$d015 = #$f0

On the row just before the char row, I open the sideborder.
Next line is a badline with 4 sprites on it. I open the sideborder by dec $d016/inc $d016.

IMMEDIATELY after the dec/inc, I put another dec/inc. Problem is, it seems to fire too late. changing $d016 to $d021/$d020, I can see the second inc finalizes about 3 cycles into the border. I thought maybe it was because INC/DEC is RMW, so I switched to STA/STY, but that seems to fire one or two cycles too late.


Can anyone shed some light? It seems like I should have time to open the border here, I know it's been done.
2013-08-12 18:57
tlr

Registered: Sep 2003
Posts: 1168
sta <abs>,x/sty perhaps?
2013-08-12 19:43
Copyfault

Registered: Dec 2001
Posts: 238
Guess only 4-cycle-store commands will work.

I'll try to shed light by writing down the cycles of each relevant rasterline

rasline = 7 (the one before the badline)

to open sb, we need $d016-write exactly @cycle #56 of this line. This line is not a badline, so we have the time to do

DEC $D016 = 6 cycles (R1+R2+R3+R4+W1+W2)

The correct value is available only on last write cycle, thus

rasline-cycle#       51 52 53 54 55 56 57 58 59 60 61 62
opcode-cycle#        R1 R2 R3 R4 W1 W2 -  -  -  -  -  X


Now the INC $D016 will occupy rasline-cycles 57-62; mind that this only works as also INC $D016 is a RMW-command thus having a write cycle exactly @rasline-cycle #62, which is a "X"-cycles that only allows for write-cycles!

Now the badline begins as follows

rasline-cycle# 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14
"cpu-view"     X  X  4  S  5  S  6  S  7  S  -  X  X  X  = 

rasline-cycle# 15 16 ... 52 53 54 55 56 57 58 59 60 61 62
"cpu-view"     =  =  ... =  =  -  -  -  -  -  -  -  -  X


The next DEC $D016 again consists of R+R+R+R+W+W cycles. The first 'R' will processed @cycle #10 of the badline, the next 3 'R' cycles @rasline-cycles #54-56, the 'W'-cycles at 57 and 58 resp. This shows that the second 'W'-cycle does not meet cycle #56 (as needed for opening the sideborder) bit comes two cycles too late. Using a 4-cycle R+R+R+W-command gladly comes to the rescue here ;)


Maybe this helps a little.
2013-08-12 20:17
Perplex

Registered: Feb 2009
Posts: 209
The tip from tlr (sta abs,x) is indeed the way to go, since you have only 1 spare cycle between two writes:

ldx #$00
ldy #$C0
lda #$C8
...

sty $D016 : sta $D016
<waste 44 cycles>
sty $D016 : sta $D016,x ; Bad line right after this
sty $D016 : sta $D016
<waste 44 cycles>
sty $D016 : sta $D016
...
2013-08-12 20:38
Six

Registered: Apr 2002
Posts: 224
I'll try this. Thank you guys so much for the input, I understand something now about how the VIC and CPU interact that was escaping me before.
2013-08-13 01:02
Six

Registered: Apr 2002
Posts: 224
Followup, MASSIVE thank you to all of you who chimed in on this. I've got it working finally - going to be an interesting task making it work on both PAL and NTSC. Thanks to Copyfault, I now understand fully why it works that way, and tlr and Perplex for a working example. I fought with the timing on this for 3 days, never understanding just WHY it wouldn't work until today.
2013-08-13 10:49
Flavioweb

Registered: Nov 2011
Posts: 357
To make it work on all archs, you just need a code to detect on what arch is executed, then change some bytes of opcodes to use the right amount of cycles in the right place.
And if you use a "reverse counter" to stabilize irq, you need to adjust the countdown as well...
Another interting thing should be keep border open with your sprites moving from "before" to "after" the open border area...
=P
2013-11-28 09:14
theWizard
Account closed

Registered: Jul 2007
Posts: 109
if you put a sprite on a raster line at the correct timing it will open the border to the size of the sprite no need to use a bad line , that will solve your timing issue.. ( i done this years ago ) you can also do it by using d011 bit 3 but then you will have to time for sprites as they will cause undesired effects across the y of the raster.

also if you do it from 0 to f2 there will be no border at all and you could even pixel the sprites and have full screen with no border , you will have to make a simple plexor though.

it works on a real 64 dunno about vice or ccs.
2018-03-28 23:45
Scan

Registered: Dec 2015
Posts: 69
Quote: To make it work on all archs, you just need a code to detect on what arch is executed, then change some bytes of opcodes to use the right amount of cycles in the right place.
And if you use a "reverse counter" to stabilize irq, you need to adjust the countdown as well...
Another interting thing should be keep border open with your sprites moving from "before" to "after" the open border area...
=P


Maybe in future projects this might be helpful: Victimer
2018-03-28 23:48
Scan

Registered: Dec 2015
Posts: 69
Quoted wrong post, beer goggles :P
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
CA$H/TRiAD
The Dark Judge
Bieno/Commodore Plus
tonysavon
bugjam
Fred/Channel 4
Andy/AEG Soft
Core/(VPN)
Guests online: 36
Top Demos
1 Uncensored  (9.7)
2 Comaland 100%  (9.7)
3 Edge of Disgrace  (9.7)
4 Coma Light 13  (9.6)
5 The Shores of Reflec..  (9.6)
6 Wonderland XII  (9.6)
7 We Come in Peace  (9.6)
8 Lunatico  (9.6)
9 Incoherent Nightmare  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 Daah, Those Acid Pil..  (9.6)
2 Arok 20 Invitation  (9.5)
3 FMX Music Demo  (9.5)
4 Pandemoniac Part 2 o..  (9.5)
5 Dawnfall V1.1  (9.5)
6 Treu Love [reu]  (9.5)
7 Merry Xmas 2017  (9.4)
8 In Memoriam BHF  (9.4)
9 Dawnfall  (9.4)
10 Synthesis  (9.4)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.4)
5 Crest  (9.3)
Top Musicians
1 Rob Hubbard  (9.8)
2 LMan  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Drax  (9.5)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.083 sec.