Converging on a useful CRTC ROM
This commit is contained in:
1 parent
cad3673bd2
commit
142cb470a0
1 file changed
+122
-65
@@ -28,9 +28,10 @@ ACIAcontrol = IO_AREA+3
|
|||||||
C_COL = $E2 ; Cursor column
|
C_COL = $E2 ; Cursor column
|
||||||
C_ROW = $E3 ; Cursor row
|
C_ROW = $E3 ; Cursor row
|
||||||
COUTC = $E4 ; Temp storage for char out.
|
COUTC = $E4 ; Temp storage for char out.
|
||||||
TMPY = $E5
|
R_STRT = $E5 ; E5,E6 contains starting address of
|
||||||
R_STRT = $E6 ; E6,E7 contains starting address of
|
|
||||||
; current row
|
; current row
|
||||||
|
R_NXT = $E7 ; E7,E8 contains starting address of
|
||||||
|
; next row
|
||||||
|
|
||||||
N_ROWS = 24
|
N_ROWS = 24
|
||||||
N_COLS = 40
|
N_COLS = 40
|
||||||
@@ -59,6 +60,12 @@ RES_vec:
|
|||||||
STA CRTC_A
|
STA CRTC_A
|
||||||
LDA #N_ROWS ; 24 rows
|
LDA #N_ROWS ; 24 rows
|
||||||
STA CRTC_C
|
STA CRTC_C
|
||||||
|
LDA #$70
|
||||||
|
STA CADDR_H
|
||||||
|
LDA #$00
|
||||||
|
STA CADDR_L
|
||||||
|
STA C_ROW
|
||||||
|
STA C_COL
|
||||||
JSR CLRVID
|
JSR CLRVID
|
||||||
;; TODO: Initialize params on CRTC
|
;; TODO: Initialize params on CRTC
|
||||||
|
|
||||||
@@ -144,10 +151,19 @@ CRTCout:
|
|||||||
CMP #$0d
|
CMP #$0d
|
||||||
BEQ DO_CR
|
BEQ DO_CR
|
||||||
;; Any other character...
|
;; Any other character...
|
||||||
CMP #'a'
|
|
||||||
STA COUTC ; Store the character going out
|
STA COUTC ; Store the character going out
|
||||||
JSR COUT1
|
JSR COUT1 ; Output it where the cursor is.
|
||||||
JSR INC_CADDR
|
;; We might need to scroll...
|
||||||
|
LDA C_ROW
|
||||||
|
CMP #N_ROWS-1
|
||||||
|
BNE @noscr
|
||||||
|
LDA C_COL
|
||||||
|
CMP #N_COLS-1
|
||||||
|
BNE @noscr
|
||||||
|
;; ... yup, we DO need to scroll.
|
||||||
|
JSR DO_SCROLL
|
||||||
|
RTS
|
||||||
|
@noscr: JSR INC_CADDR
|
||||||
INC C_COL
|
INC C_COL
|
||||||
JSR SET_CURSOR
|
JSR SET_CURSOR
|
||||||
RTS
|
RTS
|
||||||
@@ -183,8 +199,9 @@ DO_CR: SEC
|
|||||||
CMP #N_ROWS-1
|
CMP #N_ROWS-1
|
||||||
BNE @inc
|
BNE @inc
|
||||||
JSR DO_SCROLL
|
JSR DO_SCROLL
|
||||||
JMP @lf
|
RTS
|
||||||
@inc: INC C_ROW
|
|
||||||
|
@inc: JSR INCROW
|
||||||
|
|
||||||
@lf: CLC
|
@lf: CLC
|
||||||
LDA CADDR_L
|
LDA CADDR_L
|
||||||
@@ -193,10 +210,10 @@ DO_CR: SEC
|
|||||||
LDA CADDR_H
|
LDA CADDR_H
|
||||||
ADC #$00 ; Will increment if carry was set
|
ADC #$00 ; Will increment if carry was set
|
||||||
STA CADDR_H
|
STA CADDR_H
|
||||||
|
|
||||||
LDA #$00 ; Reset cursor row to 0
|
LDA #$00 ; Reset cursor row to 0
|
||||||
STA C_COL
|
STA C_COL
|
||||||
JSR SET_CURSOR
|
JSR SET_CURSOR
|
||||||
;; Move the cursor
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
SET_CURSOR:
|
SET_CURSOR:
|
||||||
@@ -210,74 +227,112 @@ SET_CURSOR:
|
|||||||
STA CRTC_C
|
STA CRTC_C
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
;; Increment C_ROW and put new
|
||||||
|
;; line start address in R_STRT,R_STRT+1
|
||||||
|
INCROW: TYA
|
||||||
|
PHA
|
||||||
|
INC C_ROW
|
||||||
|
BNE DECR2 ; Share code with DECROW
|
||||||
|
|
||||||
|
;; Decrement C_ROW and put new
|
||||||
|
;; line start address in R_STRT,R_STRT+1
|
||||||
|
DECROW: TYA
|
||||||
|
PHA
|
||||||
|
DEC C_ROW
|
||||||
|
DECR2: JSR SETRSTRT
|
||||||
|
PLA
|
||||||
|
TAY
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;; Send the cursor home to the start of the line
|
||||||
|
HOME:
|
||||||
|
LDY C_ROW
|
||||||
|
LDA CRA_LO,Y
|
||||||
|
STA CADDR_L
|
||||||
|
LDA CRA_HI,Y
|
||||||
|
STA CADDR_H
|
||||||
|
LDA #$00
|
||||||
|
STA C_COL
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;; Set the start address of the current row
|
||||||
|
SETRSTRT:
|
||||||
|
LDY C_ROW
|
||||||
|
LDA CRA_LO,Y
|
||||||
|
STA R_STRT
|
||||||
|
LDA CRA_HI,Y
|
||||||
|
STA R_STRT+1
|
||||||
|
RTS
|
||||||
|
|
||||||
|
;; Clear the current video line
|
||||||
|
CLRLN: LDA #$20
|
||||||
|
LDY #$00
|
||||||
|
@l1: STA (R_STRT),Y
|
||||||
|
INY
|
||||||
|
CPY #N_COLS
|
||||||
|
BNE @l1
|
||||||
|
RTS
|
||||||
|
|
||||||
;; Clear the video window and put the cursor at the home
|
;; Clear the video window and put the cursor at the home
|
||||||
;; position
|
;; position
|
||||||
CLRVID:
|
CLRVID:
|
||||||
LDA #$70
|
LDA #$20
|
||||||
STA CADDR_H
|
LDX #N_ROWS-1
|
||||||
LDA #$00 ; Set cursor start to $7000
|
@l1: STX C_ROW
|
||||||
STA CADDR_L
|
JSR SETRSTRT
|
||||||
STA C_ROW
|
JSR CLRLN
|
||||||
STA C_COL
|
DEX
|
||||||
JSR SET_CURSOR
|
BPL @l1
|
||||||
;; Fill with space character
|
|
||||||
STY TMPY
|
|
||||||
LDA #$20 ; Space
|
|
||||||
LDY #$00
|
|
||||||
@l1: STA $7000,Y
|
|
||||||
INY
|
|
||||||
BNE @l1
|
|
||||||
@l2: STA $7100,Y
|
|
||||||
INY
|
|
||||||
BNE @l2
|
|
||||||
@l3: STA $7200,Y
|
|
||||||
INY
|
|
||||||
BNE @l3
|
|
||||||
@l4: STA $7300,Y
|
|
||||||
INY
|
|
||||||
BNE @l4
|
|
||||||
@l5: STA $7400,Y
|
|
||||||
INY
|
|
||||||
BNE @l5
|
|
||||||
LDY TMPY
|
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;; Handle a scroll request
|
;; Handle a scroll request.
|
||||||
|
;;
|
||||||
|
;; The cursor could be anywhere on the line when this scroll
|
||||||
|
;; request comes in.
|
||||||
DO_SCROLL:
|
DO_SCROLL:
|
||||||
;; Copy $7028 through $70FF to $7000 through $70D7
|
PHA
|
||||||
STY TMPY ; Save Y
|
TYA
|
||||||
LDY #$00
|
PHA
|
||||||
@l1: LDA $7028,Y
|
TXA
|
||||||
STA $7000,Y
|
PHA
|
||||||
INY
|
|
||||||
BNE @l1
|
|
||||||
|
|
||||||
@l2: LDA $7128,Y
|
;; The idea here is to copy each line to the line above it
|
||||||
STA $7100,Y
|
LDX #$00
|
||||||
|
|
||||||
|
@l1: LDA CRA_LO,X
|
||||||
|
STA R_STRT
|
||||||
|
LDA CRA_HI,X
|
||||||
|
STA R_STRT+1
|
||||||
|
|
||||||
|
INX
|
||||||
|
|
||||||
|
LDA CRA_LO,X
|
||||||
|
STA R_NXT
|
||||||
|
LDA CRA_HI,X
|
||||||
|
STA R_NXT+1
|
||||||
|
|
||||||
|
LDY #0
|
||||||
|
@l2: LDA (R_NXT),Y
|
||||||
|
STA (R_STRT),Y
|
||||||
INY
|
INY
|
||||||
|
CPY #N_COLS
|
||||||
BNE @l2
|
BNE @l2
|
||||||
|
|
||||||
@l3: LDA $7228,Y
|
CPX #N_ROWS
|
||||||
STA $7200,Y
|
BNE @l1
|
||||||
INY
|
|
||||||
BNE @l3
|
|
||||||
|
|
||||||
@l4: LDA $7328,Y
|
;; Clear the line the cursor occupies.
|
||||||
STA $7300,Y
|
JSR CLRLN
|
||||||
INY
|
|
||||||
BNE @l4
|
|
||||||
|
|
||||||
|
;; Move the cursor to the beginning of the line
|
||||||
|
JSR HOME
|
||||||
|
JSR SET_CURSOR
|
||||||
|
|
||||||
;; Now subtract 28 from C_ADDR
|
PLA
|
||||||
SEC
|
TAX
|
||||||
LDA CADDR_L
|
PLA
|
||||||
SBC #$28
|
TAY ; Restore Y
|
||||||
STA CADDR_L
|
PLA
|
||||||
LDA CADDR_H
|
|
||||||
SBC #$00
|
|
||||||
STA CADDR_H
|
|
||||||
LDY TMPY ; Restore Y
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;; Decrement the cursor address
|
;; Decrement the cursor address
|
||||||
@@ -296,11 +351,13 @@ DEC_CADDR:
|
|||||||
RTS
|
RTS
|
||||||
|
|
||||||
COUT1:
|
COUT1:
|
||||||
STY TMPY
|
TYA
|
||||||
|
PHA ; Save Y
|
||||||
LDY #$00
|
LDY #$00
|
||||||
LDA COUTC
|
LDA COUTC
|
||||||
STA (CADDR_L),Y
|
STA (CADDR_L),Y
|
||||||
LDY TMPY
|
PLA
|
||||||
|
TAY ; Restore Y
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|||||||
Reference in new issue
Block a user