vgi tests: split up

This commit is contained in:
Vince Weaver 2021-07-30 15:10:38 -04:00
parent 7231194c5c
commit 907146f43b
10 changed files with 418 additions and 477 deletions

View File

@ -6,14 +6,16 @@ LINKERSCRIPTS = ../../../linker_scripts
EMPTYDISK = ../../../empty_disk/empty.dsk
MAKEVGI = ./make_vgi_asm
all: vgi_myst.dsk make_vgi_asm make_color_test
all: vgi_test.dsk make_vgi_asm make_color_test
vgi_myst.dsk: HELLO VGI-MYST COLOR-TEST VGI-TEST
cp $(EMPTYDISK) vgi_myst.dsk
$(DOS33) -y vgi_myst.dsk SAVE A HELLO
$(DOS33) -y vgi_myst.dsk BSAVE -a 0xC00 VGI-MYST
$(DOS33) -y vgi_myst.dsk BSAVE -a 0x4000 COLOR-TEST
$(DOS33) -y vgi_myst.dsk BSAVE -a 0x4000 VGI-TEST
vgi_test.dsk: HELLO COLOR-TEST VGI-TEST BENCHMARK_SLOW BENCHMARK_ORIGINAL BENCHMARK_FAST
cp $(EMPTYDISK) vgi_test.dsk
$(DOS33) -y vgi_test.dsk SAVE A HELLO
$(DOS33) -y vgi_test.dsk BSAVE -a 0x4000 COLOR-TEST
$(DOS33) -y vgi_test.dsk BSAVE -a 0x4000 VGI-TEST
$(DOS33) -y vgi_test.dsk BSAVE -a 0x4000 BENCHMARK_SLOW
$(DOS33) -y vgi_test.dsk BSAVE -a 0x4000 BENCHMARK_ORIGINAL
$(DOS33) -y vgi_test.dsk BSAVE -a 0x4000 BENCHMARK_FAST
###
@ -23,13 +25,50 @@ HELLO: hello.bas
###
VGI-MYST: myst_vgi.o
ld65 -o VGI-MYST myst_vgi.o -C $(LINKERSCRIPTS)/apple2_c00.inc
BENCHMARK_SLOW: benchmark_slow.o
ld65 -o BENCHMARK_SLOW benchmark_slow.o -C $(LINKERSCRIPTS)/apple2_4000.inc
benchmark_slow.o: clock.data rocket.data rocket_door.data red_book.data fireplace.data path.data \
benchmark_slow.s \
./vgi_slow/vgi_common.s \
./vgi_slow/vgi_clearscreen.s \
./vgi_slow/vgi_rectangle.s \
./vgi_slow/vgi_circles.s \
./vgi_slow/vgi_lines.s \
./vgi_slow/vgi_triangles.s
ca65 -o benchmark_slow.o benchmark_slow.s -l benchmark_slow.lst
###
BENCHMARK_ORIGINAL: benchmark_original.o
ld65 -o BENCHMARK_ORIGINAL benchmark_original.o -C $(LINKERSCRIPTS)/apple2_4000.inc
benchmark_original.o: clock.data rocket.data rocket_door.data red_book.data fireplace.data path.data \
benchmark_original.s \
./vgi_original/vgi_common.s \
./vgi_original/vgi_clearscreen.s \
./vgi_original/vgi_rectangle.s \
./vgi_original/vgi_circles.s \
./vgi_original/vgi_lines.s \
./vgi_original/vgi_triangles.s
ca65 -o benchmark_original.o benchmark_original.s -l benchmark_original.lst
###
BENCHMARK_FAST: benchmark_fast.o
ld65 -o BENCHMARK_FAST benchmark_fast.o -C $(LINKERSCRIPTS)/apple2_4000.inc
benchmark_fast.o: clock.data rocket.data rocket_door.data red_book.data fireplace.data path.data \
benchmark_fast.s \
./vgi_fast/vgi_common.s \
./vgi_fast/vgi_clearscreen.s \
./vgi_fast/vgi_rectangle.s \
./vgi_fast/vgi_circles.s \
./vgi_fast/vgi_lines.s \
./vgi_fast/vgi_triangles.s
ca65 -o benchmark_fast.o benchmark_fast.s -l benchmark_fast.lst
myst_vgi.o: clock.data rocket.data rocket_door.data red_book.data fireplace.data path.data \
myst_vgi.s vgi_clearscreen.s vgi_rectangle.s vgi_circles.s vgi_lines.s \
vgi_triangles.s
ca65 -o myst_vgi.o myst_vgi.s -l myst_vgi.lst
###
@ -37,8 +76,13 @@ VGI-TEST: test_vgi.o
ld65 -o VGI-TEST test_vgi.o -C $(LINKERSCRIPTS)/apple2_4000.inc
test_vgi.o: new.data \
test_vgi.s vgi_clearscreen.s vgi_rectangle.s vgi_circles.s vgi_lines.s \
vgi_triangles.s
test_vgi.s \
./vgi_fast/vgi_common.s \
./vgi_fast/vgi_clearscreen.s \
./vgi_fast/vgi_rectangle.s \
./vgi_fast/vgi_circles.s \
./vgi_fast/vgi_lines.s \
./vgi_fast/vgi_triangles.s
ca65 -o test_vgi.o test_vgi.s -l test_vgi.lst
@ -48,8 +92,13 @@ COLOR-TEST: color_test.o
ld65 -o COLOR-TEST color_test.o -C $(LINKERSCRIPTS)/apple2_4000.inc
color_test.o: color_test.data \
color_test.s vgi_clearscreen.s vgi_rectangle.s vgi_circles.s vgi_lines.s \
vgi_triangles.s
color_test.s \
./vgi_fast/vgi_common.s \
./vgi_fast/vgi_clearscreen.s \
./vgi_fast/vgi_rectangle.s \
./vgi_fast/vgi_circles.s \
./vgi_fast/vgi_lines.s \
./vgi_fast/vgi_triangles.s
ca65 -o color_test.o color_test.s -l color_test.lst
@ -128,5 +177,5 @@ make_color_test.o: make_color_test.c
###
clean:
rm -f *~ *.o *.lst HELLO VGI-MYST VGI-DOOM COLOR-TEST \
rm -f *~ *.o *.lst HELLO COLOR-TEST BENCHMARK_SLOW BENCHMARK_FAST BENCHMARK_ORIGINAL \
make_vgi_asm make_color_test *.data

View File

@ -0,0 +1,96 @@
; VGI Benchmark test of FAST (but large) routines
.include "zp.inc"
.include "hardware.inc"
vgi_benchmark_fast:
jsr SETGR
jsr HGR
bit FULLGR
jsr vgi_make_tables
; get pointer to image data
clock:
lda #<clock_data
sta VGIL
lda #>clock_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
rocket:
; Rocket
lda #<rocket_data
sta VGIL
lda #>rocket_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
rocket_door:
; Rocket Door
lda #<rocket_door_data
sta VGIL
lda #>rocket_door_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
red_book:
; Red Book
lda #<red_book_data
sta VGIL
lda #>red_book_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
fireplace:
;==========================
; Fireplace
lda #<fireplace_data
sta VGIL
lda #>fireplace_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
done:
jmp done
.include "./vgi_fast/vgi_common.s"
.include "clock.data"
.include "rocket.data"
.include "rocket_door.data"
.include "red_book.data"
.include "fireplace.data"
.include "path.data"
wait_until_keypress:
lda KEYPRESS
bpl wait_until_keypress
bit KEYRESET
rts

View File

@ -0,0 +1,96 @@
; VGI Benchmark test of Original (SLOW and small) routines
.include "zp.inc"
.include "hardware.inc"
vgi_benchmark_original:
jsr SETGR
jsr HGR
bit FULLGR
jsr vgi_make_tables
; get pointer to image data
clock:
lda #<clock_data
sta VGIL
lda #>clock_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
rocket:
; Rocket
lda #<rocket_data
sta VGIL
lda #>rocket_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
rocket_door:
; Rocket Door
lda #<rocket_door_data
sta VGIL
lda #>rocket_door_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
red_book:
; Red Book
lda #<red_book_data
sta VGIL
lda #>red_book_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
fireplace:
;==========================
; Fireplace
lda #<fireplace_data
sta VGIL
lda #>fireplace_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
done:
jmp done
.include "./vgi_original/vgi_common.s"
.include "clock.data"
.include "rocket.data"
.include "rocket_door.data"
.include "red_book.data"
.include "fireplace.data"
.include "path.data"
wait_until_keypress:
lda KEYPRESS
bpl wait_until_keypress
bit KEYRESET
rts

