void glColor4f(GLfloat r,GLfloat g,GLfloat b,GLfloat a) { GLParam p[8]; p[0].op=OP_Color; p[1].f=r; p[2].f=g; p[3].f=b; p[4].f=a; /* direct convertion to integer to go faster if no shading */ p[5].ui = (unsigned int) (sll2int( slladd( sllmul(r,int2sll(ZB_POINT_RED_MAX - ZB_POINT_RED_MIN)), int2sll(ZB_POINT_RED_MIN) ) ) ); p[6].ui = (unsigned int) (sll2int( slladd( sllmul(g, int2sll(ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN)), int2sll(ZB_POINT_GREEN_MIN) ) ) ); p[7].ui = (unsigned int) (sll2int( slladd( sllmul(b, int2sll(ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN)), int2sll(ZB_POINT_BLUE_MIN) ) ) ); gl_add_op(p); }
void glColor4fv(GLfloat *v) { GLParam p[8]; p[0].op=OP_Color; p[1].f=v[0]; p[2].f=v[1]; p[3].f=v[2]; p[4].f=v[3]; /* direct convertion to integer to go faster if no shading */ p[5].ui = (unsigned int) (sll2int( slladd( sllmul(v[0], int2sll(ZB_POINT_RED_MAX - ZB_POINT_RED_MIN)), int2sll(ZB_POINT_RED_MIN) ) ) ); p[6].ui = (unsigned int) (sll2int( slladd( sllmul(v[1], int2sll(ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN)), int2sll(ZB_POINT_GREEN_MIN) ) ) ); p[7].ui = (unsigned int) (sll2int( slladd( sllmul(v[2], int2sll(ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN)), int2sll(ZB_POINT_BLUE_MIN) ) ) ); gl_add_op(p); }
void Firework_Update(GBitmap *bitmap) { static int darken_count = 0; if (darken_count++ >= 4) { darken_count = 0; graphics_darken(bitmap); } // Draw fireworks for (int i = 0; i < FIREWORKS; i++) { FireworkStruct* firework = &prv_fireworks[i]; GColor color; if (firework->hasExploded) { color = GColorFromRGB( sll2int(sllmul(int2sll(firework->red), firework->alpha)), sll2int(sllmul(int2sll(firework->green), firework->alpha)), sll2int(sllmul(int2sll(firework->blue), firework->alpha))); for (int p = 0; p < FIREWORK_PARTICLES; p++) { int xpos = sll2int(firework->x[p]); int ypos = sll2int(firework->y[p]); graphics_draw_pixel_color(bitmap, (GPoint){xpos, ypos}, color); graphics_draw_pixel_color(bitmap, (GPoint){xpos + 1, ypos}, color); graphics_draw_pixel_color(bitmap, (GPoint){xpos + 1, ypos + 1}, color); graphics_draw_pixel_color(bitmap, (GPoint){xpos, ypos + 1}, color); } Firework_Explode(&prv_fireworks[i]); } else { color = GColorFromRGB(255, 255, 0); int xpos = sll2int(firework->x[0]); int ypos = sll2int(firework->y[0]); graphics_draw_pixel_color(bitmap, (GPoint){xpos, ypos}, color); graphics_draw_pixel_color(bitmap, (GPoint){xpos + 1, ypos}, color); graphics_draw_pixel_color(bitmap, (GPoint){xpos + 1, ypos + 1}, color); graphics_draw_pixel_color(bitmap, (GPoint){xpos, ypos + 1}, color); Firework_Move(&prv_fireworks[i]); } } }
sll rand_sll(sll max_val) { sll max_scale = int2sll(1000); int max_val_int = sll2int(sllmul(max_val, max_scale)); return slldiv(int2sll(rand() % (max_val_int + 1)), max_scale); }
void phase2_process(void) { sll inc=dbl2sll(0.0022); phase2_ship_x=128; phase2_ship_y=147; phase2_shoot.x=0; phase2_shoot.y=0; phase2_shoot.state=100; phase2_bad.x=0; phase2_bad.y=300; phase2_bad.state=105; phase2_global_x=0; phase2_global_y=0; music_play_fade(MUSIC_LEVEL); init_frame_time(); theend=0; while (!theend) { getKey(); if (hit1_pressed) if (phase2_shoot.state>=25) { sll angle=sllsub(mode7_angle,sllmul(inc,int2sll((128-phase2_ship_x)<<1))); sll multi=int2sll((256-phase2_ship_y)/24); phase2_shoot.dx=sllmul(sllrotl(sllcos(angle),3),SLL_CONST_PI); phase2_shoot.dy=sllmul(sllrotl(sllsin(angle),3),SLL_CONST_PI); phase2_shoot.x=slladd(mode7_x,sllmul(phase2_shoot.dx,multi)); phase2_shoot.y=slladd(mode7_y,sllmul(phase2_shoot.dy,multi)); angle=sllsub(mode7_angle,sllmul(inc,int2sll((128-phase2_ship_x)<<2))); phase2_shoot.dx=sllmul(sllrotl(sllcos(angle),3),SLL_CONST_PI); phase2_shoot.dy=sllmul(sllrotl(sllsin(angle),3),SLL_CONST_PI); phase2_shoot.alt=(phase2_ship_y-128)>>2; phase2_shoot.state=24; play_sound(SND_SHIP_LASER); } if (left_pressed) phase2_ship_x-=8; else if (right_pressed) phase2_ship_x+=8; else if (phase2_ship_x<128) phase2_ship_x+=4; else if (phase2_ship_x>128) phase2_ship_x-=4; if (phase2_ship_x>=192) phase2_ship_x-=8; else if (phase2_ship_x<=64) phase2_ship_x+=8; if (up_pressed) { if (mode7_z<512) { mode7_z += 32; phase2_ship_y-=8; } } else if (down_pressed) { if (mode7_z>256) { mode7_z -= 32; phase2_ship_y+=8; } } else if (mode7_z>400) { mode7_z-=16; phase2_ship_y+=4; } else if (mode7_z<368) { mode7_z+=16; phase2_ship_y-=4; } mode7_process(sllsub(mode7_angle,sllmul(inc,int2sll((128-phase2_ship_x)>>1)))); phase2_global_x= sll2int(mode7_x); phase2_global_y= sll2int(mode7_y); phase2_draw(); delay_frame_time(); }