Class: Badline::Cartridge

Inherits:
Object
  • Object
show all
Defined in:
lib/badline/cartridge.rb,
lib/badline/cartridge/ocean.rb,
lib/badline/cartridge/standard.rb,
lib/badline/cartridge/magic_desk.rb

Direct Known Subclasses

MagicDesk, Ocean, Standard

Defined Under Namespace

Classes: MagicDesk, Ocean, Standard, UnsupportedTypeError

Constant Summary collapse

ROML_START =
0x8000
ROMH_START =
0xa000
ULTIMAX_ROMH_START =
0xe000
BANK_SIZE =
0x2000
HARDWARE_TYPES =
{ 0 => :Standard, 5 => :Ocean, 19 => :MagicDesk }.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(crt) ⇒ Cartridge

Returns a new instance of Cartridge.



34
35
36
37
38
39
40
41
# File 'lib/badline/cartridge.rb', line 34

def initialize(crt)
  @name = crt.name
  @exrom = crt.exrom
  @game = crt.game
  @roml = @romh = nil
  @on_change = nil
  install_chips(crt.chips)
end

Instance Attribute Details

#exromObject (readonly)

Returns the value of attribute exrom.



18
19
20
# File 'lib/badline/cartridge.rb', line 18

def exrom
  @exrom
end

#gameObject (readonly)

Returns the value of attribute game.



18
19
20
# File 'lib/badline/cartridge.rb', line 18

def game
  @game
end

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/badline/cartridge.rb', line 18

def name
  @name
end

#romhObject (readonly)

Returns the value of attribute romh.



18
19
20
# File 'lib/badline/cartridge.rb', line 18

def romh
  @romh
end

#romlObject (readonly)

Returns the value of attribute roml.



18
19
20
# File 'lib/badline/cartridge.rb', line 18

def roml
  @roml
end

Class Method Details

.from_crt(crt) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/badline/cartridge.rb', line 25

def from_crt(crt)
  type = HARDWARE_TYPES.fetch(crt.hardware_type) do
    raise UnsupportedTypeError,
          "Unsupported cartridge hardware type #{crt.hardware_type}"
  end
  const_get(type).new(crt)
end

.from_file(path) ⇒ Object



21
22
23
# File 'lib/badline/cartridge.rb', line 21

def from_file(path)
  from_crt(Storage::CRTFile.new(path))
end

Instance Method Details

#on_change(&block) ⇒ Object



43
44
45
# File 'lib/badline/cartridge.rb', line 43

def on_change(&block)
  @on_change = block
end

#peek(_addr) ⇒ Object

IO1/IO2 reads are open bus unless a mapper says otherwise.



52
53
54
# File 'lib/badline/cartridge.rb', line 52

def peek(_addr)
  0xff
end

#poke(_addr, _value) ⇒ Object



56
# File 'lib/badline/cartridge.rb', line 56

def poke(_addr, _value); end

#ultimax?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/badline/cartridge.rb', line 47

def ultimax?
  @game.zero? && @exrom == 1
end