RE: [gbadev] Sprite just won't display properly.
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 can't re-convert it to that and try to ensure it is aligned to 16
bits). Sprite VRAM is like all other VRAM - you cannot write to it 8 bits
at a time, otherwise the same 8 bits get repeated across two pixels, and I'm
guessing that's what you're seeing.
-----Original Message-----
From: Karl Stenerud [mailto:
kstenerud@...]
Sent: 01 August 2001 17:30
To:
gbadev@yahoogroups.com
Subject: [gbadev] Sprite just won't display properly.
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;
}
list rules:
http://www.gbadev.org/rules.txt
<
http://www.gbadev.org/rules.txt>
unsubscribe:
gbadev-unsubscribe@egroups.com
Your use of Yahoo! Groups is subject to the Yahoo!
<
http://docs.yahoo.com/info/terms/> Terms of Service.
[Non-text portions of this message have been removed]