From 796e8351f3fe1c0802a13a2f0931c047d87500b9 Mon Sep 17 00:00:00 2001 From: lokathor Date: Sat, 15 Oct 2022 16:29:18 -0600 Subject: [PATCH] make mmio use fixed point when appropriate. --- src/mmio.rs | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/mmio.rs b/src/mmio.rs index 249aedf..e9b3c81 100644 --- a/src/mmio.rs +++ b/src/mmio.rs @@ -37,7 +37,7 @@ use crate::{ sound::{ SweepControl, TonePattern, ToneFrequency, WaveBank, WaveLenVolume, WaveFrequency, NoiseLenEnvelope, NoiseFrequency, LeftRightVolume, SoundMix, SoundEnable, SoundBias }, - timers::TimerControl, keys::{KeyInput, KeyControl}, mgba::MgbaMessageLevel, + timers::TimerControl, keys::{KeyInput, KeyControl}, mgba::MgbaMessageLevel, fixed::Fixed, }; // Note(Lokathor): This macro lets us stick each address at the start of the @@ -66,28 +66,31 @@ def_mmio!(0x0400_000A = BG1CNT: VolAddress; "Back def_mmio!(0x0400_000C = BG2CNT: VolAddress; "Background 2 Control"); def_mmio!(0x0400_000E = BG3CNT: VolAddress; "Background 3 Control"); -def_mmio!(0x0400_0010 = BG0HOFS: VolAddress; "Background 0 Horizontal Offset, wrapped to `0..=511`, (text mode)"); -def_mmio!(0x0400_0012 = BG0VOFS: VolAddress; "Background 0 Vertical Offset, wrapped to `0..=511`, (text mode)"); -def_mmio!(0x0400_0014 = BG1HOFS: VolAddress; "Background 1 Horizontal Offset, wrapped to `0..=511`, (text mode)"); -def_mmio!(0x0400_0016 = BG1VOFS: VolAddress; "Background 1 Vertical Offset, wrapped to `0..=511`, (text mode)"); -def_mmio!(0x0400_0018 = BG2HOFS: VolAddress; "Background 2 Horizontal Offset, wrapped to `0..=511`, (text mode)"); -def_mmio!(0x0400_001A = BG2VOFS: VolAddress; "Background 2 Vertical Offset, wrapped to `0..=511`, (text mode)"); -def_mmio!(0x0400_001C = BG3HOFS: VolAddress; "Background 3 Horizontal Offset, wrapped to `0..=511`, (text mode)"); -def_mmio!(0x0400_001E = BG3VOFS: VolAddress; "Background 3 Vertical Offset, wrapped to `0..=511`, (text mode)"); +def_mmio!(0x0400_0010 = BG0HOFS: VolAddress; "Background 0 Horizontal Offset (9-bit, text mode)"); +def_mmio!(0x0400_0012 = BG0VOFS: VolAddress; "Background 0 Vertical Offset (9-bit, text mode)"); -def_mmio!(0x0400_0020 = BG2PA: VolAddress; "Background 2 Param A (affine mode)"); -def_mmio!(0x0400_0022 = BG2PB: VolAddress; "Background 2 Param B (affine mode)"); -def_mmio!(0x0400_0024 = BG2PC: VolAddress; "Background 2 Param C (affine mode)"); -def_mmio!(0x0400_0026 = BG2PD: VolAddress; "Background 2 Param D (affine mode)"); -def_mmio!(0x0400_0028 = BG2X/["BG2X_L", "BG2X_H"]: VolAddress; "Background 2 X Reference Point, 8-bits fractional (affine/bitmap modes)"); -def_mmio!(0x0400_002C = BG2Y/["BG2Y_L", "BG2Y_H"]: VolAddress; "Background 2 Y Reference Point, 8-bits fractional (affine/bitmap modes)"); +def_mmio!(0x0400_0014 = BG1HOFS: VolAddress; "Background 1 Horizontal Offset (9-bit, text mode)"); +def_mmio!(0x0400_0016 = BG1VOFS: VolAddress; "Background 1 Vertical Offset (9-bit, text mode)"); -def_mmio!(0x0400_0030 = BG3PA: VolAddress; "Background 3 Param A (affine mode)"); -def_mmio!(0x0400_0032 = BG3PB: VolAddress; "Background 3 Param B (affine mode)"); -def_mmio!(0x0400_0034 = BG3PC: VolAddress; "Background 3 Param C (affine mode)"); -def_mmio!(0x0400_0036 = BG3PD: VolAddress; "Background 3 Param D (affine mode)"); -def_mmio!(0x0400_0038 = BG3X/["BG3X_L", "BG3X_H"]: VolAddress; "Background 3 X Reference Point, 8-bits fractional (affine/bitmap modes)"); -def_mmio!(0x0400_003C = BG3Y/["BG3Y_L", "BG3Y_H"]: VolAddress; "Background 3 Y Reference Point, 8-bits fractional (affine/bitmap modes)"); +def_mmio!(0x0400_0018 = BG2HOFS: VolAddress; "Background 2 Horizontal Offset (9-bit, text mode)"); +def_mmio!(0x0400_001A = BG2VOFS: VolAddress; "Background 2 Vertical Offset (9-bit, text mode)"); + +def_mmio!(0x0400_001C = BG3HOFS: VolAddress; "Background 3 Horizontal Offset (9-bit, text mode)"); +def_mmio!(0x0400_001E = BG3VOFS: VolAddress; "Background 3 Vertical Offset (9-bit, text mode)"); + +def_mmio!(0x0400_0020 = BG2PA: VolAddress, (), Safe>; "Background 2 Param A (affine mode)"); +def_mmio!(0x0400_0022 = BG2PB: VolAddress, (), Safe>; "Background 2 Param B (affine mode)"); +def_mmio!(0x0400_0024 = BG2PC: VolAddress, (), Safe>; "Background 2 Param C (affine mode)"); +def_mmio!(0x0400_0026 = BG2PD: VolAddress, (), Safe>; "Background 2 Param D (affine mode)"); +def_mmio!(0x0400_0028 = BG2X/["BG2X_L", "BG2X_H"]: VolAddress, (), Safe>; "Background 2 X Reference Point (affine/bitmap modes)"); +def_mmio!(0x0400_002C = BG2Y/["BG2Y_L", "BG2Y_H"]: VolAddress, (), Safe>; "Background 2 Y Reference Point (affine/bitmap modes)"); + +def_mmio!(0x0400_0030 = BG3PA: VolAddress, (), Safe>; "Background 3 Param A (affine mode)"); +def_mmio!(0x0400_0032 = BG3PB: VolAddress, (), Safe>; "Background 3 Param B (affine mode)"); +def_mmio!(0x0400_0034 = BG3PC: VolAddress, (), Safe>; "Background 3 Param C (affine mode)"); +def_mmio!(0x0400_0036 = BG3PD: VolAddress, (), Safe>; "Background 3 Param D (affine mode)"); +def_mmio!(0x0400_0038 = BG3X/["BG3X_L", "BG3X_H"]: VolAddress, (), Safe>; "Background 3 X Reference Point (affine/bitmap modes)"); +def_mmio!(0x0400_003C = BG3Y/["BG3Y_L", "BG3Y_H"]: VolAddress, (), Safe>; "Background 3 Y Reference Point (affine/bitmap modes)"); def_mmio!(0x0400_0040 = WIN0H: VolAddress; "Window 0 Horizontal: high=left, low=(right+1)"); def_mmio!(0x0400_0042 = WIN1H: VolAddress; "Window 1 Horizontal: high=left, low=(right+1)"); @@ -331,7 +334,7 @@ def_mmio!(0x0700_0000 = OBJ_ATTR0: VolSeries()}>; "Object attributes 1."); def_mmio!(0x0700_0004 = OBJ_ATTR2: VolSeries()}>; "Object attributes 2."); -def_mmio!(0x0700_0006 = AFFINE_PARAM_A: VolSeries()}>; "Affine parameters A."); -def_mmio!(0x0700_000E = AFFINE_PARAM_B: VolSeries()}>; "Affine parameters B."); -def_mmio!(0x0700_0016 = AFFINE_PARAM_C: VolSeries()}>; "Affine parameters C."); -def_mmio!(0x0700_001E = AFFINE_PARAM_D: VolSeries()}>; "Affine parameters D."); +def_mmio!(0x0700_0006 = AFFINE_PARAM_A: VolSeries, Safe, Safe, 32, {size_of::<[u16;16]>()}>; "Affine parameters A."); +def_mmio!(0x0700_000E = AFFINE_PARAM_B: VolSeries, Safe, Safe, 32, {size_of::<[u16;16]>()}>; "Affine parameters B."); +def_mmio!(0x0700_0016 = AFFINE_PARAM_C: VolSeries, Safe, Safe, 32, {size_of::<[u16;16]>()}>; "Affine parameters C."); +def_mmio!(0x0700_001E = AFFINE_PARAM_D: VolSeries, Safe, Safe, 32, {size_of::<[u16;16]>()}>; "Affine parameters D.");