A2osX/DRV/CONSOLE.DRV.S.txt
2015-03-15 23:00:40 +01:00

333 lines
5.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.BUILD
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF DRV/CONSOLE.DRV
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/IO.I
*--------------------------------------
ZPBASL1 .EQ ZPDRV
ZPBASL2 .EQ ZPDRV+2
*--------------------------------------
* Main DRV entry point
* input :
* X = CMD
* 0 : OPEN
* 2 : GETEVENT
* 6 : OUT
* 8 : CLOSE
*--------------------------------------
* CLD $D8
* JMP (*,x) $7C
* #JMPTABLE
* /JMPTABLE
*--------------------------------------
CURSOR.BLINK.SPEED .EQ 2
*--------------------------------------
CS.START cld
jmp (.1,x)
.1 .DA OPEN
.DA GETEVENT
.DA OUT
.DA CLOSE
.DA GETINFO
.DA 0 end or relocation
.DA CS.END-CS.START Code Length To Relocate
.DA 0 Data Segemnt to Allocate
*--------------------------------------
OPEN stz CURON
lda #$80
sta INVFLG
jsr HOME
lda #S.DEV.F.CHAR+S.DEV.F.EVENT+S.DEV.F.OUT
sta (pDevContext)
ldy #S.DEV.NAME
ldx #0
.1 lda DEVNAME,x
sta (pDevContext),y
cpx DEVNAME
beq .8
inx
iny
bne .1
.8 lda A2osX.SCREENS
ora #A2osX.SCREENS.C
sta A2osX.SCREENS
clc
rts
*--------------------------------------
GETEVENT >PULLW pEvent
lda A2osX.TIMER16
and #CURSOR.BLINK.SPEED
eor CURON
beq .9
jsr CURBLNK
.9 lda #0 Error = no event
sec
rts
*--------------------------------------
OUT >PULLA
jsr COUT
clc
rts
*--------------------------------------
CLOSE lda A2osX.SCREENS
and #$FF^A2osX.SCREENS.C
sta A2osX.SCREENS
clc
rts
*--------------------------------------
GETINFO clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
COUT cmp #8
bne .2
ldx CH
beq .10
dec CH
bra .12
.10 ldy CV
bne .11
rts
.11 lda #79
sta CH
dec CV
.12 lda #$A0
ldx CH
ldy CV
jsr SetCharAtXY
rts
.2 cmp #13
beq CROUT
ldx CH
ldy CV
jsr SetCharAtXY
FSOUT ldx CH
cpx #79
beq CROUT1
inc CH
rts
*--------------------------------------
CROUT jsr CLREOL
CROUT1 stz CH
ldy CV
cpy #23
beq SCROLL.UP
inc CV
rts
SCROLL.UP ldx #0
sta SET80STORE
.1 lda BASEL,x
sta ZPBASL1
lda BASEH,x
sta ZPBASL1+1
inx
lda BASEL,x
sta ZPBASL2
lda BASEH,x
sta ZPBASL2+1
ldy #39
sta SETPAGE2
.2 lda (ZPBASL2),y
sta (ZPBASL1),y
dey
bpl .2
ldy #39
sta CLRPAGE2
.3 lda (ZPBASL2),y
sta (ZPBASL1),y
dey
bpl .3
cpx #23
bne .1
*--------------------------------------
CLREOL ldx CH
.1 phx
ldy CV
lda #$A0
jsr SetCharAtXY
plx
inx
cpx #80
bne .1
rts
*--------------------------------------
HOME stz CH
stz CV
lda RDPAGE2
pha
lda RD80STORE
pha
sta SET80STORE
ldx #23
.1 lda BASEL,x
sta ZPBASL1
lda BASEH,x
sta ZPBASL1+1
lda #' '
ora INVFLG
sta CLRPAGE2
ldy #39
.2 sta (ZPBASL1),y
dey
bpl .2
sta SETPAGE2
ldy #39
.3 sta (ZPBASL1),y
dey
bpl .3
dex
bpl .1
pla
bmi .4
sta CLR80STORE
bra .5
.4 sta SET80STORE
.5 pla
bmi .6
sta CLRPAGE2
bra .8
.6 sta SETPAGE2
.8 rts
*--------------------------------------
CUROFF lda CURON
beq CUREXIT.RTS
CURBLNK lda A2osX.ACTIVESCRN
and #A2osX.SCREENS.C
bne CURBLNK1
lda CURON
bne CURBLNK.OFF
rts do not Light if screen is not active
CURBLNK1 lda CURON
bne CURBLNK.OFF
ldx CH
ldy CV
jsr GetCharAtXY
sta CURCHAR
ldx CH
ldy CV
lda #$20
jsr SetCharAtXY
bra CUREXIT
CURBLNK.OFF ldx CH
ldy CV
lda CURCHAR
jsr SetCharAtXY
CUREXIT lda CURON
eor #CURSOR.BLINK.SPEED
sta CURON
CUREXIT.RTS rts
*--------------------------------------
SetCharAtXY pha
lda RDPAGE2
pha
lda RD80STORE
pha
sta SET80STORE
txa
lsr
bcc .1
clc
sta CLRPAGE2
bra .2
.1 sta SETPAGE2
.2 adc BASEL,y
sta ZPBASL1
lda BASEH,y
sta ZPBASL1+1
ply
plx
pla
sta (ZPBASL1)
tya
bmi .3
sta CLR80STORE
.3 txa
bpl .4
sta SETPAGE2
rts
.4 sta CLRPAGE2
rts
*--------------------------------------
GetCharAtXY sta SET80STORE
txa
lsr
bcc .1
clc
sta CLRPAGE2
bra .2
.1 sta SETPAGE2
.2 adc BASEL,y
sta ZPBASL1
lda BASEH,y
sta ZPBASL1+1
lda (ZPBASL1)
rts
*--------------------------------------
CS.END
DEVNAME >PSTRING "CON"
CH .BS 1
CV .BS 1
INVFLG .BS 1
CURON .BS 1
CURCHAR .BS 1
*--------------------------------------
BASEL .HS 00.80.00.80.00.80.00.80.28.A8.28.A8.28.A8.28.A8.50.D0.50.D0.50.D0.50.D0
BASEH .HS 04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07
*--------------------------------------
MAN
SAVE DRV/CONSOLE.DRV.S
ASM