aaaa
This commit is contained in:
@@ -8,3 +8,4 @@ It as of right now has no particular ambitions, but rather an exploration of emu
|
|||||||
Information about the system was found from the following:
|
Information about the system was found from the following:
|
||||||
- [[https://gekkio.fi/files/gb-docs/gbctr.pdf][Game Boy: Complete Technical reference]]
|
- [[https://gekkio.fi/files/gb-docs/gbctr.pdf][Game Boy: Complete Technical reference]]
|
||||||
- [[https://rylev.github.io/DMG-01/public/book/introduction.html][DMG-01: How to Emulate a Game Boy]]
|
- [[https://rylev.github.io/DMG-01/public/book/introduction.html][DMG-01: How to Emulate a Game Boy]]
|
||||||
|
- [[https://rgbds.gbdev.io/][RGBDS]]
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ rhl = lens (\r -> ((.<<. 8) . fromIntegral $ r ^. rh) + (fromIntegral $ r ^. rl)
|
|||||||
(\r w -> r & rh %~ (const $ fromIntegral $ w .>>. 8) & rl %~ (const $ fromIntegral $ w .&. 255))
|
(\r w -> r & rh %~ (const $ fromIntegral $ w .>>. 8) & rl %~ (const $ fromIntegral $ w .&. 255))
|
||||||
|
|
||||||
data CPU = CPU { _registers :: Registers
|
data CPU = CPU { _registers :: Registers
|
||||||
|
, _ir :: Word8
|
||||||
|
, _ie :: Word8
|
||||||
, _pc :: Word16
|
, _pc :: Word16
|
||||||
, _sp :: Word16
|
, _sp :: Word16
|
||||||
, _bus :: (V.Vector 65536 Word8) }
|
, _bus :: (V.Vector 65536 Word8) }
|
||||||
@@ -190,6 +192,18 @@ data Instruction where
|
|||||||
JRE :: { rel :: Int8 } -> Instruction
|
JRE :: { rel :: Int8 } -> Instruction
|
||||||
JRCCE :: { rel :: Int8, flag :: FlagTarget, op'' :: Bool -> Bool } -> Instruction
|
JRCCE :: { rel :: Int8, flag :: FlagTarget, op'' :: Bool -> Bool } -> Instruction
|
||||||
|
|
||||||
|
CALLNN :: { val' :: Word16 } -> Instruction
|
||||||
|
CALLCCNN :: { val' :: Word16, flag :: FlagTarget, op'' :: Bool -> Bool } -> Instruction
|
||||||
|
RET :: Instruction
|
||||||
|
RETCC :: { flag :: FlagTarget, op'' :: Bool -> Bool } -> Instruction
|
||||||
|
RETI :: Instruction
|
||||||
|
RSTN :: { val' :: Word16 } -> Instruction
|
||||||
|
HALT :: Instruction
|
||||||
|
STOP :: Instruction
|
||||||
|
DI :: Instruction
|
||||||
|
EI :: Instruction
|
||||||
|
NOP :: Instruction
|
||||||
|
|
||||||
execute :: CPU -> Instruction -> CPU
|
execute :: CPU -> Instruction -> CPU
|
||||||
execute cpu = \case
|
execute cpu = \case
|
||||||
ADDR t _c -> let value = cpu ^. t
|
ADDR t _c -> let value = cpu ^. t
|
||||||
@@ -434,6 +448,17 @@ execute cpu = \case
|
|||||||
cpu & pc .~ target
|
cpu & pc .~ target
|
||||||
else
|
else
|
||||||
cpu
|
cpu
|
||||||
|
CALLNN v -> undefined
|
||||||
|
CALLCCNN v _f op -> undefined
|
||||||
|
RET -> undefined
|
||||||
|
RETCC _f op -> undefined
|
||||||
|
RETI -> undefined
|
||||||
|
RSTN v -> undefined
|
||||||
|
HALT -> undefined
|
||||||
|
STOP -> undefined
|
||||||
|
DI -> undefined
|
||||||
|
EI -> undefined
|
||||||
|
NOP -> cpu
|
||||||
where
|
where
|
||||||
add :: Word8 -> Word8 -> Bool -> (Word8, FlagRegister)
|
add :: Word8 -> Word8 -> Bool -> (Word8, FlagRegister)
|
||||||
add o n _c = let new = o + n + if _c then 1 else 0
|
add o n _c = let new = o + n + if _c then 1 else 0
|
||||||
|
|||||||
Reference in New Issue
Block a user