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

  1. ;put"@0:dateset.bud"
  2. ;
  3. *=$1600 ; 5632
  4. .obj "@0:dt5632"
  5. ;
  6. ;* * * * * * * * * * * * * * * * *
  7. ;*                               *
  8. ;* calendar date setup           *
  9. ;*                               *
  10. ;* written 11-29-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 date: sys 5632            *
  21. ;*                               *
  22. ;* enter date as: mm-dd-yy       *
  23. ;*                               *
  24. ;* * * * * * * * * * * * * * * * *
  25.               ;
  26.               ;
  27.               ;
  28. ;* * * * * * * * * * * * * * * * *
  29. ;*                               *
  30. ;*      program assignments      *
  31. ;*                               *
  32. ;* * * * * * * * * * * * * * * * *
  33.               ;
  34.               ;
  35.               ;
  36. ;system vectors & pointers...
  37.               ;
  38. ndx    =$d0   ;keyboard queue
  39.               ;
  40. mode   =$d7   ;40/80 column mode
  41.               ;
  42. color  =$f1   ;next attribute
  43.               ;
  44. keychk =$033c ;key decode vector
  45.               ;
  46. curon  =$cd6f ;flash cursor
  47. curof1 =$cd9f ;kill cursor (40 col)
  48. curof2 =$cdac ;kill cursor (80 col)
  49.               ;
  50. sigvol =$d418 ;volume control
  51.               ;
  52. mmu    =$ff00 ;memory management
  53.               ;
  54. chrout =$ffd2 ;output a byte
  55. getin  =$ffe4 ;get a byte
  56. plot   =$fff0 ;position cursor
  57.               ;
  58.               ;
  59. ;miscellaneous pointers...
  60.               ;
  61. ptr    =$fa   ;zero page pointer
  62. ctr    =$fc   ;counter
  63.               ;
  64.               ;
  65. ;clock-calendar location...
  66.               ;
  67. tdtc   =$1312 ;bcd date in clock
  68.               ;
  69.               ;
  70. ;video constants...
  71.               ;
  72. wht    =5     ;white text
  73. cr     =13    ;carriage return
  74. del    =20    ;delete
  75. esc    =27    ;escape character
  76. right  =29    ;cursor right
  77. clr    =147   ;clear screen
  78. yel    =158   ;yellow text
  79. cyn    =159   ;cyan text
  80.               ;
  81.               ;
  82. ;# # # # # # # # # # # # # # # # #
  83. ;#                               #
  84. ;#   c-128 calendar date setup   #
  85. ;#                               #
  86. ;# # # # # # # # # # # # # # # # #
  87.        ;
  88.        ;
  89. ;initial setup...
  90.        ;
  91. date   lda color ;current attribute
  92.        pha ;save
  93.        ;
  94.        lda mmu ;configuration
  95.        pha ;save on stack
  96.        ;
  97.        ldx #14
  98.        stx mmu ;enable kernal
  99.        ;
  100.        inx
  101.        stx sigvol ;maximum volume
  102.        ;
  103.        lda #183
  104.        sta keychk ;bypass f keys
  105.        ;
  106.        jsr chime ;signal user
  107.        ;
  108.        lda #clr
  109.        jsr chrout ;clear screen
  110.        ;
  111.        ;
  112. ;display input prompt...
  113.        ;
  114. date01 ldx #2 ;row
  115.        ldy #0 ;column
  116.        jsr plota ;position cursor
  117.        ;
  118.        ldx #<datep1 ;'today's date'
  119.        ldy #>datep1
  120.        jsr prnt ;display prompt
  121.        ;
  122.        ldx #2 ;position cursor...
  123.        ldy #14 ;to accept...
  124.        jsr plota ;user input
  125.        ;
  126.        jsr clrq ;clear keyb'd queue
  127.        sta ctr ;clear input counter
  128.        ;
  129.        ;
  130. ;fetch user input...
  131.        ;
  132. date02 sei ;interrupts off
  133.        ;
  134.        jsr curon ;flash cursor
  135.        ;
  136.        cli ;interrupts on
  137.        ;
  138. date03 jsr getin ;fetch keypress
  139.        beq date03 ;no input
  140.        ;
  141.        pha ;save keypress
  142.        ;
  143.        bit mode
  144.        bpl date04 ;40 columns
  145.        ;
  146.        sei
  147.        ;
  148.        jsr curof2 ;kill 80 col cursor
  149.        ;
  150.        cli
  151.        ;
  152.        jmp date05
  153.        ;
  154. date04 jsr curof1 ;kill 40 col cursor
  155.        ;
  156.        ;
  157. ;filter & store input...
  158.        ;
  159. date05 pla ;retrieve keypress
  160.        ;
  161.        ldy ctr ;fetch character count
  162.        beq date06
  163.        ;
  164.        cmp #del
  165.        beq date01 ;deleted
  166.        ;
  167. date06 cpy #6
  168.        bcc date07 ;more input needed
  169.        ;
  170.        cmp #cr
  171.        bne date02 ;not <return>
  172.        ;
  173.        beq date09 ;end of input
  174.        ;
  175. date07 cmp #"0"
  176.        bcc date02 ;out of range
  177.        ;
  178.        cmp #":"
  179.        bcs date02 ;out of range
  180.        ;
  181.        jsr chrout ;echo character
  182.        ;
  183.        sta buf,y ;store
  184.        ;
  185.        inc ctr
  186.        ;
  187.        cpy #1
  188.        beq date08
  189.        ;
  190.        cpy #3
  191.        bne date02 ;loop
  192.        ;
  193. date08 lda #right
  194.        jsr chrout ;jump over hyphen
  195.        ;
  196.        jmp date02 ;loop
  197.        ;
  198.        ;
  199. ;encode date into bcd...
  200.        ;
  201. date09 ldx #2 ;bcd offset
  202.        ldy #5 ;ascii offset
  203.        ;
  204. date10 lda buf,y ;fetch units
  205.        and #15 ;mask hi nybble
  206.        sta ctr ;store
  207.        ;
  208.        dey
  209.        lda buf,y ;fetch tens
  210.        ;
  211.        asl ;shift lo nybble...
  212.        asl ;to high
  213.        asl  
  214.        asl  
  215.        ;
  216.        ora ctr ;combine w/units
  217.        sta dbuf,x ;save bcd digit
  218.        ;
  219.        dey
  220.        dex
  221.        bpl date10 ;loop
  222.        ;
  223.        ;
  224. ;test for leap year entry...
  225.        ;
  226.        pha ;save month value
  227.        ;
  228.        lda dbuf+2 ;year entry
  229.        jsr bcbin ;change to binary
  230.        ;
  231.        ldx #$29 ;non-leap year test value
  232.        ;
  233.        lsr ;divide year by 2
  234.        bcs date11 ;non-leap year
  235.        ;
  236.        lsr  
  237.        bcs date11
  238.        ;
  239.        ldx #$30 ;bump test value
  240.        ;
  241. date11 stx clut+1 ;test value
  242.        ;
  243.        ;
  244. ;check for valid input month...
  245.        ;
  246.        pla ;input month
  247.        bne date13 ;not zero month
  248.        ;
  249. date12 jsr buzzer ;error
  250.        ;
  251.        jmp date01 ;reenter
  252.        ;
  253. date13 cmp #$13
  254.        bcs date12 ;too high
  255.        ;
  256.        ;
  257. ;check for valid input day...
  258.        ;
  259.        jsr bcbin ;change to binary
  260.        tax
  261.        dex ;make table offset
  262.        ;
  263.        lda dbuf+1 ;entry day
  264.        beq date12 ;zero for day
  265.        ;
  266.        cmp clut,x ;table
  267.        bcs date12 ;too high for month
  268.        ;
  269.        ;
  270. ;confirm entry...
  271.        ;
  272.        ldx #4
  273.        ldy #0
  274.        jsr plota
  275.        ;
  276.        ldx #<datep2 ;'is this correct?'
  277.        ldy #>datep2
  278.        jsr prnt
  279.        ;
  280.        jsr chime
  281.        ;
  282.        jsr clrq
  283.        ;
  284. date14 jsr getin ;fetch keypress
  285.        cmp #"n"
  286.        beq date16 ;abort
  287.        ;
  288.        cmp #"y"
  289.        bne date14 ;loop
  290.        ;
  291.        ;
  292. ;transfer date to calendar storage...
  293.        ;
  294.        ldx #2 ;offset
  295.        ;
  296. date15 lda dbuf,x
  297.        sta tdtc,x ;store in calendar
  298.        dex
  299.        bpl date15 ;loop
  300.        ;
  301.        ;
  302. ;restore system & exit...
  303.        ;
  304. date16 ldx #173
  305.        ldy #0
  306.        stx keychk ;enable f keys
  307.        sty sigvol ;shut off sid
  308.        ;
  309.        pla
  310.        sta mmu ;restore configuration
  311.        ;
  312.        pla
  313.        sta color ;restore attribute
  314.        ;
  315.        rts
  316.        ;
  317. ;=================================
  318.        ;
  319. ;change bcd digit to binary digit
  320.        ;
  321. bcbin  pha ;save bcd digit
  322.        ;
  323.        lsr ;shift tens nybble...
  324.        lsr ;to lo position
  325.        lsr  
  326.        lsr  
  327.        ;
  328.        tax ;becomes tens counter
  329.        ;
  330.        pla ;fetch bcd digit
  331.        and #15 ;mask tens nybble
  332.        ;
  333.        clc
  334.        ;
  335. bcbin1 dex ;step tens counter
  336.        bmi bcbin2 ;finished
  337.        ;
  338.        adc #10 ;add 10 to units
  339.        bne bcbin1 ;loop
  340.        ;
  341. bcbin2 rts
  342.        ;
  343. ;---------------------------------
  344.        ;
  345. ;buzzer tone
  346.        ;
  347. buzzer lda #6 ;frequency
  348.        ldx #251 ;duration
  349.        ldy #33 ;sawtooth
  350.        bne signal
  351.        ;
  352. ;---------------------------------
  353.        ;
  354. ;chime tone
  355.        ;
  356. chime  lda #50
  357.        ldx #250
  358.        ldy #17 ;triangle
  359.        ;
  360. ;---------------------------------
  361.        ;
  362. ;signal user
  363.        ;
  364. signal sta 54273
  365.        stx 54278
  366.        sty 54276
  367.        ;
  368.        dey
  369.        sty 54276 ;gate tone on
  370.        ;
  371.        rts
  372.        ;
  373. ;---------------------------------
  374.        ;
  375. ;clear keyboard queue
  376.        ;
  377. clrq   lda #0
  378.        sta ndx
  379.        ;
  380. clrq01 rts
  381.        ;
  382. ;---------------------------------
  383.        ;
  384. ;position cursor
  385.        ;
  386. plota  clc
  387.        ;
  388.        jmp plot
  389.        ;
  390. ;---------------------------------
  391.        ;
  392. ;print to screen
  393.        ;
  394. prnt   stx ptr ;string address
  395.        sty ptr+1
  396.        ;
  397.        ldy #0 ;offset
  398.        ;
  399. prnt01 lda (ptr),y ;fetch
  400.        beq clrq01
  401.        ;
  402.        jsr chrout
  403.        iny
  404.        bne prnt01 ;loop
  405.        ;
  406. ;---------------------------------
  407.        ;
  408. ;calendar lookup table
  409.        ;
  410. clut   .byte $32 ;jan+1
  411.        .byte $29 ;feb+1
  412.        .byte $32 ;mar+1
  413.        .byte $31 ;apr+1
  414.        .byte $32 ;may+1
  415.        .byte $31 ;jun+1
  416.        .byte $32 ;jul+1
  417.        .byte $32 ;aug+1
  418.        .byte $31 ;sep+1
  419.        .byte $32 ;oct+1
  420.        .byte $31 ;nov+1
  421.        .byte $32 ;dec+1
  422.        ;
  423. ;---------------------------------
  424.        ;
  425. ;user prompts
  426.        ;
  427. datep1 .byte yel
  428.        .asc "today's date:"
  429.        .byte cyn
  430.        .asc "   -  -"
  431.        .byte esc
  432.        .asc "q"  
  433.        .byte 0
  434.        ;
  435. datep2 .byte wht
  436.        .asc "is this date"
  437.        .asc " correct (y/n)?"  
  438.        .byte 0
  439.        ;
  440. ;---------------------------------
  441.        ;
  442. ;program storage
  443.        ;
  444. buf    *=*+6 ;input buffer
  445.        ;
  446. dbuf   *=*+3 ;date encoding buffer
  447.        ;
  448. ;=================================
  449. .end
  450.