View File

@ -0,0 +1,96 @@
; VGI Benchmark test of SLOW (but small) routines
.include "zp.inc"
.include "hardware.inc"
vgi_benchmark_slow:
jsr SETGR
jsr HGR
bit FULLGR
jsr vgi_make_tables
; get pointer to image data
clock:
lda #<clock_data
sta VGIL
lda #>clock_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
rocket:
; Rocket
lda #<rocket_data
sta VGIL
lda #>rocket_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
rocket_door:
; Rocket Door
lda #<rocket_door_data
sta VGIL
lda #>rocket_door_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
red_book:
; Red Book
lda #<red_book_data
sta VGIL
lda #>red_book_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
fireplace:
;==========================
; Fireplace
lda #<fireplace_data
sta VGIL
lda #>fireplace_data
sta VGIH
jsr play_vgi
; jsr wait_until_keypress
done:
jmp done
.include "./vgi_slow/vgi_common.s"
.include "clock.data"
.include "rocket.data"
.include "rocket_door.data"
.include "red_book.data"
.include "fireplace.data"
.include "path.data"
wait_until_keypress:
lda KEYPRESS
bpl wait_until_keypress
bit KEYRESET
rts

View File

@ -25,7 +25,7 @@ vgi_color_test:
done:
jmp done
.include "vgi_common.s"
.include "./vgi_fast/vgi_common.s"
.include "color_test.data"

View File

@ -1,9 +1,3 @@
5 HOME
10 PRINT CHR$(4);"CATALOG"
20 PRINT:PRINT "FOR THE BRIEF HI-RES MYST DEMO"
30 PRINT "TYPE: BRUN VGI-MYST"
40 PRINT:PRINT "FOR THE DOOM DEMO"
50 PRINT "TYPE: BRUN VGI-DOOM"
70 PRINT:PRINT "NOTE: THERE IS ALSO A FULL-FEATURED"
80 PRINT "LORES VERSION AVAILABLE FOR DOWNLOAD"
90 PRINT "IF YOU WANT TO PLAY ON APPLE II"

View File

@ -27,7 +27,7 @@ vgi_test:
done:
jmp done
.include "vgi_common.s"
.include "./vgi_fast/vgi_common.s"
.include "new.data"

View File

@ -1,7 +1,52 @@
;=======================
; VGI Clearscreen
;=======================
; hires color in P0
; note, using BKGND0 for this takes 0x44198 = 278,936 cycles
; unrolled here takes 0x0A501 = 42,241 cycles
vgi_clearscreen:
lda P0
jsr BKGND0
before:
ldy #0
vgi_cls_loop:
sta $2000,Y
sta $2100,Y
sta $2200,Y
sta $2300,Y
sta $2400,Y
sta $2500,Y
sta $2600,Y
sta $2700,Y
sta $2800,Y
sta $2900,Y
sta $2A00,Y
sta $2B00,Y
sta $2C00,Y
sta $2D00,Y
sta $2E00,Y
sta $2F00,Y
sta $3000,Y
sta $3100,Y
sta $3200,Y
sta $3300,Y
sta $3400,Y
sta $3500,Y
sta $3600,Y
sta $3700,Y
sta $3800,Y
sta $3900,Y
sta $3A00,Y
sta $3B00,Y
sta $3C00,Y
sta $3D00,Y
sta $3E00,Y
sta $3F00,Y
iny
bne vgi_cls_loop
after:
jmp vgi_loop ; return

View File

