From 7d6d25c5e9fec563592cf6e910fcb118cf10dd5d Mon Sep 17 00:00:00 2001 From: Antonio Vivace Date: Wed, 29 Nov 2023 10:52:07 +0100 Subject: [PATCH 01/11] Update src/cheatsheet.md Co-authored-by: Evie <14899090+eievui5@users.noreply.github.com> --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 13ebaece..833f7d97 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -206,7 +206,7 @@ ldh [rLCDC], a ### Put background/window tile data into VRAM -The region in VRAM dedicated for the background/window tilemaps is from $9000 to $97F0. Hardware.inc defines a `_VRAM9000` constant you can use for that. To copy background or window tile data into VRAM, you can use a loop to copy the bytes. +The region in VRAM dedicated for the background/window tilemaps is from $9000 to $97FF. hardware.inc defines a `_VRAM9000` constant you can use for that. myBackground: INCBIN "src/path/to/my/my-background.2bpp" myBackgroundEnd: From 74ee7ef3c7d19145b83895a8c73807e9a98df8aa Mon Sep 17 00:00:00 2001 From: Antonio Vivace Date: Wed, 29 Nov 2023 10:52:19 +0100 Subject: [PATCH 02/11] Update src/cheatsheet.md Co-authored-by: Evie <14899090+eievui5@users.noreply.github.com> --- src/cheatsheet.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 833f7d97..6dac91f2 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -208,22 +208,23 @@ ldh [rLCDC], a The region in VRAM dedicated for the background/window tilemaps is from $9000 to $97FF. hardware.inc defines a `_VRAM9000` constant you can use for that. -myBackground: INCBIN "src/path/to/my/my-background.2bpp" -myBackgroundEnd: +MyBackground: + INCBIN "src/path/to/my-background.2bpp" +.end CopyBackgroundWindowTileDataIntoVram: -; Copy the tile data -ld de, myBackground -ld hl, \_VRAM -ld bc, myBackgroundEnd - myBackground -CopyBackgroundWindowTileDataIntoVram_Loop: -ld a, [de] -ld [hli], a -inc de -dec bc -ld a, b -or a, c -jp nz, CopyBackgroundWindowTileDataIntoVram_Loop + ; Copy the tile data + ld de, myBackground + ld hl, \_VRAM + ld bc, MyBackground.end - MyBackground +.loop: + ld a, [de] + ld [hli], a + inc de + dec bc + ld a, b + or a, c + jr nz, .Loop ### Draw on the Background/Window From 40501fbc0c30a99c01ff522c1fc963fdf72b49be Mon Sep 17 00:00:00 2001 From: Antonio Vivace Date: Wed, 29 Nov 2023 10:52:42 +0100 Subject: [PATCH 03/11] Update src/cheatsheet.md Co-authored-by: Evie <14899090+eievui5@users.noreply.github.com> --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 6dac91f2..1fe073ce 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -33,7 +33,7 @@ Is there something common you think is missing? Check the [github repository](ht - [Put sprite tile data in VRAM](#put-sprite-tile-data-in-vram) - [Manipulate hardware OAM sprites](#manipulate-hardware-oam-sprites) - [Iimplement a Shadow OAM using @eievue5's Sprite Object Library](#iimplement-a-shadow-oam-using-eievue5s-sprite-object-library) - - [Manipulate Shadow OAM OAM sprites](#manipulate-shadow-oam-oam-sprites) + - [Manipulate shadow OAM sprites](#manipulate-shadow-oam-sprites) - [Micelaneous](#micelaneous) - [Save Data](#save-data) - [Generate random numbers](#generate-random-numbers) From 73f8476018e56e23297f5ed9cc85c47146bfaf10 Mon Sep 17 00:00:00 2001 From: Antonio Vivace Date: Wed, 29 Nov 2023 16:21:06 +0100 Subject: [PATCH 04/11] Update src/cheatsheet.md Co-authored-by: Evie <14899090+eievui5@users.noreply.github.com> --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 1fe073ce..210c9dfd 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -187,7 +187,7 @@ Sprites by default are in 8x8 mode. ### Enable tall (8x16) sprites -Once sprites are enabled, you can enable tall sprites using the third least signficiant bit of the `rLCDC` register: `LCDCF_OBJ16` +Once sprites are enabled, you can enable tall sprites using the 3rd bit of the `rLCDC` register: `LCDCF_OBJ16` ::: tip From 9dcaceef12062f293a56a850663dcf2d4f237fad Mon Sep 17 00:00:00 2001 From: Antonio Vivace Date: Wed, 29 Nov 2023 16:22:18 +0100 Subject: [PATCH 05/11] Apply suggestions from evie's code review Co-authored-by: Evie <14899090+eievui5@users.noreply.github.com> --- src/cheatsheet.md | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 210c9dfd..0ba84b7b 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -32,25 +32,24 @@ Is there something common you think is missing? Check the [github repository](ht - [Sprites](#sprites) - [Put sprite tile data in VRAM](#put-sprite-tile-data-in-vram) - [Manipulate hardware OAM sprites](#manipulate-hardware-oam-sprites) - - [Iimplement a Shadow OAM using @eievue5's Sprite Object Library](#iimplement-a-shadow-oam-using-eievue5s-sprite-object-library) + - [Implement shadow OAM using Evie's Sprite Object Library](#implement-shadow-oam-using-evies-sprite-object-library) - [Manipulate shadow OAM sprites](#manipulate-shadow-oam-sprites) -- [Micelaneous](#micelaneous) - - [Save Data](#save-data) +- [Miscellaneous](#miscellaneous) + - [Save data](#save-data) - [Generate random numbers](#generate-random-numbers) ## Display -The `$FF40` register controls all of the following: +The `rLCDC` register controls all of the following: -- The LCD display -- the background -- the window -- sprites -- tall sprites +- The screen +- The background +- The window +- Sprite objects -In hardware.inc, you can find a constant for that register: `rLCDC`. For more information on LCD control, refer to the [Pan Docs](https://gbdev.io/pandocs/LCDC.html) +For more information on LCD control, refer to the [Pan Docs](https://gbdev.io/pandocs/LCDC.html) -### Wait for the vertical blank phase +### Wait for VBlank To check for the vertical blank phase, use the `rLY` register. Compare that register's value against the height of the Game Boy screen in pixels: 144. @@ -69,7 +68,7 @@ To wait until the vertical blank phase is finished, you would use a code-snippet ### Turn on/off the LCD Display -You can turn the LCD on and off by altering the most significant bit controls the state of the `rLCDC` register. Hardware.inc also has constants for this: `LCDCF_ON` and `LCDCF_OFF`. +You can turn the LCD on and off by altering the most significant bit of the `rLCDC` register. hardware.inc has constants for this: `LCDCF_ON` and `LCDCF_OFF`. **To turn the LCD on:** @@ -96,16 +95,16 @@ ldh [rLCDC], a To turn the background layer on and off, alter the least significant bit of the `rLCDC` register. You can use the `LCDCF_BGON` and `LCDCF_BGOFF` constants for this. -**To turn the Background on:** +**To turn the background on:** ```rgbasm,linenos ; Turn the background on -ld a, [rLCDC] +ldh a, [rLCDC] or a, LCDCF_BGON ldh [rLCDC], a ``` -**To turn the Background off:** +**To turn the background off:** ```rgbasm,linenos ; Turn the background off @@ -118,7 +117,7 @@ ldh [rLCDC], a To turn the window layer on and off, alter the least significant bit of the `rLCDC` register. You can use the `LCDCF_WINON` and `LCDCF_WINOFF` constants for this. -**To turn the Window on:** +**To turn the window on:** ```rgbasm,linenos ; Turn the window on @@ -127,7 +126,7 @@ or a, LCDCF_WINON ldh [rLCDC], a ``` -**To turn the Window off:** +**To turn the window off:** ```rgbasm,linenos ; Turn the window off @@ -140,11 +139,11 @@ ldh [rLCDC], a By default, the window and background layer will use the same tilemap. That is, any tiles you draw on the background will be mirrored on the window and vice versa. -For the window and background, there are 2 memory spaces they can use: `$9800` and `$9C00`. For more information, refer to the [Pan Docs](https://gbdev.io/pandocs/Tile_Maps.html) +For the window and background, there are 2 memory regions they can use: `$9800` and `$9C00`. For more information, refer to the [Pan Docs](https://gbdev.io/pandocs/Tile_Maps.html) -Which space the background uses is controled by the fourth **least** significant bit of the `rLCDC` register. Which page the window uses is controlled by the 2 **most** significant bit. +Which region the background uses is controlled by the 4th bit of the `rLCDC` register. Which region the window uses is controlled by the 7th bit. -You can use one of the 4 constants to specify which layer uses which space: +You can use one of the 4 constants to specify which layer uses which region: - LCDCF_WIN9800 - LCDCF_WIN9C00 @@ -159,9 +158,9 @@ You still need to make sure the window and background are turned on when using t ### Turn on/off sprites -Sprites (or objects) can be toggled on and off using the second least significant bit of the `rLCDC` register. You can use the `LCDCF_OBJON` and `LCDCF_OBJOFF` constants for this. +Sprites (or objects) can be toggled on and off using the 2nd bit of the `rLCDC` register. You can use the `LCDCF_OBJON` and `LCDCF_OBJOFF` constants for this. -**To turn the Sprites On:** +**To turn sprite objects on:** ```rgbasm,linenos ; Turn the sprites on @@ -170,7 +169,7 @@ or a, LCDCF_OBJON ldh [rLCDC], a ``` -**To turn the Sprites Off:** +**To turn sprite objects off:** ```rgbasm,linenos ; Turn the sprites off @@ -181,7 +180,7 @@ ldh [rLCDC], a ::: tip -Sprites by default are in 8x8 mode. +Sprites are in 8x8 mode by default. ::: From 6491d3f14e009da52e36edb9632cd609f0a16d55 Mon Sep 17 00:00:00 2001 From: Larold Date: Fri, 16 Feb 2024 13:49:11 -0500 Subject: [PATCH 06/11] Update src/cheatsheet.md Co-authored-by: Quinn <3379314+quinnyo@users.noreply.github.com> --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 0ba84b7b..77075db9 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -108,7 +108,7 @@ ldh [rLCDC], a ```rgbasm,linenos ; Turn the background off -ld a, [rLCDC] +ldh a, [rLCDC] and a, LCDCF_BGOFF ldh [rLCDC], a ``` From 33920617dc61882cb9581bccdc6db96317ef22af Mon Sep 17 00:00:00 2001 From: Larold Date: Fri, 16 Feb 2024 13:50:11 -0500 Subject: [PATCH 07/11] Update src/cheatsheet.md Co-authored-by: Eldred Habert --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 77075db9..57787db6 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -109,7 +109,7 @@ ldh [rLCDC], a ```rgbasm,linenos ; Turn the background off ldh a, [rLCDC] -and a, LCDCF_BGOFF +and a, ~LCDCF_BGON ldh [rLCDC], a ``` From 07f26033b47ba81d2bd1f45901c611cf45fcef10 Mon Sep 17 00:00:00 2001 From: Larold Date: Fri, 16 Feb 2024 13:51:20 -0500 Subject: [PATCH 08/11] Update src/cheatsheet.md Co-authored-by: Quinn <3379314+quinnyo@users.noreply.github.com> --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 57787db6..b3acfad1 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -164,7 +164,7 @@ Sprites (or objects) can be toggled on and off using the 2nd bit of the `rLCDC` ```rgbasm,linenos ; Turn the sprites on -ld a, [rLCDC] +ldh a, [rLCDC] or a, LCDCF_OBJON ldh [rLCDC], a ``` From 67cf139b3ece0e39f437c5dc041c681c17c8bfb8 Mon Sep 17 00:00:00 2001 From: Larold Date: Fri, 16 Feb 2024 13:51:34 -0500 Subject: [PATCH 09/11] Update src/cheatsheet.md Co-authored-by: Quinn <3379314+quinnyo@users.noreply.github.com> --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index b3acfad1..e9b41663 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -130,7 +130,7 @@ ldh [rLCDC], a ```rgbasm,linenos ; Turn the window off -ld a, [rLCDC] +ldh a, [rLCDC] and a, LCDCF_WINOFF ldh [rLCDC], a ``` From 117139f20400ee0e687cc586d8d128382ed73f6c Mon Sep 17 00:00:00 2001 From: Larold Date: Fri, 16 Feb 2024 13:51:46 -0500 Subject: [PATCH 10/11] Update src/cheatsheet.md Co-authored-by: Quinn <3379314+quinnyo@users.noreply.github.com> --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index e9b41663..9915bab3 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -55,7 +55,7 @@ To check for the vertical blank phase, use the `rLY` register. Compare that regi ```rgbasm,linenos WaitUntilVerticalBlankStart: - ld a, [rLY] + ldh a, [rLY] cp 144 jp c, WaitUntilVerticalBlankStart ``` From 61f0b643d77e114beb796c507f5275370f0a0f02 Mon Sep 17 00:00:00 2001 From: Larold Date: Fri, 16 Feb 2024 13:53:27 -0500 Subject: [PATCH 11/11] Update src/cheatsheet.md Co-authored-by: Quinn <3379314+quinnyo@users.noreply.github.com> --- src/cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cheatsheet.md b/src/cheatsheet.md index 9915bab3..3e5b1b9c 100644 --- a/src/cheatsheet.md +++ b/src/cheatsheet.md @@ -121,7 +121,7 @@ To turn the window layer on and off, alter the least significant bit of the `rLC ```rgbasm,linenos ; Turn the window on -ld a, [rLCDC] +ldh a, [rLCDC] or a, LCDCF_WINON ldh [rLCDC], a ```