Fix unnecessary white space and retire add_n_times

This commit is contained in:
PikalaxALT
2015-07-20 11:28:05 -04:00
parent bef792f2d2
commit d9300a9bec
14 changed files with 997 additions and 600 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -6,16 +6,18 @@ FishAction: ; 92402
push af push af
push bc push bc
push hl push hl
; Get the fishing group for this map. ; Get the fishing group for this map.
ld b, e ld b, e
call GetFishGroupHeader call GetFishGroupHeader
ld hl, FishGroupHeaders ld hl, FishGroupHeaders
add_n_times hl, de, 7 rept 7
add hl, de
endr
call Fish call Fish
pop hl pop hl
pop bc pop bc
pop af pop af
@@ -42,29 +44,31 @@ Fish: ; 9241a
inc hl inc hl
ld e, b ld e, b
ld d, 0 ld d, 0
add_n_times hl, de, 2 rept 2
add hl, de
endr
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
; Encounter chance for this monster: ; Encounter chance for this monster:
call Random call Random
.CheckEncounter .CheckEncounter
cp [hl] cp [hl]
jr z, .ReadMon jr z, .ReadMon
jr c, .ReadMon jr c, .ReadMon
; Next monster... ; Next monster...
inc hl inc hl
inc hl inc hl
inc hl inc hl
jr .CheckEncounter jr .CheckEncounter
.ReadMon .ReadMon
; We're done with the encounter chance ; We're done with the encounter chance
inc hl inc hl
; Species 0 triggers a read from a time-based encounter table. ; Species 0 triggers a read from a time-based encounter table.
ld a, [hli] ld a, [hli]
ld d, a ld d, a
@@ -74,21 +78,20 @@ Fish: ; 9241a
; Level ; Level
ld e, [hl] ld e, [hl]
ret ret
.NoBite .NoBite
ld de, 0 ld de, 0
ret ret
.TimeEncounter .TimeEncounter
; The level byte is repurposed as the index for the new table. ; The level byte is repurposed as the index for the new table.
ld e, [hl] ld e, [hl]
ld d, 0 ld d, 0
ld hl, TimeFishGroups ld hl, TimeFishGroups
rept 4
add hl, de add hl, de
add hl, de endr
add hl, de
add hl, de
; One nightmon, then one daymon ; One nightmon, then one daymon
ld a, [TimeOfDay] ld a, [TimeOfDay]
@@ -97,7 +100,7 @@ Fish: ; 9241a
jr c, .TimeSpecies jr c, .TimeSpecies
inc hl inc hl
inc hl inc hl
.TimeSpecies .TimeSpecies
ld d, [hl] ld d, [hl]
inc hl inc hl
@@ -115,27 +118,27 @@ GetFishGroupHeader: ; 9245b
bit 2, [hl] bit 2, [hl]
pop hl pop hl
jr z, .end jr z, .end
; Groups 11 and 12 have special attributes. ; Groups 11 and 12 have special attributes.
ld a, d ld a, d
cp 11 cp 11
jr z, .group11 jr z, .group11
cp 12 cp 12
jr z, .group12 jr z, .group12
.end .end
dec d dec d
ld e, d ld e, d
ld d, 0 ld d, 0
ret ret
.group11 .group11
ld a, [wdfce] ld a, [wdfce]
cp 1 cp 1
jr nz, .end jr nz, .end
ld d, 6 ld d, 6
jr .end jr .end
.group12 .group12
ld a, [wdfce] ld a, [wdfce]
cp 2 cp 2

View File

@@ -806,7 +806,9 @@ Function9764: ; 9764
Function976b: ; 976b Function976b: ; 976b
ld l, a ld l, a
ld h, 0 ld h, 0
add_n_times hl, hl, 2 rept 2
add hl,hl
endr
ld bc, TrainerPalettes ld bc, TrainerPalettes
add hl, bc add hl, bc
ret ret
@@ -1974,7 +1976,9 @@ Functionb1de: ; b1de
push hl push hl
ld l, a ld l, a
ld h, 0 ld h, 0
add_n_times hl, hl, 3 rept 3
add hl,hl
endr
ld de, TilesetBGPalette ld de, TilesetBGPalette
add hl, de add hl, de
ld e, l ld e, l
@@ -2014,7 +2018,9 @@ Functionb1de: ; b1de
ld a, [MapGroup] ld a, [MapGroup]
ld l, a ld l, a
ld h, 0 ld h, 0
add_n_times hl, hl, 3 rept 3
add hl,hl
endr
ld de, RoofPals ld de, RoofPals
add hl, de add hl, de
ld a, [TimeOfDayPal] ld a, [TimeOfDayPal]

View File

