Skip to content

Commit 5d467d6

Browse files
pinobatchISSOtm
andauthored
Change most uses of "sprite" to "object" (#484)
Co-authored-by: Eldred Habert <[email protected]>
1 parent 3a23996 commit 5d467d6

16 files changed

+172
-144
lines changed

src/Accessing_VRAM_and_OAM.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
::: warning Warning
55

66
When the PPU is drawing the screen it is directly reading
7-
from Video Memory (VRAM) and from the Sprite Attribute Table (OAM).
7+
from Video Memory (VRAM) and from the Object Attribute Memory (OAM).
88
During these periods the Game Boy CPU may not access VRAM and OAM.
99
That means that any attempts to write to VRAM or OAM are ignored (data
1010
remains unchanged). And any attempts to read from VRAM or OAM will return

src/CGB_Registers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ executed. During this time, the CPU is in a strange state. `DIV` does not tick,
183183
different results depending on the [STAT mode](<#STAT modes>) it's started in:
184184

185185
- HBlank / VBlank (Mode 0 / Mode 1): The PPU cannot access any video memory, and produces black pixels
186-
- OAM scan (Mode 2): The PPU can access VRAM just fine, but not OAM, leading to rendering background, but not sprites
186+
- OAM scan (Mode 2): The PPU can access VRAM just fine, but not OAM, leading to rendering background, but not objects (sprites)
187187
- Rendering (Mode 3): The PPU can access everything correctly, and so rendering is not affected
188188

189189
TODO: confirm whether interrupts can occur (just the joypad one?) during the pause, and consequences if so

src/GBC_Approval_Process.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
Game Boy Color hardware applies automatic colorization to monochrome
44
games, with one 4-color palette for backgrounds and two 3-color
5-
palettes for sprites. Because of past under utilization of Super Game Boy
5+
palettes for objects (sprites).
6+
Because of past under-utilization of Super Game Boy
67
features even in first-party games (as explained in an article by
78
Christine Love), Nintendo required Game Boy Color games to appear
89
more colorful than this automatic colorization. Thus, Nintendo

src/Interrupt_Sources.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ dynamically controlling the SCX/SCY registers ($FF43/$FF42) to [perform
4646
special video effects](https://github.com/gb-archive/DeadCScroll).
4747

4848
Example application: set LYC to WY, enable LY=LYC interrupt, and have
49-
the handler disable sprites. This can be used if you use the window for
50-
a text box (at the bottom of the screen), and you want sprites to be
49+
the handler disable objects. This can be used if you use the window for
50+
a text box (at the bottom of the screen), and you want objects (sprites) to be
5151
hidden by the text box.
5252

5353
## INT $50 — Timer interrupt

src/LCDC.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Bit | Name | Usage notes
1212
5 | Window enable | 0=Off, 1=On
1313
4 | BG and Window tile data area | 0=8800-97FF, 1=8000-8FFF
1414
3 | BG tile map area | 0=9800-9BFF, 1=9C00-9FFF
15-
2 | OBJ size | 0=8x8, 1=8x16
15+
2 | OBJ size | 0=8×8, 1=8×16
1616
1 | OBJ enable | 0=Off, 1=On
1717
0 | BG and Window enable/priority | 0=Off, 1=On
1818

@@ -45,14 +45,14 @@ but the screen will stay blank during the first frame.
4545
### LCDC.6 — Window tile map area
4646

4747
This bit controls which background map the Window uses for rendering.
48-
When it's reset, the \$9800 tilemap is used, otherwise it's the \$9C00
48+
When it's clear (0), the \$9800 tilemap is used, otherwise it's the \$9C00
4949
one.
5050

5151
### LCDC.5 — Window enable
5252

5353
This bit controls whether the window shall be displayed or not.
5454
This bit is overridden on DMG by [bit 0](<#LCDC.0 — BG and Window enable/priority>)
55-
if that bit is reset.
55+
if that bit is clear.
5656

5757
Changing the value of this register mid-frame triggers a more complex behaviour:
5858
[see further below](<#FF4A–FF4B — WY, WX: Window Y position, X position plus 7>).
@@ -66,28 +66,30 @@ This bit controls which [addressing
6666
mode](<#VRAM Tile Data>) the BG and Window use to
6767
pick tiles.
6868

69-
Sprites aren't affected by this, and will always use \$8000 addressing
70-
mode.
69+
Objects (sprites) aren't affected by this, and will always use the \$8000 addressing mode.
7170

7271
### LCDC.3 — BG tile map area
7372

7473
This bit works similarly to [LCDC bit 6](<#LCDC.6 — Window tile map area>):
75-
if the bit is reset, the BG uses tilemap $9800, otherwise tilemap $9C00.
74+
if the bit is clear (0), the BG uses tilemap $9800, otherwise tilemap $9C00.
7675

7776

7877
### LCDC.2 — OBJ size
7978

80-
This bit controls the sprite size (1 tile or 2 stacked vertically).
79+
This bit controls the size of all objects (1 tile or 2 stacked vertically).
8180

82-
Be cautious when changing this mid-frame from 8x8 to 8x16: "remnants"
83-
of the sprites intended for 8x8 could "leak" into the 8x16 zone and
81+
Be cautious when changing object size mid-frame.
82+
Changing from 8×8 to 8×16 pixels mid-frame within 8 scanlines of the bottom of an object
83+
causes the object's second tile to be visible for the rest of those 8 lines.
84+
If the size is changed during mode 2 or 3,
85+
remnants of objects in range could "leak" into the other tile and
8486
cause artifacts.
8587

8688
### LCDC.1 — OBJ enable
8789

88-
This bit toggles whether sprites are displayed or not.
90+
This bit toggles whether objects are displayed or not.
8991

90-
This can be toggled mid-frame, for example to avoid sprites being
92+
This can be toggled mid-frame, for example to avoid objects being
9193
displayed on top of a status bar or text box.
9294

9395
(Note: toggling mid-scanline might have funky results on DMG?
@@ -101,13 +103,13 @@ LCDC.0 has different meanings depending on Game Boy type and Mode:
101103

102104
When Bit 0 is cleared, both background and window become blank (white),
103105
and the [Window Display Bit](<#LCDC.5 — Window enable>)
104-
is ignored in that case. Only Sprites may still be displayed (if enabled
106+
is ignored in that case. Only objects may still be displayed (if enabled
105107
in Bit 1).
106108

107109
#### CGB Mode: BG and Window master priority
108110

109111
When Bit 0 is cleared, the background and window lose their priority -
110-
the sprites will be always displayed on top of background and window,
112+
the objects will be always displayed on top of background and window,
111113
independently of the priority flags in OAM and BG Map attributes.
112114

113115
When Bit 0 is set, pixel priority is resolved [as described here](<#BG-to-OBJ Priority in CGB Mode>).
@@ -122,13 +124,13 @@ locks it. It's thus possible to modify it mid-scanline!
122124

123125
## Faux-layer textbox/status bar
124126

125-
A problem often seen especially in NES games is sprites rendering on top
127+
A problem often seen in 8-bit games is objects rendering on top
126128
of the textbox/status bar. It's possible to prevent this using LCDC if
127129
the textbox/status bar is "alone" on its scanlines:
128130

129131
- Set LCDC.1 to 1 for gameplay scanlines
130132
- Set LCDC.1 to 0 for textbox/status bar scanlines
131133

132134
Usually, these bars are either at the top or bottom of the screen, so
133-
the bit can be set by the VBlank handler.
134-
135+
the bit can be set by the VBlank and/or STAT handlers.
136+
Hiding objects behind a right-side window is more challenging.

src/Memory_Map.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ A000 | BFFF | 8 KiB External RAM
1111
C000 | CFFF | 4 KiB Work RAM (WRAM) |
1212
D000 | DFFF | 4 KiB Work RAM (WRAM) | In CGB mode, switchable bank 1\~7
1313
E000 | FDFF | Mirror of C000\~DDFF (ECHO RAM) | Nintendo says use of this area is prohibited.
14-
FE00 | FE9F | [Sprite attribute table (OAM)](<#VRAM Sprite Attribute Table (OAM)>) |
14+
FE00 | FE9F | [Object attribute memory (OAM)](<#VRAM Sprite Attribute Table (OAM)>) |
1515
FEA0 | FEFF | Not Usable | Nintendo says use of this area is prohibited
1616
FF00 | FF7F | [I/O Registers](<#I/O Ranges>) |
1717
FF80 | FFFE | High RAM (HRAM) |
18-
FFFF | FFFF | [Interrupt](#Interrupts) Enable register (IE) |
18+
FFFF | FFFF | [Interrupt](#Interrupts) Enable register (IE) |
1919

2020
## Jump Vectors in first ROM bank
2121

src/OAM.md

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
11

2-
# VRAM Sprite Attribute Table (OAM)
2+
# Object Attribute Memory (OAM)
33

4-
The Game Boy PPU can display up to 40 sprites either in 8x8 or
5-
in 8x16 pixels. Because of a limitation of hardware, only ten sprites
6-
can be displayed per scan line. Sprite tiles have the same format as
7-
BG tiles, but they are taken from the Sprite Tiles Table located at
4+
The Game Boy PPU can display up to 40 movable objects (or sprites), each 8×8 or
5+
8×16 pixels. Because of a limitation of hardware, only ten objects
6+
can be displayed per scanline. Object tiles have the same format as
7+
BG tiles, but they are taken from tile blocks 0 and 1 located at
88
$8000-8FFF and have unsigned numbering.
99

10-
Sprite attributes reside in the Sprite Attribute Table (OAM: Object
11-
Attribute Memory) at \$FE00-FE9F. Each of the 40 entries consists of
10+
Object attributes reside in the object attribute memory (OAM) at \$FE00-FE9F.
11+
(This corresponds to the sprite attribute table on a TMS9918 VDP.)
12+
Each of the 40 entries consists of
1213
four bytes with the following meanings:
1314

1415
## Byte 0 — Y Position
1516

16-
Y = Sprite's vertical position on the screen + 16. So for example,
17-
Y=0 hides a sprite,
18-
Y=2 hides an 8×8 sprite but displays the last two rows of an 8×16 sprite,
19-
Y=16 displays a sprite at the top of the screen,
20-
Y=144 displays an 8×16 sprite aligned with the bottom of the screen,
21-
Y=152 displays an 8×8 sprite aligned with the bottom of the screen,
22-
Y=154 displays the first six rows of a sprite at the bottom of the screen,
23-
Y=160 hides a sprite.
17+
![Interpretation of object Y coordinates](imgs/Objects_vertical_position.png)
18+
19+
Y = Object's vertical position on the screen + 16. So for example:
20+
21+
- Y=0 hides an object,
22+
- Y=2 hides an 8×8 object but displays the last two rows of an 8×16 object,
23+
- Y=16 displays an object at the top of the screen,
24+
- Y=144 displays an 8×16 object aligned with the bottom of the screen,
25+
- Y=152 displays an 8×8 object aligned with the bottom of the screen,
26+
- Y=154 displays the first six rows of an object at the bottom of the screen,
27+
- Y=160 hides an object.
2428

2529
## Byte 1 — X Position
2630

27-
X = Sprite's horizontal position on the screen + 8. This works similarly
28-
to the examples above, except that the width of a sprite is always 8. An
29-
off-screen value (X=0 or X\>=168) hides the sprite, but the sprite still
30-
affects the priority ordering, thus other sprites with lower priority may be
31-
left out due to the ten sprites limit per scan-line.
32-
A better way to hide a sprite is to set its Y-coordinate off-screen.
31+
X = Object's horizontal position on the screen + 8. This works similarly
32+
to the examples above, except that the width of an object is always 8. An
33+
off-screen value (X=0 or X\>=168) hides the object, but the object still
34+
contributes to the limit of ten objects per scanline.
35+
This can cause objects later in OAM not to be drawn on that line.
36+
A better way to hide an object is to set its Y-coordinate off-screen.
3337

3438
## Byte 2 — Tile Index
3539

36-
In 8x8 mode (LCDC bit 2 = 0), this byte specifies the sprite's only tile index ($00-$FF).
37-
This unsigned value selects a tile from the memory area at $8000-$8FFF.
40+
In 8×8 mode (LCDC bit 2 = 0), this byte specifies the object's only tile index (\$00-\$FF).
41+
This unsigned value selects a tile from the memory area at \$8000-\$8FFF.
3842
In CGB Mode this could be either in
3943
VRAM bank 0 or 1, depending on bit 3 of the following byte.
40-
In 8x16 mode (LCDC bit 2 = 1), the memory area at $8000-$8FFF is still interpreted
41-
as a series of 8x8 tiles, where every 2 tiles form a sprite. In this mode, this byte
42-
specifies the index of the first (top) tile of the sprite. This is enforced by the
43-
hardware: the least significant bit of the tile index is ignored; that is, the top 8x8
44-
tile is "NN & $FE", and the bottom 8x8 tile is "NN | $01".
44+
In 8×16 mode (LCDC bit 2 = 1), the memory area at \$8000-\$8FFF is still interpreted
45+
as a series of 8×8 tiles, where every 2 tiles form an object. In this mode, this byte
46+
specifies the index of the first (top) tile of the object. This is enforced by the
47+
hardware: the least significant bit of the tile index is ignored; that is, the top 8×8
48+
tile is "NN & \$FE", and the bottom 8×8 tile is "NN | \$01".
4549

4650
## Byte 3 — Attributes/Flags
4751

@@ -87,7 +91,7 @@ limit, possibly causing another object later in OAM not
8791
to be drawn. To keep off-screen objects from affecting on-screen ones, make
8892
sure to set their Y coordinate to Y&nbsp;=&nbsp;0 or Y&nbsp;&nbsp;160
8993
(144&nbsp;+&nbsp;16).
90-
(Y&nbsp;&nbsp;8 also works if [object size](<#LCDC.2 — OBJ size>) is set to 8x8.)
94+
(Y&nbsp;&nbsp;8 also works if [object size](<#LCDC.2 — OBJ size>) is set to 8×8.)
9195

9296
### Drawing priority
9397

src/OAM_Corruption_Bug.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# OAM Corruption Bug
22

33
There is a flaw in the Game Boy hardware that causes rubbish data to be written
4-
to OAM RAM if the following instructions are used while their 16-bit content
4+
to object attribute memory (OAM) if the following instructions are used while their 16-bit content
55
(before the operation) is in the range $FE00&ndash;$FEFF and the PPU is in mode 2:
66

77
```rgbasm
@@ -10,7 +10,7 @@ to OAM RAM if the following instructions are used while their 16-bit content
1010
ld [hli], a ld [hld], a
1111
```
1212

13-
Sprites 1 & 2 ($FE00 & $FE04) are not affected by this bug.
13+
Objects 0 and 1 ($FE00 & $FE04) are not affected by this bug.
1414

1515
Game Boy Color and Advance are not affected by this bug, even when
1616
running monochrome software.
@@ -20,11 +20,14 @@ running monochrome software.
2020
The OAM Corruption Bug (or OAM Bug) actually consists of two different bugs:
2121

2222
- Attempting to read or write from OAM (Including the $FEA0-$FEFF
23-
region) while the PPU is in mode 2 (OAM mode) will corrupt it.
23+
region) while the PPU is in mode 2 (OAM scan) will corrupt it.
2424
- Performing an increase or decrease operation on any 16-bit register
2525
(BC, DE, HL, SP or PC) while that register is in the OAM range
26-
($FE00 - $FEFF) will trigger a memory write to OAM, causing a
27-
corruption.
26+
($FE00–$FEFF) will trigger an access to OAM, causing a corruption.
27+
This happens because the CPU's increment and decrement unit (IDU)
28+
for 16-bit numbers is directly tied to the address bus.
29+
During IDU operation, the value is output as an address,
30+
even if a read or write is not asserted.
2831

2932
## Affected Operations
3033

@@ -66,7 +69,7 @@ operations are on 16-bit words.
6669

6770
A "write corruption" corrupts the currently access row in the following
6871
manner, as long as it's not the first row (containing the first two
69-
sprites):
72+
objects):
7073

7174
- The first word in the row is replaced with this bitwise expression:
7275
`((a ^ c) & (b ^ c)) ^ c`, where `a` is the original value of that

src/Rendering.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ and some others to higher abstractions concepts.
1616

1717
Similarly to other retro systems, pixels are not manipulated
1818
individually, as this would be expensive CPU-wise. Instead, pixels are grouped
19-
in 8x8 squares, called _tiles_ (or sometimes "patterns"), often considered as
19+
in 8x8 squares, called _tiles_ (or sometimes "patterns" or "characters"), often considered as
2020
the base unit in Game Boy graphics.
2121

2222
A tile does not encode color information. Instead, a tile assigns a
2323
_color ID_ to each of its pixels, ranging from 0 to 3. For this reason,
2424
Game Boy graphics are also called _2bpp_ (2 bits per pixel). When a tile is used
2525
in the Background or Window, these color IDs are associated with a _palette_. When
26-
a tile is used in an OBJ, the IDs 1 to 3 are associated with a palette, but
26+
a tile is used in an object, the IDs 1 to 3 are associated with a palette, but
2727
ID 0 means transparent.
2828

2929
## Palettes
@@ -59,7 +59,7 @@ It is fairly limited: it has no transparency, it's always a
5959
rectangle and only the position of the top-left pixel can be controlled.
6060

6161
Possible usage include a fixed status bar in an otherwise scrolling game (e.g.
62-
_Super Mario Bros. 3_).
62+
_Super Mario Land 2_).
6363

6464
### Objects
6565

@@ -82,4 +82,4 @@ To summarise:
8282

8383
- **Tile**, an 8x8-pixel chunk of graphics.
8484
- **Object**, an entry in object attribute memory, composed of 1 or 2
85-
tiles. Independent of the background.
85+
tiles. Can be moved independently of the background.

0 commit comments

Comments
 (0)