Skip to content

Commit 2022a1e

Browse files
committed
一部処理の見直しと本文に合わせて処理内容を変更した。
1 parent 013bfd1 commit 2022a1e

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/font_def.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//
55

66
// 8 x 16のフォントデータ
7-
#[allow(unused_imports)]
87
pub static FONT_DATAS: [[u8; 16]; 256] = [
98
[0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0],
109
[0x0,0x0,0x38,0x44,0x82,0xaa,0xaa,0x82,0x82,0xaa,0x92,0x44,0x38,0x0,0x0,0x0],

src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,27 @@ pub extern "C" fn entry() {
2222
let graphics: Graphics = Graphics::new();
2323

2424
// rectangle
25-
graphics.draw_box(20, 20, 100, 100, &RGB::light_red());
26-
graphics.draw_box(70, 50, 100, 100, &RGB::light_green());
27-
graphics.draw_box(120, 80, 100, 100, &RGB::light_blue());
25+
graphics.draw_box(0, 0, 240, 160, &RGB::dark_green());
2826

2927
// circle
3028
let radius:u16 = 20;
31-
graphics.draw_circle(graphics.width() - (radius + 1), (radius + 1), radius, &RGB::light_yellow());
29+
graphics.draw_circle(graphics.width() - (radius + 1),
30+
(radius + 1),
31+
radius,
32+
&RGB::white());
3233

3334
// character
34-
graphics.draw_string("Hello, World!", 0, 0, &RGB::white());
35+
graphics.draw_string("Hello, World!", 10, 10, &RGB::white());
3536

3637
loop {}
3738
}
3839

3940
fn init_graphic() {
4041
let ioram_address: u32 = 0x04000000;
42+
let video_mode: *mut u8 = ioram_address as *mut u8;
43+
let bg: *mut u8 = (ioram_address + 1) as *mut u8;
4144
unsafe {
42-
let video_mode: *mut u8 = ioram_address as *mut u8;
4345
*video_mode = 0x03; // mode 3
44-
let bg: *mut u8 = (ioram_address + 1) as *mut u8;
4546
*bg = 0x04; // BG2
4647
}
4748
}

src/rgb.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,62 +33,62 @@ impl RGBDef for RGB {
3333
}
3434

3535
fn light_red() -> RGB {
36-
return RGB { r: 0xFF, g: 0x00, b: 0x00,};
36+
return RGB { r: 0x1F, g: 0x00, b: 0x00,};
3737
}
3838

3939
fn light_green() -> RGB {
40-
return RGB { r: 0x00, g: 0xFF, b: 0x00,};
40+
return RGB { r: 0x00, g: 0x1F, b: 0x00,};
4141
}
4242

4343
fn light_yellow() -> RGB {
44-
return RGB { r: 0xFF, g: 0xFF, b: 0x00,};
44+
return RGB { r: 0x1F, g: 0x1F, b: 0x00,};
4545
}
4646

4747
fn light_blue() -> RGB {
48-
return RGB { r: 0x00, g: 0x00, b: 0xFF,};
48+
return RGB { r: 0x00, g: 0x00, b: 0x1F,};
4949
}
5050

5151
fn light_purple() -> RGB {
52-
return RGB { r: 0xFF, g: 0x00, b: 0xFF,};
52+
return RGB { r: 0x1F, g: 0x00, b: 0x1F,};
5353
}
5454

5555
fn light_pale_blue() -> RGB {
56-
return RGB { r: 0x00, g: 0xFF, b: 0xFF,};
56+
return RGB { r: 0x00, g: 0x1F, b: 0x1F,};
5757
}
5858

5959
fn white() -> RGB {
60-
return RGB { r: 0xFF, g: 0xFF, b: 0xFF,};
60+
return RGB { r: 0x1F, g: 0x1F, b: 0x1F,};
6161
}
6262

6363
fn light_gray() -> RGB {
64-
return RGB { r: 0xC6, g: 0xC6, b: 0xC6,};
64+
return RGB { r: 0x0F, g: 0x0F, b: 0x0F,};
6565
}
6666

6767
fn dark_red() -> RGB {
68-
return RGB { r: 0x84, g: 0x00, b: 0x00,};
68+
return RGB { r: 0x0F, g: 0x00, b: 0x00,};
6969
}
7070

7171
fn dark_green() -> RGB {
72-
return RGB { r: 0x00, g: 0x84, b: 0x00,};
72+
return RGB { r: 0x00, g: 0x0F, b: 0x00,};
7373
}
7474

7575
fn dark_yellow() -> RGB {
76-
return RGB { r: 0x84, g: 0x84, b: 0x00,};
76+
return RGB { r: 0x0F, g: 0x0F, b: 0x00,};
7777
}
7878

7979
fn dark_blue() -> RGB {
80-
return RGB { r: 0x00, g: 0x00, b: 0x84,};
80+
return RGB { r: 0x00, g: 0x00, b: 0x0F,};
8181
}
8282

8383
fn dark_purple() -> RGB {
84-
return RGB { r: 0x84, g: 0x00, b: 0x84,};
84+
return RGB { r: 0x0F, g: 0x00, b: 0x0F,};
8585
}
8686

8787
fn dark_pale_blue() -> RGB {
88-
return RGB { r: 0x00, g: 0x84, b: 0x84,};
88+
return RGB { r: 0x0F, g: 0x0F, b: 0x0F,};
8989
}
9090

9191
fn dark_gray() -> RGB {
92-
return RGB { r: 0x84, g: 0x84, b: 0x84,};
92+
return RGB { r: 0x07, g: 0x07, b: 0x07,};
9393
}
9494
}

0 commit comments

Comments
 (0)