Steward
分享是一種喜悅、更是一種幸福
掌機 - Game Boy Color - C/C++ - Input(Wait)
參考資訊:
https://bgb.bircd.org/
https://github.com/mrombout/gbdk_playground
http://gbdk.sourceforge.net/doc/html/book01.html
等待Input按下
1 | UINT8 waitpad ( UINT8 mask); |
第一個參數是要等待的按鍵(支援組合鍵)
回傳值為按鍵
等待Input釋放
1 | void waitpadup ( void ) |
main.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <stdio.h> #include <gb/gb.h> #include <gb/cgb.h> unsigned short palette[] = { RGB_WHITE , RGB_RED , RGB_GREEN , RGB_BLUE }; void main ( void ) { set_bkg_palette (0, 1, palette); while (1) { waitpad ( J_START ); printf ( "Start Pressed\n" ); waitpad ( J_A ); printf ( "A Pressed\n" ); waitpadup (); printf ( "A Released\n" ); } } |
完成