Post by VDC 8x2 on Jul 21, 2014 6:56:42 GMT
Some code that was boiling around in my head.
An irq routine to copy vdc memory during an irq interupt. One copy is processed per irq interupt
Load your alternate stack with data like this: reg $1e,reg$22,reg$21, reg$13 and reg$12, in descending order. When you are ready for it to process the stack, put the alternate stack pointer number into stackptr.
The routine saves and restores a,x,y reg$12,reg$13,reg$18
The ready flag to a non zero value to tell the Irq, We busy with vdc leave us alone.
The irq will not do a copy if the vdc is busy or if our custom stack pointer says $ff. $ff means there is no work for it to do.
The routine clobbers vdc reg $21 and $22. Since it will be controlling copy, makes sense to let it do so.
What Do you think of the idea?
An irq routine to copy vdc memory during an irq interupt. One copy is processed per irq interupt
Load your alternate stack with data like this: reg $1e,reg$22,reg$21, reg$13 and reg$12, in descending order. When you are ready for it to process the stack, put the alternate stack pointer number into stackptr.
The routine saves and restores a,x,y reg$12,reg$13,reg$18
The ready flag to a non zero value to tell the Irq, We busy with vdc leave us alone.
The irq will not do a copy if the vdc is busy or if our custom stack pointer says $ff. $ff means there is no work for it to do.
The routine clobbers vdc reg $21 and $22. Since it will be controlling copy, makes sense to let it do so.
;job que vdc copy
vdcadr = $d600
vdcdat = $d601
ready = $fd
IrqVec = $0314
custack = $0b
stackptr = $fe
MmuStack = $d509
defm vdcwait
bit $d600
bpl *-3
endm
defm popadr
pla ;get high byte
tax ;save in x
pla ;get low byte
endm
defm swapstack
tsx
txa
ldx /1
txs
sta /1
lda #/2
sta $d509
endm
*=$1300
install lda #>IRQVEC
cmp #>irq
beq @end ;we already install exit
lda #<irqvec
cmp #<irq
beq @end ;same value so abort install
sei
lda #<irqvec ;copy vector to irqjump
sta irqjump+1
lda #>irqvec
sta irqjump+2
lda #<irq
sta irqvec
lda #>irq
sta irqvec+1
cli
@end rts
irq pha
txa
pha
tya
pha ;saved a,x,y
lda ready
beq *+5
jmp cleanup ;program using vdc so leave
ldx stackptr
inx
bne *+5
jmp cleanup ;nothing on custom stack so leave
bit vdcadr
bmi *+5
jmp cleanup ;vdc is busy so leave
ldx #$13
stx vdcadr
lda vdcdat
pha ;store reg13
dex
stx vdcadr
vdcwait
lda vdcdat
pha ;store reg12
lda #$18
sta vdcadr
lda vdcdat
pha ;store reg18
ora $80 ;turn on copy
sta vdcadr
swapstack stackptr, custack
popadr
ldy #$12
sty vdcadr
VDCWAIT
stx vdcdat
iny
sty vdcadr
sta vdcdat
popadr
ldy #$20
sty vdcadr
stx vdcdat
iny
sty vdcadr
sta vdcdat
lda #$1e
sta vdcadr
pla ;get bytes to copy
vdcwait
sta vdcadr ;start copy
swapstack stackptr, $01
vdcwait ;with for copy to be done
lda #$18
sta vdcadr
pla ;restor copy flag
sta vdcdat
pla ;get hi byte dest
tax ;save in x
pla ;get low bye
ldy #$12
sty vdcadr
vdcwait
stx vdcdat
iny
sty vdcadr
sta vdcdat ;restored write address regs
cleanup pla
tay
pla
tax
pla
irqjump jmp $fffe
What Do you think of the idea?