home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol167 / vti88.asm < prev   
Encoding:
Assembly Source File  |  1984-04-29  |  13.6 KB  |  944 lines

  1.  
  2. ;    -------------------------------------------------------
  3. ;    Adaptation of VTI for UAP's POLY-88
  4. ;        [Version October 15,1978]
  5. ;
  6. ;        VTI88  -  Copyright (C) 1978
  7. ;        Universidad Autonoma de Puebla
  8. ;
  9. ;    written by Harold V. McIntosh, summer 1978, with
  10. ;    reference to: Harvey A. Cohen, "The Oznaki LIFE",
  11. ;    Dr. Dobbs Journal of Computer Calisthenics and
  12. ;    Orthodontia, volume 3, issue 4 (April 1978) pp. 10-11;
  13. ;    and with acknowledgements to the hospitality of the
  14. ;    Quantum Theory Project, University of Florida,
  15. ;    Gainesville, Florida.
  16. ;
  17. ;    Note that this board has been modified: bit 7=1 now
  18. ;    signifies graphic mode, contrary to the normal board.
  19. ;    ------------------------------------------------------
  20.  
  21.     org    09000H
  22.                 
  23.                 
  24. read:    equ    0C20H    ;POLY-88 WH0 keyboard input routine
  25. kbfl:    equ    0C0CH    ;keyboard input ready flag
  26.  
  27. ;    -------------------------------------------------------
  28. ;    Constants defining screen size and location.  Note that
  29. ;    while the programmer has some discretion in assigning
  30. ;    these constants, there is highly implicit usage of the
  31. ;    assumption that the screen memory begins at a 1K Hex
  32. ;    boundary, and that the row length is a power of 2.
  33. ;    Thus the video board origin may be changed through its
  34. ;    address switches, and new parameters defined without
  35. ;    difficulty; nevertheless adaptation to an 80-column 
  36. ;    board would require restructuring the subroutines.
  37. ;    -------------------------------------------------------
  38.  
  39. vorg:    equ    0F800H    ;origin of video screen memory area
  40. vsiz:    equ    00400H    ;size of video screen memory area
  41. rsiz    equ    00040H    ;length of a single display line
  42. rmsk:    equ    rsiz-1    ;mask for single row addresses
  43. morg:    equ    04000H    ;area for defining macros
  44.  
  45. ;    -------------------------------------------------------
  46. ;    Data storage locations required by the subroutines.
  47. ;    -------------------------------------------------------
  48.  
  49. ma:    equ    00CC9H    ;bit mask to locate pixel within byte
  50. wy:    equ    00CCAH    ;row count * 16  -  16 rows total
  51. ex:    equ    00CCBH    ;column count * 4  -  64 columns total
  52. wye:    equ    00CCCH    ;8-bit cartesian y-coordinate
  53. eks:    equ    00CCDH    ;8-bit cartesian x-coordinate
  54.  
  55. ;    -----------------------------------------------------
  56. ;    Entry vector designed to systematize communication with
  57. ;    calling programs written in BASIC or other external
  58. ;    languages.  These entry points should remain the same
  59. ;    even though the subroutines are revised, corrected, or
  60. ;    otherwise modified.
  61.  
  62.     jmp    ypl    ;move cursor up one pixel
  63.     jmp    ymi    ;move cursor down one pixel
  64.     jmp    xpl    ;move cursor right one pixel
  65.     jmp    xmi    ;move cursor left one pixel
  66.     jmp    home    ;place cursor at screen center
  67.     jmp    cuex    ;extinguish the cursor
  68.     jmp    culi    ;illuminate the cursor
  69.     jmp    cure    ;reverse the cursor
  70.     jmp    cuse    ;sense the cursor (zero test afterward)
  71.     jmp    blak    ;make the whole screen black
  72.     jmp    whit    ;make the whole screen white
  73.     jmp    reve    ;reverse the whole screen
  74.     jmp    cart    ;form (ma, wy, ex) from (wye, eks)
  75.     jmp    line    ;line segment with increments (dx,dy)
  76.     jmp    ekspl    ;rotate whole screen right
  77.     jmp    eksmi    ;rotate whole screen left
  78.     jmp    wyepl    ;rotate whole screen up
  79.     jmp    wyemi    ;rotate whole screen down
  80.     jmp    hh    ;advance one cycle of LIFE
  81.     jmp    ee    ;move cursor east one LIFE cell
  82.     jmp    ww    ;move cursor west one LIFE cell
  83.     jmp    nn    ;move cursor north one LIFE cell
  84.     jmp    ss    ;move cursor south one LIFE cell
  85.     jmp    kk    ;deactivate cell under cursor
  86.     jmp    ll    ;activate cell under cursor
  87.     jmp    eas    ;rotate screen and cursor one cell east
  88.     jmp    wes    ;rotate screen and cursor one cell west
  89.     jmp    nor    ;rotate screen and cursor one cell north
  90.     jmp    sou    ;rotate screen and cursor one cell south
  91.     jmp    coop    ;fetch count and terminating character
  92.     jmp    pair    ;fetch a pair of coordinates
  93.  
  94. ;    -------------------------------------------------------
  95.  
  96. ;    move cursor up one pixel
  97.  
  98. ypl:    lxi h,ma
  99.     mov a,m
  100.     ani 024H
  101.     jnz yp1
  102.     mov a,m
  103.     rlc
  104.     mov m,a
  105.     ret
  106. yp1:    rrc
  107.     rrc
  108.     mov m,a
  109.     lda wy
  110.     sui 010H
  111.     sta wy
  112.     ret
  113.  
  114. ;    move cursor down one pixel
  115.  
  116. ymi:    lxi h,ma
  117.     mov a,m
  118.     ani 009H
  119.     jnz ym1
  120.     mov a,m
  121.     rrc
  122.     mov m,a
  123.     ret
  124. ym1:    rlc
  125.     rlc
  126.     mov m,a
  127.     lda wy
  128.     adi 010H
  129.     sta wy
  130.     ret
  131.  
  132. ;    move cursor right one pixel
  133.  
  134. xpl:    lxi h,ma
  135.     mov a,m
  136.     ani 007H
  137.     jnz xp1
  138.     mov a,m
  139.     rrc
  140.     rrc
  141.     rrc
  142.     mov m,a
  143.     ret
  144. xp1:    rlc
  145.     rlc
  146.     rlc
  147.     mov m,a
  148.     lda ex
  149.     adi 004H
  150.     sta ex
  151.     ret
  152.  
  153. ;    move cursor left one pixel
  154.  
  155. xmi:    lxi h,ma
  156.     mov a,m
  157.     ani 038H
  158.     jnz xm1
  159.     mov a,m
  160.     rlc
  161.     rlc
  162.     rlc
  163.     mov m,a
  164.     ret
  165. xm1:    rrc
  166.     rrc
  167.     rrc
  168.     mov m,a
  169.     lda ex
  170.     sui 004H
  171.     sta ex
  172.     ret
  173.  
  174. ;    load A with the bit mask, HL with a byte address
  175. ;    given the cursor positioning data at (ma,wy,ex)
  176.  
  177. dot:    lhld wy
  178.     mov a,h
  179.     mvi h,vorg/0400H
  180.     dad h
  181.     dad h
  182.     rrc
  183.     rrc
  184.     ora l
  185.     mov l,a
  186.     lda ma
  187.     ret
  188.  
  189. ;    home the cursor
  190.  
  191. home:    lxi h,8080H
  192.     shld wy
  193.     mvi a,008H
  194.     sta ma
  195.     ret
  196.  
  197. ;    extinguish the cursor
  198.  
  199. cuex:    call dot
  200.     ora m
  201.     mov m,a
  202.     ret
  203.  
  204. ;    light the cursor
  205.  
  206. culi:    call dot
  207.     cma
  208.     ana m
  209.     mov m,a
  210.     ret
  211.  
  212. ;    reverse the cursor
  213.  
  214. cure:    call dot
  215.     xra m
  216.     mov m,a
  217.     ret
  218.  
  219. ;    sense the cursor
  220.  
  221. cuse:    call dot
  222.     ana m
  223.     ani 03FH
  224.     ret
  225.  
  226. ;    clear the whole screen to black
  227.  
  228. blak:    lxi d,vsiz
  229.     lxi h,vorg
  230. bl1:    mvi m,0FFH
  231.     inx h
  232.     dcr e
  233.     jnz bl1
  234.     dcr d
  235.     jnz bl1
  236.     ret
  237.  
  238. ;    clear the whole screen to white
  239.  
  240. whit:    lxi d,vsiz
  241.     lxi h,vorg
  242. whi:    mvi m,080H
  243.     inx h
  244.     dcr e
  245.     jnz whi
  246.     dcr d
  247.     jnz whi
  248.     ret
  249.  
  250. ;    reverse the whole screen
  251.  
  252. reve:    lxi d,vsiz
  253.     lxi h,vorg
  254. rev1:    mov a,m
  255.     xri 03FH
  256.     mov m,a
  257.     inx h
  258.     dcr e
  259.     jnz rev1
  260.     dcr d
  261.     jnz rev1
  262.     ret
  263.  
  264. ;    transform cartesian coordinates in the form of x,y
  265. ;    to a mask and byte address
  266.  
  267. cart:    mvi b,018H
  268.     mvi c,004H
  269.     lda wye
  270.     cma
  271.     adi 031H
  272. car1:    cmp b
  273.     jc car2
  274.     sub b
  275. car2:    cmc
  276.     adc a
  277.     dcr c
  278.     jnz car1
  279.     mov c,a
  280.     ani 00FH
  281.     rlc
  282.     rlc
  283.     rlc
  284.     rlc
  285.     sta wy
  286.     mov a,c
  287.     ani 0F0H
  288.     jnz car3
  289.     mvi a,020H
  290.     jmp car4
  291. car3:    xri 030H
  292.     rrc
  293. car4:    mov c,a
  294.     lda eks
  295.     dcr a
  296.     mov b,a
  297.     rlc
  298.     ani 0FCH
  299.     sta ex
  300.     mov a,b
  301.     ani 001H
  302.     mov a,c
  303.     jz car5
  304.     rrc
  305.     rrc
  306.     rrc
  307. car5:    sta ma
  308.     ret
  309.  
  310. ;    draw a line with increments dx,dy = (B,C).  Increment
  311. ;    may be + or - using complementary arithmetic, but less
  312. ;    than 64 in absolute value to avoid overflow problems.
  313.  
  314. line:    lxi h,ypl
  315.     mov a,c
  316.     ora a
  317.     jp lin1
  318.     cma
  319.     inr a
  320.     mov c,a
  321.     lxi h,ymi
  322. lin1:    lxi d,xpl
  323.     mov a,b
  324.     ora a
  325.     jp lin2
  326.     cma
  327.     inr a
  328.     mov b,a
  329.     lxi d,xmi
  330. lin2:    cmp c
  331.     jnc lin3
  332.     xchg
  333.     mov b,c
  334.     mov c,a
  335. lin3:    mov a,b
  336.     sta eks
  337.     mov a,c
  338.     add a
  339.     mov c,a
  340.     sub b
  341.     push psw
  342.     sub b
  343.     mov b,a
  344. lin4:    pop psw
  345.     push h
  346.     lxi h,culi
  347.     xthl
  348.     cpi 001H
  349.     jm lin5
  350.     push h
  351.     add b
  352.     jmp lin6
  353. lin5:    add c
  354. lin6:    push d
  355.     push psw
  356.     lda eks
  357.     dcr a
  358.     sta eks
  359.     jnz lin4
  360.     pop psw
  361.     ret
  362.  
  363. ;    the movements in one byte necessary to shift the
  364. ;    whole screen right one pixel.
  365.  
  366. expl:    mov a,m
  367.     ani 03FH
  368.     mov b,a
  369.     ani 038H
  370.     rrc
  371.     rrc
  372.     rrc
  373.     ora c
  374.     mov c,a
  375.     mov a,b
  376.     rlc
  377.     rlc
  378.     rlc
  379.     ani 038H
  380.     mov b,c
  381.     mov c,a
  382.     ret
  383.  
  384. ;    the movements within one byte necessary for shifting
  385. ;    the whole screen left one pixel.
  386.  
  387. exmi:    mov a,m
  388.     ani 03FH
  389.     mov b,a
  390.     rlc
  391.     rlc
  392.     rlc
  393.     ani 038H
  394.     ora c
  395.     mov c,a
  396.     mov a,b
  397.     ani 038H
  398.     rrc
  399.     rrc
  400.     rrc
  401.     mov b,c
  402.     mov c,a
  403.     ret
  404.  
  405. ;    the movements necessary within one byte to shift the
  406. ;    whole screen down one pixel.
  407.  
  408. wymi:    mov a,m
  409.     ani 03FH
  410.     mov b,a
  411.     ani 036H
  412.     rrc
  413.     ora c
  414.     mov c,a
  415.     mov a,b
  416.     rlc
  417.     rlc
  418.     ani 024H
  419.     mov b,c
  420.     mov c,a
  421.     ret
  422.  
  423. ;    the movements necessary within one byte to shift the
  424. ;    whole screen up one pixel.
  425.  
  426. wypl:    mov a,m
  427.     ani 03FH
  428.     mov b,a
  429.     rlc
  430.     ani 036H
  431.     ora c
  432.     mov c,a
  433.     mov a,b
  434.     ani 024H
  435.     rrc
  436.     rrc
  437.     mov b,c
  438.     mov c,a
  439.     ret
  440.  
  441. ;    rotate the whole screen right one pixel
  442.  
  443. ekspl:    lxi h,vorg
  444.     lxi d,rsiz-1
  445. eksp1:    push h
  446.     dad d
  447.     call expl
  448.     pop h
  449. eksp2:    call expl
  450.     mov a,b
  451.     ori 080H
  452.     mov m,a
  453.     inx h
  454.     mov a,l
  455.     ani rmsk
  456.     jnz eksp2
  457.     mov a,h
  458.     cpi (vorg+vsiz)/0100H
  459.     jnz eksp1
  460.     ret
  461.  
  462. ;    rotate the whole screen left one pixel
  463.  
  464. eksmi:    lxi h,vorg+vsiz-1
  465.     lxi d,-rsiz+1
  466. eksm1:    push h
  467.     dad d
  468.     call exmi
  469.     pop h
  470. eksm2:    call exmi
  471.     mov a,b
  472.     ori 080H
  473.     mov m,a
  474.     mov a,l
  475.     ani rmsk
  476.     dcx h
  477.     jnz eksm2
  478.     mov a,h
  479.     cpi (vorg/0100H)-1
  480.     jnz eksm1
  481.     ret
  482.  
  483. ;    rotate the whole screen up one pixel.
  484.  
  485. wyepl:    lxi h,vorg+vsiz-1
  486. wyep1:    lxi d,-vsiz+rsiz
  487.     push h
  488.     dad d
  489.     call wypl
  490.     pop h
  491.     push h
  492.     lxi d,-rsiz
  493. wyep2:    call wypl
  494.     mov a,b
  495.     ori 080H
  496.     mov m,a
  497.     dad d
  498.     mov a,h
  499.     cpi (vorg/0100H)-1
  500.     jnz wyep2
  501.     pop h
  502.     mov a,l
  503.     ani rmsk
  504.     dcx h
  505.     jnz wyep1
  506.     ret
  507.  
  508. ;    rotate the whole screen down one pixel
  509.  
  510. wyemi:    lxi h,vorg
  511. wyem1:    lxi d,vsiz-rsiz
  512.     push h
  513.     dad d
  514.     call wymi
  515.     pop h
  516.     push h
  517.     lxi d,rsiz
  518. wyem2:    call wymi
  519.     mov a,b
  520.     ori 080H
  521.     mov m,a
  522.     dad d
  523.     mov a,h
  524.     cpi (vorg+vsiz)/0100H
  525.     jnz wyem2
  526.     pop h
  527.     inx h
  528.     mov a,l
  529.     ani rmsk
  530.     jnz wyem1
  531.     ret
  532.  
  533. ;    Add to the neighbor count of adjoining cells according
  534. ;    to the bits in this byte.  We do the middle pixel,
  535. ;    adding to the count of three successive neighbors in
  536. ;    registers B,C,D.
  537.  
  538. alfa:    mov a,m
  539.     rrc
  540.     jc alf1
  541.     inr b
  542.     inr c
  543.     inr d
  544. alf1:    rrc
  545.     jc alf2
  546.     inr b
  547.     inr d
  548. alf2:    rrc
  549.     rc
  550.     inr b
  551.     inr c
  552.     inr d
  553.     ret
  554.  
  555. ;    shift the neighbor count as we move forward one byte in
  556. ;    a row scan
  557.  
  558. beta:    mov b,c
  559.     mov c,d
  560.     mvi d,00H
  561.     inx h
  562.     mov a,l
  563.     ani 03FH
  564.     rnz
  565.     push d
  566.     lxi d,-rsiz
  567.     dad d
  568.     pop d
  569.     ret
  570.  
  571. ;    PRINCIPAL PROGRAM for carrying out a cycle of LIFE.
  572. ;    Only the middle pixel in each byte is calculated
  573. ;    so that three passes are necessary after each of three
  574. ;    shifts. Two adjacent pixels are used, the right to hold
  575. ;    the present living status and the left for information
  576. ;    for the next cycle.
  577.  
  578. epsi:    lxi h,vorg+rsiz-1
  579. gama:    mvi d,00H
  580.     call alfa
  581.     call beta
  582.     call alfa
  583. delt:    push h
  584.     call beta
  585.     call alfa
  586.     xthl
  587.     mov a,b
  588.     cpi 002H
  589.     jz eta
  590.     cpi 003H
  591.     jz zeta
  592.     mov a,m
  593.     ori 010H
  594.     mov m,a
  595.     jmp thet
  596. zeta:    mov a,m
  597.     ani 0EFH
  598.     mov m,a
  599.     jmp thet
  600. eta:    mov a,m
  601.     ani 0EFH
  602.     mov e,a
  603.     ani 002H
  604.     rlc
  605.     rlc
  606.     rlc
  607.     ora e
  608.     mov m,a
  609. thet:    pop h
  610.     mov a,l
  611.     ani rmsk
  612.     jnz delt
  613.     push d
  614.     lxi d,2*rsiz-1
  615.     dad d
  616.     pop d
  617.     mov a,h
  618.     cpi (vorg+vsiz)/0100H
  619.     jnz gama
  620.     ret
  621.  
  622. ;    updating loop, moving left pixel to right
  623.  
  624. cycl:    lxi h,vorg
  625. cyc1:    mov a,m
  626.     ani 038H
  627.     mov b,a
  628.     rrc
  629.     rrc
  630.     rrc
  631.     ora b
  632.     ori 080H
  633.     mov m,a
  634.     inx h
  635.     mov a,h
  636.     cpi (vorg+vsiz)/0100H
  637.     jnz cyc1
  638.     ret
  639.  
  640. ;    execute a single cycle of LIFE by updating the middle
  641. ;    pixel and making three sweeps while shifting each time
  642.  
  643. hh:    call epsi
  644.     call wyepl
  645.     call epsi
  646.     call wyepl
  647.     call epsi
  648.     call wyemi
  649.     call wyemi
  650.     jmp cycl
  651.  
  652. ;    extinguish cursor, move two pixels east, light cursor
  653.  
  654. ee:    call cure
  655.     call xpl
  656.     call xpl
  657.     jmp  cure
  658.  
  659. ;    extinguish cursor, two pixels west, light cursor
  660.  
  661. ww:    call cure
  662.     call xmi
  663.     call xmi
  664.     jmp  cure
  665.  
  666. ;    extinguish cursor, one pixel north, light cursor
  667.  
  668. nn:    call cure
  669.     call ypl
  670.     jmp  cure
  671.  
  672. ;    extinguish cursor, one pixel south, light cursor
  673.  
  674. ss:    call cure
  675.     call ymi
  676.     jmp  cure
  677.  
  678. ;    extinguish a life cell
  679.  
  680. kk:    call xpl
  681.     call cuex
  682.     jmp xmi
  683.  
  684. ;    activate a life cell
  685.  
  686. ll:    call xpl
  687.     call culi
  688.     jmp  xmi
  689.  
  690. ;    move whole screen right one life cell, with cursor
  691.  
  692. eas:    call ekspl
  693.     call ekspl
  694.     call xpl
  695.     jmp  xpl
  696.  
  697. ;    move the whole screen left one life cell, with cursor
  698.  
  699. wes:    call eksmi
  700.     call eksmi
  701.     call xmi
  702.     jmp  xmi
  703.  
  704. ;    move the whole screen up one life cell, with cursor
  705.  
  706. nor:    call wyepl
  707.     jmp  ypl
  708.  
  709. ;    move the whole screen down one life cell, with cursor
  710.  
  711. sou:    call wyemi
  712.     jmp  ymi
  713.  
  714. ;    build up one-byte decimal number from digit string
  715. ;    null string =1, minus creates negative modulo 256
  716. ;    to correct an error type four zeroes and start over
  717.  
  718. decm:    mvi b,01H
  719.     call read
  720.     cpi '-'
  721.     jnz dec1
  722.     lxi h,dec3
  723.     push h
  724.     call read
  725. dec1:    cpi '0'
  726.     rc
  727.     cpi '9'+1
  728.     rnc
  729.     mvi b,00H
  730. dec2:    cpi '0'
  731.     rc
  732.     cpi '9'+1
  733.     rnc
  734.     sui '0'
  735.     mov c,a
  736.     mov a,b
  737.     rlc
  738.     rlc
  739.     add b
  740.     rlc
  741.     add c
  742.     mov b,a
  743.     call read
  744.     jmp dec2
  745. dec3:    push sp
  746.     mov a,b
  747.     cma
  748.     inr a
  749.     mov b,a
  750.     pop sp
  751.     ret
  752.  
  753. ;    get (B,C)= (count, operation)
  754.  
  755. coop:    call decm
  756.     mov c,a
  757.     ret
  758.  
  759. ;    get (B,C) = (X,Y); for example a pair of coordinates
  760. ;    first read b=x, then c=y
  761.  
  762. pair:    call decm
  763.     push b
  764.     call decm
  765.     pop sp
  766.     mov c,b
  767.     mov b,a
  768.     ret
  769.  
  770. ;    place a dot with coordinates x,y on the screen
  771.  
  772. pp:    call pair
  773.     lxi h,wye
  774.     mov m,c
  775.     inx h
  776.     mov m,b
  777.     call cart
  778.     jmp culi
  779.  
  780. ;    draw a line with increments (dx,dy)
  781.  
  782. ii:    call pair
  783.     jmp line
  784.  
  785. ;    =======================================================
  786. ;    beginning of second ROM
  787. ;    =======================================================
  788.  
  789.     org    9400H
  790.  
  791.     jmp main
  792.  
  793. ;    repeat the subroutine in (H,L) for the number of times
  794. ;    in B.
  795.  
  796. rept:    mov a,c
  797.     push h
  798.     push b
  799.     lxi d,repi
  800.     push d
  801.     pchl
  802. repi:    pop b
  803.     pop h
  804.     dcr b
  805.     rz
  806.     jmp rept
  807.  
  808. ;    turn one ASCII digit into a macro location
  809.  
  810. mloc:    lxi h,0005H
  811.     dad sp
  812.     mov e,m
  813.     mvi d,00H
  814.     mvi m,01H
  815.     lxi b,morg
  816.     xchg
  817.     dad h
  818.     dad h
  819.     dad h
  820.     dad h
  821.     dad h
  822.     dad b
  823.     ret
  824.  
  825. ;    record a macro definition
  826.  
  827. mdef:    call mloc
  828. mde1:    call coop
  829.     mov m,b
  830.     inx h
  831.     mov m,c
  832.     inx h
  833.     mvi a,01BH
  834.     cmp c
  835.     rz
  836.     push h
  837.     lxi h,vect
  838.     call rept
  839.     pop h
  840.     jmp mde1
  841.  
  842. ;    execute a defined macro
  843.  
  844. mxec:    call mloc
  845.     push h
  846. mxe1:    pop h
  847.     mov b,m
  848.     inx h
  849.     mov a,m
  850.     inx h
  851.     cpi 01BH
  852.     rz
  853.     cpi ')'
  854.     jz rpar
  855.     cpi '('
  856.     jz lpar
  857.     mov c,a
  858.     push h
  859.     lxi h,vect
  860.     call rept
  861.     jmp mxe1
  862. rpar:    pop psw
  863.     dcr a
  864.     jz  rpa1
  865.     pop h
  866.     push h
  867.     push psw
  868.     push h
  869.     jmp mxe1
  870. rpa1:    xthl
  871.     jmp mxe1
  872. lpar:    push h
  873.     mov a,b
  874.     push psw
  875.     push h
  876.     jmp mxe1
  877.  
  878. ;    directory vector for LIFE demonstration
  879.  
  880. vect:    cpi 'N'        ;rotate screen north
  881.     jz  nor
  882.     cpi 'S'        ;rotate screen south
  883.     jz  sou
  884.     cpi 'E'        ;rotate screen east
  885.         jz  eas
  886.     cpi 'W'        ;rotate screen west
  887.     jz  wes
  888.     cpi 06EH    ;'n' - move cursor north
  889.     jz  nn
  890.     cpi 073H    ;'s' - move cursor south
  891.     jz  ss
  892.     cpi 065H    ;'e' - move cursor east
  893.     jz  ee
  894.     cpi 077H    ;'w' - move cursor west
  895.     jz  ww
  896.     cpi 06BH    ;'k' - deactivate cell
  897.     jz  kk
  898.     cpi 06CH    ;'l' - activate cell under cursor
  899.     jz  ll
  900.     cpi 'C'        ;clear screen to black
  901.     jz  blak
  902.     cpi 'R'        ;reverse the screen
  903.     jz  reve
  904.     cpi 068H    ;'h' - advance one cycle of LIFE
  905.     jz  hh
  906.     cpi 067H    ;'g' - repeat cycles of LIFE
  907.     jz  gg
  908.     cpi '.'        ;reverse cursor illumination
  909.     jz  cure
  910.     cpi '!'
  911.     jz mdef
  912.     cpi '?'
  913.     jz mxec
  914.     cpi 069H
  915.     jz  ii
  916.     cpi 070H
  917.     jz  pp
  918.     cpi ';'        ;exit to monitor
  919.     jz  0000H
  920. vend:    ret
  921.  
  922. ;    call hh repeatedly unless keyboard input is waiting
  923.  
  924. gg:    lda kbfl
  925.     ora a
  926.     rz
  927.     call hh
  928.     jmp gg
  929.  
  930. ;    MAIN PROGRAM for LIFE demonstration
  931. ;    commands consist of a count and a letter.  An operation
  932. ;    is repeated the number of times required, null and zero
  933. ;    both being taken as once.  The correspondence between
  934. ;    letters and operations is established by a sequence of
  935. ;    CPI's and JZ's in the array vect.
  936.  
  937. main:    call home
  938. loop:    call coop
  939.     lxi h,vect
  940.     call rept
  941.     jmp loop
  942.  
  943.     end
  944.