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 > C64 32 Sprites 8x4 and Gaps
2016-10-16 21:36
Account closed

Registered: May 2002
Posts: 20
C64 32 Sprites 8x4 and Gaps

I have an ASM program that is trying to display 32 Sprites. I get all 32 on the screen as long as there is a 2px width gap between them. They are laid out in a grid (see below) so each line group has the same xpos (set once)

The moment I either make the raster happen earlier (corrupts the sprite) if not I get a horizontal gap between each grouping.

Fussing with the rasterline and Ypos of the sprites is not working.. is this possible?


Numbers are sprites slots, Letters are sprite bitmaps in non-stretched mode (21px tall). I have also turned off the top/bottom borders.


Raster IRQ fires at:

0         : turn off upper border
          : Set Sprites 0-7 (No Stretch, Enable, X-pos)
          : Update RasterIRQ Line to LogoIRQLine1
10        : Set Sprites 0-7 y-position (RasterLine+2)
          : Set Sprites 0-7 bitmaps (AA,AB,AC,AD...)
          : Update RasterIRQ Line to LogoIRQLine1
10+(21*1) : Set Sprites 0-7 y-position (RasterLine+2)
          : Set Sprites 0-7 bitmaps (AJ,AK,AL,AM...)
          : Update RasterIRQ Line to LogoIRQLine2
10+(21*2) : Set Sprites 0-7 y-position (RasterLine+2)
          : Set Sprites 0-7 bitmaps (BA,BB,BC,BD...)
          : Update RasterIRQ Line to LogoIRQLine3
10+(21*3) : Set Sprites 0-7 y-position (RasterLine+2)
          : Set Sprites 0-7 bitmaps (BJ,BK,BL,BM...)
          : Update RasterIRQ Line to BorderBottomIRQ
250       : turn off lower border
          : Update RasterIRQ to the BorderTopIRQ
... 11 posts hidden. Click here to view all posts....
2016-10-18 21:23

Registered: May 2002
Posts: 687
Using the duplicated two line or so sprite definition method would ease things a bit (mentioned elsewhere in this thread)
2016-10-18 21:32

Registered: Apr 2002
Posts: 4233
digger, you can switch to a totally different multiplex irq for the hard case, which does the 8 spr write on a badline, then have another irq for 8 sprite switch but no badline, etc.

cleaner and faster than selfmod jsr.
2016-10-19 05:56

Registered: Aug 2004
Posts: 786
Two large objects moving freely? Don't think I'd even try to attempt a cycle tuned routine for that one.

Set up first row for each object before the frame starts, then interrupts at y0+16, y0+32, y0+48, y0+64, and similar for y1. (need to sort these, obviously)

Each interrupt updates four sprites, increasing Y by 21, increasing the pointer address to the next row of definitions. Five rows of definitions are needed for each object.

Don't forget to check if the time for the next IRQ has already passed before setting $d012 and exiting, you'll have to fall through to the routine for the other object whenever the Y values are close to each other modulo 16.

It costs an extra 512 bytes of sprite definitions, but this way you've five lines (less sprite DMA and a badline) in which to update eight sprites; should be more than enough.
2016-10-19 20:06

Registered: Mar 2005
Posts: 274
Some great ideas there, thanks everyone!

@ChristopherJam: I am slowly beginning to understand your idea :) What do you mean by sprite definitions? A lookup table with sprite pointers that can be copied to $03fx?
I could probably use the sprite overlap method too, and shorten sprites to 20 or 19 rows.

I guess I will start experimenting and see how this goes :)
2016-10-20 07:56

Registered: Aug 2011
Posts: 28
You can also exchange some data between the lower lines (where you would get a badline) with the sprite below, then you can change sprite index at some other time than where the sprite ends. If you want a blanket of sprites this would be preferrable - remember that sprite index values can be changed at any time (i.e. each 16 lines, and top sprite being at -4 of first visible line) - that way you never get a sprite index change at badline :-)
2016-10-20 08:22

Registered: Apr 2002
Posts: 4233
what if sprite Y-s are shifted by 1 so 8 sprite is never aligned on the same line.



so bd sprites are lower 1 line than ac.
2016-10-20 09:46

Registered: Aug 2004
Posts: 786
@Digger By sprite definitions I just meant the images; I was still talking overlap method. I should probably draw a diagram, or bring code.

@Oswald good point about offsetting. Could even keep y values the same but offset the sprite-pointer change...
2016-12-12 00:48
Account closed

