Advertisement
TheGhastModding

blink.c

Aug 1st, 2022
1,319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1. #undef nofloats
  2.  
  3. #include "nstdlib.h"
  4. #include "cvrio.h"
  5. #include "math.h"
  6.  
  7. unsigned volatile char* emissionStrength = (unsigned char*)65280;
  8. unsigned volatile char* goToggle = (unsigned char*)65281;
  9. unsigned volatile char* btnState = (unsigned char*)65282;
  10.  
  11. void main() {
  12.     char flag = 0;
  13.     char btnHeld = 0;
  14.     *goToggle = 0;
  15.     terminalInit();
  16.     setQoff();
  17.     rand_seed(193850185);
  18.     setTextColor(63);
  19.     printf("~~ INIT ~~\nChilloutVR CDP1802 scripting engine v0\n\n");
  20.     setTextColor(53);
  21.     printf("Button is OFF");
  22.  
  23.     while(1) {
  24.         if(flag) {
  25.             *emissionStrength = *emissionStrength - 1;
  26.             if(*emissionStrength == 0) flag = 0;
  27.         }else {
  28.             *emissionStrength = *emissionStrength + 1;
  29.             if(*emissionStrength == 255) flag = 1;
  30.         }
  31.         yield();
  32.         yield();
  33.  
  34.         if(*btnState) {
  35.             if(!btnHeld) {
  36.                 btnHeld = 1;
  37.                 *goToggle = *goToggle ? 0 : 255;
  38.                 if(*goToggle) {
  39.                     setTextColor(29);
  40.                     printf("\rButton is ON ");
  41.                 }else {
  42.                     setTextColor(53);
  43.                     printf("\rButton is OFF");
  44.                 }
  45.             }
  46.         }else btnHeld = 0;
  47.     }
  48. }
  49.  
  50. #include "cvrio.c"
  51. #include "math.c"
  52. #include "nstdlib.c"
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement