----------------------------------------
-- 立ち絵制御 / E-mote
----------------------------------------
emote = {}					-- emote flag
local ex = {}				-- 内部データ
----------------------------------------
ex.frametime	= 16.666	-- 1フレームの時間(ms)
ex.maxframe		= 1000		-- Pregress / ゼロクリアする最大フレーム
ex.armfade		= 15		-- 腕fade(frame)
----------------------------------------
-- エンジンのProgress処理を使用しないOS(準備のみ)
-- ※del時にtransを待ってからデータ削除する処理が必要
ex.progressos = {
	windows = true,
	ps4		= true,
	switch	= true,
}
----------------------------------------
-- 負荷調整 綺麗 1.0 ～ 0.2 軽い / def:初期値 [n]:人数
ex.meshtable = {
--	windows = { def=1, },
	ps4		= { def=0.8, },
	switch	= { def=0.4, [3]=0.3, [4]=0.2, [5]=0.2 },
}
----------------------------------------
-- 口の開き方抑制
ex.lipsyncmax = {
--	aob={ [10]=0.7, [14]=0.7 },	-- 3
--	aka={ [10]=0.7 },			-- 3.5
}
----------------------------------------
-- vsync param
ex.vsyncparam = {
--	arms = "arm_type",			-- 腕
	tear = "face_tears",		-- 涙
	mayu = "face_eyebrow",		-- 眉
	eyes = "face_eye_open",		-- 目
	kuti = "face_mouth",		-- 口
}
----------------------------------------
--function ex.getMode() return not scr.img or flg.ui or flg.dlg or allkeystop or getSkip() end
----------------------------------------
-- fg
----------------------------------------
-- fg
function image_fg(p)
	local mode = tn(p.mode or 3)
	local sync = tn(p.sync or 0)
	local ch   = p.ch

	----------------------------------------
	-- mode保存
	if not scr.img.mwf then scr.img.mwf = {} end
	if ch then scr.img.mwf[ch] = mode end

	----------------------------------------
	-- 表示時time追加
	local s  = scr.img.fg or {}
	local v  = s[ch]
	if not p.time and (not v or not v.p or v.p.size ~= p.size) then
		p.time = (p.mx or p.my) and init.fg_fade2 or init.fg_fade
	end

	----------------------------------------
	-- face
	local ch = p.ch
	if mode == 1 or mode == 3 then
		if ch then
			if not scr.face then scr.face = {} end
			scr.face[ch] = p
		end

		-- mode1は立ち絵を消す
		if mode == 1 and s[ch] then
			if sync == 1 then
				pushTag{ fgdel, p }
				popTag()
			else
				image_store('fgdel', p)
			end
		end
	elseif ch and scr.face then
		faceparamdel(ch)
	end

	----------------------------------------
	-- 立ち絵表示
	if mode >= 2 then
		-- すぐに表示する
		if sync == 1 then
			pushTag{ fg, p }
			popTag()

		-- cacheしておく
		else
			image_store('fg', p)
		end

	----------------------------------------
	-- 消去
	elseif mode == -1 then
		faceparamdel(ch)
		setBlogFace(p)			-- blog face消去(先に処理)
		if sync == 1 then
			pushTag{ fgdel, p }
			popTag()
		else
			image_store('fgdel', p)
		end

	----------------------------------------
	-- 全消去
	elseif mode == -2 then
		faceparamdel()
		setBlogFace{ mode=-2 }	-- blog face消去(先に処理)
		if sync == 1 then
			pushTag{ fgdelall, p }
			popTag()
		else
			image_store('fgdelall', p)
		end
	end
end
----------------------------------------
-- delay fg
function delay_fg(p)
	local mode = tn(p.mode or 3)
	if mode > 1 then fg(p)
	elseif mode ==  1 then	-- mode=1で立ち絵消去するとクイックジャンプで復帰してしまうのでダミー措置(いずれ修正を)
	elseif mode == -1 then fgdel(p)		setBlogFace(p)
	elseif mode == -2 then fgdelall(p)	setBlogFace{ mode=-2 }
	else error_message(mode..'は不明な立ち絵指定です') end
end
----------------------------------------
-- fg / exskip
function exskip_fg(p)
	local ch = p.ch
	local md = tn(p.mode)
	if ch and (md == 1 or md == 3) then
		if not scr.face then scr.face = {} end
		scr.face[ch] = p
	end
end
----------------------------------------
-- fg
function fg(p, flag)
	local id  = scr.home and home and home.fgid or getImageID('fg', p)
	local idx = addImageID(id, 'base')

	----------------------------------------
	-- fgframe補正
	local ch = p.ch
	local xx = 0
	local yy = 0
	local z  = scr.img.fgf[ch]
	if z then
		xx  = z.fx - game.centerx
		yy  = z.fy
		id  = z.idx..'.fg'
		idx = addImageID(id, 'base')
		scr.img.fgf[ch].fgid = tn(p.id)
	end

	----------------------------------------
	-- face再保存
	local mode = tn(p.mode)
	if ch then
		if not scr.img.mwf then scr.img.mwf = {} end
		scr.img.mwf[ch] = mode
		if mode == 3 then
			if not scr.face then scr.face = {} end
			scr.face[ch] = p
		end
	end

	----------------------------------------
	-- レイヤー削除
	local d  = scr.img.fg[ch]
	local up = nil
	local em = nil
	local re = p.emreset
	local dr = d and d.p and p.file ~= d.p.file
	if d and (p.resize or d.id ~= id or dr) or re == 2 then
		-- 同一キャラのサイズ変更
		lydel2(d.id)
		up = true
	else
		-- 同レイヤーに別キャラがいた場合の検出
		for nm, v in pairs(scr.img.fg) do
			if ch ~= nm and id == v.id then
				lydel2(v.id)
				break
			end
		end
	end

	----------------------------------------
	-- file読み込み
	local ch = p.ch
	if not d or up then
		em = ex.lyc(idx..".0", p)

		-- 立ち位置補正
		local ax = mulpos(p.ax) or game.ax
		local ay = mulpos(p.ay) or game.ay
		local dr = p.dir
		local rx = (dr == "rxy" or dr == "rx") and 1		-- 左右反転
		local ry = (dr == "rxy" or dr == "ry") and 1		-- 上下反転
		e:tag{"lyprop", id=(idx), left=(xx), top=(yy)}
		e:tag{"lyprop", id=(addImageID(id, 'move')), anchorx=(ax), anchory=(ay), reversex=(rx), reversey=(ry)}
		e:tag{"lyprop", id=(addImageID(id, 'act' )), anchorx=(ax), anchory=(ay)}
		e:tag{"lyprop", id=(addImageID(id, 'act2')), anchorx=(ax), anchory=(ay)}
	end
	if not em then em = ex.emload(ch) end	-- em読み直し
	if not em then error_message("不明な立ち絵指定です") return end

	----------------------------------------
	-- 角度パラメータ初期化
	if re then