@@ -472,7 +472,9 @@ Function968ec: ; 968ec
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
add_n_times hl, de, 4 rept 4
add hl,de
endr
call GetMapScriptHeaderBank call GetMapScriptHeaderBank
call GetFarHalfword call GetFarHalfword
@@ -1043,7 +1045,9 @@ Function96beb: ; 96beb
ld c, a ld c, a
ld b, 0 ld b, 0
ld hl, ScriptPointers96c0c ld hl, ScriptPointers96c0c
add_n_times hl, bc, 3 rept 3
add hl,bc
endr
ld a, [hli] ld a, [hli]
ld [ScriptBank], a ld [ScriptBank], a
ld a, [hli] ld a, [hli]

View File

@@ -226,7 +226,9 @@ Function444d: ; 444d
ld a, [hl] ld a, [hl]
ld l, a ld l, a
ld h, 0 ld h, 0
add_n_times hl, hl, 2 rept 2
add hl,hl
endr
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
@@ -1385,7 +1387,9 @@ Function4a46: ; 4a46
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, .data_4a81 ld hl, .data_4a81
add_n_times hl, de, 2 rept 2
add hl,de
endr
ld d, [hl] ld d, [hl]
inc hl inc hl
ld e, [hl] ld e, [hl]
@@ -3655,7 +3659,9 @@ Function5ac2: ; 5ac2
ld c, a ld c, a
ld b, 0 ld b, 0
ld hl, .Addresses ld hl, .Addresses
add_n_times hl, bc, 2 rept 2
add hl,bc
endr
ld c, [hl] ld c, [hl]
inc hl inc hl
ld b, [hl] ld b, [hl]

View File

@@ -1,106 +1,108 @@
GetPredefPointer:: ; 854b GetPredefPointer:: ; 854b
; Return the bank and address of PredefID in a and PredefAddress. ; Return the bank and address of PredefID in a and PredefAddress.
; Save hl for later (back in Predef) ; Save hl for later (back in Predef)
ld a, h ld a, h
ld [PredefTemp], a ld [PredefTemp], a
ld a, l ld a, l
ld [PredefTemp + 1], a ld [PredefTemp + 1], a
push de push de
ld a, [PredefID] ld a, [PredefID]
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, PredefPointers ld hl, PredefPointers
add_n_times hl, de, 3 rept 3
pop de add hl,de
endr
ld a, [hli] pop de
ld [PredefAddress + 1], a
ld a, [hli] ld a, [hli]
ld [PredefAddress], a ld [PredefAddress + 1], a
ld a, [hl] ld a, [hli]
ld [PredefAddress], a
ret ld a, [hl]
; 856b
ret
PredefPointers:: ; 856b ; 856b
; $4b Predef pointers
; address, bank PredefPointers:: ; 856b
; $4b Predef pointers
add_predef LearnMove ; $0 ; address, bank
add_predef Predef1
add_predef HealParty add_predef LearnMove ; $0
add_predef FlagPredef add_predef Predef1
add_predef Functionc699 add_predef HealParty
add_predef FillPP add_predef FlagPredef
add_predef Functiond88c add_predef Functionc699
add_predef Functionda96 add_predef FillPP
add_predef Functiondb3f ; $8 add_predef Functiond88c
add_predef Functionde6e add_predef Functionda96
add_predef GiveEgg add_predef Functiondb3f ; $8
add_predef Functionc6e0 add_predef Functionde6e
add_predef Functione167 add_predef GiveEgg
add_predef Functione17b add_predef Functionc6e0
add_predef CanLearnTMHMMove add_predef Functione167
add_predef GetTMHMMove add_predef Functione17b
add_predef Function28eef ; $ 10 add_predef CanLearnTMHMMove
add_predef PrintMoveDesc add_predef GetTMHMMove
add_predef UpdatePlayerHUD add_predef Function28eef ; $ 10
add_predef FillBox add_predef PrintMoveDesc
add_predef Function3d873 add_predef UpdatePlayerHUD
add_predef UpdateEnemyHUD add_predef FillBox
add_predef StartBattle add_predef Function3d873
add_predef FillInExpBar add_predef UpdateEnemyHUD
add_predef Function3f43d ; $18 add_predef StartBattle
add_predef Function3f47c add_predef FillInExpBar
add_predef LearnLevelMoves add_predef Function3f43d ; $18
add_predef FillMoves add_predef Function3f47c
add_predef Function421e6 add_predef LearnLevelMoves
add_predef Function28f63 add_predef FillMoves
add_predef Function28f24 add_predef Function421e6
add_predef Function5084a add_predef Function28f63
add_predef ListMoves ; $20 add_predef Function28f24
add_predef Function50d2e add_predef Function5084a
add_predef Function50cdb add_predef ListMoves ; $20
add_predef Function50c50 add_predef Function50d2e
add_predef GetGender add_predef Function50cdb
add_predef StatsScreenInit add_predef Function50c50
add_predef DrawPlayerHP add_predef GetGender
add_predef DrawEnemyHP add_predef StatsScreenInit
add_predef PrintTempMonStats ; $28 add_predef DrawPlayerHP
add_predef GetTypeName add_predef DrawEnemyHP
add_predef PrintMoveType add_predef PrintTempMonStats ; $28
add_predef PrintType add_predef GetTypeName
add_predef PrintMonTypes add_predef PrintMoveType
add_predef GetUnownLetter add_predef PrintType
add_predef Functioncbcdd add_predef PrintMonTypes
add_predef Predef2F add_predef GetUnownLetter
add_predef Function9853 ; $30 add_predef Functioncbcdd
add_predef Function864c add_predef Predef2F
add_predef Function91d11 add_predef Function9853 ; $30
add_predef CheckContestMon add_predef Function864c
add_predef Function8c20f add_predef Function91d11
add_predef Function8c000 add_predef CheckContestMon
add_predef Function8c000_2 add_predef Function8c20f
add_predef PlayBattleAnim add_predef Function8c000
add_predef Predef38 ; $38 add_predef Function8c000_2
add_predef Predef39 add_predef PlayBattleAnim
add_predef Functionfd1d0 add_predef Predef38 ; $38
add_predef PartyMonItemName add_predef Predef39
add_predef GetFrontpic add_predef Functionfd1d0
add_predef GetBackpic add_predef PartyMonItemName
add_predef Function5108b add_predef GetFrontpic
add_predef GetTrainerPic add_predef GetBackpic
add_predef DecompressPredef ; $40 add_predef Function5108b
add_predef Function347d3 add_predef GetTrainerPic
add_predef ConvertMon_1to2 add_predef DecompressPredef ; $40
add_predef Functionfb877 add_predef Function347d3
add_predef Functiond0000 add_predef ConvertMon_1to2
add_predef Function50d0a add_predef Functionfb877
add_predef Functiond00a3 add_predef Functiond0000
add_predef Functiond008e add_predef Function50d0a
add_predef Functiond0669 ; $48 add_predef Functiond00a3
add_predef Functiond066e add_predef Functiond008e
dbw $ff, Function2d43 ; ???? add_predef Functiond0669 ; $48
add_predef Functiond066e
dbw $ff, Function2d43 ; ????
; 864c ; 864c

View File

@@ -3144,7 +3144,9 @@ ExitScriptSubroutine: ; 0x97b9a
ld e, [hl] ld e, [hl]
ld d, $0 ld d, $0
ld hl, wd43d ld hl, wd43d
add_n_times hl, de, 3 rept 3
add hl,de
endr
ld a, [hli] ld a, [hli]
ld b, a ld b, a
and " " and " "

View File

@@ -56,7 +56,9 @@ LoadSpawnPoint: ; 1531f
jr z, .spawn_n_a jr z, .spawn_n_a
ld l, a ld l, a
ld h, 0 ld h, 0
add_n_times hl, hl, 2 ; multiply hl by 4 rept 2 ; multiply hl by 4
add hl,hl
endr
ld de, SpawnPoints ld de, SpawnPoints
add hl, de add hl, de
ld a, [hli] ld a, [hli]

View File

@@ -2,7 +2,9 @@
Special:: ; c01b Special:: ; c01b
; Run script special de. ; Run script special de.
ld hl, SpecialsPointers ld hl, SpecialsPointers
add_n_times hl, de, 3 rept 3
add hl,de
endr
ld b, [hl] ld b, [hl]
inc hl inc hl
ld a, [hli] ld a, [hli]

View File

@@ -715,14 +715,14 @@ ClearPalettes:: ; 3317
ld a, [hCGB] ld a, [hCGB]
and a and a
jr nz, .cgb jr nz, .cgb
; DMG: just change palettes to 0 (white) ; DMG: just change palettes to 0 (white)
xor a xor a
ld [rBGP], a ld [rBGP], a
ld [rOBP0], a ld [rOBP0], a
ld [rOBP1], a ld [rOBP1], a
ret ret
.cgb .cgb
ld a, [rSVBK] ld a, [rSVBK]
push af push af
@@ -755,11 +755,11 @@ GetSGBLayout:: ; 3340
ld a, [hCGB] ld a, [hCGB]
and a and a
jr nz, .sgb jr nz, .sgb
ld a, [hSGB] ld a, [hSGB]
and a and a
ret z ret z
.sgb .sgb
predef_jump Function864c ; LoadSGBLayout predef_jump Function864c ; LoadSGBLayout
; 334e ; 334e
@@ -872,7 +872,9 @@ GetName:: ; 33c3
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, NamesPointers ld hl, NamesPointers
add_n_times hl, de, 3 rept 3
add hl, de
endr
ld a, [hli] ld a, [hli]
rst Bankswitch rst Bankswitch
ld a, [hli] ld a, [hli]
@@ -1788,7 +1790,7 @@ GetBaseData:: ; 3856
push af push af
ld a, BANK(BaseData) ld a, BANK(BaseData)
rst Bankswitch rst Bankswitch
; Egg doesn't have BaseData ; Egg doesn't have BaseData
ld a, [CurSpecies] ld a, [CurSpecies]
cp EGG cp EGG
@@ -1803,16 +1805,16 @@ GetBaseData:: ; 3856
ld bc, BaseData1 - BaseData0 ld bc, BaseData1 - BaseData0
call CopyBytes call CopyBytes
jr .end jr .end
.egg .egg
; ???? ; ????
ld de, UnknownEggPic ld de, UnknownEggPic
; Sprite dimensions ; Sprite dimensions
ld b, $55 ; 5x5 ld b, $55 ; 5x5
ld hl, BasePicSize ld hl, BasePicSize
ld [hl], b ld [hl], b
; ???? ; ????
ld hl, BasePadding ld hl, BasePadding
ld [hl], e ld [hl], e
@@ -1823,12 +1825,12 @@ GetBaseData:: ; 3856
inc hl inc hl
ld [hl], d ld [hl], d
jr .end jr .end
.end .end
; Replace Pokedex # with species ; Replace Pokedex # with species
ld a, [CurSpecies] ld a, [CurSpecies]
ld [BaseDexNo], a ld [BaseDexNo], a
pop af pop af
rst Bankswitch rst Bankswitch
pop hl pop hl