Registered: May 2002
Posts: 20
It's been a while.. Groepaz was right -- my pattern was hiding some errors. The lower line of each sprite was being copied over... I've been beating my head with the keyboard -- so i've given in and decided to post.

It seems I can get 4x4 working without any issues, the moment I move to 4x5 an higher I start getting over lap issues. So two things happen, either I loose the first sprite in even lines or I get to a point where NOP's can't fudge it anymore.

I used Bitbreakers idea for the sprite pointers, which is helping (I spent a while reading about SAX, cool)

I tried to create a really stripped down Multiple IRQ version, I even dropped pushing things to stack and dumping kernal, to see if I could squeeze things out.

But I can't seem to get past this; it must be a mistake in my concept of how to implement this... So here is an example of my sprite / raster irq:

Interupt Setup:

	lda #$7f
	sta $dc0d
	sta $dd0d
	and $d011 //clear most sign bit vic's raster register
	sta $d011
	lda #0	   //Raster line set
	sta $d012  

	lda #<IRQ_UpperBorder
	sta $fffe
	lda #>IRQ_UpperBorder
	sta $ffff
	lda #%00000001
	sta $d01a
	lda #$35 //Kill Kernal
	sta $01


//	inc $d021

	lda ScreenControlRegister
	ora #%00001000
	sta ScreenControlRegister

	.for (var i = SpriteCount; i >= 0; i--) 
		lda #WHITE
		sta sprites.colors + i

	lda #BLUE
	sta sprites.color1
	sta sprites.color2

	lda #SpriteEnable
	sta sprites.enable_bits

	//All rightside sprites with x>255 need this set
	lda #%00000000
	sta sprites.position_x_high_bits
	sta sprites.horizontal_stretch_bits
	sta sprites.vertical_stretch_bits

	// Set Horizontal Positions for Logo Sprites (set once)
	.for (var i = SpriteCount; i >= 0; i--) 
		ldx #(BorderWidth)+24*i
		stx sprites.positions + 2 * i + 0

	lda #LogoStartY-1	//Raster line set
	sta $d012	

	lda #<IRQ_Logo1
	sta $fffe
	lda #>IRQ_Logo1
	sta $ffff	

	asl $d019 // Ack the VIC INT



        //inc $d021
       // About 15 NOPS here

	lda #(SpriteBank+8+1)
	ldx #254
	sax sprites.pointers+0    //00
	sta sprites.pointers+1    //01
	lda #(SpriteBank+8+3)
	sax sprites.pointers+2    //02
	sta sprites.pointers+3    //03
	lda #(SpriteBank+8+5)
	sax sprites.pointers+4    //04
	sta sprites.pointers+5    //05
	lda #(SpriteBank+8+7)
	sax sprites.pointers+6    //06
	sta sprites.pointers+7    //07

	lda #LogoStartY
	.for (var i = SpriteCount; i >= 0; i--) 
		sta sprites.positions + 2 * i + 1

	lda #LogoStartY + (SpriteHeight * 1)-1	//Raster line set
	sta $d012	
	lda #<IRQ_Logo2
	sta $fffe
	lda #>IRQ_Logo2
	sta $ffff	

	asl $d019 //	Ack the VIC INT

... next Logo2, 3,4 then the bottom border open irq..
2016-12-16 04:29
Account closed

Registered: May 2002
Posts: 20
Ok, so setting the y coordinates before the pointers actually works better.

I got it working, I'll post my example, when its closer to 100%
2016-12-16 06:35

Registered: Apr 2002
Posts: 4233
you can set Y coord anywhere BEFORE your sprites start. even during the display of the previous sprite row.
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
Users Online
Perff/No Name
icon/The Silents, Sp..
Guests online: 31
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Comaland 100%  (9.6)
6 We Come in Peace  (9.6)
7 Lunatico  (9.6)
8 Incoherent Nightmare  (9.5)
9 Wonderland XII  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 FMX Music Demo  (9.5)
2 Pandemoniac Part 2 o..  (9.5)
3 Daah, Those Acid Pil..  (9.5)
4 Dawnfall V1.1  (9.5)
5 Treu Love [reu]  (9.5)
6 In Memoriam BHF  (9.5)
7 Merry Xmas 2017  (9.4)
8 Dawnfall  (9.4)
9 SWiRL  (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 Webmasters
1 Slaygon  (9.6)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.4)
5 CreaMD  (9.3)

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