root/morphix/trunk/gfxboot-grub/dia_video.inc

Revision 2, 4.4 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

Line 
1 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2 %
3 % Video mode selection dialog.
4 %
5 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6
7
8 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9 % Some global vars.
10 %
11 % We have kernel splash images for at least these sizes.
12 /video.splashsizes [
13    640  480
14    800  600
15   1024  768
16   1280 1024
17   1600 1200
18 ] def
19
20
21 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22 % Create sort key for video modes.
23 %
24 % ( vm_index )  ==> ( sort_index )
25 %
26 /vmsortindex {
27   video.modes.list exch get
28   dup
29   1 get 16 shl
30   exch 2 get add
31 } def
32
33
34 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
35 % Swap video mode entries.
36 % (Helper for video mode sorting.)
37 %
38 % ( vm_index_1 vm_index_2 )  ==> ( )
39 %
40 /vmsortexch {
41   over video.modes.list exch get
42   over video.modes.list exch get
43   video.modes.list
44   5 -1 roll rot put
45   video.modes.list 3 1 roll put
46 } def
47
48
49 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50 % Check if we have a splash in that resolution.
51 %
52 % ( video_mode_list_entry ) ==> ( true|false )
53 %
54 /video.havesplash {
55   false exch
56
57   0 2 video.splashsizes length 1 sub {
58     over over over
59     2 get rot 1 get rot video.splashsizes exch get eq
60     rot 1 add video.splashsizes exch get rot eq and
61     { exch pop true exch exit } if
62   } for
63
64   pop
65
66 } def
67
68
69 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70 % Build video mode list.
71 %
72 % ( ) ==> ( )
73 %
74 /video.init {
75   /xmenu.video .xm_size array def
76
77   /xmenu xmenu.video def
78
79   videomodes 6 add dup array /video.modes.text exch def array /video.modes.list exch def
80   xmenu .xm_list video.modes.text put
81
82   % add text mode entry
83
84   % [ mode width height supported ]
85 %  video.modes.list 0 [ 0 0 0 1 ] put
86 % video.modes.list 0 [ 788 800 600 1 ] put
87 %  video.modes.list [ 785 640 480 1 ] add
88 % video.modes.list 1 [ 788 800 600 1 ] put
89 % video.modes.list 2 [ 791 1024 786 1 ] put
90 % video.modes.list snprintf
91   video.modes.list 0 [ 0 0 0 1 ] put
92   video.modes.list 1 [ 785 640 480 0 ] put
93   video.modes.list 2 [ 788 800 600 0 ] put
94   video.modes.list 3 [ 791 1024 786 0 ] put
95   video.modes.list 4 [ 794 1280 1024 0 ] put
96   video.modes.list 5 [ 797 1600 1200 0 ] put
97 %  video.modes.list length 0 gt {
98 %       video.modes.list 0 [ 788 800 600 1 ] put
99 %  } if
100 % video.modes.list 0 [ 788 800 600 1 ] put
101 % video.modes.list 1 [ 791 1024 786 0 ] put
102
103 %       /videomodes 791 def
104 %  videomodes 0 gt {
105  %   0 1 videomodes 1 sub {
106  %     video.modes.list exch [ over getvideomode ] exch 1 add exch put
107   %  } for
108  % } if
109
110   % sort video.modes.list
111
112   video.modes.list length 1 gt {
113     0 1 video.modes.list length 2 sub {
114       dup 1 add 1 video.modes.list length 1 sub {
115         over vmsortindex over vmsortindex gt {
116           over over vmsortexch
117         } if
118         pop
119       } for
120       pop
121     } for
122   } if
123
124   % create mode strings
125
126   0 1 video.modes.list length 1 sub {
127     video.modes.text exch
128     dup video.modes.list exch get
129     dup 1 get 0 eq {
130       pop "Text Mode" put
131     } {
132       32 string dup rot
133       dup 2 get exch 1 get
134       "%d x %d" 32 5 -1 roll snprintf
135       put
136     } ifelse
137   } for
138
139   % select first mode
140   xmenu .xm_current 0 put
141
142   % select largest mode the monitor supports
143
144 %  0 1 video.modes.list length 1 sub {
145 %    video.modes.list over get
146 %    dup 3 get 0 gt exch video.havesplash and {
147       xmenu .xm_current 3 put
148 %    } {
149 %      pop
150 %    } ifelse
151 %  } for
152
153   pmenu.init
154 } def
155
156
157 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
158 % Update video mode.
159 %
160 % ( ) ==> ( )
161 %
162 /video.update {
163   /xmenu xmenu.video def
164
165   /window.action actRedrawPanel def
166
167   pmenu.update
168 } def
169
170
171 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
172 % Show video menu.
173 %
174 % ( ) => ( )
175 %
176 /panel.video {
177   "videomode" help.setcontext
178
179   window.xmenu
180   dup .xmenu xmenu.video put
181   dup .xmenu.update /video.update put
182   dup window.init
183       window.show
184 } def
185
186
187 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
188 % Return width of video entry.
189 %
190 % ( ) => ( width )
191 %
192 /panel.video.width {
193   /xmenu xmenu.video def
194
195   pmenu.width
196 } def
197
198
199 % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
200 % Redraw panel entry.
201 %
202 % ( panel ) => ( )
203 %
204 /panel.video.update {
205   /xmenu xmenu.video def
206
207   pmenu.panel.update
208 } def
209
210
Note: See TracBrowser for help on using the browser.