Preparing for real implementation

This commit is contained in:
Seth Morabito committed 2014-08-15 12:48:54 -07:00
1 parent 70ab2a6fc2
commit ed1d5f999b
2 files changed
+49 -84

No files matched your search

+1 -1
View File
@@ -437,7 +437,7 @@ Ibuffs = IRQ_vec+$14
Ibuffe = Ibuffs+$47; end of input buffer Ibuffe = Ibuffs+$47; end of input buffer
Ram_base = $0300 ; start of user RAM (set as needed, should be page aligned) Ram_base = $0300 ; start of user RAM (set as needed, should be page aligned)
Ram_top = $A000 ; end of user RAM+1 (set as needed, should be page aligned) Ram_top = $7000 ; end of user RAM+1 (set as needed, should be page aligned)
; This start can be changed to suit your system ; This start can be changed to suit your system
+48 -83
View File
@@ -21,9 +21,11 @@ ACIAstatus = IO_AREA+1
ACIAcommand = IO_AREA+2 ACIAcommand = IO_AREA+2
ACIAcontrol = IO_AREA+3 ACIAcontrol = IO_AREA+3
CPOS_L = $E0 ; Cursor address (low) CADDR_L = $E0 ; Cursor address (low)
CPOS_H = $E1 ; Cursor address (high) CADDR_H = $E1 ; Cursor address (high)
COUTC = $E2 ; Temp storage for char out. C_COL = $E2 ; Cursor column
C_ROW = $E3 ; Cursor row
COUTC = $E4 ; Temp storage for char out.
; now the code. all this does is set up the vectors and interrupt code ; now the code. all this does is set up the vectors and interrupt code
@@ -42,10 +44,10 @@ RES_vec
;; Initialize the CRTC ;; Initialize the CRTC
LDA #$00 ; Set cursor start to $7000 LDA #$00 ; Set cursor start to $7000
STA CPOS_L STA CADDR_L
LDA #$70 LDA #$70
STA CPOS_H STA CADDR_H
;; TODO: Initialize params on CRTC
; Initialize the ACIA ; Initialize the ACIA
ACIA_init ACIA_init
@@ -112,85 +114,49 @@ CRTCout:
STA COUTC ; Store the character going out STA COUTC ; Store the character going out
JSR ACIAout ; Also echo to terminal for debugging. JSR ACIAout ; Also echo to terminal for debugging.
;; Is this a CR or LF? ;; In parallel, we're maintaining two states:
CMP #$0D ;; - The address of the cursor, and
BEQ @dolf ;; - The Column/Row of the cursor.
CMP #$0A ;;
BEQ @docr ;; The latter state is used to handle scrolling and
;; Is this a backspace? ;; for knowing how far to back up the cursor
;; for a carriage-return.
;; Backspace
CMP #$08 CMP #$08
BEQ @dobs BEQ DO_BS
;; Line Feed
;; Otherwise, this is a normal character CMP #$0a
;; Do normal character stuff. BEQ DO_BS
TYA ; Save Y ;; Carriage Return
PHA CMP #$0d
LDA COUTC ; Restore character going out BEQ DO_CR
LDY #$00 ;; Any other character
STA (CPOS_L),Y RTS
INC CPOS_L
PLA ; Restore Y DO_BS: RTS
TAY DO_LF: RTS
JMP @done DO_CR: RTS
;; Handle a scroll request
@dolf: DO_SCROLL:
;; Handle a LF RTS
;; Increment CRSR_R.
;; If CRSR_R > ROW_M, scroll.. ;; Decrement the cursor address
INC_CADDR:
INC CADDR_L
@docr: BNE @l1 ; Did we increment to 0?
;; Handle a CR INC CADDR_H ; Yes, also increment high
;; Set CRSR_C = 0. @l1 RTS
@dobs: ;; Increment the cursor address
;; 2. Is this a backspace? DEC_CADDR:
;; IF CRSR_C == 0 && CRSR_R == 0 CMP CADDR_L ; Is low alrady 0?
;; Do nothing, already home BNE @l1
;; If CRSR_C > 0 DEC CADDR_H ; Yes, decrement high
;; Set CRSR_C = CRSR_C - 1 @l1 DEC CADDR_L
;; Else
;; Set CRSR_C = COL_M
;; Set CRSR_R = CRSR_R - 1
;;
@done:
;; Now new cursor Column and Row have been calculated,
;; and we know if we need to scroll.
;;
;; (CPOS_H) = $70 + (row /
RTS RTS
;; Convert CRSR_C, CRSR_R into Cursor Address.
;; Result stored in CPOS_L,CPOS_H
;;
;; C_POS:
;; ;; Multiply CRSR_R * $28, store result in CPOS_L,CPOS_H
;; LDA CRSR_R ; Copy CRSR_R to CPOS_L
;; STA CPOS_L
;; LDA #$00
;; LDX #$08
;; LSR CPOS_L
;; @cpos1: BCC @cpos2
;; CLC
;; ADC #$28
;; @cpos2: ROR
;; ROR CPOS_L
;; DEX
;; BNE @cpos1
;; STA CPOS_H
;; ;; At this point, CPOS_L,CPOS_H holds the product
;; ;; of CRSR_R and $28. We need to add CRSR_C with
;; ;; an unsigned 16-bit add.
;; CLC
;; LDA CRSR_C
;; ADC CPOS_L
;; STA CPOS_L
;; BCC @noinc ; If carry wasn't set, no need
;; INC CPOS_H ; to increment CPOS_H
;; @noinc:
; ;
; byte in from ACIA. This subroutine will also force ; byte in from ACIA. This subroutine will also force
@@ -265,4 +231,3 @@ LAB_mess
.word NMI_vec ; NMI vector .word NMI_vec ; NMI vector
.word RES_vec ; RESET vector .word RES_vec ; RESET vector
.word IRQ_vec ; IRQ vector .word IRQ_vec ; IRQ vector