You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/cheatsheet.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ ldh [rLCDC], a
75
75
76
76
**To turn the LCD off:**
77
77
78
-
:::warning
78
+
:::warning: ⚠️
79
79
80
80
Do not turn the LCD off outside of the Vertical Blank Phase. See "[How to wait for vertical blank phase](#how-to-wait-for-the-vertical-blank-phase)".
81
81
@@ -146,7 +146,7 @@ You can use one of the 4 constants to specify which layer uses which region:
146
146
- LCDCF_BG9800
147
147
- LCDCF_BG9C00
148
148
149
-
:::tip Note
149
+
:::tip Note
150
150
151
151
You still need to make sure the window and background are turned on when using these constants.
152
152
@@ -174,7 +174,7 @@ and a, LCDCF_OBJOFF
174
174
ldh [rLCDC], a
175
175
```
176
176
177
-
:::tip
177
+
:::tip
178
178
179
179
Sprites are in 8x8 mode by default.
180
180
@@ -184,7 +184,7 @@ Sprites are in 8x8 mode by default.
184
184
185
185
Once sprites are enabled, you can enable tall sprites using the 3rd bit of the `rLCDC` register: `LCDCF_OBJ16`
186
186
187
-
:::tip
187
+
:::tip
188
188
189
189
You can not have some 8x8 sprites and some 8x16 sprites. All sprites must be of the same size.
190
190
@@ -243,13 +243,13 @@ CopyTilemap:
243
243
jp nz, CopyTilemap
244
244
```
245
245
246
-
:::tip
246
+
:::tip
247
247
248
248
Make sure the layer you're targetting has been turned on. See ["Turn on/off the window"](#turn-onoff-the-window) and ["Turn on/off the background"](#turn-onoff-the-background)
249
249
250
250
:::
251
251
252
-
:::tip
252
+
:::tip
253
253
254
254
In terms of tiles, The background/window tilemaps are 32x32. The Game Boy's screen is 20x18. When copying tiles, understand that RGBDS or the Game Boy won't automatically jump to the next visible row after you've reached the 20th column.
255
255
@@ -279,7 +279,7 @@ Check out the Pan Docs for more info on the [Background viewport Y position, X p
279
279
280
280
Moving the window is the same as moving the background, except using the `$FF4B` and `$FF4A` registers. Hardware.inc defines two constants for that: `rWX` and `rWY`.
281
281
282
-
:::tip
282
+
:::tip
283
283
284
284
The window layer has a -7 pixel horizontal offset. This means setting `rWX` to 7 places the window at the left side of the screen, and setting `rWX` to 87 places the window with its left side halfway across the screen.
285
285
@@ -363,7 +363,7 @@ To wait **indefinitely** for a button press, create a loop where you:
363
363
- call the `UpdateKeys` function again
364
364
- Loop background to the beginning
365
365
366
-
:::tip
366
+
:::tip
367
367
368
368
This will halt all other logic (outside of interrupts), be careful if you need any logic running simultaneously.
369
369
@@ -396,7 +396,7 @@ Drawing text on the window is essentially drawing tiles (with letters/numbers/pu
396
396
397
397
To simplify the process you can define constant strings.
398
398
399
-
:::tip
399
+
:::tip
400
400
401
401
These constants end with a literal 255, which our code will read as the end of the string.
402
402
@@ -412,7 +412,7 @@ wScoreText:: db "score", 255
412
412
413
413
RGBDS has a character map functionality. You can read more in the [RGBDS Assembly Syntax Documentation](https://rgbds.gbdev.io/docs/rgbasm.5#DEFINING_DATA). This functionality, tells the compiler how to map each letter:
414
414
415
-
:::tip
415
+
:::tip
416
416
417
417
You need to have your text font tiles in VRAM at the locations specified in the map. See [How to put background/window tile data in VRAM](#how-to-put-backgroundwindow-tile-data-into-vram)
418
418
@@ -463,13 +463,13 @@ The above character mapping would convert (by the compiler) our `wScoreText` tex
463
463
464
464
With that setup, we would loop though the bytes of `wScoreText` and copy each byte to the background/window layer. After we copy each byte, we'll increment where we will copy to, and which byte in `wScoreText` we are reading. When we read 255, our code will end.
465
465
466
-
:::tip
466
+
:::tip
467
467
468
468
This example implies that your font tiles are located in VRAM at the locations specified in the character mapping.
469
469
470
470
:::
471
471
472
-
**Drawing 'score' on the window**
472
+
**Drawing 'score' on the window**
473
473
474
474
```rgbasm, lineno
475
475
@@ -503,7 +503,7 @@ DrawTextTilesLoop::
503
503
- Move the window downwards, so only 1 or 2 rows show at the bottom of the screen
504
504
- Draw your text, score, and icons on the top of the window layer.
505
505
506
-
:::tip
506
+
:::tip
507
507
508
508
Sprites will still show over the window. To fully prevent that, you can use STAT interrupts to hide sprites where the bottom HUD will be shown.
509
509
@@ -580,7 +580,7 @@ ld [_OAMRAM + 20], a
580
580
581
581
TODO - Explanation on limitations of direct OAM manipulation.
582
582
583
-
:::tip
583
+
:::tip
584
584
585
585
It's recommended that developers implement a shadow OAM, like @eievui5's [Sprite Object Library](https://github.com/eievui5/gb-sprobj-lib)
0 commit comments