headkaze · 208835
There is a global priority setting that can be used for both sprites and backgrounds (value between 0 and 3) so you can place backgrounds or sprites in front of each other. I believe this overrides oam entry position too. I use it to place the room overlays infront of the characters.
I've just finished adding the watch using rotating sprites (oh soooo much easier!) they look a whole lot better. Anyway I had to change to using sprites because drawing over tiles causes problems when using more than 16 colors. Couldn't be bothered trying to figure out why. Perhaps when using 256 colors each tile can only use 16 colors of 16 palettes. I think that's why anyway.
Didn't get this ... are you using 16 colors or 256 colors tiled background? Because if you're using 256 colors tiled background then there shouldn't be any problem. (Anyway using a rotating sprite is easier, of course!)
void DrawPixel(int x, int y, int colorIndex){ u16 tileId = *(BG_MAP_RAM_SUB(BG1_MAP_BASE_SUB) + (x / 8) + (y / 8) * 32); u16* pTile = BG_TILE_RAM_SUB(BG1_TILE_BASE_SUB) + tileId * 32 + ((x % 8) / 2) + (y % 8) * 4; *pTile = ((x % 2) == 0 ? ((*pTile &~ 0xF) | colorIndex) : ((*pTile &~ 0x0F00) | (colorIndex << 8)));}
*pTile = ((x % 2) == 0 ? ((*pTile &~ 0xFF) | colorIndex) : ((*pTile &~ 0xFF00) | (colorIndex << 8)));
if(REG_VCOUNT == 0){ REG_DISPCNT_SUB &= ~DISPLAY_SPRITE_ATTR_MASK; REG_DISPCNT_SUB |= SpriteMapping_1D_32;}if(REG_VCOUNT == 40){ REG_DISPCNT_SUB &= ~DISPLAY_SPRITE_ATTR_MASK; REG_DISPCNT_SUB |= SpriteMapping_Bmp_1D_128;}
Thanks sverx that fixed it! BTW I think I may end up having to use my pixel routine to draw the watch hands now because to use alpha blended sprites you need to have them in 16 bit color mode. When you use 16 bit color mode you can't rotate sprites
ATTR0_ROTSCALE | ATTR0_TYPE_BLENDED | ATTR0_COLOR_256
So I think okay so I need to have the sprites in bmp mode for the alpha value to work.
You have to turn on alpha blending for REG_BLDCNT (BLEND_ALPHA)
I guess this way every sprite gets semi-transparent, not only those with the flag
Semi-Transparent OBJsOBJs that are defined as 'Semi-Transparent' in OAM memory are always selected as 1st Target (regardless of BLDCNT Bit 4), and are always using Alpha Blending mode (regardless of BLDCNT Bit 6-7).The BLDCNT register may be used to perform Brightness effects on the OBJ (and/or other BG/BD layers). However, if a semi-transparent OBJ pixel does overlap a 2nd target pixel, then semi-transparency becomes priority, and the brightness effect will not take place (neither on 1st, nor 2nd target).