Squeeze the NTSC box
[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 set Y to -1
9 pen down
10 repeat 256
11 delete all of scanline
12 change Y by 1
13 set X to 0
14 set flag to 0
15 repeat 240
16 set color to 16000000 * <X > box x and Y > box y and X < box x + box w and Y < box y + box h>
17 add color to scanline
18 change X by 1
19 change flag by <item I of view = color>
20 change I by 1
21 end
22 set x to -128
23 if not flag = 240 then
24 change I by -240
25 set X to 1
26 repeat 60
27 set color to item X of scanline
28 set color2 to item X+1 of scanline
29 set color3 to item X+2 of scanline
30 set color4 to item X+3 of scanline
31 replace item I of view with color
32 replace item I+1 of view with color2
33 replace item I+2 of view with color3
34 replace item I+3 of view with color4
35 change I by 4
36 change X by 4
37 set pen color to ((color * 0.25) + (color2 * 0.25) + (color3 * 0.25) + (color4 * 0.25))
38 change x by 4
39 end
40 end
41 change y by -1
42 end
43 pen up
44
45 when flag clicked
46 initialize framebuffer
47 set box x to 128
48 set box y to 64
49 set box w to 64
50 set box h to 64
51 hide
52 reset timer
53 set count to 0
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]
This page took 0.069617 seconds and 4 git commands to generate.