--		em:playTimeline("初期化", 1)				-- timeline 1:並列処理
		ex.reset(em, p)
		if d then
--			if d.p.arms then ex.stop(em, d.p.arms) d.p.arms = nil end	-- 腕
			if d.edir then	 ex.stop(em, d.edir)   d.edir = nil end		-- 向き
			d.p.face = nil
		end
	end

	----------------------------------------
	-- 腕
	local pr = nil
	local arms = p.arms
	if not up and d and arms == d.p.arms then
		pr = true
	elseif arms then
--		ex.stop(em, d and d.p.arms)		-- 再生中なら停止
--		ex.arms(em, arms)				-- 腕動作
		em:setVariable("arm_type", arms, ex.armfade, 0)
		pr = true

		----------------------------------------
		-- pass
--		local pass = p.arps or p.pass
--		if pass then ex.pass(em, pass) end
	end
--[[
	----------------------------------------
	-- 向き
	local edir = p.emdir
	local es   = d and d.edir or "正面向き"
	if edir and edir ~= es then
		if es and edir ~= es then
			ex.stop(em, es)				-- 再生中なら停止
		end
		em:playTimeline(edir, 1)		-- timeline 1:並列処理
		pr = true
	end
]]
	----------------------------------------
	-- 表情
	local face = p.face
--	local pose = ex.getarm(p)
	local fa   = ex.getFacename(face, pose)
	local fafl = face:sub(1, 2) == "em"
--	if not up and d and face == d.p.face then
		-- モーションありかつ福笑いの処理
--		if not fafl and (p.face_eye_open or p.face_eyebrow or p.face_mouth) then
--			em:pass()
--			em:setVariable("face_talk", 0, 0, 0)	-- lipsyncリセット
--			ex.face(em, fa)							-- 表情
--		end
--		pr = true

	-- 変化があった
--	elseif face then
	if face then
		-- モーションなしは傾きリセット
		if fafl then
			local fr = 20
			em:setVariable("head_LR", 0, fr, 0)
			em:setVariable("head_UD", 0, fr, 0)
			em:setVariable("head_slant", 0, fr, 0)
			em:setVariable("body_LR", 0, fr, 0)
			em:setVariable("body_UD", 0, fr, 0)
			em:setVariable("body_slant", 0, fr, 0)
		end
		em:pass()
		em:setVariable("face_talk", 0, 0, 0)	-- lipsyncリセット
		ex.face(em, fa)							-- 表情
		pr = true

		----------------------------------------
		-- pass
		local pass = p.pass
		if pass then ex.pass(em, pass) end
	end

	----------------------------------------
	-- 基本動作 / 待機
	local alw = p.always or init.emote_autoexec
	if alw then
		local as = d and d.always or init.emote_autoexec
		if alw == "待機停止" then
			ex.stop(em, as)						-- 再生中なら停止
		elseif d and alw ~= as then
			local tm = getSkip(true) and 0 or p.time or p.fade or "fg_fade"
			if init[tm] then tm = init[tm] end
			if tm > 0 then tm = math.floor(tm / ex.frametime) end
			em:fadeOutTimeline(as, tm, 0)		-- 元を停止
			em:fadeInTimeline(alw, tm, 0)		-- 差分timeline
		else
			em:fadeInTimeline(alw, 0, 0)		-- 差分timeline
		end
	end

	----------------------------------------
	-- その他
	if pr then
		----------------------------------------
		-- E-moteコマンド確認
		ex.param(em, p)

		----------------------------------------
		-- 時間帯フィルタ
		shader_colortone(id, p)		-- シェーダー反映
--		if p.lymode then	 ex.setColortone(em, idx, { mode=(p.lymode), color=(p.color) })
--		elseif scr.tone then ex.setColortone(em, idx)
--		else				 ex.setTimezone(em, idx, ch) end		
	end

	----------------------------------------
	-- skip / effect off
	if getSkip(true) then em:step() end

	----------------------------------------
	-- 表示tween
	image_postween(id, p, "fg_fade", flag)

	----------------------------------------
	-- 保存
	if not flag then
		local fa = face:sub(1, 2) ~= "em"
		local eb = fa and p.face_eyebrow	-- 眉
		local eo = fa and p.face_eye_open	-- 目
		local mo = fa and p.face_mouth		-- 口
		local tr = p.face_tears or p.tear					-- 涙
		local ar = p.arm_type or pose == "ポーズB_" and 1	-- 腕
		scr.img.fg[ch] = { id=(id), p=(tcopy(p)), always=(alw), ase=(as1), edir=(edir), pose=(pose),
			arms=(ar), tear=(tr), mayu=(eb), eyes=(eo), kuti=(mo)
		}
		ex.emsave(ch, em)			-- em保存
		ex.lipsave("fg", em, p)		-- lipsync保存
		setBlogFace(p)				-- blogface格納
	end

	-- 負荷調整
	ex.meshdivision(em)
	ex.progress(em)					-- Progress()実行

	-- trans
	if tn(p.sync) == 1 then trans(p) end
end
----------------------------------------
-- 立ち絵消去
function fgdel(p)
	local sync = tn(p.sync or 0)
	local ch = p.ch
	if scr.img.fg and scr.img.fg[ch] then
		local id = scr.img.fg[ch].id

		-- disp動作
		image_disp(id, p)

		-- delete
		lydel2(id)
		scr.img.fg[ch] = nil
		scr.img.mwf[ch] = nil
		faceparamdel(ch)
		ex.emsave(ch, nil)			-- em削除

		-- trans
		if sync == 1 then trans(p) end
	end
end
----------------------------------------
-- 全消去
function fgdelall(p, flag)
	local sync = tn(p and p.sync or 0)
	if scr.img.fg then
		for i, v in pairs(scr.img.fg) do
			local id = v.id 
			if id then
				image_disp(id, p)	-- disp動作
				lydel2(id)			-- 消去
			end
		end
		scr.img.fg = {}
		scr.img.mwf = {}
		flg.emsave = nil			-- em削除

		-- blogface削除
		if flag then setBlogFace{ mode=-2 } end

		-- trans
		if sync == 1 then trans(p) end
	end
	scr.face = nil