@ -9,111 +9,6 @@ XRUN = TEMP2
div7_table = $9000
mod7_table = $9100
USE_FAST = 1
.if (USE_FAST=0)
; slow
;=================================
; Simple Rectangle
;=================================
VGI_RCOLOR = P0
VGI_RX1 = P1
VGI_RY1 = P2
VGI_RXRUN = P3
VGI_RYRUN = P4
vgi_simple_rectangle:
simple_rectangle_loop:
lda VGI_RCOLOR
asl ; nibble swap by david galloway
adc #$80
rol
asl
adc #$80
rol
sta VGI_RCOLOR
and #$f
tax
lda COLORTBL,X
sta HGR_COLOR
ldx VGI_RX1 ; X1 into X
lda VGI_RY1 ; Y1 into A
ldy #0 ; always 0
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
lda VGI_RXRUN ; XRUN into A
ldx #0 ; always 0
ldy #0 ; relative Y is 0
jsr HLINRL ; (X,A),(Y)
inc VGI_RY1
dec VGI_RYRUN
bne simple_rectangle_loop
jmp vgi_loop
;=================================
; Dithered Rectangle
;=================================
; VGI_RCOLOR = P0
; VGI_RX1 = P1
; VGI_RY1 = P2
; VGI_RXRUN = P3
; VGI_RYRUN = P4
VGI_RCOLOR2 = P5
vgi_dithered_rectangle:
dithered_rectangle_loop:
lda COUNT
and #$1
beq even_color
odd_color:
lda VGI_RCOLOR
jmp save_color
even_color:
lda VGI_RCOLOR2
save_color:
sta HGR_COLOR
inc COUNT
ldx VGI_RX1 ; X1 into X
lda VGI_RY1 ; Y1 into A
ldy #0 ; always 0
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
lda VGI_RXRUN ; XRUN into A
ldx #0 ; always 0
ldy #0 ; relative Y is 0
jsr HLINRL ; (X,A),(Y)
inc VGI_RY1
dec VGI_RYRUN
bne dithered_rectangle_loop
jmp vgi_loop
.else
; FAST
;=================================
@ -396,14 +291,6 @@ vgi_vstripe_rectangle:
jmp simple_rectangle_loop
.endif
;=====================
; make /7 %7 tables
;=====================

View File

