# $Id: 12c.kml 749 2005-06-06 20:17:05Z eric $
# Copyright 2004, 2005 Eric L. Smith <eric@brouhaha.com>

# Nonpareil is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.  Note that I am not
# granting permission to redistribute or modify Nonpareil under the
# terms of any later version of the General Public License.

# Nonpareil is distributed in the hope that they will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program (in the file "COPYING"); if not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111, USA.

global
	title "12C Financial Calculator"
	author "Eric Smith <eric@brouhaha.com> and John R. Hogerhuis"
	hardware "Voyager"
	model "12c"
	rom "12c.obj"
	image "12c.png"
	color 0 137 0 6	  # background color, used when transparency is off
	# transparency 128
end

background
	offset 0 0
	size 558 350
end

display
	offset 73 29
	size 305 55

	color 0  165 175 145  # background
	color 1  165 175 145  # unlit segments
	color 2    0   0   0  # lit segments

	annunciator  1  size  5  7 offset  13 42  end  # * (battery low)
	annunciator  2  size 23  7 offset  45 42  end  # USER
	annunciator  3  size  5  7 offset  88 42  end  # f
	annunciator  4  size  6  8 offset 105 44  end  # g
	annunciator  5  size 27  7 offset 124 42  end  # BEGIN
	annunciator  6  size  5  7 offset 181 42  end  # G
	annunciator  7  size 17  7 offset 187 42  end  # RAD
	annunciator  8  size 20  7 offset 211 42  end  # D.MY
	annunciator  9  size  5  7 offset 244 42  end  # C
	annunciator 10  size 23  7 offset 271 42  end  # PRGM

	digits 11
		size 27 31
		offset 5 4
	end

	segment 'a' scaled offset 560 2 size 157 182
                           color 255   0   0  end       # red

	segment 'b' scaled offset 560 2 size 157 182
                           color   0 255   0  end       # green

	segment 'c' scaled offset 560 2 size 157 182
                           color   0   0 255  end       # blue

	segment 'd' scaled offset 560 2 size 157 182
                           color 255 255   0  end       # yellow

	segment 'e' scaled offset 560 2 size 157 182
                           color 255   0 255  end       #

	segment 'f' scaled offset 560 2 size 157 182
                           color   0 255 255  end       #

	segment 'g' scaled offset 560 2 size 157 182
                           color 255 128   0  end       # orange

	segment 'h' scaled offset 560 2 size 157 182    # dot
                           color 255   0 128  end       # pink

	segment 'i' scaled offset 560 2 size 157 182    # comma
                           color 128   0   0  end       # dark red

end # display

button 11  type 0  size 38 32  offset  18 130  down 2 8 keycode 0x13  end
button 12  type 0  size 38 32  offset  72 130  down 2 8 keycode 0x33  end
button 13  type 0  size 38 32  offset 126 130  down 2 8 keycode 0x73  end
button 14  type 0  size 38 32  offset 180 130  down 2 8 keycode 0xc3  end
button 15  type 0  size 38 32  offset 234 130  down 2 8 keycode 0x83  end
button 16  type 0  size 38 32  offset 288 130  down 2 8 keycode 0x82  end
button 17  type 0  size 38 32  offset 342 130  down 2 8 keycode 0xc2  end
button 18  type 0  size 38 32  offset 396 130  down 2 8 keycode 0x72  end
button 19  type 0  size 38 32  offset 450 130  down 2 8 keycode 0x32  end
button 10  type 0  size 38 32  offset 504 130  down 2 8 keycode 0x12  end

button 21  type 0  size 38 32  offset  18 186  down 2 8 keycode 0x10  end
button 22  type 0  size 38 32  offset  72 186  down 2 8 keycode 0x30  end
button 23  type 0  size 38 32  offset 126 186  down 2 8 keycode 0x70  end
button 24  type 0  size 38 32  offset 180 186  down 2 8 keycode 0xc0  end
button 25  type 0  size 38 32  offset 234 186  down 2 8 keycode 0x80  end
button 26  type 0  size 38 32  offset 288 186  down 2 8 keycode 0x87  end
button 27  type 0  size 38 32  offset 342 186  down 2 8 keycode 0xc7  end
button 28  type 0  size 38 32  offset 396 186  down 2 8 keycode 0x77  end
button 29  type 0  size 38 32  offset 450 186  down 2 8 keycode 0x37  end
button 20  type 0  size 38 32  offset 504 186  down 2 8 keycode 0x17  end

