diff -u --recursive lbreakout-010315/lbreakout/breakout.cpp lbreakout-ps2-010315/lbreakout/breakout.cpp --- lbreakout-010315/lbreakout/breakout.cpp Thu Mar 15 07:27:33 2001 +++ lbreakout-ps2-010315/lbreakout/breakout.cpp Sat Jul 6 14:42:28 2002 @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #define TOARC(d) (((float)d/180)*M_PI) #define TODEG(a) (((float)a/M_PI)*180) @@ -54,6 +57,7 @@ { // misc // file_levels = 0; + pad_release = 0; // load font // font = SFnt_LoadFixed("f_yellow.bmp", 32, 96, 10); @@ -350,6 +354,9 @@ int ms = 0; float ca = 0; DL_Entry *e; + static int fd=-1, olddown=0xFFFF; + int newdown=0; + unsigned char buf[PS2PAD_DATASIZE]; // motion modifier if using relative mouse motion // motion_mod = (float)init_data.motion_mod / 100; @@ -491,6 +498,32 @@ if (leave) break; + if (fd == -1) { + fd = open("/dev/ps2pad00",O_RDONLY); + } + + if (fd > 0) { + read(fd,buf,PS2PAD_DATASIZE); + if (buf[0] != 0x0a) { + newdown = ((buf[2] << 8) + buf[3]) & PS2PAD_BUTTON_CROSS; + if (newdown != olddown) { + if (newdown) { + fire_shot = 0; + shot_time = 0; + pad_release = 0; + } else { + if (cur_extras[EX_WEAPON]) { + fire_shot = 1; + shot_time = shot_delay; + } + pad_release = 1; + } + } + olddown = newdown; + } + } + + // hide // Life_Hide(); Club_Hide(); @@ -520,6 +553,8 @@ if (Balls_Update(ms)) disappear = 1; } + + Shots_Update(ms); Wall_Update(ms); Wpn_Update(ms); @@ -958,7 +993,7 @@ DR_SETFULLSRC(buffer); SSur_AlphaBlit(128); char str[64]; - sprintf(str, "Continue? y/n"); + sprintf(str, "Continue? y/n (Cross/Triangle)"); SFnt_Write(font, sdl.scr, sdl.scr->w / 2, sdl.scr->h / 2, str, 0); sprintf(str, "(costs %i points)", diff[init_data.diff].con_cost); SFnt_Write(font, sdl.scr, sdl.scr->w / 2, sdl.scr->h / 2 + font->lh, str, 0); @@ -967,6 +1002,12 @@ SDL_Event e; int go_on = 1; int ret = 0; + int fd = -1; + unsigned char buf[PS2PAD_DATASIZE]; + int newdown = 0; + int olddown = 0xffff; + + fd = open("/dev/ps2pad00",O_RDONLY); while (go_on && !fast_quit) { SDL_WaitEvent(&e); if (e.type == SDL_QUIT) { @@ -993,6 +1034,30 @@ default: break; } + if (fd > 0) { + read(fd,buf,PS2PAD_DATASIZE); + if (buf[0] != 0x0a) { + newdown = ((buf[2] << 8) + buf[3]); + if (newdown != olddown) { + if (!(olddown & PS2PAD_BUTTON_CROSS)) { + player.lives = 0; + player.score -= diff[init_data.diff].con_cost; + cur_score = player.score; + DR_SETFULLDST(sdl.scr); + DR_SETFULLSRC(buffer); + SSur_Blit(); + Sdl_FullUpdate(); + go_on = 0; + ret = 1; + } + if (!(olddown & PS2PAD_BUTTON_TRIANGLE)) { + go_on = 0; + ret = 0; + } + } + olddown = newdown; + } + } } SDL_FreeSurface(buffer); if (init_data.warp && init_data.control != 0) @@ -1002,6 +1067,7 @@ if (ret) SndSrv_Play(snd_wontgiveup, 1); #endif + if (fd) close(fd); return ret; } @@ -1122,6 +1188,30 @@ int moved = 0; SDL_Event event; int n; + int newdown; + unsigned char buf[PS2PAD_DATASIZE]; + static int fd=-1; + + if (fd == -1) { + fd = open("/dev/ps2pad00",O_RDONLY); + } + + if (fd > 0) { + read(fd,buf,PS2PAD_DATASIZE); + if (buf[0] != 0xa0) { + newdown = (buf[2] << 8) + buf[3]; + if (!(newdown & PS2PAD_BUTTON_LEFT)) { + club.cur_x -= init_data.key_speed * ms; + club.time = 0; + moved = 1; + } + if (!(newdown & PS2PAD_BUTTON_RIGHT)) { + club.cur_x += init_data.key_speed * ms; + club.time = 0; + moved = 1; + } + } + } if (!init_data.warp) SDL_GetMouseState(&mx, 0); @@ -2272,7 +2362,7 @@ b = (Ball*)e->data; old_x = b->cur_x; old_y = b->cur_y; - if (b->attached && (buttonstate[MB_LEFT] || buttonstate[MB_RIGHT]|| keystate[init_data.k_fire])) { + if (b->attached && (buttonstate[MB_LEFT] || buttonstate[MB_RIGHT]|| keystate[init_data.k_fire] || pad_release)) { // if not in wall // if (b->x + club.x >= brick_w && b->x + ball_dia + club.x < sdl.scr->w - brick_w) { // release ball // diff -u --recursive lbreakout-010315/lbreakout/breakout.h lbreakout-ps2-010315/lbreakout/breakout.h --- lbreakout-010315/lbreakout/breakout.h Sat Nov 4 04:35:32 2000 +++ lbreakout-ps2-010315/lbreakout/breakout.h Thu Jul 4 00:56:38 2002 @@ -295,6 +295,7 @@ void ExDisp_Show(); private: // misc // + int pad_release; int fullscreen; SDL_Surface *ss_bkgnd; SDL_Surface *ss_picture;