Skip to content

echojc/goboy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goboy

Game Boy emulator written in Go. I've always wanted to write an emulator.

See sister project echojc/gbasm.

Compiling

Dependencies:

go get github.com/deweerdt/gocui
go get github.com/go-gl/gl/v2.1/gl
go get github.com/go-gl/glfw/v3.1/glfw

Run:

go run *.go <data-file>

Features

  • cpu
  • bg
  • sprites
  • window
  • lcd status
  • keys
  • timer
  • sound
  • cartridge types
  • serial transfer
  • stop mode

Resources

DAA

Resources:

Tested in Scala:

scala> def daa(t: (Boolean, Boolean, Boolean, Int)) = { var (fn, fc, fh, r) = t; val i = if (fn) -1 else 1; if (fh || (r&0xf) > 0x09) r += (i * 0x06); if (fc || r > 0x99) (true, r + (i * 0x60)) else (false, r) }
daa: (t: (Boolean, Boolean, Boolean, Int))(Boolean, Int)

scala> def add(a : Int, b: Int) = { val r = a+b; val fh = ((a^b^r)&0x10) > 0; val fc = r > 0xff; (false, fc, fh, r&0xff) }
add: (a: Int, b: Int)(Boolean, Boolean, Boolean, Int)

scala> (for { a <- 0 to 99; b <- 0 to 99; (fc, r) = daa(add(toBcd(a), toBcd(b))) } yield (toBcd((a+b)%100), r%256)) forall (t => t._1 == t._2)
res49: Boolean = true

scala> (for { a <- 0 to 99; b <- 0 to 99; (fc, r) = daa(add(toBcd(a), toBcd(b))) } yield (fc, a + b >= 100)) forall (t => t._1 == t._2)
res51: Boolean = true

scala> def sub(a: Int, b: Int) = { var r = a-b; val fh = ((a^b^r)&0x10) > 0; val fc = r < 0; (true, fc, fh, r&0xff) }
sub: (a: Int, b: Int)(Boolean, Boolean, Boolean, Int)

scala> (for { a <- 0 to 99; b <- 0 to 99; (fc, r) = daa(sub(toBcd(a), toBcd(b))) } yield (toBcd(((a-b)%100+100)%100), r%256)) forall (t => t._1 == t._2)
res57: Boolean = true

scala> (for { a <- 0 to 99; b <- 0 to 99; (fc, r) = daa(sub(toBcd(a), toBcd(b))) } yield (fc, a < b)) forall (t => t._1 == t._2)
res59: Boolean = true

About

Trying my hand at a Game Boy emulator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages