Class: Badline::SID

Inherits:
Object
  • Object
show all
Includes:
Addressable
Defined in:
lib/badline/sid.rb

Instance Attribute Summary

Attributes included from Addressable

#end, #length, #start

Instance Method Summary collapse

Methods included from Addressable

#[], #[]=, #addressable_at, #in_range?, #peek16, #poke16, #range

Methods included from IntegerHelper

#bcd, #bcd_to_i, #format16, #format8, #high_byte, #low_byte, #signed_int8, #uint16

Constructor Details

#initializeSID

Returns a new instance of SID.



7
8
9
10
# File 'lib/badline/sid.rb', line 7

def initialize
  addressable_at(0xd400, length: 2**10)
  @registers = Memory.new(length: 2**5)
end

Instance Method Details

#peek(addr) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/badline/sid.rb', line 12

def peek(addr)
  i = index(addr) % (2**5)
  case i
  when 0x1d..0x1f then 0xff # Unused memory
  else @registers.peek(i)
  end
end

#poke(addr, value) ⇒ Object



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

def poke(addr, value)
  i = index(addr) % (2**5)
  @registers.poke(i, value)
end