|
|
|
@ -1,11 +1,45 @@
@@ -1,11 +1,45 @@
|
|
|
|
|
#![cfg(todo = "gpu_tev_macros")] |
|
|
|
|
//! `<c3d/texenv.h>`
|
|
|
|
|
//! Definitions for `<c3d/texenv.h>`.
|
|
|
|
|
//! Most of these functions are `static inline` so they don't get generated by `bindgen`.
|
|
|
|
|
|
|
|
|
|
use core::ops::{BitOr, Shl}; |
|
|
|
|
|
|
|
|
|
use super::*; |
|
|
|
|
use libc::c_int; |
|
|
|
|
|
|
|
|
|
use super::*; |
|
|
|
|
|
|
|
|
|
// TODO: why are these two different macros in C?
|
|
|
|
|
|
|
|
|
|
/// Creates a texture combiner source parameter from three sources.
|
|
|
|
|
fn gpu_tevsources<T>(a: T, b: T, c: T) -> T |
|
|
|
|
where |
|
|
|
|
T: BitOr<Output = T> + Shl<u8, Output = T>, |
|
|
|
|
{ |
|
|
|
|
a | b << 4 | c << 8 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Creates a texture combiner operand parameter from three operands.
|
|
|
|
|
fn gpu_tevoperands<T>(a: T, b: T, c: T) -> T |
|
|
|
|
where |
|
|
|
|
T: BitOr<Output = T> + Shl<u8, Output = T>, |
|
|
|
|
{ |
|
|
|
|
a | b << 4 | c << 8 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub unsafe fn C3D_TexEnvInit(env: *mut C3D_TexEnv) { |
|
|
|
|
(*env).srcRgb = gpu_tevsources(ctru_sys::GPU_PREVIOUS, 0, 0) as u16; |
|
|
|
|
(*env).srcAlpha = (*env).srcRgb; |
|
|
|
|
(*env).__bindgen_anon_1.opAll = 0; |
|
|
|
|
(*env).funcRgb = ctru_sys::GPU_REPLACE as u16; |
|
|
|
|
(*env).funcAlpha = (*env).funcRgb; |
|
|
|
|
(*env).color = 0xFFFFFFFF; |
|
|
|
|
(*env).scaleRgb = ctru_sys::GPU_TEVSCALE_1 as u16; |
|
|
|
|
(*env).scaleAlpha = ctru_sys::GPU_TEVSCALE_1 as u16; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: maybe
|
|
|
|
|
|
|
|
|
|
pub unsafe fn C3D_TexEnvSrc(env: *mut C3D_TexEnv, mode: c_int, s1: c_int, s2: c_int, s3: c_int) { |
|
|
|
|
let param = gpu_tevsources!(s1, s2, s3); |
|
|
|
|
let param = gpu_tevsources(s1, s2, s3); |
|
|
|
|
|
|
|
|
|
if mode & C3D_RGB as i32 != 0 { |
|
|
|
|
(*env).srcRgb = param as u16; |
|
|
|
@ -17,14 +51,21 @@ pub unsafe fn C3D_TexEnvSrc(env: *mut C3D_TexEnv, mode: c_int, s1: c_int, s2: c_
@@ -17,14 +51,21 @@ pub unsafe fn C3D_TexEnvSrc(env: *mut C3D_TexEnv, mode: c_int, s1: c_int, s2: c_
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub unsafe fn C3D_TexEnvOp(env: *mut C3D_TexEnv, mode: c_int, o1: c_int, o2: c_int, o3: c_int) { |
|
|
|
|
let param = gpu_tevoperands!(o1, o2, o3); |
|
|
|
|
let param = gpu_tevoperands(o1, o2, o3); |
|
|
|
|
|
|
|
|
|
if mode & C3D_RGB as i32 != 0 { |
|
|
|
|
(*env).opRgb = param as u16; |
|
|
|
|
// (*env).opRgb = param as u16;
|
|
|
|
|
(*env) |
|
|
|
|
.__bindgen_anon_1 |
|
|
|
|
.__bindgen_anon_1 |
|
|
|
|
.set_opRgb(param as u32); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if mode & C3D_Alpha as i32 != 0 { |
|
|
|
|
(*env).opAlpha = param as u16; |
|
|
|
|
(*env) |
|
|
|
|
.__bindgen_anon_1 |
|
|
|
|
.__bindgen_anon_1 |
|
|
|
|
.set_opAlpha(param as u32); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|