end
----------------------------------------
-- mw faceパラメータ
function faceparamdel(ch)
	if scr.face then
		if ch then
			scr.face[ch] = nil
--			if ch == "mob" then
--				scr.face["MOB男"] = nil
--				scr.face["MOB女"] = nil
--				scr.face["MOB他"] = nil
--			end
		else
			scr.face = nil
		end
	end
	emote.lipdel(ch)
end
----------------------------------------
-- fgframe / 画面分割
----------------------------------------
-- fgf
function image_fgf(p)
	local sync = tn(p.sync or 0)
	local mode = tn(p.mode or 1)

	-- 立ち絵表示
	if mode >= 1 then
		-- すぐに表示する
		if sync == 1 then
			local time = p.time or init.fg_fade
			pushTag{ fgf, p }
			pushTag{ trans, { fade=time } }
			popTag()

		else
			image_store('fgf', p)
		end

	----------------------------------------
	-- 消去
	elseif mode == -1 then
		if sync == 1 then
			local time = p.time or init.fg_fade
			pushTag{ fgfdel, p }
			pushTag{ trans, { fade=time } }
			popTag()
		else
			image_store('fgfdel', p)
		end
	end
end
----------------------------------------
-- delay fgf
function delay_fgf(p)
	local mode = tn(p.mode or 1)
	if mode >= 1 then fgf(p)
	elseif mode == -1 then fgfdel(p) end
end
----------------------------------------
-- fgf id
function get_fgfid(p)
	local nm = p.frame or "frame_rt"
	local t = csv.fgframe[nm]
	local r = nm
	if t then
		local no  = p.id or t.id or 1
		local md  = t.mode or "normal"
		if md ~= "normal" then r = r..no end
	else
		sysmessage("エラー", nm, "は不明な frame 指定です")
	end
	return nm, r
end
----------------------------------------
-- fgf
function fgf(p)
	local fr, nm = get_fgfid(p)
	local ft = csv.fgframe or {}
	local t  = ft[fr]
	if t then
		local lv  = p.lv or t.lv or 10
		local no  = p.id or t.id or 1
		local md  = t.mode or "normal"					-- bg mode / normal,float,anime
		local id  = getImageID('fgf', { lv=lv, id=no })	-- base id
		local idp = addImageID(id, 'pos')				-- pos id
		local idm = addImageID(id, 'move')				-- move id
		local idx = addImageID(id, 'base')				-- base id

		----------------------------------------
		-- 背景
		local idz = idx..'.0'
		local file = p.bg   or 'frame_bg'
		local path = p.bgpx or p.bg and ":bg/" or ":cg/"
		if file == "frame_bg" then path = ":fgf/" end

		local zm = p.bz
		readImage(idz, { path=(path), file=(file:gsub(":bg/", "")), style=(p.style), dir=(p.dir) })
		e:tag{"lyprop", id=(idz), left=(mulpos(p.bx)), top=(mulpos(p.by))}
		e:tag{"lyprop", id=(idz), anchorx=(game.centerx), anchory=(game.centery), xscale=(zm), yscale=(zm)}

		----------------------------------------
		-- cg
		lydel2(idx..".bc")		-- cg奥
		lydel2(idx..".fr")		-- cg手前
		if p.cg then
			local ix = p.cgback == 1 and idx..".bc" or idx..".fr"
			local cx, pt = image_pathcut(p.cg)			-- path分離
			local px = pt or ":cg/"
			readImage(ix, { path=(px), file=(cx), style=(p.style), dir=(p.dir), movie=(p.movie), loop=(p.loop) })

			-- pos
			local x = mulpos((t.fx or 0) + (p.cgx or 0) + (p.cgbx or 0))
			local y = mulpos((t.fy or 0) + (p.cgy or 0) + (p.cgby or 0))
			e:tag{"lyprop", id=(ix), left=(x), top=(y)}
		end

		----------------------------------------
		-- mask
		e:tag{"lyprop", id=(idx), intermediate_render="2", intermediate_render_mask=(':mask/'..p.frame)}

		----------------------------------------
		-- 枠 / maskしない
		local iw = addImageID(id, 'act2')..".n"
		local px = ':fgf/'..fr
		if md == "ogv" then
			local px = ":ani/"..fr..".ogv"
			local mx = t.loop or 1
			e:tag{"video" , id=(iw), file=(px), loop=(mx)}

		elseif md == "anime" then
			local mx = t.loop or 2
			local tm = t.time or 100
			local w  = t.fx * 2
			local h  = t.fy * 2
			e:tag{"anime",	 id=(iw), mode="init", file=(px), clip=("0,0,"..w..","..h)}
			for i=1, mx do
				e:tag{"anime", id=(iw), mode="add",  file=(px), clip=("0,"..(i*h)..","..w..","..h), time=(i * tm)}
			end
			e:tag{"anime",	 id=(iw), mode="end",  time=(mx * tm)}

		elseif md == "rotate" then
			local tbl = {
				{  360,  -1, nil, "none",  10000 },		-- 
				{ -360,  -1, nil, "none",  10000 },		-- 
				{  360, nil,  -1, "inout", 10000 },		-- 
				{ -360, nil,  -1, "inout", 10000 },		-- 
				{  180, nil,  -1, "inout", 5000  },		-- 
				{ -180, nil,  -1, "inout", 5000  },		-- 
				{   90, nil,  -1, "inout", 5000  },		-- 
				{  -90, nil,  -1, "inout", 5000  },		-- 
			}
			local mx = p.dir  or t.loop or 1
			local v  = tbl[mx] or {}
			local r  = p.r    or v[1] or 360
			local lp = p.loop or v[2] or nil
			local yo = p.yoyo or v[3] or nil
			local es = p.ease or v[4] or "none"
			local tm = p.speed or t.time or v[5] or 5000
			local ax = mulpos(t.fx)
			local ay = mulpos(t.fy)
			lyc2{ id=(iw), file=(px), anchorx=(ax), anchory=(ay) }
			tween{ id=(iw), rotate=("0,"..r), time=(tm), yoyo=(yo), loop=(lp), ease=(es) }

		else
			lyc2{ id=(iw), file=(px) }
		end

		----------------------------------------
		-- pos / 全体
		if md ~= "normal" then
			local x = mulpos((p.basex or 0) + (t.x or 0) - t.fx)	-- xは中央合わせ
			local y = mulpos((p.basey or 0) + (t.y or 0))			-- yは上から
			e:tag{"lyprop", id=(id), left=(x), top=(y)}
		end
		local ax = mulpos(t.fx)
		local ay = mulpos(t.fy)
		e:tag{"lyprop", id=(idm), anchorx=(ax), anchory=(ay)}
		e:tag{"lyprop", id=(addImageID(id, 'act')), anchorx=(ax), anchory=(ay)}

		----------------------------------------
		-- tween
		local v = ft[p.disp or 'none']
		if v then
			local time = getTweenTime(p.time, init.fg_fade)
			if v.x  then tween{id=(idm), x=(mulpos(v.x)..',0'), time=(time) } end
			if v.y  then tween{id=(idm), y=(mulpos(v.y)..',0'), time=(time) } end
			if v.r  then tween{id=(idm), rotate=((v.r)..',0'), time=(time) } end
			if v.z1 then tween{id=(idm), xscale='0,100' , time=(time) } end
			if v.z2 then
				time = math.floor(time / 2)
				e:tag{"tweenset"}
				tween{id=(idm), yscale='0,5'	 , time=(time) }
				tween{id=(idm), yscale='5,100', time=(time) }
				e:tag{"/tweenset"}
				tween{id=(idm), xscale='0,100', time=(time) }
			end
		end

		----------------------------------------
		-- 保存
		if not scr.img.fgf then scr.img.fgf = {} end
		local ch = p.ch
		local zn = p.notone == 1 and "0xffffff" or p.zone
		scr.img.fgf[nm] = { id=(id), ch=(ch), p=(p) }
		if ch then scr.img.fgf[ch] = { id=(id), idx=(idx), fx=(mulpos(t.fx)), fy=(mulpos(t.fy)), zone=(zn), bg=(file) } end

		-- trans
		if sync == 1 then trans(p) end
	end
