diff options
Diffstat (limited to 'home')
-rw-r--r-- | home/init.asm | 4 | ||||
-rw-r--r-- | home/misc_32c8.asm | 98 | ||||
-rw-r--r-- | home/print_text.asm | 21 | ||||
-rw-r--r-- | home/tilemap.asm | 70 | ||||
-rw-r--r-- | home/util.asm | 85 |
5 files changed, 271 insertions, 7 deletions
diff --git a/home/init.asm b/home/init.asm index 515ce84..98fa129 100644 --- a/home/init.asm +++ b/home/init.asm @@ -104,9 +104,7 @@ Init: ; 052f call DisableAudio call _2007 - ; predef ??? - ld a, $4B ; TODO: add predefs so the line above can be uncommented - call Predef + predef CheckSGB ld a, $1F ld [rIE], a ld a, HIGH($9C00) 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/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/tilemap.asm b/home/tilemap.asm new file mode 100644 index 0000000..ca97f42 --- /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:: + 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/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 |