Project

General

Profile

Revision 248

messy things happened between commits

View differences:

proj.c
169 169
        if((r = ser_test_poll(COM1_ADDR, tx, bits, stop, parity, rate, stringc, strings))) return r;
170 170
    #endif
171 171
    #ifndef DIOGO
172
        #ifdef TELMO
173
            ent_set_scale(DEFAULT_SCALE);
172
        ent_set_scale(DEFAULT_SCALE);
174 173

  
175
            list_t *shooter_list = list_ctor();
174
        list_t *shooter_list = list_ctor();
176 175

  
177
            gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol); if(shooter1 == NULL) printf("Failed to get shooter1\n");
178
            gunner_set_spawn(shooter1, 75, 75);
179
            gunner_set_pos(shooter1, 75, 75);
176
        gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol); if(shooter1 == NULL) printf("Failed to get shooter1\n");
177
        gunner_set_spawn(shooter1, 75, 75);
178
        gunner_set_pos(shooter1, 75, 75);
180 179

  
181
            gunner_t *shooter2 = gunner_ctor(bsp_shooter, bsp_nothing);
182
            gunner_set_spawn(shooter2, 975, 75);
183
            gunner_set_pos(shooter2, 775, 75);
180
        gunner_t *shooter2 = gunner_ctor(bsp_shooter, bsp_nothing);
181
        gunner_set_spawn(shooter2, 975, 75);
182
        gunner_set_pos(shooter2, 775, 75);
184 183

  
185
            list_insert(shooter_list, list_end(shooter_list), shooter1);
186
            list_insert(shooter_list, list_end(shooter_list), shooter2);
184
        list_insert(shooter_list, list_end(shooter_list), shooter1);
185
        list_insert(shooter_list, list_end(shooter_list), shooter2);
187 186

  
188
            //bullet_t *bullet = bullet_ctor(get_bullet(), 400.0, 400.0, 2.0, -1.0);
187
        //bullet_t *bullet = bullet_ctor(get_bullet(), 400.0, 400.0, 2.0, -1.0);
189 188

  
190
            list_t *bullet_list  = list_ctor();
189
        list_t *bullet_list  = list_ctor();
191 190

  
192
            ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
193
                           gunner_get_y(shooter1)-ent_get_YLength()/2.0);
191
        ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
192
                       gunner_get_y(shooter1)-ent_get_YLength()/2.0);
194 193

  
195
            uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
194
        uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
196 195

  
197
            uint8_t last_lb = 0;
198
        #endif
196
        uint8_t last_lb = 0;
199 197

  
200 198
        /// loop stuff
201 199
        int ipc_status;
