tagged release 0.7.1
[parrot.git] / examples / nci / sdl_blue_rectangle.pir
blobb9088367ed896407f44ceb39ced0bb3fa286f44c
1 # $Id$
3 .sub _main :main
4     _init()
5     _MAIN()
6     end
7 .end
9 .include "library/sdl_types.pir"
10 .include "datatypes.pasm"
12 .sub _init
13     .include "library/sdl.pasm"
14     _init_SDL_types()
15     .begin_return
16     .end_return
17 .end
19 .sub _MAIN
20     .local pmc SDL_Init
21     .local pmc SetVideoMode
22     .local pmc SDL_Quit
23     .local pmc SDL_UpdateRect
24     .local pmc SDL_FillRect
25     .local pmc new_SDL_Rect
26     .local object screen
28     SDL_Init       = global "SDL::SDL_Init"
29     SetVideoMode   = global "SDL::SDL_SetVideoMode"
30     SDL_Quit       = global "SDL::SDL_Quit"
31     SDL_UpdateRect = global "SDL::SDL_UpdateRect"
32     SDL_FillRect   = global "SDL::SDL_FillRect"
33     new_SDL_Rect   = global "new_SDL_Rect"
35     .begin_call
36         .arg 65535
37         .nci_call SDL_Init
38     .end_call
40     .begin_call
41         .arg 640
42         .arg 480
43         .arg  0
44         .arg   0
45         .nci_call SetVideoMode
46         .result screen
47     .end_call
49     .local object blue_rect
50     #.local object blue_color
52     blue_rect = _new_SDL_Rect()
53     # blue_color = _new_SDL_Color( 255, 255, 255 )
54     .local int blue
55     .local int red
56     .local int green
57     blue = 255 << 0
58     red = 255 << 16
59     green = 255 << 8
60     print "blue = "
61     print blue
62     print "\n"
64     set blue_rect['w'], 100
65     set blue_rect['h'], 100
66     set blue_rect['x'], 270
67     set blue_rect['y'], 190
69     .begin_call
70         .arg screen
71         .arg blue_rect
72         .arg blue
73         .nci_call SDL_FillRect
74         .local int ok
75         .result ok
76     .end_call
78     # update full screen (all 0 arguments)
79     .begin_call
80         .arg screen
81         .arg 0
82         .arg 0
83         .arg 0
84         .arg 0
85         .nci_call SDL_UpdateRect
86     .end_call
88     sleep 2
90     .begin_call
91         .nci_call SDL_Quit
92     .end_call
94     .begin_return
95     .end_return
96 .end
98 # Local Variables:
99 #   mode: pir
100 #   fill-column: 100
101 # End:
102 # vim: expandtab shiftwidth=4 ft=pir: