title / diploma / vending machine

This commit is contained in:
YamaArashi 2015-07-17 00:16:27 -07:00
parent 9fbd9e9a1f
commit aa3da5f3b0
7 changed files with 159 additions and 121 deletions

View file

@ -20,9 +20,14 @@ D_LEFT EQU %00100000
D_UP EQU %01000000 D_UP EQU %01000000
D_DOWN EQU %10000000 D_DOWN EQU %10000000
PIXELS_PER_TILE EQU 8
SCREEN_WIDTH EQU 20 SCREEN_WIDTH EQU 20
SCREEN_HEIGHT EQU 18 SCREEN_HEIGHT EQU 18
SCREEN_WIDTH_PIXELS EQU SCREEN_WIDTH * PIXELS_PER_TILE
SCREEN_HEIGHT_PIXELS EQU SCREEN_HEIGHT * PIXELS_PER_TILE
NPC_MOVEMENT_DOWN EQU $00 NPC_MOVEMENT_DOWN EQU $00
NPC_MOVEMENT_UP EQU $40 NPC_MOVEMENT_UP EQU $40
NPC_MOVEMENT_LEFT EQU $80 NPC_MOVEMENT_LEFT EQU $80

View file

@ -36,19 +36,23 @@ DisplayDiploma: ; 566e2 (15:66e2)
hlCoord 10, 4 hlCoord 10, 4
ld de, wPlayerName ld de, wPlayerName
call PlaceString call PlaceString
callba Func_44dd callba DrawPlayerCharacter
; Move the player 33 pixels right and set the priority bit so he appears
; behind the background layer.
ld hl, wOAMBuffer + $01 ld hl, wOAMBuffer + $01
ld bc, $8028 ld bc, $8028
.asm_5673e .adjustPlayerGfxLoop
ld a, [hl] ld a, [hl] ; X
add $21 add 33
ld [hli], a ld [hli], a
inc hl inc hl
ld a, b ld a, b
ld [hli], a ld [hli], a ; attributes
inc hl inc hl
dec c dec c
jr nz, .asm_5673e jr nz, .adjustPlayerGfxLoop
call EnableLCD call EnableLCD
callba LoadTrainerInfoTextBoxTiles callba LoadTrainerInfoTextBoxTiles
ld b, $8 ld b, $8
@ -65,15 +69,17 @@ DisplayDiploma: ; 566e2 (15:66e2)
call Delay3 call Delay3
jp GBPalNormal jp GBPalNormal
Func_56777: ; 56777 (15:6777) UnusedPlayerNameLengthFunc: ; 56777 (15:6777)
; Unused function that does a calculation involving the length of the player's
; name.
ld hl, wPlayerName ld hl, wPlayerName
ld bc, $ff00 ld bc, $ff00
.asm_5677d .loop
ld a, [hli] ld a, [hli]
cp $50 cp "@"
ret z ret z
dec c dec c
jr .asm_5677d jr .loop
DiplomaTextPointersAndCoords: ; 56784 (15:6784) DiplomaTextPointersAndCoords: ; 56784 (15:6784)
dw DiplomaText dw DiplomaText

View file

@ -7,19 +7,19 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
xor a xor a
ld [wCurrentMenuItem], a ld [wCurrentMenuItem], a
ld [wLastMenuItem], a ld [wLastMenuItem], a
ld a, $3 ld a, A_BUTTON | B_BUTTON
ld [wMenuWatchedKeys], a ld [wMenuWatchedKeys], a
ld a, $3 ld a, 3
ld [wMaxMenuItem], a ld [wMaxMenuItem], a
ld a, $5 ld a, 5
ld [wTopMenuItemY], a ld [wTopMenuItemY], a
ld a, $1 ld a, 1
ld [wTopMenuItemX], a ld [wTopMenuItemX], a
ld hl, wd730 ld hl, wd730
set 6, [hl] set 6, [hl]
hlCoord 0, 3 hlCoord 0, 3
ld b, $8 ld b, 8
ld c, $c ld c, 12
call TextBoxBorder call TextBoxBorder
call UpdateSprites call UpdateSprites
hlCoord 2, 5 hlCoord 2, 5
@ -31,11 +31,11 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
ld hl, wd730 ld hl, wd730
res 6, [hl] res 6, [hl]
call HandleMenuInput call HandleMenuInput
bit 1, a bit 1, a ; pressed B?
jr nz, .asm_74f93 jr nz, .notThirsty
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
cp $3 cp 3 ; chose Cancel?
jr z, .asm_74f93 jr z, .notThirsty
xor a xor a
ld [$ff9f], a ld [$ff9f], a
ld [$ffa1], a ld [$ffa1], a
@ -46,12 +46,13 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
ld hl, VendingMachineText4 ld hl, VendingMachineText4
jp PrintText jp PrintText
.enoughMoney .enoughMoney
call Func_74fe7 call LoadVendingMachineItem
ld a, [$ffdb] ld a, [hVendingMachineItem]
ld b, a ld b, a
ld c, 1 ld c, 1
call GiveItem call GiveItem
jr nc, .BagFull jr nc, .BagFull
ld b, 60 ; number of times to play the "brrrrr" sound ld b, 60 ; number of times to play the "brrrrr" sound
.playDeliverySound .playDeliverySound
ld c, 2 ld c, 2
@ -62,10 +63,10 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
pop bc pop bc
dec b dec b
jr nz, .playDeliverySound jr nz, .playDeliverySound
.asm_74f72
ld hl, VendingMachineText5 ld hl, VendingMachineText5
call PrintText call PrintText
ld hl, $ffde ld hl, hVendingMachinePrice + 2
ld de, wPlayerMoney + 2 ld de, wPlayerMoney + 2
ld c, $3 ld c, $3
predef SubBCDPredef predef SubBCDPredef
@ -75,7 +76,7 @@ VendingMachineMenu: ; 74ee0 (1d:4ee0)
.BagFull .BagFull
ld hl, VendingMachineText6 ld hl, VendingMachineText6
jp PrintText jp PrintText
.asm_74f93 .notThirsty
ld hl, VendingMachineText7 ld hl, VendingMachineText7
jp PrintText jp PrintText
@ -110,22 +111,22 @@ VendingMachineText7: ; 74fe2 (1d:4fe2)
TX_FAR _VendingMachineText7 TX_FAR _VendingMachineText7
db "@" db "@"
Func_74fe7: ; 74fe7 (1d:4fe7) LoadVendingMachineItem: ; 74fe7 (1d:4fe7)
ld hl, VendingPrices ld hl, VendingPrices
ld a, [wCurrentMenuItem] ld a, [wCurrentMenuItem]
add a add a
add a add a
ld d, $0 ld d, 0
ld e, a ld e, a
add hl, de add hl, de
ld a, [hli] ld a, [hli]
ld [$ffdb], a ld [hVendingMachineItem], a
ld a, [hli] ld a, [hli]
ld [$ffdc], a ld [hVendingMachinePrice], a
ld a, [hli] ld a, [hli]
ld [$ffdd], a ld [hVendingMachinePrice + 1], a
ld a, [hl] ld a, [hl]
ld [$ffde], a ld [hVendingMachinePrice + 2], a
ret ret
VendingPrices: ; 75000 (1d:5000) VendingPrices: ; 75000 (1d:5000)

View file