button 31  type 0  size 38 32  offset  18 242  down 2 8 keycode 0x11  end
button 32  type 0  size 38 32  offset  72 242  down 2 8 keycode 0x31  end
button 33  type 0  size 38 32  offset 126 242  down 2 8 keycode 0x71  end
button 34  type 0  size 38 32  offset 180 242  down 2 8 keycode 0xc1  end
button 35  type 0  size 38 32  offset 234 242  down 2 8 keycode 0x81  end
button 36  type 0  size 38 88  offset 288 242  down 2 8 keycode 0x84  end
button 37  type 0  size 38 32  offset 342 242  down 2 8 keycode 0xc4  end
button 38  type 0  size 38 32  offset 396 242  down 2 8 keycode 0x74  end
button 39  type 0  size 38 32  offset 450 242  down 2 8 keycode 0x34  end
button 30  type 0  size 38 32  offset 504 242  down 2 8 keycode 0x14  end

button 41  type 0  size 38 32  offset  18 298  down 2 8 keycode 0x18  end
button 42  type 0  size 38 32  offset  72 298  down 2 8 keycode 0x38  end
button 43  type 0  size 38 32  offset 126 298  down 2 8 keycode 0x78  end
button 44  type 0  size 38 32  offset 180 298  down 2 8 keycode 0xc8  end
button 45  type 0  size 38 32  offset 234 298  down 2 8 keycode 0x88  end
button 47  type 0  size 38 32  offset 342 298  down 2 8 keycode 0xc5  end
button 48  type 0  size 38 32  offset 396 298  down 2 8 keycode 0x75  end
button 49  type 0  size 38 32  offset 450 298  down 2 8 keycode 0x35  end
button 40  type 0  size 38 32  offset 504 298  down 2 8 keycode 0x15  end

# main keyboard:
scancode  48 map  48 47 end  # 0
scancode  49 map  49 37 end  # 1
scancode  50 map  50 38 end  # 2
scancode  51 map  51 39 end  # 3
scancode  52 map  52 27 end  # 4
scancode  53 map  53 28 end  # 5
scancode  54 map  54 29 end  # 6
scancode  55 map  55 17 end  # 7
scancode  56 map  56 18 end  # 8
scancode  57 map  57 19 end  # 9
scancode  46 map  46 48 end  # .
scancode  43 map  43 40 end  # +
scancode  45 map  45 30 end  # -
scancode  42 map  42 20 end  # *
scancode  47 map  47 10 end  # /
scancode 65293 map 65293 36 end  # ENTER

# suggested bindings (John R. Hogerhuis)
# !, @, comma are derived from Forth. Any better (unshifted) ideas?
scancode 110   map 110     11 end  # 'n' is n
scancode 105   map 105     12 end  # 'i' is i
scancode 91    map 91      13 end  # '[' is PV (present-value)
scancode 112   map 112     14 end  # 'p' is PMT
scancode 93    map 93      15 end  # ']' is FV (future-value)
scancode 96    map 96      16 end  # back-tick is CHS (change-sign)
scancode 94    map 94      21 end  # '^' is y^x
scancode 92    map 92      22 end  # '\' is 1/x
scancode 116   map 116     23 end  # 't' is %T (percent of total) 
scancode 100   map 100     24 end  # 'd' is delta percent
scancode 37    map 37      25 end  # '%' is %
scancode 101   map 101     26 end  # 'e' is EEX
scancode 120   map 120     31 end  # 'R/S' is x (execute)  
scancode 115   map 115     32 end  # 's' is SST (single-step) 
scancode 65366 map 65366   33 end  # 'PgDn' is R-down
scancode 59    map 59      34 end  # ';' is X><Y (swap)
scancode 65535 map 65535   35 end  # 'Delete' is CLx
scancode 32    map 32      41 end  # 'Space' is ON
scancode 102   map 102     42 end  # 'f' is f
scancode 103   map 103     43 end  # 'g' is g
scancode 33    map 33      44 end  # '!' is STO
scancode 64    map 64      45 end  # '@' is RCL
scancode 44    map 44      49 end  # comma is sigma+

# keypad:
scancode 65456 map 65456 47 end  # 0
scancode 65457 map 65457 37 end  # 1
scancode 65458 map 65458 38 end  # 2
scancode 65459 map 65459 39 end  # 3
scancode 65460 map 65460 27 end  # 4
scancode 65461 map 65461 28 end  # 5
scancode 65462 map 65462 29 end  # 6
scancode 65463 map 65463 17 end  # 7
scancode 65464 map 65464 18 end  # 8
scancode 65465 map 65465 19 end  # 9
scancode 65454 map 65454 48 end  # .
scancode 65451 map 65451 40 end  # +
scancode 65453 map 65453 30 end  # -
scancode 65450 map 65450 20 end  # *
scancode 65455 map 65455 10 end  # /
scancode 65421 map 65421 36 end  # ENTER

