Organize the engine/ directory, take 3

Renamed `title` to `movies`.
Moved some functions from `engine/routines/` to their fitting
directories, and cleaned up the base `engine/` directory.
Moved `engine/pokemon/tmhm.asm` back to `engine/items/`.

Made a new subdirectory:
* engine/tilesets: Contains all map-related graphics routines.
This commit is contained in:
mid-kid
2018-03-25 16:18:33 +02:00
parent 60e21a8663
commit 0d9241889f
36 changed files with 648 additions and 648 deletions

View File

@@ -1,74 +0,0 @@
CheckNickErrors:: ; 669f
; error-check monster nick before use
; must be a peace offering to gamesharkers
; input: de = nick location
push bc
push de
ld b, MON_NAME_LENGTH
.checkchar
; end of nick?
ld a, [de]
cp "@" ; terminator
jr z, .end
; check if this char is a text command
ld hl, .textcommands
dec hl
.loop
; next entry
inc hl
; reached end of commands table?
ld a, [hl]
cp -1
jr z, .done
; is the current char between this value (inclusive)...
ld a, [de]
cp [hl]
inc hl
jr c, .loop
; ...and this one?
cp [hl]
jr nc, .loop
; replace it with a "?"
ld a, "?"
ld [de], a
jr .loop
.done
; next char
inc de
; reached end of nick without finding a terminator?
dec b
jr nz, .checkchar
; change nick to "?@"
pop de
push de
ld a, "?"
ld [de], a
inc de
ld a, "@"
ld [de], a
.end
; if the nick has any errors at this point it's out of our hands
pop de
pop bc
ret
.textcommands ; 66cf
; table defining which characters are actually text commands
; format:
; ≥ <
db TX_START, TX_BOX + 1
db "<PLAY_G>", "<JP_18>" + 1
db "<NI>", "<NO>" + 1
db "<ROUTE>", "<GREEN>" + 1
db "<ENEMY>", "<ENEMY>" + 1
db "<MOM>", "<TM>" + 1
db "<ROCKET>", "┘" + 1
db -1 ; end

View File

@@ -1,20 +0,0 @@
CheckSave:: ; 4cffe
ld a, BANK(sCheckValue1) ; BANK(sCheckValue2)
call GetSRAMBank
ld a, [sCheckValue1]
ld b, a
ld a, [sCheckValue2]
ld c, a
call CloseSRAM
ld a, b
cp SAVE_CHECK_VALUE_1
jr nz, .ok
ld a, c
cp SAVE_CHECK_VALUE_2
jr nz, .ok
ld c, $1
ret
.ok
ld c, $0
ret

View File

@@ -1,19 +0,0 @@
CheckTime:: ; c000
ld a, [wTimeOfDay]
ld hl, .TimeOfDayTable
ld de, 2
call IsInArray
inc hl
ld c, [hl]
ret c
xor a
ld c, a
ret
.TimeOfDayTable: ; c012
db MORN_F, MORN
db DAY_F, DAY
db NITE_F, NITE
db NITE_F, NITE
db -1

View File

@@ -1,229 +0,0 @@
Unreferenced_CorrectErrorsInPlayerParty:
ld hl, wPartyCount
ld a, [hl]
and a
ret z
cp PARTY_LENGTH + 1
jr c, .party_length_okay
ld a, PARTY_LENGTH
ld [hl], a
.party_length_okay
inc hl
ld b, a
ld c, 0
.loop1
ld a, [hl]
and a
jr z, .invalid_species
cp NUM_POKEMON + 1
jr z, .invalid_species
cp EGG + 1
jr c, .next_species
.invalid_species
ld [hl], SMEARGLE
push hl
push bc
ld a, c
ld hl, wPartyMon1Species
call GetPartyLocation
ld [hl], SMEARGLE
pop bc
pop hl
.next_species
inc hl
inc c
dec b
jr nz, .loop1
ld [hl], $ff
ld hl, wPartyMon1
ld a, [wPartyCount]
ld d, a
ld e, 0
.loop2
push de
push hl
ld b, h
ld c, l
ld a, [hl]
and a
jr z, .invalid_species_2
cp NUM_POKEMON + 1
jr c, .check_level
.invalid_species_2
ld [hl], SMEARGLE
push de
ld d, 0
ld hl, wPartySpecies
add hl, de
pop de
ld a, SMEARGLE
ld [hl], a
.check_level
ld [wCurSpecies], a
call GetBaseData
ld hl, MON_LEVEL
add hl, bc
ld a, [hl]
cp MIN_LEVEL
ld a, MIN_LEVEL
jr c, .invalid_level
ld a, [hl]
cp MAX_LEVEL
jr c, .load_level
ld a, MAX_LEVEL
.invalid_level
ld [hl], a
.load_level
ld [wCurPartyLevel], a
ld hl, MON_MAXHP
add hl, bc
ld d, h
ld e, l
ld hl, MON_STAT_EXP - 1
add hl, bc
ld b, TRUE
predef CalcMonStats
pop hl
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
pop de
inc e
dec d
jr nz, .loop2
ld de, wPartyMonNicknames
ld a, [wPartyCount]
ld b, a
ld c, 0
.loop3
push bc
call .GetLengthOfStringWith6CharCap
push de
farcall CheckStringForErrors
pop hl
pop bc
jr nc, .valid_nickname
push bc
push hl
ld hl, wPartySpecies
push bc
ld b, 0
add hl, bc
pop bc
ld a, [hl]
cp EGG
ld hl, .TAMAGO
jr z, .got_nickname
ld [wd265], a
call GetPokemonName
ld hl, wStringBuffer1
.got_nickname
pop de
ld bc, MON_NAME_LENGTH
call CopyBytes
pop bc
.valid_nickname
inc c
dec b
jr nz, .loop3
ld de, wPartyMonOT
ld a, [wPartyCount]
ld b, a
ld c, 0
.loop4
push bc
call .GetLengthOfStringWith6CharCap
push de
farcall CheckStringForErrors
pop hl
jr nc, .valid_ot_name
ld d, h
ld e, l
ld hl, wPlayerName
ld bc, NAME_LENGTH
call CopyBytes
.valid_ot_name
pop bc
inc c
dec b
jr nz, .loop4
ld hl, wPartyMon1Moves
ld a, [wPartyCount]
ld b, a
.loop5
push hl
ld c, NUM_MOVES
ld a, [hl]
and a
jr z, .invalid_move
cp NUM_ATTACKS + 1
jr c, .moves_loop
.invalid_move
ld [hl], POUND
.moves_loop
ld a, [hl]
and a
jr z, .fill_invalid_moves
cp NUM_ATTACKS + 1
jr c, .next_move
.fill_invalid_moves
xor a
ld [hli], a
dec c
jr nz, .fill_invalid_moves
jr .next_pokemon
.next_move
inc hl
dec c
jr nz, .moves_loop
.next_pokemon
pop hl
push bc
ld bc, PARTYMON_STRUCT_LENGTH
add hl, bc
pop bc
dec b
jr nz, .loop5
ret
; 13b6b
.TAMAGO: ; 13b6b
db "タマゴ@@@"
; 13b71
.GetLengthOfStringWith6CharCap: ; 13b71
push de
ld c, 1
ld b, NAME_LENGTH_JAPANESE
.search_loop
ld a, [de]
cp "@"
jr z, .done
inc de
inc c
dec b
jr nz, .search_loop
dec c
dec de
ld a, "@"
ld [de], a
.done
pop de
ret
; 13b87

View File

@@ -1,21 +0,0 @@
WriteOAMDMACodeToHRAM:: ; 4031
ld c, hTransferVirtualOAM - $ff00
ld b, .PushOAMEnd - .PushOAM
ld hl, .PushOAM
.loop
ld a, [hli]
ld [$ff00+c], a
inc c
dec b
jr nz, .loop
ret
.PushOAM: ; 403f
ld a, HIGH(wVirtualOAM)
ld [rDMA], a
ld a, NUM_SPRITE_OAM_STRUCTS
.pushoam_loop
dec a
jr nz, .pushoam_loop
ret
.PushOAMEnd

View File

@@ -1,80 +0,0 @@
PhoneRing_CopyTilemapAtOnce: ; 4d188
ld a, [hCGB]
and a
jp z, WaitBGMap
ld a, [wSpriteUpdatesEnabled]
cp $0
jp z, WaitBGMap
; What follows is a modified version of CopyTilemapAtOnce.
ld a, [hBGMapMode]
push af
xor a
ld [hBGMapMode], a
ld a, [hMapAnims]
push af
xor a
ld [hMapAnims], a
.wait
ld a, [rLY]
cp LY_VBLANK - 1
jr c, .wait
di
ld a, BANK(vBGMap2)
ld [rVBK], a
hlcoord 0, 0, wAttrMap
call .CopyTilemapAtOnce
ld a, BANK(vBGMap0)
ld [rVBK], a
hlcoord 0, 0
call .CopyTilemapAtOnce
.wait2
ld a, [rLY]
cp LY_VBLANK - 1
jr c, .wait2
ei
pop af
ld [hMapAnims], a
pop af
ld [hBGMapMode], a
ret
.CopyTilemapAtOnce: ; 4d1cb
ld [hSPBuffer], sp
ld sp, hl
ld a, [hBGMapAddress + 1]
ld h, a
ld l, 0
ld a, SCREEN_HEIGHT
ld [hTilesPerCycle], a
ld b, 1 << 1 ; not in v/hblank
ld c, LOW(rSTAT)
.loop
rept SCREEN_WIDTH / 2
pop de
.loop\@
ld a, [$ff00+c]
and b
jr nz, .loop\@
ld [hl], e
inc l
ld [hl], d
inc l
endr
ld de, BG_MAP_WIDTH - SCREEN_WIDTH
add hl, de
ld a, [hTilesPerCycle]
dec a
ld [hTilesPerCycle], a
jr nz, .loop
ld a, [hSPBuffer]
ld l, a
ld a, [hSPBuffer + 1]
ld h, a
ld sp, hl
ret

