øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=profile;u=390;area=showposts;start=75e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexa71d.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=profile;area=showposts;u=390e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexa71d.html.zxbüg^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿȰUËãOKtext/htmlISO-8859-1gzip0|ÖËãÿÿÿÿÿÿÿÿTue, 10 Mar 2020 21:01:46 GMT0ó°° ®0®P®€§²ð®büg^ÿÿÿÿÿÿÿÿ­.Ëã Show Posts - Squall

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Squall

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 »
76
Sorry chillyfeez, just for the sake of completion: SNES PPU Tutorial

77
Wooah x0_000, there is so much ... I feel like a boy in a candy shop :D

 :edit:
do you know where this table is (from ffva text - abilities.txt):
Code: [Select]
1 byte per character
00 - space
01 - e
02 - t
03 - a
04 - o
05 - n
06 - s
07 - r
08 - i
09 - h
0a - l
0b - .
0c - d
0d - . (terminator?)
0e - u
0f - m
10 - g
11 - y
12 - c
13 - w
14 - f
15 - p
16 - !
17 - b
18 - :
19 - k
1a - '
1b - ,
1c - v
1d - T
1e - I
1f - S
20 - C
21 - G
22 - W
23 - ?
24 - F
25 - L
26 - -
27 - B
28 - P
29 - M
2a - K
2b - H
2C - A
2D - D
2e - E
2f - R
30 - x
31 - O
32 - Y
33 - N
34 - z
35 - j
36 - q
37 - 1
38 - V
39 - U
3a - 2
3b - X
3c - J
3d - * (?)
3e - "
3f - 0
40 - 3
41 - Z
42 - 4
43 - 5
44 - Q
45 - 6
46 - 8
47 - 7
48 - %
49 - 9
4a - +
4b - ;
4c - /
4e - space
4f - &
50 - (
51 - )
52 - =
53 - .
54 - ..
55 - japanese period
56 - -
57 -
58 -
59 -
5a -
5b -
5c -
5d -
5e -
5f -
60 -
61 -
62 -
63 -
64 -
65 -
66 -
67 -
68 -
69 -
6a -
6b -
6c -
6d -
6e -
6f -

78
x0_000, you are probably the only person that I know with extended knowledge on GBA version, and one of the few that know really a lot about it. Please let your work don't sunk as many before us - all their finding, knowledge has been burred with them (after they stop to be active). That's why PLEASE, take some time and write tutorials, or simply write down what you have found addresses, tables, constant,.. with short explanation!

You never know how a tiny bit of info could lead to something bigger. When I started your paragraph of how text is organized helped me so much, that almost everything I show in my Viewer as a text is based on your tiny paragraph ... and that is like hundreds line of code in the Viewer concerning the GBA.

BTW I got crack on fonts for GBA. If you are interested I can share what I have found!

79
Good luck m8! If there is something we can do to help?

80
My goal is by knowing how things work, to give you (as an artist) the freedom to create. If you want to restrict yourself ... OK :D

81
Quote
So looking through the documentation. It looks like Mode 1 uses one 4-color BG and two 16-color BGs... how are the palettes allocated in Mode 1?
I assume sprites get 8 palettes regardless of mode? Would that mean, then, that in Mode 1 there are eight 4-color palettes for BG3 and six 16-color palettes shared by BG1 and BG2?
Excellent observations, m8!
You actually answered to to your question :) and shared a good observation (something that I should had mention it): all 4bpp Layers share same pool of palettes.
Yes because of BG3 we loose 2 Palettes in Mode 1. Keep in mind that each BG could be turned off, so we can use all 8 Palettes.

Quote
Uh-oh... This is going to be a problem for this project.
In FFIV, every character portrait and every PC battle sprite has a dedicated palette. So to use every palette I was planning to use, that would be a minimum of 16 palettes (11 portraits + 5 battle sprites). That means that hardware limitations will definitely prevent me from using the method I had originally intended for this project.
Let me ask you something:
- What is the max number of colors for BG3 in Mode1?
- What is the max number of colors for BG1 in Mode1 with BG3 on?
- What is the max number of colors for BG1 in Mode1 with BG3 off?