@ -6,14 +6,6 @@ COLOR_MODE = TEMP0
OTHER_MASK = TEMP1
XRUN = TEMP2
div7_table = $9000
mod7_table = $9100
USE_FAST = 1
.if (USE_FAST=0)
; slow
;=================================
@ -110,296 +102,24 @@ save_color:
.else
; FAST
;=================================
; Simple Rectangle
;=================================
VGI_RCOLOR = P0
VGI_RX1 = P1
VGI_RY1 = P2
VGI_RXRUN = P3
VGI_RYRUN = P4
VGI_RCOLOR2 = P5 ; only for dither
;==================================
; VGI Simple Rectangle
;==================================
vgi_simple_rectangle:
lda #0
sta COLOR_MODE
simple_rectangle_loop:
lda COLOR_MODE
beq simple_colors
bmi striped_colors
bpl handle_dither
simple_colors:
lda VGI_RCOLOR
asl ; nibble swap by david galloway
adc #$80
rol
asl
adc #$80
rol
sta VGI_RCOLOR
and #$f
tax
lda COLORTBL,X
sta HGR_COLOR
jmp done_colors
handle_dither:
lda COUNT
and #$1
beq deven_color
dodd_color:
lda VGI_RCOLOR
jmp dsave_color
deven_color:
lda VGI_RCOLOR2
dsave_color:
sta HGR_COLOR
inc COUNT
jmp done_colors
striped_colors:
; don't need to do anything here?
done_colors:
; get ROW into (GBASL)
ldx VGI_RX1 ; X1 into X
lda VGI_RY1 ; Y1 into A
ldy #0 ; always 0
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
; Y is already the RX1/7
; adjust color if in striped mode
lda COLOR_MODE
bpl not_striped
jsr swap_colors
not_striped:
; copy the XRUN
lda VGI_RXRUN
sta XRUN
inc XRUN ; needed because we compare with beq/bne
; check if narrow corner case where begin and end same block
; if RX%7 + XRUN < 8
ldx VGI_RX1
lda mod7_table,X
clc
adc XRUN
cmp #8
bcs not_corner
corner:
; want to use MASK of left_mask, MOD7 and 7-XRUN
lda mod7_table,X
tax
lda (GBASL),Y
eor HGR_BITS
and left_masks,X
ldx XRUN
and right_masks,X
eor (GBASL),Y
sta (GBASL),Y
jmp done_row ; that's all
not_corner:
; see if not starting on boundary
ldx VGI_RX1
lda mod7_table,X
beq draw_run
; handle not full left border
tax
lda (GBASL),Y
eor HGR_BITS
and left_masks,X
eor (GBASL),Y
sta (GBASL),Y
iny ; move to next
; adjust RUN length by 7- mod7
txa ; load mod7
eor #$ff
sec
adc #7
eor #$ff
sec
adc XRUN
sta XRUN
; lda HGR_BITS ; cycle colors for next
; jsr COLOR_SHIFT
jsr swap_colors
;no_shift:
; draw common
draw_run:
lda XRUN
cmp #7
bcc draw_right ; blt
lda HGR_BITS ; get color
sta (GBASL),Y ; store out
; jsr COLOR_SHIFT ; shift colors
iny ; move to next block
jsr swap_colors
lda XRUN ; take 7 off the run
sec
sbc #7
sta XRUN
jmp draw_run
; draw rightmost
draw_right:
beq done_row
; lda HGR_BITS
; jsr COLOR_SHIFT
; see if not starting on boundary
ldx XRUN
tax
lda (GBASL),Y
eor HGR_BITS
and right_masks,X
eor (GBASL),Y
sta (GBASL),Y
done_row:
inc VGI_RY1
dec VGI_RYRUN
;bne simple_rectangle_loop
beq done_done
jmp simple_rectangle_loop
done_done:
jmp vgi_loop
;==========================
; swap colors
;==========================
swap_colors:
lda COLOR_MODE
bmi swap_colors_striped
lda HGR_BITS ; get color
jsr COLOR_SHIFT ; shift colors
rts
swap_colors_striped:
tya
and #1
bne swap_odd
lda VGI_RCOLOR
jmp swap_done
swap_odd:
lda VGI_RCOLOR2
swap_done:
sta HGR_BITS
rts
;=================================
; Dithered Rectangle
;=================================
; VGI_RCOLOR = P0
; VGI_RX1 = P1
; VGI_RY1 = P2
; VGI_RXRUN = P3
; VGI_RYRUN = P4
; VGI_RCOLOR2 = P5
vgi_dithered_rectangle:
lda #1
sta COLOR_MODE
lda #0
sta COUNT
jmp simple_rectangle_loop
;=================================
; Vertical Striped Rectangle
;=================================
; VGI_RCOLOR = P0
; VGI_RX1 = P1
; VGI_RY1 = P2
; VGI_RXRUN = P3
; VGI_RYRUN = P4
; VGI_RCOLOR2 = P5
;=================================
; Vertical Striped Rectangle
;=================================
; VGI_RCOLOR = P0
; VGI_RX1 = P1
; VGI_RY1 = P2
; VGI_RXRUN = P3
; VGI_RYRUN = P4
; VGI_RCOLOR2 = P5
vgi_vstripe_rectangle:
lda #128
sta COLOR_MODE
lda #0
sta COUNT
jmp simple_rectangle_loop
.endif
lda #128
sta COLOR_MODE
lda #0
sta COUNT
jmp simple_rectangle_loop
@ -409,51 +129,9 @@ vgi_vstripe_rectangle:
;=====================
vgi_init:
vgi_make_tables:
ldy #0
lda #0
ldx #0
div7_loop:
sta div7_table,Y
inx
cpx #7
bne div7_not7
clc
adc #1
ldx #0
div7_not7:
iny
bne div7_loop
ldy #0
lda #0
mod7_loop:
sta mod7_table,Y
clc
adc #1
cmp #7
bne mod7_not7
lda #0
mod7_not7:
iny
bne mod7_loop
rts
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF