hi everybody! i'm trying to write a NES emu and i'm having some problems while fetching the 2 lower bits of the palette index given by a pattern table entry. i'll try to be as clear as possible, but since english isn't my native language it's gonna be kind of hard. hope you can understand me...
i've been reading a few documents i've found in NESDEV, and so far what i understand is this:
* in the pattern tables, tiles are stored "layered" into 2 bitplanes
* each bitplane is divided into 8 rows of 1 byte
* each bit in each row represents 1 pixel of the tile
now look at this picture:
EDIT: the pink colored number at the bottom bitplane should be the fourth number at the first column (not the fifth), from bottom to up.
in the image you can see marked in colors how i'm trying to fetch and combine the 2 bits. i mean:
(Notation: Value -> Color number)
00 -> Transparent (marked in red)
01 -> Color #1 (marked in blue)
10 -> Color #2 (marked in green)
11 -> Color #3 (marked in pink)
to get the values listed above, i'm proceding like this:
Bit0 = VRAM[0x000X] & YY;
Bit1 = VRAM[0x000X + 8] & YY;
Index = (Bit1 << 1) | Bit0;
...where YY is 0x80 in case i would want to extract bit 8 of a row, or 0x40 in case i would want to extract bit 7, or 0x20 in case i want would to extract bit 6,...
so thats what i understood, but in this post tepples said: "each row has 8 pixels; the most significant bit of each row is drawn on the left" (it's the penultimate comment in the post).
what did he meant whit "the most significant bit of each row"? since there are 8 rows, by fetching the most significant bit of each row i would be fetching the 2 bits from only the first pixel in each row, so what about the others 7 pixels? i think i'm getting something wrong...
thank you all in advance!
i've been reading a few documents i've found in NESDEV, and so far what i understand is this:
* in the pattern tables, tiles are stored "layered" into 2 bitplanes
* each bitplane is divided into 8 rows of 1 byte
* each bit in each row represents 1 pixel of the tile
now look at this picture:
EDIT: the pink colored number at the bottom bitplane should be the fourth number at the first column (not the fifth), from bottom to up.
in the image you can see marked in colors how i'm trying to fetch and combine the 2 bits. i mean:
(Notation: Value -> Color number)
00 -> Transparent (marked in red)
01 -> Color #1 (marked in blue)
10 -> Color #2 (marked in green)
11 -> Color #3 (marked in pink)
to get the values listed above, i'm proceding like this:
Bit0 = VRAM[0x000X] & YY;
Bit1 = VRAM[0x000X + 8] & YY;
Index = (Bit1 << 1) | Bit0;
...where YY is 0x80 in case i would want to extract bit 8 of a row, or 0x40 in case i would want to extract bit 7, or 0x20 in case i want would to extract bit 6,...
so thats what i understood, but in this post tepples said: "each row has 8 pixels; the most significant bit of each row is drawn on the left" (it's the penultimate comment in the post).
what did he meant whit "the most significant bit of each row"? since there are 8 rows, by fetching the most significant bit of each row i would be fetching the 2 bits from only the first pixel in each row, so what about the others 7 pixels? i think i'm getting something wrong...
thank you all in advance!