summaryrefslogtreecommitdiff
path: root/home
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-06-07 11:01:53 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2018-06-07 11:01:53 -0400
commit709ed0314d03e0a6dc1e3838875311c0f12ee46d (patch)
tree7f828794351b32d09e2ed6e4341bb2ea74db4ad6 /home
parente45a36ecaa0dd46594f49f52206707ed60eb2a3e (diff)
tilemap functions
Diffstat (limited to 'home')
-rw-r--r--home/tilemap.asm70
-rw-r--r--home/util.asm32
2 files changed, 102 insertions, 0 deletions
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 8efe322..880513b 100644
--- a/home/util.asm
+++ b/home/util.asm
@@ -86,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