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

Registered: Mar 2020
Posts: 10
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?
2020-03-25 20:42

Registered: Apr 2002
Posts: 1404
The value only becomes effective with the actual sta $d011.

Bits 4 and 5 need to be set (and bit 6 clear in your case), well, because those control the display mode.
You may change them mid-screen, but the result might not be what you want.

And what you want appears to be display on (bit 4) and bitmap mode enabled (bit 5) and ECM off (bit 6).
You can use other combinations for different screen modes, some of them invalid (black pixels).

Actually i'm not quite sure where your confusion lies.
2020-03-25 20:50

Registered: Mar 2020
Posts: 10
Ok, so the part that allows me to do raster splits is part 1, i.e. skipping bad linea?
2020-03-25 20:52

Registered: Dec 2001
Posts: 275
Hmm, looks like setting up a badline condition for the current rasterline. Assuming this "trick" is repeated (in some kind of loop with fixed timing), it should make up FLI = flexible line interpretation.

Short explanation (as addon to Krill's lines;)): a badline is created whenever the lower 3 bits of $D011 match with the lower three bits of $D012 (=current rasline). So your opcodes basically "cut out" the lower bits of $D012, set up some other bits relevant for the gfx mode you want to display (see Krill's post above) and write this to $D011 to "force" the badline condition.

Maybe it was used for smth else, but I strongly guess this was a FLI-routine.
2020-03-25 20:53

Registered: Mar 2020
Posts: 10
I used this when I did raster splits, meaning that it did occur in a loop
2020-03-25 20:54

Registered: Apr 2002
Posts: 1404
Sort of. You prevent a bad line condition, effectively turning them off.
However, the bad line condition is precisely that the low 3 bits of $d012 (current rasterline) and $d011 (YSCROLL) match.

So for this to be stable (and not depend on the beam's position within the current rasterline), better add 1 or so before the AND.
2020-03-25 21:01

Registered: Dec 2001
Posts: 275
Yes;) Wanted to wait for the reply of crl to add this: depending on the timing this "trick" could also be used to _avoid_ badlines: if you made sure that the STA $D011 happens not before the rasterline in which the LDA $D011 was executed, you'd make sure that the rasterline in which the STA $D011 is executed is not a badline. Putting this in a loop makes the VIC continously avoiding a badline.

As always in c64 coding, it all depends on the timing;)
2020-03-25 21:02

Registered: Mar 2020
Posts: 10
Interesting. Thanks for explaining
2020-03-25 23:19

Registered: Jan 2003
Posts: 371
And btw, it's bit 3 and bit 4 that are turned on when or-ing with $18. Which are:

Bit 4 = enable screen
Bit 3 = 25 rows

Those are pretty essential, in most cases, so it's a good idea to have them set... :)
2020-03-25 23:32

Registered: Apr 2002
Posts: 1404
Hah, good catch.

But both bits don't mean much until you get close to the lower border and then vertical blank.

Meaning if you set them only some way down the screen, no problem. :)
2020-03-26 06:21

Registered: Mar 2020
Posts: 10
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 :-)
... 9 posts hidden. Click here to view all posts....
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
Users Online
Black Beard/Abyss, A..
Guests online: 52
Top Demos
1 Uncensored  (9.7)
2 Coma Light 13  (9.7)
3 Edge of Disgrace  (9.7)
4 Comaland 100%  (9.6)
5 Unboxed  (9.6)
6 The Shores of Reflec..  (9.6)
7 Remains  (9.5)
8 Lunatico  (9.5)
9 We Come in Peace  (9.5)
10 C=Bit 18  (9.5)
Top onefile Demos
1 Dawnfall V1.1  (9.6)
2 Crystal Gazer  (9.6)
3 Space Demo  (9.5)
4 Field Sort  (9.5)
5 Instinct  (9.5)
6 The Tuneful Eight [u..  (9.5)
7 Smile to the Sky  (9.5)
8 Rewind  (9.5)
9 Onef1ler  (9.5)
10 Bad Boy  (9.5)
Top Groups
1 Performers  (9.6)
2 Oxyron  (9.4)
3 PriorArt  (9.4)
4 Booze Design  (9.4)
5 Censor Design  (9.4)
Top Diskmag Editors
1 hedning  (9.8)
2 Jazzcat  (9.5)
3 Newscopy  (9.4)
4 Remix  (9.2)
5 A Life in Hell  (9.1)

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