From: Lucian Mogosanu Date: Sat, 13 Dec 2014 17:08:34 +0000 (+0200) Subject: Z80: Add most basic primitives X-Git-Url: https://git.mogosanu.ro/?a=commitdiff_plain;h=ba5b52bf86f1363ee056fb44ac30fc69ced3815e;p=z80.git Z80: Add most basic primitives --- diff --git a/src/Z80/CPU.hs b/src/Z80/CPU.hs index 2d34f11..9114d90 100644 --- a/src/Z80/CPU.hs +++ b/src/Z80/CPU.hs @@ -29,29 +29,3 @@ data Prefixed = | DDCBPrefixed | FDCBPrefixed deriving (Show, Eq) - --- not really into lenses so we're using these for now -setAF, setBC, setDE, setHL :: CPU -> Word16 -> CPU -setAF cpu w = cpu { af = w } -setBC cpu w = cpu { bc = w } -setDE cpu w = cpu { de = w } -setHL cpu w = cpu { hl = w } - -setAF', setBC', setDE', setHL' :: CPU -> Word16 -> CPU -setAF' cpu w = cpu { af' = w } -setBC' cpu w = cpu { bc' = w } -setDE' cpu w = cpu { de' = w } -setHL' cpu w = cpu { hl' = w } - -setIX, setIY, setSP, setPC :: CPU -> Word16 -> CPU -setIX cpu w = cpu { ix = w } -setIY cpu w = cpu { iy = w } -setSP cpu w = cpu { sp = w } -setPC cpu w = cpu { pc = w } - -setI, setR :: CPU -> Word8 -> CPU -setI cpu b = cpu { i = b } -setR cpu b = cpu { r = b } - -setPrefixed :: CPU -> Prefixed -> CPU -setPrefixed cpu p = cpu { prefixed = p } diff --git a/src/Z80/Primitives.hs b/src/Z80/Primitives.hs new file mode 100644 index 0000000..a0be8df --- /dev/null +++ b/src/Z80/Primitives.hs @@ -0,0 +1,27 @@ +module Z80.Primitives where + +-- not really into lenses so we're using these for now +setAF, setBC, setDE, setHL :: CPU -> Word16 -> CPU +setAF cpu w = cpu { af = w } +setBC cpu w = cpu { bc = w } +setDE cpu w = cpu { de = w } +setHL cpu w = cpu { hl = w } + +setAF', setBC', setDE', setHL' :: CPU -> Word16 -> CPU +setAF' cpu w = cpu { af' = w } +setBC' cpu w = cpu { bc' = w } +setDE' cpu w = cpu { de' = w } +setHL' cpu w = cpu { hl' = w } + +setIX, setIY, setSP, setPC :: CPU -> Word16 -> CPU +setIX cpu w = cpu { ix = w } +setIY cpu w = cpu { iy = w } +setSP cpu w = cpu { sp = w } +setPC cpu w = cpu { pc = w } + +setI, setR :: CPU -> Word8 -> CPU +setI cpu b = cpu { i = b } +setR cpu b = cpu { r = b } + +setPrefixed :: CPU -> Prefixed -> CPU +setPrefixed cpu p = cpu { prefixed = p }