Skip to content

Commit

Permalink
broken build while i move laptops
Browse files Browse the repository at this point in the history
  • Loading branch information
ix committed Sep 7, 2019
1 parent cdea798 commit 8cb48ca
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 81 deletions.
4 changes: 2 additions & 2 deletions example/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import Prelude hiding ((&&), (/=), (<), (==), (>), (||))
main :: IO ()
main = rom >>= T.putStrLn
where rom = compileROM $ do
let tilemap = matrix 31 31 $ \_ -> 0
let tilemap = matrix 31 31 $ const 0
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 $ 0x9000) $ fromIntegral $ length sprite
memcpy (Name sprite') (Address 0x9000) $ fromIntegral $ length sprite
updateTilemap tilemap
setLCDControl $ defaultLCDControl { lcdDisplayEnable = True, lcdBackgroundEnable = True }
freeze
32 changes: 16 additions & 16 deletions lazyboy.cabal
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.31.1.
-- This file has been generated from package.yaml by hpack version 0.31.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: 40ed3a8c4154cea848dce54c8ed9103dcecbe85b39d4e4716a55d48a59198782
-- hash: 0c999a1b9bbfbbc0435e270f359fcb16ce0a6d3826017f4c28b9951055f350b6

name: lazyboy
version: 0.2.2.1
Expand Down Expand Up @@ -46,13 +46,13 @@ library
src
ghc-options: -optP-Wno-nonportable-include-path
build-depends:
aeson >=1.4.2.0 && <1.5
, base >=4.7 && <5
, hspec >=2.6.1 && <2.7
, matrix >=0.3.6 && <0.4
, microstache >=1.0.1.1 && <1.1
, text >=1.2.3.1 && <1.3
, transformers >=0.5.6.2 && <0.6
aeson
, base
, hspec
, matrix
, microstache
, text
, transformers
default-language: Haskell2010

test-suite lazyboy-test
Expand All @@ -64,12 +64,12 @@ test-suite lazyboy-test
test
ghc-options: -optP-Wno-nonportable-include-path -threaded -rtsopts -with-rtsopts=-N
build-depends:
aeson >=1.4.2.0 && <1.5
, base >=4.7 && <5
, hspec >=2.6.1 && <2.7
aeson
, base
, hspec
, lazyboy
, matrix >=0.3.6 && <0.4
, microstache >=1.0.1.1 && <1.1
, text >=1.2.3.1 && <1.3
, transformers >=0.5.6.2 && <0.6
, matrix
, microstache
, text
, transformers
default-language: Haskell2010
14 changes: 7 additions & 7 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ data-files: templates/*.mustache
description: An EDSL for programming the Nintendo Game Boy. <https://github.com/ix/lazyboy#readme>

dependencies:
- aeson >= 1.4.2.0 && < 1.5
- base >= 4.7 && < 5
- hspec >= 2.6.1 && < 2.7
- microstache >= 1.0.1.1 && < 1.1
- text >= 1.2.3.1 && < 1.3
- transformers >= 0.5.6.2 && < 0.6
- matrix >= 0.3.6 && < 0.4
- aeson
- base
- hspec
- microstache
- text
- transformers
- matrix

library:
source-dirs: src
Expand Down
15 changes: 5 additions & 10 deletions src/Lazyboy/Control.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ not action = do
and :: Lazyboy Condition -> Lazyboy Condition -> Lazyboy Condition
and a b = protecting [AF, HL] $ do
a' <- a
cond a' $ do
tell [LDrn L 1]
cond a' $ tell [LDrn L 1]
b' <- b
cond b' $ do
tell [LDrn A 1]
cond b' $ tell [LDrn A 1]
tell [ANDr L]
return Zero

Expand All @@ -161,11 +159,9 @@ and a b = protecting [AF, HL] $ do
or :: Lazyboy Condition -> Lazyboy Condition -> Lazyboy Condition
or a b = protecting [AF, HL] $ do
a' <- a
cond a' $ do
tell [LDrn L 1]
cond a' $ tell [LDrn L 1]
b' <- b
cond b' $ do
tell [LDrn A 1]
cond b' $ tell [LDrn A 1]
tell [ORr L]
return Zero

Expand All @@ -175,8 +171,7 @@ while condition block = do
loop <- getLocalLabel
skip <- getLocalLabel
tell [LABEL loop]
if' (not condition) $ do
tell [JP $ Name skip]
if' (not condition) $ tell [JP $ Name skip]
block
tell [JP $ Name loop]
tell [LABEL skip]
Expand Down
2 changes: 1 addition & 1 deletion src/Lazyboy/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ memset dest len value = protecting [AF, HL, BC] $ do

-- | Executes an action when vertical blank occurs.
onVblank :: Lazyboy () -> Lazyboy ()
onVblank block = protecting [AF] $ do
onVblank block = protecting [AF] $
withLocalLabel $ \label -> do
tell [LDAnn $ Address ly, CPn 145]
tell [JPif NonZero $ Name label]
Expand Down
11 changes: 6 additions & 5 deletions src/Lazyboy/IO/Graphics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import Text.Printf
import Type.Reflection (Typeable)

-- | Type alias that represents a tile map as a Matrix.
type Tilemap = Matrix Integer
type Tilemap = Matrix Word8

-- | An exception type for use in this module.
data GraphicsException a = ExceedsBounds a (a, a)

-- | An instance of Show for formatting exception messages.
instance (Show a) => Show (GraphicsException a) where
instance Show a => Show (GraphicsException a) where
show (ExceedsBounds value bounds) = mconcat ["A value of '", show value, "' was provided to a function accepting a value in the range of (", show $ fst bounds, ", ", show $ snd bounds, ")!"]

-- | An instance of Exception for the exceptional type.
Expand All @@ -59,7 +59,7 @@ updateTilemap tiles = protecting [HL, DE, BC] $ do
inc DE
inc BC

where bytes = map fromIntegral $ toList tiles
where bytes = toList tiles
(high, low) = split count
count = fromIntegral $ length tiles - 1

Expand All @@ -85,10 +85,11 @@ setTile x y tile

-- | Set the X scroll co-ordinate.
setScrollX :: Word8 -> Lazyboy ()
setScrollX x = write (Address GB.scx) x
setScrollX = write (Address GB.scx)

-- | Set the Y scroll co-ordinate.
setScrollY :: Word8 -> Lazyboy ()
setScrollY y = write (Address GB.scy) y
setScrollY = write (Address GB.scy)

-- | Set the X and Y scroll co-ordinates.
setScroll :: (Word8, Word8) -> Lazyboy ()
Expand Down
78 changes: 39 additions & 39 deletions src/Lazyboy/Target/ASM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ instance Show Instruction where
show (LDnnA v1) = printf "ld [%s], A" v1
show (LDAIO v1) = printf "ldh A, [$FF00+$%X]" v1
show (LDIOA v1) = printf "ldh [$FF00+$%X], A" v1
show (LDAIOC) = printf "ldh A, [$FF00+C]"
show (LDIOCA) = printf "ldh [$FF00+C], A"
show (LDHLAI) = printf "ld [HL+], A"
show (LDAHLI) = printf "ld A, [HL+]"
show LDAIOC = printf "ldh A, [$FF00+C]"
show LDIOCA = printf "ldh [$FF00+C], A"
show LDHLAI = printf "ld [HL+], A"
show LDAHLI = printf "ld A, [HL+]"

-- handle some special cases for ld rr,nn
show (LDrrnn AF _) = throw AttemptedAFPCLoad
show (LDrrnn PC _) = throw AttemptedAFPCLoad
show (LDrrnn r1 v1) = printf "ld %s, %s" r1 v1

show (LDSPHL) = printf "ld SP, HL"
show LDSPHL = printf "ld SP, HL"

-- stack manipulation
show (PUSH SP) = throw InvalidStackOperation
Expand All @@ -97,17 +97,17 @@ instance Show Instruction where
show (JP v1@(Address _)) = printf "jp %s" v1
show (JP v1@(Name (Global _))) = printf "jp %s" v1
show (JP v1@(Name (Local _))) = printf "jr %s" v1
show (JPHL) = printf "jp HL"
show JPHL = printf "jp HL"
show (JPif c v1@(Address _)) = printf "jp %s, %s" c v1
show (JPif c v1@(Name (Global _))) = printf "jp %s, %s" c v1
show (JPif c v1@(Name (Local _))) = printf "jr %s, %s" c v1

-- call and return
show (CALL v1) = printf "call %s" v1
show (CALLif c v1) = printf "call %s, %s" c v1
show (RET) = printf "ret"
show RET = printf "ret"
show (RETif c) = printf "ret %s" c
show (RETi) = printf "reti"
show RETi = printf "reti"

show (RST 0x00) = printf "RST $00"
show (RST 0x08) = printf "RST $08"
Expand All @@ -122,35 +122,35 @@ instance Show Instruction where
-- arithmetic and comparisons
show (ADDAr r1) = printf "add A, %s" r1
show (ADDAn v) = printf "add A, %d" v
show (ADDHL) = printf "add A, [HL]"
show ADDHL = printf "add A, [HL]"
show (ADCAr r1) = printf "adc A, %s" r1
show (ADCAn v) = printf "adc A, %d" v
show (ADCHL) = printf "adc A, [HL]"
show ADCHL = printf "adc A, [HL]"
show (SUBAr r1) = printf "sub A, %s" r1
show (SUBAn v) = printf "sub A, %d" v
show (SUBHL) = printf "sub A, [HL]"
show SUBHL = printf "sub A, [HL]"
show (SBCAr r1) = printf "sbc A, %s" r1
show (SBCAn v) = printf "sbc A, %d" v
show (SBCAHL) = printf "sbc A, [HL]"
show SBCAHL = printf "sbc A, [HL]"

show (ANDr r1) = printf "and A, %s" r1
show (ANDn v) = printf "and A, %d" v
show (ANDHL) = printf "and A, [HL]"
show ANDHL = printf "and A, [HL]"
show (XORr r1) = printf "xor A, %s" r1
show (XORn v) = printf "xor A, %d" v
show (XORHL) = printf "xor A, [HL]"
show XORHL = printf "xor A, [HL]"
show (ORr r1) = printf "or A, %s" r1
show (ORn v) = printf "or A, %d" v
show (ORHL) = printf "or A, [HL]"
show ORHL = printf "or A, [HL]"
show (CPr r1) = printf "cp A, %s" r1
show (CPn v) = printf "cp A, %d" v
show (CPHL) = printf "cp A, [HL]"
show CPHL = printf "cp A, [HL]"
show (INCr r1) = printf "inc %s" r1
show (INCHL) = printf "inc [HL]"
show INCHL = printf "inc [HL]"
show (DECr r1) = printf "dec %s" r1
show (DECHL) = printf "dec [HL]"
show (DAA) = printf "daa"
show (CPL) = printf "cpl"
show DECHL = printf "dec [HL]"
show DAA = printf "daa"
show CPL = printf "cpl"
show (ADDHLrr BC) = printf "add HL, BC"
show (ADDHLrr DE) = printf "add HL, DE"
show (ADDHLrr HL) = printf "add HL, HL"
Expand All @@ -168,35 +168,35 @@ instance Show Instruction where
show (DECrr r1) = throw $ IllegalModification r1

-- Rotate & shift
show (RLCA) = printf "rlca"
show (RLA) = printf "rla"
show (RRCA) = printf "rrca"
show (RRA) = printf "rra"
show RLCA = printf "rlca"
show RLA = printf "rla"
show RRCA = printf "rrca"
show RRA = printf "rra"
show (RLC r1) = printf "rlc %s" r1
show (RLCHL) = printf "rlc [HL]"
show RLCHL = printf "rlc [HL]"
show (RL r1) = printf "rl %s" r1
show (RLHL) = printf "rl [HL]"
show RLHL = printf "rl [HL]"
show (RRC r1) = printf "rrc %s" r1
show (RRCHL) = printf "rrc [HL]"
show RRCHL = printf "rrc [HL]"
show (RR r1) = printf "rr %s" r1
show (RRHL) = printf "rr [HL]"
show RRHL = printf "rr [HL]"
show (SLA r1) = printf "sla %s" r1
show (SLAHL) = printf "sla [HL]"
show SLAHL = printf "sla [HL]"
show (SWAP r1) = printf "swap %s" r1
show (SWAPHL) = printf "swap [HL]"
show SWAPHL = printf "swap [HL]"
show (SRA r1) = printf "sra %s" r1
show (SRAHL) = printf "sra [HL]"
show SRAHL = printf "sra [HL]"
show (SRL r1) = printf "srl %s" r1
show (SRLHL) = printf "srl [HL]"
show SRLHL = printf "srl [HL]"

-- CPU control
show (CCF) = printf "ccf"
show (SCF) = printf "scf"
show (NOP) = printf "nop"
show (HALT) = printf "halt"
show (STOP) = printf "stop"
show (DI) = printf "di"
show (EI) = printf "ei"
show CCF = printf "ccf"
show SCF = printf "scf"
show NOP = printf "nop"
show HALT = printf "halt"
show STOP = printf "stop"
show DI = printf "di"
show EI = printf "ei"

-- Bit manipulation
show (BITnr v r1)
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-13.17
resolver: lts-14.4

# User packages to be built.
# Various formats can be used as shown in the example below.
Expand Down
12 changes: 12 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
snapshots:
- completed:
size: 523884
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/4.yaml
sha256: 16f24be248b42c9e16d59db84378836b1e7c239448a041cae46d32daffa45a8b
original: lts-14.4

0 comments on commit 8cb48ca

Please sign in to comment.