From 1619122a58e75f8e628eef99404cdbb606a7f542 Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Mon, 23 Feb 2026 11:32:45 -0600 Subject: [PATCH] fixes --- input.cm | 2 +- resources.cm | 25 ++++++++----------------- sdl_gpu.cm | 8 ++++---- sound.cm | 7 ++++++- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/input.cm b/input.cm index bf056ef0..1a2ae0fb 100644 --- a/input.cm +++ b/input.cm @@ -160,7 +160,7 @@ function pick_user(canon) { if (canon.kind == 'button' && canon.pressed) { if (picked.active_device != canon.device_id) { // Release all held actions when switching device - old_down = picked.router.down + old_down = picked.router.down() arrfor(array(old_down), action => { if (old_down[action]) { picked.dispatch(action, { pressed: false, released: true, time: canon.time }) diff --git a/resources.cm b/resources.cm index 276dc281..2c8cfc94 100644 --- a/resources.cm +++ b/resources.cm @@ -1,14 +1,5 @@ var io = use('cellfs') -function hashify(fn) { - var hash = {} - return function(arg) { - var key = arg - if (hash[key] == null) hash[key] = fn(arg) - return hash[key] - } -} - // Merge of the old resources.js and packer.js functionalities var Resources = {} @@ -77,21 +68,21 @@ Resources.canonical = function(file) { } // The resource finders -Resources.find_image = hashify(function(file) { +Resources.find_image = function(file) { return find_in_path(file, Resources.images) -}) +} -Resources.find_sound = hashify(function(file) { +Resources.find_sound = function(file) { return find_in_path(file, Resources.sounds) -}) +} -Resources.find_script = hashify(function(file) { +Resources.find_script = function(file) { return find_in_path(file, Resources.scripts) -}) +} -Resources.find_font = hashify(function(file) { +Resources.find_font = function(file) { return find_in_path(file, Resources.fonts) -}) +} // .prosperonignore reading helper function read_ignore(dir) { diff --git a/sdl_gpu.cm b/sdl_gpu.cm index 9aca74e5..9c7e2b3a 100644 --- a/sdl_gpu.cm +++ b/sdl_gpu.cm @@ -762,8 +762,8 @@ sdl_gpu.get_texture_info = function(path) { sdl_gpu.get_or_create_target = function(width, height, key) { // Clamp dimensions to minimum 1x1 to prevent GPU errors - var w = (!width || width < 1) ? 1 : width - var h = (!height || height < 1) ? 1 : height + var w = (is_number(width) && width > 0) ? width : 1 + var h = (is_number(height) && height > 0) ? height : 1 var pool_key = `${w}x${h}` @@ -1149,9 +1149,9 @@ function _preload_textures(commands) { }) // Load all textures - arrfor(array(paths, function(path) { + arrfor(array(paths), function(path) { sdl_gpu.get_texture(path) - })) + }) } function _execute_commands(commands, window_size) { diff --git a/sound.cm b/sound.cm index fb7c1d63..109c05cc 100644 --- a/sound.cm +++ b/sound.cm @@ -74,9 +74,14 @@ feeder.resume_device() // Audio pump - called periodically to fill the audio buffer function pump() { var mixed = null - while (feeder.queued() < CHUNK_BYTES * 3) { + var iters = 0 + var q = feeder.queued() + while (q < CHUNK_BYTES * 3) { mixed = player.pull(FRAMES_PER_CHUNK) feeder.put(mixed) + iters = iters + 1 + if (iters > 100) break + q = feeder.queued() } $delay(pump, 1/240)