gr: more separation of things

This commit is contained in:
Vince Weaver 2021-01-06 11:52:07 -05:00
parent a1732840d1
commit f05c1744c4
15 changed files with 703 additions and 6 deletions

View File

@ -1,9 +1,15 @@
all:
cd mode7 && make
cd rotate && make
cd rasterbars && make
cd rotozoom && make
cd scroll_text && make
cd starfield && make
clean:
cd mode7 && make clean
cd rotate && make clean
cd rasterbars && make clean
cd rotozoom && make clean
cd scroll_text && make clean
cd starfield && make clean
rm -f *~

17
graphics/gr/README Normal file
View File

@ -0,0 +1,17 @@
Various experiments in lo-res graphics
+ mode7
mode7 tests, used when making mode7 demo
+ rasterbars
colored bars (not really rasterbars), used in mode7 demo
+ rotozoom
rotozoom, used in tfv
+ scroll_text
some lo-res scroll text
+ starfield
lo-res starfield

View File

@ -1,7 +1,8 @@
include ../../Makefile.inc
include ../../../Makefile.inc
DOS33 = ../../utils/dos33fs-utils/dos33
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
DOS33 = ../../../utils/dos33fs-utils/dos33
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
LINKERSCRIPTS = ../../../linker_scripts
all: gr.dsk
@ -12,7 +13,7 @@ gr.dsk: SNOW
###
SNOW: snow.o
ld65 -o SNOW snow.o -C ../../linker_scripts/apple2_300.inc
ld65 -o SNOW snow.o -C $(LINKERSCRIPTS)/apple2_300.inc
snow.o: snow.s
ca65 -o snow.o snow.s -l snow.lst

BIN
textmode/textflip/HELLO Normal file

Binary file not shown.

View File

@ -0,0 +1,39 @@
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
LINKERSCRIPTS = ../../linker_scripts
all: textflip.dsk
$(DOS33):
cd ../../utils/dos33fs-utils && make
textflip.dsk: $(DOS33) HELLO TEXT_DEMO
cp empty.dsk textflip.dsk
$(DOS33) -y textflip.dsk SAVE A HELLO
$(DOS33) -y textflip.dsk BSAVE -a 0x1000 TEXT_DEMO
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
TEXT_DEMO: text_demo.o
ld65 -o TEXT_DEMO text_demo.o -C $(LINKERSCRIPTS)/apple2_1000.inc
text_demo.o: text_demo.s \
pageflip.s \
gr_fast_clear.s
ca65 -o text_demo.o text_demo.s -l text_demo.lst
###
clean:
rm -f *~ *.o TEXT_DEMO *.lst

BIN
textmode/textflip/empty.dsk Normal file

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

124
textmode/textflip/gr_hlin.s Normal file
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,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,80 @@
;================================
; htab_vtab
;================================
; move to CH/CV
htab_vtab:
lda CV
asl
tay
lda gr_offsets,Y ; lookup low-res memory address
clc
adc CH ; add in xpos
sta BASL ; store out low byte of addy
lda gr_offsets+1,Y ; look up high byte
adc DRAW_PAGE ;
sta BASH ; and store it out
; BASH:BASL now points at right place
rts
;================================
; move_and_print
;================================
; move to CH/CV
move_and_print:
jsr htab_vtab
;================================
; print_string
;================================
print_string:
ldy #0
print_string_loop:
lda (OUTL),Y
beq done_print_string
ora #$80
sta (BASL),Y
iny
bne print_string_loop
done_print_string:
rts
;====================
; point_to_end_string
;====================
point_to_end_string:
iny
tya
clc
adc OUTL
sta OUTL
lda #0
adc OUTH
sta OUTH
rts
;================================
; print_both_pages
;================================
print_both_pages:
lda DRAW_PAGE
pha
lda #0
sta DRAW_PAGE
jsr move_and_print
lda #4
sta DRAW_PAGE
jsr move_and_print
pla
sta DRAW_PAGE
rts ; oops forgot this initially
; explains the weird vertical stripes on the screen

Binary file not shown.

186
textmode/textflip/zp.inc Normal file
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