home *** CD-ROM | disk | FTP | other *** search
/ Transactor / Transactor_22_1988_Transactor_Publishing.d64 / clockset.bud < prev    next >
Text File  |  2023-02-26  |  9KB  |  463 lines

  1. ;put"@0:clockset.bud"
  2. ; ** rewritten in Buddy 128 format
  3. ;
  4. *=$1600 ; 5632
  5. .obj "@0:clk5632"
  6. ;* * * * * * * * * * * * * * * * *
  7. ;*                               *
  8. ;* clock & alarm setup           *
  9. ;*                               *
  10. ;* written 12-02-85  w.j. brier  *
  11. ;*                               *
  12. ;* revised  1-18-87              *
  13. ;*                               *
  14. ;* copyright (c) 1985            *
  15. ;*                               *
  16. ;* all rights reserved           *
  17. ;*                               *
  18. ;* use with clock-calendar 128   *
  19. ;*                               *
  20. ;* set time of day: sys 5632,0   *
  21. ;* set alarm time:  sys 5632,1   *
  22. ;*                               *
  23. ;* enter time in 24 hour format  *
  24. ;*                               *
  25. ;* * * * * * * * * * * * * * * * *
  26.               ;
  27.               ;
  28.               ;
  29. ;* * * * * * * * * * * * * * * * *
  30. ;*                               *
  31. ;*  <<< program assignments >>>  *
  32. ;*                               *
  33. ;* * * * * * * * * * * * * * * * *
  34.               ;
  35.               ;
  36.               ;
  37. ;system vectors & pointers...
  38.               ;
  39. ndx    =$d0   ;keyboard queue
  40.               ;
  41. mode   =$d7   ;40/80 column mode
  42.               ;
  43. color  =$f1   ;next attribute
  44.               ;
  45. keychk =$033c ;key decode vector
  46.               ;
  47. curon  =$cd6f ;flash cursor
  48. curof1 =$cd9f ;kill cursor (40 col)
  49. curof2 =$cdac ;kill cursor (80 col)
  50.               ;
  51. sigvol =$d418 ;volume control
  52.               ;
  53. tod2   =$dd08 ;time of day clock #2
  54.               ;
  55. mmu    =$ff00 ;memory configuration
  56.               ;
  57. chrout =$ffd2 ;output a byte
  58. getin  =$ffe4 ;get a byte
  59. plot   =$fff0 ;position cursor
  60.               ;
  61.               ;
  62. ;miscellaneous pointers...
  63.               ;
  64. ptr    =$fa   ;zero page pointer
  65. ctr    =$fc   ;counter
  66.               ;
  67.               ;
  68. ;clock-calendar locations...
  69.               ;
  70. altc   =$131e ;alarm register
  71. aflg   =$1320 ;alarm enable flag
  72.               ;
  73.               ;
  74. ;video constants...
  75.               ;
  76. wht    =5     ;white text
  77. cr     =13    ;carriage return
  78. del    =20    ;delete
  79. esc    =27    ;escape character
  80. right  =29    ;cursor right
  81. clr    =147   ;clear screen
  82. yel    =158   ;yellow text
  83. cyn    =159   ;cyan text
  84.               ;
  85.               ;
  86.               ;
  87. ;# # # # # # # # # # # # # # # # #
  88. ;#                               #
  89. ;#    c-128  time/alarm setup    #
  90. ;#                               #
  91. ;# # # # # # # # # # # # # # # # #
  92.        ;
  93.        ;
  94.        ;
  95. ;initial setup...
  96.        ;
  97. stim   and #1 ;mask garbage &...
  98.        sta sflg ;set entry mode flag
  99.        ;
  100.        lda color ;current attribute
  101.        pha ;save
  102.        ;
  103.        lda mmu ;configuration
  104.        pha ;save on stack
  105.        ;
  106.        ldx #14
  107.        stx mmu ;enable kernal
  108.        ;
  109.        inx
  110.        stx sigvol ;maximum volume
  111.        ;
  112.        lda #183
  113.        sta keychk ;bypass f keys
  114.        ;
  115.        jsr chime ;signal user
  116.        ;
  117.        lda #clr
  118.        jsr chrout ;clear screen
  119.        ;
  120.        ;
  121. ;display input prompt...
  122.        ;
  123. stim01 ldx #2 ;row
  124.        ldy #0 ;column
  125.        jsr plota ;position cursor
  126.        ;
  127.        lda sflg ;entry mode
  128.        ;
  129.        asl ;double
  130.        tax ;becomes prompt offset
  131.        ;
  132.        lda ptab,x ;prompt address
  133.        ldy ptab+1,x
  134.        jsr prnt ;output
  135.        ;
  136.        ldx #2 ;row
  137.        ;
  138.        sec
  139.        tya
  140.        sbc #7 ;generate column value
  141.        tay
  142.        jsr plota ;position cursor
  143.        ;
  144.        jsr clrq ;clear keyb'd queue
  145.        sta ctr ;clear input counter
  146.        ;
  147.        ;
  148. ;fetch user input...
  149.        ;
  150. stim02 sei ;interrupts off
  151.        ;
  152.        jsr curon ;flash cursor
  153.        ;
  154.        cli ;interrupts on
  155.        ;
  156. stim03 jsr getin ;fetch keypress
  157.        beq stim03 ;no input
  158.        ;
  159.        pha ;save keypress
  160.        ;
  161.        bit mode
  162.        bpl stim04 ;40 columns
  163.        ;
  164.        sei
  165.        ;
  166.        jsr curof2 ;kill 80 col cursor
  167.        ;
  168.        cli
  169.        ;
  170.        jmp stim05
  171.        ;
  172. stim04 jsr curof1 ;kill 40 col cursor
  173.        ;
  174.        ;
  175. ;filter & store input...
  176.        ;
  177. stim05 pla ;retrieve keypress
  178.        ;
  179.        ldy ctr ;fetch count
  180.        beq stim06
  181.        ;
  182.        cmp #del
  183.        beq stim01 ;input deleted
  184.        ;
  185. stim06 cpy #4
  186.        bcc stim07 ;more input needed
  187.        ;
  188.        cmp #cr
  189.        bne stim02 ;not <return>
  190.        ;
  191.        beq stim08 ;finished
  192.        ;
  193. stim07 cmp #"0"
  194.        bcc stim02 ;out of range
  195.        ;
  196.        cmp #":"
  197.        bcs stim02 ;out of range
  198.        ;
  199.        jsr chrout ;echo digit
  200.        ;
  201.        sta buf,y ;store
  202.        ;
  203.        inc ctr ;bump character count
  204.        ;
  205.        cpy #1
  206.        bne stim02 ;loop
  207.        ;
  208.        lda #right
  209.        jsr chrout ;jump over colon
  210.        ;
  211.        jmp stim02 ;loop
  212.        ;
  213.        ;
  214. ;encode time into bcd...
  215.        ;
  216. stim08 ldx buf ;fetch hours (tens)
  217.        lda buf+1 ;fetch hours (units)
  218.        jsr ascbcd ;convert
  219.        ;
  220.        cmp #$24
  221.        bcc stim10
  222.        ;
  223. stim09 jsr buzzer ;illegal value
  224.        ;
  225.        jmp stim01 ;reenter
  226.        ;
  227. stim10 sta todc+2 ;save
  228.        ;
  229.        ldx buf+2 ;fetch minutes (tens)
  230.        lda buf+3 ;fetch minutes (units)
  231.        jsr ascbcd ;convert
  232.        ;
  233.        cmp #$60
  234.        bcs stim09 ;illegal minute value
  235.        ;
  236.        sta todc+1 ;save
  237.        ;
  238.        lda #0
  239.        sta todc ;zero seconds
  240.        ;
  241.        ;
  242. ;confirm time entry...
  243.        ;
  244.        ldx #4
  245.        ldy #0
  246.        jsr plota
  247.        ;
  248.        lda #<timp3 ;'correct?'
  249.        ldy #>timp3
  250.        jsr prnt
  251.        ;
  252.        jsr chime
  253.        ;
  254.        jsr clrq
  255.        ;
  256. stim11 jsr getin ;fetch keypress
  257.        cmp #"n"
  258.        beq stim15 ;abort
  259.        ;
  260.        cmp #"y"
  261.        bne stim11 ;loop
  262.        ;
  263.        lda sflg
  264.        beq stim12 ;setting tod
  265.        ;
  266.        ;
  267. ;set alarm time & enable flag...
  268.        ;
  269.        ldx todc+2 ;entered hours
  270.        ldy todc+1 ;entered minutes
  271.        stx altc ;set alarm register
  272.        sty altc+1
  273.        ;
  274.        sta aflg ;set alarm flag
  275.        ;
  276.        jmp stim15 ;exit
  277.        ;
  278.        ;
  279. ;set time of day...
  280.        ;
  281. stim12 lda todc+2 ;hours
  282.        beq stim13 ;is midnite
  283.        ;
  284.        cmp #$12
  285.        bcc stim13 ;is am
  286.        ;
  287.        ;
  288. ;convert 24 hour entry to 12 hour...
  289.        ;
  290.        sed ;decimal mode
  291.        ;
  292.        sec
  293.        sbc #$12 ;change to 12 hour time
  294.        ;
  295.        cld ;binary mode
  296.        ;
  297.        ora #128 ;set pm bit
  298.        ;
  299.        sta todc+2 ;save hours
  300.        ;
  301.        ;
  302. ;set clock registers...
  303.        ;
  304.        sei
  305.        ;
  306. stim13 lda tod2+7 ;control register
  307.        and #127 ;setting time of day
  308.        sta tod2+7
  309.        ;
  310.        ldx #2 ;todc offset
  311.        ldy #3 ;tod2 offset
  312.        ;
  313. stim14 lda todc,x ;fetch time &...
  314.        sta tod2,y ;store in cia #2...
  315.        dex ;hardware registers
  316.        dey
  317.        bne stim14 ;loop
  318.        ;
  319.        sta tod2 ;start clock
  320.        ;
  321.        cli
  322.        ;
  323.        ;
  324. ;restore system & exit...
  325.        ;
  326. stim15 ldx #173
  327.        ldy #0
  328.        stx keychk ;enable f keys
  329.        sty sigvol ;sound off
  330.        ;
  331.        pla
  332.        sta mmu ;restore configuration
  333.        ;
  334.        pla
  335.        sta color ;restore attribute
  336.        ;
  337.        rts
  338.        ;
  339. ;=================================
  340.        ;
  341. ;convert ascii to bcd
  342.        ;
  343. ascbcd and #15 ;units to binary
  344.        sta ctr ;store
  345.        ;
  346.        txa ;swap tens
  347.        ;
  348.        asl ;shift tens to...
  349.        asl ;high nybble
  350.        asl  
  351.        asl  
  352.        ;
  353.        ora ctr ;combine nybbles
  354.        ;
  355.        rts
  356.        ;
  357. ;---------------------------------
  358.        ;
  359. ;position cursor
  360.        ;
  361. plota  clc
  362.        ;
  363.        jmp plot
  364.        ;
  365. ;---------------------------------
  366.        ;
  367. ;print to screen
  368.        ;
  369. prnt   sta ptr ;save text pointer
  370.        sty ptr+1
  371.        ;
  372.        ldy #0 ;offset
  373.        ;
  374. prnt01 lda (ptr),y ;fetch
  375.        beq clrq01 ;exit
  376.        ;
  377.        jsr chrout ;print
  378.        iny
  379.        bne prnt01 ;loop
  380.        ;
  381. ;---------------------------------
  382.        ;
  383. ;clear keyboard queue
  384.        ;
  385. clrq   lda #0
  386.        sta ndx
  387.        ;
  388. clrq01 rts
  389.        ;
  390. ;---------------------------------
  391.        ;
  392. ;buzzer
  393.        ;
  394. buzzer lda #6
  395.        ldx #251
  396.        ldy #33
  397.        bne signal
  398.        ;
  399. ;---------------------------------
  400.        ;
  401. ;chime
  402.        ;
  403. chime  lda #50
  404.        ldx #250
  405.        ldy #17
  406.        ;
  407. ;---------------------------------
  408.        ;
  409. ;signal user
  410.        ;
  411. signal sta 54273
  412.        stx 54278
  413.        sty 54276
  414.        ;
  415.        dey
  416.        sty 54276
  417.        ;
  418.        rts
  419.        ;
  420. ;---------------------------------
  421.        ;
  422. ;input prompt look-up table
  423.        ;
  424. ptab   .word timp1,timp2
  425.        ;
  426. ;---------------------------------
  427.        ;
  428. ;input prompts
  429.        ;
  430. timp1  .byte yel
  431.        .asc "correct time (hh:mm):"
  432.        .byte cyn
  433.        .asc "   :"           
  434.        .byte esc
  435.        .asc "q"
  436.        .byte 0
  437.        ;
  438. timp2  .byte yel
  439.        .asc "alarm time (hh:mm):"
  440.        .byte cyn
  441.        .asc "   :"           
  442.        .byte esc
  443.        .asc "q"
  444.        .byte 0
  445.        ;
  446. timp3  .byte wht
  447.        .asc "is this time cor"
  448.        .asc "rect (y/n)?"  
  449.        .byte 0
  450.        ;
  451. ;---------------------------------
  452.        ;
  453. ;program storage
  454.        ;
  455. buf    *=*+4 ;input buffer
  456.        ;
  457. sflg   *=*+1 ;entry mode
  458.        ;
  459. todc   *=*+3 ;bcd time (s:m:h)
  460. ;
  461. ;=================================
  462. .end
  463.