home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Brotikasten
/
BROTCD01.iso
/
c128
/
c124.d64
/
clock128.src
< prev
next >
Wrap
Text File
|
1995-08-09
|
9KB
|
250 lines
;"0:CLOCK128.SRC
;
.MAC W8563
LDX ?1
LDA ?2
JSR WRITE8563
.MND
.MAC R8563
LDX ?1
JSR READ8563
.MND
;****************************
;* THIS ROUTINE FOR C-128 USE ONLY !
;****************************
CIA2TOD1 = $DD08 ;TIME OF DAY CLOCK (10THS)
CIA2TODS = $DD09 ;TOD CLOCK (SECONDS)
CIA2TODM = $DD0A ;TOD CLOCK (MINUTES)
CIA2TODH = $DD0B ;TOD CLOCK (HOURS)
CIA2CRA = $DD0E ;CIA CONTROL REGISTER
CIA2CRB = $DD0F ;CIA CONTROL REGISTER
.LIB K128.XREF
*= $1300 ;BEGIN PROGRAM AT 4864
LDA #"0"
LDX #7
STARTLOOP STA INTIMEOUT,X
DEX
STA INTIMEOUT,X
DEX
DEX
BPL STARTLOOP
JSR SETCLOCK ;LET US SET THE CLOCK
SEI ;SET IRQ INTERUPT VECTOR
LDA #<CLOCKIRQ ;TO CLOCK ROUTINE
STA $0314
LDA #>CLOCKIRQ
STA $0315
CLI
LDA 241
STA CHARCOLOR
RTS ;RETURN TO BASIC
COPYRIGHT .BYT "(C) COPYRIGHT 1987 "
.BYT "BY DIAMOND SOFTWARE AND C.L. GOTWALD"
IRQDONE JMP RETVEC ;RETURN TO HARDWARE IRQ
CLOCKIRQ NOP
LDA $D3 ;IS ALT KEY PRESSED?
AND #%00001000 ;CLEAR ALL EXCEPT ALT FLAG
BEQ CLOCKIRQCONT ;NOT PRESSED, CONTINUE
INC CHARCOLOR
CLOCKIRQCONT INC STOPWATCH ;THIS IS A SLOW DOWN
BIT STOPWATCH ;TECHNIC. I HAD PROBLEMS
BPL IRQDONE ;WITH LONG IRQ'S
LDA #0 ;RESET STOPWATCH
STA STOPWATCH
JSR READCLOCK ;READ THE TOD CLOCK
LDA CHARCOLOR ;GET CHAR COLOR TO PRINT
AND #%00001111 ;CLEAR HI NYBBLE
ORA #%01000000 ;SET REV ON
STA TIMEATTRIBS
BIT $D600 ;STOP ALL SCREEN ACCESS
BPL IRQDONE
SEI
R8563 #18 ;GET UPDATE ADDR HI
STA SAVE18 ;SAVE IT
R8563 #19 ;GET UPDATE ADDR LO
STA SAVE19 ;SAVE IT
LDA #70 ;SET SCREEN ADDRESS LO
STA SCNLOC
W8563 #18:#0 ;PREPARE FOR TIME OUTPUT
W8563 #19:SCNLOC
LDY #0
CLOCKOUTLOOP LDA NEWTIME,Y ;GET NEXT CHARACTER
STA OUTCHAR ;STORE FOR USE
W8563 #31:OUTCHAR ;OUTPUT TO SCREEN
W8563 #18:#8 ;CHANGE ACCESS ADDR
W8563 #19:SCNLOC
W8563 #31:TIMEATTRIBS ;OUTPUT ATTRIBUTES
W8563 #18:#0 ;RESET ACCESS ADDR
INC SCNLOC ;FOR NEXT USE
W8563 #19:SCNLOC
INY ;INCREMENT CHAR COUNT
CPY #10 ;HAVE WE DONE ALL?
BNE CLOCKOUTLOOP ;NO, PUT THE NEXT CHAR
W8563 #18:SAVE18 ;RESTORE SCREEN ACCESS
W8563 #19:SAVE19 ;FOR NORMAL PROGRAM ACCESS
CLI ;CLEAR INTERRUPT
JMP RETVEC ;HARDWARE IRQ ROUTINE
ERRORRESET NOP
LDX #7
ERR01 LDA NEWTIME+1,X
STA INTIMEOUT,X
DEX
BPL ERR01
LDA #"*"
STA INTIMEOUT,Y
JSR PRIMM
.BYT 13,"æ",0
JMP SETCLOCK
CLOCKERR JMP ERRORRESET
SETCLOCK NOP
JSR PRIMM ;PRINT IMMEDIATE
.BYT "ENTER TIME (HH:MM:SS) "
INTIMEOUT .BYT "00:00:00¥¥¥¥¥¥¥¥",0
LDX #0 ;GET TIME
GETTIME JSR CHRIN
CMP #13 ;END OF INPUT?
BEQ TESTSYNTAX ;YES, CHECK IT OUT
CPX #8
BEQ GETTIME
STA NEWTIME+1,X
INX
BNE GETTIME
TESTSYNTAX NOP
LDX #2 ;PREPARE INDICES
LDY #7
TESTSYNTAX01 LDA NEWTIME+1,Y ;LOAD INPUT CHARACTER
SEC
SBC #"0" ;MAKE IT 0 TO 9
; CMP #0 ;IS IT LESS THAN "0"?
BMI CLOCKERR ;YES, GO AGAIN
CLC
CMP #10 ;IS IT GREATER THAN "9"?
BCS CLOCKERR ;YES, GO AGAIN
STA NEWTIMEBCD,X ;OKAY, STORE IT
DEY ;
LDA NEWTIME+1,Y ;LOAD INPUT CHARACTER
SEC
SBC #"0" ;MAKE IT 0 TO 9
; CMP #0 ;IS IT LESS THAN "0"?
BMI CLOCKERR ;YES, GO AGAIN
CLC
CMP #10 ;IS IT GREATER THAN "9"?
BCS CLOCKERR ;YES, GO AGAIN
ASL A ;SHIFT VALUE TO THE UPPER
ASL A ;NYBBLE OF THE ACCUMULATOR
ASL A
ASL A
ORA NEWTIMEBCD,X ;OR IN THE LOW BYTE
STA NEWTIMEBCD,X ;STORE BCD VALUE
DEY ;DECREMENT PAST THE ":"
DEY
DEX
BPL TESTSYNTAX01 ;TEST MINUTES/HOURS
LDA NEWTIMEBCD ;CHECK FOR VALID HOUR
LDY #1
CLC
CMP #$24 ;IS IT >= 24?
CLOCKERR01 BCS CLOCKERR ;BAD NUMBER, GO AGAIN
SEC
CMP #$12 ;IS IT < 12?
BCC AMHOUR ;YES, DON'T SET PM BIT
SED
SEC
SBC #$12
CLD
PMHOUR ORA #%10000000
AMHOUR STA NEWTIMEBCD ;STORE HOURS
LDY #4
LDA NEWTIMEBCD+1 ;CHECK MINUTES SYNTAX
CMP #$60 ;IS IT >= 60?
BCS CLOCKERR01 ;YES, ERROR
LDY #7
LDA NEWTIMEBCD+2 ;CHECK SECONDS SYNTAX
CMP #$60 ;IS IT >= 60?
BCS CLOCKERR01 ;YES, ERROR
LDA NEWTIMEBCD ;GET HOURS
STA CIA2TODH ;STORE IN TOD CLOCK
LDA NEWTIMEBCD+1 ;GET MINUTES
STA CIA2TODM ;STORE IN TOD CLOCK
LDA NEWTIMEBCD+2 ;GET SECONDS
STA CIA2TODS ;STORE IN TOD CLOCK
NOP
LDA #0 ;LOAD 0
STA CIA2TOD1 ;START TOD CLOCK TICKING
RTS ;RETURN TO SET IRQ VECTOR
NEWTIME .BYT " 00:00:00 ",0
TIMEATTRIBS .BYT 0
NEWTIMEBCD .BYT 0,0,0
LASTUPDATE .BYT 0
SCNLOC .BYT 0
OUTCHAR .BYT 0
SAVE18 .BYT 0
SAVE19 .BYT 0
RETVEC = $FA65
STOPWATCH .BYT 0
CHARCOLOR .BYT 0
;
;
READCLOCK LDA CIA2TODH ;GET HOURS
STA NEWTIMEBCD ;STORE HOURS
LDA CIA2TODM ;GET MINUTES
STA NEWTIMEBCD+1 ;STORE MINUTES
LDA CIA2TODS ;GET SECONDS
STA NEWTIMEBCD+2 ;STORE SECONDS
LDA CIA2TOD1 ;RESTART CLOCK
LDY #7
LDX #2
READCLOCK01 LDA NEWTIMEBCD,X ;LOAD SECONDS/MINUTES/HRS
AND #%00001111 ;STRIP UPPER NYBBLE
CLC
ADC #$30 ;MAKE IT ASCII
STA NEWTIME+1,Y ;STORE IN OUTPUT LOCATION
DEY
LDA NEWTIMEBCD,X ;RELOAD SECS/MINS/HRS
AND #%11110000 ;STRIP LOWER NYBBLE
LSR A ;SHIFT UPPER NYBBLE TO
LSR A ;LOWER NYBBLE
LSR A
LSR A
ADC #$30 ;MAKE IT ASCII
STA NEWTIME+1,Y ;AND STORE IN OUTPUT
DEY
LDA #":" ;PUT ":" IN ITS LOCATION
STA NEWTIME+1,Y
DEY
DEX ;ARE WE DONE YET?
BMI ESCAPECLOCK ;YES, LEAVE
BNE READCLOCK01
PHP ;HOLD THIS STATUS
LDA NEWTIMEBCD ;IS IT PM?
BMI READCLOCK02 ;NO, GO AGAIN
CMP #$12 ;IS IT 00:??:??
BNE R