Skip to content

Commit adfa11c

Browse files
committed
warning抑制
1 parent c5eb6a4 commit adfa11c

File tree

6 files changed

+95
-91
lines changed

6 files changed

+95
-91
lines changed

.circleci/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
- run:
2323
name: build
2424
command: cargo build
25+
- run:
26+
name: build desktop
27+
command: cd desktop && cargo build
2528
- run:
2629
name: test
2730
command: cd test && cargo test
@@ -31,6 +34,10 @@ jobs:
3134
name: build release
3235
command: cargo build --release
3336
when: always
37+
- run:
38+
name: build desktop release
39+
command: cd desktop && cargo build --release
40+
when: always
3441
- run:
3542
name: test release
3643
command: cd test && cargo test --release

desktop/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn main() {
114114
// エミュを進める
115115
let mut total_cycle: usize = 0;
116116
while total_cycle < cycle_for_draw_once {
117-
let cpu_cycle = usize::from(cpu.step(&mut cpu_sys, &ppu));
117+
let cpu_cycle = usize::from(cpu.step(&mut cpu_sys));
118118
ppu.step(cpu_cycle, &mut cpu, &mut cpu_sys, &mut video_sys, &mut fb);
119119
total_cycle = total_cycle + cpu_cycle;
120120
}

src/apu.rs

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::cpu::*;
2-
use super::system::*;
32

43
#[derive(Copy, Clone)]
54
pub enum PulseDutyCycle {
@@ -13,74 +12,74 @@ pub enum PulseDutyCycle {
1312
pub struct PulseSound {
1413
// $4000 / $4004
1514
/// Duty Cycleを設定する
16-
pub dutyCycle: PulseDutyCycle,
15+
pub duty_cycle: PulseDutyCycle,
1716
/// 再生時間カウンタ有効
18-
pub isLengthCounterHalt: bool,
17+
pub is_length_counter_halt: bool,
1918
/// 音響選択
20-
pub isConstantVolume: bool,
19+
pub is_constant_volume: bool,
2120
/// 音量値 4bit
2221
pub volume: u8,
2322

2423
// $4001 / $4005
2524
/// 周波数スイープ有効
26-
pub isSweepEnable: bool,
25+
pub is_sweep_enable: bool,
2726
/// 周波数スイープ値
28-
pub sweepPeriod: u8,
27+
pub sweep_period: u8,
2928
/// 周波数スイープの方向(add/sub)
30-
pub isSweepNegative: bool,
29+
pub is_sweep_negative: bool,
3130
/// 周波数範囲
32-
pub sweepShift: u8,
31+
pub sweep_shift: u8,
3332

3433
// $4002, $4003 / $4006, $4007
3534
/// 周波数
36-
pub timerValue: u16,
35+
pub timer_value: u16,
3736
/// 再生時間
38-
pub lengthCounterLoad: u8,
37+
pub length_counter_load: u8,
3938
}
4039
impl Default for PulseSound {
4140
fn default() -> Self {
4241
Self {
43-
dutyCycle: PulseDutyCycle::Duty12_5,
44-
isLengthCounterHalt: false,
45-
isConstantVolume: false,
42+
duty_cycle: PulseDutyCycle::Duty12_5,
43+
is_length_counter_halt: false,
44+
is_constant_volume: false,
4645
volume: 0,
47-
isSweepEnable: false,
48-
sweepPeriod: 0,
49-
isSweepNegative: false,
50-
sweepShift: 0,
51-
timerValue: 0,
52-
lengthCounterLoad: 0,
46+
is_sweep_enable: false,
47+
sweep_period: 0,
48+
is_sweep_negative: false,
49+
sweep_shift: 0,
50+
timer_value: 0,
51+
length_counter_load: 0,
5352
}
5453
}
5554
}
5655

5756
impl PulseSound {
5857
pub fn get_freq(&self) -> u32 {
59-
CPU_FREQ / (16 * (u32::from(self.timerValue) + 1))
58+
CPU_FREQ / (16 * (u32::from(self.timer_value) + 1))
6059
}
6160
}
6261

6362
#[derive(Copy, Clone)]
6463
pub struct TriangleSound {
6564
// $4008
6665
/// 再生時間カウンタ有効
67-
pub isLengthCounterHalt: bool,
66+
pub is_length_counter_halt: bool,
6867
/// 再生時間カウンタ値
69-
pub counterLoad: u8,
68+
pub counter_load: u8,
7069
// $400a, $400b
7170
/// 周波数
72-
pub timerValue: u16,
71+
pub timer_value: u16,
7372
/// 再生時間
74-
pub lengthCounterLoad: u8,
73+
pub length_counter_load: u8,
7574
}
7675

7776
impl Default for TriangleSound {
7877
fn default() -> Self {
7978
Self {
80-
isLengthCounterHalt: false,
81-
counterLoad: 0,
82-
timerValue: 0,
83-
lengthCounterLoad: 0,
79+
is_length_counter_halt: false,
80+
counter_load: 0,
81+
timer_value: 0,
82+
length_counter_load: 0,
8483
}
8584
}
8685
}
@@ -89,30 +88,30 @@ impl Default for TriangleSound {
8988
pub struct NoiseSound {
9089
// $400c
9190
/// 再生時間カウンタ有効
92-
pub isLengthCounterHalt: bool,
91+
pub is_length_counter_halt: bool,
9392
/// 音響選択
94-
pub isConstantVolume: bool,
93+
pub is_constant_volume: bool,
9594
/// 音量値 4bit
9695
pub volume: u8,
9796
// $400E
9897
/// ノイズの種類
99-
pub isNoiseTypeLoop: bool,
98+
pub is_noise_type_loop: bool,
10099
/// 再生時間カウンタ値
101-
pub noisePeriod: u8,
100+
pub noise_period: u8,
102101
// $400f
103102
/// 再生時間
104-
pub lengthCounterLoad: u8,
103+
pub length_counter_load: u8,
105104
}
106105

107106
impl Default for NoiseSound {
108107
fn default() -> Self {
109108
Self {
110-
isLengthCounterHalt: false,
111-
isConstantVolume: false,
109+
is_length_counter_halt: false,
110+
is_constant_volume: false,
112111
volume: 0,
113-
isNoiseTypeLoop: false,
114-
noisePeriod: 0,
115-
lengthCounterLoad: 0,
112+
is_noise_type_loop: false,
113+
noise_period: 0,
114+
length_counter_load: 0,
116115
}
117116
}
118117
}
@@ -121,54 +120,56 @@ impl Default for NoiseSound {
121120
pub struct DmcSound {
122121
// $4010
123122
/// Loop時に割り込み有効
124-
pub isIrqEnable: bool,
123+
pub is_irq_enable: bool,
125124
/// ループ有効
126-
pub isLoopEnable: bool,
125+
pub is_loop_enable: bool,
127126
/// サンプルレートビット 4bit
128127
pub frequency: u8,
129128
// $4011
130129
/// 再生時間
131-
pub loadCounter: u8,
130+
pub load_counter: u8,
132131
// $4012
133132
/// 読み込み先アドレス
134133
/// $C000-FFFFを参照するので 11AAAAAA-AA000000
135-
pub sampleAddress: u8,
134+
pub sample_addr: u8,
136135
// $4013
137136
/// ループに使うデータ量
138137
/// 0000LLLL, LLLL0001
139-
pub sampleLength: u8,
138+
pub sample_length: u8,
140139
}
141140

142141
impl Default for DmcSound {
143142
fn default() -> Self {
144143
Self {
145-
isIrqEnable: false,
146-
isLoopEnable: false,
144+
is_irq_enable: false,
145+
is_loop_enable: false,
147146
frequency: 0,
148-
loadCounter: 0,
149-
sampleAddress: 0,
150-
sampleLength: 0,
147+
load_counter: 0,
148+
sample_addr: 0,
149+
sample_length: 0,
151150
}
152151
}
153152
}
154153

155154
pub struct Apu {
156155
/// Frame Sequencer、CPUサイクルに連動して加算 11bit
157-
pub frameSeqCounter: u16,
156+
pub frame_seq_counter: u16,
158157
}
159158
impl Default for Apu {
160159
fn default() -> Self {
161-
Self { frameSeqCounter: 0 }
160+
Self { frame_seq_counter: 0 }
162161
}
163162
}
164163

165164
impl Apu {
166-
/// FrameSe
165+
/// FrameSeq
166+
/// TODO: 実装
167+
#[allow(dead_code)]
167168
fn increment_seq(&mut self, cpu_cyc: u8) {
168-
self.frameSeqCounter = (self.frameSeqCounter + u16::from(cpu_cyc)) & 0x03ff; // 11bit
169+
self.frame_seq_counter = (self.frame_seq_counter + u16::from(cpu_cyc)) & 0x03ff; // 11bit
169170
}
170171
/// APUの処理を進めます
171-
pub fn step(&mut self, cpu: &mut Cpu, cpu_cyc: u8) {
172+
pub fn step(&mut self, _cpu: &mut Cpu, _cpu_cyc: u8) {
172173
// TODO:がんばる
173174

174175
}

src/cpu_instruction.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::cpu::*;
22
use super::interface::SystemBus;
3-
use super::ppu::Ppu; // TODO: 削除
43
use super::system::System;
54

65
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
@@ -557,8 +556,7 @@ impl Cpu {
557556
/// 命令を実行します
558557
/// ret: cycle数
559558
/// http://obelisk.me.uk/6502/reference.html
560-
// TODO: debug printようにppu借りる
561-
pub fn step(&mut self, system: &mut System, ppu: &Ppu) -> u8 {
559+
pub fn step(&mut self, system: &mut System) -> u8 {
562560
// 命令がおいてあるところのaddress
563561
let inst_pc = self.pc;
564562
let inst_code = self.fetch_u8(system);

src/system_apu_reg.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,27 @@ impl System {
3030
APU_PULSE_2_OFFSET
3131
};
3232
// 順番に読んで値を決めるだけ
33-
dst.dutyCycle = match (self.io_reg[base_offset + 0] >> 6) & 0x03 {
33+
dst.duty_cycle = match (self.io_reg[base_offset + 0] >> 6) & 0x03 {
3434
0 => PulseDutyCycle::Duty12_5,
3535
1 => PulseDutyCycle::Duty25_0,
3636
2 => PulseDutyCycle::Duty50_0,
3737
3 => PulseDutyCycle::Duty75_0,
38-
_ => panic!("invalid pulse dutyCycle: {}", self.io_reg[base_offset + 0]),
38+
_ => panic!("invalid pulse duty_cycle: {}", self.io_reg[base_offset + 0]),
3939
};
4040
// $4000 DDLCVVVV
41-
dst.isLengthCounterHalt = (self.io_reg[base_offset + 0] & 0x20) == 0x20;
42-
dst.isConstantVolume = (self.io_reg[base_offset + 0] & 0x10) == 0x10;
43-
dst.volume = self.io_reg[base_offset + 0] & 0x0f;
41+
dst.is_length_counter_halt = (self.io_reg[base_offset + 0] & 0x20) == 0x20;
42+
dst.is_constant_volume = (self.io_reg[base_offset + 0] & 0x10) == 0x10;
43+
dst.volume = self.io_reg[base_offset + 0] & 0x0f;
4444
// $4001 EPPPNSSS
45-
dst.isSweepEnable = (self.io_reg[base_offset + 1] & 0x80) == 0x80;
46-
dst.sweepPeriod = (self.io_reg[base_offset + 1] & 0x70) >> 4;
47-
dst.isSweepNegative = (self.io_reg[base_offset + 1] & 0x04) == 0x04;
48-
dst.sweepShift = self.io_reg[base_offset + 1] & 0x07;
45+
dst.is_sweep_enable = (self.io_reg[base_offset + 1] & 0x80) == 0x80;
46+
dst.sweep_period = (self.io_reg[base_offset + 1] & 0x70) >> 4;
47+
dst.is_sweep_negative = (self.io_reg[base_offset + 1] & 0x04) == 0x04;
48+
dst.sweep_shift = self.io_reg[base_offset + 1] & 0x07;
4949
// $4002 TTTTTTTT(timer lower)
5050
// $4003 LLLLLTTT(timer Upper)
51-
dst.timerValue = u16::from(self.io_reg[base_offset + 2])
52-
| (u16::from(self.io_reg[base_offset + 3] & 0x07) << 8);
53-
dst.lengthCounterLoad = (self.io_reg[base_offset + 3] & 0xf8) >> 3;
51+
dst.timer_value = u16::from(self.io_reg[base_offset + 2])
52+
| (u16::from(self.io_reg[base_offset + 3] & 0x07) << 8);
53+
dst.length_counter_load = (self.io_reg[base_offset + 3] & 0xf8) >> 3;
5454

5555
Some(dst)
5656
}
@@ -64,13 +64,13 @@ impl System {
6464

6565
let mut dst = TriangleSound::default();
6666
// $4008 CRRRRRRRR
67-
dst.isLengthCounterHalt = (self.io_reg[APU_TRIANGLE_OFFSET + 0] & 0x80) == 0x80;
68-
dst.counterLoad = self.io_reg[APU_TRIANGLE_OFFSET + 0] & 0x7f;
67+
dst.is_length_counter_halt = (self.io_reg[APU_TRIANGLE_OFFSET + 0] & 0x80) == 0x80;
68+
dst.counter_load = self.io_reg[APU_TRIANGLE_OFFSET + 0] & 0x7f;
6969
// $400a TTTTTTTT(timer lower)
7070
// $400b LLLLLTTT(timer upper)
71-
dst.timerValue = u16::from(self.io_reg[APU_TRIANGLE_OFFSET + 2])
72-
| (u16::from(self.io_reg[APU_TRIANGLE_OFFSET + 3] & 0x07) << 8);
73-
dst.lengthCounterLoad = (self.io_reg[APU_TRIANGLE_OFFSET + 3] & 0xf8) >> 3;
71+
dst.timer_value = u16::from(self.io_reg[APU_TRIANGLE_OFFSET + 2])
72+
| (u16::from(self.io_reg[APU_TRIANGLE_OFFSET + 3] & 0x07) << 8);
73+
dst.length_counter_load = (self.io_reg[APU_TRIANGLE_OFFSET + 3] & 0xf8) >> 3;
7474

7575
Some(dst)
7676
}
@@ -83,14 +83,14 @@ impl System {
8383
}
8484
let mut dst = NoiseSound::default();
8585
// $400c --LCVVVV
86-
dst.isLengthCounterHalt = (self.io_reg[APU_NOISE_OFFSET + 0] & 0x20) == 0x20;
87-
dst.isConstantVolume = (self.io_reg[APU_NOISE_OFFSET + 0] & 0x10) == 0x10;
88-
dst.volume = self.io_reg[APU_NOISE_OFFSET + 0] & 0x0f;
86+
dst.is_length_counter_halt = (self.io_reg[APU_NOISE_OFFSET + 0] & 0x20) == 0x20;
87+
dst.is_constant_volume = (self.io_reg[APU_NOISE_OFFSET + 0] & 0x10) == 0x10;
88+
dst.volume = self.io_reg[APU_NOISE_OFFSET + 0] & 0x0f;
8989
// $400E L---PPPP
90-
dst.isNoiseTypeLoop = (self.io_reg[APU_NOISE_OFFSET + 2] & 0x80) == 0x80;
91-
dst.noisePeriod = self.io_reg[APU_NOISE_OFFSET + 2] & 0x0f;
90+
dst.is_noise_type_loop = (self.io_reg[APU_NOISE_OFFSET + 2] & 0x80) == 0x80;
91+
dst.noise_period = self.io_reg[APU_NOISE_OFFSET + 2] & 0x0f;
9292
// $400F LLLLL---
93-
dst.lengthCounterLoad = (self.io_reg[APU_NOISE_OFFSET + 3] & 0xf8) >> 3;
93+
dst.length_counter_load = (self.io_reg[APU_NOISE_OFFSET + 3] & 0xf8) >> 3;
9494

9595
Some(dst)
9696
}
@@ -103,15 +103,15 @@ impl System {
103103
}
104104
let mut dst = DmcSound::default();
105105
// $4010 IL--RRRR
106-
dst.isIrqEnable = (self.io_reg[APU_DMC_OFFSET + 0] & 0x80) == 0x80;
107-
dst.isLoopEnable = (self.io_reg[APU_DMC_OFFSET + 0] & 0x40) == 0x40;
108-
dst.frequency = self.io_reg[APU_DMC_OFFSET + 0] & 0x0f;
106+
dst.is_irq_enable = (self.io_reg[APU_DMC_OFFSET + 0] & 0x80) == 0x80;
107+
dst.is_loop_enable = (self.io_reg[APU_DMC_OFFSET + 0] & 0x40) == 0x40;
108+
dst.frequency = self.io_reg[APU_DMC_OFFSET + 0] & 0x0f;
109109
// $4011 -DDDDDDD
110-
dst.loadCounter = self.io_reg[APU_DMC_OFFSET + 1] & 0x7f;
110+
dst.load_counter = self.io_reg[APU_DMC_OFFSET + 1] & 0x7f;
111111
// $4012 Sample Address
112-
dst.loadCounter = self.io_reg[APU_DMC_OFFSET + 2];
112+
dst.sample_addr = self.io_reg[APU_DMC_OFFSET + 2];
113113
// $4013 Sample Length
114-
dst.loadCounter = self.io_reg[APU_DMC_OFFSET + 3];
114+
dst.sample_length = self.io_reg[APU_DMC_OFFSET + 3];
115115

116116
Some(dst)
117117
}

0 commit comments

Comments
 (0)