View File

@@ -150,7 +150,9 @@ Function2198:: ; 2198
add a add a
ld l, a ld l, a
ld h, 0 ld h, 0
add_n_times hl, hl, 3 rept 3
add hl,hl
endr
ld a, [TilesetBlocksAddress] ld a, [TilesetBlocksAddress]
add l add l
ld l, a ld l, a
@@ -1703,7 +1705,9 @@ GetFacingTileCoord:: ; 2a07
srl a srl a
ld l, a ld l, a
ld h, 0 ld h, 0
add_n_times hl, hl, 2 rept 2
add hl,hl
endr
ld de, .Directions ld de, .Directions
add hl, de add hl, de
@@ -1745,7 +1749,9 @@ Function2a3c:: ; 2a3c
jr z, .nope jr z, .nope
ld l, a ld l, a
ld h, $0 ld h, $0
add_n_times hl, hl, 2 rept 2
add hl,hl
endr
ld a, [TilesetCollisionAddress] ld a, [TilesetCollisionAddress]
ld c, a ld c, a
ld a, [TilesetCollisionAddress + 1] ld a, [TilesetCollisionAddress + 1]

View File

@@ -493,7 +493,9 @@ Function1a2f:: ; 1a2f
ld hl, ObjectStruct3_Data ld hl, ObjectStruct3_Data
ld e, a ld e, a
ld d, 0 ld d, 0
add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH rept OBJECT_STRUCT_3_DATA_WIDTH
add hl,de
endr
ld a, [hl] ld a, [hl]
ret ret
; 1a47 ; 1a47
@@ -504,7 +506,9 @@ Function1a47:: ; 1a47
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, ObjectStruct3_Data + 1 ld hl, ObjectStruct3_Data + 1
add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH rept OBJECT_STRUCT_3_DATA_WIDTH
add hl,de
endr
ld a, BANK(ObjectStruct3_Data) ld a, BANK(ObjectStruct3_Data)
call GetFarByte call GetFarByte
add a add a
@@ -542,7 +546,9 @@ Function1a71:: ; 1a71
ld e, a ld e, a
ld d, 0 ld d, 0
ld hl, ObjectStruct3_Data + 1 ld hl, ObjectStruct3_Data + 1
add_n_times hl, de, OBJECT_STRUCT_3_DATA_WIDTH rept OBJECT_STRUCT_3_DATA_WIDTH
add hl,de
endr
ld b, h ld b, h
ld c, l ld c, l
pop de pop de

View File

@@ -142,9 +142,3 @@ bcd: MACRO
shift shift
endr endr
ENDM ENDM
add_n_times: MACRO
rept \3
add \1, \2
endr
ENDM

1070
main.asm

File diff suppressed because it is too large Load Diff