home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_22_1988_Transactor_Publishing.d64
/
clockset.bud
< prev
next >
Wrap
Text File
|
2023-02-26
|
9KB
|
463 lines
;put"@0:clockset.bud"
; ** rewritten in Buddy 128 format
;
*=$1600 ; 5632
.obj "@0:clk5632"
;* * * * * * * * * * * * * * * * *
;* *
;* clock & alarm setup *
;* *
;* written 12-02-85 w.j. brier *
;* *
;* revised 1-18-87 *
;* *
;* copyright (c) 1985 *
;* *
;* all rights reserved *
;* *
;* use with clock-calendar 128 *
;* *
;* set time of day: sys 5632,0 *
;* set alarm time: sys 5632,1 *
;* *
;* enter time in 24 hour format *
;* *
;* * * * * * * * * * * * * * * * *
;
;
;
;* * * * * * * * * * * * * * * * *
;* *
;* <<< 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
;
tod2 =$dd08 ;time of day clock #2
;
mmu =$ff00 ;memory configuration
;
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 locations...
;
altc =$131e ;alarm register
aflg =$1320 ;alarm enable flag
;
;
;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 time/alarm setup #
;# #
;# # # # # # # # # # # # # # # # #
;
;
;
;initial setup...
;
stim and #1 ;mask garbage &...
sta sflg ;set entry mode flag
;
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...
;
stim01 ldx #2 ;row
ldy #0 ;column
jsr plota ;position cursor
;
lda sflg ;entry mode
;
asl ;double
tax ;becomes prompt offset
;
lda ptab,x ;prompt address
ldy ptab+1,x
jsr prnt ;output
;
ldx #2 ;row
;
sec
tya
sbc #7 ;generate column value
tay
jsr plota ;position cursor
;
jsr clrq ;clear keyb'd queue
sta ctr ;clear input counter
;
;
;fetch user input...
;
stim02 sei ;interrupts off
;
jsr curon ;flash cursor
;
cli ;interrupts on
;
stim03 jsr getin ;fetch keypress
beq stim03 ;no input
;
pha ;save keypress
;
bit mode
bpl stim04 ;40 columns
;
sei
;
jsr curof2 ;kill 80 col cursor
;
cli
;
jmp stim05
;
stim04 jsr curof1 ;kill 40 col cursor
;
;
;filter & store input...
;
stim05 pla ;retrieve keypress
;
ldy ctr ;fetch count
beq stim06
;
cmp #del
beq stim01 ;input deleted
;
stim06 cpy #4
bcc stim07 ;more input needed
;
cmp #cr
bne stim02 ;not <return>
;
beq stim08 ;finished
;
stim07 cmp #"0"
bcc stim02 ;out of range
;
cmp #":"
bcs stim02 ;out of range
;
jsr chrout ;echo digit
;
sta buf,y ;store
;
inc ctr ;bump character count
;
cpy #1
bne stim02 ;loop
;
lda #right
jsr chrout ;jump over colon
;
jmp stim02 ;loop
;
;
;encode time into bcd...
;
stim08 ldx buf ;fetch hours (tens)
lda buf+1 ;fetch hours (units)
jsr ascbcd ;convert
;
cmp #$24
bcc stim10
;
stim09 jsr buzzer ;illegal value
;
jmp stim01 ;reenter
;
stim10 sta todc+2 ;save
;
ldx buf+2 ;fetch minutes (tens)
lda buf+3 ;fetch minutes (units)
jsr ascbcd ;convert
;
cmp #$60
bcs stim09 ;illegal minute value
;
sta todc+1 ;save
;
lda #0
sta todc ;zero seconds
;
;
;confirm time entry...
;
ldx #4
ldy #0
jsr plota
;
lda #<timp3 ;'correct?'
ldy #>timp3
jsr prnt
;
jsr chime
;
jsr clrq
;
stim11 jsr getin ;fetch keypress
cmp #"n"
beq stim15 ;abort
;
cmp #"y"
bne stim11 ;loop
;
lda sflg
beq stim12 ;setting tod
;
;
;set alarm time & enable flag...
;
ldx todc+2 ;entered hours
ldy todc+1 ;entered minutes
stx altc ;set alarm register
sty altc+1
;
sta aflg ;set alarm flag
;
jmp stim15 ;exit
;
;
;set time of day...
;
stim12 lda todc+2 ;hours
beq stim13 ;is midnite
;
cmp #$12
bcc stim13 ;is am
;
;
;convert 24 hour entry to 12 hour...
;
sed ;decimal mode
;
sec
sbc #$12 ;change to 12 hour time
;
cld ;binary mode
;
ora #128 ;set pm bit
;
sta todc+2 ;save hours
;
;
;set clock registers...
;
sei
;
stim13 lda tod2+7 ;control register
and #127 ;setting time of day
sta tod2+7
;
ldx #2 ;todc offset
ldy #3 ;tod2 offset
;
stim14 lda todc,x ;fetch time &...
sta tod2,y ;store in cia #2...
dex ;hardware registers
dey
bne stim14 ;loop
;
sta tod2 ;start clock
;
cli
;
;
;restore system & exit...
;
stim15 ldx #173
ldy #0
stx keychk ;enable f keys
sty sigvol ;sound off
;
pla
sta mmu ;restore configuration
;
pla
sta color ;restore attribute
;
rts
;
;=================================
;
;convert ascii to bcd
;
ascbcd and #15 ;units to binary
sta ctr ;store
;
txa ;swap tens
;
asl ;shift tens to...
asl ;high nybble
asl
asl
;
ora ctr ;combine nybbles
;
rts
;
;---------------------------------
;
;position cursor
;
plota clc
;
jmp plot
;
;---------------------------------
;
;print to screen
;
prnt sta ptr ;save text pointer
sty ptr+1
;
ldy #0 ;offset
;
prnt01 lda (ptr),y ;fetch
beq clrq01 ;exit
;
jsr chrout ;print
iny
bne prnt01 ;loop
;
;---------------------------------
;
;clear keyboard queue
;
clrq lda #0
sta ndx
;
clrq01 rts
;
;---------------------------------
;
;buzzer
;
buzzer lda #6
ldx #251
ldy #33
bne signal
;
;---------------------------------
;
;chime
;
chime lda #50
ldx #250
ldy #17
;
;---------------------------------
;
;signal user
;
signal sta 54273
stx 54278
sty 54276
;
dey
sty 54276
;
rts
;
;---------------------------------
;
;input prompt look-up table
;
ptab .word timp1,timp2
;
;---------------------------------
;
;input prompts
;
timp1 .byte yel
.asc "correct time (hh:mm):"
.byte cyn
.asc " :"
.byte esc
.asc "q"
.byte 0
;
timp2 .byte yel
.asc "alarm time (hh:mm):"
.byte cyn
.asc " :"
.byte esc
.asc "q"
.byte 0
;
timp3 .byte wht
.asc "is this time cor"
.asc "rect (y/n)?"
.byte 0
;
;---------------------------------
;
;program storage
;
buf *=*+4 ;input buffer
;
sflg *=*+1 ;entry mode
;
todc *=*+3 ;bcd time (s:m:h)
;
;=================================
.end