Class: Badline::Cartridge
- Inherits:
-
Object
- Object
- Badline::Cartridge
- Defined in:
- lib/badline/cartridge.rb,
lib/badline/cartridge/ocean.rb,
lib/badline/cartridge/standard.rb,
lib/badline/cartridge/magic_desk.rb
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
-
#exrom ⇒ Object
readonly
Returns the value of attribute exrom.
-
#game ⇒ Object
readonly
Returns the value of attribute game.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#romh ⇒ Object
readonly
Returns the value of attribute romh.
-
#roml ⇒ Object
readonly
Returns the value of attribute roml.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(crt) ⇒ Cartridge
constructor
A new instance of Cartridge.
- #on_change(&block) ⇒ Object
-
#peek(_addr) ⇒ Object
IO1/IO2 reads are open bus unless a mapper says otherwise.
- #poke(_addr, _value) ⇒ Object
- #ultimax? ⇒ Boolean
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
#exrom ⇒ Object (readonly)
Returns the value of attribute exrom.
18 19 20 |
# File 'lib/badline/cartridge.rb', line 18 def exrom @exrom end |
#game ⇒ Object (readonly)
Returns the value of attribute game.
18 19 20 |
# File 'lib/badline/cartridge.rb', line 18 def game @game end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/badline/cartridge.rb', line 18 def name @name end |
#romh ⇒ Object (readonly)
Returns the value of attribute romh.
18 19 20 |
# File 'lib/badline/cartridge.rb', line 18 def romh @romh end |
#roml ⇒ Object (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 |
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
47 48 49 |
# File 'lib/badline/cartridge.rb', line 47 def ultimax? @game.zero? && @exrom == 1 end |