; Periodic Table v1.6 by John McCord #include "ti82.h" .org START_ADDR .db "Periodic Table by JPM",0 CurStAddr = TEXT_MEM call SetGraph ld hl, Data ld (CurStAddr), hl call DispMenu KeyLoop: ROM_CALL(KEY_HAND) ; Check for keys. Key_Hand allows contrast to be changed. Crash if 2nd+On is pressed cp $02 ; Key code for left? jr z, Prev ; If yes, display previous entry cp $01 ; Key code for right? jr z, Next ; If yes, display next entry cp $06 ; Key code for clear? jr nz, KeyLoop ; If no, loop until yes. If yes, quit. SetGraph: ; Since this large amount of code is used twice, its smaller to do a function ROM_CALL(CLEARLCD) ; Clear the screen ld hl, $0000 ; Set cursor to 0,0 ld (CURSOR_X), hl ld hl, Header call DispMenu ; Display the header string which we stored at hl ld hl, $0700 ; Set the cursor to 0,7- down one row ld (CURSOR_X), hl xor a ; xor a does the same thing as ld a, 0 but 1 byte smaller ld bc, $FFFF ; Store highest 16 bit number into bc, which is used in cpir or cpdr as farthest we go back ld hl, (CurStAddr) ; Load hl with current entry ret Next: call SetGraph ; Go to setgraph cpir ; Look forward for the next 0 ld (CurStAddr), hl ; Save the address we found ld a, 255 ; 255 is what to check for cp (hl) ; If it landed on 255, it is at the end jr z, Prev ; Yes, so go to prev to correct for the error call DispMenu ; Otherwise, display the entry jr KeyLoop ; Go back Prev: call SetGraph ; Go to setgraph dec hl dec hl ; Dec the address twice to get before the leading zero cpdr ; Look backward for the next 0 inc hl inc hl ; Inc the address twice to get to the start of the entry ld (CurStAddr), hl ; Save the address we found ld a, 255 ; 255 is what to check for cp (hl) ; If it landed on 255, it is at the beginning jr z, Next ; Yes, so go to next to correct for the error call DispMenu ; Otherwise, display the entry jr KeyLoop ; Go back DispMenu: ; If you do ROM_CALL 3 times, it breaks even, I think. Any more is smaller. ROM_CALL(D_ZM_STR) ; Display a string ret ; End function Header: .db "# Element Sym Mass",0 .db 255,0 Data: .db "1 Hydrogen H 1.00794",0 .db "2 Helium He 4.00260",0 .db "3 Lithium Li 6.941",0 .db "4 Beryllium Be 9.01218",0 .db "5 Boron B 10.81",0 .db "6 Carbon C 12.011",0 .db "7 Nitrogen N 14.0067",0 .db "8 Oxygen O 15.9994",0 .db "9 Flourine F 18.998403",0 .db "10 Neon Ne 20.1797",0 .db "11 Sodium Na 22.98977",0 .db "12 Magnesium Mg 24.305",0 .db "13 Aluminum Al 26.98154",0 .db "14 Silicon Si 28.0855",0 .db "15 Phosphorous P 30.97376",0 .db "16 Sulfur S 32.066",0 .db "17 Chlorine Cl 35.453",0 .db "18 Argon Ar 39.948",0 .db "19 Potassium K 39.0983",0 .db "20 Calcium Ca 40.078",0 .db "21 Scandium Sc 44.9559",0 .db "22 Titanium Ti 47.88",0 .db "23 Vanadium V 50.9415",0 .db "24 Chromium Cr 51.996",0 .db "25 Manganese Mn 54.9380",0 .db "26 Iron Fe 55.847",0 .db "27 Cobalt Co 58.9332",0 .db "28 Nickel Ni 58.69",0 .db "29 Copper Cu 63.546",0 .db "30 Zinc Zn 65.39",0 .db "31 Gallium Ga 69.72",0 .db "32 Germanium Ge 72.61",0 .db "33 Arsenic As 74.9216",0 .db "34 Selenium Se 78.96",0 .db "35 Bromine Br 79.904",0 .db "36 Krypton Kr 83.80",0 .db "37 Rubidium Rb 85.4678",0 .db "38 Strontium Sr 87.62",0 .db "39 Yttrium Y 88.9059",0 .db "40 Zirconium Zr 91.224",0 .db "41 Niobium Nb 92.9064",0 .db "42 Molybdenum Mo 95.94",0 .db "43 Technetium Tc 98",0 .db "44 Ruthenium Ru 101.07",0 .db "45 Rhodium Rh 102.9055",0 .db "46 Palladium Pd 106.42",0 .db "47 Silver Ag 107.8682",0 .db "48 Cadmium Cd 112.41",0 .db "49 Indium In 114.82",0 .db "50 Tin Sn 118.710",0 .db "51 Antimony Sb 121.757",0 .db "52 Tellurium Te 127.60",0 .db "53 Iodine I 126.9045",0 .db "54 Xenon Xe 131.29",0 .db "55 Cesium Cs 132.9054",0 .db "56 Barium Ba 137.33",0 .db "57 Lanthanum La 138.9055",0 .db "58 Cerium Ce 140.12",0 .db "59 Praseodymium Pr 140.9077",0 .db "60 Neodymium Nd 144.24",0 .db "61 Promethium Pm 145",0 .db "62 Samarium Sm 150.36",0 .db "63 Europium Eu 151.96",0 .db "64 Gadolinium Gd 157.25",0 .db "65 Terbium Tb 158.9254",0 .db "66 Dysprosium Dy 162.50",0 .db "67 Holmium Ho 164.9304",0 .db "68 Erbium Er 167.26",0 .db "69 Thulium Tm 168.9342",0 .db "70 Ytterbium Yb 173.04",0 .db "71 Lutetium Lu 174.967",0 .db "72 Hafnium Hf 178.49",0 .db "73 Tantalum Ta 180.9479",0 .db "74 Tungsten W 183.85",0 .db "75 Rhenium Re 186.207",0 .db "76 Osmium Os 190.2",0 .db "77 Iridium Ir 192.22",0 .db "78 Platinum Pt 195.08",0 .db "79 Gold Au 196.9665",0 .db "80 Mercury Hg 200.59",0 .db "81 Thallium Tl 204.38",0 .db "82 Lead Pb 207.2",0 .db "83 Bismuth Bi 208.9804",0 .db "84 Polonium Po 209",0 .db "85 Astatine At 210",0 .db "86 Radon Rn 222",0 .db "87 Francium Fr 223",0 .db "88 Radium Ra 226.0254",0 .db "89 Actinum Ac 227.0278",0 .db "90 Thorium Th 232.0381",0 .db "91 Protactinium Pa 231.0359",0 .db "92 Uranium U 238.0289",0 .db "93 Neptunium Np 237.048",0 .db "94 Plutonium Pu 244",0 .db "95 Americium Am 243",0 .db "96 Curium Cm 247",0 .db "97 Berkelium Bk 247",0 .db "98 Californium Cf 251",0 .db "99 Einsteinium Es 252",0 .db "100 Fermium Fm 257",0 .db "101 Mendelevium Md 258",0 .db "102 Nobelium No 259",0 .db "103 Lawrencium Lr 260",0 .db "104 Rutherfordium Rf 261",0 .db "105 Dubnium Db 262",0 .db "106 Seaborgium Sg 263",0 .db "107 Bohrium Bh 262",0 .db "108 Hassium Hs 265",0 .db "109 Meitnerium Mt 266",0 .db "110 Ununnilium Uun 269",0 .db "111 Unununium Uuu 272",0 .db "112 Ununbium Uub 277",0 .db "113 Ununtrium Uut ???",0 .db "114 Ununquadium Uuq ???",0 .db "115 Ununpentium Uup ???",0 .db "116 Ununhexium Uuh ???",0 .db "117 Ununseptium Uus ???",0 .db "118 Ununoctium Uuo ???",0 .db 255,0 .end