@ -67,50 +67,60 @@ ENDC
ld a, BANK(Version_GFX) ld a, BANK(Version_GFX)
call FarCopyDataDouble call FarCopyDataDouble
call Func_4519 call ClearBothBGMaps
; place tiles for pokemon logo (except for the last row)
hlCoord 2, 1 hlCoord 2, 1
ld a, $80 ld a, $80
ld de, SCREEN_WIDTH ld de, SCREEN_WIDTH
ld c, $6 ld c, 6
.asm_434d .pokemonLogoTileLoop
ld b, $10 ld b, $10
push hl push hl
.asm_4350 .pokemonLogoTileRowLoop ; place tiles for one row
ld [hli], a ld [hli], a
inc a inc a
dec b dec b
jr nz, .asm_4350 jr nz, .pokemonLogoTileRowLoop
pop hl pop hl
add hl, de add hl, de
dec c dec c
jr nz, .asm_434d jr nz, .pokemonLogoTileLoop
; place tiles for the last row of the pokemon logo
hlCoord 2, 7 hlCoord 2, 7
ld a, $31 ld a, $31
ld b, $10 ld b, $10
.asm_4361 .pokemonLogoLastTileRowLoop
ld [hli], a ld [hli], a
inc a inc a
dec b dec b
jr nz, .asm_4361 jr nz, .pokemonLogoLastTileRowLoop
call Func_44dd
call DrawPlayerCharacter
; put a pokeball in the player's hand
ld hl, wOAMBuffer + $28 ld hl, wOAMBuffer + $28
ld a, $74 ld a, $74
ld [hl], a ld [hl], a
; place tiles for title screen copyright
hlCoord 2, 17 hlCoord 2, 17
ld de, .titlescreenTilemap ld de, .tileScreenCopyrightTiles
ld b, $10 ld b, $10
.asm_4377 .tileScreenCopyrightTilesLoop
ld a, [de] ld a, [de]
ld [hli], a ld [hli], a
inc de inc de
dec b dec b
jr nz, .asm_4377 jr nz, .tileScreenCopyrightTilesLoop
jr .asm_438f
.titlescreenTilemap ; 437f (1:437f) jr .next
.tileScreenCopyrightTiles ; 437f (1:437f)
db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc. db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc.
.asm_438f .next
call SaveScreenTilesToBuffer2 call SaveScreenTilesToBuffer2
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
call EnableLCD call EnableLCD
@ -121,37 +131,39 @@ IF DEF(_BLUE)
ld a,SQUIRTLE ; which Pokemon to show first on the title screen ld a,SQUIRTLE ; which Pokemon to show first on the title screen
ENDC ENDC
ld [wWhichTrade], a ld [wTitleMonSpecies], a
call Func_4524 call LoadTitleMonSprite
ld a, $9b ld a, (vBGMap0 + $300) / $100
call Func_4533 call TitleScreenCopyTileMapToVRAM
call SaveScreenTilesToBuffer1 call SaveScreenTilesToBuffer1
ld a, $40 ld a, $40
ld [hWY], a ld [hWY], a
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
ld a, $98 ld a, vBGMap0 / $100
call Func_4533 call TitleScreenCopyTileMapToVRAM
ld b, $6 ld b, $6
call GoPAL_SET call GoPAL_SET
call GBPalNormal call GBPalNormal
ld a, $e4 ld a, %11100100
ld [rOBP0], a ld [rOBP0], a
ld bc, $ffaf ; background scroll Y
; make pokemon logo bounce up and down
ld bc, hSCY ; background scroll Y
ld hl, .TitleScreenPokemonLogoYScrolls ld hl, .TitleScreenPokemonLogoYScrolls
.asm_43c6 .bouncePokemonLogoLoop
ld a, [hli] ld a, [hli]
and a and a
jr z, .asm_43f4 jr z, .finishedBouncingPokemonLogo
ld d, a ld d, a
cp $fd cp -3
jr nz, .asm_43d4 jr nz, .skipPlayingSound
ld a, (SFX_1f_62 - SFX_Headers_1f) / 3 ld a, (SFX_1f_62 - SFX_Headers_1f) / 3
call PlaySound call PlaySound
.asm_43d4 .skipPlayingSound
ld a, [hli] ld a, [hli]
ld e, a ld e, a
call .ScrollTitleScreenPokemonLogo call .ScrollTitleScreenPokemonLogo
jr .asm_43c6 jr .bouncePokemonLogoLoop
.TitleScreenPokemonLogoYScrolls: ; 43db (1:43db) .TitleScreenPokemonLogoYScrolls: ; 43db (1:43db)
; Controls the bouncing effect of the Pokemon logo on the title screen ; Controls the bouncing effect of the Pokemon logo on the title screen
@ -168,36 +180,40 @@ ENDC
; Scrolls the Pokemon logo on the title screen to create the bouncing effect ; Scrolls the Pokemon logo on the title screen to create the bouncing effect
; Scrolls d pixels e times ; Scrolls d pixels e times
call DelayFrame call DelayFrame
ld a, [bc] ld a, [bc] ; background scroll Y
add d add d
ld [bc], a ld [bc], a
dec e dec e
jr nz, .ScrollTitleScreenPokemonLogo jr nz, .ScrollTitleScreenPokemonLogo
ret ret
.asm_43f4
.finishedBouncingPokemonLogo
call LoadScreenTilesFromBuffer1 call LoadScreenTilesFromBuffer1
ld c, 36 ld c, 36
call DelayFrames call DelayFrames
ld a, (SFX_1f_63 - SFX_Headers_1f) / 3 ld a, (SFX_1f_63 - SFX_Headers_1f) / 3
call PlaySound call PlaySound
; scroll game version in from the right
call PrintGameVersionOnTitleScreen call PrintGameVersionOnTitleScreen
ld a, $90 ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a ld [hWY], a
ld d, $90 ld d, 144
.asm_440a .scrollTitleScreenGameVersionLoop
ld h, d ld h, d
ld l, $40 ld l, 64
call Func_44cf call ScrollTitleScreenGameVersion
ld h, $0 ld h, 0
ld l, $50 ld l, 80
call Func_44cf call ScrollTitleScreenGameVersion
ld a, d ld a, d
add $4 add 4
ld d, a ld d, a
and a and a
jr nz, .asm_440a jr nz, .scrollTitleScreenGameVersionLoop
ld a, $9c
call Func_4533 ld a, vBGMap1 / $100
call TitleScreenCopyTileMapToVRAM
call LoadScreenTilesFromBuffer2 call LoadScreenTilesFromBuffer2
call PrintGameVersionOnTitleScreen call PrintGameVersionOnTitleScreen
call Delay3 call Delay3
@ -207,19 +223,22 @@ ENDC
call PlaySound call PlaySound
xor a xor a
ld [wcc5b], a ld [wcc5b], a
.asm_443b
ld c, $c8 ; Keep scrolling in new mons indefinitely until the user performs input.
.awaitUserInterruptionLoop
ld c, 200
call CheckForUserInterruption call CheckForUserInterruption
jr c, .asm_4459 jr c, .finishedWaiting
call Func_44c1 call TitleScreenScrollInMon
ld c, $1 ld c, 1
call CheckForUserInterruption call CheckForUserInterruption
jr c, .asm_4459 jr c, .finishedWaiting
callba Func_372ac callba TitleScreenAnimateBallIfStarterOut
call Func_4496 call TitleScreenPickNewMon
jr .asm_443b jr .awaitUserInterruptionLoop
.asm_4459
ld a, [wWhichTrade] .finishedWaiting
ld a, [wTitleMonSpecies]
call PlayCry call PlayCry
call WaitForSoundToFinish call WaitForSoundToFinish
call GBPalWhiteOutWithDelay3 call GBPalWhiteOutWithDelay3
@ -229,10 +248,10 @@ ENDC
inc a inc a
ld [H_AUTOBGTRANSFERENABLED], a ld [H_AUTOBGTRANSFERENABLED], a
call ClearScreen call ClearScreen
ld a, $98 ld a, vBGMap0 / $100
call Func_4533 call TitleScreenCopyTileMapToVRAM
ld a, $9c ld a, vBGMap1 / $100
call Func_4533 call TitleScreenCopyTileMapToVRAM
call Delay3 call Delay3
call LoadGBPal call LoadGBPal
ld a, [hJoyHeld] ld a, [hJoyHeld]
@ -247,12 +266,12 @@ ENDC
ld hl, DoClearSaveDialogue ld hl, DoClearSaveDialogue
jp Bankswitch jp Bankswitch
Func_4496: ; 4496 (1:4496) TitleScreenPickNewMon: ; 4496 (1:4496)
ld a, $98 ld a, vBGMap0 / $100
call Func_4533 call TitleScreenCopyTileMapToVRAM
.new .loop
; Generate a new TitleMon. ; Keep looping until a mon different from the current one is picked.
call Random call Random
and $f and $f
ld c, a ld c, a
@ -260,14 +279,14 @@ Func_4496: ; 4496 (1:4496)
ld hl, TitleMons ld hl, TitleMons
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
ld hl, wWhichTrade ld hl, wTitleMonSpecies
; Can't be the same as before. ; Can't be the same as before.
cp [hl] cp [hl]
jr z, .new jr z, .loop
ld [hl], a ld [hl], a
call Func_4524 call LoadTitleMonSprite
ld a, $90 ld a, $90
ld [hWY], a ld [hWY], a
@ -275,14 +294,14 @@ Func_4496: ; 4496 (1:4496)
callba TitleScroll callba TitleScroll
ret ret
Func_44c1: ; 44c1 (1:44c1) TitleScreenScrollInMon: ; 44c1 (1:44c1)
ld d, 0 ; scroll in ld d, 0 ; scroll in
callba TitleScroll callba TitleScroll
xor a xor a
ld [hWY], a ld [hWY], a
ret ret
Func_44cf: ; 44cf (1:44cf) ScrollTitleScreenGameVersion: ; 44cf (1:44cf)
.wait .wait
ld a, [rLY] ld a, [rLY]
cp l cp l
@ -297,7 +316,7 @@ Func_44cf: ; 44cf (1:44cf)
jr z, .wait2 jr z, .wait2
ret ret
Func_44dd: ; 44dd (1:44dd) DrawPlayerCharacter: ; 44dd (1:44dd)
ld hl, PlayerCharacterTitleGraphics ld hl, PlayerCharacterTitleGraphics
ld de, vSprites ld de, vSprites
ld bc, $230 ld bc, $230
@ -305,49 +324,49 @@ Func_44dd: ; 44dd (1:44dd)
call FarCopyData2 call FarCopyData2
call ClearSprites call ClearSprites
xor a xor a
ld [wWhichTrade], a ld [wPlayerCharacterOAMTile], a
ld hl, wOAMBuffer ld hl, wOAMBuffer
ld de, $605a ld de, $605a
ld b, $7 ld b, 7
.asm_44fa .loop
push de push de
ld c, $5 ld c, 5
.asm_44fd .innerLoop
ld a, d ld a, d
ld [hli], a ld [hli], a ; Y
ld a, e ld a, e
ld [hli], a ld [hli], a ; X
add $8 add 8
ld e, a ld e, a
ld a, [wWhichTrade] ld a, [wPlayerCharacterOAMTile]
ld [hli], a ld [hli], a ; tile
inc a inc a
ld [wWhichTrade], a ld [wPlayerCharacterOAMTile], a
inc hl inc hl
dec c dec c
jr nz, .asm_44fd jr nz, .innerLoop
pop de pop de
ld a, $8 ld a, 8
add d add d
ld d, a ld d, a
dec b dec b
jr nz, .asm_44fa jr nz, .loop
ret ret
Func_4519: ; 4519 (1:4519) ClearBothBGMaps: ; 4519 (1:4519)
ld hl, vBGMap0 ld hl, vBGMap0
ld bc, $800 ld bc, $400 * 2
ld a, $7f ld a, " "
jp FillMemory jp FillMemory
Func_4524: ; 4524 (1:4524) LoadTitleMonSprite: ; 4524 (1:4524)
ld [wcf91], a ld [wcf91], a
ld [wd0b5], a ld [wd0b5], a
hlCoord 5, 10 hlCoord 5, 10
call GetMonHeader call GetMonHeader
jp LoadFrontSpriteByMonIndex jp LoadFrontSpriteByMonIndex
Func_4533: ; 4533 (1:4533) TitleScreenCopyTileMapToVRAM: ; 4533 (1:4533)
ld [H_AUTOBGTRANSFERDEST + 1], a ld [H_AUTOBGTRANSFERDEST + 1], a
jp Delay3 jp Delay3

