- added music/sfc subsystem\n- added basic audio\n- added music/sound test screen\n- added some basic vscode tasks
This commit is contained in:
14
.vscode/settings.json
vendored
14
.vscode/settings.json
vendored
@@ -15,5 +15,17 @@
|
||||
],
|
||||
"Lua.diagnostics.disable": [
|
||||
"undefined-global"
|
||||
]
|
||||
],
|
||||
"python.autoComplete.extraPaths": [
|
||||
"${workspaceFolder}/sources/poky/bitbake/lib",
|
||||
"${workspaceFolder}/sources/poky/meta/lib"
|
||||
],
|
||||
"python.analysis.extraPaths": [
|
||||
"${workspaceFolder}/sources/poky/bitbake/lib",
|
||||
"${workspaceFolder}/sources/poky/meta/lib"
|
||||
],
|
||||
"files.associations": {
|
||||
"*.conf": "bitbake",
|
||||
"*.inc": "bitbake"
|
||||
}
|
||||
}
|
||||
27
.vscode/tasks.json
vendored
Normal file
27
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Run TIC80",
|
||||
"type": "shell",
|
||||
"command": "tic80 --fs=. impostor.lua"
|
||||
},
|
||||
{
|
||||
"label": "Build & Run TIC80",
|
||||
"type": "shell",
|
||||
"command": "make build && tic80 --fs=. impostor.lua"
|
||||
},
|
||||
{
|
||||
"label": "Export assets",
|
||||
"type": "shell",
|
||||
"command": "make export_assets"
|
||||
},
|
||||
{
|
||||
"label": "Make build",
|
||||
"type": "shell",
|
||||
"command": "make build"
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -4,15 +4,18 @@ init/init.config.lua
|
||||
init/init.windows.lua
|
||||
init/init.context.lua
|
||||
system/system.print.lua
|
||||
system/system.util.lua
|
||||
entity/entity.npc.lua
|
||||
entity/entity.item.lua
|
||||
system/system.input.lua
|
||||
system/system.audio.lua
|
||||
system/system.ui.lua
|
||||
map/map.bedroom.lua
|
||||
window/window.splash.lua
|
||||
window/window.intro.lua
|
||||
window/window.menu.lua
|
||||
window/window.configuration.lua
|
||||
window/window.audiotest.lua
|
||||
window/window.popup.lua
|
||||
window/window.game.lua
|
||||
system/system.main.lua
|
||||
|
||||
@@ -4,10 +4,13 @@ local MenuWindow = {}
|
||||
local GameWindow = {}
|
||||
local PopupWindow = {}
|
||||
local ConfigurationWindow = {}
|
||||
local AudioTestWindow = {}
|
||||
|
||||
local Util = {}
|
||||
local UI = {}
|
||||
local Print = {}
|
||||
local Input = {}
|
||||
local NPC = {}
|
||||
local Item = {}
|
||||
local Player = {}
|
||||
local Audio = {}
|
||||
|
||||
@@ -4,3 +4,4 @@ local WINDOW_MENU = 2
|
||||
local WINDOW_GAME = 3
|
||||
local WINDOW_POPUP = 4
|
||||
local WINDOW_CONFIGURATION = 7
|
||||
local WINDOW_AUDIOTEST = 9001 -- mert ez debug
|
||||
|
||||
@@ -1,3 +1,35 @@
|
||||
-- <PALETTE>
|
||||
-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
|
||||
-- </PALETTE>
|
||||
-- <SFX>
|
||||
-- 000:060006400600064006000640060006400600060006000600060006000600060006000600060006000600060006000600060006000600060006000600300000000900
|
||||
-- 016:05000500050005400540054005700570057005400540054005700570057005c005c005c005c005c005c005c005c005c005c005c005c005c005c005c0470000000000
|
||||
-- 017:040004000400040004000400046004600460046004600460146024c034c054c064c084c0a4c0b4c0c4c0c4c0d4c0d4c0e4c0f4c0f4c0f4c0f4c0f4c0400000000000
|
||||
-- 018:04c004c004c004c004c004c0046004600460046004600460240034005400640084009400a400b400c400d400d400e400e400e400f400f400f400f400300000000000
|
||||
-- 019:0400040004000400040004d014d014d024d034d054d074d094d0b4d0c4d0e4d0f4d0f4d0f4d0f4d0f4d0f4d0f4d0f4d0f4d0f4d0f4d0f4d0f4d0f4d0400000000000
|
||||
-- 020:090009000900090009000900090009000900090009000900090009000900090009000900090009000900090009000900090009000900090009000900500000000000
|
||||
-- 021:01000100010001000100f10001100110011001100110f11001200120012001200120f1201130113011302130213021302130313041308130a130d130380000000000
|
||||
-- 032:010001100100011001000110010001100100010001000100010001000100010001000100010001000100010001000100010001000100010001000100301000000800
|
||||
-- 033:000000010002000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d40000000004
|
||||
-- 044:0600f6000620f6000600f6000610f600f600f6000600f600f600f600f6000600060006000600060006000600060006000600060006000600060006004600000f0f00
|
||||
-- 045:0000f0000020f0000000f0000010f000f000f0000000f000f000f000f0000000000000000000000000000000000000000000000000000000000000004600000f0f00
|
||||
-- 057:000000010002000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d40000000004
|
||||
-- 058:41004110410041104100411041004110c100c100c100c100c100c100c100c100c100c100c100c100c100c100c100c100c100c100c100c100c100c100100000080800
|
||||
-- 059:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000
|
||||
-- 060:220022002200820082008200820082008200820082008200820082008200820082008200820082008200820082008200820082008200820082008200100000000000
|
||||
-- 061:9f009f00bf00df00df00ef00ef00ef00ef00ef00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00400000000000
|
||||
-- 062:00000100010001000100510081008100910091009100a100a100a100a100a100b100b100b100b100c100c100c100d100d100d100e100e100e100f100484000000000
|
||||
-- 063:00b000100000000000000000100060009000b000c000d000d000e000e000e000f000f000f000f000f000f000f000f000f000f000f000f000f000f000405000000000
|
||||
-- </SFX>
|
||||
-- <WAVES>
|
||||
-- 000:bcceefceedddddc84333121268abaa99
|
||||
-- 001:6789bdd96adc83248dd6334adda7578b
|
||||
-- 002:0123456789abcdef0123456789abcdef
|
||||
-- 003:224578acdeeeeddcba95434567653100
|
||||
-- 004:00000000ffffffff00000000ffffffff
|
||||
-- 005:0123456789abcdeffedcba9876543210
|
||||
-- 006:0123456789abcdef0123456789abcdef
|
||||
-- 007:76543210123456789abcdefedcba9878
|
||||
-- 008:0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
|
||||
-- 009:fff000fff000fff000fff000fff000ff
|
||||
-- </WAVES>
|
||||
|
||||
16
inc/system/system.audio.lua
Normal file
16
inc/system/system.audio.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Audio subsystem
|
||||
|
||||
function Audio.music_stop() music() end
|
||||
function Audio.music_play_mainmenu() end
|
||||
function Audio.music_play_wakingup() end
|
||||
function Audio.music_play_room_morning() end
|
||||
function Audio.music_play_room_street_1() end
|
||||
function Audio.music_play_room_street_2() end
|
||||
function Audio.music_play_room_() end
|
||||
function Audio.music_play_room_work() end
|
||||
|
||||
function Audio.sfx_select() sfx(17, 'C-7', 30) end
|
||||
function Audio.sfx_deselect() sfx(18, 'C-7', 30) end
|
||||
function Audio.sfx_beep() sfx(19, 'C-6', 30) end
|
||||
function Audio.sfx_success() sfx(16, 'C-7', 60) end
|
||||
function Audio.sfx_bloop() sfx(21, 'C-3', 60) end
|
||||
@@ -16,8 +16,8 @@ local INPUT_KEY_ENTER = 50
|
||||
|
||||
function Input.up() return btnp(INPUT_KEY_UP) end
|
||||
function Input.down() return btnp(INPUT_KEY_DOWN) end
|
||||
function Input.left() return btn(INPUT_KEY_LEFT) end
|
||||
function Input.right() return btn(INPUT_KEY_RIGHT) end
|
||||
function Input.left() return btnp(INPUT_KEY_LEFT) end
|
||||
function Input.right() return btnp(INPUT_KEY_RIGHT) end
|
||||
function Input.select() return btnp(INPUT_KEY_A) or keyp(INPUT_KEY_SPACE) end
|
||||
function Input.menu_confirm() return btnp(INPUT_KEY_A) or keyp(INPUT_KEY_ENTER) end
|
||||
function Input.player_interact() return btnp(INPUT_KEY_B) or keyp(INPUT_KEY_ENTER) end -- B button
|
||||
|
||||
@@ -24,6 +24,10 @@ local STATE_HANDLERS = {
|
||||
ConfigurationWindow.update()
|
||||
ConfigurationWindow.draw()
|
||||
end,
|
||||
[WINDOW_AUDIOTEST] = function()
|
||||
AudioTestWindow.update()
|
||||
AudioTestWindow.draw()
|
||||
end,
|
||||
}
|
||||
|
||||
local initialized_game = false
|
||||
|
||||
@@ -5,4 +5,4 @@ function Print.text(text, x, y, color, fixed, scale)
|
||||
scale = scale or 1
|
||||
print(text, x + 1, y + 1, shadow_color, fixed, scale)
|
||||
print(text, x, y, color, fixed, scale)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,11 +19,13 @@ end
|
||||
|
||||
function UI.update_menu(items, selected_item)
|
||||
if Input.up() then
|
||||
Audio.sfx_beep()
|
||||
selected_item = selected_item - 1
|
||||
if selected_item < 1 then
|
||||
selected_item = #items
|
||||
end
|
||||
elseif Input.down() then
|
||||
Audio.sfx_beep()
|
||||
selected_item = selected_item + 1
|
||||
if selected_item > #items then
|
||||
selected_item = 1
|
||||
|
||||
5
inc/system/system.util.lua
Normal file
5
inc/system/system.util.lua
Normal file
@@ -0,0 +1,5 @@
|
||||
Util = {}
|
||||
|
||||
function Util.safeindex(array, index)
|
||||
return ((index - 1 + #array) % #array) + 1
|
||||
end
|
||||
85
inc/window/window.audiotest.lua
Normal file
85
inc/window/window.audiotest.lua
Normal file
@@ -0,0 +1,85 @@
|
||||
AudioTestWindow = {
|
||||
index_menu = 1,
|
||||
index_func = 1,
|
||||
list_func = {},
|
||||
menuitems = {},
|
||||
last_pressed = false
|
||||
}
|
||||
|
||||
function AudioTestWindow.generate_menuitems(list_func, index_func)
|
||||
return {
|
||||
{
|
||||
label = "Play music/sound: " .. (list_func[index_func] or "?"),
|
||||
action = function()
|
||||
local current_func = Audio[list_func[index_func]]
|
||||
if current_func then
|
||||
current_func()
|
||||
else
|
||||
trace("Invalid Audio function: " .. list_func[index_menu])
|
||||
end
|
||||
end
|
||||
},
|
||||
{
|
||||
label = "Stop playing music",
|
||||
action = function()
|
||||
Audio.music_stop()
|
||||
end
|
||||
},
|
||||
{
|
||||
label = "Back",
|
||||
action = function()
|
||||
AudioTestWindow.back()
|
||||
end
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
function AudioTestWindow.generate_listfunc()
|
||||
local result = {}
|
||||
|
||||
for k, v in pairs(Audio) do
|
||||
if type(v) == "function" then
|
||||
result[#result + 1] = k
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(result)
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
function AudioTestWindow.back()
|
||||
Audio.sfx_deselect()
|
||||
GameWindow.set_state(WINDOW_MENU)
|
||||
end
|
||||
|
||||
function AudioTestWindow.init()
|
||||
AudioTestWindow.last_pressed = false
|
||||
AudioTestWindow.index_menu = 1
|
||||
AudioTestWindow.index_func = 1
|
||||
AudioTestWindow.list_func = AudioTestWindow.generate_listfunc()
|
||||
AudioTestWindow.menuitems = AudioTestWindow.generate_menuitems(AudioTestWindow.list_func, AudioTestWindow.index_func)
|
||||
end
|
||||
|
||||
function AudioTestWindow.draw()
|
||||
UI.draw_top_bar("Audio test")
|
||||
UI.draw_menu(AudioTestWindow.menuitems, AudioTestWindow.index_menu, 20, 50)
|
||||
end
|
||||
|
||||
function AudioTestWindow.update()
|
||||
if Input.up() then
|
||||
AudioTestWindow.index_menu = Util.safeindex(AudioTestWindow.menuitems, AudioTestWindow.index_menu - 1)
|
||||
elseif Input.down() then
|
||||
AudioTestWindow.index_menu = Util.safeindex(AudioTestWindow.menuitems, AudioTestWindow.index_menu + 1)
|
||||
elseif Input.left() then
|
||||
AudioTestWindow.index_func = Util.safeindex(AudioTestWindow.list_func, AudioTestWindow.index_func - 1)
|
||||
AudioTestWindow.menuitems = AudioTestWindow.generate_menuitems(AudioTestWindow.list_func, AudioTestWindow.index_func)
|
||||
elseif Input.right() then
|
||||
AudioTestWindow.index_func = Util.safeindex(AudioTestWindow.list_func, AudioTestWindow.index_func + 1)
|
||||
AudioTestWindow.menuitems = AudioTestWindow.generate_menuitems(AudioTestWindow.list_func, AudioTestWindow.index_func)
|
||||
elseif Input.menu_confirm() then
|
||||
AudioTestWindow.menuitems[AudioTestWindow.index_menu].action()
|
||||
elseif Input.menu_back() then
|
||||
AudioTestWindow.back()
|
||||
end
|
||||
end
|
||||
@@ -9,6 +9,7 @@ function MenuWindow.update()
|
||||
if Input.menu_confirm() then
|
||||
local selected_item = Context.menu_items[Context.selected_menu_item]
|
||||
if selected_item and selected_item.action then
|
||||
Audio.sfx_select()
|
||||
selected_item.action()
|
||||
end
|
||||
end
|
||||
@@ -41,6 +42,11 @@ function MenuWindow.configuration()
|
||||
GameWindow.set_state(WINDOW_CONFIGURATION)
|
||||
end
|
||||
|
||||
function MenuWindow.audio_test()
|
||||
AudioTestWindow.init()
|
||||
GameWindow.set_state(WINDOW_AUDIOTEST)
|
||||
end
|
||||
|
||||
function MenuWindow.refresh_menu_items()
|
||||
Context.menu_items = {} -- Start with an empty table
|
||||
|
||||
@@ -52,9 +58,8 @@ function MenuWindow.refresh_menu_items()
|
||||
table.insert(Context.menu_items, {label = "New Game", action = MenuWindow.new_game})
|
||||
table.insert(Context.menu_items, {label = "Load Game", action = MenuWindow.load_game})
|
||||
table.insert(Context.menu_items, {label = "Configuration", action = MenuWindow.configuration})
|
||||
table.insert(Context.menu_items, {label = "Audio Test", action = MenuWindow.audio_test})
|
||||
table.insert(Context.menu_items, {label = "Exit", action = MenuWindow.exit})
|
||||
|
||||
|
||||
Context.selected_menu_item = 1 -- Reset selection after refreshing
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user