mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
popn: rest of the new cab lights (#651)
## Link to GitHub Issue or related Pull Request, if one exists #618 ## Description of change Add rest of the LED strip lights. ## Testing Tested U region.
This commit is contained in:
@@ -484,7 +484,7 @@ namespace games::popn {
|
|||||||
const auto data_size = std::min(map.data.capacity(), (size_t)number_of_leds / 3);
|
const auto data_size = std::min(map.data.capacity(), (size_t)number_of_leds / 3);
|
||||||
|
|
||||||
// pick a color to use
|
// pick a color to use
|
||||||
const auto rgb = tapeledutils::pick_color_from_led_tape((uint8_t *)i_pData, data_size);
|
const auto rgb = tapeledutils::pick_color_from_led_tape(map, (uint8_t *)i_pData, data_size);
|
||||||
|
|
||||||
// program the lights into API
|
// program the lights into API
|
||||||
auto &lights = get_lights();
|
auto &lights = get_lights();
|
||||||
|
|||||||
@@ -136,6 +136,18 @@ std::vector<Light> &games::popn::get_lights() {
|
|||||||
{"Pika", "IC Card R"},
|
{"Pika", "IC Card R"},
|
||||||
{"Pika", "IC Card G"},
|
{"Pika", "IC Card G"},
|
||||||
{"Pika", "IC Card B"},
|
{"Pika", "IC Card B"},
|
||||||
|
{"Pika", "Speakers R"},
|
||||||
|
{"Pika", "Speakers G"},
|
||||||
|
{"Pika", "Speakers B"},
|
||||||
|
{"Pika", "Monitor R"},
|
||||||
|
{"Pika", "Monitor G"},
|
||||||
|
{"Pika", "Monitor B"},
|
||||||
|
{"Pika", "Control Panel R"},
|
||||||
|
{"Pika", "Control Panel G"},
|
||||||
|
{"Pika", "Control Panel B"},
|
||||||
|
{"Pika", "Cabinet R"},
|
||||||
|
{"Pika", "Cabinet G"},
|
||||||
|
{"Pika", "Cabinet B"},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,18 @@ namespace games::popn {
|
|||||||
IC_Card_R,
|
IC_Card_R,
|
||||||
IC_Card_G,
|
IC_Card_G,
|
||||||
IC_Card_B,
|
IC_Card_B,
|
||||||
|
Speaker_R,
|
||||||
|
Speaker_G,
|
||||||
|
Speaker_B,
|
||||||
|
Monitor_R,
|
||||||
|
Monitor_G,
|
||||||
|
Monitor_B,
|
||||||
|
ControlPanel_R,
|
||||||
|
ControlPanel_G,
|
||||||
|
ControlPanel_B,
|
||||||
|
Cabinet_R,
|
||||||
|
Cabinet_G,
|
||||||
|
Cabinet_B,
|
||||||
} popn_lights_t;
|
} popn_lights_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,39 +38,83 @@ namespace games::popn {
|
|||||||
// pin 1 = left pop (red pop kun), size 16, values 0-0xFF
|
// pin 1 = left pop (red pop kun), size 16, values 0-0xFF
|
||||||
// pin 2 = right pop (blue pop kun), size 16, values 0-0xFF
|
// pin 2 = right pop (blue pop kun), size 16, values 0-0xFF
|
||||||
// pin 3 = title, size 44, values 0-0xFF
|
// pin 3 = title, size 44, values 0-0xFF
|
||||||
// pin 4 = speaker, size 40, values 0-0xFF - U region only
|
// pin 4 = speaker, size 40, values 0-0x7F - U region only
|
||||||
// pin 5 = monitor, size 18, values 0-0x7F - U region only
|
// pin 5 = monitor, size 18, values 0-0x7F - U region only
|
||||||
// pin 6 = control panel, size 28, values 0-0x7F - U region only
|
// pin 6 = control panel, size 28, values 0-0x7F - U region only
|
||||||
// pin 7 = cabinet, size 22, values 0-0x7F - U region only
|
// pin 7 = cabinet, size 22, values 0-0x7F - U region only
|
||||||
tapeledutils::tape_led TAPELED_MAPPING[POPN_TAPELED_TOTAL] = {
|
tapeledutils::tape_led TAPELED_MAPPING[POPN_TAPELED_TOTAL] = {
|
||||||
{
|
{
|
||||||
0, // these are button lights and handled specially
|
// [0] button lights: these are button lights and handled specially
|
||||||
|
0,
|
||||||
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
"Invalid"
|
"Invalid"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// [1] red pop-kun
|
||||||
5, // 5*3; game reports 16 but make it 15
|
5, // 5*3; game reports 16 but make it 15
|
||||||
Lights::popn_lights_t::RedPopKun_R,
|
Lights::popn_lights_t::RedPopKun_R,
|
||||||
Lights::popn_lights_t::RedPopKun_G,
|
Lights::popn_lights_t::RedPopKun_G,
|
||||||
Lights::popn_lights_t::RedPopKun_B,
|
Lights::popn_lights_t::RedPopKun_B,
|
||||||
|
0xFF,
|
||||||
"Red Pop-Kun"
|
"Red Pop-Kun"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// [2] blue pop-kun
|
||||||
5, // 5*3; game reports 16 but make it 15
|
5, // 5*3; game reports 16 but make it 15
|
||||||
Lights::popn_lights_t::BluePopKun_R,
|
Lights::popn_lights_t::BluePopKun_R,
|
||||||
Lights::popn_lights_t::BluePopKun_G,
|
Lights::popn_lights_t::BluePopKun_G,
|
||||||
Lights::popn_lights_t::BluePopKun_B,
|
Lights::popn_lights_t::BluePopKun_B,
|
||||||
|
0xFF,
|
||||||
"Blue Pop-Kun"
|
"Blue Pop-Kun"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
14, // 14*3; game reports 44 but make it 42; these are lights above the banner
|
// [3] top LED
|
||||||
|
14, // 14*3; game reports 44 but make it 42
|
||||||
Lights::popn_lights_t::TopLED_R,
|
Lights::popn_lights_t::TopLED_R,
|
||||||
Lights::popn_lights_t::TopLED_G,
|
Lights::popn_lights_t::TopLED_G,
|
||||||
Lights::popn_lights_t::TopLED_B,
|
Lights::popn_lights_t::TopLED_B,
|
||||||
|
0xFF,
|
||||||
"Top"
|
"Top"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// [4] speakers
|
||||||
|
13, // 13*3; game reports 40 but make it 39
|
||||||
|
Lights::popn_lights_t::Speaker_G,
|
||||||
|
Lights::popn_lights_t::Speaker_R,
|
||||||
|
Lights::popn_lights_t::Speaker_B,
|
||||||
|
0x7F,
|
||||||
|
"Speakers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// [5] monitor
|
||||||
|
6,
|
||||||
|
Lights::popn_lights_t::Monitor_G,
|
||||||
|
Lights::popn_lights_t::Monitor_R,
|
||||||
|
Lights::popn_lights_t::Monitor_B,
|
||||||
|
0x7F,
|
||||||
|
"Monitor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// [6] control panel
|
||||||
|
9, // 9*3; game reports 28
|
||||||
|
Lights::popn_lights_t::ControlPanel_G,
|
||||||
|
Lights::popn_lights_t::ControlPanel_R,
|
||||||
|
Lights::popn_lights_t::ControlPanel_B,
|
||||||
|
0x7F,
|
||||||
|
"Control Panel"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// [7] Cabinet
|
||||||
|
7, // 7*3; game reports 22
|
||||||
|
Lights::popn_lights_t::Cabinet_G,
|
||||||
|
Lights::popn_lights_t::Cabinet_R,
|
||||||
|
Lights::popn_lights_t::Cabinet_B,
|
||||||
|
0x7F,
|
||||||
|
"Cabinet"
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace games::popn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SPICE64
|
#if SPICE64
|
||||||
constexpr int POPN_TAPELED_TOTAL = 4;
|
constexpr int POPN_TAPELED_TOTAL = 8;
|
||||||
extern tapeledutils::tape_led TAPELED_MAPPING[POPN_TAPELED_TOTAL];
|
extern tapeledutils::tape_led TAPELED_MAPPING[POPN_TAPELED_TOTAL];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace tapeledutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for bi2x-style byte array of all colors and LEDs at once
|
// for bi2x-style byte array of all colors and LEDs at once
|
||||||
rgb_float3_t pick_color_from_led_tape(uint8_t *data, size_t data_size) {
|
static rgb_float3_t pick_color_from_led_tape_internal(uint8_t *data, size_t data_size, uint8_t divisor) {
|
||||||
rgb_float3_t result = {0.f, 0.f, 0.f};
|
rgb_float3_t result = {0.f, 0.f, 0.f};
|
||||||
if (TAPE_LED_ALGORITHM == TAPE_LED_USE_AVERAGE) {
|
if (TAPE_LED_ALGORITHM == TAPE_LED_USE_AVERAGE) {
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ namespace tapeledutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// normalize
|
// normalize
|
||||||
const float avg_mult = 1.f / (data_size * 255);
|
const float avg_mult = 1.f / (data_size * divisor);
|
||||||
result.r = avg_ri * avg_mult;
|
result.r = avg_ri * avg_mult;
|
||||||
result.g = avg_gi * avg_mult;
|
result.g = avg_gi * avg_mult;
|
||||||
result.b = avg_bi * avg_mult;
|
result.b = avg_bi * avg_mult;
|
||||||
@@ -50,7 +50,7 @@ namespace tapeledutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// normalize
|
// normalize
|
||||||
const float single_mult = 1.f / 255;
|
const float single_mult = 1.f / divisor;
|
||||||
result.r = color[0] * single_mult;
|
result.r = color[0] * single_mult;
|
||||||
result.g = color[1] * single_mult;
|
result.g = color[1] * single_mult;
|
||||||
result.b = color[2] * single_mult;
|
result.b = color[2] * single_mult;
|
||||||
@@ -58,6 +58,15 @@ namespace tapeledutils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rgb_float3_t pick_color_from_led_tape(tape_led &light, uint8_t *data, size_t data_size) {
|
||||||
|
const auto max_value = (light.max_value > 0) ? light.max_value : 0xFF;
|
||||||
|
return pick_color_from_led_tape_internal(data, data_size, max_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_float3_t pick_color_from_led_tape(uint8_t *data, size_t data_size) {
|
||||||
|
return pick_color_from_led_tape_internal(data, data_size, 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
// for bi2a-style that calls for each individual LED
|
// for bi2a-style that calls for each individual LED
|
||||||
size_t get_led_index_using_avg_algo(size_t data_size) {
|
size_t get_led_index_using_avg_algo(size_t data_size) {
|
||||||
size_t index_to_use;
|
size_t index_to_use;
|
||||||
|
|||||||
@@ -25,13 +25,33 @@ namespace tapeledutils {
|
|||||||
struct tape_led {
|
struct tape_led {
|
||||||
std::vector<rgb_float3_t> data;
|
std::vector<rgb_float3_t> data;
|
||||||
int index_r, index_g, index_b; // Averaged RGB light output indexes
|
int index_r, index_g, index_b; // Averaged RGB light output indexes
|
||||||
|
uint8_t max_value;
|
||||||
std::string lightName;
|
std::string lightName;
|
||||||
|
|
||||||
tape_led(size_t data_size, int index_r, int index_g, int index_b, std::string lightName)
|
tape_led(
|
||||||
: data(std::vector<rgb_float3_t>(data_size)), index_r(index_r), index_g(index_g), index_b(index_b), lightName(std::move(lightName)) {}
|
size_t data_size,
|
||||||
|
int index_r, int index_g, int index_b,
|
||||||
|
std::string lightName)
|
||||||
|
: data(
|
||||||
|
std::vector<rgb_float3_t>(data_size)),
|
||||||
|
index_r(index_r), index_g(index_g), index_b(index_b),
|
||||||
|
max_value(0),
|
||||||
|
lightName(std::move(lightName)) {}
|
||||||
|
|
||||||
|
tape_led(
|
||||||
|
size_t data_size,
|
||||||
|
int index_r, int index_g, int index_b,
|
||||||
|
uint8_t max_value,
|
||||||
|
std::string lightName)
|
||||||
|
: data(
|
||||||
|
std::vector<rgb_float3_t>(data_size)),
|
||||||
|
index_r(index_r), index_g(index_g), index_b(index_b),
|
||||||
|
max_value(max_value),
|
||||||
|
lightName(std::move(lightName)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_enabled();
|
bool is_enabled();
|
||||||
|
rgb_float3_t pick_color_from_led_tape(tape_led &light, uint8_t *data, size_t data_size);
|
||||||
rgb_float3_t pick_color_from_led_tape(uint8_t *data, size_t data_size);
|
rgb_float3_t pick_color_from_led_tape(uint8_t *data, size_t data_size);
|
||||||
size_t get_led_index_using_avg_algo(size_t data_size);
|
size_t get_led_index_using_avg_algo(size_t data_size);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user