View file

@ -87,9 +87,9 @@ TitleBallYTable: ; 372a0 (d:72a0)
; This is really two 0-terminated lists. Initiated with an index of 1. ; This is really two 0-terminated lists. Initiated with an index of 1.
db 0, $71, $6f, $6e, $6d, $6c, $6d, $6e, $6f, $71, $74, 0 db 0, $71, $6f, $6e, $6d, $6c, $6d, $6e, $6f, $71, $74, 0
Func_372ac: ; 372ac (d:72ac) TitleScreenAnimateBallIfStarterOut: ; 372ac (d:72ac)
; Animate the TitleBall if a starter just got scrolled out. ; Animate the TitleBall if a starter just got scrolled out.
ld a, [wWhichTrade] ld a, [wTitleMonSpecies]
cp STARTER1 cp STARTER1
jr z, .ok jr z, .ok
cp STARTER2 cp STARTER2

View file

@ -201,6 +201,9 @@ hTilesetType EQU $FFD7
H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10 H_CURRENTSPRITEOFFSET EQU $FFDA ; multiple of $10
hVendingMachineItem EQU $FFDB
hVendingMachinePrice EQU $FFDC ; 3-byte BCD number
hNewPartyLength EQU $FFE4 hNewPartyLength EQU $FFE4
hDividend2 EQU $FFE5 hDividend2 EQU $FFE5

View file

@ -634,6 +634,10 @@ wOverrideSimulatedJoypadStatesMask:: ; cd3b
ds 1 ds 1
wTitleMonSpecies:: ; cd3d
wPlayerCharacterOAMTile:: ; cd3d
wMoveDownSmallStarsOAMCount:: ; cd3d wMoveDownSmallStarsOAMCount:: ; cd3d
; the number of small stars OAM entries to move down ; the number of small stars OAM entries to move down