• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Go で書き直した Ikemen


Commit MetaInfo

修订版c9a73394d575f8752bcb49d1380237f7a21af92d (tree)
时间2019-09-08 19:04:30
作者neatunsou <sisiy4excite@gmai...>
Commiterneatunsou

Log Message

BGMのloopstartとloopendを読み込むようにした
Screenpackでbgmのloopとvolumeを読み込むようにした
Storyboardでテキスト表示ができなかったのを修正
StoryboardのBGdefを読み込むときに文字列でインデックスを取ろうとする場合があったのを修正

更改概述

差异

--- a/script/main.lua
+++ b/script/main.lua
@@ -658,7 +658,7 @@ function main.f_drawBG(data, info, layerno, timer)
658658 end
659659
660660 --reset screenpack data
661-function main.f_resetBG(info, bgdef, bgm)
661+function main.f_resetBG(info, bgdef, bgm, bgmLoop, bgmVolume, bgmloopstart, bgmloopend)
662662 bgm = bgm or nil
663663 animReset(info.fadein_data)
664664 animUpdate(info.fadein_data)
@@ -684,7 +684,7 @@ function main.f_resetBG(info, bgdef, bgm)
684684 end
685685 end
686686 if bgm ~= nil then
687- playBGM(bgm)
687+ playBGM(bgm, true, bgmLoop, bgmVolume, bgmloopstart or "0", bgmloopend or "0")
688688 end
689689 end
690690
@@ -1152,7 +1152,7 @@ for line in content:gmatch('[^\r\n]+') do
11521152 break
11531153 end
11541154 main.t_selStages[row] = {name = tmp, stage = c}
1155- local zoomout, zoomin, bgmusic, bgmvolume = getStageInfo(row)
1155+ local zoomout, zoomin, bgmusic, bgmvolume, bgmloopstart, bgmloopend = getStageInfo(row)
11561156 if zoomout ~= '' then
11571157 main.t_selStages[row].zoommin = tonumber(zoomout)
11581158 end
@@ -1161,7 +1161,7 @@ for line in content:gmatch('[^\r\n]+') do
11611161 end
11621162 if bgmusic ~= '' then
11631163 bgmusic = bgmusic:gsub('\\', '/')
1164- main.t_selStages[row].music = {[1] = {bgmusic = bgmusic, bgmvolume = tonumber(bgmvolume)}}
1164+ main.t_selStages[row].music = {[1] = {bgmusic = bgmusic, bgmvolume = tonumber(bgmvolume), bgmloopstart = bgmloopstart, bgmloopend = bgmloopend}}
11651165 end
11661166 main.t_includeStage[#main.t_includeStage + 1] = row
11671167 main.t_stageDef[c] = row
@@ -1231,7 +1231,7 @@ for i = 1, #main.t_selChars do
12311231 break
12321232 end
12331233 main.t_selStages[row] = {name = tmp, stage = main.t_selChars[i].stage[j]}
1234- local zoomout, zoomin, bgmusic, bgmvolume = getStageInfo(row)
1234+ local zoomout, zoomin, bgmusic, bgmvolume, bgmloopstart, bgmloopend = getStageInfo(row)
12351235 if zoomout ~= '' then
12361236 main.t_selStages[row].zoommin = tonumber(zoomout)
12371237 end
@@ -1241,7 +1241,7 @@ for i = 1, #main.t_selChars do
12411241 if bgmusic ~= '' then
12421242 bgmusic = bgmusic:gsub('\\', '/')
12431243 main.t_selStages[row].music = {}
1244- main.t_selStages[row].music[1] = {bgmusic = bgmusic, bgmvolume = tonumber(bgmvolume)}
1244+ main.t_selStages[row].music[1] = {bgmusic = bgmusic, bgmvolume = tonumber(bgmvolume), bgmloopstart = bgmloopstart, bgmloopend = bgmloopend}
12451245 end
12461246 if main.t_selChars[i].includestage == nil or main.t_selChars[i].includestage == 1 then
12471247 main.t_includeStage[#main.t_includeStage + 1] = row
@@ -1583,7 +1583,7 @@ function main.f_mainMenu()
15831583 if motif.files.intro_storyboard ~= '' then
15841584 storyboard.f_storyboard(motif.files.intro_storyboard)
15851585 end
1586- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
1586+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
15871587 while true do
15881588 cursorPosY, moveTxt, item = main.f_menuCommon1(cursorPosY, moveTxt, item, t)
15891589 if esc() then
--- a/script/motif.lua
+++ b/script/motif.lua
@@ -42,42 +42,44 @@ local motif =
4242 {
4343 title_bgm = '',
4444 title_bgm_volume = 100,
45- title_bgm_loop = 1, --not supported yet
46- title_bgm_loopstart = nil, --not supported yet
47- title_bgm_loopend = nil, --not supported yet
45+ title_bgm_loop = 1,
46+ title_bgm_loopstart = nil,
47+ title_bgm_loopend = nil,
4848 select_bgm = '',
4949 select_bgm_volume = 100,
50- select_bgm_loop = 1, --not supported yet
51- select_bgm_loopstart = nil, --not supported yet
52- select_bgm_loopend = nil, --not supported yet
50+ select_bgm_loop = 1,
51+ select_bgm_loopstart = nil,
52+ select_bgm_loopend = nil,
5353 vs_bgm = '',
5454 vs_bgm_volume = 100,
55- vs_bgm_loop = 1, --not supported yet
56- vs_bgm_loopstart = nil, --not supported yet
57- vs_bgm_loopend = nil, --not supported yet
55+ vs_bgm_loop = 1,
56+ vs_bgm_loopstart = nil,
57+ vs_bgm_loopend = nil,
5858 victory_bgm = '',
5959 victory_bgm_volume = 100,
60- victory_bgm_loop = 1, --not supported yet
61- victory_bgm_loopstart = nil, --not supported yet
62- victory_bgm_loopend = nil, --not supported yet
60+ victory_bgm_loop = 1,
61+ victory_bgm_loopstart = nil,
62+ victory_bgm_loopend = nil,
6363 continue_bgm = 'sound/CONTINUE.ogg', --Ikemen feature
64- continue_bgm_volume = 100, --Ikemen feature (not supported yet)
65- continue_bgm_loop = 1, --Ikemen feature (not supported yet)
66- continue_bgm_loopstart = nil, --Ikemen feature (not supported yet)
67- continue_bgm_loopend = nil, --Ikemen feature (not supported yet)
64+ continue_bgm_volume = 100, --Ikemen feature
65+ continue_bgm_loop = 1, --Ikemen feature
66+ continue_bgm_loopstart = nil, --Ikemen feature
67+ continue_bgm_loopend = nil, --Ikemen feature
6868 continue_end_bgm = 'sound/GAME_OVER.ogg', --Ikemen feature
69- continue_end_volume = 100, --Ikemen feature (not supported yet)
70- continue_end_loop = 0, --Ikemen feature (not supported yet)
71- continue_end_loopstart = nil, --Ikemen feature (not supported yet)
72- continue_end_loopend = nil, --Ikemen feature (not supported yet)
69+ continue_end_bgm_volume = 100, --Ikemen feature
70+ continue_end_bgm_loop = 0, --Ikemen feature
71+ continue_end_bgm_loopstart = nil, --Ikemen feature
72+ continue_end_bgm_loopend = nil, --Ikemen feature
7373 results_bgm = '', --Ikemen feature
74- results_bgm_loop = 1, --Ikemen feature (not supported yet)
75- results_bgm_loopstart = nil, --Ikemen feature (not supported yet)
76- results_bgm_loopend = nil, --Ikemen feature (not supported yet)
74+ results_bgm_volume = 100, --Ikemen feature
75+ results_bgm_loop = 1, --Ikemen feature
76+ results_bgm_loopstart = nil, --Ikemen feature
77+ results_bgm_loopend = nil, --Ikemen feature
7778 tournament_bgm = '', --Ikemen feature
78- tournament_bgm_loop = 1, --Ikemen feature (not supported yet)
79- tournament_bgm_loopstart = nil, --Ikemen feature (not supported yet)
80- tournament_bgm_loopend = nil, --Ikemen feature (not supported yet)
79+ tournament_bgm_volume = 100, --Ikemen feature
80+ tournament_bgm_loop = 1, --Ikemen feature
81+ tournament_bgm_loopstart = nil, --Ikemen feature
82+ tournament_bgm_loopend = nil, --Ikemen feature
8183 },
8284 title_info =
8385 {
--- a/script/select.lua
+++ b/script/select.lua
@@ -374,22 +374,33 @@ end
374374
375375 function select.f_assignMusic()
376376 local track = ''
377+ local trackVolume = 100
378+ local tracloopstart,tracloopend = nil
377379 if main.stageMenu then
378380 if main.t_selStages[stageNo].music ~= nil then
379381 track = math.random(1, #main.t_selStages[stageNo].music)
382+ trackVolume = main.t_selStages[stageNo].music[track].bgmvolume
383+ trackloopstart = main.t_selStages[stageNo].music[track].bgmloopstart
384+ trackloopend = main.t_selStages[stageNo].music[track].bgmloopend
380385 track = main.t_selStages[stageNo].music[track].bgmusic
381386 end
382387 else
383388 if main.t_selChars[t_p2Selected[1].cel + 1].music ~= nil then
384389 track = math.random(1, #main.t_selChars[t_p2Selected[1].cel + 1].music)
390+ trackVolume = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmvolume
391+ trackloopstart = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmloopstart
392+ trackloopend = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmloopend
385393 track = main.t_selChars[t_p2Selected[1].cel + 1].music[track].bgmusic
386394 elseif main.t_selStages[stageNo].music ~= nil then
387395 track = math.random(1, #main.t_selStages[stageNo].music)
396+ trackVolume = main.t_selStages[stageNo].music[track].bgmvolume
397+ trackloopstart = main.t_selStages[stageNo].music[track].bgmloopstart
398+ trackloopend = main.t_selStages[stageNo].music[track].bgmloopend
388399 track = main.t_selStages[stageNo].music[track].bgmusic
389400 end
390401 stageEnd = true
391402 end
392- playBGM(track)
403+ playBGM(track, true, 1, trackVolume, trackloopstart or "0", trackloopend or "0")
393404 end
394405
395406 function select.f_selectStage()
@@ -697,13 +708,13 @@ function select.f_selectSimple()
697708 stageList = 0
698709 main.f_cmdInput()
699710 while true do
700- main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm)
711+ main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
701712 select.f_selectReset()
702713 selectStart()
703714 while not selScreenEnd do
704715 if esc() then
705716 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
706- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
717+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
707718 return
708719 end
709720 select.f_selectScreen()
@@ -743,12 +754,12 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
743754 select.f_selectReset()
744755 stageEnd = true
745756 while true do
746- main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm)
757+ main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
747758 selectStart()
748759 while not selScreenEnd do
749760 if esc() then
750761 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
751- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
762+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
752763 return
753764 end
754765 select.f_selectScreen()
@@ -789,7 +800,7 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
789800 if motif.files.intro_storyboard ~= '' then
790801 storyboard.f_storyboard(motif.files.intro_storyboard)
791802 end
792- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
803+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
793804 return
794805 --player won (also if lost in VS 100 Kumite)
795806 elseif winner == 1 or main.gameMode == '100kumite' then
@@ -830,7 +841,7 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
830841 if motif.files.intro_storyboard ~= '' then
831842 storyboard.f_storyboard(motif.files.intro_storyboard)
832843 end
833- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
844+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
834845 return
835846 --next match available
836847 else
@@ -856,7 +867,7 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
856867 if motif.files.intro_storyboard ~= '' then
857868 storyboard.f_storyboard(motif.files.intro_storyboard)
858869 end
859- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
870+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
860871 return
861872 --player lost but can continue
862873 else
@@ -877,7 +888,7 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
877888 if motif.files.intro_storyboard ~= '' then
878889 storyboard.f_storyboard(motif.files.intro_storyboard)
879890 end
880- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
891+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
881892 return
882893 end
883894 if config.ContSelection then --true if 'Char change at Continue' option is enabled
@@ -894,14 +905,14 @@ getSpriteInfo('chars/kfm/kfm.sff', 0, 1)
894905 while not selScreenEnd do
895906 if esc() then
896907 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
897- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
908+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
898909 return
899910 end
900911 select.f_selectScreen()
901912 end
902913 elseif esc() then
903914 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
904- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
915+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
905916 return
906917 end
907918 end
@@ -992,12 +1003,12 @@ function select.f_selectTournament()
9921003 stageList = 0
9931004 main.f_cmdInput()
9941005 while true do
995- main.f_resetBG(motif.tournament_info, motif.tournamentbgdef, motif.music.tournament_bgm)
1006+ main.f_resetBG(motif.tournament_info, motif.tournamentbgdef, motif.music.tournament_bgm, motif.music.tournament_bgm_loop, motif.music.tournament_bgm_volume, motif.music.tournament_bgm_loopstart, motif.music.tournament_bgm_loopend)
9961007 select.f_selectReset()
9971008 while not selScreenEnd do
9981009 if esc() then
9991010 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
1000- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
1011+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
10011012 return
10021013 end
10031014 select.f_selectTournamentScreen()
@@ -1992,7 +2003,7 @@ function select.f_selectVersus()
19922003 textImgSetText(txt_matchNo, text[1])
19932004 local delay = 0
19942005 local minTime = 15 --let's reserve few extra ticks in case selectChar function needs time to load data, also prevents sound from being interrupted
1995- main.f_resetBG(motif.vs_screen, motif.versusbgdef, motif.music.vs_bgm)
2006+ main.f_resetBG(motif.vs_screen, motif.versusbgdef, motif.music.vs_bgm, motif.music.vs_bgm_loop, motif.music.vs_bgm_volume, motif.music.vs_bgm_loopstart, motif.music.vs_bgm_loopend)
19962007 if not main.versusScreen then
19972008 delay = minTime
19982009 select.f_selectChar(1, t_p1Selected)
@@ -2038,7 +2049,7 @@ function select.f_selectVersus()
20382049 while true do
20392050 if esc() then
20402051 sndPlay(motif.files.snd_data, motif.select_info.cancel_snd[1], motif.select_info.cancel_snd[2])
2041- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
2052+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
20422053 break
20432054 elseif p1Confirmed and p2Confirmed then
20442055 if orderTime == -1 and main.f_btnPalNo(main.p1Cmd) > 0 and delay > motif.versusbgdef.timer + minTime then
@@ -2309,15 +2320,15 @@ function select.f_result(state)
23092320 else
23102321 return
23112322 end
2312- main.f_resetBG(t, motif.resultsbgdef, motif.music.results_bgm)
2323+ main.f_resetBG(t, motif.resultsbgdef, motif.music.results_bgm, motif.music.results_bgm_loop, motif.music.results_bgm_volume, motif.music.results_bgm_loopstart, motif.music.results_bgm_loopend)
23132324 main.f_cmdInput()
23142325 while true do
23152326 if esc() or main.f_btnPalNo(main.p1Cmd) > 0 then
2316- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
2327+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
23172328 break
23182329 elseif motif.resultsbgdef.timer >= t.show_time then
23192330 --add fadeout code here
2320- main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm)
2331+ main.f_resetBG(motif.title_info, motif.titlebgdef, motif.music.title_bgm, motif.music.title_bgm_loop, motif.music.title_bgm_volume, motif.music.title_bgm_loopstart, motif.music.title_bgm_loopend)
23212332 break
23222333 end
23232334 --draw clearcolor
@@ -2394,7 +2405,7 @@ function select.f_selectVictory()
23942405 if motif.music.victory_bgm == '' then
23952406 main.f_resetBG(motif.victory_screen, motif.victorybgdef)
23962407 else
2397- main.f_resetBG(motif.victory_screen, motif.victorybgdef, motif.music.victory_bgm)
2408+ main.f_resetBG(motif.victory_screen, motif.victorybgdef, motif.music.victory_bgm, motif.music.victory_bgm_loop, motif.music.victory_bgm_volume, motif.music.victory_bgm_loopstart, motif.music.victory_bgm_loopend)
23982409 end
23992410 local winquote = ''
24002411 local winnerNum = 0
@@ -2503,7 +2514,7 @@ local txt_credits = main.f_createTextImg(
25032514 )
25042515
25052516 function select.f_continue()
2506- main.f_resetBG(motif.continue_screen, motif.continuebgdef, motif.music.continue_bgm)
2517+ main.f_resetBG(motif.continue_screen, motif.continuebgdef, motif.music.continue_bgm, motif.music.continue_bgm_loop, motif.music.continue_bgm_volume, motif.music.continue_bgm_loopstart, motif.music.continue_bgm_loopend)
25072518 animReset(motif.continue_screen.continue_anim_data)
25082519 animUpdate(motif.continue_screen.continue_anim_data)
25092520 continue = false
@@ -2526,7 +2537,7 @@ function select.f_continue()
25262537 text = main.f_extractText(motif.continue_screen.credits_text, main.credits)
25272538 textImgSetText(txt_credits, text[1])
25282539 main.f_cmdInput()
2529- main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm)
2540+ main.f_resetBG(motif.select_info, motif.selectbgdef, motif.music.select_bgm, motif.music.select_bgm_loop, motif.music.select_bgm_volume, motif.music.select_bgm_loopstart, motif.music.select_bgm_loopend)
25302541 break
25312542 elseif main.f_btnPalNo(main.p1Cmd) > 0 and motif.continuebgdef.timer >= motif.continue_screen.continue_starttime + motif.continue_screen.continue_skipstart then
25322543 local cnt = 0
@@ -2578,7 +2589,7 @@ function select.f_continue()
25782589 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_0_snd[1], motif.continue_screen.continue_0_snd[2])
25792590 end
25802591 elseif motif.continuebgdef.timer == motif.continue_screen.continue_end_skiptime then
2581- playBGM(motif.music.continue_end_bgm)
2592+ playBGM(motif.music.continue_end_bgm, true, motif.music.continue_end_loop, motif.music.continue_end_volume, motif.music.continue_end_loopstart or "0", motif.music.continue_end_loopend or "0")
25822593 sndPlay(motif.files.continue_snd_data, motif.continue_screen.continue_end_snd[1], motif.continue_screen.continue_end_snd[2])
25832594 end
25842595 --draw credits text
--- a/script/storyboard.lua
+++ b/script/storyboard.lua
@@ -61,7 +61,7 @@ local function f_play(t)
6161 end
6262 --play bgm
6363 if i == 0 and t.scene[k].bgm ~= nil then
64- playBGM(t.scene[k].bgm)
64+ playBGM(t.scene[k].bgm, true, t.scene[k].bgm_loop, t.scene[k].bgm_volume, t.scene[k].bgm_loopstart or "0", t.scene[k].bgm_loopend or "0")
6565 end
6666 --play snd
6767 if t.scenedef.snd_data ~= nil then
@@ -92,10 +92,10 @@ local function f_play(t)
9292 t.scene[k].layer[k2].text_data,
9393 t.scene[k].layer[k2].text,
9494 t.scene[k].layer[k2].text_timer,
95- t.scene[k].layerall_pos[1] + t_layer[k2].offset[1],
96- t.scene[k].layerall_pos[2] + t_layer[k2].offset[2],
97- t.scene[k].layer[k2].text_spacing,
98- t.scene[k].layer[k2].text_delay,
95+ t.scene[k].layerall_pos[1] + t.scene[k].layer[k2].offset[1],
96+ t.scene[k].layerall_pos[2] + t.scene[k].layer[k2].offset[2],
97+ t.scene[k].layer[k2].text_spacing[2],
98+ t.scene[k].layer[k2].textdelay,
9999 t.scene[k].layer[k2].text_length
100100 )
101101 end
@@ -120,7 +120,7 @@ local function f_play(t)
120120 end
121121 end
122122 end
123- playBGM('')
123+ playBGM('', true, 1, 100, "0", "0")
124124 end
125125
126126 local function f_parse(path)
@@ -238,6 +238,9 @@ local function f_parse(path)
238238 sound = {},
239239 --bgm = '',
240240 bgm_loop = 0,
241+ bgm_volume = 100,
242+ bgm_loopstart = nil,
243+ bgm_loopend = nil,
241244 --window = {0, 0, 0, 0},
242245 bg_name = ''
243246 }
@@ -281,9 +284,9 @@ local function f_parse(path)
281284 {
282285 anim = -1,
283286 text = '',
284- font = {1, 0, 1, nil, nil, nil},
287+ font = {1, 0, 0, nil, nil, nil},
285288 text_spacing = {0, 15}, --Ikemen feature
286- text_delay = 2, --Ikemen feature
289+ textdelay = 2,
287290 text_length = 50, --Ikemen feature
288291 text_timer = 0, --Ikemen feature
289292 offset = {0, 0},
@@ -396,8 +399,12 @@ local function f_parse(path)
396399 elseif main.f_fileExists('font/' .. t.scenedef.font[k]) then
397400 t.scenedef.font[k] = 'font/' .. t.scenedef.font[k]
398401 end
402+ t.scenedef.font_data[k] = fontNew(t.scenedef.font[k])
403+ t.scenedef.font[k] = {}
404+ t.scenedef.font[k][1] = k
405+ t.scenedef.font[k][2] = 0
406+ t.scenedef.font[k][3] = 0
399407 end
400- t.scenedef.font_data[k] = fontNew(t.scenedef.font[k])
401408 end
402409 end
403410 --loop through scenes
@@ -435,7 +442,7 @@ local function f_parse(path)
435442 local t_bgdef = t[t.scene[k].bg_name .. 'def']
436443 local prev_k2 = ''
437444 for k2, v2 in pairs(t_bgdef) do --loop through table keys
438- if t_bgdef[k2].type ~= nil then
445+ if type(k2) == "number" and t_bgdef[k2].type ~= nil then
439446 t_bgdef[k2].type = t_bgdef[k2].type:lower()
440447 --mugen ignores delta = 0 (defaults to 1)
441448 if t_bgdef[k2].delta[1] == 0 then t_bgdef[k2].delta[1] = 1 end
@@ -520,17 +527,17 @@ local function f_parse(path)
520527 --text
521528 if t_layer[k2].text ~= '' then
522529 t.scene[k].layer[k2].text_data = main.f_createTextImg(
523- t.scenedef.font_data[t.scenedef.font[t_layer[k2].font][1]],
524- t.scenedef.font[t_layer[k2].font][2],
525- t.scenedef.font[t_layer[k2].font][3],
530+ t.scenedef.font_data[t.scenedef.font[t_layer[k2].font[1]][1]],
531+ t_layer[k2].font[2],
532+ t_layer[k2].font[3],
526533 t_layer[k2].text,
527534 t.scene[k].layerall_pos[1] + t_layer[k2].offset[1],
528535 t.scene[k].layerall_pos[2] + t_layer[k2].offset[2],
529536 320/t.info.localcoord[1],
530537 240/t.info.localcoord[2],
531- t.scenedef.font[t_layer[k2].font][4],
532- t.scenedef.font[t_layer[k2].font][5],
533- t.scenedef.font[t_layer[k2].font][6]
538+ t_layer[k2].font[4],
539+ t_layer[k2].font[5],
540+ t_layer[k2].font[6]
534541 )
535542 end
536543 --endtime
--- a/src/script.go
+++ b/src/script.go
@@ -201,7 +201,7 @@ func scriptCommonInit(l *lua.LState) {
201201 return 0
202202 })
203203 luaRegister(l, "playBGM", func(l *lua.LState) int {
204- sys.bgm.Open(strArg(l, 1))
204+ sys.bgm.Open(strArg(l, 1), boolArg(l, 2), int(numArg(l, 3)), int(numArg(l, 4)), int(Atoi(strArg(l, 5))), int(Atoi(strArg(l, 6))))
205205 return 0
206206 })
207207 luaRegister(l, "esc", func(l *lua.LState) int {
@@ -1203,12 +1203,14 @@ func systemScriptInit(l *lua.LState) {
12031203 return 1
12041204 })
12051205 luaRegister(l, "getStageInfo", func(*lua.LState) int {
1206- a, b, c, d := sys.sel.GetStageInfo(int(numArg(l, 1)))
1206+ a, b, c, d, e, f := sys.sel.GetStageInfo(int(numArg(l, 1)))
12071207 l.Push(lua.LString(a))
12081208 l.Push(lua.LString(b))
12091209 l.Push(lua.LString(c))
12101210 l.Push(lua.LString(d))
1211- return 4
1211+ l.Push(lua.LString(e))
1212+ l.Push(lua.LString(f))
1213+ return 6
12121214 })
12131215 luaRegister(l, "getKey", func(*lua.LState) int {
12141216 s := ""
--- a/src/sound.go
+++ b/src/sound.go
@@ -236,8 +236,18 @@ func (n *NormalizerLR) process(bai float64, sam *float32) float64 {
236236 // Bgm
237237
238238 type Bgm struct {
239- filename string
240- ctrl *beep.Ctrl
239+ filename string
240+ bgmLoopStart int
241+ bgmLoopEnd int
242+ defaultFilename string
243+ defaultBgmVolume int
244+ defaultbgmLoopStart int
245+ defaultbgmLoopEnd int
246+ sampleRate beep.SampleRate
247+ streamer beep.StreamSeekCloser
248+ ctrl *beep.Ctrl
249+ resampler *beep.Resampler
250+ volume *effects.Volume
241251 }
242252
243253 func newBgm() *Bgm {
@@ -260,58 +270,71 @@ func (bgm *Bgm) IsFormat(extension string) bool {
260270 return filepath.Ext(bgm.filename) == extension
261271 }
262272
263-func (bgm *Bgm) Open(filename string) {
264-
273+func (bgm *Bgm) Open(filename string, isDefaultBGM bool, loop, bgmVolume, bgmLoopStart, bgmLoopEnd int) {
265274 if filepath.Base(bgm.filename) == filepath.Base(filename) {
266275 return
267276 }
268-
269277 bgm.filename = filename
278+ bgm.bgmLoopStart = bgmLoopStart
279+ bgm.bgmLoopEnd = bgmLoopEnd
280+ if isDefaultBGM {
281+ bgm.defaultFilename = filename
282+ bgm.defaultBgmVolume = bgmVolume
283+ bgm.defaultbgmLoopStart = bgmLoopStart
284+ bgm.defaultbgmLoopEnd = bgmLoopEnd
285+ }
270286 speaker.Clear()
271287
272288 if bgm.IsVorbis() {
273- bgm.ReadVorbis()
289+ bgm.ReadVorbis(loop, bgmVolume)
274290 } else if bgm.IsMp3() {
275- bgm.ReadMp3()
291+ bgm.ReadMp3(loop, bgmVolume)
276292 } else if bgm.IsFLAC() {
277- bgm.ReadFLAC()
293+ bgm.ReadFLAC(loop, bgmVolume)
278294 }
279295
280296 }
281297
282-func (bgm *Bgm) ReadMp3() {
298+func (bgm *Bgm) ReadMp3(loop int, bgmVolume int) {
283299 f, _ := os.Open(bgm.filename)
284300 s, format, err := mp3.Decode(f)
301+ bgm.streamer = s
285302 if err != nil {
286303 return
287304 }
288- bgm.ReadFormat(s, format)
305+ bgm.ReadFormat(format, loop, bgmVolume)
289306 }
290307
291-func (bgm *Bgm) ReadFLAC() {
308+func (bgm *Bgm) ReadFLAC(loop int, bgmVolume int) {
292309 f, _ := os.Open(bgm.filename)
293310 s, format, err := flac.Decode(f)
311+ bgm.streamer = s
294312 if err != nil {
295313 return
296314 }
297- bgm.ReadFormat(s, format)
315+ bgm.ReadFormat(format, loop, bgmVolume)
298316 }
299317
300-func (bgm *Bgm) ReadVorbis() {
318+func (bgm *Bgm) ReadVorbis(loop int, bgmVolume int) {
301319 f, _ := os.Open(bgm.filename)
302320 s, format, err := vorbis.Decode(f)
321+ bgm.streamer = s
303322 if err != nil {
304323 return
305324 }
306- bgm.ReadFormat(s, format)
325+ bgm.ReadFormat(format, loop, bgmVolume)
307326 }
308327
309-func (bgm *Bgm) ReadFormat(s beep.StreamSeekCloser, format beep.Format) {
310- streamer := beep.Loop(-1, s)
311- volume := -5 + float64(sys.bgmVolume)*0.06*(float64(sys.masterVolume)/100)
312- streamer = &effects.Volume{Streamer: streamer, Base: 2, Volume: volume, Silent: volume <= -5}
313- resample := beep.Resample(int(3), format.SampleRate, beep.SampleRate(Mp3SampleRate), streamer)
314- bgm.ctrl = &beep.Ctrl{Streamer: resample}
328+func (bgm *Bgm) ReadFormat(format beep.Format, loop int, bgmVolume int) {
329+ loopCount := int(1)
330+ if loop > 0 {
331+ loopCount = -1
332+ }
333+ streamer := beep.Loop(loopCount, bgm.streamer)
334+ volume := -5 + float64(sys.bgmVolume)*0.06*(float64(sys.masterVolume)/100)*(float64(bgmVolume)/100)
335+ bgm.volume = &effects.Volume{Streamer: streamer, Base: 2, Volume: volume, Silent: volume <= -5}
336+ bgm.resampler = beep.Resample(int(3), format.SampleRate, beep.SampleRate(Mp3SampleRate), bgm.volume)
337+ bgm.ctrl = &beep.Ctrl{Streamer: bgm.resampler}
315338 speaker.Play(bgm.ctrl)
316339 }
317340
--- a/src/system.go
+++ b/src/system.go
@@ -406,15 +406,11 @@ func (s *System) audioOpen() {
406406 func (s *System) soundWrite() {
407407 defer func() { s.audioClose <- true }()
408408 src := NewAudioSource()
409- bgmSrc := NewAudioSource()
410409 processed := false
411410 for !s.gameEnd {
412411 if src.Src.State() != openal.Playing {
413412 src.Src.Play()
414413 }
415- if bgmSrc.Src.State() != openal.Playing {
416- bgmSrc.Src.Play()
417- }
418414 if !processed {
419415 time.Sleep(10 * time.Millisecond)
420416 }
@@ -434,27 +430,20 @@ func (s *System) soundWrite() {
434430 }
435431 processed = true
436432 }
437- if bgmSrc.Src.BuffersProcessed() > 0 {
438- out := s.nullSndBuf[:]
439- if !s.nomusic {
440- if s.bgm.ctrl != nil {
441- s.bgm.ctrl.Paused = false
442- }
443- } else {
444- if s.bgm.ctrl != nil {
445- s.bgm.Pause()
433+ if !s.nomusic {
434+ if s.bgm.ctrl != nil {
435+ s.bgm.ctrl.Paused = false
436+ if s.bgm.bgmLoopEnd > 0 && s.bgm.streamer.Position() >= s.bgm.bgmLoopEnd {
437+ s.bgm.streamer.Seek(s.bgm.bgmLoopStart)
446438 }
447439 }
448- buf := bgmSrc.Src.UnqueueBuffer()
449- buf.SetDataInt16(openal.FormatStereo16, out, audioFrequency)
450- bgmSrc.Src.QueueBuffer(buf)
451- if err := openal.Err(); err != nil {
452- s.errLog.Println(err.Error())
440+ } else {
441+ if s.bgm.ctrl != nil {
442+ s.bgm.Pause()
453443 }
454- processed = true
455444 }
445+
456446 }
457- bgmSrc.Delete()
458447 src.Delete()
459448 openal.NullContext.Activate()
460449 device := s.audioContext.GetDevice()
@@ -1748,7 +1737,7 @@ type SelectChar struct {
17481737 sportrait, lportrait, vsportrait, vportrait *Sprite
17491738 }
17501739 type SelectStage struct {
1751- def, name, zoomout, zoomin, bgmusic, bgmvolume string
1740+ def, name, zoomout, zoomin, bgmusic, bgmvolume, bgmloopstart, bgmloopend string
17521741 }
17531742 type Select struct {
17541743 columns, rows int
@@ -1810,12 +1799,12 @@ func (s *Select) GetStageName(n int) string {
18101799 }
18111800 return s.stagelist[n-1].name
18121801 }
1813-func (s *Select) GetStageInfo(n int) (zoomin, zoomout, bgmusic, bgmvolume string) {
1802+func (s *Select) GetStageInfo(n int) (zoomin, zoomout, bgmusic, bgmvolume, bgmloopstart, bgmloopend string) {
18141803 n %= len(s.stagelist) + 1
18151804 if n < 0 {
18161805 n += len(s.stagelist) + 1
18171806 }
1818- return s.stagelist[n-1].zoomin, s.stagelist[n-1].zoomout, s.stagelist[n-1].bgmusic, s.stagelist[n-1].bgmvolume
1807+ return s.stagelist[n-1].zoomin, s.stagelist[n-1].zoomout, s.stagelist[n-1].bgmusic, s.stagelist[n-1].bgmvolume, s.stagelist[n-1].bgmloopstart, s.stagelist[n-1].bgmloopend
18191808 }
18201809 func (s *Select) addCahr(def string) {
18211810 s.charlist = append(s.charlist, SelectChar{})
@@ -1968,6 +1957,14 @@ func (s *Select) AddStage(def string) error {
19681957 if !ok {
19691958 ss.bgmvolume = "100"
19701959 }
1960+ ss.bgmloopstart, ok = is.getString("bgmloopstart")
1961+ if !ok {
1962+ ss.bgmloopstart = ""
1963+ }
1964+ ss.bgmloopend, ok = is.getString("bgmloopend")
1965+ if !ok {
1966+ ss.bgmloopend = ""
1967+ }
19711968 }
19721969 }
19731970 }