Skip to content

Commit

Permalink
Add an example for directly modifying pixels on mode 3 realtime durin…
Browse files Browse the repository at this point in the history
…g game vs loading a pixel array directly. (#188)

* Create mode3_realtime_example.r

* Rename mode3_realtime_example.r to mode3_realtime_example.rs

* Update mode3_realtime_example.rs

* Update mode3_realtime_example.rs

* Update mode3_realtime_example.rs
  • Loading branch information
EvanTheProgrammer authored Nov 16, 2023
1 parent a215c26 commit a2d760d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/mode3_realtime_example.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Made by Evan Goemer
* Discord: @evangoemer
*/

#![no_std]
#![no_main]

use gba::prelude::*;

#[panic_handler]
fn panic_handler(_: &core::panic::PanicInfo) -> ! {
loop {}
}

#[no_mangle]
fn main() {
DISPCNT.write(
DisplayControl::new().with_video_mode(VideoMode::_3).with_show_bg2(true),
);

let red = 0;
let green = 255;
let blue = 0;

let color = Color::from_rgb(red, green, blue);

for y in 0..160 {
for x in 0..240 {
VIDEO3_VRAM.index(x, y).write(color);
}
}
}

0 comments on commit a2d760d

Please sign in to comment.