pokecrystal-board/engine/dummy_game.asm

613 lines
8.7 KiB
NASM
Raw Normal View History

2015-11-11 20:38:57 -08:00
_DummyGame: ; e1e5b (38:5e5b)
2015-12-28 14:09:53 -08:00
call .LoadGFXAndPals
2015-11-11 20:38:57 -08:00
call DelayFrame
2015-12-28 14:09:53 -08:00
.loop
call .JumptableLoop
jr nc, .loop
2015-11-11 20:38:57 -08:00
ret
.LoadGFXAndPals:
2015-11-11 20:38:57 -08:00
call DisableLCD
2016-06-06 15:23:00 -07:00
ld b, SCGB_DIPLOMA
2015-11-11 20:38:57 -08:00
call GetSGBLayout
callab ClearSpriteAnims
2015-11-11 20:38:57 -08:00
ld hl, LZ_e2221
ld de, VTiles2 tile $00
call Decompress
ld hl, Unknown_e00ed
ld de, VTiles0 tile $00
2015-12-28 14:09:53 -08:00
ld bc, 4 tiles
2015-11-11 20:38:57 -08:00
ld a, BANK(Unknown_e00ed)
call FarCopyBytes
ld a, $8
ld hl, wc300
ld [hli], a
ld [hl], $0
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
xor a
call ByteFill
xor a
ld [hSCY], a
ld [hSCX], a
ld [rWY], a
ld [wJumptableIndex], a
ld a, $1
ld [hBGMapMode], a
ld a, $e3
ld [rLCDC], a
ld a, $e4
call DmgToCgbBGPals
ld a, $e0
2015-12-09 08:38:40 -08:00
call DmgToCgbObjPal0
2015-11-11 20:38:57 -08:00
ret
.JumptableLoop:
2015-11-11 20:38:57 -08:00
ld a, [wJumptableIndex]
bit 7, a
2015-12-28 14:09:53 -08:00
jr nz, .quit
call .ExecuteJumptable
callab PlaySpriteAnimations
2015-11-11 20:38:57 -08:00
call DelayFrame
and a
ret
2015-12-28 14:09:53 -08:00
.quit
2015-11-11 20:38:57 -08:00
scf
ret
.ExecuteJumptable:
2015-12-28 14:09:53 -08:00
jumptable .Jumptable, wJumptableIndex
.Jumptable:
2015-12-28 14:09:53 -08:00
dw .RestartGame
dw .ResetBoard
dw .InitBoardTilemapAndCursorObject
dw .CheckTriesRemaining
dw .PickCard1
dw .PickCard2
dw .DelayPickAgain
dw .RevealAll
dw .AskPlayAgain
.RestartGame:
2015-12-28 14:09:53 -08:00
call DummyGame_InitStrings
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
inc [hl]
ret
.ResetBoard:
call ret_e00ed
2015-12-28 14:09:53 -08:00
jr nc, .proceed
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
set 7, [hl]
ret
2015-12-28 14:09:53 -08:00
.proceed
call DummyGame_InitBoard
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
inc [hl]
xor a
2015-12-28 14:09:53 -08:00
ld [wDummyGameCounter], a
ld hl, wDummyGameLastMatches
2015-11-11 20:38:57 -08:00
rept 4
ld [hli], a
endr
ld [hl], a
2015-12-28 14:09:53 -08:00
ld [wDummyGameNumCardsMatched], a
.InitBoardTilemapAndCursorObject:
2015-12-28 14:09:53 -08:00
ld hl, wDummyGameCounter
2015-11-11 20:38:57 -08:00
ld a, [hl]
2015-12-28 14:09:53 -08:00
cp 45
jr nc, .spawn_object
2015-11-11 20:38:57 -08:00
inc [hl]
2015-12-28 14:09:53 -08:00
call DummyGame_Card2Coord
2015-11-11 20:38:57 -08:00
xor a
2015-12-28 14:09:53 -08:00
ld [wDummyGameLastCardPicked], a
call DummyGame_PlaceCard
2015-11-11 20:38:57 -08:00
ret
2015-12-28 14:09:53 -08:00
.spawn_object
depixel 6, 3, 4, 4
2016-01-10 14:44:09 -08:00
ld a, SPRITE_ANIM_INDEX_COMPOSE_MAIL_CURSOR
2015-11-13 07:48:49 -08:00
call _InitSpriteAnimStruct
2015-12-28 14:09:53 -08:00
ld a, 5
ld [wDummyGameNumberTriesRemaining], a
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
inc [hl]
ret
.CheckTriesRemaining:
2015-12-28 14:09:53 -08:00
ld a, [wDummyGameNumberTriesRemaining]
2015-11-11 20:38:57 -08:00
hlcoord 17, 0
2015-12-28 14:09:53 -08:00
add "0"
2015-11-11 20:38:57 -08:00
ld [hl], a
2015-12-28 14:09:53 -08:00
ld hl, wDummyGameNumberTriesRemaining
2015-11-11 20:38:57 -08:00
ld a, [hl]
and a
2015-12-28 14:09:53 -08:00
jr nz, .next_try
2015-11-11 20:38:57 -08:00
ld a, $7
ld [wJumptableIndex], a
ret
2015-12-28 14:09:53 -08:00
.next_try
2015-11-11 20:38:57 -08:00
dec [hl]
xor a
ld [wcf64], a
ld hl, wJumptableIndex
inc [hl]
.PickCard1:
2015-11-11 20:38:57 -08:00
ld a, [wcf64]
and a
ret z
dec a
ld e, a
2015-12-28 14:09:53 -08:00
ld d, 0
ld hl, wDummyGameCards
2015-11-11 20:38:57 -08:00
add hl, de
ld a, [hl]
2015-12-28 14:09:53 -08:00
cp -1
2015-11-11 20:38:57 -08:00
ret z
2015-12-28 14:09:53 -08:00
ld [wDummyGameLastCardPicked], a
ld [wDummyGameCard1], a
2015-11-11 20:38:57 -08:00
ld a, e
2015-12-28 14:09:53 -08:00
ld [wDummyGameCard1Location], a
call DummyGame_Card2Coord
call DummyGame_PlaceCard
2015-11-11 20:38:57 -08:00
xor a
ld [wcf64], a
ld hl, wJumptableIndex
inc [hl]
ret
.PickCard2:
2015-11-11 20:38:57 -08:00
ld a, [wcf64]
and a
ret z
dec a
2015-12-28 14:09:53 -08:00
ld hl, wDummyGameCard1Location
2015-11-11 20:38:57 -08:00
cp [hl]
ret z
ld e, a
2015-12-28 14:09:53 -08:00
ld d, 0
ld hl, wDummyGameCards
2015-11-11 20:38:57 -08:00
add hl, de
ld a, [hl]
2015-12-28 14:09:53 -08:00
cp -1
2015-11-11 20:38:57 -08:00
ret z
2015-12-28 14:09:53 -08:00
ld [wDummyGameLastCardPicked], a
ld [wDummyGameCard2], a
2015-11-11 20:38:57 -08:00
ld a, e
2015-12-28 14:09:53 -08:00
ld [wDummyGameCard2Location], a
call DummyGame_Card2Coord
call DummyGame_PlaceCard
ld a, 64
ld [wDummyGameCounter], a
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
inc [hl]
.DelayPickAgain:
2015-12-28 14:09:53 -08:00
ld hl, wDummyGameCounter
2015-11-11 20:38:57 -08:00
ld a, [hl]
and a
2015-12-28 14:09:53 -08:00
jr z, .PickAgain
2015-11-11 20:38:57 -08:00
dec [hl]
ret
.PickAgain:
2015-12-28 14:09:53 -08:00
call DummyGame_CheckMatch
2015-11-11 20:38:57 -08:00
ld a, $3
ld [wJumptableIndex], a
ret
.RevealAll:
2015-11-11 20:38:57 -08:00
ld a, [hJoypadPressed]
and A_BUTTON
ret z
xor a
2015-12-28 14:09:53 -08:00
ld [wDummyGameCounter], a
.RevelationLoop:
2015-12-28 14:09:53 -08:00
ld hl, wDummyGameCounter
2015-11-11 20:38:57 -08:00
ld a, [hl]
2015-12-28 14:09:53 -08:00
cp 45
jr nc, .finish_round
2015-11-11 20:38:57 -08:00
inc [hl]
push af
2015-12-28 14:09:53 -08:00
call DummyGame_Card2Coord
2015-11-11 20:38:57 -08:00
pop af
push hl
ld e, a
ld d, $0
2015-12-28 14:09:53 -08:00
ld hl, wDummyGameCards
2015-11-11 20:38:57 -08:00
add hl, de
ld a, [hl]
pop hl
2015-12-28 14:09:53 -08:00
cp -1
jr z, .RevelationLoop
ld [wDummyGameLastCardPicked], a
call DummyGame_PlaceCard
jr .RevelationLoop
2015-11-11 20:38:57 -08:00
2015-12-28 14:09:53 -08:00
.finish_round
2015-11-11 20:38:57 -08:00
call WaitPressAorB_BlinkCursor
ld hl, wJumptableIndex
inc [hl]
.AskPlayAgain:
call ret_e00ed
2015-12-28 14:09:53 -08:00
jr nc, .restart
2015-11-11 20:38:57 -08:00
ld hl, wJumptableIndex
set 7, [hl]
ret
2015-12-28 14:09:53 -08:00
.restart
2015-11-11 20:38:57 -08:00
xor a
ld [wJumptableIndex], a
ret
2015-12-28 14:09:53 -08:00
2015-11-11 20:38:57 -08:00
; e2010
2015-12-28 14:09:53 -08:00
DummyGame_CheckMatch: ; e2010
ld hl, wDummyGameCard1
2015-11-11 20:38:57 -08:00
ld a, [hli]
cp [hl]
2015-12-28 14:09:53 -08:00
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]
2015-11-11 20:38:57 -08:00
ld e, a
ld d, $0
2015-12-28 14:09:53 -08:00
ld hl, wDummyGameCards
2015-11-11 20:38:57 -08:00
add hl, de
2015-12-28 14:09:53 -08:00
ld [hl], -1
ld a, [wDummyGameCard2Location]
2015-11-11 20:38:57 -08:00
ld e, a
2015-12-28 14:09:53 -08:00
ld d, 0
ld hl, wDummyGameCards
2015-11-11 20:38:57 -08:00
add hl, de
2015-12-28 14:09:53 -08:00
ld [hl], -1
ld hl, wDummyGameLastMatches
.find_empty_slot
2015-11-11 20:38:57 -08:00
ld a, [hli]
and a
2015-12-28 14:09:53 -08:00
jr nz, .find_empty_slot
2015-11-11 20:38:57 -08:00
dec hl
2015-12-28 14:09:53 -08:00
ld a, [wDummyGameCard1]
2015-11-11 20:38:57 -08:00
ld [hl], a
2015-12-28 14:09:53 -08:00
ld [wDummyGameLastCardPicked], a
ld hl, wDummyGameNumCardsMatched
2015-11-11 20:38:57 -08:00
ld e, [hl]
inc [hl]
2015-12-28 14:09:53 -08:00
inc [hl]
ld d, 0
2015-11-11 20:38:57 -08:00
hlcoord 5, 0
add hl, de
2015-12-28 14:09:53 -08:00
call DummyGame_PlaceCard
ld hl, .VictoryText
2015-11-11 20:38:57 -08:00
call PrintText
ret
2015-12-28 14:09:53 -08:00
.no_match
2015-11-11 20:38:57 -08:00
xor a
2015-12-28 14:09:53 -08:00
ld [wDummyGameLastCardPicked], a
ld a, [wDummyGameCard1Location]
call DummyGame_Card2Coord
call DummyGame_PlaceCard
ld a, [wDummyGameCard2Location]
call DummyGame_Card2Coord
call DummyGame_PlaceCard
ld hl, DummyGameText_Darn
2015-11-11 20:38:57 -08:00
call PrintText
ret
.VictoryText:
2015-11-11 20:38:57 -08:00
start_asm
push bc
hlcoord 2, 13
2015-12-28 14:09:53 -08:00
call DummyGame_PlaceCard
ld hl, DummyGameText_Yeah
2015-11-11 20:38:57 -08:00
pop bc
inc bc
2015-12-28 14:09:53 -08:00
inc bc
inc bc
2015-11-11 20:38:57 -08:00
ret
2015-12-28 14:09:53 -08:00
2015-11-11 20:38:57 -08:00
; e2093
2015-12-28 14:09:53 -08:00
DummyGameText_Yeah: ; 0xe2093
2015-11-11 20:38:57 -08:00
; , yeah!
text_jump UnknownText_0x1c1a5b
db "@"
; 0xe2098
2015-12-28 14:09:53 -08:00
DummyGameText_Darn: ; 0xe2098
2015-11-11 20:38:57 -08:00
; Darn…
text_jump UnknownText_0x1c1a65
db "@"
; 0xe209d
2015-12-28 14:09:53 -08:00
DummyGame_InitBoard: ; e209d
ld hl, wDummyGameCards
ld bc, wDummyGameCardsEnd - wDummyGameCards
2015-11-11 20:38:57 -08:00
xor a
call ByteFill
2015-12-28 14:09:53 -08:00
call DummyGame_GetDistributionOfTiles
ld c, 2
2015-11-11 20:38:57 -08:00
ld b, [hl]
2015-12-28 14:09:53 -08:00
call DummyGame_SampleTilePlacement
ld c, 8
2015-11-11 20:38:57 -08:00
ld b, [hl]
2015-12-28 14:09:53 -08:00
call DummyGame_SampleTilePlacement
ld c, 4
2015-11-11 20:38:57 -08:00
ld b, [hl]
2015-12-28 14:09:53 -08:00
call DummyGame_SampleTilePlacement
ld c, 7
2015-11-11 20:38:57 -08:00
ld b, [hl]
2015-12-28 14:09:53 -08:00
call DummyGame_SampleTilePlacement
ld c, 3
2015-11-11 20:38:57 -08:00
ld b, [hl]
2015-12-28 14:09:53 -08:00
call DummyGame_SampleTilePlacement
ld c, 6
2015-11-11 20:38:57 -08:00
ld b, [hl]
2015-12-28 14:09:53 -08:00
call DummyGame_SampleTilePlacement
ld c, 1
2015-11-11 20:38:57 -08:00
ld b, [hl]
2015-12-28 14:09:53 -08:00
call DummyGame_SampleTilePlacement
ld c, 5
ld hl, wDummyGameCards
ld b, wDummyGameCardsEnd - wDummyGameCards
.loop
2015-11-11 20:38:57 -08:00
ld a, [hl]
and a
2015-12-28 14:09:53 -08:00
jr nz, .no_load
2015-11-11 20:38:57 -08:00
ld [hl], c
2015-12-28 14:09:53 -08:00
.no_load
2015-11-11 20:38:57 -08:00
inc hl
dec b
2015-12-28 14:09:53 -08:00
jr nz, .loop
2015-11-11 20:38:57 -08:00
ret
2015-12-28 14:09:53 -08:00
2015-11-11 20:38:57 -08:00
; e20e5
2015-12-28 14:09:53 -08:00
DummyGame_SampleTilePlacement: ; e20e5
2015-11-11 20:38:57 -08:00
push hl
2015-12-28 14:09:53 -08:00
ld de, wDummyGameCards
.loop
2015-11-11 20:38:57 -08:00
call Random
2015-12-28 14:09:53 -08:00
and %00111111
cp 45
jr nc, .loop
2015-11-11 20:38:57 -08:00
ld l, a
2015-12-28 14:09:53 -08:00
ld h, 0
2015-11-11 20:38:57 -08:00
add hl, de
ld a, [hl]
and a
2015-12-28 14:09:53 -08:00
jr nz, .loop
2015-11-11 20:38:57 -08:00
ld [hl], c
dec b
2015-12-28 14:09:53 -08:00
jr nz, .loop
2015-11-11 20:38:57 -08:00
pop hl
inc hl
ret
2015-12-28 14:09:53 -08:00
2015-11-11 20:38:57 -08:00
; e2101
2015-12-28 14:09:53 -08:00
DummyGame_GetDistributionOfTiles: ; e2101
2015-12-15 15:59:49 -08:00
ld a, [wMenuCursorY]
2015-11-11 20:38:57 -08:00
dec a
ld l, a
ld h, 0
add hl, hl
2015-12-28 14:09:53 -08:00
add hl, hl
add hl, hl
ld de, .distributions
2015-11-11 20:38:57 -08:00
add hl, de
ret
2015-12-28 14:09:53 -08:00
.distributions
2015-11-11 20:38:57 -08:00
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
; e2128
2015-12-28 14:09:53 -08:00
DummyGame_PlaceCard: ; e2128
ld a, [wDummyGameLastCardPicked]
2015-11-11 20:38:57 -08:00
sla a
sla a
2015-12-28 14:09:53 -08:00
add 4
2015-11-11 20:38:57 -08:00
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
2015-12-28 14:09:53 -08:00
2015-11-11 20:38:57 -08:00
; e2142
2015-12-28 14:09:53 -08:00
DummyGame_DeleteCard: ; e2142
2015-11-11 20:38:57 -08:00
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
2015-12-28 14:09:53 -08:00
2015-11-11 20:38:57 -08:00
; e2152
2015-12-28 14:09:53 -08:00
DummyGame_InitStrings: ; e2152
2015-11-11 20:38:57 -08:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, $1
call ByteFill
hlcoord 0, 0
2015-12-28 14:09:53 -08:00
ld de, .japstr1
2015-11-11 20:38:57 -08:00
call PlaceString
hlcoord 15, 0
2015-12-28 14:09:53 -08:00
ld de, .japstr2
2015-11-11 20:38:57 -08:00
call PlaceString
2015-12-28 14:09:53 -08:00
ld hl, .dummy_text
2015-11-11 20:38:57 -08:00
call PrintText
ret
2015-12-28 14:09:53 -08:00
.dummy_text
2015-11-11 20:38:57 -08:00
db "@"
2015-12-28 14:09:53 -08:00
.japstr1
db "とったもの@"
.japstr2
db "あと かい@"
2015-11-11 20:38:57 -08:00
; e2183
2015-12-28 14:09:53 -08:00
DummyGame_Card2Coord: ; e2183
ld d, 0
.find_row
sub 9
jr c, .found_row
2015-11-11 20:38:57 -08:00
inc d
2015-12-28 14:09:53 -08:00
jr .find_row
2015-11-11 20:38:57 -08:00
2015-12-28 14:09:53 -08:00
.found_row
add 9
2015-11-11 20:38:57 -08:00
ld e, a
hlcoord 1, 2
2015-12-28 14:09:53 -08:00
ld bc, 2 * SCREEN_WIDTH
.loop2
2015-11-11 20:38:57 -08:00
ld a, d
and a
2015-12-28 14:09:53 -08:00
jr z, .done
2015-11-11 20:38:57 -08:00
add hl, bc
dec d
2015-12-28 14:09:53 -08:00
jr .loop2
2015-11-11 20:38:57 -08:00
2015-12-28 14:09:53 -08:00
.done
2015-11-11 20:38:57 -08:00
sla e
add hl, de
ret
2015-12-28 14:09:53 -08:00
2015-11-11 20:38:57 -08:00
; e21a1
2015-12-28 14:09:53 -08:00
DummyGame_InterpretJoypad_AnimateCursor: ; e21a1 (38:61a1)
2015-11-11 20:38:57 -08:00
ld a, [wJumptableIndex]
cp $7
jr nc, .quit
call JoyTextDelay
ld hl, hJoypadPressed ; $ffa3
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
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_INDEX
2015-11-11 20:38:57 -08:00
add hl, bc
ld [hl], $0
ret
.pressed_a
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
inc a
ld [wcf64], a
ret
.pressed_left
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_XOFFSET
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
ret z
2015-12-28 14:09:53 -08:00
sub 1 tiles
2015-11-11 20:38:57 -08:00
ld [hl], a
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
dec [hl]
ret
.pressed_right
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_XOFFSET
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
2015-12-28 14:09:53 -08:00
cp (9 - 1) tiles
2015-11-11 20:38:57 -08:00
ret z
2015-12-28 14:09:53 -08:00
add 1 tiles
2015-11-11 20:38:57 -08:00
ld [hl], a
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
inc [hl]
ret
.pressed_up
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_YOFFSET
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
and a
ret z
2015-12-28 14:09:53 -08:00
sub 1 tiles
2015-11-11 20:38:57 -08:00
ld [hl], a
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
2015-12-28 14:09:53 -08:00
sub 9
2015-11-11 20:38:57 -08:00
ld [hl], a
ret
.pressed_down
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_YOFFSET
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
2015-12-28 14:09:53 -08:00
cp (5 - 1) tiles
2015-11-11 20:38:57 -08:00
ret z
2015-12-28 14:09:53 -08:00
add 1 tiles
2015-11-11 20:38:57 -08:00
ld [hl], a
2015-12-28 14:09:53 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 20:38:57 -08:00
add hl, bc
ld a, [hl]
2015-12-28 14:09:53 -08:00
add 9
2015-11-11 20:38:57 -08:00
ld [hl], a
ret
2015-12-28 14:09:53 -08:00
2015-11-11 20:38:57 -08:00
; e2221 (38:6221)
LZ_e2221: ; e2221
INCBIN "gfx/unknown/0e2221.2bpp.lz"