......
215 213
                            if (msg.m_notify.interrupts & n) {
216 214
                                interrupt_handler(i);
217 215
                                if ((scancode[0]) == ESC_BREAK_CODE) good = 0;
218
                                #ifdef TELMO
219 216
                                if (i == 0) {
220 217
                                    if (no_interrupts % refresh_count_value == 0) {
221
                                        update_movement(map1, shooter1, shooter2);
222
                                        //bullet_update_movement(bullet);
218
                                            update_movement(map1, shooter1, get_key_presses(), shooter_list);
223 219

  
224
                                        if (no_interrupts % 180 == 0) gunner_set_pos(shooter2, 775, 75);
220
                                            update_game_state(map1, shooter_list, bullet_list);
225 221

  
226
    while (good) {
227
        /* Get a request message. */
228
        if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) {
229
            printf("driver_receive failed with %d", r);
230
            continue;
231
        }
232
        if (is_ipc_notify(ipc_status)) { /* received notification */
233
            switch (_ENDPOINT_P(msg.m_source)) {
234
                case HARDWARE: /* hardware interrupt notification */
235
                    for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) {
236
                        if (msg.m_notify.interrupts & n) {
237
                            interrupt_handler(i);
238
                            if ((scancode[0]) == ESC_BREAK_CODE) good = 0;
239
                            #ifdef TELMO
240
                            if (i == 0) {
241
                                if (no_interrupts % refresh_count_value == 0) {
242
                                    update_movement(map1, shooter1, get_key_presses(), shooter_list);
243
                                    //bullet_update_movement(bullet);
222
                                            update_scale();
223
                                            sprite_set_pos(sp_crosshair, get_mouse_X(), get_mouse_Y());
224
                                            double angle = get_mouse_angle(shooter1);
225
                                            gunner_set_angle(shooter1, angle - M_PI_2);
226
                                            graph_clear_screen();
244 227

  
245
                                        update_scale();
246
                                        sprite_set_pos(sp_crosshair, get_mouse_X(), get_mouse_Y());
247
                                        double angle = get_mouse_angle(shooter1);
248
                                        gunner_set_angle(shooter1, angle - M_PI_2);
249
                                        graph_clear_screen();
228
                                            ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
229
                                                           gunner_get_y(shooter1)-ent_get_YLength()/2.0);
250 230

  
251
                                        ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
252
                                                       gunner_get_y(shooter1)-ent_get_YLength()/2.0);
231
                                            map_draw   (map1);
232
                                            gunner_draw_list(shooter_list);
233
                                            bullet_draw_list(bullet_list);
253 234

  
254
                                        map_draw   (map1);
255
                                        gunner_draw(shooter2);
256
                                        gunner_draw(shooter1);
257
                                        bullet_draw_list(bullet_list);
258

  
259
                                        sprite_draw(sp_crosshair);
260
                                        graph_draw();
235
                                            sprite_draw(sp_crosshair);
236
                                            graph_draw();
237
                                        }
261 238
                                    }
262
                                }
263
                                if (i == 12) {
264
                                    if (counter_mouse_ih >= 3) {
265
                                        struct packet pp = mouse_parse_packet(packet_mouse_ih);
266
                                        update_mouse(&pp);
267
                                        //printf("X: %d Y: %d\n", get_mouse_X(), get_mouse_Y());
268
                                        counter_mouse_ih = 0;
269
                                        last_lb = get_key_presses()->lb_pressed;
239
                                    if (i == 12) {
240
                                        if (counter_mouse_ih >= 3) {
241
                                            struct packet pp = mouse_parse_packet(packet_mouse_ih);
242
                                            update_mouse(&pp);
243
                                            //printf("X: %d Y: %d\n", get_mouse_X(), get_mouse_Y());
244
                                            counter_mouse_ih = 0;
245
                                            if (last_lb ^ get_key_presses()->lb_pressed && get_key_presses()->lb_pressed) {
246
                                                shoot_bullet(shooter1, bullet_list, bsp_bullet);
247
                                            }
248
                                            last_lb = get_key_presses()->lb_pressed;
249
                                        }
270 250
                                    }
271 251
                                }
272
                                #endif
273 252
                            }
274
                        }
275 253

  
276
                        break;
277
                    default:
278
                        break; /* no other notifications expected: do nothing */
279
                }
254
                            break;
255
                        default:
256
                            break; /* no other notifications expected: do nothing */
257
                    }
280 258
            } else { /* received standart message, not a notification */
281 259
                /* no standart message expected: do nothing */
282 260
            }
283 261
        }
284 262

  
285
        #ifdef TELMO
286
            while(list_size(shooter_list) > 0){
287
                gunner_t *p = list_erase(shooter_list, list_begin(shooter_list));
288
                gunner_dtor(p);
289
            }
263
        while(list_size(shooter_list) > 0){
264
            gunner_t *p = list_erase(shooter_list, list_begin(shooter_list));
265
            gunner_dtor(p);
266
        }
290 267

  
291
            while(list_size(bullet_list) > 0){
292
                bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
293
                bullet_dtor(p);
294
            }
295
            if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n");
296
        #endif
268
        while(list_size(bullet_list) > 0){
269
            bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
270
            bullet_dtor(p);
271
        }
272
        if(list_dtor(shooter_list)) printf("COULD NOT DESTRUCT SHOOTER LIST\n");
273
        if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n");
297 274

  
298 275
        basic_sprite_dtor      (bsp_crosshair); bsp_crosshair = NULL;
299 276
        basic_sprite_dtor      (bsp_shooter  ); bsp_shooter   = NULL;
......
315 292
            printf("%s: failed to cleanup.\n", __func__);
316 293
            return 1;
317 294
        }
318

  
319 295
    #endif
320 296

  
297

  
321 298
    return 0;
322 299
}

Also available in: Unified diff