mode7: update a fast screen clear routine

This commit is contained in:
Vince Weaver 2017-12-31 15:09:37 -05:00
parent 6af4836f26
commit 6af85a9533
8 changed files with 151 additions and 133 deletions

View File

@ -2,53 +2,6 @@
;= ROUTINES ;= ROUTINES
;===================================================================== ;=====================================================================
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_screens_notext:
;===================================
; Clear top/bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_top
lda #$0
jsr clear_bottom_a
;===================================
; Clear top/bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_top
lda #$0
jsr clear_bottom_a
rts
;================================ ;================================
; hlin_setup ; hlin_setup
;================================ ;================================
@ -168,69 +121,3 @@ hlin_single_bottom_loop:
rts rts
;=============================
; clear_top
;=============================
clear_top:
lda #$00
;=============================
; clear_top_a
;=============================
clear_top_a:
sta COLOR
; HLIN Y, V2 AT A
lda #39
sta V2
lda #0
clear_top_loop:
ldy #0
pha
jsr hlin_double
pla
clc
adc #$2
cmp #40
bne clear_top_loop
rts
;=============================
; clear_bottom
;=============================
clear_bottom:
lda #$a0 ; NORMAL space
clear_bottom_a:
sta COLOR
lda #40
sta V2
clear_bottom_loop:
ldy #0
pha
jsr hlin_double
pla
clc
adc #$2
cmp #48
bne clear_bottom_loop
rts
; 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,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,115 @@
;=====================================================================
;= ROUTINES
;=====================================================================
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_screens_notext:
;===================================
; Clear top/bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_top
lda #$0
jsr clear_bottom_a
;===================================
; Clear top/bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_top
lda #$0
jsr clear_bottom_a
rts
;=============================
; clear_top
;=============================
; takes 2+10+ (24+703 )*20 +6
; 14,558 cycles(?) 15ms, 70Hz
clear_top:
lda #$00 ; 2
;=============================
; clear_top_a
;=============================
clear_top_a:
sta COLOR ; 3
; HLIN Y, V2 AT A
lda #39 ; 2
sta V2 ; 3
lda #0 ; 2
clear_top_loop:
ldy #0 ; 2
pha ; 3
jsr hlin_double ; 6+
pla ; 4
clc ; 2
adc #$2 ; 2
cmp #40 ; 2
bne clear_top_loop ; 2nt/3
rts ; 6
;=============================
; clear_bottom
;=============================
clear_bottom:
lda #$a0 ; NORMAL space
clear_bottom_a:
sta COLOR
lda #40
sta V2
clear_bottom_loop:
ldy #0
pha
jsr hlin_double
pla
clc
adc #$2
cmp #48
bne clear_bottom_loop
rts

View File

@ -27,8 +27,9 @@ MODE7_ISLAND: mode7_island.o
mode7_island.o: mode7.s island_lookup.s island_map.inc \ mode7_island.o: mode7.s island_lookup.s island_map.inc \
zp.inc sprites.inc \ zp.inc sprites.inc \
../asm_routines/gr_hlin.s \
../asm_routines/multiply_fast.s \ ../asm_routines/multiply_fast.s \
../asm_routines/hlin_clearscreen.s \ ../asm_routines/gr_fast_clear.s \
../asm_routines/pageflip.s \ ../asm_routines/pageflip.s \
../asm_routines/gr_setpage.s \ ../asm_routines/gr_setpage.s \
../asm_routines/keypress.s \ ../asm_routines/keypress.s \
@ -41,8 +42,9 @@ MODE7_CHECKERBOARD: mode7_checkerboard.o
mode7_checkerboard.o: mode7.s checkerboard_lookup.s \ mode7_checkerboard.o: mode7.s checkerboard_lookup.s \
zp.inc sprites.inc \ zp.inc sprites.inc \
../asm_routines/gr_hlin.s \
../asm_routines/multiply_fast.s \ ../asm_routines/multiply_fast.s \
../asm_routines/hlin_clearscreen.s \ ../asm_routines/gr_fast_clear.s \
../asm_routines/pageflip.s \ ../asm_routines/pageflip.s \
../asm_routines/gr_setpage.s \ ../asm_routines/gr_setpage.s \
../asm_routines/keypress.s \ ../asm_routines/keypress.s \
@ -58,7 +60,8 @@ MODE7_RAINBOW: mode7_rainbow.o
mode7_rainbow.o: mode7.s rainbow_lookup.s \ mode7_rainbow.o: mode7.s rainbow_lookup.s \
zp.inc sprites.inc \ zp.inc sprites.inc \
../asm_routines/multiply_fast.s \ ../asm_routines/multiply_fast.s \
../asm_routines/hlin_clearscreen.s \ ../asm_routines/gr_fast_clear.s \
../asm_routines/gr_hlin.s \
../asm_routines/pageflip.s \ ../asm_routines/pageflip.s \
../asm_routines/gr_setpage.s \ ../asm_routines/gr_setpage.s \
../asm_routines/keypress.s \ ../asm_routines/keypress.s \
@ -71,7 +74,8 @@ SCROLL_DEMO: scroll_demo.o
scroll_demo.o: scroll_demo.s \ scroll_demo.o: scroll_demo.s \
deater_scroll.inc \ deater_scroll.inc \
../asm_routines/hlin_clearscreen.s \ ../asm_routines/gr_hlin.s \
../asm_routines/gr_fast_clear.s \
../asm_routines/gr_scroll.s \ ../asm_routines/gr_scroll.s \
../asm_routines/pageflip.s \ ../asm_routines/pageflip.s \
../asm_routines/gr_setpage.s ../asm_routines/gr_setpage.s
@ -82,7 +86,8 @@ SKY_DEMO: sky_demo.o
sky_demo.o: sky_demo.s \ sky_demo.o: sky_demo.s \
starry_sky.scroll \ starry_sky.scroll \
../asm_routines/hlin_clearscreen.s \ ../asm_routines/gr_hlin.s \
../asm_routines/gr_fast_clear.s \
../asm_routines/gr_scroll.s \ ../asm_routines/gr_scroll.s \
../asm_routines/pageflip.s \ ../asm_routines/pageflip.s \
../asm_routines/gr_setpage.s ../asm_routines/gr_setpage.s
@ -92,10 +97,10 @@ STARFIELD_DEMO: starfield_demo.o
ld65 -o STARFIELD_DEMO starfield_demo.o -C ./apple2_1000.inc ld65 -o STARFIELD_DEMO starfield_demo.o -C ./apple2_1000.inc
starfield_demo.o: starfield_demo.s \ starfield_demo.o: starfield_demo.s \
../asm_routines/hlin_clearscreen.s \
../asm_routines/gr_scroll.s \ ../asm_routines/gr_scroll.s \
../asm_routines/pageflip.s \ ../asm_routines/pageflip.s \
../asm_routines/gr_setpage.s ../asm_routines/gr_setpage.s \
../asm_routines/gr_fast_clear.s
ca65 -o starfield_demo.o starfield_demo.s -l starfield_demo.lst ca65 -o starfield_demo.o starfield_demo.s -l starfield_demo.lst
scroller: scroller.o scroller: scroller.o

