diff options
author | Idain <luiscarlosholguinperez@outlook.com> | 2021-12-08 21:57:12 -0400 |
---|---|---|
committer | Idain <luiscarlosholguinperez@outlook.com> | 2021-12-08 21:57:12 -0400 |
commit | 8ebcff800da173bdda73d076babb5603dd3d4e89 (patch) | |
tree | 98bf6e7097315476fb8e83634000cc36470938f5 | |
parent | b80d68f0c8268af97c335e4aa49937b124cae0d4 (diff) |
Add new step to edit SGB roof colors and avoid assembly errors
-rw-r--r-- | Add-a-new-map-and-landmark.md | 84 |
1 files changed, 68 insertions, 16 deletions
diff --git a/Add-a-new-map-and-landmark.md b/Add-a-new-map-and-landmark.md index 0071ab1..6e9f987 100644 --- a/Add-a-new-map-and-landmark.md +++ b/Add-a-new-map-and-landmark.md @@ -12,10 +12,11 @@ This tutorial is for how to add a new map and a new landmark. As an example, we' - [Outdoor sprite set](#outdoor-sprite-set) 5. [Define its properties](#5-define-its-properties) 6. [Define its attributes](#6-define-its-attributes) -7. [Define any new landmarks](#7-define-any-new-landmarks) -8. [Write its event scripts](#8-write-its-event-scripts) -9. [Include the block and script data](#9-include-the-block-and-script-data) -10. [Common mistakes](#10-common-mistakes) +7. [Define its SGB roof palettes](#7-define-its-sgb-roof-palettes) +8. [Define any new landmarks](#8-define-any-new-landmarks) +9. [Write its event scripts](#9-write-its-event-scripts) +10. [Include the block and script data](#10-include-the-block-and-script-data) +11. [Common mistakes](#11-common-mistakes) - [Cave entrance/exit warp doesn't work](#cave-entranceexit-warp-doesnt-work) @@ -81,22 +82,25 @@ Edit [constants/map_constants.asm](../blob/master/constants/map_constants.asm): ; - scripts and events (see data/maps/scripts.asm) const_def - newgroup ; 1 - + newgroup OLIVINE ; 1 map_const OLIVINE_POKECENTER_1F, 5, 4 ; 1 ... + endgroup ... - newgroup ; 26 - + newgroup CHERRYGROVE ; 26 map_const ROUTE_30, 10, 27 ; 1 ... + endgroup -+ newgroup -+ -+ map_const GLOBAL_TERMINAL_OUTSIDE, 10, 13 -+ map_const GLOBAL_TERMINAL_1F, 9, 6 ++ newgroup GLOBAL_TERMINAL ; 27 ++ map_const GLOBAL_TERMINAL_OUTSIDE, 10, 13 ; 1 ++ map_const GLOBAL_TERMINAL_1F, 9, 6 ; 2 ++ endgroup + +-NUM_MAP_GROUPS EQU const_value ; 26 ++NUM_MAP_GROUPS EQU const_value ; 27 ``` Map constants have two parts: the group ID and the map ID. Groups are significant for outdoor maps because they share a roof palette and an outdoor sprite set (more on those later). For indoor maps, groups don't really matter, but they're usually grouped with their corresponding outdoor maps for the sake of organization. @@ -135,6 +139,7 @@ Edit [data/maps/roofs.asm](../blob/master/data/maps/roofs.asm): ... db ROOF_NEW_BARK ; 26 (Cherrygrove) + db ROOF_GOLDENROD ; 27 (Global Terminal) + assert_table_length NUM_MAP_GROUPS + 1 ``` Roof tiles, like all graphics, are only loaded when you warp to a map. Walking across map connections, like from Route 34 to Goldenrod City, will not reload graphics. So if two maps are connected, even if they're in different groups, their roof types have to match. We're going to connect the Global Terminal to Goldenrod City's west edge later, so it has to use the same roof type. @@ -184,6 +189,7 @@ Edit [data/maps/outdoor_sprites.asm](../blob/master/data/maps/outdoor_sprites.as ... dw CherrygroveGroupSprites + dw GlobalTerminalSprites + assert_table_length NUM_MAP_GROUPS ... @@ -269,12 +275,14 @@ Edit [data/maps/maps.asm](../blob/master/data/maps/maps.asm): ... dw MapGroup_Cherrygrove ; 26 + dw MapGroup_GlobalTerminal ; 27 + assert_table_length NUM_MAP_GROUPS ... +MapGroup_GlobalTerminal: + map GlobalTerminalOutside, TILESET_JOHTO_MODERN, ROUTE, LANDMARK_GOLDENROD_CITY, MUSIC_GOLDENROD_CITY, FALSE, PALETTE_AUTO, FISHGROUP_SHORE + map GlobalTerminal1F, TILESET_RADIO_TOWER, INDOOR, GLOBAL_TERMINAL, MUSIC_GOLDENROD_CITY, FALSE, PALETTE_DAY, FISHGROUP_SHORE + assert_table_length NUM_GLOBAL_TERMINAL_MAPS ``` The `map` macro defines these different properties: @@ -330,7 +338,50 @@ If the offset isn't clear, try comparing screenshots of other maps with their ow (Before November 10, 2018, the `connection` macro took six parameters; instead of a single sideways offset, you had to specify a target offset, source offset, and strip length, which were confusing and harder to calculate. The current macro definition has legacy support for the old one, since in all of the official maps, sideways offset = target offset − source offset, with the strip length being completely redundant. I strongly recommend porting the new macro to any old pokecrystal projects.) -## 7. Define any new landmarks +## 7. Define its SGB roof palettes + +Even though Pokémon Crystal isn't compatible with the Super Game Boy, there's a table defining roof palettes for this mode and if we don't edit it then we'll get assembly errors when building the ROM, so we need to add the corresponding constant and define its colors. + +First, let's edit [data/maps/sgb_roof_pal_inds.asm](../blob/master/data/maps/sgb_roof_pal_inds.asm): + +```diff + MapGroupRoofSGBPalInds: + ; entries correspond to map groups + table_width 1, MapGroupRoofSGBPalInds + db PREDEFPAL_ROUTES + ... + db PREDEFPAL_CHERRYGROVE ++ db PREDEFPAL_GLOBAL_TERMINAL + assert_table_length NUM_MAP_GROUPS + 1 +``` + +We've put `PREDEFPAL_GLOBAL_TERMINAL` in the list, but the constant hasn't been defined yet. Let's create it in [constants/sgb_constants.asm](../blob/master/constants/sgb_constants.asm): + +```diff + ; PredefPals indexes (see gfx/sgb/predef.pal) + ; GetPredefPal arguments (see engine/gfx/color.asm) + const_def + const PREDEFPAL_ROUTES + ... + const PREDEFPAL_DUNGEONS ++ const PREDEFPAL_GLOBAL_TERMINAL + const PREDEFPAL_NITE + ... +``` + +Now the only thing left is to define the colors associated to it. Since which colors we choose really don't matter (again, the SGB mode can't be accesed) let's take the ones from Goldenrod City and edit [gfx/sgb/predef.pal](../blob/master/gfx/sgb/predef.pal): + +```diff + RGB 31,31,31, 22,25,19, 16,21,30, 00,00,00 ; PREDEFPAL_ROUTES + ... + RGB 31,31,31, 21,14,09, 15,20,20, 00,00,00 ; PREDEFPAL_DUNGEONS ++ RGB 31,31,31, 29,26,18, 15,20,31, 00,00,00 ; PREDEFPAL_GLOBAL_TERMINAL + RGB 31,31,31, 12,28,22, 15,20,20, 00,00,00 ; PREDEFPAL_NITE + ... +``` + + +## 8. Define any new landmarks If you don't need any new landmarks, skip this step. @@ -365,6 +416,7 @@ Now edit [data/maps/landmarks.asm](../blob/master/data/maps/landmarks.asm): landmark 52, 76, Route35Name ... landmark 140, 116, FastShipName + assert_table_length NUM_LANDMARKS NewBarkTownName: db "NEW BARK¯TOWN@" ... @@ -377,7 +429,7 @@ The two numbers passed to the `landmark` macro are the X and Y coordinates on th Note the use of "¯" in some landmark names. That character gets treated as a line break in the Town Map, but as a space in pop-up location name signs. -## 8. Write its event scripts +## 9. Write its event scripts Create **maps/GlobalTerminalOutside.asm**: @@ -439,7 +491,7 @@ You'll probably want a variety of NPCs in the Global Terminal, some from regions Note that before August 2020, maps did not have `def_*` macros, so they had to manually declare their quantities of `scene_script`s, `callback`s, `warp_event`s, etc. So instead of `def_warp_events`, you would have `db 1` or `db 2`, depending on how many `warp_event`s the map has. If any of those `db` values were wrong, the map could glitch or crash when you enter it. -## 9. Include the block and script data +## 10. Include the block and script data We created some new files in maps/, but they aren't `INCLUDE`d in the project yet. @@ -473,7 +525,7 @@ Anyway, we're done!  -## 10. Common mistakes +## 11. Common mistakes ...Well, hopefully we're done. You may be having issues with some aspects of new maps. Here are some common ones and their fixes. |