Lets think globally:
We will have 14 different Palettes (6 from BG and 8 from Sprites). That may net you 210 different colors on the screen. That is close to VGA in PC. That is many times more colorful then 90% of all games for SNES.
Of course we can't use both Sprite & BG palettes from one Tile. Lets take the BGs - 6 palettes with max 90 colors. Lets say we use only BGs for the whole PHS. You have 90 colors and 6 palettes. You don't have to limit 1 portrait with 1 palette. You may use all 6 palettes from each portrait. Remember the limitation is a Pal for a Tile, but a portrait composed by 3x3 or 4x4 (not sure what you will use) may use all 6!!! Imagine how cool a portrait will look in 4x4 tiles (64x64 pixels) with 90 colors

82
IV. Palette
1. What is a Palette?
Our next abstraction is a Palette. Think of an artist painting a picture - although the picture may contain millions colors, while painting the artist take only couple of colors on a palette (tray/board) to draw specific areas of the picture. The same way, when the PPU draw a Tile, it uses a selection of colors named a Palette.

The number of colors in a Palette is tightly connected with the Layer BPP:
 - If a Layer is 4bpp, then the Palette contain 2^4 = 16 colors with indexes 0..15.
 - If a Layer is 2bpp, then the Palette contain 2^2 = 4 colors with indexes 0..3
 - How many colors we have in 8bpp?

2. Color (Palette Entry)
In each Palette entry 0 is a special - it is used for transparency. All colors are 16 bit in the format: 0BBBBBGGGGGRRRRR.
That is 5 bits for each component - Red/Green/Blue. In specialized books you will see this abbreviated as 5-5-5.

3. Palette memory
PPU contain dedicated memory of 512 bytes for Palettes, abbreviated as CGRAM. That memory can hold 256 colors. Depending of the Layer's BPP that memory is used differently:
- in 8bpp - we have 1 Palette containing 256 colors, entries: $00..$FF
- in 4bpp - we have 8 Palettes, occupying entries: $00..$7F
- in 2bpp (Mode 0) we have 8 Palettes for each layer: $00..$1F (BG1), $20..$3F (BG2), $40..$5F (BG3) and $60..7F (BG4)
* Sprites use 8 Palettes, occupying entries: $80..$FF

4. PPU Registers:
Code: [Select]
$2121: Address for accessing CGRAM (1b/W). This register selects the  word location (byte address * 2)
$2122: Data write to CGRAM (1b/W)
$213B: Data read from CGRAM (1b/R)
[i]*Since read/write return only 1 bite, you need 2 consecutive operations to get the whole color (16bits)[/i]

83
Excellent work, m8!!! I'm proud of you!!!
Both task completed!

That was the hardest part - hard to explain, hard to code, and hard to understand.

Quote
I guess this somehow makes the data easier or faster for the SNES to interpret? You don't have to explain why or how that is - it's probably deeper than I need to go.
My speculation is - hardware. Usually by doing this weird for us things, they organize memory ... like a Bit-Plane in one memory chip. Then you can assign different processors to work on different chip memory simultaneously without interfering (internal multitasking).

The other possibilities is to have separate bus to each chip which will multiply the access to VRAM. For example if each bus is 8 bit and we have 4 banks with separate bus connection - that is effectively 32 bit bus (you can read 32bits in one bus tact).
That's exactly what contemporary video cards do - multiple cores for multitasking and wide bus to guarantee fast access to the VRAM. In the past GTX modifications had better performance, not because they have more cores or frequency, but wide bus, because the bus is quite a bottleneck for the performance.

Anyway we have only 2 things left: Sprites and Palettes. Both should be familiar to you so I'm only going to write SNES specifics. After that we may talk a little bit of DMA/HDMA and if you want finish the 2 ??? - Clipping & Scrolling of layers :)

