sample2.c 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "wonx/disp.h"
  2. #include "wonx/key.h"
  3. static unsigned char clear[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  4. static unsigned char block[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  5. main()
  6. {
  7. int x, y, f, k;
  8. display_control(DCM_SCR2 | DCM_SPR);
  9. lcd_set_color(0, 0xffff);
  10. palette_set_color(0, 0);
  11. palette_set_color(8, (0xf << 12));
  12. font_set_color(0x03);
  13. font_set_monodata(0, 1, clear);
  14. font_set_monodata(1, 1, block);
  15. sprite_set_char(0,
  16. CFM_SPR_UPPER |
  17. ((0 << 9) & CFM_SPR_PALETTE) |
  18. (1 & CFM_FONT)
  19. );
  20. sprite_set_range(0, 1);
  21. x = 14;
  22. y = 9;
  23. f = 0;
  24. while (!f) {
  25. sprite_set_location(0, x * 8, y * 8);
  26. k = key_hit_check();
  27. if (k & KEY_START) f = 1;
  28. if (k & KEY_A) f = 1;
  29. if ((k & KEY_LEFT1) && (x > 0)) x--;
  30. if ((k & KEY_RIGHT1) && (x < LCD_PIXEL_WIDTH/8 - 1)) x++;
  31. if ((k & KEY_UP1) && (y > 0)) y--;
  32. if ((k & KEY_DOWN1) && (y < LCD_PIXEL_HEIGHT/8 - 1)) y++;
  33. }
  34. bios_exit();
  35. }