Skip to content

Commit

Permalink
Merge pull request #133 from ElectroDeoxys/master
Browse files Browse the repository at this point in the history
Split bank 7
  • Loading branch information
ElectroDeoxys authored Jul 21, 2023
2 parents 635e4c3 + e06e485 commit 43b7b92
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 271 deletions.
67 changes: 67 additions & 0 deletions src/engine/debug_sprites.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Func_1c865:
ret

; debug function
; adjusts hSCX and hSCY by using the arrow keys
; pressing B makes it scroll faster
Func_1c866: ; unreferenced
ldh a, [hKeysHeld]
and B_BUTTON
call nz, .asm_1c86d ; executes following part twice
.asm_1c86d
ldh a, [hSCX]
ld b, a
ldh a, [hSCY]
ld c, a
ldh a, [hKeysHeld]
bit D_UP_F, a
jr z, .check_d_down
inc c
.check_d_down
bit D_DOWN_F, a
jr z, .check_d_left
dec c
.check_d_left
bit D_LEFT_F, a
jr z, .check_d_right
inc b
.check_d_right
bit D_RIGHT_F, a
jr z, .asm_1c889
dec b
.asm_1c889
ld a, b
ldh [hSCX], a
ld a, c
ldh [hSCY], a
ret

; sets some flags on a given sprite
Func_1c890: ; unreferenced
ld a, [wVBlankCounter]
and %111111
ret nz

ld a, [wd41b]
cp $11
jr z, .asm_1c8a3
cp $0e
ret c
cp $10
ret nc

; wd41b == $11 || (wd41b >= $0e && wd41b < $10)
.asm_1c8a3
ld a, [wd41c]
ld [wWhichSprite], a
ld c, SPRITE_ANIM_FLAGS
call GetSpriteAnimBufferProperty
call UpdateRNGSources
and (1 << SPRITE_ANIM_FLAG_X_SUBTRACT)
jr nz, .asm_1c8b9
res SPRITE_ANIM_FLAG_SPEED, [hl]
jr .asm_1c8bb
.asm_1c8b9
set SPRITE_ANIM_FLAG_SPEED, [hl]
.asm_1c8bb
ret
55 changes: 55 additions & 0 deletions src/engine/masters_beaten_list.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ClearMasterBeatenList:
push hl
push bc
ld c, $a
ld hl, wMastersBeatenList
xor a
.loop
ld [hli], a
dec c
jr nz, .loop
pop bc
pop hl
ret

; writes Master in register a to
; first empty slot in wMastersBeatenList
AddMasterBeatenToList:
push hl
push bc
ld b, a
ld c, $a
ld hl, wMastersBeatenList
.loop
ld a, [hl]
or a
jr z, .found_empty_slot
cp b
jr z, .exit
inc hl
dec c
jr nz, .loop
debug_nop
jr .exit

.found_empty_slot
ld a, b
ld [hl], a

.exit
pop bc
pop hl
ret

; iterates all masters and attempts to
; add each of them to wMastersBeatenList
AddAllMastersToMastersBeatenList:
ld a, $01
.loop
push af
call AddMasterBeatenToList
pop af
inc a
cp $0b
jr c, .loop
ret
50 changes: 50 additions & 0 deletions src/engine/overworld/debug_player_coordinates.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
JumpSetWindowOff:
jp SetWindowOff

; debug function
; prints player's coordinates by pressing B
; and draws palettes by pressing A
Func_1c003: ; unreferenced
ld a, [wCurMap]
or a
jr z, JumpSetWindowOff
ld a, [wOverworldMode]
cp OWMODE_START_SCRIPT
jr nc, JumpSetWindowOff

ldh a, [hKeysHeld]
ld b, a
and A_BUTTON | B_BUTTON
cp b
jr nz, JumpSetWindowOff
and B_BUTTON
jr z, JumpSetWindowOff

ld bc, $20
ld a, [wPlayerXCoord]
bank1call WriteTwoByteNumberInTxSymbolFormat
ld bc, $320
ld a, [wPlayerYCoord]
bank1call WriteTwoByteNumberInTxSymbolFormat
ld a, $77
ldh [hWX], a
ld a, $88
ldh [hWY], a

ldh a, [hKeysPressed]
and A_BUTTON
jr z, .skip_load_scene
ld a, SCENE_COLOR_PALETTE
lb bc, 0, 33
call LoadScene
.skip_load_scene
ldh a, [hKeysHeld]
and A_BUTTON
jr z, .set_wd_on
ld a, $67
ldh [hWX], a
ld a, $68
ldh [hWY], a
.set_wd_on
call SetWindowOn
ret
43 changes: 43 additions & 0 deletions src/engine/overworld/load_map_header.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
; loads data from the map header of wCurMap
LoadMapHeader:
push hl
push bc
push de
ld a, [wCurMap]
add a
ld c, a
add a
add c
ld c, a
ld b, 0
ld hl, MapHeaders
add hl, bc
ld a, [hli]
ld [wCurTilemap], a
ld a, [hli]
ld c, a ; CGB tilemap variant
ld a, [hli]
ld [wCurMapInitialPalette], a ; always 0?
ld a, [hli]
ld [wCurMapSGBPals], a
ld a, [hli]
ld [wCurMapPalette], a
ld a, [hli]
ld [wDefaultSong], a

ld a, [wConsole]
cp CONSOLE_CGB
jr nz, .got_tilemap
; use CGB variant, if valid
ld a, c
or a
jr z, .got_tilemap
ld [wCurTilemap], a
.got_tilemap

pop de
pop bc
pop hl
ret

INCLUDE "data/map_headers.asm"
Loading

0 comments on commit 43b7b92

Please sign in to comment.