SpurgeGameCorner_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 0

SpurgeGameCornerSlotMachine:
	farjump OwsauriSlots

SpurgeGameCornerMemory::
	opentext
	checkcoins 25
	sif =, 2
		jumptext .need_25_coins_text
	refreshscreen 0
	special Special_MemoryGame
	iffalse .end
	writetext .you_won_text
	waitbutton

.itemloop
	callasm .process_item
	sif false, then
.end
		closetext
		end
	sendif
	verbosegiveitem ITEM_FROM_MEM, 1
	waitbutton
	jump .itemloop

.process_item
	xor a
	ld d, a
	ld [hScriptVar], a
	ld hl, wMemoryGameLastMatches
	ld a, [hl]
	and a
	ret z
	dec a
	ld hl, .items
	ld e, a
	add hl, de
	ld a, [hl]
	ld [hScriptVar], a

	ld hl, wMemoryGameLastMatches + 1
	ld de, wMemoryGameLastMatches
	ld bc, 4
	rst CopyBytes
	xor a
	ld [wMemoryGameLastMatches + 4], a
	ret

.items
	db ANTIDOTE
	db RARE_CANDY
	db POKE_DOLL
	db REPEL
	db POTION
	db POKE_BALL
	db GREAT_BALL
	db NUGGET

.need_25_coins_text
	db TX_COMPRESSED, $72, $85, $a8, $43, $3c, $c7, $34, $5b, $8c, $84, $64
	db $43, $d6, $18, $23, $ba, $0a, $5a, $46, $8f
	db $53, $40

.you_won_text
	db TX_COMPRESSED, $6d, $09, $39, $5e, $db, $5d, $db, $18, $48, $8e

	db $2f, $39, $42, $d4, $4e, $83, $1c, $a8, $24
	db $e3, $4d

SpurgeGameCornerCardFlip::
	refreshscreen 0
	special Special_CardFlip
	closetext
	end

SpurgeGameCornerPoker:
	farjump GameCornerPoker

SpurgeGameCornerBlackjack:
	farjump GameCornerBlackjack

SpurgeGameCornerExchangeCounterOpening:
	faceplayer
	opentext
	farwritetext OwsauriGameCorner_Text_ExchangeGameCoins
	waitbutton
	checkitem COIN_CASE
	sif true
		end
	jumptext .no_coin_case_text

.no_coin_case_text
	db TX_COMPRESSED, $76, $9a, $58, $e5, $0b, $53, $21, $25, $32, $27, $41
	db $8d, $ed, $8d, $a1, $19, $23, $6e, $a0
	db $fd, $4d

SpurgeGameCornerMonExchange:
	scall SpurgeGameCornerExchangeCounterOpening
	sif false
		end
	farwritetext OwsauriGameCornerMonExchange_Text_WhichMon
	special Special_DisplayCoinCaseBalance
	menuanonjumptable .menu
	dw SpurgeGameCorner_SaveYourCoinsComeAgain
	dw .kangaskhan
	dw .eevee
	dw .porygon

.menu
	db $40 ; flags
	db 03, 00 ; start coords
	db 11, 19 ; end coords
	dw .options
	db 1 ; default option

.options
	db $80
	db 3
	db "Kangaskhan   1000@"
	db "Eevee        3000@"
	db "Porygon      5000@"

.get_mon
	pushvar
	writebyte 0
	copyvartobyte wScriptTemp + 1
	popvar
	sif =, 2
		jumptext SpurgeGameCorner_Text_NeedMoreCoins
	checkcode VAR_PARTYCOUNT
	sif >, 5
		jumptext SpurgeGameCorner_Text_NoRoomForMon
	copybytetovar wScriptTemp
	pokenamemem 0, 0
	writetext .is_that_right_text
	yesorno
	closetext
	sif false
		jump SpurgeGameCorner_SaveYourCoinsComeAgain
	waitsfx
	playsound SFX_TRANSACTION
	farwritetext OwsauriGameCorner_Text_HereYouGo
	waitbutton
	copybytetovar wScriptTemp
	special Special_GameCornerPrizeMonCheckDex
	givepoke 0, 20, NO_ITEM, 0
	closetext
	writebyte 1
	copyvartobyte wScriptTemp + 1
	end

.is_that_right_text
	db TX_COMPRESSED, $07, $23
	db $ef, $0d, $12, $d3, $b7, $16, $3e, $53, $74
	db $b4, $d0

.kangaskhan
	writebyte KANGASKHAN
	copyvartobyte wScriptTemp
	checkcoins 1000
	scall .get_mon
	copybytetovar wScriptTemp + 1
	sif true
		takecoins 1000
	end

.eevee
	writebyte EEVEE
	copyvartobyte wScriptTemp
	checkcoins 3000
	scall .get_mon
	copybytetovar wScriptTemp + 1
	sif true
		takecoins 3000
	end

