Lokalhorst!!! Can you please help me??

Started by stiggity, July 31, 2010, 07:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

stiggity

Lokalhorst:
I wrote a nice little clock and date routine, and its Y2K compliant, and i would like to wedge it into the main IRQ @ $314/$315. I have done so, but the IRQ routine i wrote is messing up the VDC screen, and is useless, as it usually prints tons of random characters all over the place, and hangs... BigDumbDinosaur is starting to make me feel.... just that. He is trying to help, but not in the fasion im used too. What exactly do i have to do to get my time&date routine to work well, while its running on the IRQ.. if you look at my post "swap out basic" u can follow the thread, but BDD's last post, i dont know if it  was for real, or was he trying to make me feel stupid. I want my time&date routine to be able to work with a "window" command (which basically draws the top "sysop" window). Any help will be greatly appreciated thanks..

Regards,
-Steve

LokalHorst

#1
Ugh, whats up here? - been away only shortly.

looking for a working example ?
The key is to save those VDC-registers which are modified due to the custom code, at the beginning, and restore them on exiting. It's not req. to blank-out the full editor rom-range (c400 - ce00) which includes many routines that doesn't touch the VDC. The stack-sniffing part is limited to page $CDxx and only required if the screen-update is part of the IRQ-handler.
Caution - the following code is spiced with 'magic-numbers' ;) straight from the build-in ML-Monitor

*= $1300 ;

stack = $0100

WRITE80 = $cdca
WRITE_Reg = $cdcc
READ80 = $cdd8
READ_Reg = $cdda

cia1tenth = $dc08
cia1sec = $dc09
cia1min = $dc0a
cia1hour = $dc0b

SYSIRQ = $fa65 ;default IRQ-handler

IRQentry: ;from vec. $0314/15
cld ;important - the interrupted prog might have used decimal-mode

jsr ReadTime ;read to buffer ~0.5sec interval

tsx
lda stack +7,x ;get interrupted prog loc. Hi byte
eor #$cd
beq continue ;skip vdc access if in range $CDxx

usrsub:   ;anything that modifies VDC-registers goes here
jsr DispUpd ;upd. VDC display
continue:
;insert additional jsr that don't mess with the VDC here

jmp SYSIRQ ;to std. IRQ handler

ReadTime:
lda cia1tenth
and #$04
smod:
cmp #$00 ;upd. time buffer ?
bne updtime
lda #$2c ;op-code bit
sta usrsub ;disable DispUpd -> no new data (yet)
rts

updtime:
sta smod +1
lda #$20  ;op-code jsr
sta usrsub ;enable DispUpd

ldy #$00
lda cia1hour
and #$1f
cmp #$12
bne chk_pm
lda #$00 ;noon or midnight
chk_pm:
bit cia1hour
bpl no_change
clc
sed
adc #$12
cld
no_change:
jsr bcd2asc
iny  ;skip separator
lda cia1min
jsr bcd2asc
iny
lda cia1sec
bit cia1tenth ;un-latch clock

;sub bcd to ascii decode
bcd2asc:
pha
lsr a
lsr a
lsr a
lsr a
ora #$30
sta TimeBuf,y
iny
pla
and #$0f
ora #$30
sta TimeBuf,y
iny
rts

DisplUpd:
;save upd pointer -1 & last written data
ldx #$13 ;vdc-reg. 19 (update lo)
jsr READ_Reg
sec
sbc #$01
sta VupdSavL
jsr WRITE_Reg
dex   ;vdc-reg. 18 (update hi)
jsr READ_Reg
sbc #$00
sta VupdSavH
jsr WRITE_Reg
jsr READ80  ;read back last written data (reg 31)
sta VdtaSav

;now the clock display
ldx #$13  ;set upd location to $0048 (top-right corner -8)
lda #$48
jsr WRITE_Reg
dex
lda #$00
jsr WRITE_Reg

ldy #$00  ;output buffered time string
outloop:
lda TimeBuf,y
jsr WRITE80
iny
cpy #$08
bcc outloop

;restoring the registers used, before exiting
ldx #$13
lda VupdSavL
jsr WRITE_Reg
dex
lda VupdSavH
jsr WRITE_Reg
lda VdtaSav
jmp WRITE80

;Time string
TimeBuf .byte '00:00:00'
;saved VDC register values goin' here
VupdSavL .byte $00
VupdSavH .byte $00
VdtaSav .byte $00