Root/alpy/patches/020-example-fixes.patch

1Index: Alpy-0.1.5/examples/demo.py
2===================================================================
3--- Alpy-0.1.5.orig/examples/demo.py 2012-04-01 23:29:57.989557335 +0200
4+++ Alpy-0.1.5/examples/demo.py 2012-04-01 23:45:58.686160740 +0200
5@@ -13,7 +13,8 @@
6 
7 MAX_SPEED = 32
8 SPEED_SHIFT = 3
9-MAX_STARS = 128
10+# reduced number of stars to keep NanoNote's CPU happy
11+MAX_STARS = 64
12 MAX_ALIENS = 50
13 
14 ycounter = 0
15@@ -155,8 +156,10 @@
16             self.oy = 0
17     def draw(self, bmp):
18         x = int(((self.ox-screen.w/2) * (self.oy/(4-int(self.z)/2)+screen.h)/screen.h) + screen.w/2)
19+ set_color_depth(8)
20         bmp.putpixel(x, self.oy, 15 - int(self.z))
21-
22+ set_color_depth(32)
23+
24 class Alien:
25     bullet_exploded = 0
26     def __init__(self, img):
27@@ -340,7 +343,7 @@
28     clear_keybuf()
29     set_palette(data[GAME_PAL].dat)
30     position_mouse(screen.w/2, screen.h/2)
31- register_counter('game_time', speed = MSEC_TO_TIMER(6400/screen.w))
32+ register_counter('game_time', speed = MSEC_TO_TIMER(50))
33     install_fps()
34     counters.game_time = 0
35     esc = 0
36@@ -359,8 +362,8 @@
37         fade_out(5)
38         sys.exit(0)
39     draw_screen()
40- b = Bitmap(160, 160)
41- b2 = Bitmap(160, 160)
42+ b = Bitmap(160, 160,depth=8)
43+ b2 = Bitmap(160, 160,depth=8)
44     b.clear()
45     b.textout(data[END_FONT].dat, "GAME OVER", 80, 50, 2, align='center')
46     b.textout(data[END_FONT].dat, "SCORE: %d" % player.score, 80, 82, 2, align='center')
47@@ -388,7 +391,10 @@
48     h = screen.h / size
49 
50     screen.clear()
51- b.stretch_blit(screen, dest_x=(screen.w - w)/2, dest_y=(screen.h - h)/2,
52+ b32 = Bitmap(b.w, b.h, depth=32)
53+ set_palette(data[GAME_PAL].dat);
54+ b.blit(b32);
55+ b32.stretch_blit(screen, dest_x=(screen.w - w)/2, dest_y=(screen.h - h)/2,
56                    dest_width=w, dest_height=h)
57 
58 
59@@ -400,11 +406,26 @@
60     set_palette(data[GAME_PAL].dat)
61     fade_out(fade_speed)
62 
63+# added to use as workaround over seemingly broken explosion.dat data-file
64+def make_explosion(i):
65+ set_color_depth(8)
66+ set_palette(data[GAME_PAL].dat)
67+ ex = Bitmap(47,47)
68+ ex.clear()
69+ ex.circle(ex.w/2,ex.h/2,radius=ex.w/2,fill=True,
70+ color=makecol(255-i*180/EXPLODE_FRAMES,
71+ 240-i*240/EXPLODE_FRAMES,
72+ 235-i*235/EXPLODE_FRAMES))
73+ spr = ex.get_rle()
74+ set_color_depth(32)
75+ return spr
76+
77 def generate_explosions():
78     global explosion, expl_dat
79- expl_dat = load_datafile('explosion.dat')
80- explosion = map(lambda x: expl_dat[x].dat, range(EXPLODE_FRAMES))
81-
82+ # broken data file? even allegro's dat util can't open without crashing
83+ #expl_dat = load_datafile('explosion.dat')
84+ explosion=[make_explosion(i) for i in range(EXPLODE_FRAMES)]
85+
86 color = 0
87 def title_screen():
88     global color
89@@ -445,25 +466,27 @@
90     if color > 3: color = 0
91 
92     screen.clear()
93+
94     set_palette(Game.title_palette)
95 
96     register_counter('scroll_count', MSEC_TO_TIMER(5))
97     counters.scroll_count = 1
98 
99     t = data[TITLE_BMP].dat
100+ t32 = Bitmap(t.w, t.h, depth=32);
101+ t.blit(t32);
102     while 1:
103         c = counters.scroll_count
104         if c >= 160: break
105- t.stretch_blit(screen, 0, 0, 320, 128, screen.w/2-c,
106+ t32.stretch_blit(screen, 0, 0, 320, 128, screen.w/2-c,
107                        screen.h/2-c*64/160-32, c*2, c*128/160)
108 
109     remove_counter('scroll_count')
110 
111- t.blit(screen, screen.w/2-160, screen.h/2-96, width=320, height=128)
112-
113- buffer = Bitmap(screen.w, screen.h)
114+ t32.blit(screen, screen.w/2-160, screen.h/2-96, width=320, height=128)
115+ buffer = Bitmap(screen.w, screen.h, depth=8)
116     buffer.clear()
117- text_bmp = Bitmap(screen.w, 24)
118+ text_bmp = Bitmap(screen.w, 24, depth=8)
119     text_bmp.clear()
120 
121     clear_keybuf()
122@@ -473,7 +496,6 @@
123     buffer.blit()
124 
125     fade_out(5)
126-
127     while keypressed():
128         if readkey() & 0xff == 27:
129             return 0
130@@ -496,18 +518,20 @@
131     allegro_init()
132     install_keyboard()
133     install_timer()
134- install_mouse()
135+## install_mouse()
136 
137     jumpstart = 0
138 
139+ set_color_depth(32);
140+
141     try:
142         install_sound()
143         if not jumpstart:
144             fade_out(4)
145- set_gfx_mode(GFX_AUTODETECT, 320, 200)
146+ set_gfx_mode(GFX_SAFE, 320, 200)
147         set_color_conversion(COLORCONV_NONE)
148         global data
149- data = load_datafile('demo.dat')
150+ data = load_datafile('/usr/share/allegro/shooter.dat')
151     except AlpyException, msg:
152         set_gfx_mode(GFX_TEXT, 0, 0)
153         allegro_message("Alpy `%s'. Allegro `%s'" % (msg, get_allegro_error()))
154@@ -530,16 +554,18 @@
155             pass
156         fade_out(1)
157 
158- try: set_gfx_mode(GFX_AUTODETECT, 640, 480)
159+ set_color_depth(32);
160+ try: set_gfx_mode(GFX_SAFE, 320, 240)
161     except AlpyException, msg:
162         allegro_message("Alpy `%s'. Allegro `%s'" % (msg, get_allegro_error()))
163 
164     screen.clear()
165- set_color_depth(8)
166+# set_color_depth(8)
167 
168+ sys.stderr.flush()
169     generate_explosions()
170 
171- Game.s = Bitmap(screen.w, screen.h)
172+ Game.s = Bitmap(screen.w, screen.h, depth=8)
173     intro_spl = data[INTRO_SPL].dat
174     intro_spl.stop()
175 
176Index: Alpy-0.1.5/examples/exbitmap.py
177===================================================================
178--- Alpy-0.1.5.orig/examples/exbitmap.py 2012-04-01 23:29:58.481559747 +0200
179+++ Alpy-0.1.5/examples/exbitmap.py 2012-04-01 23:31:13.897929383 +0200
180@@ -6,7 +6,10 @@
181 
182 import alpy, sys
183 
184-alpy.allegro_init()
185+print "init"
186+alpy.install_allegro(alpy.SYSTEM_LINUX)
187+#alpy.allegro_init()
188+print "huhu"
189 
190 if len(sys.argv) != 2:
191     alpy.allegro_message("Usage: 'exbitmap filename.[bmp|lbm|pcx|tga]'")
192@@ -14,7 +17,7 @@
193 
194 alpy.install_keyboard()
195 try:
196- alpy.set_gfx_mode(alpy.GFX_SAFE, 640, 480)
197+ alpy.set_gfx_mode(alpy.GFX_SAFE, 320, 240)
198 except AlpyException, msg:
199     alpy.set_gfx_mode(GFX_TEXT, 0, 0)
200     alpy.allegro_message("Unable to set any graphic mode. %s, %s." % (msg,
201Index: Alpy-0.1.5/examples/exblend.py
202===================================================================
203--- Alpy-0.1.5.orig/examples/exblend.py 2012-04-01 23:29:57.953557157 +0200
204+++ Alpy-0.1.5/examples/exblend.py 2012-04-01 23:31:13.925929521 +0200
205@@ -24,7 +24,7 @@
206 if bpp > 0:
207     set_color_depth(bpp)
208     try:
209- set_gfx_mode(GFX_AUTODETECT, 640, 480)
210+ set_gfx_mode(GFX_AUTODETECT, 320, 240)
211     except AlpyException:
212         failure = 1
213 else:
214@@ -33,7 +33,7 @@
215         bpp = d
216         set_color_depth(bpp)
217         try:
218- set_gfx_mode(GFX_AUTODETECT, 640, 480)
219+ set_gfx_mode(GFX_AUTODETECT, 320, 240)
220         except AlpyException:
221             failure = 1
222             continue
223@@ -44,7 +44,7 @@
224 if failure:
225     set_gfx_mode(GFX_TEXT, 0, 0)
226     allegro_message("Error setting %d bit graphics mode. %s\n" % (bpp,
227- get_allegro_error*()))
228+ get_allegro_error()))
229     sys.exit(1)
230 
231 set_color_conversion(COLORCONV_TOTAL)
232Index: Alpy-0.1.5/examples/excolmap.py
233===================================================================
234--- Alpy-0.1.5.orig/examples/excolmap.py 2012-04-01 23:29:58.377559237 +0200
235+++ Alpy-0.1.5/examples/excolmap.py 2012-04-01 23:31:13.961929696 +0200
236@@ -89,7 +89,7 @@
237                                            callback_func, 'blend')
238 
239     try:
240- alpy.set_gfx_mode(alpy.GFX_AUTODETECT, 320, 200)
241+ alpy.set_gfx_mode(alpy.GFX_SAFE, 320, 200)
242     except alpy.AlpyException, msg:
243         alpy.set_gfx_mode(alpy.GFX_TEXT, 0, 0)
244         alpy.allegro_message('Unable to set any graphic mode. %s, %s' % (msg,
245Index: Alpy-0.1.5/examples/exdat.py
246===================================================================
247--- Alpy-0.1.5.orig/examples/exdat.py 2012-04-01 23:29:57.921557001 +0200
248+++ Alpy-0.1.5/examples/exdat.py 2012-04-01 23:31:13.989929835 +0200
249@@ -13,9 +13,9 @@
250 install_sound()
251 
252 try:
253- data = load_datafile('demo.dat')
254+ data = load_datafile('/usr/share/allegro/shooter.dat')
255     set_gfx_mode(GFX_SAFE, 320, 200)
256-except alpy.AlpyException, msg:
257+except AlpyException, msg:
258     import sys
259     set_gfx_mode(GFX_TEXT, 0, 0)
260     allegro_message('error: %s, %s' % (msg, get_allegro_error()))
261Index: Alpy-0.1.5/examples/exfli.py
262===================================================================
263--- Alpy-0.1.5.orig/examples/exfli.py 2012-04-01 23:29:58.341559061 +0200
264+++ Alpy-0.1.5/examples/exfli.py 2012-04-01 23:31:14.025930011 +0200
265@@ -14,7 +14,7 @@
266 
267 try:
268     set_gfx_mode(GFX_SAFE, 320, 200)
269- data = load_datafile('demo.dat')
270+ data = load_datafile('/usr/share/allegro/shooter.dat')
271 
272     while 1:
273         if keypressed(): break
274Index: Alpy-0.1.5/examples/extimer.py
275===================================================================
276--- Alpy-0.1.5.orig/examples/extimer.py 2012-04-01 23:29:58.197558355 +0200
277+++ Alpy-0.1.5/examples/extimer.py 2012-04-01 23:31:14.061930188 +0200
278@@ -12,7 +12,7 @@
279 install_timer()
280 
281 try:
282- set_gfx_mode(GFX_AUTODETECT, 320, 200)
283+ set_gfx_mode(GFX_SAFE, 320, 200)
284 except AlpyException, msg:
285     set_gfx_mode(GFX_TEXT, 0, 0)
286     allegro_message("Unable to set any graphic mode\n%s\n%s\n" % (msg, get_allegro_error()))
287

Archive Download this file



interactive