
		onbankgroup

;************************************************************************
;*									*
;*	僞僀僩儖    丗	僛儖僟偺揱愢 俢倃				*
;*	僼傽僀儖柤  丗	ZCA.S						*
;*	張棟撪梕    丗	僇儊儔壆 張棟					*
;*	嶌惉擔晅    丗  侾俋俋俉乛侽俋乛侾俋				*
;*									*
;************************************************************************
;
;==============	僶儞僋侽 ================================================
BANK0		GROUP	0
;-------------<	ZMA >----------------------------------------------------
		EXTERN	DJBST,GRBST
		EXTERN	CAMERA_CHR_TRAN,CAMERA_SCR_TRAN
		EXTERN	CAMERA_COL_TRAN,CAMERA_CHR_RESET
;-------------<	ZPL >----------------------------------------------------
		EXTERN	FDIN,FDOUT,GPLAY
;-------------<	ZCO >----------------------------------------------------
		EXTERN	LCDC_OFF
;
;==============	僶儞僋俀侾 ==============================================
BANK21		GROUP	21
;-------------<	ZMA >----------------------------------------------------
		EXTERN	CL_CAMERA_OBJ
;
;==============	僶儞僋俀俋 ==============================================
BANK29		GROUP	$29
;-------------<	ZCC >----------------------------------------------------
		EXTERN	Photo_00_cgx,Photo_00_scr,Photo_00_col
		EXTERN	Photo_01_cgx,Photo_01_scr,Photo_01_col
		EXTERN	Photo_02_cgx,Photo_02_scr,Photo_02_col
;
;========================================================================
		PUBALL
		NLIST
		KANJI
		isdmg
;------------------------------------------------------------------------
		LIB	ZRAM		; RAM 俤俻倀俙俿俤 僼傽僀儖
		LIB	ZBN		; BG unit no file !
;------------------------------------------------------------------------
		LIST


;仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩
;仩	僶儞僋俀俉						       仩
;仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩仩
BANK28		GROUP	$28
		ORG	$4000

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僇儊儔壆 儊僀儞							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CAMERA_MAIN
		LD	A,(ITMODE)
		RST	0
;------------------------------------------------------------------------
CAMERA_TABLE
		DW	CAMERA_INIT	; (0) 僀僯僔儍儖
CFOUT		DW	FADE_OUT	; (1) 僼僃乕僪傾僂僩
		DW	TRANSFER_MAIN	; (2) 揮憲儊僀儞
		DW	FADE_IN		; (3) 僼僃乕僪僀儞
		DW	CAMERA_PLAY	; (4) 僾儗僀
		DW	FADE_OUT	; (5) 僼僃乕僪傾僂僩
		DW	RETURN_GAME	; (6) 儕僞乕儞僎乕儉

C_fout		EQU	(CFOUT-CAMERA_TABLE)/2

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僼僃乕僪傾僂僩							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FADE_OUT
		CALL	FDIN		; FDIN 偩偗偳僼僃乕僪傾僂僩

		LD	A,(SBHR)
		CP	$04
		RET	NZ

		JP	ITMODE_INC

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僼僃乕僪僀儞							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FADE_IN
		CALL	FDOUT		; FDOUT 偩偗偳僼僃乕僪僀儞

		LD	A,(SBHR)
		CP	$04
		RET	NZ

		JP	ITMODE_INC

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僇儊儔壆 僀僯僔儍儖						x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CAMERA_INIT
		XOR	A
		LD	(PHOTONO),A
		LD	(SBHR),A
;------------------------------------------------------------------------
;;;;;;;		CALL	COLOR_ESCAPE	; 僇儔乕懸旔

		JP	ITMODE_INC

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僇儔乕懸旔							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
COLOR_ESCAPE
		LD	A,(CGBFLG)
		AND	A
		JR	Z,COLES_200
		LD	HL,CGWORK
		LD	C,$080
		DI			;妱傝崬傒嬛巭
COLES_100
		XOR	A
		LD	(SVBK),A
		LD	B,(HL)
		LD	A,$003
		LD	(SVBK),A
		LD	(HL),B
		INC	HL
		DEC	C
		LD	A,C
		AND	A
		JR	NZ,COLES_100
		XOR	A
		LD	(SVBK),A
		EI			;妱傝崬傒嫋壜
COLES_200
		RET

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	揮憲儊僀儞							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TRANSFER_MAIN
		CALL	LCDC_OFF	; 俴俠俢俠 僗僩僢僾

		CALL	CHR_TRANSFER	; 僉儍儔僋僞乕
		CALL	SCR_TRANSFER	; 僗僋儕乕儞
		CALL	COL_TRANSFER	; 僇儔乕

		LD	A,$001		; 僼僃乕僪僀儞僼儔僌俷俶
		LD	(FADEMDFG),A
		XOR	A
		LD	(SBHR),A

