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 every second pixel is the same and giving that moasic effect.
so just merge every 2 u8's into u16 and then write it to the vram.
or something
> 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
> unsubscribe: gbadev-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>