diff options
-rw-r--r-- | FAQ.md | 13 | ||||
-rw-r--r-- | constants/collision_constants.asm | 14 | ||||
-rw-r--r-- | constants/radio_constants.asm | 2 | ||||
-rw-r--r-- | constants/script_constants.asm | 8 | ||||
-rw-r--r-- | data/collision_permissions.asm | 24 | ||||
-rw-r--r-- | data/maps/scenes.asm | 2 | ||||
-rw-r--r-- | engine/events/checkforhiddenitems.asm | 2 | ||||
-rw-r--r-- | engine/overworld/events.asm | 2 | ||||
-rw-r--r-- | engine/overworld/npc_movement.asm | 30 | ||||
-rw-r--r-- | home/map.asm | 86 | ||||
-rw-r--r-- | home/stone_queue.asm | 2 | ||||
-rw-r--r-- | hram.asm | 1 | ||||
-rw-r--r-- | macros/scripts/maps.asm | 2 | ||||
-rw-r--r-- | mobile/mobile_5f.asm | 2 |
14 files changed, 112 insertions, 78 deletions
@@ -42,7 +42,7 @@ If you are using 64-bit Windows, download [**64-bit Cygwin**][cygwin] and [**64- If you have not changed any of the asm, make sure you have the latest version of pokecrystal and the correct version of rgbds (see [INSTALL.md](INSTALL.md)). -If you added or changed any code, it has to fit in the **memory banks**. The 2MB ROM is divided into 128 banks of 4KB each, numbered $00 to $7F. The linkerscript **pokecrystal.link** lists which `SECTION`s go in which banks. Try moving some code into a new section. +If you added or changed any code, it has to fit in the **memory banks**. The 2MB ROM is divided into 128 banks of 4KB ($4000 bytes) each, numbered $00 to $7F. The linkerscript [pokecrystal.link](pokecrystal.link) lists which `SECTION`s go in which banks. Try moving some code into a new section. ### "Invalid file or object file version" @@ -57,12 +57,12 @@ If you added or changed any code, you've made a mistake while writing some of it ## How do I edit maps? -For `asm` scripts, read [docs/map_event_scripts.md](docs/map_event_scripts.md). For `blk` layouts, try [Polished Map][polished-map] or [crowdmap][crowdmap]. +For `asm` scripts, read [docs/map_event_scripts.md](docs/map_event_scripts.md). For `blk` layouts, use [Polished Map][polished-map]. ## How do I edit the colors of an image? -Most `.png` images are paletted PNGs. You can edit these with any program that supports creating PNGs with palette information. These palettes should consist of exactly 4 colors. Additionally, for Pokémon images, the first color should be white, and the last black. Tools such as Paint and [GIMP](https://www.gimp.org/) will do the right job, while other tools such as Photoshop might mess it up and output palettes of 255 colors even though only using 4. You may try using tools like [GraphicsGale](https://graphicsgale.com/us/) or [IrfanView](https://www.irfanview.com/) to fix this, or sometimes resaving the image in Paint seems to help. +Most `.png` images are paletted PNGs. You can edit these with any program that supports creating PNGs with palette information. These palettes should consist of exactly 4 colors. Additionally, for Pokémon images, the first color should be white, and the last black. Tools such as Paint and [GIMP](gimp) will do the right job, while other tools such as [paint.net](paintdotnet) or Photoshop might mess it up and output palettes of 255 colors even though only using 4. You may try using tools like [GraphicsGale](graphicsgale) or [IrfanView](irfanview) to fix this, or sometimes resaving the image in Paint seems to help. Some image `.png` files are greyscale. This indicates that even though these images do have proper colors in-game, they're shared with something else, and as such changing them will affect other things as well. Don't try opening the `.2bpp` files, these only contain the image data as well, not the palettes. @@ -81,6 +81,9 @@ Try asking on IRC or Discord (see [README.md](README.md)). [cygwin]: https://cygwin.com/install.html [rgbds]: https://github.com/rednex/rgbds/releases [polished-map]: https://github.com/Rangi42/polished-map -[crowdmap]: https://github.com/yenatch/crowdmap/ -[tutorials]: https://github.com/pret/pokecrystal/wiki/Tutorials +[gimp]: https://www.gimp.org/ +[paintdotnet]: https://www.getpaint.net/ +[graphicsgale]: https://graphicsgale.com/us/ +[irfanview]: https://www.irfanview.com/ [asm]: https://github.com/pret/pokecrystal/wiki/Assembly-programming +[tutorials]: https://github.com/pret/pokecrystal/wiki/Tutorials diff --git a/constants/collision_constants.asm b/constants/collision_constants.asm index b693dc8f8..f9724da60 100644 --- a/constants/collision_constants.asm +++ b/constants/collision_constants.asm @@ -102,6 +102,18 @@ COLL_RIGHT_WALL EQU $b0 COLL_LEFT_WALL EQU $b1 COLL_UP_WALL EQU $b2 COLL_DOWN_WALL EQU $b3 ; unused +COLL_DOWN_RIGHT_WALL EQU $b4 ; unused +COLL_DOWN_LEFT_WALL EQU $b5 ; unused +COLL_UP_RIGHT_WALL EQU $b6 ; unused +COLL_UP_LEFT_WALL EQU $b7 ; unused +COLL_RIGHT_BUOY EQU $c0 ; unused +COLL_LEFT_BUOY EQU $c1 ; unused +COLL_UP_BUOY EQU $c2 ; unused +COLL_DOWN_BUOY EQU $c3 ; unused +COLL_DOWN_RIGHT_BUOY EQU $c4 ; unused +COLL_DOWN_LEFT_BUOY EQU $c5 ; unused +COLL_UP_RIGHT_BUOY EQU $c6 ; unused +COLL_UP_LEFT_BUOY EQU $c7 ; unused COLL_FF EQU $ff ; garbage ; collision data type nybbles @@ -114,4 +126,4 @@ HI_NYBBLE_WALK_ALT EQU $50 HI_NYBBLE_WARPS EQU $70 HI_NYBBLE_LEDGES EQU $a0 HI_NYBBLE_SIDE_WALLS EQU $b0 -HI_NYBBLE_UNUSED_C0 EQU $c0 +HI_NYBBLE_SIDE_BUOYS EQU $c0 diff --git a/constants/radio_constants.asm b/constants/radio_constants.asm index 537b3289e..39eedbd84 100644 --- a/constants/radio_constants.asm +++ b/constants/radio_constants.asm @@ -2,7 +2,7 @@ ; indexes for: ; - RadioChannelSongs (see data/radio/channel_music.asm) ; - PlayRadioShow/RadioJumptable (see engine/pokegear/radio.asm) -; - RadioChannels (see engine/pokegear/radio.asm) +; - RadioChannels (see engine/pokegear/pokegear.asm) const_def const OAKS_POKEMON_TALK ; 00 const POKEDEX_SHOW ; 01 diff --git a/constants/script_constants.asm b/constants/script_constants.asm index 34f2bc864..91a519b8d 100644 --- a/constants/script_constants.asm +++ b/constants/script_constants.asm @@ -86,6 +86,14 @@ RETVAR_EXECUTE EQU (2 << 6) const PLAYEREVENT_JOYCHANGEFACING NUM_PLAYER_EVENTS EQU const_value +; script data sizes (see macros/scripts/maps.asm) +SCENE_SCRIPT_SIZE EQU 4 ; scene_script +CALLBACK_SIZE EQU 3 ; callback +WARP_EVENT_SIZE EQU 5 ; warp_event +COORD_EVENT_SIZE EQU 8 ; coord_event +BG_EVENT_SIZE EQU 5 ; bg_event +OBJECT_EVENT_SIZE EQU 13 ; object_event + ; bg_event types ; TryBGEvent arguments (see engine/overworld/events.asm) const_def diff --git a/data/collision_permissions.asm b/data/collision_permissions.asm index 2307ec98a..82ebb770a 100644 --- a/data/collision_permissions.asm +++ b/data/collision_permissions.asm @@ -183,10 +183,10 @@ TileCollisionTable:: NONTALKABLE LANDTILE ; COLL_LEFT_WALL NONTALKABLE LANDTILE ; COLL_UP_WALL NONTALKABLE LANDTILE ; COLL_DOWN_WALL - NONTALKABLE LANDTILE ; b4 - NONTALKABLE LANDTILE ; b5 - NONTALKABLE LANDTILE ; b6 - NONTALKABLE LANDTILE ; b7 + NONTALKABLE LANDTILE ; COLL_DOWN_RIGHT_WALL + NONTALKABLE LANDTILE ; COLL_DOWN_LEFT_WALL + NONTALKABLE LANDTILE ; COLL_UP_RIGHT_WALL + NONTALKABLE LANDTILE ; COLL_UP_LEFT_WALL NONTALKABLE LANDTILE ; b8 NONTALKABLE LANDTILE ; b9 NONTALKABLE LANDTILE ; ba @@ -195,14 +195,14 @@ TileCollisionTable:: NONTALKABLE LANDTILE ; bd NONTALKABLE LANDTILE ; be NONTALKABLE LANDTILE ; bf - NONTALKABLE WATERTILE ; c0 - NONTALKABLE WATERTILE ; c1 - NONTALKABLE WATERTILE ; c2 - NONTALKABLE WATERTILE ; c3 - NONTALKABLE WATERTILE ; c4 - NONTALKABLE WATERTILE ; c5 - NONTALKABLE WATERTILE ; c6 - NONTALKABLE WATERTILE ; c7 + NONTALKABLE WATERTILE ; COLL_RIGHT_BUOY + NONTALKABLE WATERTILE ; COLL_LEFT_BUOY + NONTALKABLE WATERTILE ; COLL_UP_BUOY + NONTALKABLE WATERTILE ; COLL_DOWN_BUOY + NONTALKABLE WATERTILE ; COLL_DOWN_RIGHT_BUOY + NONTALKABLE WATERTILE ; COLL_DOWN_LEFT_BUOY + NONTALKABLE WATERTILE ; COLL_UP_RIGHT_BUOY + NONTALKABLE WATERTILE ; COLL_UP_LEFT_BUOY NONTALKABLE WATERTILE ; c8 NONTALKABLE WATERTILE ; c9 NONTALKABLE WATERTILE ; ca diff --git a/data/maps/scenes.asm b/data/maps/scenes.asm index 9c820f9a6..0c8f6b750 100644 --- a/data/maps/scenes.asm +++ b/data/maps/scenes.asm @@ -84,4 +84,4 @@ MapScenes:: scene_var MOUNT_MOON_SQUARE, wMountMoonSquareSceneID scene_var MOBILE_TRADE_ROOM, wMobileTradeRoomSceneID scene_var MOBILE_BATTLE_ROOM, wMobileBattleRoomSceneID - db -1 + db -1 ; end diff --git a/engine/events/checkforhiddenitems.asm b/engine/events/checkforhiddenitems.asm index c0d31fe24..c71bd2905 100644 --- a/engine/events/checkforhiddenitems.asm +++ b/engine/events/checkforhiddenitems.asm @@ -60,7 +60,7 @@ CheckForHiddenItems: .next ; Restore the bg_event pointer and increment it by the length of a bg_event. pop hl - ld bc, 5 + ld bc, BG_EVENT_SIZE add hl, bc ; Restore the BG event counter and decrement it. If it hits zero, there are no hidden items in range. ld a, [wBuffer2] diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index ec81f1c27..fe2c51560 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -418,7 +418,7 @@ RunSceneScript: ld a, [hli] ld h, [hl] ld l, a -rept 4 +rept SCENE_SCRIPT_SIZE add hl, de endr diff --git a/engine/overworld/npc_movement.asm b/engine/overworld/npc_movement.asm index ffed4875b..d249d2fd4 100644 --- a/engine/overworld/npc_movement.asm +++ b/engine/overworld/npc_movement.asm @@ -114,7 +114,10 @@ WillObjectBumpIntoTile: ret .data_6f5b - db DOWN_MASK, UP_MASK, RIGHT_MASK, LEFT_MASK + db DOWN_MASK ; DOWN + db UP_MASK ; UP + db RIGHT_MASK ; LEFT + db LEFT_MASK ; RIGHT Function6f5f: ld hl, OBJECT_STANDING_TILE @@ -137,19 +140,22 @@ Function6f5f: ret .data_6f7b - db UP_MASK, DOWN_MASK, LEFT_MASK, RIGHT_MASK + db UP_MASK ; DOWN + db DOWN_MASK ; UP + db LEFT_MASK ; LEFT + db RIGHT_MASK ; RIGHT Function6f7f: ld d, a and $f0 cp HI_NYBBLE_SIDE_WALLS - jr z, .done - cp HI_NYBBLE_UNUSED_C0 - jr z, .done + jr z, .continue + cp HI_NYBBLE_SIDE_BUOYS + jr z, .continue xor a ret -.done +.continue ld a, d and 7 ld e, a @@ -161,8 +167,14 @@ Function6f7f: ret .data_6f99 - db 8, 4, 1, 2 - db 10, 6, 9, 5 + db RIGHT_MASK ; COLL_RIGHT_WALL/BUOY + db LEFT_MASK ; COLL_LEFT_WALL/BUOY + db DOWN_MASK ; COLL_UP_WALL/BUOY + db UP_MASK ; COLL_DOWN_WALL/BUOY + db UP_MASK | RIGHT_MASK ; COLL_DOWN_RIGHT_WALL/BUOY + db UP_MASK | LEFT_MASK ; COLL_DOWN_LEFT_WALL/BUOY + db DOWN_MASK | RIGHT_MASK ; COLL_UP_RIGHT_WALL/BUOY + db DOWN_MASK | LEFT_MASK ; COLL_UP_LEFT_WALL/BUOY Function6fa1: ld hl, OBJECT_DIRECTION_WALKING @@ -493,7 +505,7 @@ Unreferenced_Function7113: cp d jr nz, .check_current_coords ldh a, [hObjectStructIndexBuffer] - cp $0 + cp PLAYER_OBJECT jr z, .next jr .yes diff --git a/home/map.asm b/home/map.asm index 9af673f3d..6600cd7db 100644 --- a/home/map.asm +++ b/home/map.asm @@ -46,8 +46,8 @@ GetCurrentMapSceneID:: ret GetMapSceneID:: -; Searches the scene script table for the map group and number loaded in bc, and returns the wram pointer in de. -; If the map is not in the scene script table, returns carry. +; Searches the scene_var table for the map group and number loaded in bc, and returns the wram pointer in de. +; If the map is not in the scene_var table, returns carry. push bc ldh a, [hROMBank] push af @@ -59,7 +59,7 @@ GetMapSceneID:: push hl ld a, [hli] ; map group, or terminator cp -1 - jr z, .end ; the current map is not in the scene script table + jr z, .end ; the current map is not in the scene_var table cp b jr nz, .next ; map group did not match ld a, [hli] ; map number @@ -69,7 +69,7 @@ GetMapSceneID:: .next pop hl - ld de, 4 ; scene_script size + ld de, 4 ; scene_var size add hl, de jr .loop @@ -275,7 +275,7 @@ GetDestinationWarpNumber:: .next pop hl - ld a, 5 + ld a, WARP_EVENT_SIZE add l ld l, a jr nc, .okay @@ -325,7 +325,7 @@ CopyWarpData:: ld l, a ld a, c dec a - ld bc, 5 ; warp size + ld bc, WARP_EVENT_SIZE call AddNTimes ld bc, 2 ; warp number add hl, bc @@ -487,7 +487,7 @@ GetMapConnection:: ret ReadMapSceneScripts:: - ld a, [hli] ; scene script count + ld a, [hli] ; scene_script count ld c, a ld [wCurMapSceneScriptCount], a ld a, l @@ -498,7 +498,7 @@ ReadMapSceneScripts:: and a ret z - ld bc, 4 ; scene_script size + ld bc, SCENE_SCRIPT_SIZE call AddNTimes ret @@ -514,7 +514,7 @@ ReadMapCallbacks:: and a ret z - ld bc, 3 + ld bc, CALLBACK_SIZE call AddNTimes ret @@ -529,7 +529,7 @@ ReadWarps:: ld a, c and a ret z - ld bc, 5 + ld bc, WARP_EVENT_SIZE call AddNTimes ret @@ -546,7 +546,7 @@ ReadCoordEvents:: and a ret z - ld bc, 8 + ld bc, COORD_EVENT_SIZE call AddNTimes ret @@ -563,7 +563,7 @@ ReadBGEvents:: and a ret z - ld bc, 5 + ld bc, BG_EVENT_SIZE call AddNTimes ret @@ -622,7 +622,7 @@ CopyMapObjectEvents:: push hl ld a, $ff ld [hli], a - ld b, MAPOBJECT_E - MAPOBJECT_SPRITE + ld b, OBJECT_EVENT_SIZE .loop2 ld a, [de] inc de @@ -664,14 +664,14 @@ RestoreFacingAfterWarp:: ld a, [hli] ld h, [hl] ld l, a - inc hl ; get to the warp coords - inc hl ; get to the warp coords - inc hl ; get to the warp coords +rept 3 ; get to the warp coords + inc hl +endr ld a, [wWarpNumber] dec a ld c, a ld b, 0 - ld a, 5 + ld a, WARP_EVENT_SIZE call AddNTimes ld a, [hli] ld [wYCoord], a @@ -981,7 +981,7 @@ RunMapCallback:: ld l, a or h ret z - ld de, 3 + ld de, CALLBACK_SIZE .loop ld a, [hl] cp b @@ -1261,7 +1261,7 @@ UpdateBGMapRow:: push de call .iteration pop de - ld a, $20 + ld a, BG_MAP_WIDTH add e ld e, a @@ -1295,7 +1295,7 @@ UpdateBGMapColumn:: ld [hli], a ld a, d ld [hli], a - ld a, $20 + ld a, BG_MAP_WIDTH add e ld e, a jr nc, .skip @@ -1344,11 +1344,11 @@ LoadTilesetGFX:: ldh a, [rVBK] push af - ld a, $1 + ld a, BANK(vTiles5) ldh [rVBK], a ld hl, wDecompressScratch + $60 tiles - ld de, vTiles2 + ld de, vTiles5 ld bc, $60 tiles call CopyBytes @@ -1573,12 +1573,12 @@ GetMovementPermissions:: call .CheckHiNybble ret nz ld a, [wTileDown] - and 7 - cp $2 + and %111 + cp COLL_UP_WALL & %111 ; COLL_UP_BUOY & %111 jr z, .ok_down - cp $6 + cp COLL_UP_RIGHT_WALL & %111 ; COLL_UP_RIGHT_BUOY & %111 jr z, .ok_down - cp $7 + cp COLL_UP_LEFT_WALL & %111 ; COLL_UP_LEFT_BUOY & %111 ret nz .ok_down @@ -1591,12 +1591,12 @@ GetMovementPermissions:: call .CheckHiNybble ret nz ld a, [wTileUp] - and 7 - cp $3 + and %111 + cp COLL_DOWN_WALL & %111 ; COLL_DOWN_BUOY & %111 jr z, .ok_up - cp $4 + cp COLL_DOWN_RIGHT_WALL & %111 ; COLL_DOWN_RIGHT_BUOY & %111 jr z, .ok_up - cp $5 + cp COLL_DOWN_LEFT_WALL & %111 ; COLL_DOWN_LEFT_BUOY & %111 ret nz .ok_up @@ -1609,12 +1609,12 @@ GetMovementPermissions:: call .CheckHiNybble ret nz ld a, [wTileRight] - and 7 - cp $1 + and %111 + cp COLL_LEFT_WALL & %111 ; COLL_LEFT_BUOY & %111 jr z, .ok_right - cp $5 + cp COLL_DOWN_LEFT_WALL & %111 ; COLL_DOWN_LEFT_BUOY & %111 jr z, .ok_right - cp $7 + cp COLL_UP_LEFT_WALL & %111 ; COLL_UP_LEFT_BUOY & %111 ret nz .ok_right @@ -1627,12 +1627,12 @@ GetMovementPermissions:: call .CheckHiNybble ret nz ld a, [wTileLeft] - and 7 - cp $0 + and %111 + cp COLL_RIGHT_WALL & %111 ; COLL_RIGHT_BUOY & %111 jr z, .ok_left - cp $4 + cp COLL_DOWN_RIGHT_WALL & %111 ; COLL_DOWN_RIGHT_BUOY & %111 jr z, .ok_left - cp $6 + cp COLL_UP_RIGHT_WALL & %111 ; COLL_UP_RIGHT_BUOY & %111 ret nz .ok_left @@ -1645,7 +1645,7 @@ GetMovementPermissions:: and $f0 cp HI_NYBBLE_SIDE_WALLS ret z - cp HI_NYBBLE_UNUSED_C0 + cp HI_NYBBLE_SIDE_BUOYS ret GetFacingTileCoord:: @@ -1799,7 +1799,7 @@ CheckIfFacingTileCoordIsBGEvent:: .next pop hl - ld a, 5 ; BG event event length + ld a, BG_EVENT_SIZE add l ld l, a jr nc, .nocarry @@ -1814,7 +1814,7 @@ CheckIfFacingTileCoordIsBGEvent:: .copysign pop hl ld de, wCurBGEventYCoord - ld bc, 5 ; BG event event length + ld bc, BG_EVENT_SIZE call CopyBytes scf ret @@ -1871,7 +1871,7 @@ CheckCurrentMapCoordEvents:: .next pop hl - ld a, $8 ; coord event size + ld a, COORD_EVENT_SIZE add l ld l, a jr nc, .nocarry @@ -1886,7 +1886,7 @@ CheckCurrentMapCoordEvents:: .copy_coord_event pop hl ld de, wCurCoordEventSceneID - ld bc, 8 ; coord event size + ld bc, COORD_EVENT_SIZE call CopyBytes scf ret diff --git a/home/stone_queue.asm b/home/stone_queue.asm index b32fc10bd..482299d9c 100644 --- a/home/stone_queue.asm +++ b/home/stone_queue.asm @@ -76,7 +76,7 @@ HandleStoneQueue:: jr .found_warp .not_on_warp - ld a, 5 + ld a, WARP_EVENT_SIZE add l ld l, a jr nc, .no_carry @@ -160,4 +160,3 @@ hDMATransfer:: db ; ffe8 hMobile:: db ; ffe9 hSystemBooted:: db ; ffea hClockResetTrigger:: db ; ffeb -hFFEC:: db ; ffec diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm index 7f5947a55..1dd8a4ce8 100644 --- a/macros/scripts/maps.asm +++ b/macros/scripts/maps.asm @@ -32,7 +32,7 @@ coord_event: MACRO db \3, \2, \1 db 0 ; filler dw \4 - db 0, 0 ; filler + dw 0 ; filler ENDM bg_event: MACRO diff --git a/mobile/mobile_5f.asm b/mobile/mobile_5f.asm index a2668fa89..d36daca91 100644 --- a/mobile/mobile_5f.asm +++ b/mobile/mobile_5f.asm @@ -3286,7 +3286,7 @@ Function17e5af: ld h, a bccoord 0, 0 add hl, bc - ld bc, hFFEC + ld bc, $ffec add hl, bc ld a, [wMobileInactivityTimerSeconds] ld c, a |