84
Code: [Select]
This isn't really a hard no, but it's definitely difficult enough to be a soft no.Hehe very soft indeed :D

85
III.2. Tile internal storage (Bit-planes) EXTENDED

2.1 What is a Bit-plane
A Bit-Plane is a 2d MxN matrix/array/block of 1 bit values, yes only 0 or 1!
In graphics, if we take bit 0 (rightmost) of each pixel of a picture, the 2d matrix of all bit 0 is a Bit-Plane0. Similarly, of all bit1 of pixels of a picture is Bit-Plane1 and so on.

Lets talk specifically about Tiles in 4BPP:
If we take all bit 0 of all 8x8 pixels, we will have 8x8 1bit matrix - Bit-Plane0
If we take all bit 1 of all 8x8 pixels, we will have 8x8 1bit matrix - Bit-Plane1
If we take all bit 2 of all 8x8 pixels, we will have 8x8 1bit matrix - Bit-Plane2
If we take all bit 3 of all 8x8 pixels, we will have 8x8 1bit matrix - Bit-Plane3
* each Bit-Plane is 8 bytes, each byte contain a row of bits
* Number of BPP = Number of Bit-Planes!

2.2. Example
Code: [Select]
   Tile in Decimal:                     Same Tile in Binary (4bit):
00 01 02 03 04 05 06 07          0000 0001 0010 0011 0100 0101 0110 0111
08 09 10 11 12 13 14 15          1000 1001 1010 1011 1100 1101 1110 1111
00 01 02 03 04 05 06 07          0000 0001 0010 0011 0100 0101 0110 0111   
08 09 10 11 12 13 14 15   ---\  1000 1001 1010 1011 1100 1101 1110 1111
00 01 02 03 04 05 06 07   ---/  0000 0001 0010 0011 0100 0101 0110 0111
08 09 10 11 12 13 14 15          1000 1001 1010 1011 1100 1101 1110 1111
00 01 02 03 04 05 06 07          0000 0001 0010 0011 0100 0101 0110 0111
08 09 10 11 12 13 14 15          1000 1001 1010 1011 1100 1101 1110 1111

Code: [Select]
Bit-Plane 0:        Bit-Plane 1:      Bit-Plane 2:       Bit-Plane 3:
0 1 0 1 0 1 0 1   0 0 1 1 0 0 1 1   0 0 0 0 1 1 1 1   0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1   0 0 1 1 0 0 1 1   0 0 0 0 1 1 1 1   1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1   0 0 1 1 0 0 1 1   0 0 0 0 1 1 1 1   0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1   0 0 1 1 0 0 1 1   0 0 0 0 1 1 1 1   1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1   0 0 1 1 0 0 1 1   0 0 0 0 1 1 1 1   0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1   0 0 1 1 0 0 1 1   0 0 0 0 1 1 1 1   1 1 1 1 1 1 1 1
0 1 0 1 0 1 0 1   0 0 1 1 0 0 1 1   0 0 0 0 1 1 1 1   0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1   0 0 1 1 0 0 1 1   0 0 0 0 1 1 1 1   1 1 1 1 1 1 1 1

2.3 How Bit-Planes are stored in SNES
In the perfect world we will be done, but in SNES things are even more complicated. In memory this is present as:
Code: [Select]
  p -  Bit-Plane,   pX - Bit-Plane X
  r -  row,  rX - row X
  pX:rY - a byte value made by the 8 bits of a row Y in Bit-Plane X
p0:r0  p1:r0  p0:r1  p1:r1  p0:r2  p1:r2  p0:r3  p1:r3  p0:r4  p1:r4  p0:r5  p1:r5  p0:r6  p1:r6  p0:r7  p1:r7
p2:r0  p3:r0  p2:r1  p3:r1  p2:r2  p3:r2  p2:r3  p3:r3  p2:r4  p3:r4  p2:r5  p3:r5  p2:r6  p3:r6  p2:r7  p3:r7

