NCPrePatcher 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # NCPrePatcher
2
+
3
+ A preprocessor for [NCPatcher](https://github.com/TheGameratorT/NCPatcher) with access to your NDS ROM and a disassembler.
4
+
5
+ ## Installation
6
+
7
+ #### Requirements
8
+
9
+ - [Ruby (≥ 3.4 required)](https://www.ruby-lang.org/en/downloads/)
10
+
11
+ Go to Releases, download the .gem file for your platform, then open up the command line where it was downloaded to and enter:
12
+ ```console
13
+ gem install NCPrePatcher-[version]-[platform].gem
14
+ ```
15
+
16
+ The `ncpp` command should now be available at your command line (a system reboot may be required).
17
+
18
+ ## Usage
19
+
20
+ NCPrePatcher can be used as a Ruby library or, as it was built for, as a preprocessor alongside NCPatcher.
21
+
22
+ For the former, simply `require` it as you would with any gem:
23
+ ```ruby
24
+ require ncpp
25
+ ```
26
+
27
+ For the latter, navigate to an existing project using NCPatcher (where an `ncpatcher.json` file is present), and run:
28
+ ```console
29
+ ncpp
30
+ ```
31
+ Follow the directions given, and it will be installed into your project. Subsequently, running `ncpp` manually will no longer be required; being added as a pre-build command in `ncpatcher.json`, it will run when NCPatcher does.
32
+
33
+ For examples of usage as a preprocessor, see [ncpp-demos](https://github.com/pete420griff/ncpp-demos).
34
+
35
+ To view what else NCPrePatcher can do, run:
36
+ ```console
37
+ ncpp --help
38
+ ```
39
+
40
+ ## Building
41
+
42
+ > [!NOTE]
43
+ > This is an alternative to installing NCPrePatcher via the methods described in [the installation guide](#installation)
44
+
45
+ #### Requirements
46
+
47
+ - Ruby
48
+ - CMake and a modern C++ compiler
49
+ - Rust and Cargo
50
+
51
+ To build the required native libraries, go to /ext/ and run:
52
+ ```console
53
+ ruby build.rb
54
+ ```
55
+
56
+ Then go back to the base directory and run:
57
+ ```console
58
+ gem build ncpp.gemspec
59
+ ```
60
+
61
+ ## Credits
62
+
63
+ - Code from NCPatcher used by the **nitro** library
64
+ - [unarm](https://github.com/AetiasHax/unarm) used for disassembling
65
+ - [Ruby-FFI](https://github.com/ffi/ffi) used for binding the above libraries to Ruby
66
+ - [Parslet](https://github.com/kschiess/parslet) used for parsing the DSL
data/example/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Examples
2
+
3
+ This folder contains examples of using NCPrePatcher as a **Ruby library**.
data/example/disasm.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'ncpp'
2
+
3
+ start_time = Time.now
4
+
5
+ puts 'Loading rom...'
6
+ rom = Nitro::Rom.new('Ratatouille.nds')
7
+
8
+ NCPP.show_rom_info(rom)
9
+
10
+ puts "Ov0 sinit start: " + rom.ovt.get_entry(0)[:sinit_start].to_hex
11
+ puts "Ov1 sinit start: " + rom.ovt.get_entry(1)[:sinit_start].to_hex
12
+ puts "Ov2 sinit start: " + rom.ovt.get_entry(2)[:sinit_start].to_hex
13
+
14
+ # puts 'Loading symbols...'
15
+ # Unarm.load_symbols9('symbols9.x')
16
+
17
+ f = File.open('rat-disasm.txt', 'w')
18
+
19
+ puts 'Disassembling arm9...'
20
+
21
+ # Here we treat every word in the binary as if it's an arm instruction; this is of course not reality
22
+ rom.arm9.each_ins {|ins| f.puts "#{ins.addr.to_hex}: #{ins.str}" }
23
+
24
+ f.puts
25
+
26
+ rom.each_overlay do |ov, id|
27
+ puts "Disassembling overlay#{id}"
28
+ ov.each_ins {|ins| f.puts "#{ins.addr.to_hex}: #{ins.str}" }
29
+ f.puts
30
+ end
31
+
32
+ f.close
33
+
34
+ puts "Done! Took #{Time.now - start_time} seconds."
data/exe/ncpp ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ncpp'
4
+ NCPP.run(ARGV)