.porygon
	writebyte PORYGON
	copyvartobyte wScriptTemp
	checkcoins 5000
	scall .get_mon
	copybytetovar wScriptTemp + 1
	sif true
		takecoins 5000
	end

SpurgeGameCornerTMExchange:
	scall SpurgeGameCornerExchangeCounterOpening
	sif false
		end
	farwritetext OwsauriGameCornerTMExchange_Text_WhichTM
	special Special_DisplayCoinCaseBalance
	menuanonjumptable .menu
	dw SpurgeGameCorner_SaveYourCoinsComeAgain
	dw .tm33
	dw .tm41
	dw .tm48

.menu
	db $40 ; flags
	db 03, 05 ; start coords
	db 11, 19 ; end coords
	dw .options
	db 1 ; default option

.options
	db $80
	db 3
	db "TM33    3000@"
	db "TM41    3000@"
	db "TM48    3000@"

.tm33
	writebyte 33
	jump .do_exchange

.tm41
	writebyte 41
	jump .do_exchange

.tm48
	writebyte 48
.do_exchange
	farjump OwsauriGameCorner_TMExchange_DoExchange

SpurgeGameCornerCoinCaseSeller:
	faceplayer
	checkevent EVENT_GET_COIN_CASE
	sif true
		jumptext .after_sale_text
	opentext
	special PlaceMoneyTopRight
	writetext .will_sell_text
	yesorno
	sif false
		jumptext .declined_text
	checkmoney 0, 1000
	sif =, 2
		jumptext .not_enough_money_text
	takemoney 0, 1000
	special PlaceMoneyTopRight
	setevent EVENT_GET_COIN_CASE
	opentext
	writetext .accepted_text
	verbosegiveitem COIN_CASE, 1
	closetext
	end

.after_sale_text
	db TX_COMPRESSED, $6d, $08, $c9, $1b, $75, $07

	db $4a, $01, $ba, $76, $e3, $68, $46, $48, $db, $a8, $3a
	db $5a, $68

.will_sell_text
	db TX_COMPRESSED, $e1, $42, $2e, $9e

	db $00, $0e, $9c, $3d, $88, $3e, $f6, $02, $0b
	db $4f, $6c, $6d, $08, $c9, $1b, $75, $07

	db $e0, $0e, $a5, $38, $d2, $2e, $10, $cf
	db $2f, $09, $ad, $70, $5a, $16, $05, $81, $62, $0c, $91, $67, $6d, $2c, $9e

	db $01, $c0, $7b, $da
	db $5a, $68

.declined_text
	db TX_COMPRESSED, $29, $26, $49, $c8, $66, $d5, $a0
	db $bd, $4d

.accepted_text
	db TX_COMPRESSED, $75, $2d, $21, $6b, $94, $dc, $40
	db $7d, $4f, $10

.not_enough_money_text
	db TX_COMPRESSED, $a7

	db $80, $06, $39, $dc, $7c, $e2, $91, $03, $54, $a9, $26
	db $47, $81, $05, $a9, $ac, $db, $5b, $de, $82, $89, $d0, $63
	db $54, $f8, $48, $60
	db $bd, $4d

SpurgeGameCornerNPC1:
	db TX_COMPRESSED, $73, $69, $fd, $3b, $02, $49, $69, $39, $80, $d6, $8b
	db $7a, $d6, $0b

	db $88, $06, $10, $63, $e7
	db $c6, $9a

SpurgeGameCornerNPC2:
	db TX_COMPRESSED, $29, $23, $44, $58, $6a, $83, $44, $de
	db $f5, $e6, $75, $79, $8f, $9b, $e1, $58, $2e

	db $20, $05, $76, $d9, $4c, $ba, $83, $19, $d5, $e5
	db $0f, $69, $33, $2a, $19, $26, $c1, $0b, $18, $9b, $3f

	db $00, $72, $85, $a8, $9d, $06, $39, $80, $c1
	db $8d, $e6, $53, $a4, $64, $d1, $2c, $31, $fd, $b6
	db $52, $00, $46, $8d, $68, $fc, $a9, $23, $65, $31, $f3, $d2
	db $21, $e0, $41, $6a, $33, $a4, $95, $0c, $91, $a1, $12
	db $c2, $03, $01, $83, $1c, $10, $b1, $89, $b3, $44, $3d, $65
	db $2f, $58, $df, $38, $23, $ba, $08, $64, $e7

	db $88, $01, $23, $8c, $ea, $cf, $06, $bb
	db $f7, $ad, $21, $6b, $94, $97, $c1, $dc, $64, $28, $b4
	db $2a, $73, $45, $b8, $c8, $46, $44, $4b, $0c, $11, $dd, $05, $4f
	db $05, $34

SpurgeGameCornerNPC3:
	db TX_COMPRESSED, $29, $26, $83, $9a, $b3, $96, $93
	db $79, $1d, $0d, $c7, $f5, $94, $8c, $86, $8f

	db $00, $75, $10, $d2, $ce, $24, $22, $0e, $02, $0b
	db $4f, $29, $10, $35, $44, $86, $a9, $69, $34
	db $1a, $aa, $82, $b5, $28, $ac, $14, $20, $6a, $a7
	db $82, $9a

SpurgeGameCornerNPC4:
	db TX_COMPRESSED, $29, $23, $44, $58, $6a, $83, $44, $b4
	db $9b, $cc, $f7, $50, $81, $b3, $19, $d5, $e6, $73, $af, $9f
	db $a9, $a0

SpurgeGameCornerNPC5:
	db TX_COMPRESSED, $12, $ee, $b2, $a5, $4e, $6b, $2a, $5c

	db $40, $30, $8e, $e6, $a2, $33, $d0, $a0, $e5
	db $85, $e7, $34, $5a, $9a, $88, $08, $2d, $46, $74, $9e

	db $00, $eb, $08, $08, $2d, $4e, $43, $02, $0c, $6b
	db $fb, $c0, $82, $d4, $e8, $50, $7c
	db $69, $a0

SpurgeGameCornerNPC6:
	db TX_COMPRESSED, $07, $03, $c9, $86, $70, $85, $48, $d7

	db $c4, $01, $46, $48, $c8, $46, $44, $41, $06, $b9, $6b, $05
	db $c6, $9a

SpurgeGameCornerNPC7:
	db TX_COMPRESSED, $6e, $90, $53, $56, $64, $a6, $4b, $49, $a0
	db $de, $c9, $b4, $c9, $a2, $54, $3e, $e6
	db $96, $9a

SpurgeGameCornerNPC8:
	db TX_COMPRESSED, $75, $12, $7a, $bc, $c0, $41, $6a, $33, $a4
	db $7a, $a1, $92, $39, $35, $67, $1b, $74, $99, $19
	db $a1, $55, $43, $b4, $cb, $48, $d1

	db $e0, $02, $4d, $5f, $e0, $70, $8c, $85, $a5, $a0, $ff, $1d
	db $3c, $9d, $06, $38, $af, $73, $3a, $d3, $2a, $54, $f0
	db $53, $40

SpurgeGameCornerNPC9:
	db TX_COMPRESSED, $75, $84, $75, $14, $8c, $c4, $41, $1d, $d0, $43, $27
	db $2f, $5a, $4d, $07, $11, $d0, $dc, $e7, $5f, $34

	db $7c, $00, $ef, $14, $e4, $24, $26, $cb, $d5, $23, $8f
	db $9b, $d8, $05, $66, $0c, $6b, $96, $19, $50, $c9
	db $34, $01, $42, $a2, $c8, $59, $7e, $3a, $64, $e7, $0b, $44, $65, $3f
	db $7b, $00, $ae, $3e, $0a, $28, $20, $56, $d1, $2f
	db $d4, $d0

SpurgeGameCornerNPC10:
	db TX_COMPRESSED, $75, $15, $9d, $c1, $68, $58, $16, $3f, $13, $b9
	db $9a, $f7, $21, $0e, $62, $74, $99, $fc, $c8, $5a, $57, $d3
	db $ca, $ac, $86, $a2, $7e, $5a, $4c, $93, $a1, $45

	db $f8, $03, $b4, $ca, $8f, $bd, $fc, $b5, $82
	db $7b, $79, $d1, $92, $9e
	db $0a, $68

SpurgeGameCorner_SaveYourCoinsComeAgain:
	jumptext .text

.text
	db TX_COMPRESSED, $76, $26, $3d, $38, $7a, $7a, $83, $88, $d0, $63
	db $78, $10, $5a, $5c, $64, $23, $22, $26, $93
	db $2a, $99, $0b, $e7, $37, $9d, $19, $38
	db $d3, $40

SpurgeGameCorner_Text_NeedMoreCoins:
	db TX_COMPRESSED, $50, $15, $ac, $17, $18, $e5, $0b, $50, $86, $79
	db $79, $f0, $ac, $e3, $21, $19, $11
	db $ea, $68

SpurgeGameCorner_Text_NoRoomForMon:
	db TX_COMPRESSED, $50, $15, $ac, $17, $a3, $94, $2d, $46, $74, $94
	db $c7, $99, $d5, $ac, $14, $d2, $02, $8f, $85, $67
	db $ea, $68

SpurgeGameCorner_MapEventHeader:: db 0, 0

.Warps: db 2
	warp_def 13, 14, 3, SPURGE_CITY
	warp_def 13, 15, 3, SPURGE_CITY

.CoordEvents: db 0

