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 > Sprite multiplexer
2009-06-12 19:21
Axel
Account closed

Registered: Apr 2006
Posts: 42
Sprite multiplexer

I am trying to do simple multiplexer using "Zone split" technique. Something like this:
      1 2
      1 2
      1 2
      ...

I found in codebase that: "The Y-coordinate for a sprite must have been set before the raster line reaches that Y-position, or the re-used sprite won't display at all" What does it mean?
I wrote this piece of code:
	     
lda $d001		
clc			
adc #21			
sta $d001
sta $d003
ldx spriteindex
lda frametable,x	
sta $07f8		
lda frametable+1,x	
sta $07f9               
txa			
clc			
adc #2
sta spriteindex

How exacly can I get it to work?


2009-06-12 19:31
Oswald

Registered: Apr 2002
Posts: 5094
you have to set Y pos before the electron beam stops drawing the current sprite(s) and after it have started drawing them. its about timing.
2009-06-12 19:46
Axel
Account closed

Registered: Apr 2006
Posts: 42
Ok, but how achieve this timing,
How to code this? Could you give me some example?
2009-06-12 20:34
Oswald

Registered: Apr 2002
Posts: 5094
this is what raster interrupts are for. you can make the cpu to execute a piece of code each frame, tied to a designated raster line. more at codebase ;)
2009-06-12 22:33
Axel
Account closed

Registered: Apr 2006
Posts: 42
I tried to change $d012 register in raster routine but it doesn't work. How to update raster line where this routine is triggered?
Stable raster is needed?
2009-06-13 03:52
Oswald

Registered: Apr 2002
Posts: 5094
if you want to do different changes on different lines each frame, then you should do it like this:


irq1 do shit

lda #irq2$d012val
sta $d012
lda #<irq2
sta $fffe ;(assuming we have turned kernal rom off)
lda #>irq2
sta $ffff
rti

irq2 do shit

lda #irq1$d012val
sta $d012
lda #<irq1
sta $fffe
lda #>irq1
sta $ffff
rti

irq1 will always be triggered at raster line #irq1$d012val, irq2 similarly. I think you should start with some colored rasterlines at various positions (=more visual feedback&helps to learn some basic timing), and if you can get that right move on to sprites.

stable raster is NOT needed.
2009-06-13 05:11
Graham
Account closed

Registered: Dec 2002
Posts: 990
you forgot DEC $D019 :)
2009-06-13 05:24
Oswald

Registered: Apr 2002
Posts: 5094
thats in "doshit" :)
2009-06-13 08:12
Oswald

Registered: Apr 2002
Posts: 5094

2009-06-13 13:52
Axel
Account closed

Registered: Apr 2006
Posts: 42
Thanks for explaination.
So if I want to reuse sprite1 and sprite2 for example 10 times, I need 10 raster interrupts ?
2009-06-13 18:38
Oswald

Registered: Apr 2002
Posts: 5094
you dont get the basic concept of this. the electron beam draws the screen on a real CRT (non lcd/tft displays) left to right top to bottom. The c64s video chip reads and sends data in synch with this to display the picture. if the video chip finds that the vertical raster position ($d012 upon read gives you that, upon write it sets raster interrupt line) is the same as one of the sprites' Y coord then it starts to display the given sprite. this mechanism makes it possible to multiplex sprites. after the rasterbeam&vic started drawing a sprite during one screen scan, with correct timing you may set a new Y pos further down, and when the electron beam matches this position again, the sprite will be redisplayed since sprite Ycoord will match vertical raster position again. thus if you want to display a sprite X times you have to do this 'trick' x times.

so dont think of the c64's video display as something static, its being drawn left to right top to bottom 50 times each second, and by manipulating VIC registers timed correctly to this behaviour you may create rasterlines, rastersplits, sprite multiplexing, etc.
 
... 7 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
Advanced
Users Online
Mike
Alakran_64
Darkflight
MWR/Visdom
tokra/Akronyme Analo..
Acidchild/Padua
Peacemaker/CENSOR/Hi..
bexxx
Slajerek/Samar
Guests online: 117
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 Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 hedning  (9.7)
4 Irata  (9.7)
5 Tim  (9.7)

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