Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Sprite just won't display properly.   Message List  
Reply | Forward Message #5969 of 15019 |
I'm trying to display a single sprite to the screen, but it looks
like it always has some sort of mosaic effect enabled.
I have a 32x64 sprite set up to display, but when the gba actually
displays it, it displays every second pixel and then doubles that
horizontally, resulting in a rather ugly sprite.

Here is what I have so far (I'm not too worried about the garbage
sprites at the moment):

#include "gba_gfx.h"
#include "sprites/test2.c"

#define SPRITE_WIDTH 32
#define SPRITE_HEIGHT 64
#define SPRITE_BITS 8

#define TILESET 0
#define MAPSET 16
#define TILE_SIZE (8*8)
#define SPRITE_SIZE (SPRITE_WIDTH*SPRITE_HEIGHT)
#define SPRITE_TILES (SPRITE_SIZE / TILE_SIZE)
#define SPRITE_NUM(A) (((A)*SPRITE_TILES))
#define SPRITE_OFFSET(A) (SPRITE_NUM(A)*TILE_SIZE)

#define ATTR0_SHAPE_SQUARE 0
#define ATTR0_SHAPE_RECTH 0x4000
#define ATTR0_SHAPE_RECTV 0x8000
#define ATTR0_COLOR_16 0
#define ATTR0_COLOR_256 0x2000
#define ATTR0_Y_COORD(A) ((A)&0xff)
#define ATTR0_FORCE_SPRITE_OFF 0x200

#define ATTR1_SIZE_8 0
#define ATTR1_SIZE_16 0x4000
#define ATTR1_SIZE_32 0x8000
#define ATTR1_SIZE_64 0xc000
#define ATTR1_FLIP_X 0x1000
#define ATTR1_FLIP_Y 0x2000
#define ATTR1_X_COORD(A) ((A)&0x1ff)

#define ATTR2_TILE_NUMBER(A) ((A))


void copy8(volatile u8* dst, volatile u8* src, u32 length)
{
while(length--)
*dst++ = *src++;
}

void copy16(volatile u16* dst, volatile u16* src, u32 length)
{
while(length--)
*dst++ = *src++;
}

int AgbMain(void)
{
volatile u8* pSpriteTiles = (u8*)(ADDR_SPRITE_DATA);
volatile u8* pSpritePalette = (u8*)ADDR_PALETTE_OBJ;
volatile u16* psprite = (u16*)ADDR_OAM;

copy16((u16*)pSpritePalette, (u16*)test2_Palette,
1<<SPRITE_BITS);
copy8(pSpriteTiles(u8*)test2_Character, SPRITE_SIZE);

*IO_DISPCNT = DISPCNT_VIDEO_MODE(0) | DISPCNT_SPRITES |
DISPCNT_1D_MAPPING;

*psprite++ = ATTR0_SHAPE_RECTV | ATTR0_COLOR_256 |
ATTR0_Y_COORD(48);
*psprite++ = ATTR1_SIZE_64 | ATTR1_X_COORD(104);
*psprite++ = ATTR2_TILE_NUMBER(0);
*psprite = 0;

while(1);

return 0;
}






Wed Aug 1, 2001 4:29 pm

kstenerud@...
Send Email Send Email

Forward
Message #5969 of 15019 |
Expand Messages Author Sort by Date

I'm trying to display a single sprite to the screen, but it looks like it always has some sort of mosaic effect enabled. I have a 32x64 sprite set up to...
Karl Stenerud
kstenerud@...
Send Email
Aug 1, 2001
6:53 pm

Don't have the sprite area of VRAM declared as "u8". Declare it as "u16", and copy your sprite data 16 bits at a time (typecast your source data to u16 if you...
Tom Prosser
tom@...
Send Email
Aug 1, 2001
11:26 pm

You are using your copy8 function to copy to VRAM, you not allowed to write to VRAM in 8bits, only 16 and 32 so the next 8 is a copy of the first 8 and so...
Dan Cotter
dancotter@...
Send Email
Aug 2, 2001
3:19 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help