View File

@@ -1,24 +0,0 @@
PlaceWaitingText:: ; 4000
hlcoord 3, 10
ld b, 1
ld c, 11
ld a, [wBattleMode]
and a
jr z, .notinbattle
call TextBox
jr .proceed
.notinbattle
predef LinkTextboxAtHL
.proceed
hlcoord 4, 11
ld de, .Waiting
call PlaceString
ld c, 50
jp DelayFrames
.Waiting: ; 4025
db "Waiting...!@"

View File

@@ -1,31 +0,0 @@
PlaySlowCry: ; fb841
ld a, [wScriptVar]
call LoadCry
jr c, .done
ld hl, wCryPitch
ld a, [hli]
ld h, [hl]
ld l, a
ld bc, -$140
add hl, bc
ld a, l
ld [wCryPitch], a
ld a, h
ld [wCryPitch + 1], a
ld hl, wCryLength
ld a, [hli]
ld h, [hl]
ld l, a
ld bc, $60
add hl, bc
ld a, l
ld [wCryLength], a
ld a, h
ld [wCryLength + 1], a
farcall _PlayCry
call WaitSFX
.done
ret
; fb877

View File

@@ -0,0 +1,29 @@
GetPredefPointer:: ; 854b
; Return the bank and address of wPredefID in a and wPredefAddress.
; Save hl for later (back in Predef)
ld a, h
ld [wPredefTemp], a
ld a, l
ld [wPredefTemp + 1], a
push de
ld a, [wPredefID]
ld e, a
ld d, 0
ld hl, PredefPointers
add hl, de
add hl, de
add hl, de
pop de
ld a, [hli]
ld [wPredefAddress + 1], a
ld a, [hli]
ld [wPredefAddress], a
ld a, [hl]
ret
; 856b
INCLUDE "data/predef_pointers.asm"

View File

@@ -1,77 +0,0 @@
SaveMenu_CopyTilemapAtOnce: ; 4cf45 (13:4f45)
ld a, [hCGB]
and a
jp z, WaitBGMap
; The following is a modified version of CopyTilemapAtOnce.
ld a, [hBGMapMode]
push af
xor a
ld [hBGMapMode], a
ld a, [hMapAnims]
push af
xor a
ld [hMapAnims], a
.WaitLY:
ld a, [rLY]
cp $60
jr c, .WaitLY
di
ld a, BANK(vBGMap2)
ld [rVBK], a
hlcoord 0, 0, wAttrMap
call .CopyTilemapAtOnce
ld a, BANK(vBGMap0)
ld [rVBK], a
hlcoord 0, 0
call .CopyTilemapAtOnce
.WaitLY2:
ld a, [rLY]
cp $60
jr c, .WaitLY2
ei
pop af
ld [hMapAnims], a
pop af
ld [hBGMapMode], a
ret
.CopyTilemapAtOnce: ; 4cf80 (13:4f80)
ld [hSPBuffer], sp ; $ffd9
ld sp, hl
ld a, [hBGMapAddress + 1]
ld h, a
ld l, 0
ld a, SCREEN_HEIGHT
ld [hTilesPerCycle], a
ld b, 1 << 1
ld c, LOW(rSTAT)
.loop
rept SCREEN_WIDTH / 2
pop de
.loop\@
ld a, [$ff00+c]
and b
jr nz, .loop\@
ld [hl], e
inc l
ld [hl], d
inc l
endr
ld de, BG_MAP_WIDTH - SCREEN_WIDTH
add hl, de
ld a, [hTilesPerCycle]
dec a
ld [hTilesPerCycle], a
jr nz, .loop
ld a, [hSPBuffer]
ld l, a
ld a, [hSPBuffer + 1]
ld h, a
ld sp, hl
ret

View File

@@ -1,21 +0,0 @@
TownMap_ConvertLineBreakCharacters: ; 1de2c5
ld hl, wStringBuffer1
.loop
ld a, [hl]
cp "@"
jr z, .end
cp "%"
jr z, .line_break
cp "¯"
jr z, .line_break
inc hl
jr .loop
.line_break
ld [hl], "<LNBRK>"
.end
ld de, wStringBuffer1
hlcoord 9, 0
call PlaceString
ret