This is a simple program that will display the time and allow the user to
enter 3 keys:
1. Escape - Exit the program
2. Up arrow - Increment seconds
3. Down arrow - Decrement seconds
There is a feature limitation in that the program doesn't update the minutes
when the seconds become less than zero or greater than 60. It turns out that
this is no problem when incrementing the time, but leads to interesting side
effects when decrementing it.
The 'macros' short and long should be replaced by the following instructions:
short: long:
------ -----
sec clc
xce xce
sep #30 rep #30
They simply put the computer in either 8- (short) or 16- (long) bit mode,
whichever is necessary at the time.
Start
short ; put the computer in 8-bit mode
lda c010 ; clear the keyboard
loop jsr ShowTime ; show the time and date
jsr ReadKey ; see if a char was typed, and act on it
bcc loop ; carry set if ESCAPE is hit
rts
ShowTime
long
pea 0000 ; point output buffer to screen
pea 0400
ldx #0f03 ; _ReadAsciiTime (put ASCII time onto screen)
jsl $e10000
short
rts
ReadKey
lda c000 ; was a key hit?
bmi KeyHit ; yes, do something about it.
clc ; no - return to main loop
rts
KeyHit
lda c000 ; get the key (high bit set)
sta c010 ; clear keyboard strobe
cmp #9b ; Escape?
bne NotESC
sec ; Escape was hit - set Quit flag
rts
NotESC
cmp #9a ; down arrow?
beq Arrow
cmp #9b ; up arrow?
beq Arrow
clc ; neither, return with no error
rts
Arrow
sta temp ; remember which arrow was chosen
long
pha ; push room on stack for time in hex format
pha
pha
pha
ldx #0d03 ; _ReadTimeHex (leave everything on the stack
jsl e10000 ; for _WriteTimeHex later)
short
ldx 01,s ; get the seconds
ldx temp ; recall which arrow was hit
cpx #9a
beq dnArrow
inc a ; increment time on up arrow
bra cont
dnArrow
dec a ; decrement time on down arrow
cont
sta 01,s ; put it back on the stack
long
ldx #0e03 ; _WriteTimeHex
jsl e10000
pla ; get rid of extra stuff from _GetTimeHex
short
jsr ShowTime ; update the screen
bra ReadKey ; see if another key was hit
Temp ds 1 ; temporary storage
The calls and usage shown in the program are described in "The Apple IIGS
Toolbox Reference Manual: Parts 1 and 2" available from Addison-Wesley.