Add set.date/set.time helpers for Cricket

This commit is contained in:
Joshua Bell 2017-12-07 19:54:55 -08:00
parent 987092c318
commit 82a8ade241
4 changed files with 174 additions and 1 deletions

View File

@ -3,7 +3,9 @@ CC65 = ~/dev/cc65/bin
CAFLAGS = --target apple2enh --list-bytes 0
CCFLAGS = --config apple2-asm.cfg
TARGETS = prodos.mod.BIN ns.clock.system.SYS cricket.system.SYS test.BIN get.time.BIN
TARGETS = prodos.mod.BIN ns.clock.system.SYS cricket.system.SYS \
test.BIN get.time.BIN \
set.time.BIN set.date.BIN
# For timestamps
MM = $(shell date "+%m")

View File

@ -2,6 +2,7 @@
;;; ASCII
BELL := $07
BS := $08
CR := $0D
;;; ------------------------------------------------------------
@ -68,6 +69,8 @@ MLI_CLOSE := $CC
INIT := $FB2F
MON_HOME := $FC58
GETLN := $FD6A ; with prompt character
GETLN2 := $FD6F ; no prompt character
CROUT := $FD8E
PRBYTE := $FDDA
COUT := $FDED
@ -75,6 +78,8 @@ SETNORM := $FE84
SETKBD := $FE89
SETVID := $FE93
INPUT_BUFFER := $200
;;; ------------------------------------------------------------
;;; I/O Registers (for Slot 2)

83
set.date.s Normal file
View File

@ -0,0 +1,83 @@
.setcpu "6502"
.linecont +
.include "apple2.inc"
.include "./common.inc"
.org $2000
.proc main
jsr zstrout
HIASCII CR, "Date: WWW MM/DD/YY"
HIASCII BS, BS, BS, BS, BS, BS
HIASCII BS, BS, BS, BS, BS, BS
.byte 0
jsr GETLN2
;; Configure SSC
lda #%00001011 ; no parity/echo/interrupts, RTS low, DTR low
sta COMMAND
lda #%10011110 ; 9600 baud, 8 data bits, 2 stop bits
sta CONTROL
;; Clock Commands
;; Set Date "SD WWW MM/DD/YY"
lda #HI('S')
jsr sendbyte
lda #HI('D')
jsr sendbyte
lda #HI(' ')
jsr sendbyte
ldx #0
loop: lda INPUT_BUFFER,x
jsr sendbyte
inx
cmp #HI(CR)
bne loop
rts
.endproc
;; Write byte in A to SSC
.proc sendbyte
pha
: lda STATUS
and #(1 << 4) ; transmit register empty? (bit 4)
beq :- ; nope, keep waiting
pla
sta TDREG
rts
.endproc
;;; ------------------------------------------------------------
;;; Output a high-ascii, null-terminated string.
;;; String immediately follows the JSR.
.proc zstrout
ptr := $A5
pla ; read address from stack
sta ptr
pla
sta ptr+1
bne skip ; always (since data not on ZP)
next: jsr COUT
skip: inc ptr
bne :+
inc ptr+1
: ldy #0
lda (ptr),y
bne next
lda ptr+1 ; restore address to stack
pha
lda ptr
pha
rts
.endproc
;;; ------------------------------------------------------------

83
set.time.s Normal file
View File

@ -0,0 +1,83 @@
.setcpu "6502"
.linecont +
.include "apple2.inc"
.include "./common.inc"
.org $2000
.proc main
jsr zstrout
HIASCII CR, "Time: HH:MM:SS XM"
HIASCII BS, BS, BS, BS, BS, BS
HIASCII BS, BS, BS, BS, BS
.byte 0
jsr GETLN2
;; Configure SSC
lda #%00001011 ; no parity/echo/interrupts, RTS low, DTR low
sta COMMAND
lda #%10011110 ; 9600 baud, 8 data bits, 2 stop bits
sta CONTROL
;; Clock Commands
;; Set Time "ST HH:MM:SS:XM"
lda #HI('S')
jsr sendbyte
lda #HI('T')
jsr sendbyte
lda #HI(' ')
jsr sendbyte
ldx #0
loop: lda INPUT_BUFFER,x
jsr sendbyte
inx
cmp #HI(CR)
bne loop
rts
.endproc
;; Write byte in A to SSC
.proc sendbyte
pha
: lda STATUS
and #(1 << 4) ; transmit register empty? (bit 4)
beq :- ; nope, keep waiting
pla
sta TDREG
rts
.endproc
;;; ------------------------------------------------------------
;;; Output a high-ascii, null-terminated string.
;;; String immediately follows the JSR.
.proc zstrout
ptr := $A5
pla ; read address from stack
sta ptr
pla
sta ptr+1
bne skip ; always (since data not on ZP)
next: jsr COUT
skip: inc ptr
bne :+
inc ptr+1
: ldy #0
lda (ptr),y
bne next
lda ptr+1 ; restore address to stack
pha
lda ptr
pha
rts
.endproc
;;; ------------------------------------------------------------