View File

@ -1114,12 +1114,14 @@ exit:
; External modules ; External modules
;=============================================== ;===============================================
.include "../asm_routines/hlin_clearscreen.s" .include "../asm_routines/gr_hlin.s"
.include "../asm_routines/pageflip.s" .include "../asm_routines/pageflip.s"
.include "../asm_routines/gr_setpage.s" .include "../asm_routines/gr_setpage.s"
.include "../asm_routines/keypress.s" .include "../asm_routines/keypress.s"
.include "../asm_routines/gr_putsprite.s" .include "../asm_routines/gr_putsprite.s"
.include "../asm_routines/text_print.s" .include "../asm_routines/text_print.s"
.include "../asm_routines/gr_offsets.s"
.include "../asm_routines/gr_fast_clear.s"
.if .def(CHECKERBOARD_MAP) .if .def(CHECKERBOARD_MAP)
.include "../asm_routines/gr_scroll.s" .include "../asm_routines/gr_scroll.s"

View File

@ -36,10 +36,11 @@ scroll_forever:
;=============================================== ;===============================================
; Routines ; Routines
;=============================================== ;===============================================
.include "../asm_routines/hlin_clearscreen.s" .include "../asm_routines/gr_fast_clear.s"
.include "../asm_routines/gr_scroll.s" .include "../asm_routines/gr_scroll.s"
.include "../asm_routines/pageflip.s" .include "../asm_routines/pageflip.s"
.include "../asm_routines/gr_setpage.s" .include "../asm_routines/gr_setpage.s"
.include "../asm_routines/gr_offsets.s"
;=============================================== ;===============================================
; Variables ; Variables

View File

@ -51,12 +51,13 @@ scroll_forever:
;=============================================== ;===============================================
; Routines ; Routines
;=============================================== ;===============================================
.include "../asm_routines/hlin_clearscreen.s" .include "../asm_routines/gr_fast_clear.s"
.include "../asm_routines/gr_scroll.s" .include "../asm_routines/gr_scroll.s"
.include "../asm_routines/pageflip.s" .include "../asm_routines/pageflip.s"
.include "../asm_routines/gr_setpage.s" .include "../asm_routines/gr_setpage.s"
.include "../asm_routines/keypress.s" .include "../asm_routines/keypress.s"
.include "../asm_routines/bg_scroll.s" .include "../asm_routines/bg_scroll.s"
.include "../asm_routines/gr_offsets.s"
;=============================================== ;===============================================
; Variables ; Variables

View File

@ -25,15 +25,15 @@ NUMSTARS EQU 16
;=============== ;===============
; Init Variables ; Init Variables
;=============== ;===============
lda #0 lda #0 ; 2
sta DRAW_PAGE sta DRAW_PAGE ; 3
sta RANDOM_POINTER sta RANDOM_POINTER ; 3
ldy #(NUMSTARS-1) ldy #(NUMSTARS-1) ; 2
init_stars: init_stars:
jsr random_star jsr random_star ; 6
dey dey ; 2
bpl init_stars bpl init_stars ; 2nt/3
;=========================== ;===========================
;=========================== ;===========================
@ -46,8 +46,8 @@ starfield_loop:
;=============== ;===============
; clear screen ; clear screen
;=============== ;===============
jsr clear_top jsr clear_top ; 6+
; 6047
;=============== ;===============
; draw stars ; draw stars
;=============== ;===============
@ -312,12 +312,14 @@ random_star:
; External modules ; External modules
;=============================================== ;===============================================
.include "../asm_routines/hlin_clearscreen.s" ;.include "../asm_routines/hlin_clearscreen.s"
.include "../asm_routines/pageflip.s" .include "../asm_routines/pageflip.s"
.include "../asm_routines/gr_setpage.s" .include "../asm_routines/gr_setpage.s"
.include "../asm_routines/keypress.s" .include "../asm_routines/keypress.s"
.include "../asm_routines/gr_putsprite.s" .include "../asm_routines/gr_putsprite.s"
.include "../asm_routines/text_print.s" .include "../asm_routines/text_print.s"
.include "../asm_routines/gr_offsets.s"
.include "../asm_routines/gr_fast_clear.s"
;=============================================== ;===============================================
; Variables ; Variables