end
----------------------------------------
-- fgfdel
function fgfdel(p)
	if not scr.img.fgf then scr.img.fgf = {} end
	local fr, nm = get_fgfid(p)
	local ft = csv.fgframe or {}
	local s  = scr.img.fgf or {}
	local t  = ft[fr]
	if t and s[nm] then
		local id  = s[nm].id							-- id
		local idm = addImageID(id, 'move')				-- move id
		local time = getTweenTime(p.time, init.fg_fade)

		-- tween
		local v = ft[p.disp or 'none']
		if v then
--			e:tag{"lyprop", id=(idm), anchorx=(mulpos(t.fx)), anchory=(mulpos(t.fy))}
			if v.x  then tween{id=(idm), x=('0,'..mulpos(v.x)), time=(time) } end
			if v.y  then tween{id=(idm), y=('0,'..mulpos(v.y)), time=(time) } end
			if v.r  then tween{id=(idm), rotate=('0,'..(v.r)), time=(time) } end
			if v.z1 then tween{id=(idm), xscale='100,0' , time=(time) } end
			if v.z2 then
				local t2 = math.floor(time / 2)
				e:tag{"tweenset"}
				tween{id=(idm), yscale='100,5',	time=(t2) }
				tween{id=(idm), yscale='5,0',	time=(t2) }
				e:tag{"/tweenset"}
				tween{id=(idm), xscale='100,0', time=(t2), delay=(t2) }
			end
		end

		-- 保存
		local ch = s[nm].ch
		if ch then
			local z = scr.img or {}
			fgdel{ ch=(ch) }		-- 立ち絵を消さないと落ちる
			if z.mwf then scr.img.mwf[ch] = nil end
			if z.fg  then scr.img.fg[ch]  = nil end
			scr.img.fgf[ch] = nil
		end
		scr.img.fgf[nm] = nil

		lydel2(id)
	else
		sysmessage("エラー", fr, "は設置されていない frame です")
	end
end
----------------------------------------
-- frame action
function tag_fgfact(p)
	local sync = tn(p.sync or 0)
	if sync == 1 then cgact(p)			-- すぐに実行する
	else image_store('fgfact', p) end	-- スタック
end
----------------------------------------
function fgfact(p)
	if not scr.img.fgf then scr.img.fgf = {} end
	local fr, nm = get_fgfid(p)
	local s  = scr.img.fgf or {}
	if s[nm] then
		local ft = csv.fgframe or {}
		local t  = ft[fr]
		local v  = tcopy(p)
		v.lv = p.lv or t.lv or 10
		v.no = p.id or t.id or 1
		image_act(s[nm].id, v)
	else
		sysmessage("エラー", fr, "は設置されていない frame です")
	end
end
----------------------------------------
-- 立ち絵アクション
----------------------------------------
-- 
function tag_fgact(p)
	local sn = tn(p.sync or 0)
	local ic = p.act

	-- すぐに実行する
	if sn == 1 then
		fgact(p)

	-- icon
	elseif ic == "icon" then
		if scr.img.buff then
			estag("init")
			estag{"image_loop"}		-- 先に画像を表示してしまう
			estag{"fgact", p}
			estag()
		else
			fgact(p)
		end

	-- スタック
	else
		image_store('fgact', p)
	end
end
----------------------------------------
function fgact(p)
	if not scr.img.fg then scr.img.fg = {} end
	local ch = p.ch or ""
	local v  = scr.img.fg[ch]
	if v then image_act(v.id, p) end
end
----------------------------------------
-- face
----------------------------------------
function mwf(p)
	-- 消去
	if p.del then
--		if flg.emface then scr.faceflag = "del" end
		if flg.emface then mw_facedel(true) flip() end

	-- 表示
	else
		local ch = p.ch
		if ch then
			if not scr.face then scr.face = {} end
			scr.face[ch] = p
			scr.faceflag = ch
		end
	end
end
----------------------------------------
-- 音声のあるキャラのみmwに出す
function faceview(p)
	local ch = scr.faceflag or getNameChar(p, "fg")
	local v  = scr.face and scr.face[ch] or {}
	local nm = scr.faceflag or v.mw and ch or p.vo and p.vo[1] and p.vo[1].ch
	if nm == "del" then
		mw_facedel(true)

	-- floatでは表示しない
	elseif nm and not getFloatFlag() then 
		-- 表示
		if v then
			mw_face(v)
			scr.mwface = nm
		end

	-- 枠
--	elseif scr.mwframe then
--		e:tag{"lyprop", id=(game.mwid..".mw.bb"), alpha="0"}
	end
	scr.faceflag = nil
