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 > Lda $d012 And #$07 ora #18 sta $d011
2020-03-25 20:29
crl

Registered: Mar 2020
Posts: 19
Lda $d012 And #$07 ora #18 sta $d011

The title says it all. I learned this raster timing trick in 1988, but I never understood why and how it works.

I understand that we in step 1 take the current raster line and AND it by %00000111. In step 2, we OR by %00011000. And then, we store that in $d011.

But when I look at the specific bits in d011, I get confused.

In step 1, we shift the screen downwards by x lines, x being equal to $d012 and %00000111.

But why do we then turn bits 4 and 5 on in d011 in step 2?

Bit 5 = high resolution graphics on
Bit 4 = screen area is visible or not

Can someone explain this 32 years old mystery to me?
 
... 9 posts hidden. Click here to view all posts....
 
2020-03-26 06:21
crl

Registered: Mar 2020
Posts: 19
Mr. Sid, correct. Somewhere in the process, I confused 0-7 with 1-8.

I played a bit my code again, and it seems that bit 3 isn't important to the intended outcome, which in this case is to make some nicely timed rasterbars without badlines.

But what I still don't understand is why I need to keep setting bit 4 (enable screen) every rasterline in order to ensure timing.

Another question I would like to ask is why I get a chessboard pattern on top of my rasterbards when I do this.

I'm sorry if these are stupid questions but I haven't coded for 30 years :-)
2020-03-26 07:53
oziphantom

Registered: Oct 2014
Posts: 409
are you in default font? probably because you are messing with the bad lines and the VIC is getting char FF which is the checkerboard char in the default font. Change the last byte in the bank ($3fff probably for you at the moment) and see if the pattern changes.
2020-03-26 10:33
Rastah Bar

Registered: Oct 2012
Posts: 237
crl, have a look at the VIC-article:
VIC Article [english]

Sections 3.5-3.7 and 3.14 are particularly interesting for what you are doing.

It is not that you have to keep setting bit 4, but rather that you don't want to set it to 0.
2020-03-26 11:20
tlr

Registered: Sep 2003
Posts: 1402
In my earliest side border stuff I used things like this:
.C:464b  A0 2F       LDY #$2F
.C:464d  EE 16 D0    INC $D016
.C:4650  CE 16 D0    DEC $D016
.C:4653  AE 11 D0    LDX $D011
.C:4656  E8          INX
.C:4657  8A          TXA
.C:4658  29 07       AND #$07
.C:465a  09 00       ORA #$18
.C:465c  8D 11 D0    STA $D011
.C:465f  EA          NOP
.C:4660  EA          NOP
.C:4661  EA          NOP
.C:4662  EA          NOP
.C:4663  EA          NOP
.C:4664  24 FC       BIT $FC
.C:4666  88          DEY
.C:4667  10 E4       BPL $464D
.C:4669  A9 1B       LDA #$1B
.C:466b  8D 11 D0    STA $D011
Changing the ORA #$18 -> ORA #$00 makes no difference. I guess I just added it because you're "supposed" to set those bits.
2020-03-26 11:22
Krill

Registered: Apr 2002
Posts: 1539
Actually, doing INC $d011 once per rasterline is sufficient to avoid badlines in that scenario (with a proper initial value).
They are "shoved" to the next line continuously.
2020-03-26 11:36
tlr

Registered: Sep 2003
Posts: 1402
Quote: Actually, doing INC $d011 once per rasterline is sufficient to avoid badlines in that scenario (with a proper initial value).
They are "shoved" to the next line continuously.


Yes, or modify it to use the loop counter. I wasn't really looking for optimizations here I guess. I remember being quite content just making it work. :)
2020-03-26 11:47
Krill

Registered: Apr 2002
Posts: 1539
Quoting tlr
Yes, or modify it to use the loop counter. I wasn't really looking for optimizations here I guess. I remember being quite content just making it work. :)
Wasn't quite aiming at your old code but at OP's educational benefit. :)
2020-03-27 10:33
tlr

Registered: Sep 2003
Posts: 1402
Another approach is to just change Y-scroll when absolutely necessary to avoid a bad line. No need to change it every line.
2020-03-27 10:51
Krill

Registered: Apr 2002
Posts: 1539
Quoting tlr
Another approach is to just change Y-scroll when absolutely necessary to avoid a bad line. No need to change it every line.
Yes, or open the Y-border but actually clear DEN ($d011 bit 4). Screen remains on, but without any badlines at all! \=D/
2020-03-27 11:24
tlr

Registered: Sep 2003
Posts: 1402
Quote: Quoting tlr
Another approach is to just change Y-scroll when absolutely necessary to avoid a bad line. No need to change it every line.
Yes, or open the Y-border but actually clear DEN ($d011 bit 4). Screen remains on, but without any badlines at all! \=D/


Good point, forgot about that. Though then you are restricted to idle fetch and sprites only for the full screen.
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
Xidex/7-Inch
Remdy/Dentifrice
hedning/G★P
theK
Medicus
Perplex/Offence
MCM/ONSLAUGHT
Guests online: 78
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.6)
3 Coma Light 13  (9.6)
4 Memento Mori  (9.6)
5 Comaland 100%  (9.6)
6 Unboxed  (9.6)
7 Lunatico  (9.6)
8 The Shores of Reflec..  (9.6)
9 Remains  (9.5)
10 C=Bit 18  (9.5)
Top onefile Demos
1 Crystal Gazer  (9.5)
2 Dawnfall V1.1  (9.5)
3 Smile to the Sky  (9.5)
4 Daah, Those Acid Pil..  (9.5)
5 Rewind  (9.5)
6 Instinct  (9.4)
7 Tribute to Ben - Las..  (9.4)
8 In Memoriam BHF  (9.4)
9 Coro(l)na Nuthouse  (9.4)
10 Cuarentenauta  (9.4)
Top Groups
1 Booze Design  (9.4)
2 Censor Design  (9.4)
3 PriorArt  (9.4)
4 Oxyron  (9.3)
5 Triad  (9.2)
Top Original Suppliers
1 hedning  (9.8)
2 Derbyshire Ram  (9.5)
3 Baracuda  (9.5)
4 Irata  (9.3)
5 Fungus  (9.0)

Home - Disclaimer
Copyright © No Name 2001-2020
Page generated in: 0.038 sec.