Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > C64 32 Sprites 8x4 and Gaps
2016-10-16 21:36
wbochar

Registered: May 2002
Posts: 26
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?

Notes:

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

AA:0-AB:1-AC:2-AD3-AE4-AF5-AG6-AH7
AI:0-AJ:1-AK:2-AL3-AM4-AN5-AI6-AO7
BA:0-BB:1-BC:2-BD:3-BE4-BF5-BG6-BH7
BI:0-AJ:1-BK:2-BL:3-BM4-BN5-BI6-BO7

Raster IRQ fires at:


BorderTopIRQ:
0         : turn off upper border
          : Set Sprites 0-7 (No Stretch, Enable, X-pos)
          : Update RasterIRQ Line to LogoIRQLine1
LogoIRQLine1:
10        : Set Sprites 0-7 y-position (RasterLine+2)
          : Set Sprites 0-7 bitmaps (AA,AB,AC,AD...)
          : Update RasterIRQ Line to LogoIRQLine1
LogoIRQLine2:
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
LogoIRQLine3:
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
LogoIRQLine4:
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
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
algorithm

Registered: May 2002
Posts: 702
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
Oswald

Registered: Apr 2002
Posts: 5017
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
ChristopherJam

Registered: Aug 2004
Posts: 1370
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
Digger

Registered: Mar 2005
Posts: 421
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
Firehawk

Registered: Aug 2011
Posts: 31
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
Oswald

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

4sprites:

ab
cd

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

Registered: Aug 2004
Posts: 1370
@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
wbochar

Registered: May 2002
Posts: 26
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:

	sei
	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

        cli


IRQ_UpperBorder:
	
//	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
	lda #LIGHT_BLUE
	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

	rti



IRQ_Logo1:

        //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
	rti

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

Registered: May 2002
Posts: 26
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
Oswald

Registered: Apr 2002
Posts: 5017
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
Advanced
Users Online
Sentinel/Excess/TREX
Mike
Jak T Rip/DMAgic
megatonn/Bronx
Andy/AEG
kbs/Pht/Lxt
Didi/Laxity
The Syndrom/TIA/Pret..
Guests online: 87
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 Wafer Demo  (9.5)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Onscreen 5k  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Starlight  (9.6)

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