end
----------------------------------------
-- MW face
function mw_face(p)
	local id = getMWID("face")
	scr.mwfropen = nil

	----------------------------------------
	-- mwface 0:off 1:on 2:立ち絵があればoff
	local mw = true
	local ch = p.ch
	local c  = conf.mwface or 1
	if c == 0 then
		mw = nil
	else
		-- 立ち絵が出てるときにmwfaceを出さない判定
		local s  = scr.img.mwf or {}
		if ch and s[ch] == 3 and c == 2 then mw = nil end
	end

	-- すでに表示されている場合は一旦消去
	if ch and mw and flg.emface then
		flg.emface = nil
	end

	----------------------------------------
	-- 表示
	local mode = p.mode
	if mw and (mode == 1 or mode == 3) then
		setMWFaceFile(p, "face", id)
		scr.mwfropen = true

		-- 枠
		local w = scr.mwno or 1
		if w == 1 and scr.mwframe then
			local i1 = game.mwid..".mw.bb"
			e:tag{"lyprop", id=(i1), alpha="255"}
			if flg.exmsgon then
				local tm = init.mw_hidetime
				local v  = getBtnInfo("face01")
				e:tag{"lytweendel", id=(i1)}
				tween{ id=(i1), x=(-v.w..",0"), time=(tm) }
				flg.exmsgon = nil
			end
		end
	end

	-- blogface格納
	setBlogFace(p)
end
----------------------------------------
-- MW face 消去
function mw_facedel(flag)
	local p  = flg.emface or {}
	local ch = p.ch
	if not flag and ch then
		local bl = scr.ip.block			-- 次のblockを見て消すか決める
		local nx = ast[bl].linenext
		local v  = ast[nx]
		local nm = v and v.text.name
		if not nm then
			flag = true					-- ト書き
		elseif v then
			if ch ~= nm[1] then
				flag = true				-- 別のキャラ
			end
		end
	end

	-- 消去
	if flag and scr.mwface then
		local id = getMWID("face")
		if id then lydel2(id) end
		flg.emface = nil
		scr.mwface = nil
		scr.mwfropen = nil
		emote.lipdel("delete")			-- lipsync停止

		-- 枠
		if scr.mwframe and checkBtnExist("face01") then
			e:tag{"lyprop", id=(game.mwid..".mw.bb"), alpha="0"}
		end
	end
end
----------------------------------------
-- MW face描画
function setMWFaceFile(p, nm, id)
	if not p or not p.file then
		return

	-- blog / favo
	elseif nm == "blogface" or nm == "favoface" then
		ex.blogface(p, nm, id)
		return

	-- emoteはfaceのみ実行
	elseif nm ~= "face" then
		return
	end

	local ch = p.ch
	local v  = flg.emface or {}
	local re = p.emreset

	----------------------------------------
	-- body
	local ix = id..".0"
	local em = v.em
	if not em or ch ~= v.ch then
		lydel2(id)
		em = ex.lyc(ix, p, "fa")
	end
	if re then
		ex.reset(em, p)				-- 角度パラメータ初期化
--		if v.arms then ex.stop(em, v.arms) v.arms = nil end		-- 腕
		if v.edir then ex.stop(em, v.edir) v.edir = nil end		-- 向き
	end

	----------------------------------------
	-- 腕
	local pr = nil
	local arms = p.arms
	if not up and d and arms == d.p.arms then
		pr = true
	elseif arms then
--		ex.stop(em, d and d.p.arms)		-- 再生中なら停止
--		ex.arms(em, arms)				-- 腕動作
		em:setVariable("arm_type", arms, 0, 0)
		pr = true

		----------------------------------------
		-- pass
--		local pass = p.arps or p.pass
--		if pass then ex.pass(em, pass) end
	end
--[[
	local arms = p.arms
	if arms then
		ex.stop(em, v.arms)			-- 再生中なら停止
		ex.arms(em, arms)
	end

	----------------------------------------
	-- 向き
	local edir = p.emdir
	local es   = v.edir
	if edir then
		if es and edir ~= es then ex.stop(em, es) end	-- 再生中なら停止
		em:playTimeline(edir, 1)
	end
]]
	----------------------------------------
	-- face
	local fa = p.face
	if fa:sub(1, 2) == "em" then
		-- 傾きリセット
		local fr = 20
		em:setVariable("head_LR", 0, fr, 0)
		em:setVariable("head_UD", 0, fr, 0)
		em:setVariable("head_slant", 0, fr, 0)
		em:setVariable("body_LR", 0, fr, 0)
		em:setVariable("body_UD", 0, fr, 0)
		em:setVariable("body_slant", 0, fr, 0)
		fa = fa:sub(3)
	end
	em:pass()
	em:setVariable("face_talk", 0, 0, 0)	-- lipsyncリセット
	ex.face(em, fa)							-- face
	ex.param(em, p)							-- E-moteコマンド確認

	-- 負荷調整
	ex.meshdivision(em, 1)
	ex.progress(em)							-- Progress()実行

	----------------------------------------
	-- effect off
	if em and conf.effect == 0 then em:step() end

	----------------------------------------
	-- 常に合成
	local mw = csv.mw.face
	local c  = mw.clip
	local z  = mw.zoom
	local m = get_uipath().."mw/maskface.png"
	local f = flg.mwfacemask
	if not f then
		if isFile(m) then f = true else f = "none" end
		flg.mwfacemask = f
	end
	if f == "none" then
		e:tag{"lyprop", id=(id), left=(mw.x), top=(mw.y)}
	else
		e:tag{"lyprop", id=(id), left=(mw.x), top=(mw.y), intermediate_render="2", intermediate_render_mask=(m)}
	end
	if z then e:tag{"lyprop", id=(idb), anchorx="0", anchory="0", xscale=(z), yscale=(z)} end

	-- 色調フィルタ
--	if not flg.ui and init.game_mwtone == "on" then ex.setColortone(em, id) end
	if init.game_mwtone == "on" then
		local t = scr.tone
		if t then
			shader_colortone(id, t.p)
		else
			shader_colortone(id, p)
		end
	end

	-- 保存
	local fr = fa:sub(1, 2) ~= "em"
	local eb = fr and p.face_eyebrow	-- 眉
	local eo = fr and p.face_eye_open	-- 目
	local mo = fr and p.face_mouth		-- 口
	local tr = p.face_tears or p.tear	-- 涙
	ex.lipsave("fa", em, p)
	flg.emface = { ch=(ch), em=(em), edir=(edir), arms=(arms),
		arms=(ar), tear=(tr), mayu=(eb), eyes=(eo), kuti=(mo)
	}
end
----------------------------------------
-- blogface
function ex.blogface(p, nm, id)
	local bf = csv.mw[nm]
	local px = ":fg/_blog/"..p.file.."/"..p.face
	lyc2{ id=(id), file=(px), x=(bf.x), y=(bf.y), zoom=(bf.zoom)}
