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 > Raster X position.
2012-01-26 19:51
Flavioweb

Registered: Nov 2011
Posts: 463
Raster X position.

From VIC article:
Quote:

As the LP input of the VIC is connected to the keyboard matrix as are all
lines of the joystick ports, it can also be controlled by software. This is
done with bit 4 of port B of CIA A ($dc01/$dc03). This allows to determine
the current X position of the raster beam by triggering an LP edge and
reading from LPX afterwards (the VIC has no register that would allow
reading the X position directly). This can e.g. be used to synchronize
raster interrupt routines on exact cycles.


What means?
I can write some code to know exactly where raster is in his X position?
Something like: raster irq trigger -> irq routine -> wait for X raster position -> start do someting...

Is it possible?
There are some assembly examples somewhere?
 
... 20 posts hidden. Click here to view all posts....
 
2012-01-30 07:31
Copyfault

Registered: Dec 2001
Posts: 478
Let's fix the following 'polling1_done'-position in the pseudo code:

polling_loop
lda #ras_pos
cmp $d012
bne *-3
polling1_done
<opcode>

Asuming that we operate only on non-badline without sprites and that all IRQs are turned off it is clear that the opcode placed at _1st_line is read between raster cycle 3 to 11 depending on when raster line "ras_pos" was reached during the polling loop.

Having exactly 62 waiting cycles between each read access of the "cmp $d012"-commands ensures that in the next polling loop the read cycle will be exactly one cycle earlier:

polling2
lda #ras_pos+1
cmp $d012 ;read access between cycle#62@line"ras_pos" to cycle#7@line"ras_pos+1"
bne polling2_done
polling2_done
<opcode>

The "bne polling2_done" will only be taken if the read access of "cmp $d012" was still on line ras_pos. If so we have to waste one cycle to make sure to be on line ras_pos+1. Thus the opcode at "polling2_done" is read between cycle 3 to 10.

Continuing in this fashion you can eliminate one jitter cycle per polling. Take the time and keep track of the possbile raster cycle position for a fixed position in the polling loops to fully get the idea. Feel free to PM if smth remains unclear.
Previous - 1 | 2 | 3 - 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
fieserWolF/Abyss-Con..
kbs/Pht/Lxt
iAN CooG/HVSC
Alakran_64
MWR/Visdom
t0m3000/hf^boom!^ibx
Andy/AEG
Freeze/Blazon
aNdy/AL/Cosine
Guests online: 93
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 Censor Design  (9.3)
5 Triad  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

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