9e29869692b57910cd64ed8f0e0ca9925d00fda3
[ScratchNES.git] / src / PPU / NTSCBox.tosh
1 ; "256x256 framebuffer"
2 ; "Uses smart double buffering with a poking rendering method"
3 ; "Designed for use with ScratchNES"
4
5 define-atomic paint
6 go to x: -128 y: 128
7 set I to 1
8 pen down
9 repeat 256
10 delete all of scanline
11 set Y to 128 - y position
12 set X to 0
13 set flag to 0
14 repeat 240
15 set color to 16000000 * <X > box x and Y > box y and X < box x + box w and Y < box y + box h>
16 add color to scanline
17 change X by 1
18 change flag by <item I of view = color>
19 change I by 1
20 end
21 if not flag = 240 then
22 change I by -240
23 set X to 1
24 set x to -128
25 repeat 60
26 set color to item X of scanline
27 set color2 to item X+1 of scanline
28 set color3 to item X+2 of scanline
29 set color4 to item X+3 of scanline
30 replace item I of view with color
31 replace item I+1 of view with color2
32 replace item I+2 of view with color3
33 replace item I+3 of view with color4
34 change I by 4
35 change X by 4
36 set pen color to ((color * 0.25) + (color2 * 0.25) + (color3 * 0.25) + (color4 * 0.25))
37 change x by 4
38 end
39 end
40 change y by -1
41 end
42 pen up
43
44 when flag clicked
45 initialize framebuffer
46 set box x to 128
47 set box y to 64
48 set box w to 64
49 set box h to 64
50 hide
51 reset timer
52 set count to 0
53 show variable count
54 show variable q
55 forever
56 set box x to 128 + (64 * cos of (50 * timer))
57 paint
58 change count by 1
59 set q to timer / count
60 end
61
62 define initialize framebuffer
63 delete all of view
64 repeat (256 * 240)
65 add -1 to view
66 end
67 pen up
68 clear
69 set pen size to 1
70
71 define ; [comment]
72
This page took 0.061783 seconds and 3 git commands to generate.