2.4 Fill the missing XXs:
As a practical task, I will give you the value of few pX:rY. Your task is to tell me the missing ones marked as XX. All values are in hex!
Code: [Select]
55 33 XX XX XX XX XX XX XX XX XX XX XX XX XX XX
0F 00 XX XX XX XX XX XX XX XX XX XX XX XX XX XX

2.5 Some interesting cases:
- 2bpp? Its very easy, we have only 2 bit-planes and only 1 row (16 bytes). Its not by chance I used 2 rows to put bytes of a Tile :)
- 3bpp? First row is the same. Second row is only 8 bytes and contain bytes of Bit-Plane 2.
- 3bpp->4bpp? (please tell, how do you think it will happen)

86
Excellent questions, m8! Asking questions is the right way of understanding :D

1) MxN usually in the math mean a two dimensional matrix with M rows and N cols. It pretty much mean the same in programming for arrays. The importance is that in it represent rectangular block, but we don't care about exact dimension. If it was MxM or NxN it will mean square rather rectangular. In short MxN stands for 2D rectangular matrix/array/block without specifying the exact dimension.

2) You really nail it!!! Excellent question!!!
As you said FF4 uses internally 3bpp for most monsters and many other graphical objects (inheritance from NES I guess, because FF5 uses 4bpp in most cases). The problem is SNES has 2 or 4 bpp (without loosing quality). That's why all 3bpp stored in the ROM needs to be converted to 4bpp. That is done by inserting a 4th bit-plane with zeroes. 4(decimal) = 100 (binary-3bits) = 0100 (binary-4bits). Because of the way bit-planes are stored, your observation is right: it add 8 zeroes over the last $10 bytes.

Because 3bpp require: 3 x 8x8 bits = 192 bits = 24 bytes = $18, but 4bpp require $20 bytes, we will save 8 bytes per Tile and since we have plenty of Tiles building the image, some people call this compression. FF5 monsters could be 3bpp or 4bpp. There is a flag that tell us that, so in Japanese documents it was named compression :D

Quote
3) I don't know if it's really important for me to know, since there are graphics viewing and editing programs
Pretty much NO. Manipulating the individual pixels of a Tile is used mainly for creating special effects. In my observations, Square were a little bit lazy and were doing only effects trough manipulating PPU registers (easy and fast). The other case is for creating Tiles on the fly (trough code) - a library of functions that can manipulate Tiles, like Plot(TileID, X, Y, Color). In FF4, probably the only occasion of manipulating Tiles is the conversion of 3bb -> 4bpp.

87
III Tiles
We used that word so much, so I hope you got some intuitive understanding, but now is it a time to get a more formal one :D

1. What is a Tile
Tile is the basic element to a tile engines. It is the atom of the chemistry so to speak. It is the brick of an wall :D
A tile is a 2D MxN matrix (block/array) of points/pixels. In SNES a tile is an 8x8 block of pixels!. The colors of each pixels could be an index in a palette or Direct Color (R/G/B values) and that is defined by the Mode/Layer

2. Internal storage (or Bit-planes)
A tile is stored in the memory as a Bit-Planes. Depending on how many BPP is a layer, the tile uses the same amount of Bit-planes. Since SNES can use only 2/4/8 BPP, the tiles uses 2/4/8 Bit-planes. I really, really hope you know what bit-plane is, but if not and you want to know SNES specifics let me know.
From hacking standpoint its important to know - how many bytes a Tile occupy:
- in 2bpp, we have 2 x 8x8 = 128 bits = 16 bytes = $10 bytes
- in 4bpp, we have 4 x 8x8 = 256 bits = 32 bytes = $20 bytes

