mirror of
https://github.com/mgcaret/rom4x.git
synced 2024-12-22 18:30:25 +00:00
79 lines
1.9 KiB
Ruby
79 lines
1.9 KiB
Ruby
source_rom = "iic+_rom5.bin"
|
|
dest_rom = "iic+_rom5x.bin"
|
|
rom_base = 0xc000
|
|
|
|
source_files = Rake::FileList.new('*.s')
|
|
|
|
desc "Default: clean and build it"
|
|
task :default => [:clean, :assemble, :build_rom] do
|
|
sh "ls -l #{dest_rom}"
|
|
end
|
|
|
|
desc "Clean object files"
|
|
task :clean do
|
|
sh "rm -f #{dest_rom}"
|
|
sh "rm -f sf512_#{dest_rom}"
|
|
sh "rm -f *.o"
|
|
sh "rm -f *.lst"
|
|
sh "rm -f *.b"
|
|
sh "rm -f accel5x"
|
|
sh "rm -f POOF1 *.po"
|
|
end
|
|
|
|
desc "Assemble all source files"
|
|
task :assemble => source_files.ext('.b')
|
|
|
|
rule ".o" => ".s" do |t|
|
|
sh "ca65 -l #{t.name}.lst #{t.source}"
|
|
end
|
|
|
|
rule ".b" => ".o" do |t|
|
|
sh "ld65 -t none -o #{t.name} #{t.source}"
|
|
end
|
|
|
|
desc "Build ROM"
|
|
task :build_rom => [:assemble] do
|
|
puts "Building ROM image..."
|
|
obj_files = Rake::FileList.new('*.b')
|
|
rom = File.read(source_rom)
|
|
obj_files.each do |t|
|
|
if t =~ /B(\h)_(\h{4})/
|
|
bnum = $1.to_i(16)
|
|
badd = $2.to_i(16)
|
|
addr = bnum * 16384 + badd - rom_base
|
|
fc = File.read(t)
|
|
fl = fc.bytes.count
|
|
puts "Loading #{t} into bank #{bnum} @ $#{badd.to_s(16)}, file addr $#{addr.to_s(16)}, len $#{fl.to_s(16)} (#{fl})"
|
|
nzc = 0
|
|
fc.each_byte do |b|
|
|
nzc += 1 if rom.getbyte(addr) != 0 && rom.getbyte(addr) != b
|
|
rom.setbyte(addr, b)
|
|
addr += 1
|
|
end
|
|
puts "\tNote: patched over #{nzc} nonzero bytes!" if nzc > 0
|
|
else
|
|
puts "I dont know where to load #{t}"
|
|
end
|
|
end
|
|
File.write(dest_rom, rom)
|
|
puts "ROM image done: #{dest_rom}"
|
|
end
|
|
|
|
desc "Build SST27SF512 Image"
|
|
task :sf512 => [:build_rom] do
|
|
sh "cat #{dest_rom} #{dest_rom} > sf512_#{dest_rom}"
|
|
end
|
|
|
|
desc "Build accel5x test binary"
|
|
task :accel5x do
|
|
sh "ca65 -D testaccel -o accel5x.o -l accel5x.lst B1_FD00_accel5x.s"
|
|
sh "ld65 -t none -o accel5x accel5x.o"
|
|
end
|
|
|
|
desc "Build accel5x test binary into accel5x.po disk image"
|
|
task :"accel5x.po" => [:accel5x] do
|
|
sh "to_pro -140 accel5x"
|
|
sh "mv -f POOF1 accel5x.po"
|
|
end
|
|
|