Skip to content

Commit da2ebda

Browse files
committed
More map tests
1 parent 09aa949 commit da2ebda

5 files changed

Lines changed: 90 additions & 22 deletions

File tree

p8rs-tests/carts/gfx/map/basic.p8

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,73 @@ map(4, 4, 112, 112, 4, 4)
2424
map(4, 0, 112, -16, 4, 4)
2525
p8rs.test_scr("clipping");
2626

27+
cls()
28+
map()
29+
p8rs.test_scr("no args");
30+
31+
cls()
32+
map(8)
33+
p8rs.test_scr("one arg");
34+
35+
cls()
36+
map(4, 2)
37+
p8rs.test_scr("two arg");
38+
39+
cls()
40+
map(4, 4, 16)
41+
map(0, 4, 30, 30)
42+
map(0, 0, 40, 40, 4)
43+
map(0, 0, 50, 50, 8, 8)
44+
p8rs.test_scr("less args");
45+
46+
cls()
47+
camera(-63, -65)
48+
map(0, 0, -56, -56, 4, 4)
49+
map(0, 4, -56, 24, 4, 4)
50+
map(4, 4, 24, 24, 4, 4)
51+
map(4, 0, 24, -56, 4, 4)
52+
map(8, 8, -56, -20, 14, 5)
53+
camera()
54+
p8rs.test_scr("camera");
55+
56+
cls()
57+
clip(26, 34, 68, 60)
58+
camera(-63, -65)
59+
map(0, 0, -56, -56, 4, 4)
60+
map(0, 4, -56, 24, 4, 4)
61+
map(4, 4, 24, 24, 4, 4)
62+
map(4, 0, 24, -56, 4, 4)
63+
map(8, 8, -56, -20, 14, 5)
64+
camera()
65+
clip()
66+
p8rs.test_scr("clip");
67+
68+
cls()
69+
pal(4, 0x23)
70+
pal(2, 0x34)
71+
pal(4, 0x53, 2)
72+
pal(5, 0x48, 2)
73+
palt(4, false)
74+
fillp(0b0011001111001100.000)
75+
map(0, 0, 24, 48, 2, 2)
76+
fillp(0b0011001111001100.001)
77+
map(2, 0, 48, 48, 2, 2)
78+
fillp(0b0011001111001100.010)
79+
map(4, 0, 72, 48, 2, 2)
80+
fillp(0b0011001111001100.011)
81+
map(8, 0, 96, 48, 2, 2)
82+
fillp(0b0011001111001100.100)
83+
map(0, 2, 24, 72, 2, 2)
84+
fillp(0b0011001111001100.101)
85+
map(2, 2, 48, 72, 2, 2)
86+
fillp(0b0011001111001100.110)
87+
map(4, 2, 72, 72, 2, 2)
88+
fillp(0b0011001111001100.111)
89+
map(8, 2, 96, 72, 2, 2)
90+
fillp()
91+
p8rs.test_scr("pattern flags");
92+
93+
2794
local layers = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 0b01010101, 0b10101010, 0b00110011, 0b00001111, 0b11111111 }
2895
for _, l in ipairs(layers) do
2996
cls()

p8rs-tests/carts/gfx/map/width.p8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function test(width, base)
1212
map(-2, height - 6, 0, 64, 8, 8)
1313
map(width - 6, height - 6, 64, 64, 8, 8)
1414
map(width - 6, -2, 64, 0, 8, 8)
15-
p8rs.test_scr(width .. "x" .. height)
15+
p8rs.test_scr(width .. "X" .. height)
1616
end
1717

1818
for width = 0x01,0xff do

p8rs-tests/carts/gfx/map/width_ex.p8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function test(width, base)
1212
map(-2, height - 6, 0, 64, 8, 8)
1313
map(width - 6, height - 6, 64, 64, 8, 8)
1414
map(width - 6, -2, 64, 0, 8, 8)
15-
p8rs.test_scr(width .. "x" .. height)
15+
p8rs.test_scr(width .. "X" .. height)
1616
end
1717

1818
for width = 0x01,0xff do

p8rs-tests/carts/gfx/rect.p8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ rect(0, 80, 64, 96, 80, 4)
9494
fillp(0b0011001111001100.111)
9595
rect(0, 64, 64, 80, 80, 4)
9696
fillp()
97-
p8rs.test_scr("Pattern flags");
97+
p8rs.test_scr("pattern flags");

p8rs/src/vm/memory/mod.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ impl Memory {
3232

3333
pub fn sprites(&mut self) -> Sprites<'_> {
3434
// TODO: Handle map conflicts
35+
// TODO: https://www.lexaloffle.com/bbs/?tid=50158 ?
3536
let base_addr = match self.machine_state().sprite_addr_map().get() {
3637
0x00 => 0x0000,
3738
0x60 => 0x6000,
@@ -67,6 +68,25 @@ impl Memory {
6768
}
6869
}
6970

71+
pub fn screen(&mut self) -> Screen<'_> {
72+
// TODO: Handle map conflicts
73+
let base_addr = match self.machine_state().screen_addr_map().get() {
74+
0x00 => 0x0000,
75+
0x60 => 0x6000,
76+
0x80 => 0x8000,
77+
0xa0 => 0xa000,
78+
0xc0 => 0xc000,
79+
0xe0 => 0xe000,
80+
_ => 0x0000,
81+
};
82+
83+
Screen(self.const_slice(base_addr))
84+
}
85+
86+
pub fn painter(&mut self) -> Painter<'_> {
87+
Painter::new(self)
88+
}
89+
7090
pub fn sprite_flags(&mut self) -> SpriteFlags<'_> {
7191
SpriteFlags(self.const_slice(0x3000))
7292
}
@@ -91,25 +111,6 @@ impl Memory {
91111
self.const_slice(0x5f80)
92112
}
93113

94-
pub fn screen(&mut self) -> Screen<'_> {
95-
// TODO: Handle map conflicts
96-
let base_addr = match self.machine_state().screen_addr_map().get() {
97-
0x00 => 0x0000,
98-
0x60 => 0x6000,
99-
0x80 => 0x8000,
100-
0xa0 => 0xa000,
101-
0xc0 => 0xc000,
102-
0xe0 => 0xe000,
103-
_ => 0x0000,
104-
};
105-
106-
Screen(self.const_slice(base_addr))
107-
}
108-
109-
pub fn painter(&mut self) -> Painter<'_> {
110-
Painter::new(self)
111-
}
112-
113114
#[inline(always)]
114115
pub(crate) fn const_slice<const S: usize>(&mut self, base: u16) -> &mut [u8; S] {
115116
(&mut self.0[base as usize..base as usize + S]).try_into().unwrap()

0 commit comments

Comments
 (0)