.BGEvents: db 36
	signpost 4, 6, SIGNPOST_READ, SpurgeGameCornerSlotMachine
	signpost 5, 6, SIGNPOST_READ, SpurgeGameCornerSlotMachine
	signpost 2, 6, SIGNPOST_READ, SpurgeGameCornerSlotMachine
	signpost 3, 6, SIGNPOST_READ, SpurgeGameCornerSlotMachine
	signpost 4, 7, SIGNPOST_READ, SpurgeGameCornerSlotMachine
	signpost 5, 7, SIGNPOST_READ, SpurgeGameCornerSlotMachine
	signpost 2, 7, SIGNPOST_READ, SpurgeGameCornerSlotMachine
	signpost 3, 7, SIGNPOST_READ, SpurgeGameCornerSlotMachine
	signpost 2, 14, SIGNPOST_READ, SpurgeGameCornerMemory
	signpost 3, 14, SIGNPOST_READ, SpurgeGameCornerMemory
	signpost 4, 14, SIGNPOST_READ, SpurgeGameCornerMemory
	signpost 5, 14, SIGNPOST_READ, SpurgeGameCornerMemory
	signpost 2, 15, SIGNPOST_READ, SpurgeGameCornerMemory
	signpost 3, 15, SIGNPOST_READ, SpurgeGameCornerMemory
	signpost 4, 15, SIGNPOST_READ, SpurgeGameCornerMemory
	signpost 5, 15, SIGNPOST_READ, SpurgeGameCornerMemory
	signpost 5, 22, SIGNPOST_READ, SpurgeGameCornerCardFlip
	signpost 4, 22, SIGNPOST_READ, SpurgeGameCornerCardFlip
	signpost 2, 22, SIGNPOST_READ, SpurgeGameCornerCardFlip
	signpost 3, 22, SIGNPOST_READ, SpurgeGameCornerCardFlip
	signpost 5, 23, SIGNPOST_READ, SpurgeGameCornerCardFlip
	signpost 4, 23, SIGNPOST_READ, SpurgeGameCornerCardFlip
	signpost 2, 23, SIGNPOST_READ, SpurgeGameCornerCardFlip
	signpost 3, 23, SIGNPOST_READ, SpurgeGameCornerCardFlip
	signpost 6, 1, SIGNPOST_READ, SpurgeGameCornerPoker
	signpost 7, 1, SIGNPOST_READ, SpurgeGameCornerPoker
	signpost 8, 1, SIGNPOST_READ, SpurgeGameCornerPoker
	signpost 9, 1, SIGNPOST_READ, SpurgeGameCornerPoker
	signpost 10, 1, SIGNPOST_READ, SpurgeGameCornerPoker
	signpost 11, 1, SIGNPOST_READ, SpurgeGameCornerPoker
	signpost 6, 28, SIGNPOST_READ, SpurgeGameCornerBlackjack
	signpost 7, 28, SIGNPOST_READ, SpurgeGameCornerBlackjack
	signpost 8, 28, SIGNPOST_READ, SpurgeGameCornerBlackjack
	signpost 9, 28, SIGNPOST_READ, SpurgeGameCornerBlackjack
	signpost 10, 28, SIGNPOST_READ, SpurgeGameCornerBlackjack
	signpost 11, 28, SIGNPOST_READ, SpurgeGameCornerBlackjack

.ObjectEvents: db 14
	person_event SPRITE_CLERK, 2, 1, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_JUMPSTD, 0, gamecornercoinvendor, -1
	person_event SPRITE_RECEPTIONIST, 2, 27, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, SpurgeGameCornerMonExchange, -1
	person_event SPRITE_RECEPTIONIST, 2, 29, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, SpurgeGameCornerTMExchange, -1
	person_event SPRITE_PHARMACIST, 10, 19, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_OW_PLAYER, PERSONTYPE_SCRIPT, 0, SpurgeGameCornerCoinCaseSeller, -1
	person_event SPRITE_FISHING_GURU, 5, 21, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_OW_BROWN, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC1, -1
	person_event SPRITE_RECEPTIONIST, 1, 13, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_GREEN, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC2, -1
	person_event SPRITE_RECEPTIONIST, 1, 5, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_BLUE, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC3, -1
	person_event SPRITE_RECEPTIONIST, 1, 21, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_BROWN, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC4, -1
	person_event SPRITE_RECEPTIONIST, 5, 27, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_YELLOW, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC5, -1
	person_event SPRITE_RECEPTIONIST, 5, 2, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC6, -1
	person_event SPRITE_FISHER, 8, 2, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC7, -1
	person_event SPRITE_POKEFAN_M, 4, 16, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC8, -1
	person_event SPRITE_POKEFAN_F, 4, 5, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC9, -1
	person_event SPRITE_COOLTRAINER_M, 11, 27, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_TEXTFP, 0, SpurgeGameCornerNPC10, -1

