| |
wbochar
Registered: May 2002 Posts: 29 |
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.... |
| |
Digger
Registered: Mar 2005 Posts: 437 |
Great thread! How would you go about two 4x4 blocks of unexpanded sprites, with normal graphics underneath (no $d018 trick).
1. Each 4x4 block will have an independent X and Y position
2. The screen is also freely moving in X and Y with $d011/$d016 so badlines will occur on different rasterlines
The trickiest case happens when you have to update all 8 sprite-pointers on a badline when the Y coords of two blocks are aligned so the thread answers this question.
But how to generate an IRQ handler for that?
Was thinking of a speedcode with injected $d012 values, but then how to handle the critical situation above?
Injected JSR addresses to various update routines (4/8 sprites) would seem to consume too many cycles. |
| |
algorithm
Registered: May 2002 Posts: 705 |
Using the duplicated two line or so sprite definition method would ease things a bit (mentioned elsewhere in this thread) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
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. |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1409 |
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. |
| |
Digger
Registered: Mar 2005 Posts: 437 |
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 :) |
| |
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 :-) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
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. |
| |
ChristopherJam
Registered: Aug 2004 Posts: 1409 |
@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... |
| |
wbochar
Registered: May 2002 Posts: 29 |
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.. |
| |
wbochar
Registered: May 2002 Posts: 29 |
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% |
Previous - 1 | 2 | 3 - Next |