;;;;;;		LD	A,(LCDCB)	; 俷俛俰 俛俧 俷俶 俴俠俢俠 僗僞乕僩
		LD	A,%11000111	; 俷俛俰 俛俧 俷俶 俴俠俢俠 僗僞乕僩
		LD	(LCDCB),A
		LD	(LCDC),A

		JP	ITMODE_INC

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僉儍儔僋僞乕揮憲						x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CHR_TRANSFER
		LD	A,(PHOTONO)
		LD	B,A
		SLA	A
		ADD	A,B		; 亊俁
		LD	D,$0
		LD	E,A
		LD	HL,Chr_data_adrs
		ADD	HL,DE
		PUSH	DE

		LD	A,(HLI)
		LD	C,A
		ld	(chradr+0),a
		LD	A,(HLI)
		LD	B,A
		ld	(chradr+1),a
		LD	A,(HL)		; 俛俙俶俲
		ld	(chradr+2),a
		LD	H,B		; 俫俬俧俫
		LD	L,C		; 俴俷倂
		PUSH	HL

		LD	BC,$800		; 揮憲屄悢
		LD	DE,CHR_VRAM_ADRS+1000H

		CALL	CAMERA_CHR_TRAN		; 俛俧

		POP	HL
		LD	BC,$800		; 揮憲屄悢
		ADD	HL,BC
		LD	DE,CHR_VRAM_ADRS+800H
		LD	A,(chradr+2)

		CALL	CAMERA_CHR_TRAN		; 俛俧仌俷俛俰

;
;	偲傝偁偊偢丄偙偙偱揮憲両
;
		LD	BC,$400			; 揮憲屄悢
		LD	DE,CHR_VRAM_ADRS
		LD	HL,$4000+1200H
		LD	A,$35

		CALL	CAMERA_CHR_TRAN		; 俷俛俰

		POP	DE
		RET

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僗僋儕乕儞揮憲							x
;x----------------------------------------------------------------------x
;x	    俤俶俿俼倄							x
;x		俢俤       丗 僨乕僞傾僪儗僗僀儞僨僢僋僗		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SCR_TRANSFER
;;;;;;;		LD	A,(PHOTONO)
;;;;;;;		LD	B,A
;;;;;;;		SLA	A
;;;;;;;		ADD	A,B		; 亊俁
;;;;;;;		LD	D,$0
;;;;;;;		LD	E,A
		LD	HL,Scr_data_adrs
		ADD	HL,DE
		PUSH	DE

		LD	A,(HLI)
		LD	C,A
		LD	A,(HLI)
		LD	B,A
		LD	A,(HL)		; 俛俙俶俲
		LD	H,B		; 俫俬俧俫
		LD	L,C		; 俴俷倂

		CALL	CAMERA_SCR_TRAN

		POP	DE
		RET

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僇儔乕揮憲							x
;x----------------------------------------------------------------------x
;x	    俤俶俿俼倄							x
;x		俢俤       丗 僨乕僞傾僪儗僗僀儞僨僢僋僗		x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
COL_TRANSFER
		LD	A,(CGBFLG)
		AND	A
		RET	Z

;;;;;;;		LD	A,(PHOTONO)
;;;;;;;		LD	B,A
;;;;;;;		SLA	A
;;;;;;;		ADD	A,B		; 亊俁
;;;;;;;		LD	D,$0
;;;;;;;		LD	E,A
		LD	HL,Col_data_adrs
		ADD	HL,DE

		LD	A,(HLI)
		LD	C,A
		LD	A,(HLI)
		LD	B,A
		LD	A,(HL)		; 俛俙俶俲
		LD	H,B		; 俫俬俧俫
		LD	L,C		; 俴俷倂

;;;;;;;		LD	BC,$0080	; 揮憲屄悢
		LD	BC,$0040	; 揮憲屄悢
		LD	DE,CGWORK

		CALL	CAMERA_COL_TRAN

;
;	偲傝偁偊偢丄偙偙偱揮憲両
;
		LD	BC,$0040	; 揮憲屄悢
		LD	HL,CL_CAMERA_OBJ
		LD	DE,CGWORK+40H
		LD	A,:CL_CAMERA_OBJ

		CALL	CAMERA_COL_TRAN

		RET

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	僇儊儔壆 僾儗僀							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CAMERA_PLAY
		LD	A,(KEYA2)
		AND	%10000000	; 俽俿俙俼俿僉乕 俷俶丠
		JR	Z,CAMPL_100	; 俶俷

		XOR	A
		LD	(SBHR),A
		JP	ITMODE_INC
;------------------------------------------------------------------------
;	嵍塃僉乕 僠僃僢僋
;------------------------------------------------------------------------
CAMPL_100
		BIT	1,A
		JR	Z,CAMPL_200
;------------------------------------------------------------------------
					; 嵍僉乕俷俶
		LD	A,(PHOTONO)
		AND	A
		JR	Z,CAMPL_110

		DEC	A
		JR	CAMPL_300
CAMPL_110
		LD	A,Photo_count
		JR	CAMPL_300
;------------------------------------------------------------------------
CAMPL_200				; 塃僉乕俷俶
		BIT	0,A
		JR	Z,CAMPL_500

		LD	A,(PHOTONO)
		INC	A
		CP	Photo_count
		JR	NZ,CAMPL_300

		XOR	A
;------------------------------------------------------------------------
CAMPL_300
		LD	(PHOTONO),A

		LD	A,C_fout
		LD	(ITMODE),A
		XOR	A
		LD	(SBHR),A
		RET

;------------------------------------------------------------------------
;	傕偟偐偟偰丄俙儃僞儞偱 僾儕儞僩傾僂僩丠
;------------------------------------------------------------------------
CAMPL_500
		LD	A,(KEYA2)
		BIT	4,A
		RET	Z

;###################################################
;	僾儕儞僩傾僂僩 僀僯僔儍儖張棟傪偙偙傊
;###################################################
		RET

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	 儕僞乕儞僎乕儉							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
RETURN_GAME
		CALL	LCDC_OFF	; 俴俠俢俠 僗僩僢僾

		LD	A,:RETURN_GAME
		CALL	CAMERA_CHR_RESET

		LD	A,(LCDCB)	; 俷俛俰 俛俧 俷俶 俴俠俢俠 僗僞乕僩
		LD	(LCDCB),A
		LD	(LCDC),A

		LD	A,GPLAY
		LD	(GMMODE),A
		XOR	A
		LD	(ITMODE),A
		RET

;-------------------------------------------------------


		LD	A,$001		;僼僃乕僪僀儞僼儔僌俷俶
		LD	(FADEMDFG),A

		XOR	A
		LD	(SHOPFG),A	; Shop BG initial !!
		LD	(ZZZFLG),A	;僞儕儞 倸倸倸 僙僢僩僼儔僌
		LD	(SCCH),A
		LD	(SCCV),A
		LD	(ITEMNOT),A
		LD	(WNDFLG),A

		LD	A,$07
		LD	(SLEVEL),A
		LD	A,$70
		LD	(SLEVEL+1),A

		LD	A,GPLAY
		LD	(GMMODE),A

		LD	(BGMNOT),A

		LD	A,$2		; (CGB)
		LD	(ITMODE),A

		LD	A,(DJFLAG)
		AND	A
		LD	A,DJBST		; Bank set!
		JR	NZ,RETGM_100	; Danjyon ?
					; yes !
		LD	A,GRBST		; Bank set!
RETGM_100
		LD	(BLNKFG),A

		LD	HL,SCRLFG	; Scroll base display reset !
		LD	E,$0
RETGM_200
		XOR	A
		LD	(HLI),A
		INC	E
		LD	A,E
		CP	$C
		JR	NZ,RETGM_200

		LD	A,$80
		LD	(WNDYPS),A
		LD	A,$06
		LD	(WDX),A		; Item window position initial 

		LD	A,$08
		LD	(WNDSPD),A	; Item window speed initial

		LD	A,$07		;僒僂儞僪儃儕儏乕儉栠偡
		LD	(SLEVEL),A	;
		LD	A,$70		;
		LD	(SLEVEL+1),A	;

		LD	A,(CGBFLG)
		AND	A
		RET	Z
		LD	HL,CGWORK
		LD	C,$080
		DI			;妱傝崬傒嬛巭
RETGM_300
		LD	A,$003
		LD	(SVBK),A
		LD	B,(HL)
		DEC	A
		LD	(SVBK),A
		LD	(HL),B
		INC	HL
		DEC	C
		LD	A,C
		AND	A
		JR	NZ,RETGM_300
		XOR	A
		LD	(SVBK),A

		LD	A,(LCDCB)
		AND	%01111111
		LD	(LCDC),A

		LD	A,(DNJNNO)
		CP	NEWDJ		;怴僟儞僕儑儞丠
		JR	NZ,RETGM_400	;	NO --> RETGM_400
		LD	A,$001
		LD	(BKCHF2),A
RETGM_400
		LD	A,(LCDCB)
		LD	(LCDC),A

		EI			;妱傝崬傒嫋壜

		RET

;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	 儌乕僪倝値們							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ITMODE_INC
		LD	HL,ITMODE
		INC	(HL)
		RET




;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;x	 揮憲僨乕僞							x
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CHR_VRAM_ADRS	EQU	$8000
SCR_VRAM_ADRS	EQU	$9800

;劇劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劉
;劆	僉儍儔僋僞乕僨乕僞 傾僪儗僗				       劆
;劋劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劊
Chr_data_adrs
		DL	Photo_00_cgx
		DL	Photo_01_cgx
		DL	Photo_02_cgx
Chr_data_end

Photo_count	EQU	(Chr_data_end-Chr_data_adrs)/3

;劇劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劉
;劆	僗僋儕乕儞乕僨乕僞 傾僪儗僗				       劆
;劋劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劊
Scr_data_adrs
		DL	Photo_00_scr
		DL	Photo_01_scr
		DL	Photo_02_scr


;劇劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劉
;劆	僇儔乕僨乕僞 傾僪儗僗					       劆
;劋劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劅劊
Col_data_adrs
		DL	Photo_00_col
		DL	Photo_01_col
		DL	Photo_02_col





;------------------------------------------------------------------------
		END
;------------------------------------------------------------------------