3. Tile map
A Tille Map is a 2D matrix MxN where each value is a Tile ID. Wait a minute, that looks dangerously similar to the definition of a layer. YES it is, a layer is an instance (custom case) of a tile map. And not just that, a Sprite is another instance of a TileMap.
Because of the way SNES works (Tiles don't hold palette info), the values of this 2D matrix (TileMap) are 16 bits, with the same meaning as layers:
Code: [Select]
Bit 0-9     - Tile ID      (000h-3FFh)
Bit 10-12   - Palette ID   (0-7)
Bit 13      - BG Priority  (0=Lower, 1=Higher)
Bit 14      - X-Flip       (0=Normal, 1=Mirror horizontally)
Bit 15      - Y-Flip       (0=Normal, 1=Mirror vertically)

4. Tile Size
SNES uses 2 sizes for tiles - 8x8 and 16x16. Wait a minute, didn't you say earlier is only 8x8? Yes I did! 16x16 tiles are actually 4 tiles (2x2) stored in a certain order.

5. Important registers (soon)

88
Working as a software developer, I  learned one thing about the graphic: eye is easily deceived. What you see on the screen could be totally different on how its implemented. For example, when you battle in FF4, you may think that all monsters and chars are sprites. But if you use vSNES you will see that monsters (not sure about chars) are actually in BG1 or 2 (so to speak they are static picture) :D

Unless you do save-state we can only speculate, but if I have to do it, I will probably make the top-most layer tile prerendered of the crystal and the flashing effect (you merge the two layers in Photoshop and the result is assigned to top-most tile).

Speaking of pre-render effect ... in FFBE check the candles - both walls and candles have clear vision, but if you take sometime and watch the fire/light animation over the wall ... see how pixelize it is (effect that happen from rendering the animation in true color(24/32bits) and then converted to less colors, most like 8bit/256). So instead each frame of fire to be rendered in realtime, they use bitmaps with prerendered effect already applied.

89
II. Layers
The second abstraction is Layer. You may see it as Background or BG in documentation. It work the same way  as in specialized graphic applications: Photoshop or Gimp - the final image is composed by plotting couple of images 1 by 1, each on top of the next, each containing transparent pixels trough which you may see things from the image under it.

SNES contain 4 such layers  (usually called background) + 1 sprite layer (which function in similar way) for a total of 5 layers. Unlike Photoshop where each layer can have 256 levels of transparency, here we have only 2 levels - fully transparent or not. Using color with index 0 mark transparent parts.

The other difference from Photoshop is that in each layer we can define priority for individual Tiles. For BG1-4 we have priority 0 and 1, while for Sprites (OBJ) we have 0-3. The order in which final image is rendered depend on the mode, so check the documentations for specifics (or experiment in vSNES).
While usually the mode define things like BPP or Max Colors, in SNES each layer has its own definition and is determined by the mode. For example in Mode 0 - all 4 BG are 2 BPP (4 color), but in Mode 1 - 4bpp for BG1,2 and 2bpp for BG3. Sprites (OBJ) are always in 4bpp, regardless of the Mode!

Code: [Select]
$212C - control which layer is visible or not
$2105 - tilesize for each leayer
$2107-$210A - set layer's base address in VRAM and its size. For now we all work with 32x32

 :edit:
Now that we know so many things about layers, what exactly we have in a layer?
Each layer is a two dimensional array of 16 bit values. There are 4 possible dimensions, but for now we will talk about 32x32. Each value has this format (exception in Mode 7 or "Offset-per-Tile" modes: 2,4,6):
Code: [Select]
  Bit 0-9     - Tile ID      (000h-3FFh)
  Bit 10-12   - Palette ID   (0-7)
  Bit 13      - BG Priority  (0=Lower, 1=Higher)
  Bit 14      - X-Flip       (0=Normal, 1=Mirror horizontally)
  Bit 15      - Y-Flip       (0=Normal, 1=Mirror vertically)

Clipping???
Scrolling????

90
Writing those long paragraphs take me quite sometime - to check, to experiment, to synthesize, to add some practicality ... so I really need your input - is it too much, is it not enough, whatever is your first impression/response after reading it (if you prefer PM, Telegram thats fine too)!

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 »