-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[warning] ⚠️ broken commit of background manipulation
- Loading branch information
Showing
5 changed files
with
98 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,28 @@ | ||
module Main where | ||
|
||
import qualified Data.Text.Lazy.IO as T | ||
import Data.Matrix | ||
import qualified Data.Text.Lazy.IO as T | ||
import Data.Word | ||
import Lazyboy | ||
import Lazyboy.IO.Graphics | ||
import Lazyboy.Prelude | ||
import Lazyboy.Target.ASM | ||
import Prelude hiding ((&&), (/=), (<), (==), (>), (||)) | ||
import Prelude hiding ((&&), (/=), (<), (==), (>), (||)) | ||
|
||
-- [TODO] it seems like the registers get overwritten and break the control flow in this program | ||
-- to fix that, let's make use of the stack to store state before we make any changes | ||
-- see here: http://gameboy.mongenel.com/dmg/lesson1.html (search: STACK) | ||
main :: IO () | ||
main = rom >>= T.putStrLn | ||
where rom = compileROM $ do | ||
byte A 0xDE | ||
byte B 0xDE | ||
if' ((A == (0xDE :: Word8)) && (A == B)) $ do | ||
write (Address wram0) 0xDE | ||
let tilemap = matrix 32 32 $ \_ -> 1 | ||
let sprite = [0x00,0x00,0x00,0x00,0x24,0x24,0x00,0x00,0x81,0x81,0x7e,0x7e,0x00,0x00,0x00,0x00] | ||
sprite' <- embedBytes sprite | ||
setScroll (0, 0) | ||
setBackgroundPalette defaultPalette | ||
onVblank $ do | ||
disableLCD | ||
memcpy (Name sprite') (Address $ 0x9010) $ fromIntegral $ length sprite | ||
updateTilemap tilemap | ||
setLCDControl $ defaultLCDControl { lcdDisplayEnable = True, lcdBackgroundEnable = True } | ||
freeze |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{-| | ||
Module : Data.Bits.Extra | ||
Description : Additional bitwise functions used by Lazyboy | ||
Copyright : (c) Rose 2019 | ||
License : BSD3 | ||
Maintainer : rose@lain.org.uk | ||
Stability : experimental | ||
Portability : POSIX | ||
This module extends Data.Bits with additional functionality. | ||
-} | ||
|
||
module Data.Bits.Extra where | ||
|
||
import Data.Bits | ||
import Data.Word | ||
|
||
-- | Split a 16 bit integer into its two 8 bit component parts. | ||
split :: Word16 -> (Word8, Word8) | ||
split n = (fromIntegral $ n `shiftR` 8, fromIntegral $ n .&. 0x00FF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters