gr: split off scroll text

This commit is contained in:
Vince Weaver 2021-01-06 10:35:17 -05:00
parent 0d8e4d7d6c
commit f9d6554425
15 changed files with 806 additions and 17 deletions

View File

@ -5,21 +5,19 @@ PNG2GR = ../../../utils/gr-utils/png2gr
PNG2RLE = ../../../utils/gr-utils/png2rle
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
all: mode7.dsk scroller background
all: mode7.dsk background
$(DOS33):
cd ../../../utils/dos33fs-utils && make
mode7.dsk: $(DOS33) MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
PLOT_TEST RASTERBARS SCROLL_DEMO SKY_DEMO \
PLOT_TEST RASTERBARS SKY_DEMO \
STARFIELD_DEMO STARFIELD_1K TEXT_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_ISLAND
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_CHECKERBOARD
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_RAINBOW
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 PLOT_TEST
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 RASTERBARS
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 SCROLL_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 SKY_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 STARFIELD_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 STARFIELD_1K
@ -83,18 +81,6 @@ plot_test.o: plot_test.s \
gr_setpage.s
ca65 -o plot_test.o plot_test.s -l plot_test.lst
SCROLL_DEMO: scroll_demo.o
ld65 -o SCROLL_DEMO scroll_demo.o -C ./apple2_1000.inc
scroll_demo.o: scroll_demo.s \
deater_scroll.inc \
gr_hlin.s \
gr_fast_clear.s \
gr_scroll.s \
pageflip.s \
gr_setpage.s
ca65 -o scroll_demo.o scroll_demo.s -l scroll_demo.lst
SKY_DEMO: sky_demo.o
ld65 -o SKY_DEMO sky_demo.o -C ./apple2_1000.inc
@ -165,6 +151,6 @@ background.o: background.c
clean:
rm -f *~ *.o scroller background \
MODE7 MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
PLOT_TEST RASTERBARS SCROLL_DEMO STARFIELD_DEMO STARFIELD_1K \
PLOT_TEST RASTERBARS STARFIELD_DEMO STARFIELD_1K \
SKY_DEMO TEXT_DEMO *.lst

View File

@ -0,0 +1,50 @@
include ../../../Makefile.inc
DOS33 = ../../../utils/dos33fs-utils/dos33
PNG2GR = ../../../utils/gr-utils/png2gr
PNG2RLE = ../../../utils/gr-utils/png2rle
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
all: scroll_text.dsk scroller
$(DOS33):
cd ../../../utils/dos33fs-utils && make
scroll_text.dsk: $(DOS33) HELLO SCROLL_DEMO
cp empty.dsk scroll_text.dsk
$(DOS33) -y scroll_text.dsk SAVE A HELLO
$(DOS33) -y scroll_text.dsk BSAVE -a 0x1000 SCROLL_DEMO
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
SCROLL_DEMO: scroll_demo.o
ld65 -o SCROLL_DEMO scroll_demo.o -C ../../../linker_scripts/apple2_1000.inc
scroll_demo.o: scroll_demo.s \
deater_scroll.inc \
gr_hlin.s \
gr_fast_clear.s \
gr_scroll.s \
pageflip.s \
gr_setpage.s
ca65 -o scroll_demo.o scroll_demo.s -l scroll_demo.lst
###
scroller: scroller.o
$(CC) $(LFLAGS) -o scroller scroller.o
scroller.o: scroller.c
$(CC) $(CFLAGS) -c scroller.c
###
clean:
rm -f *~ *.o scroller background SCROLL_DEMO *.lst

View File

@ -0,0 +1,4 @@
routine for generating/testing lo-res scroll test
used in the mode7_demo

Binary file not shown.

View File

@ -0,0 +1,193 @@
clear_screens:
;===================================
; Clear top/bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_top
jsr clear_bottom
;===================================
; Clear top/bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_top
jsr clear_bottom
rts
clear_bottoms:
;===================================
; Clear bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_bottom
;===================================
; Clear bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_bottom
rts
;=========================================================
; clear_top
;=========================================================
; clear DRAW_PAGE
; original = 14,558 cycles(?) 15ms, 70Hz
; OPTIMIZED MAX (page0,48rows): 45*120+4+6 = 5410 = 5.4ms 185Hz
; (pageX,40rows): 50*120+4+6 = 6010 = 6.0ms 166Hz
; 50*120+4+6+37 = 6055 = 6.0ms 166Hz
clear_top:
lda #0 ; 2
clear_top_a:
sta COLOR ; 3
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __ctf+2 ; 3
sta __ctf+5 ; 3
adc #1 ; 2
sta __ctf+8 ; 3
sta __ctf+11 ; 3
adc #1 ; 2
sta __ctf2+2 ; 3
sta __ctf2+5 ; 3
adc #1 ; 2
sta __ctf2+8 ; 3
sta __ctf2+11 ; 3
ldy #120 ; 2
lda COLOR ; 3
clear_top_fast_loop:
__ctf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
cpy #80 ; 2
bpl no_draw_bottom ; 2nt/3
__ctf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
no_draw_bottom:
dey ; 2
bpl clear_top_fast_loop ; 2nt/3
rts ; 6
;=========================================================
; clear_bottom
;=========================================================
; clear bottom of draw page
clear_bottom:
clc ; 2
lda DRAW_PAGE ; 3
adc #6 ; 2
sta __cbf2+2 ; 3
sta __cbf2+5 ; 3
adc #1 ; 2
sta __cbf2+8 ; 3
sta __cbf2+11 ; 3
ldy #120 ; 2
lda #$a0 ; Normal Space ; 2
clear_bottom_fast_loop:
__cbf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
cpy #80 ; 2
bpl clear_bottom_fast_loop ; 2nt/3
rts ; 6
clear_screens_notext:
;===================================
; Clear top/bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_all
;===================================
; Clear top/bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_all
rts
;=========================================================
; clear_all
;=========================================================
; clear 48 rows
; clear color: clear_all_color+1
clear_all:
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __caf+2 ; 3
sta __caf+5 ; 3
adc #1 ; 2
sta __caf+8 ; 3
sta __caf+11 ; 3
adc #1 ; 2
sta __caf2+2 ; 3
sta __caf2+5 ; 3
adc #1 ; 2
sta __caf2+8 ; 3
sta __caf2+11 ; 3
ldy #120 ; 2
clear_all_color:
lda #0 ; 2
clear_all_fast_loop:
__caf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
__caf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
bpl clear_all_fast_loop ; 2nt/3
rts ; 6

View File

