Skip to content

Commit

Permalink
Merge pull request #85 from qoda-dev/fix/graphics
Browse files Browse the repository at this point in the history
delete unused test
  • Loading branch information
nkrs-lab authored Apr 12, 2023
2 parents 8e7041b + 1b0138b commit 5ae9f2c
Showing 1 changed file with 0 additions and 99 deletions.
99 changes: 0 additions & 99 deletions src/soc/peripheral/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,103 +1079,4 @@ mod gpu_tests {
assert_eq!(gpu.object_palette_1.color_1, PixelColor::WHITE);
assert_eq!(gpu.object_palette_1.color_0, PixelColor::DARK_GRAY);
}

#[test]
fn test_draw_big_sprite() {
let mut gpu = Gpu::new();

// init GPU
gpu.object_display_enabled = true;
gpu.object_size = ObjectSize::OS8X16;

// init VRAM
// here we're looking for tile at index 0
gpu.write_vram(0x0010, 0x7F);
gpu.write_vram(0x0011, 0xFF);
gpu.write_vram(0x0012, 0xFF);
gpu.write_vram(0x0013, 0xFE);

// set OAM
// set y position
gpu.write_oam(0x0000, 0x10);
// set x position
gpu.write_oam(0x0001, 0x08);
// set tile index
gpu.write_oam(0x0002, 0x01);
// set attributes
gpu.write_oam(0x0003, 0x00);

// draw the line in the frame buffer
gpu.current_line = 0;
gpu.draw_line();
gpu.current_line = 1;
gpu.draw_line();

// check frame buffer
// line 1 * 160 = 160 / 0x00A0
assert_eq!(gpu.frame_buffer[0x0000], PixelColor::DARK_GRAY as u8);
assert_eq!(gpu.frame_buffer[0x00A7], PixelColor::LIGHT_GRAY as u8);

// shift sprite y position for 31 lines down
// set y position
gpu.write_oam(0x0000, 0x2F);

// draw the line in the frame buffer
gpu.current_line = 31;
gpu.draw_line();
gpu.current_line = 32;
gpu.draw_line();

// check frame buffer
// line 31 * 160 = 4960 / 0x1360
assert_eq!(gpu.frame_buffer[0x1360], PixelColor::DARK_GRAY as u8);
// line 32 * 160 = 5120 / 0x1400
assert_eq!(gpu.frame_buffer[0x1407], PixelColor::LIGHT_GRAY as u8);

// shift sprite x position for 3 columns right
// set y position
gpu.write_oam(0x0001, 0x0B);

// draw the line in the frame buffer
gpu.current_line = 31;
gpu.draw_line();
gpu.current_line = 32;
gpu.draw_line();

// check frame buffer
// line 31 * 160 = 4960 / 0x1360
assert_eq!(gpu.frame_buffer[0x1363], PixelColor::DARK_GRAY as u8);
// line 32 * 160 = 5120 / 0x1400
assert_eq!(gpu.frame_buffer[0x140A], PixelColor::LIGHT_GRAY as u8);
}

#[test]
fn test_draw_window() {
let mut gpu = Gpu::new();

// init GPU
gpu.window_display_enabled = true;
gpu.background_display_enabled = true;
gpu.window_tile_map_area = TileMapArea::X9800;
gpu.background_tile_data_area = true;
gpu.current_line = 0; // first line of the second tile row

// init VRAM
// here we're looking for tile at index 0
gpu.write_vram(0x0000, 0x01);
gpu.write_vram(0x0001, 0x00);

// set tile map
// here we're looking for tile at index 0
gpu.write_vram(0x1800, 0x00);

// draw the line in the frame buffer
gpu.window_x_offset = 0;
gpu.draw_line();
assert_eq!(gpu.frame_buffer[0x0000], PixelColor::LIGHT_GRAY as u8);

gpu.window_x_offset = 128;
gpu.draw_line();
assert_eq!(gpu.frame_buffer[0x0080], PixelColor::LIGHT_GRAY as u8);
}
}

0 comments on commit 5ae9f2c

Please sign in to comment.