end
----------------------------------------
-- blogface格納
function setBlogFace(p)
	local md = p.mode or 3
	local ch = p.ch
	if md > -2 and  not ch or init.game_backlogface ~= "on" then return end
	if not scr.blogface then scr.blogface = {} end

	-- 全消去
	if md == -2 then
		scr.blogface = nil

	-- 消去
	elseif md == -1 then
		scr.blogface[ch] = nil

	-- 表示
	else
		scr.blogface[ch] = tcopy(p)
	end
end
----------------------------------------
-- ボイスを取得して立ち絵の表情を返す
function getBlogFace()
	local r = nil
	local v = scr.blogface
	if not v or init.game_backlogface ~= "on" then return r end

	-- text blockから名前を取り出す
	local b  = scr.ip.block
	local t  = ast[b].text
	local nm = getNameChar(t, "fg")		-- 話者名
	if nm and v[nm] then
		local ch = v[nm].ch
		local fl = v[nm].file or "none"
		local fa = v[nm].face or "none"
		r = { ch=(ch), file=(fl), face=(fa) }
	end
	return r
end
----------------------------------------
-- E-mote
----------------------------------------
function ex.lyc(id, p, size)
	local ch = p.emch or p.ch
	local po = p.pose or "a"
	local sz = size or p.size or "no"
	local z  = csv.emote.base[ch]
	local nm = z[1]
	local vv = csv.emote[nm] or {}
	local v  = vv[po][sz] or vv.a[sz]
--	local y  = mulpos(80)		-- 上側はみ出し補正
	local gs = game.scale		-- OS倍率
	local sc = v.zoom			-- zoom補正
	local sx = mulpos(v.x)		-- x補正
	local sy = mulpos(v.y)		-- y補正
	local sw = mulpos(v.w)		-- w補正
	local sh = mulpos(v.h)		-- h補正
	local x  = math.floor((sw - game.width ) / 2) sx = sx + x
	local y  = math.floor((sh - game.height) / 2) sy = sy + y

	----------------------------------------
	-- load時のエラー回避
	lyc2{ id=(id..".-1"), width="16", height="4", color="0x00000000", visible="0" }

	----------------------------------------
	-- body
	local path = p.path
	local file = p.file
	local ext  = game.fgext
	local px   = path..file..ext
	local em   = e:createEmoteLayer{ id=(id..".0"), files={ px }, width=(sw), height=(sh), progress=(ex.getProgress(true)) }

	-- zoom / pos処理 (50%以下は縮小を２回に分ける)
	local zm = 100
	if sc < 0.5 then
		zm = math.ceil(percent(sc, 0.5))
		sc = 0.5
	end

	if gs ~= 1 and game.trueos == "windows" then sc = sc * gs end -- 倍率修正

	em:setScale(sc, 0, 0)							-- emote scale
	em:setCoord(sx, sy, 0, 0)						-- emote pos
	e:tag{"lyprop", id=(id), left=(-x), top=(-y)}	-- 頭切れ回避
	e:tag{"lyprop", id=(id), anchorx=(game.ax), anchory=(game.ay), xscale=(zm), yscale=(zm)}

	----------------------------------------
	-- 揺れ上書き
	local ow = init.emote_shakeoverwt
	if ow == "on" then
		if z[2] and z[2] ~= 1 then em:setHairScale(z[2]) end		-- 髪揺れ
		if z[3] and z[3] ~= 1 then em:setBustScale(z[3]) end		-- 乳揺れ
	end

	----------------------------------------
	-- 固定動作
--[[
	local md = init.emote_autoexec
	local mw = size == "fa" and init.emote_autoexec_mw ~= "on"
--	if md and not mw and conf.effect == 1 then
	if md and conf.effect == 1 then
		local hd = ex.getarm(p)
--		em:fadeInTimeline(hd..md, 0, 0)		-- 差分timeline
	end
]]
	return em
end
----------------------------------------
-- arms head
function ex.getarm(p)
	return (p.arm_type == 1 or p.arms == 1) and "ポーズB_" or "ポーズA_"
end
----------------------------------------
-- arms
function ex.arms(em, arms)
	local ar = arms
	if em then
		em:playTimeline(ar, 1)		-- timeline 1:並列処理
--		em:step()
	end
end
----------------------------------------
-- face
function ex.face(em, face)
--	local v  = init.emote_facestat or {}
	local fa = face
--		if v[2] == "前" then fa = v[1]..fa
--	elseif v[2] == "後" then fa = fa..v[1] end
	if em then
		em:playTimeline(fa, 1)		-- timeline 1:並列処理
	end
end
----------------------------------------
-- emote パラメータ
function ex.param(em, p)
	local pr = {
		face_eye_lr=1, face_eye_ud=1, face_hitomi_sp=1, face_eye_open=1, face_eye_sp=1, face_eyebrow=1, face_eyebrow_sp=1,
		face_mouth=1, face_mouth_sp=1, face_eye_hi=1, face_tears=1, face_cheek=1, face_talk=1,
		head_lr=1, head_ud=1, head_slant=1,
		body_lr=1, body_ud=1, body_slant=1,
		act_sp=1, act_sp2=1, act_sp3=1,
		move_lr=1, move_ud=1, arm_type=1,
		fade_a=1, fade_b=1, fade_c=1, fade_d=1, fade_e=1, fade_q=1, fade_r=1, fade_s=1, fade_t=1, fade_u=1, fade_v=1, fade_w=1, fade_x=1, fade_y=1, fade_z=1,
		vr_ud=1, vr_lr=1,
		bust_lr=1, bust_ud=1, bust_lr_spare=1, bust_ud_spare=1,
		hair_lr_front=1, hair_lr_m_front=1, hair_ud_front=1, hair_lr_sidel=1, hair_lr_m_sidel=1, hair_ud_sidel=1,
		hair_lr_sider=1, hair_lr_m_sider=1, hair_ud_sider=1, hair_lr=1, hair_lr_m=1, hair_ud=1,
		quake_lr=1, quake_lr_m=1, quake_ud=1, quake_lr_spare=1, quake_lr_m_spare=1, quake_ud_spare=1,
	}

	-- パラメータ確認
	local es = p.emease or 0	-- tween用と分離
	local fr = p.frame or p.time or init.fg_fade
	if fr > 0 then fr = math.floor(fr / ex.frametime) end
	for k, v in pairs(p) do
		if pr[k] then
			if k:find("_lr_m") then k = k:gsub("_lr_m", "_LR_M") end
			if k:find("_ud_m") then k = k:gsub("_ud_m", "_UD_M") end
			if k:find("_lr") then k = k:gsub("_lr", "_LR") end
			if k:find("_ud") then k = k:gsub("_ud", "_UD") end
			em:setVariable(k, v, fr, es)
		end
	end
end
----------------------------------------
-- 傾きreset
function ex.reset(em, p)
	local tbl = {
		"head_LR", "head_UD", "head_slant", 
		"body_LR", "body_UD", "body_slant",
		"act_sp", "act_sp2", "act_sp3", "move_LR", "move_UD"
	}
	-- パラメータ確認
	local es = p.emease or 0	-- tween用と分離
	local fr = p.frame or p.time or init.fg_fade
	if fr > 0 then fr = math.floor(fr / ex.frametime) end
	for i, v in ipairs(tbl) do
		local s = string.lower(v)
		if not p[s] then em:setVariable(v, 0, fr, es) end
	end
end
----------------------------------------
-- emote action
function emote.action(p)
	local ch = p.ch
	local nm = p.act
	local em = ex.emload(ch)
	if em then
		local v = init.emote_actstat or {}
			if v[2] == "前" then nm = v[1]..nm
		elseif v[2] == "後" then nm = nm..v[1] end
--		message("通知", "アクション", nm, "実行")
		em:playTimeline(nm, 1)		-- timeline 1:並列処理
	end
end
----------------------------------------
-- pass/step/skip
function ex.pass(em, no)
	local sw = {
		function() em:pass() end,
		function() em:step() end,
		function() em:skip() end,
	}
	if sw[no] then sw[no]() end
end
----------------------------------------
-- stop timeline
function ex.stop(em, nm)
	if em and nm then
		local st = em:isTimelinePlaying(nm)		-- 再生確認
		if st then em:stopTimeline(nm) end		-- 再生されていれば停止
	end
end
----------------------------------------
-- 色調反映
--[[
function ex.setColortone(em, id, p)
	local t = p or scr.tone
	if t then
		local tc = { add=1 , multi=1, sepia=1 }
		local tg = { gray=1, sepia=1 }
		local md = t.mode
		local cl = t.color
		local ix = game.sw and "1.0" or id
		local ir = game.sw and 2 or 1

		-- 反転
		if md == "nega" then
			e:tag{"lyprop", id=(ix), intermediate_render=(ir), negative="1", grayscale="0", colormultiply="0"}
			cl = nil

		-- sepia
		elseif md == "sepia" then
			e:tag{"lyprop", id=(ix), intermediate_render=(ir), negative="0", grayscale="1", colormultiply=(cl)}

		-- grayscale
		elseif tg[md] then
--			em:setGrayscale(1, 0, 0)
			e:tag{"lyprop", id=(ix), intermediate_render=(ir), negative="0", grayscale="1", colormultiply="0"}
		end

		-- 色味
		if cl and tc[md] then
			ex.setcolor(em, cl)
		end
	end
end
----------------------------------------
-- 時間帯フィルタ
function ex.setTimezone(em, idx, ch)
	-- fgfフィルタ
	local s = scr.img.fgf
	local f = s and s[ch] and s[ch].zone

	-- 描画
	local z = f or scr.zone
	local c = z and (init[z] or init["zone_"..z] or z)
	if c and c ~= "none" then
		ex.setcolor(em, c)
--		e:tag{"lyprop", id=(idx), intermediate_render="1", negative="0", grayscale="0", colormultiply=("0"..c)}
	end
end
----------------------------------------
-- 色味変換(除算固定)
function ex.setcolor(em, cl)
	if cl:sub(1, 1) == "x" then cl = "0"..cl end
	local no = cl
	if #no < 10 then
		local r  = math.floor(tn("0x"..cl:sub(3, 4)) / 2)
		local g  = math.floor(tn("0x"..cl:sub(5, 6)) / 2)
		local b  = math.floor(tn("0x"..cl:sub(7, 8)) / 2)
		no = tn("0x"..string.format("%02x%02x%02xff", r, g, b))
	end
	em:setColor(no, 0, 0)
end
]]
----------------------------------------
-- 負荷調整
function ex.meshdivision(em, def)
	local n = ex.meshtable[game.os]
	if n then
		local no = n.def
		local ct = def or 0
		for ch, v in pairs(scr.img.fg) do ct = ct + 1 end
		if n[ct] then no = n[ct] end
--		message("負荷", no, ct)
		em:setMeshDivisionRatio(no)
	end
end
----------------------------------------
-- 
----------------------------------------
-- 保存
function ex.emsave(ch, em)
	if not flg.emsave then flg.emsave = {} end
	flg.emsave[ch] = em
end
----------------------------------------
-- 読み出し
function ex.emload(ch)
	if not flg.emsave then flg.emsave = {} end
	return flg.emsave[ch]
end
----------------------------------------
-- bg reset
function emote.bgreset()
	flg.emoteaction	= nil
	flg.emotetime	= nil
	flg.emsave		= nil
	flg.emface		= nil
	flg.lipsync		= nil
	flg.lipsave		= nil
--	scr.img.fg = {}
end
----------------------------------------
-- trans / em更新
--[[
function emote.trans()
	local s = scr.img.fg or {}
	local p = flg.emsave
	if p and game.cs then
		for ch, v in pairs(p) do
			if s[ch] then
				local id = s[ch].idx
				flg.emsave[ch] = e:getEmoteLayer{ id=(id..".0"), next=true }
			end
		end
	end
end
]]
----------------------------------------
-- Lip Sync
----------------------------------------
-- Lip保存
function ex.lipsave(tg, em, p)
	if not flg.lipsave then flg.lipsave = {} end
	local ch = p.emch or p.ch
	local z  = csv.emote.base[ch]
	local nm = z[1]:sub(1, 3)
	flg.lipsave[nm] = p.nolip ~= 1 and { name=(tg), ch=(ch), em=(em) } or nil
end
----------------------------------------
-- Lip削除
function emote.lipdel(ch)
	local s = flg.lipsave

	-- 顔削除
	if ch == "delete" then
		if s then
			for nm, v in pairs(s) do
				if v.name == "fa" then
					flg.lipsave[nm] = nil
				end
			end
		end

	-- 全削除
	elseif not ch then
		flg.lipsave = nil

	-- キャラ指定削除
	elseif s then
		local z  = csv.emote.base[ch]
		local nm = z[1]:sub(1, 3)
		if s[nm] and s[nm].name ~= "fa" then
			flg.lipsave[nm] = nil
		end
	end
end
----------------------------------------
-- lipsync check
function ex.lipcheck()
	return init.emote_lipsync == "on"
