home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_22_1988_Transactor_Publishing.d64
/
dateset.bud
< prev
next >
Wrap
Text File
|
2023-02-26
|
9KB
|
450 lines
;put"@0:dateset.bud"
;
*=$1600 ; 5632
.obj "@0:dt5632"
;
;* * * * * * * * * * * * * * * * *
;* *
;* calendar date setup *
;* *
;* written 11-29-85 w.j. brier *
;* *
;* revised 1-18-87 *
;* *
;* copyright (c) 1985 *
;* *
;* all rights reserved *
;* *
;* use with clock-calendar 128 *
;* *
;* set date: sys 5632 *
;* *
;* enter date as: mm-dd-yy *
;* *
;* * * * * * * * * * * * * * * * *
;
;
;
;* * * * * * * * * * * * * * * * *
;* *
;* program assignments *
;* *
;* * * * * * * * * * * * * * * * *
;
;
;
;system vectors & pointers...
;
ndx =$d0 ;keyboard queue
;
mode =$d7 ;40/80 column mode
;
color =$f1 ;next attribute
;
keychk =$033c ;key decode vector
;
curon =$cd6f ;flash cursor
curof1 =$cd9f ;kill cursor (40 col)
curof2 =$cdac ;kill cursor (80 col)
;
sigvol =$d418 ;volume control
;
mmu =$ff00 ;memory management
;
chrout =$ffd2 ;output a byte
getin =$ffe4 ;get a byte
plot =$fff0 ;position cursor
;
;
;miscellaneous pointers...
;
ptr =$fa ;zero page pointer
ctr =$fc ;counter
;
;
;clock-calendar location...
;
tdtc =$1312 ;bcd date in clock
;
;
;video constants...
;
wht =5 ;white text
cr =13 ;carriage return
del =20 ;delete
esc =27 ;escape character
right =29 ;cursor right
clr =147 ;clear screen
yel =158 ;yellow text
cyn =159 ;cyan text
;
;
;# # # # # # # # # # # # # # # # #
;# #
;# c-128 calendar date setup #
;# #
;# # # # # # # # # # # # # # # # #
;
;
;initial setup...
;
date lda color ;current attribute
pha ;save
;
lda mmu ;configuration
pha ;save on stack
;
ldx #14
stx mmu ;enable kernal
;
inx
stx sigvol ;maximum volume
;
lda #183
sta keychk ;bypass f keys
;
jsr chime ;signal user
;
lda #clr
jsr chrout ;clear screen
;
;
;display input prompt...
;
date01 ldx #2 ;row
ldy #0 ;column
jsr plota ;position cursor
;
ldx #<datep1 ;'today's date'
ldy #>datep1
jsr prnt ;display prompt
;
ldx #2 ;position cursor...
ldy #14 ;to accept...
jsr plota ;user input
;
jsr clrq ;clear keyb'd queue
sta ctr ;clear input counter
;
;
;fetch user input...
;
date02 sei ;interrupts off
;
jsr curon ;flash cursor
;
cli ;interrupts on
;
date03 jsr getin ;fetch keypress
beq date03 ;no input
;
pha ;save keypress
;
bit mode
bpl date04 ;40 columns
;
sei
;
jsr curof2 ;kill 80 col cursor
;
cli
;
jmp date05
;
date04 jsr curof1 ;kill 40 col cursor
;
;
;filter & store input...
;
date05 pla ;retrieve keypress
;
ldy ctr ;fetch character count
beq date06
;
cmp #del
beq date01 ;deleted
;
date06 cpy #6
bcc date07 ;more input needed
;
cmp #cr
bne date02 ;not <return>
;
beq date09 ;end of input
;
date07 cmp #"0"
bcc date02 ;out of range
;
cmp #":"
bcs date02 ;out of range
;
jsr chrout ;echo character
;
sta buf,y ;store
;
inc ctr
;
cpy #1
beq date08
;
cpy #3
bne date02 ;loop
;
date08 lda #right
jsr chrout ;jump over hyphen
;
jmp date02 ;loop
;
;
;encode date into bcd...
;
date09 ldx #2 ;bcd offset
ldy #5 ;ascii offset
;
date10 lda buf,y ;fetch units
and #15 ;mask hi nybble
sta ctr ;store
;
dey
lda buf,y ;fetch tens
;
asl ;shift lo nybble...
asl ;to high
asl
asl
;
ora ctr ;combine w/units
sta dbuf,x ;save bcd digit
;
dey
dex
bpl date10 ;loop
;
;
;test for leap year entry...
;
pha ;save month value
;
lda dbuf+2 ;year entry
jsr bcbin ;change to binary
;
ldx #$29 ;non-leap year test value
;
lsr ;divide year by 2
bcs date11 ;non-leap year
;
lsr
bcs date11
;
ldx #$30 ;bump test value
;
date11 stx clut+1 ;test value
;
;
;check for valid input month...
;
pla ;input month
bne date13 ;not zero month
;
date12 jsr buzzer ;error
;
jmp date01 ;reenter
;
date13 cmp #$13
bcs date12 ;too high
;
;
;check for valid input day...
;
jsr bcbin ;change to binary
tax
dex ;make table offset
;
lda dbuf+1 ;entry day
beq date12 ;zero for day
;
cmp clut,x ;table
bcs date12 ;too high for month
;
;
;confirm entry...
;
ldx #4
ldy #0
jsr plota
;
ldx #<datep2 ;'is this correct?'
ldy #>datep2
jsr prnt
;
jsr chime
;
jsr clrq
;
date14 jsr getin ;fetch keypress
cmp #"n"
beq date16 ;abort
;
cmp #"y"
bne date14 ;loop
;
;
;transfer date to calendar storage...
;
ldx #2 ;offset
;
date15 lda dbuf,x
sta tdtc,x ;store in calendar
dex
bpl date15 ;loop
;
;
;restore system & exit...
;
date16 ldx #173
ldy #0
stx keychk ;enable f keys
sty sigvol ;shut off sid
;
pla
sta mmu ;restore configuration
;
pla
sta color ;restore attribute
;
rts
;
;=================================
;
;change bcd digit to binary digit
;
bcbin pha ;save bcd digit
;
lsr ;shift tens nybble...
lsr ;to lo position
lsr
lsr
;
tax ;becomes tens counter
;
pla ;fetch bcd digit
and #15 ;mask tens nybble
;
clc
;
bcbin1 dex ;step tens counter
bmi bcbin2 ;finished
;
adc #10 ;add 10 to units
bne bcbin1 ;loop
;
bcbin2 rts
;
;---------------------------------
;
;buzzer tone
;
buzzer lda #6 ;frequency
ldx #251 ;duration
ldy #33 ;sawtooth
bne signal
;
;---------------------------------
;
;chime tone
;
chime lda #50
ldx #250
ldy #17 ;triangle
;
;---------------------------------
;
;signal user
;
signal sta 54273
stx 54278
sty 54276
;
dey
sty 54276 ;gate tone on
;
rts
;
;---------------------------------
;
;clear keyboard queue
;
clrq lda #0
sta ndx
;
clrq01 rts
;
;---------------------------------
;
;position cursor
;
plota clc
;
jmp plot
;
;---------------------------------
;
;print to screen
;
prnt stx ptr ;string address
sty ptr+1
;
ldy #0 ;offset
;
prnt01 lda (ptr),y ;fetch
beq clrq01
;
jsr chrout
iny
bne prnt01 ;loop
;
;---------------------------------
;
;calendar lookup table
;
clut .byte $32 ;jan+1
.byte $29 ;feb+1
.byte $32 ;mar+1
.byte $31 ;apr+1
.byte $32 ;may+1
.byte $31 ;jun+1
.byte $32 ;jul+1
.byte $32 ;aug+1
.byte $31 ;sep+1
.byte $32 ;oct+1
.byte $31 ;nov+1
.byte $32 ;dec+1
;
;---------------------------------
;
;user prompts
;
datep1 .byte yel
.asc "today's date:"
.byte cyn
.asc " - -"
.byte esc
.asc "q"
.byte 0
;
datep2 .byte wht
.asc "is this date"
.asc " correct (y/n)?"
.byte 0
;
;---------------------------------
;
;program storage
;
buf *=*+6 ;input buffer
;
dbuf *=*+3 ;date encoding buffer
;
;=================================
.end