@ -0,0 +1,124 @@
;=====================================================================
;= ROUTINES
;=====================================================================
;================================
; hlin_setup
;================================
; put address in GBASL/GBASH
; Ycoord in A, Xcoord in Y
hlin_setup:
sty TEMPY ; 3
tay ; y=A ; 2
lda gr_offsets,Y ; lookup low-res memory address ; 4
clc ; 2
adc TEMPY ; 3
sta GBASL ; 3
iny ; 2
lda gr_offsets,Y ; 4
adc DRAW_PAGE ; add in draw page offset ; 3
sta GBASH ; 3
rts ; 6
;===========
; 35
;================================
; hlin_double:
;================================
; HLIN Y, V2 AT A
; Y, X, A trashed
; start at Y, draw up to and including X
hlin_double:
;int hlin_double(int page, int x1, int x2, int at) {
jsr hlin_setup ; 41
sec ; 2
lda V2 ; 3
sbc TEMPY ; 3
tax ; 2
inx ; 2
;===========
; 53
; fallthrough
;=================================
; hlin_double_continue: width
;=================================
; GBASL has correct offset for row/col
; width in X
hlin_double_continue:
ldy #0 ; 2
lda COLOR ; 3
hlin_double_loop:
sta (GBASL),Y ; 6
inc GBASL ; 5
dex ; 2
bne hlin_double_loop ; 2nt/3
rts ; 6
;=============
; 53+5+X*16+5
;================================
; hlin_single:
;================================
; HLIN Y, V2 AT A
; Y, X, A trashed
hlin_single:
jsr hlin_setup
sec
lda V2
sbc TEMPY
tax
; fallthrough
;=================================
; hlin_single_continue: width
;=================================
; width in X
hlin_single_continue:
hlin_single_top:
lda COLOR
and #$f0
sta COLOR
hlin_single_top_loop:
ldy #0
lda (GBASL),Y
and #$0f
ora COLOR
sta (GBASL),Y
inc GBASL
dex
bne hlin_single_top_loop
rts
hlin_single_bottom:
lda COLOR
and #$0f
sta COLOR
hlin_single_bottom_loop:
ldy #0
lda (GBASL),Y
and #$f0
sta (GBASL),Y
inc GBASL
dex
bne hlin_single_bottom_loop
rts

View File

@ -0,0 +1,5 @@
; move these to zero page for slight speed increase?
gr_offsets:
.word $400,$480,$500,$580,$600,$680,$700,$780
.word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8
.word $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0

View File

@ -0,0 +1,195 @@
.ifndef scroll_row1
scroll_row1 EQU $8A00
scroll_row2 EQU $8B00
scroll_row3 EQU $8C00
scroll_row4 EQU $8D00
.endif
SCROLL_LENGTH EQU $61
OFFSET EQU $62
;========================
; scroll some text
;========================
; RLE compressed data in INL/INH
; CV is Y position to display at
gr_scroll:
lda #0
sta OFFSET
;=======================
; decompress scroll text
;=======================
jsr decompress_scroll
scroll_loop:
ldx #0
ldy CV
lsr
lda gr_offsets,Y ; get position
sta sm1+1
lda gr_offsets+2,Y ; get position
sta sm2+1
lda gr_offsets+4,Y ; get position
sta sm3+1
lda gr_offsets+6,Y ; get position
sta sm4+1
iny
clc
lda gr_offsets,Y ; get position
adc DRAW_PAGE
sta sm1+2
lda gr_offsets+2,Y ; get position
adc DRAW_PAGE
sta sm2+2
lda gr_offsets+4,Y ; get position
adc DRAW_PAGE
sta sm3+2
lda gr_offsets+6,Y ; get position
adc DRAW_PAGE
sta sm4+2
ldy OFFSET
draw_loop:
lda scroll_row1,Y
sm1:
sta $400,X
lda scroll_row2,Y
sm2:
sta $480,X
lda scroll_row3,Y
sm3:
sta $500,X
lda scroll_row4,Y
sm4:
sta $580,X
iny
inx
cpx #40
bne draw_loop
;==================
; flip pages
;==================
jsr page_flip ; 6
;==================
; delay
;==================
lda #125
jsr WAIT
;==================
; loop forever
;==================
clc
lda OFFSET
adc #40
cmp SCROLL_LENGTH
beq done_scrolling
inc OFFSET
jmp scroll_loop ; 3
done_scrolling:
rts
;=======================
; decompress scroll
;=======================
decompress_scroll:
ldy #0
jsr scroll_load_and_increment
sta SCROLL_LENGTH
lda #<scroll_row1
sta OUTL
lda #>scroll_row1
sta OUTH
decompress_scroll_loop:
jsr scroll_load_and_increment ; load compressed value
cmp #$A1 ; EOF marker
beq done_decompress_scroll ; if EOF, exit
pha ; save
and #$f0 ; mask
cmp #$a0 ; see if special AX
beq decompress_scroll_special
pla ; note, PLA sets flags!
ldx #$1 ; only want to print 1
bne decompress_scroll_run
decompress_scroll_special:
pla
and #$0f ; check if was A0
bne decompress_scroll_color ; if A0 need to read run, color
decompress_scroll_large:
jsr scroll_load_and_increment ; get run length
decompress_scroll_color:
tax ; put runlen into X
jsr scroll_load_and_increment ; get color
decompress_scroll_run:
sta (OUTL),Y
pha
clc ; increment 16-bit pointer
lda OUTL
adc #$1
sta OUTL
lda OUTH
adc #$0
sta OUTH
pla
dex ; repeat for X times
bne decompress_scroll_run
beq decompress_scroll_loop ; get next run
done_decompress_scroll:
rts
scroll_load_and_increment:
lda (INL),Y ; load and increment 16-bit pointer
pha
clc
lda INL
adc #$1
sta INL
lda INH
adc #$0
sta INH
pla
rts

View File

@ -0,0 +1,20 @@
;==========================================================
; set_text_page0
;==========================================================
;
set_text_page0:
bit PAGE0 ; set page0
bit TEXT ; set text mode
rts
;==========================================================
; set_gr_page0
;==========================================================
;
set_gr_page0:
bit PAGE0 ; set page 0
bit LORES ; Lo-res graphics
bit TEXTGR ; mixed gr/text mode
bit SET_GR ; set graphics
rts

View File

@ -0,0 +1,2 @@
5 HOME
10 PRINT CHR$(4);"CATALOG"

View File

@ -0,0 +1,24 @@
;==========
; page_flip
;==========
page_flip:
lda DISP_PAGE ; 3
beq page_flip_show_1 ; 2nt/3
page_flip_show_0:
bit PAGE0 ; 4
lda #4 ; 2
sta DRAW_PAGE ; DRAW_PAGE=1 ; 3
lda #0 ; 2
sta DISP_PAGE ; DISP_PAGE=0 ; 3
rts ; 6
page_flip_show_1:
bit PAGE1 ; 4
sta DRAW_PAGE ; DRAW_PAGE=0 ; 3
lda #1 ; 2
sta DISP_PAGE ; DISP_PAGE=1 ; 3
rts ; 6
;====================
; DISP_PAGE=0 26
; DISP_PAGE=1 24

View File

@ -0,0 +1,186 @@
.define EQU =
;; Zero page monitor routines addresses
WNDLFT EQU $20
WNDWDTH EQU $21
WNDTOP EQU $22
WNDBTM EQU $23
CH EQU $24
CV EQU $25
GBASL EQU $26
GBASH EQU $27
BASL EQU $28
BASH EQU $29
H2 EQU $2C
V2 EQU $2D
MASK EQU $2E
COLOR EQU $30
INVFLG EQU $32
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
COLOR1 EQU $E0
COLOR2 EQU $E1
MATCH EQU $E2
XX EQU $E3
YY EQU $E4
YADD EQU $E5
LOOP EQU $E6
MEMPTRL EQU $E7
MEMPTRH EQU $E8
NAMEL EQU $E9
NAMEH EQU $EA
NAMEX EQU $EB
CHAR EQU $EC
DISP_PAGE EQU $ED
DRAW_PAGE EQU $EE
FIRST EQU $F0
LASTKEY EQU $F1
PADDLE_STATUS EQU $F2
XPOS EQU $F3
YPOS EQU $F4
TEMP EQU $FA
RUN EQU $FA
TEMP2 EQU $FB
TEMPY EQU $FB
INL EQU $FC
INH EQU $FD
OUTL EQU $FE
OUTH EQU $FF
;; Flying Routine Only
TURNING EQU $60
;SCREEN_X EQU $61 ; not used?
SCREEN_Y EQU $62
ANGLE EQU $63
HORIZ_SCALE_I EQU $64
HORIZ_SCALE_F EQU $65
FACTOR_I EQU $66
FACTOR_F EQU $67
DX_I EQU $68
DX_F EQU $69
SPACEX_I EQU $6A
SPACEX_F EQU $6B
CX_I EQU $6C
CX_F EQU $6D
DY_I EQU $6E
DY_F EQU $6F
SPACEY_I EQU $70
SPACEY_F EQU $71
CY_I EQU $72
CY_F EQU $73
TEMP_I EQU $74
TEMP_F EQU $75
DISTANCE_I EQU $76
DISTANCE_F EQU $77
SPACEZ_I EQU $78
SPACEZ_F EQU $79
DRAW_SPLASH EQU $7A
SPEED EQU $7B
SPLASH_COUNT EQU $7C
OVER_LAND EQU $7D
NUM1L EQU $7E
NUM1H EQU $7F
NUM2L EQU $80
NUM2H EQU $81
RESULT EQU $82 ; 83,84,85
NEGATE EQU $86 ; UNUSED?
LAST_SPACEX_I EQU $87
LAST_SPACEY_I EQU $88
LAST_MAP_COLOR EQU $89
DRAW_SKY EQU $8A
COLOR_MASK EQU $8B
RANDOM_POINTER EQU $8C
STATE EQU $8D
SHIPY EQU $E4
KEYPRESS EQU $C000
KEYRESET EQU $C010
;; SOFT SWITCHES
CLR80COL EQU $C000 ; PAGE0/PAGE1 normal
SET80COL EQU $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead
EIGHTYCOL EQU $C00D
SPEAKER EQU $C030
SET_GR EQU $C050
SET_TEXT EQU $C051
FULLGR EQU $C052
TEXTGR EQU $C053
PAGE0 EQU $C054
PAGE1 EQU $C055
LORES EQU $C056 ; Enable LORES graphics
HIRES EQU $C057 ; Enable HIRES graphics
AN3 EQU $C05E ; Annunciator 3
PADDLE_BUTTON0 EQU $C061
PADDL0 EQU $C064
PTRIG EQU $C070
;; BASIC ROUTINES
NORMAL EQU $F273
;; MONITOR ROUTINES
HLINE EQU $F819 ;; HLINE Y,$2C at A
VLINE EQU $F828 ;; VLINE A,$2D at Y
CLRSCR EQU $F832 ;; Clear low-res screen
CLRTOP EQU $F836 ;; clear only top of low-res screen
SETCOL EQU $F864 ;; COLOR=A
TEXT EQU $FB36
TABV EQU $FB5B ;; VTAB to A
BASCALC EQU $FBC1 ;;
VTAB EQU $FC22 ;; VTAB to CV
HOME EQU $FC58 ;; Clear the text screen
WAIT EQU $FCA8 ;; delay 1/2(26+27A+5A^2) us
SETINV EQU $FE80 ;; INVERSE
SETNORM EQU $FE84 ;; NORMAL
COUT EQU $FDED ;; output A to screen
COUT1 EQU $FDF0 ;; output A to screen
COLOR_BLACK EQU 0
COLOR_RED EQU 1
COLOR_DARKBLUE EQU 2
COLOR_PURPLE EQU 3
COLOR_DARKGREEN EQU 4
COLOR_GREY EQU 5
COLOR_MEDIUMBLUE EQU 6
COLOR_LIGHTBLUE EQU 7
COLOR_BROWN EQU 8
COLOR_ORANGE EQU 9
COLOR_GREY2 EQU 10
COLOR_PINK EQU 11
COLOR_LIGHTGREEN EQU 12
COLOR_YELLOW EQU 13
COLOR_AQUA EQU 14
COLOR_WHITE EQU 15
COLOR_BOTH_RED EQU $11
COLOR_BOTH_DARKBLUE EQU $22
COLOR_BOTH_DARKGREEN EQU $44
COLOR_BOTH_GREY EQU $55
COLOR_BOTH_MEDIUMBLUE EQU $66
COLOR_BOTH_LIGHTBLUE EQU $77
COLOR_BOTH_BROWN EQU $88
COLOR_BOTH_ORANGE EQU $99
COLOR_BOTH_PINK EQU $BB
COLOR_BOTH_LIGHTGREEN EQU $CC
COLOR_BOTH_YELLOW EQU $DD
COLOR_BOTH_AQUA EQU $EE
COLOR_BOTH_WHITE EQU $FF
AUX_BOTH_MEDIUMBLUE EQU $33 ; 0011 0011
AUX_BOTH_GREY EQU $AA ; 1010 1010