end
----------------------------------------
-- read lip csv
function emote.readlipcsv(path, ch)
	local ez = #game.soundext
	local px = path:sub(1, -ez).."vol.csv"
	local r  = btn.name ~= "favo"
	if r and ex.lipcheck() and not getSkip(true) and isFile(px) then
		local r = parseCSV(px)
		if not flg.lipsync then flg.lipsync = {} end
		flg.lipsync[ch] = { count=0, time=(e:now()), p=(r[1]) }
	end
end
----------------------------------------
-- lipsync end
function emote.lipstop(p)
	local v = flg.lipsync
	local s = flg.lipsave
	if ex.lipcheck() and v and s and p then
		local ch = p.ch
		if v[ch] and s[ch] then 
			s[ch].em:setVariable("face_talk", 0, 0, 0)		-- 念の為口を閉じておく
			flg.lipsync[ch] = nil
		end
	end
end
----------------------------------------
-- lip vsync
function emote.vsync()
	-- 動作停止
	if scr.emotemotion then return end

	-- lip vsync
	local t = ex.lipsyncmax or {}
	local p = flg.lipsync
	local s = flg.lipsave
	if ex.lipcheck() and s and p then
		for nm, v in pairs(p) do
			local ct = p[nm] and p[nm].time and math.ceil((e:now() - p[nm].time) / ex.frametime) or -1
			local em = s[nm] and s[nm].em
			local no = tn(v.p[ct])

			-- しゃべる
			if no then
				if s[nm] then
					-- 口の開き方抑制
					local mt = em:getVariable("face_mouth")
					local cz = t[nm] and t[nm][mt]
					if cz then no = no * cz end
					em:setVariable("face_talk", no, 0, 0)
--					ex.progress(em)
				end

			-- lypsync終了
			else
				if s[nm] then
					em:setVariable("face_talk", 0, 0, 0)
--					ex.progress(em)
				end
				flg.lipsync[nm] = nil
			end
		end

		-- 残数確認
		local p = flg.lipsync
		if p then
			local c = 0
			for i, v in pairs(p) do c = c + 1 end	-- 再生数
			if c == 0 then flg.lipsync = nil end	-- 0なら停止しておく
		end
	end

	----------------------------------------
	-- 腕とか涙とか
	local func = function(v, em)
		for nm, pm in pairs(ex.vsyncparam) do
			if v[nm] then
				local ar = em:getVariable(pm)
				if ar ~= v[nm] then em:setVariable(pm, v[nm], 0, 0) end
			end
		end
	end

	-- 立ち絵
	local z = scr.img and scr.img.fg
	if z then
		for ch, v in pairs(z) do
			local em = ex.emload(ch)
			if em then func(v, em) end
		end
	end

	-- face
	local z = flg.emface
	if z and z.em then func(z, z.em) end

	----------------------------------------
	-- Progress
	if ex.getProgOS() then
		-- frame計算 / E-moteの処理に1フレーム以上時間がかかっていたら経過フレームを加算する
		local tm = e:now()
		local fr = 0
		local fs = flg.emotetime
		if fs then
			local mf = ex.maxframe			-- 足切り時間
			local es = tm - fs				-- 経過時間
			if es > mf then es = mf end		-- 一定以上経過していたらスリープ復帰の可能性があるので足切り
            fr = es * 0.06					-- player->Progress(elapse * (60.0f / 1000.0f));
		end

		-- fg loop
		local p = flg.emsave
		if p then
			for nm, em in pairs(p) do em:progress(fr) end	-- 必ず1フレーム進める
		end

		-- face
		local s = flg.emface
		if s and s.em then s.em:progress(fr) end			-- 必ず1フレーム進める
		flg.emotetime = tm
	end
end
----------------------------------------
-- lip skip
function emote.lipskip()
	local p  = flg.lipsync
	local s  = flg.lipsave
	flg.lipsync = nil	
	if ex.lipcheck() and s and p then
		for nm, v in pairs(p) do
			if s[nm] then
				s[nm].em:setVariable("face_talk", 0, 0, 0)
				ex.pass(s[nm].em, 1)
			end
		end
	end
end
----------------------------------------
-- 
----------------------------------------
-- ロード時に呼ばれる
function emote.loading()
	-- home
	if scr.home then return end

	-- emote復帰
	local s = scr.img.fg
	if s then
		scr.img.fg = {}
		for ch, v in pairs(s) do
			fg(v.p)
		end
	end

	-- mwface復帰
	local nm = scr.mwface
	if nm then
		local v  = scr.face
		local p  = getTextBlock()	-- text block取得
		local ch = getNameChar(p, "fg")
		if v and ch and v[ch] then
			local id = getMWID("face")
			setMWFaceFile(v[ch], "face", id)
		end
	end
end
----------------------------------------
-- cache
----------------------------------------
-- Windows cache / 一旦読んですぐ消す
function emote.cacheinit()
	local gs = game.os
	local s  = init.system.fake
	if gs == "windows" then
		local id  = 999
		local ext = game.fgext
		local z   = not emotecache and csv.cache.stand or {}
		for i, v in ipairs(z) do
			local px = ":fg/"..v..ext
			if isFile(px) then
				local em = e:createEmoteLayer{ id=(id.."."..i), files={ px }, width=(0), height=(0), progress=(ex.getProgress(true)) }
			end
		end
		lydel2(id)
		emotecache = true

	-- magickpath書き換え
	elseif s and gs ~= "windows" and game.trueos == "windows" then
		local m  = init.mpath.image
		local px = s.image_path..s.image.fg
		e:setMagicPath{ "fg", px }
	end
end
----------------------------------------
-- 立ち絵cache
function emote.fgcache(p)

end
----------------------------------------
-- 立ち絵cache削除
function emote.cachereset()

end
----------------------------------------
-- その他
----------------------------------------
-- Progress()実行
function ex.progress(em, no)
	if ex.getProgress() then
		local ct = no or 0
		em:progress(ct)
	end
end
----------------------------------------
function ex.getProgOS()
	return ex.progressos[game.os]
end
----------------------------------------
function ex.getProgress(flag)
	local r = ex.getProgOS()
	if flag and r then r = false end
	return r
end
----------------------------------------
function ex.getFacename(face, pose)
	local fa = face
	if fa:sub(1, 2) == "em" then
		fa = fa:sub(3)
--	else
--		fa = pose..fa.."_モーション"
	end
	return fa
end
----------------------------------------
function readfgImage(id, p, flag)
--	readImage(id, p, flag)
end
----------------------------------------
function emote.getver()
	return e:getEmoteVersion()
end
----------------------------------------
