; NEOZCNCAgvO

#define	NEOZC_CLIENT	1

#define	DEBUG_TEXT	1
//#define	DEBUG		1
//#define	BALL_RESET	1	; {[Zbgp



#include "..\\Library\\e3dhsp3.as"

#include "..\\Library\\hsp261cmp.as"	;; HSP2.61݊}NLɂ

#include "..\\Common\\neozc_cs_common.hsp"

#ifdef	USE_PCBNET
	#include "..\\Common\\AMdplayStub.hsp"
#else	; USE AMDplay
  #ifdef COM_DEBUG
	#include "..\\Library\\AMdplayD.as" ; for DEBUG
  #else
	#include "..\\Library\\AMdplay.as"
  #endif

  #include "..\\Library\\m_AMdplaySupport.as"
#endif


#include "neozc_macro.hsp"


; ݒt@C̓ǂݍ
#include "neozc_loadini.hsp"

;; st@C쐬p
#packopt type 0
#packopt name "neozc_client.exe"
#packopt hide 0

; tB[h̃TCY (O܂)
#define	global	MAP_SIZE	200000
#define global	MAP_DIV		5
#define global	MAP_HEIGHT	10000

; LbN̎
#define KICK_TYPE_PIN		1
#define KICK_TYPE_TAME		2
#define KICK_TYPE_SHOOT		3

; LbN(s)̋̍ől
#define	KICK_DISTANCE_MAX	15000

; }EX
#define MOUSE_RBUTTON		0x01	; (bit 0)
#define	MOUSE_LBUTTON		0x02	; (bit 1)

; SYNC҂^CAEg
#define SYNC_WAIT_TIMEOUT	20	; t[

