Class: Nitro::Rom
Instance Attribute Summary collapse
-
#arm7 ⇒ Object
readonly
Returns the value of attribute arm7.
-
#arm9 ⇒ Object
readonly
Returns the value of attribute arm9.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#overlay_count ⇒ Object
(also: #ov_count)
readonly
Returns the value of attribute overlay_count.
-
#overlay_table ⇒ Object
(also: #ov_table, #ovt)
readonly
Returns the value of attribute overlay_table.
-
#overlays ⇒ Object
readonly
Returns the value of attribute overlays.
Instance Method Summary collapse
- #each_overlay ⇒ Object (also: #each_ov)
- #get_file(id) ⇒ Object
- #get_file_size(id) ⇒ Object
- #get_overlay(id) ⇒ Object (also: #get_ov)
-
#initialize(file_path) ⇒ Rom
constructor
A new instance of Rom.
- #load_overlay(id) ⇒ Object (also: #load_ov)
- #nitro_sdk_version ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(file_path) ⇒ Rom
Returns a new instance of Rom.
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/nitro/nitro.rb', line 391 def initialize(file_path) @ptr = FFI::AutoPointer.new(nitroRom_alloc, method(:nitroRom_release)) # Check whether file exists here because if C++ throws an exception we get a segfault if !File.exist?(file_path) puts "Error: #{file_path} does not exist" raise "Rom initialization failed" end nitroRom_load(@ptr, file_path) @header = HeaderBin.new(nitroRom_getHeader(@ptr)) @arm9 = ArmBin.new(ptr: FFI::AutoPointer.new(nitroRom_loadArm9(@ptr), method(:armBin_release))) @arm7 = ArmBin.new(ptr: FFI::AutoPointer.new(nitroRom_loadArm7(@ptr), method(:armBin_release))) = nitroRom_getOverlayCount(@ptr) = Array.new() = OvtBin.new(ptr: nitroRom_getArm9OvT(@ptr), size: @header.arm9_ovt_size) define_ov_accessors end |
Instance Attribute Details
#arm7 ⇒ Object (readonly)
Returns the value of attribute arm7.
385 386 387 |
# File 'lib/nitro/nitro.rb', line 385 def arm7 @arm7 end |
#arm9 ⇒ Object (readonly)
Returns the value of attribute arm9.
385 386 387 |
# File 'lib/nitro/nitro.rb', line 385 def arm9 @arm9 end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
385 386 387 |
# File 'lib/nitro/nitro.rb', line 385 def header @header end |
#overlay_count ⇒ Object (readonly) Also known as: ov_count
Returns the value of attribute overlay_count.
385 386 387 |
# File 'lib/nitro/nitro.rb', line 385 def end |
#overlay_table ⇒ Object (readonly) Also known as: ov_table, ovt
Returns the value of attribute overlay_table.
385 386 387 |
# File 'lib/nitro/nitro.rb', line 385 def end |
#overlays ⇒ Object (readonly)
Returns the value of attribute overlays.
385 386 387 |
# File 'lib/nitro/nitro.rb', line 385 def end |
Instance Method Details
#each_overlay ⇒ Object Also known as: each_ov
441 442 443 444 445 |
# File 'lib/nitro/nitro.rb', line 441 def .times do |i| yield (i), i end end |
#get_file(id) ⇒ Object
414 415 416 |
# File 'lib/nitro/nitro.rb', line 414 def get_file(id) nitroRom_getFile(id) end |
#get_file_size(id) ⇒ Object
418 419 420 |
# File 'lib/nitro/nitro.rb', line 418 def get_file_size(id) nitroRom_getFileSize(id) end |
#get_overlay(id) ⇒ Object Also known as: get_ov
434 435 436 437 438 |
# File 'lib/nitro/nitro.rb', line 434 def (id) raise IndexError if id > -1 (id) if [id].nil? [id] end |
#load_overlay(id) ⇒ Object Also known as: load_ov
426 427 428 429 430 431 |
# File 'lib/nitro/nitro.rb', line 426 def (id) raise IndexError if id > -1 ov_ptr = nitroRom_loadOverlay(@ptr, id) raise "Failed to load overlay #{id}." if !ov_ptr [id] = OverlayBin.new(id, ptr: FFI::AutoPointer.new(ov_ptr, method(:overlayBin_release))) end |
#nitro_sdk_version ⇒ Object
422 423 424 |
# File 'lib/nitro/nitro.rb', line 422 def nitro_sdk_version @arm9.module_params[:sdk_version_id] end |
#size ⇒ Object
410 411 412 |
# File 'lib/nitro/nitro.rb', line 410 def size nitroRom_getSize(@ptr) end |