summaryrefslogtreecommitdiff
path: root/src/devices
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/screen.rs30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/devices/screen.rs b/src/devices/screen.rs
index 02de8b9..ee11f52 100644
--- a/src/devices/screen.rs
+++ b/src/devices/screen.rs
@@ -456,11 +456,12 @@ impl ScreenDevice {
let mut position = self.cursor;
let mut pointer: usize = 0;
- macro_rules! inc_x { ($v:expr) => { position.x = position.x.wrapping_add($v) }; }
- macro_rules! dec_x { ($v:expr) => { position.x = position.x.wrapping_sub($v) }; }
- macro_rules! inc_y { ($v:expr) => { position.y = position.y.wrapping_add($v) }; }
- macro_rules! dec_y { ($v:expr) => { position.y = position.y.wrapping_sub($v) }; }
- macro_rules! plot { () => {
+ macro_rules! for8 { ($block:block) => { for _ in 0..8 { $block } }; }
+ macro_rules! r { ($v:expr) => { position.x = position.x.wrapping_add($v) }; }
+ macro_rules! l { ($v:expr) => { position.x = position.x.wrapping_sub($v) }; }
+ macro_rules! d { ($v:expr) => { position.y = position.y.wrapping_add($v) }; }
+ macro_rules! u { ($v:expr) => { position.y = position.y.wrapping_sub($v) }; }
+ macro_rules! px { () => {
let colour = sprite[pointer];
if !(transparent && colour == 0) {
self.draw_pixel(self.sprite_colours[colour as usize], layer, position);
@@ -468,16 +469,17 @@ impl ScreenDevice {
pointer += 1;
}; }
+
match params & 0x07 {
- 0x00 => { for _ in 0..8 { for _ in 0..8 { plot!(); inc_x!(1); } dec_x!(8); inc_y!(1); } }
- 0x01 => { inc_x!(7); for _ in 0..8 { for _ in 0..8 { plot!(); dec_x!(1); } inc_x!(8); inc_y!(1); } }
- 0x02 => { inc_y!(7); for _ in 0..8 { for _ in 0..8 { plot!(); inc_x!(1); } dec_x!(8); dec_y!(1); } }
- 0x03 => { inc_x!(7); inc_y!(7); for _ in 0..8 { for _ in 0..8 { plot!(); dec_x!(1); } inc_x!(8); dec_y!(1); } }
-
- 0x04 => { for _ in 0..8 { for _ in 0..8 { plot!(); inc_y!(1); } dec_y!(8); inc_x!(1); } }
- 0x05 => { inc_x!(7); for _ in 0..8 { for _ in 0..8 { plot!(); inc_y!(1); } dec_y!(8); dec_x!(1); } }
- 0x06 => { inc_y!(7); for _ in 0..8 { for _ in 0..8 { plot!(); dec_y!(1); } inc_y!(8); inc_x!(1); } }
- 0x07 => { inc_x!(7); inc_y!(7); for _ in 0..8 { for _ in 0..8 { plot!(); dec_y!(1); } inc_y!(8); dec_x!(1); } }
+ 0 => { for8!{{ for8!{{ px!(); r!(1); }} l!(8); d!(1); }} }
+ 1 => { r!(7); for8!{{ for8!{{ px!(); l!(1); }} r!(8); d!(1); }} }
+ 2 => { d!(7); for8!{{ for8!{{ px!(); r!(1); }} l!(8); u!(1); }} }
+ 3 => { r!(7); d!(7); for8!{{ for8!{{ px!(); l!(1); }} r!(8); u!(1); }} }
+
+ 4 => { for8!{{ for8!{{ px!(); d!(1); }} u!(8); r!(1); }} }
+ 5 => { r!(7); for8!{{ for8!{{ px!(); d!(1); }} u!(8); l!(1); }} }
+ 6 => { d!(7);for8!{{ for8!{{ px!(); u!(1); }} d!(8); r!(1); }} }
+ 7 => { r!(7); d!(7); for8!{{ for8!{{ px!(); u!(1); }} d!(8); l!(1); }} }
_ => unreachable!(),
}