ref: 62b756c46e5c527a3a3fe2fea0ac99d96bb8cf3e
parent: 7254c100931d6c96c877ca7a2db3dc03076d138a
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sun Nov 8 14:32:57 EST 2020
Rename "dummy game" to "memory game"
--- a/constants/sprite_anim_constants.asm
+++ b/constants/sprite_anim_constants.asm
@@ -46,7 +46,7 @@
const SPRITE_ANIM_INDEX_COMPOSE_MAIL_CURSOR ; 09
const SPRITE_ANIM_INDEX_RED_WALK ; 0a
const SPRITE_ANIM_INDEX_UNUSED_CURSOR ; 0b
- const SPRITE_ANIM_INDEX_DUMMY_GAME ; 0c
+ const SPRITE_ANIM_INDEX_MEMORY_GAME_CURSOR ; 0c
const SPRITE_ANIM_INDEX_POKEGEAR_ARROW ; 0d
const SPRITE_ANIM_INDEX_TRADE_POKE_BALL ; 0e
const SPRITE_ANIM_INDEX_TRADE_POOF ; 0f
@@ -96,7 +96,7 @@
const SPRITE_ANIM_SEQ_SLOTS_EGG ; 0b
const SPRITE_ANIM_SEQ_MAIL_CURSOR ; 0c
const SPRITE_ANIM_SEQ_UNUSED_CURSOR ; 0d
- const SPRITE_ANIM_SEQ_DUMMY_GAME_CURSOR ; 0e
+ const SPRITE_ANIM_SEQ_MEMORY_GAME_CURSOR ; 0e
const SPRITE_ANIM_SEQ_POKEGEAR_ARROW ; 0f
const SPRITE_ANIM_SEQ_TRADE_POKE_BALL ; 10
const SPRITE_ANIM_SEQ_TRADE_TUBE_BULGE ; 11
--- a/data/events/special_pointers.asm
+++ b/data/events/special_pointers.asm
@@ -55,7 +55,7 @@
add_special UnownPuzzle
add_special SlotMachine
add_special CardFlip
- add_special UnusedDummyGame ; unused
+ add_special UnusedMemoryGame ; unused
add_special ClearBGPalettesBufferScreen ; unused
add_special FadeOutPalettes
add_special BattleTowerFade
--- a/data/sprite_anims/sequences.asm
+++ b/data/sprite_anims/sequences.asm
@@ -25,8 +25,8 @@
db SPRITE_ANIM_FRAMESET_RED_WALK, SPRITE_ANIM_SEQ_NULL, SPRITE_ANIM_DICT_DEFAULT
; SPRITE_ANIM_INDEX_UNUSED_CURSOR
db SPRITE_ANIM_FRAMESET_STILL_CURSOR, SPRITE_ANIM_SEQ_UNUSED_CURSOR, SPRITE_ANIM_DICT_ARROW_CURSOR
-; SPRITE_ANIM_INDEX_DUMMY_GAME
- db SPRITE_ANIM_FRAMESET_STILL_CURSOR, SPRITE_ANIM_SEQ_DUMMY_GAME_CURSOR, SPRITE_ANIM_DICT_ARROW_CURSOR
+; SPRITE_ANIM_INDEX_MEMORY_GAME_CURSOR
+ db SPRITE_ANIM_FRAMESET_STILL_CURSOR, SPRITE_ANIM_SEQ_MEMORY_GAME_CURSOR, SPRITE_ANIM_DICT_ARROW_CURSOR
; SPRITE_ANIM_INDEX_POKEGEAR_ARROW
db SPRITE_ANIM_FRAMESET_STILL_CURSOR, SPRITE_ANIM_SEQ_POKEGEAR_ARROW, SPRITE_ANIM_DICT_ARROW_CURSOR
; SPRITE_ANIM_INDEX_TRADE_POKE_BALL
--- a/data/text/common_2.asm
+++ b/data/text/common_2.asm
@@ -1368,11 +1368,11 @@
para ""
done
-_DummyGameYeahText::
+_MemoryGameYeahText::
text " , yeah!"
done
-_DummyGameDarnText::
+_MemoryGameDarnText::
text "Darn…"
done
--- a/engine/events/specials.asm
+++ b/engine/events/specials.asm
@@ -206,11 +206,11 @@
call StartGameCornerGame
ret
-UnusedDummyGame:
+UnusedMemoryGame:
call CheckCoinsAndCoinCase
ret c
- ld a, BANK(_DummyGame)
- ld hl, _DummyGame
+ ld a, BANK(_MemoryGame)
+ ld hl, _MemoryGame
call StartGameCornerGame
ret
--- a/engine/games/card_flip.asm
+++ b/engine/games/card_flip.asm
@@ -4,7 +4,7 @@
CARDFLIP_DECK_SIZE EQUS "(wDeckEnd - wDeck)"
assert wDiscardPileEnd - wDiscardPile == wDeckEnd - wDeck
-DummyGameGFX:
+MemoryGameGFX:
; Graphics for an unused Game Corner
; game were meant to be here.
--- a/engine/games/dummy_game.asm
+++ /dev/null
@@ -1,590 +1,0 @@
-_DummyGame:
- call .LoadGFXAndPals
- call DelayFrame
-.loop
- call .JumptableLoop
- jr nc, .loop
- ret
-
-.LoadGFXAndPals:
- call DisableLCD
- ld b, SCGB_DIPLOMA
- call GetSGBLayout
- callfar ClearSpriteAnims
- ld hl, DummyGameLZ
- ld de, vTiles2 tile $00
- call Decompress
- ld hl, DummyGameGFX
- ld de, vTiles0 tile $00
- ld bc, 4 tiles
- ld a, BANK(DummyGameGFX)
- call FarCopyBytes
- ld a, SPRITE_ANIM_DICT_ARROW_CURSOR
- ld hl, wSpriteAnimDict
- ld [hli], a
- ld [hl], $00
- hlcoord 0, 0
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- xor a
- call ByteFill
- xor a
- ldh [hSCY], a
- ldh [hSCX], a
- ldh [rWY], a
- ld [wJumptableIndex], a
- ld a, $1
- ldh [hBGMapMode], a
- ld a, LCDC_DEFAULT
- ldh [rLCDC], a
- ld a, $e4
- call DmgToCgbBGPals
- ld a, $e0
- call DmgToCgbObjPal0
- ret
-
-.JumptableLoop:
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .quit
- call .ExecuteJumptable
- callfar PlaySpriteAnimations
- call DelayFrame
- and a
- ret
-
-.quit
- scf
- ret
-
-.ExecuteJumptable:
- jumptable .Jumptable, wJumptableIndex
-
-.Jumptable:
- dw .RestartGame
- dw .ResetBoard
- dw .InitBoardTilemapAndCursorObject
- dw .CheckTriesRemaining
- dw .PickCard1
- dw .PickCard2
- dw .DelayPickAgain
- dw .RevealAll
- dw .AskPlayAgain
-
-.RestartGame:
- call DummyGame_InitStrings
- ld hl, wJumptableIndex
- inc [hl]
- ret
-
-.ResetBoard:
- call UnusedCursor_InterpretJoypad_AnimateCursor
- jr nc, .proceed
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-
-.proceed
- call DummyGame_InitBoard
- ld hl, wJumptableIndex
- inc [hl]
- xor a
- ld [wDummyGameCounter], a
- ld hl, wDummyGameLastMatches
-rept 4
- ld [hli], a
-endr
- ld [hl], a
- ld [wDummyGameNumCardsMatched], a
-.InitBoardTilemapAndCursorObject:
- ld hl, wDummyGameCounter
- ld a, [hl]
- cp 45
- jr nc, .spawn_object
- inc [hl]
- call DummyGame_Card2Coord
- xor a
- ld [wDummyGameLastCardPicked], a
- call DummyGame_PlaceCard
- ret
-
-.spawn_object
- depixel 6, 3, 4, 4
- ld a, SPRITE_ANIM_INDEX_DUMMY_GAME
- call InitSpriteAnimStruct
- ld a, 5
- ld [wDummyGameNumberTriesRemaining], a
- ld hl, wJumptableIndex
- inc [hl]
- ret
-
-.CheckTriesRemaining:
- ld a, [wDummyGameNumberTriesRemaining]
- hlcoord 17, 0
- add "0"
- ld [hl], a
- ld hl, wDummyGameNumberTriesRemaining
- ld a, [hl]
- and a
- jr nz, .next_try
- ld a, $7
- ld [wJumptableIndex], a
- ret
-
-.next_try
- dec [hl]
- xor a
- ld [wDummyGameCardChoice], a
- ld hl, wJumptableIndex
- inc [hl]
-.PickCard1:
- ld a, [wDummyGameCardChoice]
- and a
- ret z
- dec a
- ld e, a
- ld d, 0
- ld hl, wDummyGameCards
- add hl, de
- ld a, [hl]
- cp -1
- ret z
- ld [wDummyGameLastCardPicked], a
- ld [wDummyGameCard1], a
- ld a, e
- ld [wDummyGameCard1Location], a
- call DummyGame_Card2Coord
- call DummyGame_PlaceCard
- xor a
- ld [wDummyGameCardChoice], a
- ld hl, wJumptableIndex
- inc [hl]
- ret
-
-.PickCard2:
- ld a, [wDummyGameCardChoice]
- and a
- ret z
- dec a
- ld hl, wDummyGameCard1Location
- cp [hl]
- ret z
- ld e, a
- ld d, 0
- ld hl, wDummyGameCards
- add hl, de
- ld a, [hl]
- cp -1
- ret z
- ld [wDummyGameLastCardPicked], a
- ld [wDummyGameCard2], a
- ld a, e
- ld [wDummyGameCard2Location], a
- call DummyGame_Card2Coord
- call DummyGame_PlaceCard
- ld a, 64
- ld [wDummyGameCounter], a
- ld hl, wJumptableIndex
- inc [hl]
-.DelayPickAgain:
- ld hl, wDummyGameCounter
- ld a, [hl]
- and a
- jr z, .PickAgain
- dec [hl]
- ret
-
-.PickAgain:
- call DummyGame_CheckMatch
- ld a, $3
- ld [wJumptableIndex], a
- ret
-
-.RevealAll:
- ldh a, [hJoypadPressed]
- and A_BUTTON
- ret z
- xor a
- ld [wDummyGameCounter], a
-.RevelationLoop:
- ld hl, wDummyGameCounter
- ld a, [hl]
- cp 45
- jr nc, .finish_round
- inc [hl]
- push af
- call DummyGame_Card2Coord
- pop af
- push hl
- ld e, a
- ld d, $0
- ld hl, wDummyGameCards
- add hl, de
- ld a, [hl]
- pop hl
- cp -1
- jr z, .RevelationLoop
- ld [wDummyGameLastCardPicked], a
- call DummyGame_PlaceCard
- jr .RevelationLoop
-
-.finish_round
- call WaitPressAorB_BlinkCursor
- ld hl, wJumptableIndex
- inc [hl]
-.AskPlayAgain:
- call UnusedCursor_InterpretJoypad_AnimateCursor
- jr nc, .restart
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-
-.restart
- xor a
- ld [wJumptableIndex], a
- ret
-
-DummyGame_CheckMatch:
- ld hl, wDummyGameCard1
- ld a, [hli]
- cp [hl]
- jr nz, .no_match
-
- ld a, [wDummyGameCard1Location]
- call DummyGame_Card2Coord
- call DummyGame_DeleteCard
-
- ld a, [wDummyGameCard2Location]
- call DummyGame_Card2Coord
- call DummyGame_DeleteCard
-
- ld a, [wDummyGameCard1Location]
- ld e, a
- ld d, $0
- ld hl, wDummyGameCards
- add hl, de
- ld [hl], -1
-
- ld a, [wDummyGameCard2Location]
- ld e, a
- ld d, 0
- ld hl, wDummyGameCards
- add hl, de
- ld [hl], -1
-
- ld hl, wDummyGameLastMatches
-.find_empty_slot
- ld a, [hli]
- and a
- jr nz, .find_empty_slot
- dec hl
- ld a, [wDummyGameCard1]
- ld [hl], a
- ld [wDummyGameLastCardPicked], a
- ld hl, wDummyGameNumCardsMatched
- ld e, [hl]
- inc [hl]
- inc [hl]
- ld d, 0
- hlcoord 5, 0
- add hl, de
- call DummyGame_PlaceCard
- ld hl, .VictoryText
- call PrintText
- ret
-
-.no_match
- xor a
- ld [wDummyGameLastCardPicked], a
-
- ld a, [wDummyGameCard1Location]
- call DummyGame_Card2Coord
- call DummyGame_PlaceCard
-
- ld a, [wDummyGameCard2Location]
- call DummyGame_Card2Coord
- call DummyGame_PlaceCard
-
- ld hl, DummyGameDarnText
- call PrintText
- ret
-
-.VictoryText:
- text_asm
- push bc
- hlcoord 2, 13
- call DummyGame_PlaceCard
- ld hl, DummyGameYeahText
- pop bc
- inc bc
- inc bc
- inc bc
- ret
-
-DummyGameYeahText:
- text_far _DummyGameYeahText
- text_end
-
-DummyGameDarnText:
- text_far _DummyGameDarnText
- text_end
-
-DummyGame_InitBoard:
- ld hl, wDummyGameCards
- ld bc, wDummyGameCardsEnd - wDummyGameCards
- xor a
- call ByteFill
- call DummyGame_GetDistributionOfTiles
-
- ld c, 2
- ld b, [hl]
- call DummyGame_SampleTilePlacement
-
- ld c, 8
- ld b, [hl]
- call DummyGame_SampleTilePlacement
-
- ld c, 4
- ld b, [hl]
- call DummyGame_SampleTilePlacement
-
- ld c, 7
- ld b, [hl]
- call DummyGame_SampleTilePlacement
-
- ld c, 3
- ld b, [hl]
- call DummyGame_SampleTilePlacement
-
- ld c, 6
- ld b, [hl]
- call DummyGame_SampleTilePlacement
-
- ld c, 1
- ld b, [hl]
- call DummyGame_SampleTilePlacement
-
- ld c, 5
- ld hl, wDummyGameCards
- ld b, wDummyGameCardsEnd - wDummyGameCards
-.loop
- ld a, [hl]
- and a
- jr nz, .no_load
- ld [hl], c
-.no_load
- inc hl
- dec b
- jr nz, .loop
- ret
-
-DummyGame_SampleTilePlacement:
- push hl
- ld de, wDummyGameCards
-.loop
- call Random
- and %00111111
- cp 45
- jr nc, .loop
- ld l, a
- ld h, 0
- add hl, de
- ld a, [hl]
- and a
- jr nz, .loop
- ld [hl], c
- dec b
- jr nz, .loop
- pop hl
- inc hl
- ret
-
-DummyGame_GetDistributionOfTiles:
- ld a, [wMenuCursorY]
- dec a
- ld l, a
- ld h, 0
- add hl, hl
- add hl, hl
- add hl, hl
- ld de, .distributions
- add hl, de
- ret
-
-.distributions
- db $02, $03, $06, $06, $06, $08, $08, $06
- db $02, $02, $04, $06, $06, $08, $08, $09
- db $02, $02, $02, $04, $07, $08, $08, $0c
-
-DummyGame_PlaceCard:
- ld a, [wDummyGameLastCardPicked]
- sla a
- sla a
- add 4
- ld [hli], a
- inc a
- ld [hld], a
- inc a
- ld bc, SCREEN_WIDTH
- add hl, bc
- ld [hli], a
- inc a
- ld [hl], a
- ld c, 3
- call DelayFrames
- ret
-
-DummyGame_DeleteCard:
- ld a, $1
- ld [hli], a
- ld [hld], a
- ld bc, SCREEN_WIDTH
- add hl, bc
- ld [hli], a
- ld [hl], a
- ld c, 3
- call DelayFrames
- ret
-
-DummyGame_InitStrings:
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, $1
- call ByteFill
- hlcoord 0, 0
- ld de, .japstr1
- call PlaceString
- hlcoord 15, 0
- ld de, .japstr2
- call PlaceString
- ld hl, .dummy_text
- call PrintText
- ret
-
-.dummy_text
- db "@"
-.japstr1
- db "とったもの@"
-.japstr2
- db "あと かい@"
-
-DummyGame_Card2Coord:
- ld d, 0
-.find_row
- sub 9
- jr c, .found_row
- inc d
- jr .find_row
-
-.found_row
- add 9
- ld e, a
- hlcoord 1, 2
- ld bc, 2 * SCREEN_WIDTH
-.loop2
- ld a, d
- and a
- jr z, .done
- add hl, bc
- dec d
- jr .loop2
-
-.done
- sla e
- add hl, de
- ret
-
-DummyGame_InterpretJoypad_AnimateCursor:
- ld a, [wJumptableIndex]
- cp $7
- jr nc, .quit
- call JoyTextDelay
- ld hl, hJoypadPressed
- ld a, [hl]
- and A_BUTTON
- jr nz, .pressed_a
- ld a, [hl]
- and D_LEFT
- jr nz, .pressed_left
- ld a, [hl]
- and D_RIGHT
- jr nz, .pressed_right
- ld a, [hl]
- and D_UP
- jr nz, .pressed_up
- ld a, [hl]
- and D_DOWN
- jr nz, .pressed_down
- ret
-
-.quit
- ld hl, SPRITEANIMSTRUCT_INDEX
- add hl, bc
- ld [hl], $0
- ret
-
-.pressed_a
- ld hl, SPRITEANIMSTRUCT_VAR1
- add hl, bc
- ld a, [hl]
- inc a
- ld [wDummyGameCardChoice], a
- ret
-
-.pressed_left
- ld hl, SPRITEANIMSTRUCT_XOFFSET
- add hl, bc
- ld a, [hl]
- and a
- ret z
- sub 1 tiles
- ld [hl], a
- ld hl, SPRITEANIMSTRUCT_VAR1
- add hl, bc
- dec [hl]
- ret
-
-.pressed_right
- ld hl, SPRITEANIMSTRUCT_XOFFSET
- add hl, bc
- ld a, [hl]
- cp (9 - 1) tiles
- ret z
- add 1 tiles
- ld [hl], a
- ld hl, SPRITEANIMSTRUCT_VAR1
- add hl, bc
- inc [hl]
- ret
-
-.pressed_up
- ld hl, SPRITEANIMSTRUCT_YOFFSET
- add hl, bc
- ld a, [hl]
- and a
- ret z
- sub 1 tiles
- ld [hl], a
- ld hl, SPRITEANIMSTRUCT_VAR1
- add hl, bc
- ld a, [hl]
- sub 9
- ld [hl], a
- ret
-
-.pressed_down
- ld hl, SPRITEANIMSTRUCT_YOFFSET
- add hl, bc
- ld a, [hl]
- cp (5 - 1) tiles
- ret z
- add 1 tiles
- ld [hl], a
- ld hl, SPRITEANIMSTRUCT_VAR1
- add hl, bc
- ld a, [hl]
- add 9
- ld [hl], a
- ret
-
-DummyGameLZ:
-INCBIN "gfx/dummy_game/dummy_game.2bpp.lz"
--- /dev/null
+++ b/engine/games/memory_game.asm
@@ -1,0 +1,590 @@
+_MemoryGame:
+ call .LoadGFXAndPals
+ call DelayFrame
+.loop
+ call .JumptableLoop
+ jr nc, .loop
+ ret
+
+.LoadGFXAndPals:
+ call DisableLCD
+ ld b, SCGB_DIPLOMA
+ call GetSGBLayout
+ callfar ClearSpriteAnims
+ ld hl, MemoryGameLZ
+ ld de, vTiles2 tile $00
+ call Decompress
+ ld hl, MemoryGameGFX
+ ld de, vTiles0 tile $00
+ ld bc, 4 tiles
+ ld a, BANK(MemoryGameGFX)
+ call FarCopyBytes
+ ld a, SPRITE_ANIM_DICT_ARROW_CURSOR
+ ld hl, wSpriteAnimDict
+ ld [hli], a
+ ld [hl], $00
+ hlcoord 0, 0
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+ xor a
+ call ByteFill
+ xor a
+ ldh [hSCY], a
+ ldh [hSCX], a
+ ldh [rWY], a
+ ld [wJumptableIndex], a
+ ld a, $1
+ ldh [hBGMapMode], a
+ ld a, LCDC_DEFAULT
+ ldh [rLCDC], a
+ ld a, $e4
+ call DmgToCgbBGPals
+ ld a, $e0
+ call DmgToCgbObjPal0
+ ret
+
+.JumptableLoop:
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .quit
+ call .ExecuteJumptable
+ callfar PlaySpriteAnimations
+ call DelayFrame
+ and a
+ ret
+
+.quit
+ scf
+ ret
+
+.ExecuteJumptable:
+ jumptable .Jumptable, wJumptableIndex
+
+.Jumptable:
+ dw .RestartGame
+ dw .ResetBoard
+ dw .InitBoardTilemapAndCursorObject
+ dw .CheckTriesRemaining
+ dw .PickCard1
+ dw .PickCard2
+ dw .DelayPickAgain
+ dw .RevealAll
+ dw .AskPlayAgain
+
+.RestartGame:
+ call MemoryGame_InitStrings
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+.ResetBoard:
+ call UnusedCursor_InterpretJoypad_AnimateCursor
+ jr nc, .proceed
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+.proceed
+ call MemoryGame_InitBoard
+ ld hl, wJumptableIndex
+ inc [hl]
+ xor a
+ ld [wMemoryGameCounter], a
+ ld hl, wMemoryGameLastMatches
+rept 4
+ ld [hli], a
+endr
+ ld [hl], a
+ ld [wMemoryGameNumCardsMatched], a
+.InitBoardTilemapAndCursorObject:
+ ld hl, wMemoryGameCounter
+ ld a, [hl]
+ cp 45
+ jr nc, .spawn_object
+ inc [hl]
+ call MemoryGame_Card2Coord
+ xor a
+ ld [wMemoryGameLastCardPicked], a
+ call MemoryGame_PlaceCard
+ ret
+
+.spawn_object
+ depixel 6, 3, 4, 4
+ ld a, SPRITE_ANIM_INDEX_MEMORY_GAME_CURSOR
+ call InitSpriteAnimStruct
+ ld a, 5
+ ld [wMemoryGameNumberTriesRemaining], a
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+.CheckTriesRemaining:
+ ld a, [wMemoryGameNumberTriesRemaining]
+ hlcoord 17, 0
+ add "0"
+ ld [hl], a
+ ld hl, wMemoryGameNumberTriesRemaining
+ ld a, [hl]
+ and a
+ jr nz, .next_try
+ ld a, $7
+ ld [wJumptableIndex], a
+ ret
+
+.next_try
+ dec [hl]
+ xor a
+ ld [wMemoryGameCardChoice], a
+ ld hl, wJumptableIndex
+ inc [hl]
+.PickCard1:
+ ld a, [wMemoryGameCardChoice]
+ and a
+ ret z
+ dec a
+ ld e, a
+ ld d, 0
+ ld hl, wMemoryGameCards
+ add hl, de
+ ld a, [hl]
+ cp -1
+ ret z
+ ld [wMemoryGameLastCardPicked], a
+ ld [wMemoryGameCard1], a
+ ld a, e
+ ld [wMemoryGameCard1Location], a
+ call MemoryGame_Card2Coord
+ call MemoryGame_PlaceCard
+ xor a
+ ld [wMemoryGameCardChoice], a
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+.PickCard2:
+ ld a, [wMemoryGameCardChoice]
+ and a
+ ret z
+ dec a
+ ld hl, wMemoryGameCard1Location
+ cp [hl]
+ ret z
+ ld e, a
+ ld d, 0
+ ld hl, wMemoryGameCards
+ add hl, de
+ ld a, [hl]
+ cp -1
+ ret z
+ ld [wMemoryGameLastCardPicked], a
+ ld [wMemoryGameCard2], a
+ ld a, e
+ ld [wMemoryGameCard2Location], a
+ call MemoryGame_Card2Coord
+ call MemoryGame_PlaceCard
+ ld a, 64
+ ld [wMemoryGameCounter], a
+ ld hl, wJumptableIndex
+ inc [hl]
+.DelayPickAgain:
+ ld hl, wMemoryGameCounter
+ ld a, [hl]
+ and a
+ jr z, .PickAgain
+ dec [hl]
+ ret
+
+.PickAgain:
+ call MemoryGame_CheckMatch
+ ld a, $3
+ ld [wJumptableIndex], a
+ ret
+
+.RevealAll:
+ ldh a, [hJoypadPressed]
+ and A_BUTTON
+ ret z
+ xor a
+ ld [wMemoryGameCounter], a
+.RevelationLoop:
+ ld hl, wMemoryGameCounter
+ ld a, [hl]
+ cp 45
+ jr nc, .finish_round
+ inc [hl]
+ push af
+ call MemoryGame_Card2Coord
+ pop af
+ push hl
+ ld e, a
+ ld d, $0
+ ld hl, wMemoryGameCards
+ add hl, de
+ ld a, [hl]
+ pop hl
+ cp -1
+ jr z, .RevelationLoop
+ ld [wMemoryGameLastCardPicked], a
+ call MemoryGame_PlaceCard
+ jr .RevelationLoop
+
+.finish_round
+ call WaitPressAorB_BlinkCursor
+ ld hl, wJumptableIndex
+ inc [hl]
+.AskPlayAgain:
+ call UnusedCursor_InterpretJoypad_AnimateCursor
+ jr nc, .restart
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+.restart
+ xor a
+ ld [wJumptableIndex], a
+ ret
+
+MemoryGame_CheckMatch:
+ ld hl, wMemoryGameCard1
+ ld a, [hli]
+ cp [hl]
+ jr nz, .no_match
+
+ ld a, [wMemoryGameCard1Location]
+ call MemoryGame_Card2Coord
+ call MemoryGame_DeleteCard
+
+ ld a, [wMemoryGameCard2Location]
+ call MemoryGame_Card2Coord
+ call MemoryGame_DeleteCard
+
+ ld a, [wMemoryGameCard1Location]
+ ld e, a
+ ld d, $0
+ ld hl, wMemoryGameCards
+ add hl, de
+ ld [hl], -1
+
+ ld a, [wMemoryGameCard2Location]
+ ld e, a
+ ld d, 0
+ ld hl, wMemoryGameCards
+ add hl, de
+ ld [hl], -1
+
+ ld hl, wMemoryGameLastMatches
+.find_empty_slot
+ ld a, [hli]
+ and a
+ jr nz, .find_empty_slot
+ dec hl
+ ld a, [wMemoryGameCard1]
+ ld [hl], a
+ ld [wMemoryGameLastCardPicked], a
+ ld hl, wMemoryGameNumCardsMatched
+ ld e, [hl]
+ inc [hl]
+ inc [hl]
+ ld d, 0
+ hlcoord 5, 0
+ add hl, de
+ call MemoryGame_PlaceCard
+ ld hl, .VictoryText
+ call PrintText
+ ret
+
+.no_match
+ xor a
+ ld [wMemoryGameLastCardPicked], a
+
+ ld a, [wMemoryGameCard1Location]
+ call MemoryGame_Card2Coord
+ call MemoryGame_PlaceCard
+
+ ld a, [wMemoryGameCard2Location]
+ call MemoryGame_Card2Coord
+ call MemoryGame_PlaceCard
+
+ ld hl, MemoryGameDarnText
+ call PrintText
+ ret
+
+.VictoryText:
+ text_asm
+ push bc
+ hlcoord 2, 13
+ call MemoryGame_PlaceCard
+ ld hl, MemoryGameYeahText
+ pop bc
+ inc bc
+ inc bc
+ inc bc
+ ret
+
+MemoryGameYeahText:
+ text_far _MemoryGameYeahText
+ text_end
+
+MemoryGameDarnText:
+ text_far _MemoryGameDarnText
+ text_end
+
+MemoryGame_InitBoard:
+ ld hl, wMemoryGameCards
+ ld bc, wMemoryGameCardsEnd - wMemoryGameCards
+ xor a
+ call ByteFill
+ call MemoryGame_GetDistributionOfTiles
+
+ ld c, 2
+ ld b, [hl]
+ call MemoryGame_SampleTilePlacement
+
+ ld c, 8
+ ld b, [hl]
+ call MemoryGame_SampleTilePlacement
+
+ ld c, 4
+ ld b, [hl]
+ call MemoryGame_SampleTilePlacement
+
+ ld c, 7
+ ld b, [hl]
+ call MemoryGame_SampleTilePlacement
+
+ ld c, 3
+ ld b, [hl]
+ call MemoryGame_SampleTilePlacement
+
+ ld c, 6
+ ld b, [hl]
+ call MemoryGame_SampleTilePlacement
+
+ ld c, 1
+ ld b, [hl]
+ call MemoryGame_SampleTilePlacement
+
+ ld c, 5
+ ld hl, wMemoryGameCards
+ ld b, wMemoryGameCardsEnd - wMemoryGameCards
+.loop
+ ld a, [hl]
+ and a
+ jr nz, .no_load
+ ld [hl], c
+.no_load
+ inc hl
+ dec b
+ jr nz, .loop
+ ret
+
+MemoryGame_SampleTilePlacement:
+ push hl
+ ld de, wMemoryGameCards
+.loop
+ call Random
+ and %00111111
+ cp 45
+ jr nc, .loop
+ ld l, a
+ ld h, 0
+ add hl, de
+ ld a, [hl]
+ and a
+ jr nz, .loop
+ ld [hl], c
+ dec b
+ jr nz, .loop
+ pop hl
+ inc hl
+ ret
+
+MemoryGame_GetDistributionOfTiles:
+ ld a, [wMenuCursorY]
+ dec a
+ ld l, a
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ ld de, .distributions
+ add hl, de
+ ret
+
+.distributions
+ db $02, $03, $06, $06, $06, $08, $08, $06
+ db $02, $02, $04, $06, $06, $08, $08, $09
+ db $02, $02, $02, $04, $07, $08, $08, $0c
+
+MemoryGame_PlaceCard:
+ ld a, [wMemoryGameLastCardPicked]
+ sla a
+ sla a
+ add 4
+ ld [hli], a
+ inc a
+ ld [hld], a
+ inc a
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ ld [hli], a
+ inc a
+ ld [hl], a
+ ld c, 3
+ call DelayFrames
+ ret
+
+MemoryGame_DeleteCard:
+ ld a, $1
+ ld [hli], a
+ ld [hld], a
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ ld [hli], a
+ ld [hl], a
+ ld c, 3
+ call DelayFrames
+ ret
+
+MemoryGame_InitStrings:
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, $1
+ call ByteFill
+ hlcoord 0, 0
+ ld de, .japstr1
+ call PlaceString
+ hlcoord 15, 0
+ ld de, .japstr2
+ call PlaceString
+ ld hl, .dummy_text
+ call PrintText
+ ret
+
+.dummy_text
+ db "@"
+.japstr1
+ db "とったもの@"
+.japstr2
+ db "あと かい@"
+
+MemoryGame_Card2Coord:
+ ld d, 0
+.find_row
+ sub 9
+ jr c, .found_row
+ inc d
+ jr .find_row
+
+.found_row
+ add 9
+ ld e, a
+ hlcoord 1, 2
+ ld bc, 2 * SCREEN_WIDTH
+.loop2
+ ld a, d
+ and a
+ jr z, .done
+ add hl, bc
+ dec d
+ jr .loop2
+
+.done
+ sla e
+ add hl, de
+ ret
+
+MemoryGame_InterpretJoypad_AnimateCursor:
+ ld a, [wJumptableIndex]
+ cp $7
+ jr nc, .quit
+ call JoyTextDelay
+ ld hl, hJoypadPressed
+ ld a, [hl]
+ and A_BUTTON
+ jr nz, .pressed_a
+ ld a, [hl]
+ and D_LEFT
+ jr nz, .pressed_left
+ ld a, [hl]
+ and D_RIGHT
+ jr nz, .pressed_right
+ ld a, [hl]
+ and D_UP
+ jr nz, .pressed_up
+ ld a, [hl]
+ and D_DOWN
+ jr nz, .pressed_down
+ ret
+
+.quit
+ ld hl, SPRITEANIMSTRUCT_INDEX
+ add hl, bc
+ ld [hl], $0
+ ret
+
+.pressed_a
+ ld hl, SPRITEANIMSTRUCT_VAR1
+ add hl, bc
+ ld a, [hl]
+ inc a
+ ld [wMemoryGameCardChoice], a
+ ret
+
+.pressed_left
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
+ add hl, bc
+ ld a, [hl]
+ and a
+ ret z
+ sub 1 tiles
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_VAR1
+ add hl, bc
+ dec [hl]
+ ret
+
+.pressed_right
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
+ add hl, bc
+ ld a, [hl]
+ cp (9 - 1) tiles
+ ret z
+ add 1 tiles
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_VAR1
+ add hl, bc
+ inc [hl]
+ ret
+
+.pressed_up
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
+ add hl, bc
+ ld a, [hl]
+ and a
+ ret z
+ sub 1 tiles
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_VAR1
+ add hl, bc
+ ld a, [hl]
+ sub 9
+ ld [hl], a
+ ret
+
+.pressed_down
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
+ add hl, bc
+ ld a, [hl]
+ cp (5 - 1) tiles
+ ret z
+ add 1 tiles
+ ld [hl], a
+ ld hl, SPRITEANIMSTRUCT_VAR1
+ add hl, bc
+ ld a, [hl]
+ add 9
+ ld [hl], a
+ ret
+
+MemoryGameLZ:
+INCBIN "gfx/memory_game/memory_game.2bpp.lz"
--- a/engine/gfx/sprite_anims.asm
+++ b/engine/gfx/sprite_anims.asm
@@ -27,7 +27,7 @@
dw AnimSeq_SlotsChanseyEgg
dw AnimSeq_MailCursor
dw AnimSeq_UnusedCursor
- dw AnimSeq_DummyGameCursor
+ dw AnimSeq_MemoryGameCursor
dw AnimSeq_PokegearArrow
dw AnimSeq_TradePokeBall
dw AnimSeq_TradeTubeBulge
@@ -407,8 +407,8 @@
callfar AnimatePokegearModeIndicatorArrow
ret
-AnimSeq_DummyGameCursor:
- callfar DummyGame_InterpretJoypad_AnimateCursor
+AnimSeq_MemoryGameCursor:
+ callfar MemoryGame_InterpretJoypad_AnimateCursor
ret
AnimSeq_TradePokeBall:
binary files a/gfx/dummy_game/dummy_game.png /dev/null differ
--- a/gfx/lz.mk
+++ b/gfx/lz.mk
@@ -8,7 +8,7 @@
gfx/diploma/diploma.2bpp.lz: LZFLAGS += --method 8 --align 1
-gfx/dummy_game/dummy_game.2bpp.lz: LZFLAGS += --method 2 --align 4
+gfx/memory_game/memory_game.2bpp.lz: LZFLAGS += --method 2 --align 4
gfx/intro/%.lz: LZFLAGS += --align 4
gfx/intro/suicune_close.2bpp.lz: LZFLAGS += --method 2 --align 4
binary files /dev/null b/gfx/memory_game/memory_game.png differ
--- a/main.asm
+++ b/main.asm
@@ -479,7 +479,7 @@
INCLUDE "engine/events/print_unown_2.asm"
INCLUDE "engine/games/card_flip.asm"
INCLUDE "engine/games/unown_puzzle.asm"
-INCLUDE "engine/games/dummy_game.asm"
+INCLUDE "engine/games/memory_game.asm"
INCLUDE "engine/pokemon/bills_pc.asm"
--- a/wram.asm
+++ b/wram.asm
@@ -849,18 +849,18 @@
wDiscardPileEnd::
NEXTU
-; dummy game
-wDummyGameCards:: ds 9 * 5
-wDummyGameCardsEnd::
-wDummyGameLastCardPicked:: db
-wDummyGameCard1:: db
-wDummyGameCard2:: db
-wDummyGameCard1Location:: db
-wDummyGameCard2Location:: db
-wDummyGameNumberTriesRemaining:: db
-wDummyGameLastMatches:: ds 5
-wDummyGameCounter:: db
-wDummyGameNumCardsMatched:: db
+; unused memory game
+wMemoryGameCards:: ds 9 * 5
+wMemoryGameCardsEnd::
+wMemoryGameLastCardPicked:: db
+wMemoryGameCard1:: db
+wMemoryGameCard2:: db
+wMemoryGameCard1Location:: db
+wMemoryGameCard2Location:: db
+wMemoryGameNumberTriesRemaining:: db
+wMemoryGameLastMatches:: ds 5
+wMemoryGameCounter:: db
+wMemoryGameNumCardsMatched:: db
NEXTU
; mobile data
@@ -1412,8 +1412,8 @@
wCardFlipWhichCard:: db
NEXTU
-; dummy game
-wDummyGameCardChoice:: db
+; unused memory game
+wMemoryGameCardChoice:: db
NEXTU
; magnet train