diff options
| author | ISSOtm <eldredhabert0@gmail.com> | 2018-06-10 14:20:59 +0200 |
|---|---|---|
| committer | ISSOtm <eldredhabert0@gmail.com> | 2018-06-10 14:20:59 +0200 |
| commit | d89bd1ac8b1304313bae285ada7d24601cf67d09 (patch) | |
| tree | 7d83ac3340a0535aa85269e7247008164f9b8d7d /home | |
| parent | b136e995a3b22a674c44241a68365d8b1152cb8b (diff) | |
Merge branch 'math_etc' into 'master'
Diffstat (limited to 'home')
| -rw-r--r-- | home/map.asm | 4 | ||||
| -rw-r--r-- | home/map_objects.asm | 676 | ||||
| -rw-r--r-- | home/math.asm | 25 | ||||
| -rw-r--r-- | home/menu.asm | 8 | ||||
| -rw-r--r-- | home/menu_window.asm | 246 | ||||
| -rw-r--r-- | home/misc_32c8.asm | 98 | ||||
| -rw-r--r-- | home/mon_stats.asm | 82 | ||||
| -rw-r--r-- | home/print_text.asm | 21 | ||||
| -rw-r--r-- | home/scrolling_menu.asm | 93 | ||||
| -rw-r--r-- | home/tilemap.asm | 70 | ||||
| -rw-r--r-- | home/unknown_388f.asm | 101 | ||||
| -rw-r--r-- | home/util.asm | 85 |
12 files changed, 1499 insertions, 10 deletions
diff --git a/home/map.asm b/home/map.asm index 7244fb1..b8ddee5 100644 --- a/home/map.asm +++ b/home/map.asm @@ -888,8 +888,8 @@ ReadObjectEvents:: ; 268f ClearObjectStructs:: ; 26cf xor a - ld [$CE7F], a ; TODO - ld hl, wObject1Struct + ld [wUnkObjectStruct], a ; TODO + ld hl, wObject2Struct ld de, wObject2Struct - wObject1Struct ld c, 7 .clear_struct diff --git a/home/map_objects.asm b/home/map_objects.asm new file mode 100644 index 0000000..70cba50 --- /dev/null +++ b/home/map_objects.asm @@ -0,0 +1,676 @@ +include "constants.asm" + +SECTION "Map Object Related Functions", ROM0 [$15b5] + +Function15b5:: ; 15b5 + callab Function8000 + ret + +GetMapObject:: ; 00:15be + ld hl, wMapObjects + ld bc, MAP_OBJECT_LENGTH + call AddNTimes + ld b, h + ld c, l + ret + +GetMapObjectAttrPtr:: ; 15ca + call GetMapObject + ld d, $0 + add hl, de + ret + +Function15d1:: ; 15d1 + ldh [hMapObjectIndexBuffer], a + call GetMapObject + call Function40eb + ret + +Function15da:: + ldh [hMapObjectIndexBuffer], a + callab Function8131 + ldh a, [hMapObjectIndexBuffer] + call GetMapObject + call Function40eb + ret + +Function15ed:: + ldh [hMapObjectIndexBuffer], a + call GetMapObject + ld a, $0 + ldh [hObjectStructIndexBuffer], a + ld de, wObjectStructs + callab Function813d + ret + +Function1602:: + ldh [hMapObjectIndexBuffer], a + call GetMapObject + ld a, $2 + ldh [hObjectStructIndexBuffer], a + ld de, wObject1Struct + callab Function813d + ret + +Function1617:: ; 00:1617 + ldh [hMapObjectIndexBuffer], a + call GetMapObject + ld hl, MAPOBJECT_OBJECT_STRUCT_ID + add hl, bc + ld a, [hl] + cp $ff + ret z + ld [hl], $ff + push af + ld d, a + ld a, [wObjectFollow_Leader] + cp d + jr nz, .asm_1633 + ld a, $ff + ld [wObjectFollow_Leader], a +.asm_1633: ; 00:1633 + ld a, [wObjectFollow_Follower] + cp d + jr nz, .asm_163e + ld a, $0 + ld [wObjectFollow_Follower], a +.asm_163e: ; 00:163e + pop af + call GetObjectStruct + ld bc, OBJECT_LENGTH + xor a + call ByteFill + ret + +Function164a:: + call Function1617 + callab Function8125 + ret + +Function1656:: + push hl + call GetMapObject + ld d, b + ld e, c + ld a, $ff + ld [de], a + inc de + pop hl + ld bc, MAP_OBJECT_TEMPLATE_LENGTH + call CopyBytes + ret + +Function1668:: + call GetMapObject + ld a, [wXCoord] + add $4 + ld hl, MAPOBJECT_X_COORD + add hl, bc + ld [hl], a + ld a, [wYCoord] + add $4 + ld hl, MAPOBJECT_Y_COORD + add hl, bc + ld [hl], a + ret + +Function1680:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_NEXT_MAP_X + add hl, bc + ld d, [hl] + ld hl, OBJECT_NEXT_MAP_Y + add hl, bc + ld e, [hl] + ldh a, [hMapObjectIndexBuffer] + call GetMapObject + ld hl, MAPOBJECT_X_COORD + add hl, bc + ld [hl], d + ld hl, MAPOBJECT_Y_COORD + add hl, bc + ld [hl], e + and a + ret + +Function169f:: + call GetMapObject + ld hl, MAPOBJECT_OBJECT_STRUCT_ID + add hl, bc + ld a, [hl] + push af + ld [hl], $ff + inc hl + ld bc, MAP_OBJECT_LENGTH - 1 + xor a + call ByteFill + pop af + cp $ff + ret z + cp $a + ret nc + ld b, a + ld a, [wObjectFollow_Leader] + cp b + jr nz, .asm_16c5 + ld a, $ff + ld [wObjectFollow_Leader], a +.asm_16c5: ; 00:16c5 + ld a, b + call GetObjectStruct + ld bc, OBJECT_LENGTH + xor a + call ByteFill + ret + +LoadMovementDataPointer:: + ld [wMovementObject], a + ldh a, [hROMBank] + ld [wMovementDataBank], a + ld a, l + ld [wMovementDataAddr], a + ld a, h + ld [wMovementDataAddr + 1], a + ld a, [wMovementObject] + call CheckObjectVisibility + ret c + ld hl, $3 + add hl, bc + ld [hl], $19 + ld hl, $8 + add hl, bc + ld [hl], $0 + ld hl, wVramState + set 7, [hl] + and a + ret + +Function16fb:: + ld [wMovementObject], a + ldh a, [hROMBank] + ld [wMovementDataBank], a + ld a, l + ld [wMovementDataAddr], a + ld a, h + ld [wMovementDataAddr + 1], a + ld a, [wMovementObject] + call CheckObjectVisibility + jr c, .asm_171f + ld hl, OBJECT_MOVEMENTTYPE + add hl, bc + ld [hl], $19 + ld hl, OBJECT_FACING + add hl, bc + ld [hl], $0 +.asm_171f: ; 00:171f + ret + +CheckObjectVisibility:: ; 00:1720 + ldh [hMapObjectIndexBuffer], a + call GetMapObject + ld hl, MAPOBJECT_OBJECT_STRUCT_ID + add hl, bc + ld a, [hl] + cp $ff + jr z, .asm_1735 + ldh [hObjectStructIndexBuffer], a + call GetObjectStruct + and a + ret + +.asm_1735: ; 00:1735 + scf + ret + +PushToCmdQueue:: ; 1737 + push de + call GetCmdQueueEmptySlot + pop de + ret c + ld b, h + ld c, l + ld a, [de] + inc de + ld hl, $1 + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $2 + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $3 + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $d + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $e + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $f + add hl, bc + ld [hl], a + ldh a, [hMapObjectIndexBuffer] + inc a + ld hl, $0 + add hl, bc + ld [hl], a + push bc + dec a + call GetObjectStruct + ld d, b + ld e, c + pop bc + ld hl, $18 + add hl, de + ld a, [hl] + ld hl, $4 + add hl, bc + ld [hl], a + ld hl, $19 + add hl, de + ld a, [hl] + ld hl, $5 + add hl, bc + ld [hl], a + ret + +GetCmdQueueEmptySlot:: ; 00:178e + ld hl, wCmdQueue + ld de, CMDQUEUE_ENTRY_SIZE + ld a, 1 +.asm_1796: ; 00:1796 + ldh [hObjectStructIndexBuffer], a + ld a, [hl] + and a + jr z, .asm_17a6 + add hl, de + ldh a, [hObjectStructIndexBuffer] + inc a + cp 4 + 1 + jr nz, .asm_1796 + scf + ret + +.asm_17a6: ; 00:17a6 + xor a + ret + +UpdateSprites:: ; 00:17a8 + ld a, [wVramState] + bit 0, a + ret z + callab Function5007 + callab Function5190 + ret + +GetObjectStruct:: ; 00:17bf + ld bc, $28 + ld hl, wObjectStructs + call AddNTimes + ld b, h + ld c, l + ret + +Function17cb:: + add $10 + ld e, a + ldh a, [hROMBank] + push af + ld a, BANK(Function862e) + call Bankswitch + call Function862e + pop af + call Bankswitch + ret + +Function17de:: + push hl + push bc + ld c, a + ld b, $ff + ld hl, .Data +.asm_17e6: ; 00:17e6 + ld a, [hli] + cp b + jr z, .asm_17ee + cp c + jr nz, .asm_17e6 + scf +.asm_17ee: ; 00:17ee + pop bc + pop hl + ret + +.Data: ; 00:17f1 + db $51, $55, $56, $57, $58, $5a, $5b, $ff + +Function17f9:: + call GetMapObject + ld hl, $0 + add hl, bc + ld a, [hl] + cp $ff + ret z + call GetObjectStruct + push bc + call Function1828 + pop bc + ld hl, $5 + add hl, bc + res 5, [hl] + ret + +Function1813:: + call GetMapObject + ld hl, $0 + add hl, bc + ld a, [hl] + cp $ff + ret z + call GetObjectStruct + ld hl, $5 + add hl, bc + set 5, [hl] + ret + +Function1828:: ; 00:1828 + ld bc, wObjectStructs + xor a +.asm_182c: ; 00:182c + push af + ld hl, OBJECT_SPRITE + add hl, bc + ld a, [hl] + and a + jr z, .asm_183b + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 5, [hl] +.asm_183b: ; 00:183b + ld hl, OBJECT_LENGTH + add hl, bc + ld b, h + ld c, l + pop af + inc a + cp 10 + jr nz, .asm_182c + ret + +Function1848:: + push bc + ld bc, wObjectStructs + xor a +.asm_184d: ; 00:184d + push af + ld hl, OBJECT_SPRITE + add hl, bc + ld a, [hl] + and a + jr z, .asm_185c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 5, [hl] +.asm_185c: ; 00:185c + ld hl, OBJECT_LENGTH + add hl, bc + ld b, h + ld c, l + pop af + inc a + cp 10 + jr nz, .asm_184d + pop bc + ret + +Function186a:: + call GetMapObject + ld hl, $0 + add hl, bc + ld a, [hl] + cp $ff + ret z + call GetObjectStruct + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 5, [hl] + ret + +Function187f:: + xor a +.asm_1880: ; 00:1880 + push af + push hl + ld b, a + ldh a, [hROMBank] + push af + ld c, [hl] + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + ld a, c + call Bankswitch + ld a, b + call ._hl_ + pop af + call Bankswitch + pop hl + pop af + inc a + cp 16 + jr nz, .asm_1880 + ret + +._hl_: ; 00:189f + jp hl + +Function18a0:: + ld a, [wcb70] + and a + ret z + ldh a, [hROMBank] + push af + ld a, BANK(Function83e8) + call Bankswitch + call Function83e8 + pop af + call Bankswitch + ret + +Function18b4:: + ld bc, wPlayerStruct + ld hl, OBJECT_FLAGS + add hl, bc + set 3, [hl] + set 2, [hl] + set 1, [hl] + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 5, [hl] + call Function18e5 + ret + +Function18cc:: + ld hl, wPlayerFlags + res 3, [hl] + res 2, [hl] + res 1, [hl] + ld hl, wPlayerFlags + 1 + res 5, [hl] + ld hl, wPlayerMovementType + ld [hl], $10 + ld hl, wPlayerDirection + ld [hl], $0 + ret + +Function18e5:: ; 00:18e5 + ld hl, OBJECT_DIRECTION_WALKING + add hl, bc + ld a, [hl] + srl a + srl a + and $3 + ld e, a + ld d, $0 + ld hl, .Data + add hl, de + ld a, [hl] + ld hl, OBJECT_MOVEMENTTYPE + add hl, bc + ld [hl], a + ld hl, OBJECT_FACING + add hl, bc + ld [hl], $0 + ret + +.Data: + db $05, $06, $07, $08 + +Function1908:: + call CheckObjectVisibility + ret c + push bc + call Function191d + pop bc + ld hl, OBJECT_FLAGS + add hl, bc + set 7, [hl] + ldh a, [hObjectStructIndexBuffer] + ld [wCenteredObject], a + ret + +Function191d:: ; 00:191d + ld a, [wCenteredObject] + cp $ff + ret z + call GetObjectStruct + ld hl, OBJECT_FLAGS + add hl, bc + res 7, [hl] + ld a, $ff + ld [wCenteredObject], a + ret + +; 1932 + +StartFollow:: + push bc + ld a, b + call SetLeaderIfVisible + pop bc + ld a, c + call SetFollowerIfVisible + callab QueueFollowerFirstStep + ret + +SetLeaderIfVisible:: ; 00:1945 + call CheckObjectVisibility + ret c + ldh a, [hObjectStructIndexBuffer] + ld [wObjectFollow_Leader], a + ret + +ResetLeader:: + xor a + ld [wObjectFollow_Leader], a + ret + +SetFollowerIfVisible:: ; 00:1954 + push af + call ResetFollower + pop af + call CheckObjectVisibility + ret c + ld hl, OBJECT_MOVEMENTTYPE + add hl, bc + ld [hl], $18 + ld hl, OBJECT_FACING + add hl, bc + ld [hl], $0 + ldh a, [hObjectStructIndexBuffer] + ld [wObjectFollow_Follower], a + ret + +ResetFollower:: ; 00:196f + ld a, [wObjectFollow_Follower] + and a + ret z + cp $ff + ret z + call GetObjectStruct + call Function18e5 + ret + +Function197e:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 0, [hl] + ret + +Function1989:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 0, [hl] + ret + +Function1994:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 4, [hl] + ret + +Function199f:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 4, [hl] + ret + +Function19aa:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 7, [hl] + ret + +Function19b5:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 7, [hl] + ret + +Function19c0:: + push de + call CheckObjectVisibility + pop de + ret c + ld a, d + add a + add a + and $c + ld hl, OBJECT_DIRECTION_WALKING + add hl, bc + ld [hl], a + ret diff --git a/home/math.asm b/home/math.asm new file mode 100644 index 0000000..8b3db6f --- /dev/null +++ b/home/math.asm @@ -0,0 +1,25 @@ +include "constants.asm" + +if DEBUG +SECTION "Math utility functions", ROM0 [$3380] +else +SECTION "Math utility functions", ROM0 [$3344] +endc + +Multiply:: + push hl + push bc + callab _Multiply + pop bc + pop hl + ret + +Divide:: + push hl + push de + push bc + homecall _Divide + pop bc + pop de + pop hl + ret diff --git a/home/menu.asm b/home/menu.asm index 64d3f9a..2d8f1f3 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -210,15 +210,15 @@ Function1e8a:: ; 00:1e8a ldh [hBGMapMode], a xor a call OpenSRAM - call Function1cae + call GetWindowStackTop ld a, l ld [wWindowStackPointer], a ld a, h ld [wWindowStackPointer + 1], a - call Function1c7a + call PopWindow ld d, h ld e, l - call Function1c60 + call RestoreTileBackup call CloseSRAM ld hl, wWindowStackSize dec [hl] @@ -271,7 +271,7 @@ GetMenuIndexSet:: ; 00:1ec3 Function1ee9:: ; 1ee9 call MenuBoxCoord2Tile - call Function1c86 + call GetMenuBoxDims ld a, [wMenuDataItems] add a cp b diff --git a/home/menu_window.asm b/home/menu_window.asm new file mode 100644 index 0000000..b5082ca --- /dev/null +++ b/home/menu_window.asm @@ -0,0 +1,246 @@ +include "constants.asm" + +SECTION "Menu Window Functions", ROM0 [$1bf4] + +PushWindow:: ; 00:1bf4 + ld hl, PlaceWaitingText + ld a, $9 + jp FarCall_hl + +ExitMenu:: ; 00:1bfc + push af + callab _ExitMenu + call Function1c0a + pop af + ret + +Function1c0a:: ; 00:1c0a + ld a, [wVramState] + bit 0, a + ret z + + xor a + call OpenSRAM + hlcoord 0, 0 + ld de, sSpriteBuffer0 + ld bc, $168 + call CopyBytes + call CloseSRAM + + call LoadMapPart + + xor a + call OpenSRAM + ld hl, sSpriteBuffer0 + decoord 0, 0 + ld bc, $168 +.asm_1c33: ; 00:1c33 + ld a, [hl] + cp $61 + jr c, .asm_1c39 + ld [de], a +.asm_1c39: ; 00:1c39 + inc hl + inc de + dec bc + ld a, c + or b + jr nz, .asm_1c33 + call CloseSRAM + + ret + +InitVerticalMenuCursor:: ; 00:1c44 + jpab _InitVerticalMenuCursor + +CloseWindow:: ; 00:1c4c + push af + call ExitMenu + call WaitBGMap + call UpdateSprites + pop af + ret + +Function1c58:: + jpab Function24185 + +RestoreTileBackup:: ; 00:1c60 + call MenuBoxCoord2Tile + call GetMenuBoxDims + inc b + inc c +.asm_1c68: ; 00:1c68 + push bc + push hl +.asm_1c6a: ; 00:1c6a + ld a, [de] + ld [hli], a + dec de + dec c + jr nz, .asm_1c6a + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .asm_1c68 + ret + +PopWindow:: ; 00:1c7a + ld b, $10 + ld de, wMenuDataHeader +.asm_1c7f: ; 00:1c7f + ld a, [hld] + ld [de], a + inc de + dec b + jr nz, .asm_1c7f + ret + +GetMenuBoxDims:: ; 00:1c86 + push hl + ld hl, wMenuBorderTopCoord + ld a, [hli] + ld b, a + ld a, [hli] + ld c, a + ld a, [hli] + sub b + ld b, a + ld a, [hli] + sub c + ld c, a + pop hl + ret + +CopyMenuData:: ; 00:1c96 + push hl + push de + push bc + push af + ld hl, wMenuDataPointer + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wMenuDataFlags + ld bc, $10 + call CopyBytes + pop af + pop bc + pop de + pop hl + ret + +GetWindowStackTop:: ; 00:1cae + ld hl, wWindowStackPointer + ld a, [hli] + ld h, [hl] + ld l, a + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + ret + +PlaceVerticalMenuItems:: ; 00:1cb9 + call CopyMenuData + ld hl, wMenuDataPointer + ld e, [hl] + inc hl + ld d, [hl] + call GetMenuTextStartCoord + call Coord2Tile ; hl now contains the tilemap address where we will start printing text. + inc de + ld a, [de] + inc de + ld b, a +.asm_1ccc: ; 00:1ccc + push bc + call PlaceString + inc de + ld bc, 2 * SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .asm_1ccc + + ld a, [wMenuDataFlags] + bit 4, a + ret z + + call MenuBoxCoord2Tile + ld a, [de] + ld c, a + inc de + ld b, $0 + add hl, bc + jp PlaceString + +MenuBox:: ; 00:1ceb + call MenuBoxCoord2Tile + call GetMenuBoxDims + dec b + dec c + jp DrawTextBox + +GetMenuTextStartCoord:: ; 00:1cf6 + ld a, [wMenuBorderTopCoord] + ld b, a + inc b + ld a, [wMenuBorderLeftCoord] + ld c, a + inc c + ld a, [wMenuDataFlags] + bit 6, a + jr nz, .asm_1d08 + inc b +.asm_1d08: ; 00:1d08 + ld a, [wMenuDataFlags] + bit 7, a + jr z, .asm_1d10 + inc c +.asm_1d10: ; 00:1d10 + ret + +ClearMenuBoxInterior:: + call MenuBoxCoord2Tile + ld bc, SCREEN_WIDTH + 1 + add hl, bc + call GetMenuBoxDims + dec b + dec c + call ClearBox + ret + +ClearWholeMenuBox:: + call MenuBoxCoord2Tile + call GetMenuBoxDims + inc c + inc b + call ClearBox + ret + +MenuBoxCoord2Tile:: ; 00:1d2d + ld a, [wMenuBorderLeftCoord] + ld c, a + ld a, [wMenuBorderTopCoord] + ld b, a +Coord2Tile:: ; 00:1d35 + xor a + ld h, a + ld l, b + ld a, c + ld b, h + ld c, l + add hl, hl + add hl, hl + add hl, bc + add hl, hl + add hl, hl + ld c, a + xor a + ld b, a + add hl, bc + bccoord 0, 0 + add hl, bc + ret diff --git a/home/misc_32c8.asm b/home/misc_32c8.asm new file mode 100644 index 0000000..3eabb12 --- /dev/null +++ b/home/misc_32c8.asm @@ -0,0 +1,98 @@ +include "constants.asm" + +if DEBUG +SECTION "Unknown 32c8", ROM0[$32c8] +else +SECTION "Unknown 32c8", ROM0[$328c] +endc + +Function32c8:: + predef Functionce10 + ld a, b + and a + ret + +Function32d0:: + ld hl, .Data + ret + +.Data: ; 00:32d4 + db "@" + +SubtractSigned:: + sub b + ret nc + cpl + add $1 + scf + ret + +if DEBUG +SECTION "Unknown 3686", ROM0[$3686] +else +SECTION "Unknown 3686", ROM0[$364a] +endc + +GiveMonToPlayer:: ; 3686 +; Give to the player Pokemon of species b at level c. + ld a, b + ld [wMonDexIndex], a + ld a, c + ld [wCurPartyLevel], a + xor a + ld [wMonType], a + jpba Function1130a + +WaitPressedAny:: ; 369a +; Waits for one of the buttons in d to be pressed. +; If bc is negative, waits forever. +; Otherwise, times out after bc frames then returns z. + +; Reset hJoypadSum to clear button history + xor a + ldh [hJoypadSum], a +.loop: ; 00:369d +; Wait for joypad polling. + call DelayFrame + +; If any of the buttons in d were pressed, return nz. + ldh a, [hJoypadSum] + and a + jr z, .not_pressed + and d + ret nz +.not_pressed: ; 00:36a7 + +; If bc < 0, don't check timeout. + bit 7, b + jr nz, .loop + +; Count down to timeout. + dec bc + ld a, b + or c + jr nz, .loop + +; Return z, signifying that the request timed out. + ret + +CountSetBits:: ; 36b1 +; Count the number of bits set in b bytes at hl. +; Return to a, c, and wce37. + ld c, $0 +.asm_36b3: ; 00:36b3 + ld a, [hli] + ld e, a + ld d, $8 +.asm_36b7: ; 00:36b7 + srl e + ld a, $0 + adc c + ld c, a + dec d + jr nz, .asm_36b7 + dec b + jr nz, .asm_36b3 + ld a, c + ld [wce37], a + ret diff --git a/home/mon_stats.asm b/home/mon_stats.asm new file mode 100644 index 0000000..e84e552 --- /dev/null +++ b/home/mon_stats.asm @@ -0,0 +1,82 @@ +include "constants.asm" + +if DEBUG +SECTION "Mon Stats", ROM0 [$394b] +else +SECTION "Mon Stats", ROM0 [$390f] +endc + +DrawBattleHPBar:: + push hl + push de + push bc + ld a, $60 + ld [hli], a + ld a, $61 + ld [hli], a + push hl + ld a, $62 +.asm_3957: ; 00:3957 + ld [hli], a + dec d + jr nz, .asm_3957 + ld a, $6b + add b + ld [hl], a + pop hl + ld a, e + and a + jr nz, .asm_396a + ld a, c + and a + jr z, .asm_397d + ld e, $1 +.asm_396a: ; 00:396a + ld a, e + sub $8 + jr c, .asm_3979 + ld e, a + ld a, $6a + ld [hli], a + ld a, e + and a + jr z, .asm_397d + jr .asm_396a + +.asm_3979: ; 00:3979 + ld a, $62 + add e + ld [hl], a +.asm_397d: ; 00:397d + pop bc + pop de + pop hl + ret + +PrepMonFrontpic:: + ld a, $1 + ld [wSpriteFlipped], a +_PrepMonFrontpic:: + ld a, [wMonDexIndex] + and a + jr z, .asm_39a8 + cp 252 + jr nc, .asm_39a8 + push hl + ld de, vFrontPic + call LoadMonFrontSprite + pop hl + xor a + ldh [hGraphicStartTile], a + lb bc, 7, 7 + predef PlaceGraphic + xor a + ld [wSpriteFlipped], a + ret + +.asm_39a8: ; 00:39a8 + xor a + ld [wSpriteFlipped], a + inc a + ld [wMonDexIndex], a + ret diff --git a/home/print_text.asm b/home/print_text.asm index e8b4eeb..0a17688 100644 --- a/home/print_text.asm +++ b/home/print_text.asm @@ -48,4 +48,23 @@ PrintLetterDelay:: ; 33a3 (0:33a3) pop de pop hl ret -; 0x33e3
\ No newline at end of file +; 0x33e3 + +CopyDataUntil:: ; 33e3 +; Copy [hl .. bc) to de. + +; In other words, the source data is +; from hl up to but not including bc, +; and the destination is de. + +.asm_33e3: ; 00:33e3 + ld a, [hli] + ld [de], a + inc de + ld a, h + cp b + jr nz, .asm_33e3 + ld a, l + cp c + jr nz, .asm_33e3 + ret diff --git a/home/scrolling_menu.asm b/home/scrolling_menu.asm new file mode 100644 index 0000000..28d3d3e --- /dev/null +++ b/home/scrolling_menu.asm @@ -0,0 +1,93 @@ +include "constants.asm" + +if DEBUG +SECTION "Scrolling Menu", ROM0 [$3810] +else +SECTION "Scrolling Menu", ROM0 [$37D4] +endc + +Function3810:: + ld e, [hl] + inc hl + ld d, [hl] + inc hl + push hl + ld h, d + ld l, e + call CopyMenuHeader + pop hl + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ld a, [de] + ld [wMenuCursorBuffer], a + push de + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ld a, [de] + ld [wMenuScrollPosition], a + push de + call ScrollingMenu + pop de + ld a, [wMenuScrollPosition] + ld [de], a + pop de + ld a, [wMenuCursorY] + ld [de], a + ld a, [wMenuJoypad] + ret + +ScrollingMenu:: ; 00:383e + call CopyMenuData + ldh a, [hROMBank] + push af + + ld a, BANK(_InitScrollingMenu) ; and BANK(_ScrollingMenu) + call Bankswitch + + call _InitScrollingMenu + call SetPalettes + call _ScrollingMenu + + pop af + call Bankswitch + + ld a, [wMenuJoypad] + ret + +Function385a:: + push hl + jr asm_3865 + +Function385d:: + callab Function_8f1cb +asm_3865: ; 00:3865 + pop hl + call MenuTextBox + ld c, $0 + call Function3872 + call CloseWindow + ret + +Function3872:: ; 00:3872 + push bc + jr asm_387d + +Function3875:: + callab Function8cd0c +asm_387d: ; 00:387d + pop bc + call GetJoypad + ldh a, [hJoyDown] + and A_BUTTON | B_BUTTON + jr nz, .asm_388e + ld a, c + and a + jr z, Function3872 + dec c + jr z, Function3872 +.asm_388e: ; 00:388e + ret diff --git a/home/tilemap.asm b/home/tilemap.asm new file mode 100644 index 0000000..6d7ff38 --- /dev/null +++ b/home/tilemap.asm @@ -0,0 +1,70 @@ +include "constants.asm" + +if DEBUG +SECTION "Tilemap Functions", ROM0 [$360B] +else +SECTION "Tilemap Functions", ROM0 [$35CF] +endc + +Function360b:: + call ClearSprites + ld hl, wVramState + set 0, [hl] + call Function3657 + call LoadFontExtra + call GetMemSGBLayout + jr WaitBGMap + +ClearBGPalettes:: ; 361e + call ClearPalettes +WaitBGMap:: ; 00:3621 +; Tell VBlank to update BG Map + ld a, $1 + ldh [hBGMapMode], a +; Wait for it to do its magic + ld c, 3 + call DelayFrames + ret + +SetPalettes:: ; 00:362b + ld a, %11100100 + ldh [rBGP], a + ld a, %11010000 + ldh [rOBP0], a + ret + +ClearPalettes:: ; 00:3634 + xor a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a + ret + +GetMemSGBLayout:: ; 00:363c + ld b, SGB_RAM +GetSGBLayout:: ; 00:363e + ld a, [wSGB] + and a + ret z + predef_jump Function928b + +SetHPPal:: ; 00:3648 + ld a, e + cp 27 ; 56.25% + ld d, $0 + jr nc, .done + cp 10 ; 20.83% + inc d + jr nc, .done + inc d +.done: ; 00:3655 + ld [hl], d + ret + +Function3657:: ; 00:3657 + call DisableLCD + callab Function140d9 + call LoadFont + call UpdateSprites + call EnableLCD + ret diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm new file mode 100644 index 0000000..58c83fa --- /dev/null +++ b/home/unknown_388f.asm @@ -0,0 +1,101 @@ +include "constants.asm" + +if DEBUG +SECTION "Unknown 388F", ROM0 [$388F] +else +SECTION "Unknown 388F", ROM0 [$3853] +endc + + +Function388f:: + ret + +Function3890:: + callba Function14cac + ret + +Function3899:: + callba Function14dac + ret + +Function38a2:: + callba Function14dc4 + ret + +Function38ab:: + callba Function14ddd + ret + +Function38b4:: + callba Function14e00 + ret + +Function38bd:: + callba Function14e5f + ret + +Function38c6:: + callba Function14e27 + ret + +Function38cf:: + callba Function14e4a + ret + +Function38d8:: + ld hl, wc5ed + set 7, [hl] + ld a, $8 + ld [wd637], a + ret + +Function38e3:: + ldh a, [hJoyState] + and $f0 + ret z + call Function3233 + jp nz, Function323e + callab Function3ee3e + ld a, [wBattleMode] + and a + ret z + ld a, $3 + call WriteIntod637 + call Function3240 + ret + +Function3904:: + predef Function3ef19 + ld a, $f3 + ldh [hMapEntryMethod], a + ld hl, wd4a9 + set 5, [hl] + ld hl, wJoypadFlags + set 4, [hl] + set 6, [hl] + ld a, $b + call WriteIntod637 + ret + +Function391f:: + ret + +Function3910:: + ld a, [wcd5d] + cp $1 + jr z, .asm_392d + ld a, $4 + call WriteIntod637 + ret + +.asm_392d: ; 00:392d + ld hl, wJoypadFlags + res 4, [hl] + ld hl, .text + call Function3111 + call RotateFourPalettesLeft + jp Init + +.text: + text "つぎは がんばるぞ!!" + done diff --git a/home/util.asm b/home/util.asm index 6591da2..880513b 100644 --- a/home/util.asm +++ b/home/util.asm @@ -1,12 +1,59 @@ INCLUDE "constants.asm" if DEBUG -SECTION "Misc Utility Functions", ROM0[$341F] +SECTION "Misc Utility Functions", ROM0[$33EF] else -SECTION "Misc Utility Functions", ROM0[$33E3] +SECTION "Misc Utility Functions", ROM0[$33B3] endc -_341F:: ; 341f +Function33ef:: + ; hl = src + ; de = dest + ; b = y + ; c = x + push hl + push de + push bc + ld a, b + dec a + dec a + ld b, $0 +.asm_33f7: ; 00:33f7 + add hl, bc + dec a + jr nz, .asm_33f7 + pop bc + dec b + ld a, b + push hl + add hl, bc + ld d, h + ld e, l + pop hl +.asm_3403: ; 00:3403 + push af + push bc + call CopyBytes + pop bc + push bc + ld a, c + xor $ff + ld c, a + ld b, $ff + inc bc + add hl, bc + ld d, h + ld e, l + add hl, bc + pop bc + pop af + dec a + jr nz, .asm_3403 + pop hl + pop de + jp CopyBytes + +SkipNames:: ; 341f ; Returns hl + a * 6 and a ret z @@ -39,3 +86,35 @@ memcmp:: ; 3430 dec c jr nz, .loop ret + +Function3439:: ; 3439 +; Place 2x2 sprite from *de into OAM at slot a + ld h, HIGH(wVirtualOAM) + swap a + ld l, a + call .Load + push bc + ld a, $8 + add c + ld c, a + call .Load + pop bc + ld a, $8 + add b + ld b, a + call .Load + ld a, $8 + add c + ld c, a +.Load: ; 00:3455 + ld [hl], b + inc hl + ld [hl], c + inc hl + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + ret |
