Author Topic: Chemical Formula Input Routine  (Read 2475 times)

0 Members and 2 Guests are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Chemical Formula Input Routine
« on: January 18, 2012, 02:14:40 pm »
Can someone write me up one if they have the time? I started to write one myself, but got confused. Below is what I have so far. Can someone please help me out with this. I'm looking for the routine to prompt for an equation, allow you to press the down arrow for subscripts, make the second character of a two-character symbol lower-case, and make the y= button give the arrow.

Code: [Select]
ReceiveEquation:
    bcall(_ClrLCDFull)
    ld  a,0
    ld  (penCol),a
    ld  (penRow),a
    ld  de,saferam1+1
    ld  a,0
    ld  (saferam1),a
    ld  a,0
getKloop:
    bcall(_getCSC)
    jr  z,getKloop
    cp  $01
    jr  z,switchnumeric
    cp  $04
    jr  z,switchalpha
    cp  $02
    jr  z,backspace
    cp  $09
    jr  z,done


switchnumeric:
    bit 0,(TextInputFlag)
    jr  z,getKloop
    ld  hl,NumericCharMap
    ld  a,(penRow)
    add a,3
    ld  (penRow),a
    res 0,(TextInputFlag)
    jr  getKloop

switchalphaup:
    bit 0,(TextInputFlag)
    jr  nz,getKloop
    ld  hl,AlphaCharMap
    ld  a,(penRow)
    sub 3
    ld  (penRow),a
    set 0,(TextInputFlag)
    jr  getKloop

backspace:
    ld  a,(saferam1)
    cp  0
    jr  z,getKloop
    dec a
    ld  (saferam1),a
    dec de
    ld  a,(penCol)
    sub 5
    ld  (penCol),a
    jr  getKloop

done:
       
AlphaUpCharMap:
    .db 0,0,0,0,0,0,0,0,0,0
    .db "WRMH"
AlphaLowCharMap:

NumericCharMap: