added touch

This commit is contained in:
bQUARKz 2026-01-14 09:14:59 +00:00
parent fea5e09f82
commit f7077ffec0
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
5 changed files with 51 additions and 32 deletions

View File

@ -89,14 +89,11 @@ impl Machine {
// SETUP BANCO 2 (Tiles 16x16 para Sprites)
if self.gfx.banks[2].is_none() {
let mut bank = crate::model::TileBank::new(crate::model::TileSize::Size16, 128, 128);
// Define Cor na Paleta 0, Índice 1 = INDIGO (Roxo)
bank.palettes[0][1] = Color::INDIGO;
// Define Cor na Paleta 1, Índice 1 = AMARELO (para Palette Swap)
bank.palettes[1][1] = Color::YELLOW;
// Define Cor na Paleta 1, Índice 1 = AMARELO (para Palette Swap)
bank.palettes[2][1] = Color::RED;
// Define Cor na Paleta 1, Índice 1 = AMARELO (para Palette Swap)
bank.palettes[3][1] = Color::GREEN;
bank.palettes[4][1] = Color::ORANGE;
let tile_size = 16;
let start_x = 16;
@ -121,7 +118,7 @@ impl Machine {
}
// 512 Sprites (usando Banco 2 - Indigo e Amarelo)
for i in 0..511 {
for i in 0..510 {
let s = &mut self.gfx.sprites[i];
s.active = true;
s.bank_id = 2;
@ -156,10 +153,30 @@ impl Machine {
cursor.tile.palette_id = 3; // GREEN
}
// // Teste de Pressed: se clicou JUSTO AGORA, reseta o frame_index
// if self.touch.f.pressed {
// self.frame_index = 0;
// }
// --- INTERATIVIDADE COM INPUT (Gamepad) ---
let player = &mut self.gfx.sprites[510]; // Usaremos outro sprite para o Pad
player.active = true;
player.bank_id = 2;
player.tile.id = 1;
player.priority = 4;
player.tile.palette_id = 1; // YELLOW
// Movimento contínuo (enquanto segura)
let move_speed = 2;
if self.pad.up.down { player.y -= move_speed; }
if self.pad.down.down { player.y += move_speed; }
if self.pad.left.down { player.x -= move_speed; }
if self.pad.right.down { player.x += move_speed; }
// Trigger (apenas no frame que apertou)
if self.pad.a.pressed {
player.tile.palette_id = 4;
}
// Exemplo de uso do released
if self.pad.start.released {
// Se soltar o Start, podemos pausar algo futuramente
}
// // Post-FX Fade Pulsante
// let pulse = (self.frame_index / 4) % 64;

View File

@ -9,17 +9,19 @@
pub struct Color(pub u16);
impl Color {
pub const INDIGO: Self = Self::rgb(32, 32, 64);
pub const GRAY: Self = Self::rgb(64, 64, 64);
pub const BLACK: Self = Self::rgb(0, 0, 0); // 0x0000
pub const WHITE: Self = Self::rgb(255, 255, 255); // 0xFFFF
pub const RED: Self = Self::rgb(255, 0, 0); // 0xF800
pub const GREEN: Self = Self::rgb(0, 255, 0); // 0x07E0
pub const BLUE: Self = Self::rgb(0, 0, 255); // 0x001F
pub const YELLOW: Self = Self::rgb(255, 255, 0); // 0xFFE0
pub const CYAN: Self = Self::rgb(0, 255, 255); // 0x07FF
pub const ORANGE: Self = Self::rgb(255, 128, 0);
pub const INDIGO: Self = Self::rgb(75, 0, 130);
pub const GRAY: Self = Self::rgb(128, 128, 128);
pub const CYAN: Self = Self::rgb(0, 255, 255); // 0x07FF
pub const MAGENTA: Self = Self::rgb(255, 0, 255); // 0xF81F
pub const COLOR_KEY: Self = Self::MAGENTA;
pub const TRANSPARENT: Self = Self::MAGENTA;
/// Extrai canais já na faixa nativa do RGB565:
/// R: 0..31, G: 0..63, B: 0..31

View File

@ -7,11 +7,11 @@ pub struct InputSignals {
pub right_signal: bool,
pub a_signal: bool,
pub d_signal: bool,
pub w_signal: bool,
pub s_signal: bool,
pub q_signal: bool,
pub e_signal: bool,
pub b_signal: bool,
pub x_signal: bool,
pub y_signal: bool,
pub l_signal: bool,
pub r_signal: bool,
pub start_signal: bool,
pub select_signal: bool,

View File

@ -9,11 +9,11 @@ pub struct Pad {
pub right: Button,
pub a: Button, // ps: square
pub d: Button, // ps: circle
pub w: Button, // ps: triangle
pub s: Button, // ps: cross
pub q: Button, // ps: R
pub e: Button, // ps: L
pub b: Button, // ps: circle
pub x: Button, // ps: triangle
pub y: Button, // ps: cross
pub l: Button, // ps: R
pub r: Button, // ps: L
pub start: Button,
pub select: Button,
@ -27,11 +27,11 @@ impl Pad {
self.right.begin_frame(signals.right_signal);
self.a.begin_frame(signals.a_signal);
self.d.begin_frame(signals.d_signal);
self.w.begin_frame(signals.w_signal);
self.s.begin_frame(signals.s_signal);
self.q.begin_frame(signals.q_signal);
self.e.begin_frame(signals.e_signal);
self.b.begin_frame(signals.b_signal);
self.x.begin_frame(signals.x_signal);
self.y.begin_frame(signals.y_signal);
self.l.begin_frame(signals.l_signal);
self.r.begin_frame(signals.r_signal);
self.start.begin_frame(signals.start_signal);
self.select.begin_frame(signals.select_signal);

View File

@ -150,11 +150,11 @@ impl ApplicationHandler for PrometeuApp {
// A/B (troque depois como quiser)
KeyCode::KeyA => self.input_signals.a_signal = is_down,
KeyCode::KeyD => self.input_signals.d_signal = is_down,
KeyCode::KeyW => self.input_signals.w_signal = is_down,
KeyCode::KeyS => self.input_signals.s_signal = is_down,
KeyCode::KeyQ => self.input_signals.q_signal = is_down,
KeyCode::KeyE => self.input_signals.e_signal = is_down,
KeyCode::KeyD => self.input_signals.b_signal = is_down,
KeyCode::KeyW => self.input_signals.x_signal = is_down,
KeyCode::KeyS => self.input_signals.y_signal = is_down,
KeyCode::KeyQ => self.input_signals.l_signal = is_down,
KeyCode::KeyE => self.input_signals.r_signal = is_down,
KeyCode::KeyZ => self.input_signals.start_signal = is_down,
KeyCode::ShiftLeft | KeyCode::ShiftRight => self.input_signals.select_signal = is_down,