2020-11-15 23:23:01 -08:00
|
|
|
require "colorize"
|
2021-05-06 00:29:04 -07:00
|
|
|
require "option_parser"
|
2020-11-15 23:23:01 -08:00
|
|
|
|
2020-09-23 08:21:56 -07:00
|
|
|
require "bitfield"
|
2020-10-02 23:30:14 -07:00
|
|
|
require "sdl"
|
2020-09-23 08:21:56 -07:00
|
|
|
|
2021-05-06 00:29:04 -07:00
|
|
|
require "./crab/common/*"
|
2021-06-16 19:39:37 -07:00
|
|
|
require "./crab/common/frontend/*"
|
2021-05-06 00:29:04 -07:00
|
|
|
require "./crab/gb"
|
2020-08-22 00:15:30 -07:00
|
|
|
require "./crab/gba"
|
|
|
|
|
2020-12-27 20:35:34 -08:00
|
|
|
Colorize.on_tty_only!
|
|
|
|
|
2020-08-22 00:15:30 -07:00
|
|
|
module Crab
|
|
|
|
VERSION = "0.1.0"
|
|
|
|
|
|
|
|
extend self
|
|
|
|
|
|
|
|
def run
|
2021-05-06 00:29:04 -07:00
|
|
|
rom = nil
|
|
|
|
bios = nil
|
|
|
|
fifo = false
|
|
|
|
headless = false
|
|
|
|
|
|
|
|
OptionParser.parse do |parser|
|
|
|
|
parser.banner = "#{"crab".colorize.bold} - An accurate and readable Game Boy (Color) (Advance) emulator"
|
|
|
|
parser.separator
|
|
|
|
parser.separator("Usage: bin/crab [BIOS] ROM")
|
|
|
|
parser.separator
|
|
|
|
parser.on("-h", "--help", "Show the help message") do
|
|
|
|
puts parser
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
parser.on("--fifo", "Enable FIFO rendering") { fifo = true }
|
|
|
|
parser.on("--headless", "Don't open window or play audio") { headless = true }
|
|
|
|
parser.unknown_args do |args|
|
|
|
|
case args.size
|
|
|
|
when 1 then rom = args[0]
|
|
|
|
when 2 then bios, rom = args[0], args[1]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-18 17:39:50 -07:00
|
|
|
frontend = Frontend.new(bios, rom, headless)
|
2021-06-16 19:39:37 -07:00
|
|
|
frontend.run
|
2020-08-22 00:15:30 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
unless PROGRAM_NAME.includes?("crystal-run-spec")
|
|
|
|
Crab.run
|
|
|
|
end
|