diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-07-19 19:38:45 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-07-24 21:20:13 +0000 |
commit | 0c4f89370d05056faa789aa9cabcccc4e509fb9f (patch) | |
tree | 6ddf7fff0a47564db41d39927ea1acbdb03e74ee /apps/plugins/jackpot.c | |
parent | 092c340a2062fa98b7387fc5fd63578ddae7d0b6 (diff) | |
download | rockbox-0c4f89370d05056faa789aa9cabcccc4e509fb9f.tar.gz rockbox-0c4f89370d05056faa789aa9cabcccc4e509fb9f.zip |
[2/4] get rid of HAVE_LCD_CHARCELLS
HAVE_LCD_BITMAP is now redundant.
lcd_bitmap is always-on in features.txt so manual and lang strings
don't have to change
Change-Id: I08eeb20de48099ffc2dc23782711af368c2ec794
Diffstat (limited to 'apps/plugins/jackpot.c')
-rw-r--r-- | apps/plugins/jackpot.c | 70 |
1 files changed, 2 insertions, 68 deletions
diff --git a/apps/plugins/jackpot.c b/apps/plugins/jackpot.c index b380e85180..26f8f47e8f 100644 --- a/apps/plugins/jackpot.c +++ b/apps/plugins/jackpot.c | |||
@@ -30,24 +30,7 @@ const struct button_mapping* plugin_contexts[]={pla_main_ctx}; | |||
30 | #define NB_PICTURES 9 | 30 | #define NB_PICTURES 9 |
31 | #define NB_SLOTS 3 | 31 | #define NB_SLOTS 3 |
32 | 32 | ||
33 | #ifdef HAVE_LCD_CHARCELLS | 33 | #ifdef HAVE_LCD_BITMAP |
34 | #define PICTURE_ROTATION_STEPS 7 | ||
35 | static unsigned char jackpot_slots_patterns[]={ | ||
36 | 0x00, 0x0A, 0x1F, 0x1F, 0x1F, 0x0e, 0x04, /* (+00)Heart */ | ||
37 | 0x00, 0x04, 0x0E, 0x1F, 0x1F, 0x04, 0x0E, /* (+07)Spade */ | ||
38 | 0x00, 0x04, 0x0E, 0x1F, 0x0E, 0x04, 0x00, /* (+14)Diamond */ | ||
39 | 0x00, 0x15, 0x0E, 0x1F, 0x0E, 0x15, 0x00, /* (+21)Club */ | ||
40 | 0x03, 0x04, 0x0e, 0x1F, 0x1F, 0x1F, 0x0e, /* (+28)Cherry */ | ||
41 | 0x00, 0x04, 0x04, 0x1F, 0x04, 0x0E, 0x1F, /* (+35)Cross */ | ||
42 | 0x04, 0x0E, 0x15, 0x04, 0x0A, 0x0A, 0x11, /* (+42)Man */ | ||
43 | 0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, /* (+49)Square */ | ||
44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* (+56)Empty */ | ||
45 | 0x00, 0x0A, 0x1F, 0x1F, 0x1F, 0x0e, 0x04 /* (+63)Heart */ | ||
46 | }; | ||
47 | static unsigned long char_patterns[NB_SLOTS]; | ||
48 | #define SLEEP_TIME (HZ/24) | ||
49 | #else /* bitmaps LCDs */ | ||
50 | |||
51 | #define PICTURE_HEIGHT (BMPHEIGHT_jackpot_slots/(NB_PICTURES+1)) | 34 | #define PICTURE_HEIGHT (BMPHEIGHT_jackpot_slots/(NB_PICTURES+1)) |
52 | #if NB_SCREENS==1 | 35 | #if NB_SCREENS==1 |
53 | #define PICTURE_ROTATION_STEPS PICTURE_HEIGHT | 36 | #define PICTURE_ROTATION_STEPS PICTURE_HEIGHT |
@@ -72,7 +55,7 @@ const struct picture jackpot_pictures[]={ | |||
72 | }; | 55 | }; |
73 | 56 | ||
74 | #define SLEEP_TIME (HZ/200) | 57 | #define SLEEP_TIME (HZ/200) |
75 | #endif /* HAVE_LCD_CHARCELLS */ | 58 | #endif /* HAVE_LCD_BITMAP */ |
76 | 59 | ||
77 | struct jackpot | 60 | struct jackpot |
78 | { | 61 | { |
@@ -92,29 +75,9 @@ struct jackpot | |||
92 | int money; | 75 | int money; |
93 | }; | 76 | }; |
94 | 77 | ||
95 | #ifdef HAVE_LCD_CHARCELLS | ||
96 | static void patterns_init(struct screen* display) | ||
97 | { | ||
98 | int i; | ||
99 | for(i=0;i<NB_SLOTS;i++) | ||
100 | char_patterns[i]=display->get_locked_pattern(); | ||
101 | } | ||
102 | |||
103 | static void patterns_deinit(struct screen* display) | ||
104 | { | ||
105 | /* Restore the old pattern */ | ||
106 | int i; | ||
107 | for(i=0;i<NB_SLOTS;i++) | ||
108 | display->unlock_pattern(char_patterns[i]); | ||
109 | } | ||
110 | #endif /* HAVE_LCD_CHARCELLS */ | ||
111 | |||
112 | /*Call when the program exit*/ | 78 | /*Call when the program exit*/ |
113 | static void jackpot_exit(void) | 79 | static void jackpot_exit(void) |
114 | { | 80 | { |
115 | #ifdef HAVE_LCD_CHARCELLS | ||
116 | patterns_deinit(rb->screens[SCREEN_MAIN]); | ||
117 | #endif /* HAVE_LCD_CHARCELLS */ | ||
118 | } | 81 | } |
119 | 82 | ||
120 | static void jackpot_init(struct jackpot* game) | 83 | static void jackpot_init(struct jackpot* game) |
@@ -168,47 +131,25 @@ static void jackpot_display_slot_machine(struct jackpot* game, struct screen* di | |||
168 | char str[20]; | 131 | char str[20]; |
169 | int i; | 132 | int i; |
170 | bool changes=false; | 133 | bool changes=false; |
171 | #ifdef HAVE_LCD_CHARCELLS | ||
172 | display->putchar(0, 0, '['); | ||
173 | #else | ||
174 | const struct picture* picture= &(jackpot_pictures[display->screen_type]); | 134 | const struct picture* picture= &(jackpot_pictures[display->screen_type]); |
175 | int pos_x=(display->getwidth()-NB_SLOTS*(picture->width+1))/2; | 135 | int pos_x=(display->getwidth()-NB_SLOTS*(picture->width+1))/2; |
176 | int pos_y=(display->getheight()-(picture->slide_height))/2; | 136 | int pos_y=(display->getheight()-(picture->slide_height))/2; |
177 | #endif /* HAVE_LCD_CHARCELLS */ | ||
178 | for(i=0;i<NB_SLOTS;i++) | 137 | for(i=0;i<NB_SLOTS;i++) |
179 | { | 138 | { |
180 | #ifdef HAVE_LCD_CHARCELLS | ||
181 | /* the only charcell lcd is 7 pixel high */ | ||
182 | int state_y=(game->slot_state[i]*7)/PICTURE_ROTATION_STEPS; | ||
183 | #else | ||
184 | int state_y= | 139 | int state_y= |
185 | (picture->slide_height*game->slot_state[i])/PICTURE_ROTATION_STEPS; | 140 | (picture->slide_height*game->slot_state[i])/PICTURE_ROTATION_STEPS; |
186 | #endif /* HAVE_LCD_CHARCELLS */ | ||
187 | int previous_state_y=game->state_y[display->screen_type][i]; | 141 | int previous_state_y=game->state_y[display->screen_type][i]; |
188 | if(state_y==previous_state_y) | 142 | if(state_y==previous_state_y) |
189 | continue;/*no need to update the picture | 143 | continue;/*no need to update the picture |
190 | as it's the same as previous displayed one*/ | 144 | as it's the same as previous displayed one*/ |
191 | changes=true; | 145 | changes=true; |
192 | game->state_y[display->screen_type][i]=state_y; | 146 | game->state_y[display->screen_type][i]=state_y; |
193 | #ifdef HAVE_LCD_CHARCELLS | ||
194 | char* current_pattern=&(jackpot_slots_patterns[state_y]); | ||
195 | display->define_pattern(char_patterns[i], | ||
196 | current_pattern); | ||
197 | display->putchar(i+1, 0, char_patterns[i]); | ||
198 | #else | ||
199 | vertical_picture_draw_part(display, picture, state_y, pos_x, pos_y); | 147 | vertical_picture_draw_part(display, picture, state_y, pos_x, pos_y); |
200 | pos_x+=(picture->width+1); | 148 | pos_x+=(picture->width+1); |
201 | #endif | ||
202 | } | 149 | } |
203 | if(changes){ | 150 | if(changes){ |
204 | #ifdef HAVE_LCD_CHARCELLS | ||
205 | rb->snprintf(str,sizeof(str),"$%d", game->money); | ||
206 | display->putchar(++i, 0, ']'); | ||
207 | display->puts(++i, 0, str); | ||
208 | #else | ||
209 | rb->snprintf(str,sizeof(str),"money : $%d", game->money); | 151 | rb->snprintf(str,sizeof(str),"money : $%d", game->money); |
210 | display->puts(0, 0, str); | 152 | display->puts(0, 0, str); |
211 | #endif | ||
212 | display->update(); | 153 | display->update(); |
213 | } | 154 | } |
214 | } | 155 | } |
@@ -216,9 +157,6 @@ static void jackpot_display_slot_machine(struct jackpot* game, struct screen* di | |||
216 | 157 | ||
217 | static void jackpot_info_message(struct screen* display, char* message) | 158 | static void jackpot_info_message(struct screen* display, char* message) |
218 | { | 159 | { |
219 | #ifdef HAVE_LCD_CHARCELLS | ||
220 | display->puts_scroll(0,1,message); | ||
221 | #else | ||
222 | int xpos, ypos; | 160 | int xpos, ypos; |
223 | int message_height, message_width; | 161 | int message_height, message_width; |
224 | display->getstringsize(message, &message_width, &message_height); | 162 | display->getstringsize(message, &message_width, &message_height); |
@@ -228,7 +166,6 @@ static void jackpot_info_message(struct screen* display, char* message) | |||
228 | message_height); | 166 | message_height); |
229 | display->putsxy(xpos,ypos,message); | 167 | display->putsxy(xpos,ypos,message); |
230 | display->update(); | 168 | display->update(); |
231 | #endif /* HAVE_LCD_CHARCELLS */ | ||
232 | } | 169 | } |
233 | 170 | ||
234 | static void jackpot_print_turn_result(struct jackpot* game, | 171 | static void jackpot_print_turn_result(struct jackpot* game, |
@@ -299,9 +236,6 @@ enum plugin_status plugin_start(const void* parameter) | |||
299 | (void)parameter; | 236 | (void)parameter; |
300 | atexit(jackpot_exit); | 237 | atexit(jackpot_exit); |
301 | rb->srand(*rb->current_tick); | 238 | rb->srand(*rb->current_tick); |
302 | #ifdef HAVE_LCD_CHARCELLS | ||
303 | patterns_init(rb->screens[SCREEN_MAIN]); | ||
304 | #endif /* HAVE_LCD_CHARCELLS */ | ||
305 | jackpot_init(&game); | 239 | jackpot_init(&game); |
306 | 240 | ||
307 | FOR_NB_SCREENS(i){ | 241 | FOR_NB_SCREENS(i){ |