; {[̉ẽItZbg
#define BS_XOFFS	10
#define BS_YOFFS	0
#define BS_ZOFFS	10

; l̉ẽItZbg
#define MAN_XOFFS	10
#define MAN_YOFFS	0
#define MAN_ZOFFS	10


; XN[ID̒`
#define SCR_SUB		2
if ( Full_Screen == "1" ) {
	SCR_MAIN = 2
}
else {
	SCR_MAIN = 0
}

#define SCR_CHAT	10

; L̈ړ (GKȊO)
#define MVSTAT_NORMAL		1	; ʏړ
#define MVSTAT_THROW_IN		2	; X[C
#define MVSTAT_CORNER_KICK	3	; R[i[LbN
#define MVSTAT_FREE_KICK	4	; t[LbN


; tXN[̃`FbN
;gosub *CheckFullScreen


if ( Full_Screen == "1" ) {
;	chgdisp 1	; 𑜓x640x480ɋύX
	screenw = dispx
	screenh = dispy
}
else {
	screenw = SCREEN_WIDTH
	screenh = SCREEN_HEIGHT
}

	scrw_center = screenw / 2
	scrh_center = screenh / 2
;	screen SCR_SUB, 640, 480, 1

if ( Full_Screen == "1" ) {
	bgscr SCR_MAIN, screenw, screenh
}
else {
	screen SCR_MAIN, screenw, screenh, 1
}

;	gsel SCR_MAIN,1
;	pos 0, 0
;	objsize screenw, (screenh-20)
;	winobj "STATIC", "", 0, $54000000
;	objid1 = stat

;	gsel SCR_SUB, 1
	title GAME_NAME + " Client " + GAME_VERSION + " Robby"

onexit *bye0

#include "neozc_clentry.hsp"

*start_game


	; vC[f[^̏
	gosub *Players_Init

;	gsel SCR_MAIN, 1

	title GAME_NAME + " Client " + GAME_VERSION

#ifdef DEBUG
	E3DEnableDbgFile
#endif


#if 1
	; `bgpʍ쐬
	gosub *CreateChatScreen

	gsel SCR_MAIN, 1
#endif

	; Easy3D̏
;	E3DInit fullscreenflag, validbits
;	E3DInit SCR_MAIN, objid1, 0, 16, 0, scid
	E3DInit SCR_MAIN, -1, 0, 16, 0, scid

	onexit *bye

	await 10

	; TEh̏
	gosub *InitSounds

;	gsel SCR_SUB, 1
	; ʐM̊Jn
	gosub *AMdplay_init
	cls

	gsel SCR_MAIN, 1

	dim keybuf, 256

	pathlen = 2048
	sdim mediadir, pathlen
	mediadir = curdir + "\\..\\Media"

	;file path p̃obt@[̍쐬
	sdim pathbuf, pathlen, 15

	chgdegx = 0 : chkdegy = 0 : chkdegz = 0

	pointmax = 100

	debug_disp = 0			; foO\

	;J̏
;	camposx = 0 : camposy = 2500 : camposz = 0
;	E3DSetCameraPos camposx, camposy, camposz	
;	camdegxz = 180 : camdegy = 0
;	E3DSetCameraDeg camdegxz, camdegy
;	Viewpoint = 1

	; Jړp
	if ( my_tm == TEAM_BLUE ) {

		if ( my_pos == GKPOS ) { 	; GK
;			camposxx = -7000
;			camposyy = 7000
			cam_alpha = 25
			cam_dis = 15000
		} else {
;			camposxx = -5000
;			camposyy = 15000
			cam_alpha = 25
			cam_dis = 17000
		}
;		camposzz = 0
		cam_beta = 180
	}
	else {
		if ( my_pos == GKPOS ) { 	; GK
;			camposxx = 7000
;			camposyy = 7000
			cam_alpha = 25
			cam_dis = 15000
		}
		else {
;			camposxx = 5000
;			camposyy = 15000
			cam_alpha = 25
			cam_dis = 17000
		}
;		camposzz = 0
		cam_beta = 0
	}
	gosub *CalcCameraPos
	gosub *SaveCameraPos


	confflag = 0
	endflag = 0

	;projection̕ύXƂ́Aȉ̂QsLɂĂB
	proj_near = 100 : proj_far = 500000 : proj_fov = 45
	E3DSetProjection proj_near, proj_far, proj_fov


;	E3DCreateProgressBar
;	E3DSetProgressBar 0

	
	; X^WAf[^̃[h
	pathbuf.0 = mediadir + "\\Field\\studium.mqo"
	E3DLoadMQOFIleAsGround pathbuf.0, 100, hsid0

#if 0
	pathbuf.0 = mediadir + "\\Ground\\test_course_02.mqo"
	E3DLoadMQOFileAsGround pathbuf.0, 16000, hsid0
#endif

	posx0 = 0 : posy0 = 0 : posz0 = 0
	degx0 = 0 : degy0 = 0 : degz0 = 0
	E3DSetPos hsid0, posx0, posy0, posz0
	E3DSetDir hsid0, degx0, degy0, degz0
	frameno0 = 0

	; tB[h̊O (J[\ʒuopɁAɏd˂)
	pathbuf.0 = mediadir + "\\Ground\\base.bmp"
	pathbuf.1 = mediadir + "\\Ground\\road.bmp"
	pathbuf.2 = mediadir + "\\Ground\\water.bmp"
	pathbuf.3 = mediadir + "\\Ground\\bg_texture.bmp"
	E3DLoadGroundBMP pathbuf.0, pathbuf.1, pathbuf.2, pathbuf.3, MAP_SIZE, MAP_SIZE, MAP_DIV, MAP_DIV, MAP_HEIGHT, hsid1
	E3DSetPos hsid1, LINE_X0 * 2, -300, LINE_Z0 * 2
	E3DSetDir hsid1, 0, 0, 0
	frameno1 = 0

;	E3DSetProgressBar 30

#if 0
	; ǃf[^̃[h
	E3DSetMovableArea pathbuf.1, mapsize, mapsize, mapdiv, mapdiv, mapheight + 1000, hsid1

	posx1 = 0 : posy1 = 0 : posz1 = 0
	degx1 = 0 : degy1 = 0 : degz1 = 0
	E3DSetPos hsid1, posx1, posy1, posz1
	E3DSetDir hsid1, degx1, degy1, degz1
	frameno1 = 0
#endif

;	E3DSetProgressBar 50

	; vC[p̃ff[^	(\͂Ȃ)
	gosub *InitModelData

	; HSID蓖
	if ( my_pos == GKPOS ) {	; GK̏ꍇ
		player_hsid.my_pno = gk_hsid_tbl.0.my_tm
		player_shsid.my_pno = gk_shsid_tbl.0.my_tm
		gk_hsid_used.0.my_tm = 1
	}
	else {
		player_hsid.my_pno = pl_hsid_tbl.0.my_tm
		player_shsid.my_pno = pl_shsid_tbl.0.my_tm
		pl_hsid_used.0.my_tm = 1
	}

#if 0
	;ff[^̓ǂݍ
	if ( my_tm == TEAM_RED ) {
		pathbuf.0 = mediadir + "\\man\\man.sig"
	}
	else {
		pathbuf.0 = mediadir + "\\man\\man2.sig"
	}
;	pathbuf.1 = mediadir + "\\man\\man.qua"
	pathbuf.1 = mediadir + "\\man\\walk.qua"
	pathbuf.2 = mediadir + "\\man\\run.qua"
	pathbuf.3 = mediadir + "\\man\\stop.qua"

	E3DSigLoad pathbuf.0, hsid4
	E3DAddMotion hsid4, pathbuf.1, mk4_walk, max4_walk
	E3DAddMotion hsid4, pathbuf.2, mk4_run, max4_run
	E3DAddMotion hsid4, pathbuf.3, mk4_stop, max4_stop

#else
	hsid4 = player_hsid.my_pno
	shsid4 = player_shsid.my_pno

	; [Vpf[^Zbg
	mk4_walk = mkot_walk: max4_walk = maxot_walk
	mk4_run = mkot_run: max4_run = maxot_run
	mk4_throw = mkot_throw: max4_throw = maxot_throw
	mk4_throw_stop = mkot_throw_stop: max4_throw_stop = maxot_throw_stop
	mk4_stop = mkot_stop: max4_stop = maxot_stop
	mk4_trap = mkot_trap: max4_trap = maxot_trap
	mk4_kick1 = mkot_kick1: max4_kick1 = maxot_kick1


#endif
	motkind = mk4_stop
	E3DSetMotionKind hsid4, motkind

	;posx4 = 15910 : posy4 = 3000 : posz4 = 15778
	degx4 = 0: degy4 = curdeg: degz4 = 0

	E3DSetPos hsid4, posx4, posy4, posz4
	E3DSetDir hsid4, degx4, degy4, degz4
	frameno4 = 0
	newmk4 = 0
	curposx4 = posx4 : curposy4 = posy4 : curposz4 = posz4
	E3DSetBeforePos hsid4

	; ŏ̃|WʐM
	gosub *Send_Player_Move

	; {[
	pathbuf.0 = mediadir + "\\ball\\ball.sig"
;	pathbuf.1 = mediadir + "\\ball.qua"
	pathbuf.1 = mediadir + "\\ball\\stop.qua
	pathbuf.2 = mediadir + "\\ball\\roll.qua"
	E3DSigLoad pathbuf.0, hsidb
	E3DAddMotion hsidb, pathbuf.1, mkb_stop, maxb_stop
	E3DAddMotion hsidb, pathbuf.2, mkb_roll, maxb_roll

	E3DSetMotionKind hsidb, mkb_stop

	; {[̉e
	pathbuf.0 = mediadir + "\\ball\\ballshadow.sig"
	E3DSigLoad pathbuf.0, hsidbs

	ball_pos_recv = 0

#ifdef BALL_RESET
	; {[ʒuZbgp	
	posxb = 0 : posyb = BALL_INIY : poszb = 0	; ^񒆂
	degxb = 0 : degyb = 180 : degzb = 0

	E3DSetPos hsidb, posxb, posyb, poszb
	E3DSetDir hsidb, degxb, degyb, degzb

	E3DSetPos hsidbs, posxb+BS_XOFFS, posyb+BS_YOFFS, poszb+BS_ZOFFS
	E3DSetDir hsidbs, 0, 0, 0

	gosub *Send_Ball_Move
#else
	posxb = -10000 : posyb = -1000 : poszb = 0	; Kȃ|WV
	degxb = 0 : degyb = 180 : degzb = 0

	E3DSetPos hsidb, posxb, posyb, poszb
	E3DSetDir hsidb, degxb, degyb, degzb

	E3DSetPos hsidbs, posxb+BS_XOFFS, posyb+BS_YOFFS, poszb+BS_ZOFFS
	E3DSetDir hsidbs, 0, 0, 0

#endif

	framenob = 0
	framenobs = 0
;	E3DSetBeforePos hsidb

;	E3DSetProgressBar 60

	;!!!!!!!!!!!!!!!!!!!!!
	; PosOnGround ߂g߂ɁAChkInViewA炩߁AĂłKv܂B
	;!!!!!!!!!!!!!!!!!!!!!
	E3DChkInView scid, hsid0

	;////////billboard
		
	E3DSeed 321
	
	bbnum = 50

	; tHg̍쐬
	E3DCreateFont 12, 0, 600, 0, 0, 0, "lr SVbN", fontid1	; Ƒ
;	E3DCreateFont 12, 0, 600, 0, 0, 0, "Ariel", fontid1	; Ƒ

	E3DCreateFont 36, 0, 500, 0, 0, 0, "lr SVbN", fontid2

	; `bgp
	E3DCreateFont 12, 0, 600, 0, 0, 0, "lr SVbN", fontid_chat

	; Q[W(XvCg)̍쐬
	pathbuf.0 = mediadir + "\\gage1.bmp"
	E3DCreateSprite pathbuf.0, 1, gage_spid1
	E3DGetSpriteSize gage_spid1, spw1, sph1

	pathbuf.1 = mediadir + "\\gage2.bmp"
	E3DCreateSprite pathbuf.1, 0, gage_spid2
	E3DGetSpriteSize gage_spid2, spw2, sph2
	E3DSetSpriteRotation gage_spid2, spw2/2, sph2/2, 180

	; [_(XvCg)̍쐬
	; tB[h
	pathbuf.0 = mediadir + "\\radermap.bmp"
	E3DCreateSprite pathbuf.0, 1, radermap_spid
	E3DGetSpriteSize radermap_spid, radermapw, radermaph

	; X^~ipXvCg̍쐬
	pathbuf.0 = mediadir + "\\stamina.bmp"
	E3DCreateSprite pathbuf.0, 0, stamina_spid1
	E3DGetSpriteSize stamina_spid1, staw1, stah1

	pathbuf.0 = mediadir + "\\stamina2.bmp"
	E3DCreateSprite pathbuf.0, 0, stamina_spid2
	E3DGetSpriteSize stamina_spid2, staw2, stah2
	E3DSetSpriteRotation stamina_spid2, staw2/2, stah2/2, 180

	pathbuf.0 = mediadir + "\\stamina2.bmp"
	E3DCreateSprite pathbuf.0, 0, stamina_spid3
	E3DGetSpriteSize stamina_spid3, staw3, stah3
	E3DSetSpriteRotation stamina_spid3, staw3/2, stah3/2, 180

	; {[
	pathbuf.0 = mediadir + "\\raderball.bmp"
	E3DCreateSprite pathbuf.0, 2, raderball_spid, 128, 128, 128
	E3DGetSpriteSize raderball_spid, raderballw, raderballh

	; Blue`[
	pathbuf.0 = mediadir + "\\raderp1.bmp"
	E3DCreateSprite pathbuf.0, 1, raderp1_spid, 128, 128, 128
	E3DGetSpriteSize  raderp1_spid, raderp1w, raderp1h

	; Red`[
	pathbuf.0 = mediadir + "\\raderp2.bmp"
	E3DCreateSprite pathbuf.0, 1, raderp2_spid
	E3DGetSpriteSize  raderp2_spid, raderp2w, raderp2h

	; X^[g{^
	pathbuf.0 = mediadir + "\\startbutton.bmp"
	E3DCreateSprite pathbuf.0, 1, startbtn_spid
	E3DGetSpriteSize startbtn_spid, startbtnw, startbtnh

;	E3DSetProgressBar 90

	;********


	;/////////////////	
	
	testfps = 0

	lightdirx1 = 10
	lightdiry1 = -10
	lightdirz1 = 2
	lightr1 = 255
	lightg1 = 255
	lightb1 = 255

	E3DCreateLight lid1
	E3DSetDirectionalLight lid1, lightdirx1, lightdiry1, lightdirz1, lightr1, lightg1, lightb1

	chkfps1 = 0

	pathbuf.0 = mediadir + "\\dummy.bmp"
	pathbuf.1 = mediadir + "\\cloud3.bmp"
	E3DCreateBG scid, pathbuf.0, pathbuf.1, 1, 0, 0


;	E3DDestroyProgressBar

	pbflag = 0;

	result0 = 0 : result1 = 0 : result2 = 0 : result3 = 0
	adjustx0 = 0 : adjusty0 = 0 : adjustz0 = 0
	adjustx1 = 0 : adjusty1 = 0 : adjustz1 = 0
	adjustx2 = 0 : adjusty2 = 0 : adjustz2 = 0
	adjustx3 = 0 : adjusty3 = 0 : adjustz3 = 0

	befposx = posx4 : befposy = posy4 : befposz = posz4

	ccw = 0
	nx1 = 0 : ny1 = 0 : nz1 = 0
	dot1 = 0 : dot2 = 0 : dot = 0

	dim arfps, 50

	; GKPA͈̔
	if ( my_tm == TEAM_BLUE ) {
		pa_linex0 = PA_LINE_X0
		pa_linez0 = PA_LINE_Z0
		pa_linex1 = PA_LINE_X1
		pa_linez1 = PA_LINE_Z1
	}
	else {
		pa_linex0 = -(PA_LINE_X1)
		pa_linez0 =  PA_LINE_Z0
		pa_linex1 = -(PA_LINE_X0)
		pa_linez1 =  PA_LINE_Z1
	}

	; X^~io[̍W
	stax = screenw-150
	stay = screenh-100

	; [_̍W
	raderx = screenw-150
	radery = screenh-250
	rxoffs = 0
	ryoffs = 0
	raderscx = (LINE_Z1 - LINE_Z0) / radermapw
	raderscy = (LINE_X1 - LINE_X0) / radermaph
	raderdeg = 0	; 
	
	; tO
	sync_flag = 1
	sync_wait_cnt = 0

	; Q[
	game_state = STAT_PRE_GAME
	
	; Jñ{[`[
	ini_ball_owner_team = TEAM_BLUE

	game_start_flag = 0
	mymv_stat = MVSTAT_NORMAL 

	; ̃f[^̏
	gosub *InitMyData

	; `bgbZ[W
	gosub *InitChatMsg


*main
	; Mf[^`FbN
	gosub *Receive_Check

	switch game_state
		case STAT_PRE_GAME	; Q[JnO
			if ( game_start_flag > 0 ) {

;				gsel SCR_SUB, -1
				cls
				if ( game_start_flag == 1 ) {
					gosub *Send_Game_Ack
				}
				else {
					; T[o[ɃQ[Jnʒm
					gosub *Send_Game_Start
				}

				; vC[f[^
				gosub *InitPlayers	

				; ̃f[^
				gosub *InitMyData

				; `bgf[^
				gosub *InitChatMsg

				game_phase = PHASE_HALF1

				game_state = STAT_WAIT_READY
			}
			else {
				gosub *game_main_playing
			}
			swbreak
		case STAT_WAIT_READY
			gosub *game_main_wait_ready
			swbreak
		case STAT_GAME_PLAYING
			gosub *game_main_playing
			swbreak
		case STAT_GAME_BREAK
			gosub *game_main_break
			swbreak
		default
			gosub *game_main_playing
			swbreak
	swend

	; t[ԍ̍XV
	my_frameNo++
	if ( my_frameNo > FRAME_NO_MAX ) {
		my_frameNo = 0
	}

	goto *main


*bye
	;E3DDestroyHandlerSet hsid1
	;E3DDestroyHandlerSet hsid2
	;E3DDestroyHandlerSet hsid0
	;E3DDestroyBG scid

	;E3DDestroyLight lid1

	E3DBye
*bye0

	end

; {[̈ʒuZbg
*MoveBall
	If ( ball_pos_recv == 0 ) {
		return
	}

	E3DSetPos hsidb, posxb, posyb + ymove * 2, poszb
	E3DSetPos hsidbs, posxb+BS_XOFFS, posyb+BS_YOFFS, poszb+BS_ZOFFS

	prev_ba_motkind = ba_motkind
	If ( ( ba_dribbled == 1 ) || ( ba_stat == BA_STAT_MOVING ) ) {
		ba_motkind = mkb_roll
		ba_dribbled = 0 
	}
	else {
		ba_motkind = mkb_stop
	}

	If ( prev_ba_motkind != ba_motkind ) {
		E3DSetMotionKind hsidb, ba_motkind
	}

	return

; J̈ړ
*MoveCamera
	if ( ball_view == 1 ) {
		saveposx4 = posxb: saveposy4 = posyb: saveposz4 = poszb
;		E3DGetPos hsidb, saveposx4, saveposy4, saveposz4
	}
	else {
		saveposx4 = posx4: saveposy4 = posy4: saveposz4 = posz4
;		E3DGetPos hsid4, saveposx4, saveposy4, saveposz4
	}

	E3DSetCameraPos saveposx4 + camposxx, saveposy4 + camposyy, saveposz4 + camposzz
	E3DSetCameraTarget saveposx4, saveposy4 + 500, saveposz4, 0, 1, 0
return

; JW̌vZ
*CalcCameraPos

	E3DCos cam_alpha, cos_alpha
	E3DSin cam_alpha, sin_alpha
	E3DCos cam_beta, cos_beta
	E3DSin cam_beta, sin_beta
	
	camposxx = cam_dis * int(cos_alpha * 100) * int(cos_beta * 100) / 10000
	camposzz = cam_dis * int(cos_alpha * 100) * int(sin_beta * 100) / 10000
	camposyy = cam_dis * int(sin_alpha * 100) / 100
return

; X[Cp̃J|WV
*SetCameraPos_ThrowIn
	if ( posz4 <= (LINE_Z0 + 1000) ) {
		camposzz = 15000
	}	
	else {
		camposzz = -15000
	}
	camposxx = 0
	camposyy = 10000
return

; t[LbNp̃J|WV
*SetCameraPos_FreeKick
	if ( my_tm == TEAM_BLUE ) {
		camposxx = -17000
	}
	else {
		camposxx = 17000
	}
	camposyy = 7200
	camposzz = 0
return


; R[i[LbNp̃J|WV
*SetCameraPos_CornerKick

	if ( posx4 < (LINE_X0+1000) ) && ( posz4 < (LINE_Z0+1000 ) ) {
		camposxx = -2000: camposyy = 3000: camposzz = -4500
	}
	if ( posx4 < (LINE_X0+1000) ) && ( posz4 > (LINE_Z1-1000 ) ) {
		camposxx = -2000: camposyy = 3000: camposzz =  4500
	}
	if ( posx4 > (LINE_X1-1000) ) && ( posz4 < (LINE_Z0+1000 ) ) {
		camposxx =  2000: camposyy = 3000: camposzz = -4500
	}
	if ( posx4 > (LINE_X1-1000) ) && ( posz4 > (LINE_Z1-1000 ) ) {
		camposxx =  2000: camposyy = 3000: camposzz =  4500
	}

return

; ݂̃J|WVޔ
*SaveCameraPos
	svcamposxx = camposxx
	svcamposyy = camposyy
	svcamposzz = camposzz
return

; ޔJ|WV𕜋A
*RestoreCameraPos
	camposxx = svcamposxx
	camposyy = svcamposyy
	camposzz = svcamposzz
return


*DrawRader
	; [_\
	
	E3DBeginSprite

	; tB[h	
	E3DRenderSprite radermap_spid, 1.0, 1.0, raderx+rxoffs, radery+ryoffs
	E3DSetSpriteARGB radermap_spid, 128, 255, 255, 255

#if 0
	; _ɂA[_[̌ύX
	If ( camposxx < 2000 ) && ( camposxx > -2000 ) {
;		E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 90
		E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 0

		; vC[WvZ
		raderp1y = (posz4 - LINE_Z0) / raderscx + radery
		raderp1x = -(posx4 - LINE_X0) / raderscy + raderx + radermapw

		; {[WvZ
		raderbally = (poszb - LINE_Z0) / raderscx + radery
		raderballx = -(posxb - LINE_X0) / raderscy + raderx + radermapw

	}
	else {
		if ( camposxx < -2000 ) {
;			E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 180
			E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 180

			; vC[WvZ
			raderp1x = -((posz4 - LINE_Z0) / raderscx) + raderx + radermapw
			raderp1y = -((posx4 - LINE_X0) / raderscy) + radery + radermaph

			; {[WvZ
			raderballx = -(poszb - LINE_Z0) / raderscx + raderx + radermapw
			raderbally = -(posxb - LINE_X0) / raderscy + radery + radermaph
		}
		else {
;			E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 0
			E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 90

			; vC[WvZ
			raderp1x = (posz4 - LINE_Z0) / raderscx + raderx
			raderp1y = (posx4 - LINE_X0) / raderscy + radery

			; {[WvZ
			raderballx = (poszb - LINE_Z0) / raderscx + raderx
			raderbally = (posxb - LINE_X0) / raderscy + radery

		}
	}
#else

	if ( camposzz > 5000 ) {
		E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 0
		rxoffs = 3: ryoffs = 3		; ʒu̔

		; vC[WvZ
		raderp1y = (posz4 - LINE_Z0) / raderscx + radery
		raderp1x = -(posx4 - LINE_X0) / raderscy + raderx + radermapw

		; {[WvZ
		raderbally = (poszb - LINE_Z0) / raderscx + radery
		raderballx = -(posxb - LINE_X0) / raderscy + raderx + radermapw

	}
	else { 
		if ( camposzz < -5000 ) {
			E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 180
		rxoffs = 3: ryoffs = 4		; ʒu̔

			; vC[WvZ
			raderp1y = -(posz4 - LINE_Z0) / raderscx + radery + radermaph
			raderp1x = (posx4 - LINE_X0) / raderscy + raderx

			; {[WvZ
			raderbally = -(poszb - LINE_Z0) / raderscx + radery + radermaph
			raderballx = (posxb - LINE_X0) / raderscy + raderx
		}
		else {
			if ( camposxx > 0 ) {
				E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 90
				rxoffs = 3: ryoffs = 4		; ʒu̔

				; vC[WvZ
				raderp1x = (posz4 - LINE_Z0) / raderscx + raderx
				raderp1y = (posx4 - LINE_X0) / raderscy + radery

				; {[WvZ
				raderballx = (poszb - LINE_Z0) / raderscx + raderx
				raderbally = (posxb - LINE_X0) / raderscy + radery
			} else {
				E3DSetSpriteRotation radermap_spid, radermapw/2, radermaph/2, 90
				rxoffs = 4: ryoffs = 4		; ʒu̔

				; vC[WvZ
				raderp1x = -((posz4 - LINE_Z0) / raderscx) + raderx + radermapw
				raderp1y = -((posx4 - LINE_X0) / raderscy) + radery + radermaph	

				; {[WvZ
				raderballx = -(poszb - LINE_Z0) / raderscx + raderx + radermapw
				raderbally = -(posxb - LINE_X0) / raderscy + radery + radermaph
			}
		}
	}
#endif
	; vC[̃[_[\
	DrawOtherPlayerRaders

	; vC[\
	If ( my_tm == TEAM_BLUE ) {
		E3DRenderSprite raderp1_spid, 1.0, 1.0, raderp1x, raderp1y
	}
	else {
		E3DRenderSprite raderp2_spid, 1.0, 1.0, raderp1x, raderp1y
	}
	; {[\
	E3DRenderSprite raderball_spid, 1.0, 1.0, raderballx, raderbally

	E3DEndSprite

return

*DrawGameMsg

	; XRA̕\
	tmpstr = "Blue"
	E3DDrawText (scrw_center-50), (screenh-80), 1, 0, 0, 255, tmpstr
	tmpstr = " " + game_ctrl.iGCSCBLUE + " - " + game_ctrl.iGCSCRED + " "
	E3DDrawText scrw_center, (screenh-80), 1, 255, 255, 255, tmpstr
	tmpstr = "Red"
	E3DDrawText scrw_center+60, (screenh-80), 1, 255, 0, 0, tmpstr

	; Q[䃁bZ[W̕\
	if ( game_ctrlmsg_cnt > 0 ) {
		game_ctrlmsg_cnt--
		if ( game_ctrlmsg_cnt == 0 ) {
			game_ctrlmsg1 = "                       "
			game_ctrlmsg2 = "                       "
		}

		E3DDrawTextByFontID scid, fontid2, (scrw_center-100), (scrh_center-140), game_ctrlmsg1, 255, 255, 200, 100
		E3DDrawTextByFontID scid, fontid2, (scrw_center-100), (scrh_center-100), game_ctrlmsg2, 255, 255, 200, 100

	}

return

; Ԃ̕\
*DrawTime
	if ( end_time == 0 ) : return

	gosub *GetCurTime

	if ( prev_time != ret_time ) {
		tmptime = end_time - ret_time

		timestr = (tmptime/60)
		timestr = "0" + timestr
		strmid secstr, timestr, -1, 2
		timestr = (tmptime\60)
		timestr = "0" + timestr
		strmid minstr, timestr, -1, 2
		timestr = secstr + ":" + minstr
	
		switch game_phase
			case PHASE_HALF1
				phstr = "  1st"
				swbreak
			case PHASE_HALF2
				phstr = "  2nd"
				swbreak
			case PHASE_EXTRA_HALF1
				phstr = "  ex 1st"
				swbreak
			case PHASE_EXTRA_HALF2
				phstr = "  ex 2nd"
				swbreak
			default
				phstr = " "
		swend
		timestr = timestr + phstr
	}
	
	E3DDrawText (scrw_center-10), (screenh-100), 1, 255, 255, 255, timestr
	prev_time = ret_time
return

*DrawText

	textr = 255 : textg = 255 : textb = 255
	textscale = 1

	lcnt = 0
	avfps = 0
	repeat 50
		avfps += arfps.lcnt
		lcnt++
	loop
	avfps = avfps / 50

	textposx = screenw - 200 : textposy = 5
	strchk1 = "chkFPS1   " + chkfps1 + "(av:" + avfps + ")"
	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk1

#ifdef DEBUG_TEXT

if ( debug_disp == 1 ) {
	tyoffs = 170

	sdim strchk8, 256

	textposx = 10 : textposy = 100 + tyoffs
	strchk8 = dbgmsg
	strchk8 = " " + dbgmsg
 	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk8

	textposx = 10 : textposy = 120 + tyoffs
	strchk8 = "sync wait cnt : " + sync_wait_cnt + "S FrNo:" + server_frameNo + " C FrNo:" + my_frameNo
 	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk8

	E3DGetPos hsid4, chkposx, chkposy, chkposz
	textposx = 10 : textposy = 140 + tyoffs
	strchk3 = "chara position   X : " + chkposx + "  Y : " + chkposy + "  Z : " + chkposz + "  Dri: " + dribbling + " Trap:" + trapping_cnt
	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk3

	textposx = 10 : textposy = 160 + tyoffs
	strchk4 = "confGround result,  result0 " + result0 + "  result1 " + result1 + "  result2 " + result2 + "  result3 " + result3
  	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk4
	
	textposx = 10 : textposy = 180 + tyoffs
	if ( result0 != 0 ){
		strchk5 = "adjustx0 " + adjustx0 + " adjusty0 " + adjusty0 + " adjustz0 " + adjustz0
  		E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk5
	}

	textposx = 10 : textposy = 200 + tyoffs
	strchk6 = "mousex " + mousex + ":mousey " + mousey + ":cur " + curdeg + ":dest " + destdeg
  	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk6

	textposx = 10 : textposy = 220 + tyoffs
	strchk7 = "cam: xx:" + camposxx + " yy: " + camposyy + " zz:" + camposzz + " dxz:" + camdegxz + " dy:" + camdegy
  	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk7

	textposx = 10 : textposy = 240 + tyoffs
	strchk8 = "cam: alpha:" + cam_alpha + " beta: " + cam_beta + " distance:" + cam_dis
  	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk8

	textposx = 10 : textposy = 260 + tyoffs
	strchk9 = "ballx :" + posxb + " bally: " + posyb + " ballz:" + poszb + " ballymv: " + ymove + " stat " + ba_stat
  	E3DDrawText textposx, textposy, textscale, textr, textg, textb, strchk9
}
#endif

return

; tXN[̃`FbN
*CheckFullScreen
	fullscreenflag = 1 ; tXN[ɂꍇɂPw肷BEChE[h̎͂Ow肷

	; ܂AWOO~UOÔRQrbg`FbNB

	E3DCheckFullScreenParams screenw, screenh, 32, validflag, validw, validh, validbits
	if( validflag == 0 ){
		; sꍇ́AWOO~UOÔPUrbg`FbN
		E3DCheckFullScreenParams screenw, screenh, 32, validflag, validw, validh, validbits

		if( validflag == 0 ){
			; sꍇ́AUSO~SWÔRQrbg`FbNB
			scrw = 640 : scrh = 480
			E3DCheckFullScreenParams screenw, screenh, 32, validflag, validw, validh, validbits

			if( validflag == 0 ){
				; sꍇ́AUSO~SWÔPUrbg`FbNB
				scrw = 640 : scrh = 480
				E3DCheckFullScreenParams screenw, screenh, 32, validflag, validw, validh, validbits
				
				if( validflag == 0 ){
					; sꍇ́AtXN[߂B
					fullscreenflag = 0
				}
			}
		}

	}

	if( validflag == 1 ){
		screenw = validw
		screenh = validh
	}
	else {
		screenw = SCREEN_WIDTH
		screenh = SCREEN_HEIGHT
	}	
return

; ݎԂ̎擾
*GetCurTime
	gettime hour, 4
	gettime min, 5
	gettime sec, 6

	ret_time = (hour * 60 * 60) + (min * 60) + sec
return

; Q[ԕʃC
#include "neozc_main.hsp"

; Lړp
#include "neozc_plmove.hsp"

; ʐMpTu[`
#include "neozc_com.hsp"

; vC[p̏CN[h
#include "neozc_players.hsp"

; `bg
#include "neozc_chat.hsp"

; TEh֘A
#include "neozc_sound.hsp"
