-
Notifications
You must be signed in to change notification settings - Fork 0
/
16-14-7.nut
123 lines (111 loc) · 2.53 KB
/
16-14-7.nut
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* bricks.nut
*
* An isometric example of a minecraft like dungeon system
* (C)2024 elmerucr
*/
dofile("16-14-7_data.nut")
offset_x <- 136
offset_y <- 81
function init()
{
for (local i=0; i<sprite.size; i++) {
vpoke(0x10000+i, sprite.data[i])
}
for (local i=0; i<sprite.palette.len(); i++) {
poke(0x1100+i, sprite.palette[i])
}
poke16(0x0a14, 16)
poke16(0x0a16, 21)
poke(0x0a19, 0x01)
poke(0x0a1a, 0x00)
poke(0x0a1b, 0x00)
poke(0x0a1c, 0x20)
poke(0x0a1d, 0x00)
poke(0x0a1e, 0x00)
poke(0x0a1f, 0x03)
/*
* Activate frame done interrupt which happens directly after each
* screen refresh and calls the squirrel frame() function.
*/
poke(0x401, 1)
}
function frame()
{
poke(0x805, 0x01) // target color
poke(0x819, 0xff) // max gamma r
poke(0x81a, 0xff) // max gamma g
poke(0x81b, 0xff) // max gamma b
// vpoke(0xf3e800, 0x05);
// vpoke(0xf3e801, 0x00);
// vpoke(0xf3e802, 0xf0);
// vpoke(0xf3e803, 0x00);
poke(0x803, 0x0) // destination surface = 0x0 = screen
poke(0x801, 4) // clear surface command
poke(0x802,0x1) // src surface = 0x1
poke(0x803,0x0) // dest surface = 0x0
if ((peek(0x580 + 0x41) & 1) != 0) {
// cursor left
offset_x += 1
}
if ((peek(0x580 + 0x44) & 1)!= 0) {
// cursor right
offset_x -= 1
}
if ((peek(0x580 + 0x42) & 1) != 0) {
// cursor up
offset_y += 1
}
if ((peek(0x580 + 0x43) & 1) != 0) {
// cursor down
offset_y -= 1
}
for (local z=0; z<2; z++) {
for (local y=-40; y<40; y++) {
for (local x=-40; x<40; x++) {
local dist = (x*x)+(y*y)
local ry = (81-offset_y)/14
local rx = (-(offset_x-136)/16)
local od = (rx-x)*(rx-x)+(ry-y)*(ry-y)
if (od <= 45) {
poke(0x819, 255)
poke(0x81a, 255)
poke(0x81b, 255)
// poke(0x819, 255-(3*od))
// poke(0x81a, 255-(3*od))
// poke(0x81b, 255-(3*od))
} else if (od <= 65) {
poke(0x819, 255-(3*od))
poke(0x81a, 255-(3*od))
poke(0x81b, 255-(3*od))
} else {
poke(0x819, 0)
poke(0x81a, 0)
poke(0x81b, 0)
}
if (z == 0) {
poke(0x0a1f, 1) // dirt
if (dist < 400) {
poke16(0x0a10, offset_x + (16 * x))
poke16(0x0a12, offset_y + (14 * y) - (7 * z))
poke(0x801, 0x01)
}
} else {
poke(0x0a1f, 0) // stones
if ((dist < 100) && (dist > 30)) {
poke16(0x0a10, offset_x + (16 * x))
poke16(0x0a12, offset_y + (14 * y) - (7 * z))
poke(0x801, 0x01)
}
}
}
}
}
poke(0x805,0x33)
poke(0x819, 0xff)
poke(0x81a, 0xff)
poke(0x81b, 0xff)
poke16(0x0808, 144)
poke16(0x080a, 81)
poke(0x801, 0x08)
}