Scrolling is now a 16 bit integer.

This commit is contained in:
Rob Greene 2016-01-31 16:11:23 -06:00
parent b21be649e0
commit d22bcd1e5a

View File

@ -66,9 +66,9 @@ DATA DA 0 ; data buffer
_init da 0 ; current page init _init da 0 ; current page init
_display da 0 ; current page line display handler _display da 0 ; current page line display handler
_keypress da 0 ; current page keypress handler _keypress da 0 ; current page keypress handler
curline dfb 0 ; current first line topline dw 0 ; current line at top of page
endline dfb 0 ; end of page = min(curline+20,maxlines) maxlines dw 0 ; maximum number of lines availalable
maxlines dfb 0 ; maximum number of lines availalable printline dw 0 ; line being printed
DEND DEND
inbuf = $200 ; reusable buffer inbuf = $200 ; reusable buffer
@ -77,6 +77,8 @@ DATASTART = $4000
DATAEND = $6000 DATAEND = $6000
DATALEN = DATAEND-DATASTART DATALEN = DATAEND-DATASTART
PAGELEN = 20 ; number of lines displayed in content window
* High ASCII constants * High ASCII constants
CTRLH = "H"-$40 CTRLH = "H"-$40
@ -155,40 +157,42 @@ SetupPage
dfb $00 dfb $00
ldx #_init ; vector offset ldx #_init ; vector offset
jsr _VCALL jsr _VCALL
sta maxlines sty maxlines
stz curline sta maxlines+1
stz topline
stz topline+1
DrawPage DrawPage
jsr PRINT ; Clear and then draw the content area jsr PRINT ; Clear and then draw the content area
dfb _HOME,$8d,$8d,0 dfb _HOME,$8d,$8d,0
lda #0
:loop pha
clc clc
lda curline adc topline
adc #20 sta printline
sta endline lda topline+1
adc #0
sta printline+1
cmp maxlines+1
blt :drwlin
lda printline
cmp maxlines cmp maxlines
bcc :start bge :erase
lda maxlines ; maxlines < endline, use maxlines
sta endline :drwlin lda printline+1
ldy printline
:start lda curline ldx #_display
:next pha
ldx #_display ; vector offset
jsr _VCALL jsr _VCALL
pla bra :incr
inc
cmp endline :erase jsr PRINT
bcc :next
; Clear rest of screen
:wipe cmp #20
bcs KeyboardWait
pha
jsr PRINT
dfb _CLREOL,$8D,0 dfb _CLREOL,$8D,0
pla
:incr pla
inc inc
bne :wipe cmp #PAGELEN
blt :loop
KeyboardWait KeyboardWait
lda KEYBOARD lda KEYBOARD
@ -244,20 +248,53 @@ KeyboardWait
jmp DrawPage jmp DrawPage
; "Local" subroutines ; "Local" subroutines
:down1 lda curline
inc ; if topline+PAGELEN >= maxlines then return
sta curline ; topline = topline + 1
clc :down1 clc
adc #20 lda topline
adc #PAGELEN
sta printline
lda printline+1
adc #0
sta printline+1
cmp maxlines+1
bcc :minus1
lda printline
cmp maxlines cmp maxlines
bcc :rts bge :rts
; went too far :minus1 inc topline
:up1 lda curline bne :rts
dec inc topline+1
bmi :rts rts
sta curline ; if topline = 0 then return
; topline = topline - 1
:up1 lda topline
ora topline+1
beq :rts ; already = 0
sec
lda topline
sbc #1
sta topline
lda topline+1
sbc #0
sta topline+1
:rts rts :rts rts
;:down1 lda curline
; inc
; sta curline
; clc
; adc #20
; cmp maxlines
; bcc :rts
; ; went too far
;:up1 lda curline
; dec
; bmi :rts
; sta curline
;:rts rts
:pgKey ldx #_keypress :pgKey ldx #_keypress
; Fall through and JMP to _keypress which takes control for local page keys ; Fall through and JMP to _keypress which takes control for local page keys
@ -292,9 +329,20 @@ SetScreen
clc clc
rts rts
*
* Data per page: Apple ASCII, Initialization, Display, Keypress (7 bytes) * Data per page: Apple ASCII, Initialization, Display, Keypress (7 bytes)
* Note: Initialization should also display 24th line for the page. *
* Cursor is there and line is clear. * Definitions:
* - BYTE = Character to match on, case insensitive
* - ADDR = Initialize routine. Returns with A:Y for number of lines.
* Note: Initialization should also display 24th line for the page.
* (Cursor is there and line is clear.)
* - ADDR = Display routine. Called with A:Y for line number. Should end with $8D and is
* responsible for clearing the line.
* - ADDR = Keypress handler. NOT A SUBROUTINE. This routine has a number of entry
* points it might call. KeyboardWait for another keypress or SetupPage to
* reinitialize and redraw.
*
:data :data
dfb "A" dfb "A"
da AboutInit, AboutDisplay, AboutKeypress da AboutInit, AboutDisplay, AboutKeypress
@ -302,6 +350,8 @@ SetScreen
da FieldInit, FieldDisplay, FieldKeypress da FieldInit, FieldDisplay, FieldKeypress
dfb "B" dfb "B"
da BrowseInit, BrowseDisplay, BrowseKeypress da BrowseInit, BrowseDisplay, BrowseKeypress
dfb "T"
da TestInit, TestDisplay, TestKeypress
dfb 0 ; end dfb 0 ; end
* *
@ -309,7 +359,7 @@ SetScreen
* *
* Build array of line pointers in INBUF. * Build array of line pointers in INBUF.
AboutInit ; Returns with Acc = max lines AboutInit ; Returns with A:Y = max lines
jsr PRINT jsr PRINT
asc _INVERSE,_MT_ON,_U_ARROW,_D_ARROW,_MT_OFF,_NORMAL," Scroll / " asc _INVERSE,_MT_ON,_U_ARROW,_D_ARROW,_MT_OFF,_NORMAL," Scroll / "
asc _INVERSE,_MT_ON,_O_APPLE,_NORMAL,"-",_INVERSE,_U_ARROW,_D_ARROW,_MT_OFF,_NORMAL," Page" asc _INVERSE,_MT_ON,_O_APPLE,_NORMAL,"-",_INVERSE,_U_ARROW,_D_ARROW,_MT_OFF,_NORMAL," Page"
@ -319,20 +369,20 @@ AboutInit ; Returns with Acc = max lines
sta PTR sta PTR
lda #>:lines lda #>:lines
sta PTR+1 sta PTR+1
ldx #0 ; max lines ldy #0 ; max lines
ldy #0 ; buffer offset ldx #0 ; buffer offset
:save lda PTR :save lda PTR
sta inbuf,y sta inbuf,x
lda PTR+1
iny
sta inbuf,y
iny
inx inx
lda PTR+1
sta inbuf,x
inx
iny
:loop lda (PTR) :loop lda (PTR)
bne :incr bne :incr
txa lda #0 ; high byte of max lines; Y = low byte
rts rts
:incr lda (PTR) :incr lda (PTR)
@ -409,8 +459,8 @@ AboutInit ; Returns with Acc = max lines
asc "-END-",$00 asc "-END-",$00
dfb 0 dfb 0
AboutDisplay ; Called with Acc = line AboutDisplay ; Called with A:Y = line
pha phy ; assuming < 256 lines
lda #_CLREOL lda #_CLREOL
jsr COUT jsr COUT
pla pla
@ -430,7 +480,7 @@ AboutKeypress ; Called with Acc = key
* FIELD Interface * FIELD Interface
* *
FieldInit ; Returns with Acc = max lines FieldInit ; Returns with A:Y = max lines
jsr PRINT jsr PRINT
asc _INVERSE,_MT_ON,_U_ARROW,_D_ARROW,_MT_OFF,_NORMAL," Scroll / " asc _INVERSE,_MT_ON,_U_ARROW,_D_ARROW,_MT_OFF,_NORMAL," Scroll / "
asc _INVERSE,_MT_ON,_O_APPLE,_NORMAL,"-",_INVERSE,_U_ARROW,_D_ARROW,_MT_OFF,_NORMAL," Page / " asc _INVERSE,_MT_ON,_O_APPLE,_NORMAL,"-",_INVERSE,_U_ARROW,_D_ARROW,_MT_OFF,_NORMAL," Page / "
@ -467,9 +517,12 @@ FieldInit ; Returns with Acc = max lines
; Calculate # of lines ; Calculate # of lines
txa txa
lsr lsr
tay
lda #0 ; Assumed < 256 lines
rts rts
FieldDisplay ; Called with Acc = line FieldDisplay ; Called with A:Y = line
tya ; Assuming < 256 lines
asl asl
tay tay
lda inbuf,y lda inbuf,y
@ -593,14 +646,14 @@ BrowseInit ; Returns with Acc = max lines
dec TEMP dec TEMP
bne :scan bne :scan
; The number of lines is based on how many bytes we show on screen ; The number of lines is based on how many bytes we show on screen
; HOWEVER, we are limited to 255 lines, so we actually skip the last 32 bytes lda #1 ; A:Y = $100 or 256 lines
lda #$ff ldy #0
rts rts
BrowseDisplay ; Called with Acc = line BrowseDisplay ; Called with Acc = line
; Calculate buffer address ; Calculate buffer address
sta DATA sta DATA+1
stz DATA+1 sty DATA
ldy #5 ; times 32 ldy #5 ; times 32
:mult32 asl DATA :mult32 asl DATA
rol DATA+1 rol DATA+1
@ -647,6 +700,30 @@ BrowseKeypress ; Called with Acc = key
jmp FieldKeypress ; identical to Field ... for now at least jmp FieldKeypress ; identical to Field ... for now at least
*
* TEST interface
*
TestInit
lda #>535
ldy #<535 ; Nice odd number of lines > 256
rts
TestDisplay
phy
pha
lda #_CLREOL
jsr COUT
pla
jsr PRHEX
pla
jsr PRHEX
jmp PRCR
TestKeypress
jmp KeyboardWait
* *
* DISK II routines * DISK II routines
* *