#!/usr/bin/ruby

code = open(ARGV[0], "r+")
lines = code.readlines
last = lines.pop

# 110001 10000000
# xx---x xxxxxxxx

lines.push(":02400E00143F5D\n")
lines.push(last)
code.seek(0)
lines.each {|l| l.gsub!(/\n/, "\r\n")}
code.write(lines.join)

#src = open(ARGV[1], "r+")
#lines = src.readlines
#(0..9).each {|l|
#	if lines[l] =~ /^\s*id/
#		print lines[l]
#		lines[l].gsub!(/(\d{4})/) { sprintf("%04d", $1.to_i + 1) }
#		break
#	end
#}
#src.seek(0)
#src.write(lines.join)

#:02400E00103F61(2F71)	# 16F819
#         ^^^^		# 3F10 -> 103F
#LcdThermo(16F819)
#FOSC	INTRC__RA6=I/O
#WDTE	Disable
#PWRTE	Enable
#MCLRE	RA5=I/O
#BODEN	Disable
#LVP	RB3=I/O
#CPD	Disable
#WRT	ALL_Enable
#DEBUG	Disable
#CCPMX	CCP1=RB2(RB3)
#CP		Disable

#:02400E00103F61	# 16F648A
#         ^^^^		# 3F10 -> 103F
#MasterZapper(16F648)
#FOSC	INTOSC_GPIO
#WDTE	Disable
#PWRTE	Enable
#MCLRE	Internal
#BODEN	Disable
#LVP	RB4:GPIO
#CPD	Disable
#CP		Disable

#:02400E008031FF	# 12F629/12F675
#         ^^^^		# 3184 -> 8031
#FanCtrl(12F629)
#FOSC	LP
#WDTE	Disable
#PWRTE	Enable
#MCLRE	Internal
#BODEN	Disable
#CP		Disable
#CPD	Disable

#:02400E008431FB	# 12F629/12F675
#         ^^^^		# 3184 -> 8431
#FanCtrl(12F629)
#FOSC	INTOSC(GP4:I/O)
#WDTE	Disable
#PWRTE	Enable
#MCLRE	Internal
#BODEN	Disable
#CP		Disable
#CPD	Disable

