class GBTiles::GBT::Export::ASM::Channel
Constants
- NOTES
Attributes
channel_number[RW]
Public Class Methods
new(channel_number)
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 41 def initialize channel_number @channel_number = channel_number end
Public Instance Methods
convert_effect()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 102 def convert_effect if effect_number == 0x0 then return effect_arpeggio end if effect_number == 0xB then return effect_jump end if effect_number == 0xC then return effect_volume end if effect_number == 0xD then return effect_break_and_set_step end if effect_number == 0xE && effect_param_1 == 0x8 then return effect_pan end if effect_number == 0xE && effect_param_1 == 0xC then return effect_cut_note end if effect_number == 0xF then return effect_speed end throw "Unsupported effect" end
convert_speed(speed)
click to toggle source
Amiga’s 50 Hz to GB’s 60 Hz
# File lib/gbtiles/gbt/export/asm/channel.rb, line 98 def convert_speed speed speed * 60 / 50 end
convert_volume()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 93 def convert_volume (effect_param == 64) ? 0xF : (effect_param >> 2); end
data()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 29 def data @data end
data=(value)
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 33 def data=(value) if value.kind_of?(Array) then @data = value else @data = value.unpack('CCCC') end end
effect_number()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 73 def effect_number @data[2] & 0xF end
effect_param()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 77 def effect_param @data[3] end
effect_param_1()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 81 def effect_param_1 (@data[3] & 0xF0) >> 4 end
effect_param_2()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 85 def effect_param_2 @data[3] & 0x0F end
effect_param_as_bcd()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 89 def effect_param_as_bcd (((effect_param & 0xF0) >> 4) * 10) + (effect_param & 0xF) end
is_empty_effect?()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 69 def is_empty_effect? effect_number == 0 && effect_param == 0 end
is_noise?()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 55 def is_noise? false end
is_pulse?()
click to toggle source
Channel
information
# File lib/gbtiles/gbt/export/asm/channel.rb, line 47 def is_pulse? false end
is_wav?()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 51 def is_wav? false end
note_index()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 134 def note_index period = sample_period if period <= 0 then return -1 end if !is_noise? then if !period.between?(NOTES.last, NOTES.first) then throw "Note `#{period}` out of bounds" end end NOTES.index( NOTES.min_by { |x| (period - x).abs } ) end
sample_number()
click to toggle source
Data
# File lib/gbtiles/gbt/export/asm/channel.rb, line 61 def sample_number (@data[0] & 0xF0) | ((@data[2] & 0xF0) >> 4) end
sample_period()
click to toggle source
# File lib/gbtiles/gbt/export/asm/channel.rb, line 65 def sample_period @data[1] | ((@data[0] & 0xF) << 8) end