Brian McKenna avatar Brian McKenna committed 25778e4

Move randomness into Haskell code

Comments (0)

Files changed (2)


 void oamMainSet(int x, int y) {
-        SPRITE_PALETTE[1] = RGB15(rand() % 32,0,0);
         oamSet(&oamMain, 0, x, y, 0, 0, SpriteSize_16x16,
                SpriteColorFormat_256Color, oamMainGraphics, -1, false, false,
                false, false, false);
+void oamMainColor(int r, int g, int b) {
+        SPRITE_PALETTE[1] = RGB15(r, g, b);
 void oamMainUpdate() {


+import Random
 foreign import ccall "nds.h consoleDemoInit" consoleDemoInit :: IO ()
 foreign import ccall "nds.h consoleClear" consoleClear :: IO ()
 foreign import ccall "nds.h swiWaitForVBlank" swiWaitForVBlank :: IO ()
 foreign import ccall "helpers.h oamMainInit" oamMainInit :: IO ()
 foreign import ccall "helpers.h oamMainSet" oamMainSet :: Int -> Int -> IO ()
+foreign import ccall "helpers.h oamMainColor" oamMainColor :: Int -> Int -> Int -> IO ()
 foreign import ccall "helpers.h oamMainUpdate" oamMainUpdate :: IO ()
 foreign import primitive "const.DutyCycle_50" dutyCycle_50 :: Int
       print getTouchY
       return ()
+    r <- randomRIO (0, 31)
+    oamMainColor r 0 0
     oamMainSet getTouchX getTouchY
     return ()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.