mode7: add common plot routine

This commit is contained in:
Vince Weaver 2017-12-31 19:21:31 -05:00
parent 999cdbb6ac
commit c1dbf70269
3 changed files with 125 additions and 2 deletions

48
asm_routines/gr_plot.s Normal file
View File

@ -0,0 +1,48 @@
;================================
; plot routine
;================================
; Xcoord in XPOS
; Ycoord in YPOS
; color in COLOR
plot:
lda YPOS ; 2
lsr ; shift bottom bit into carry ; 2
bcc plot_even ; 2nt/3
plot_odd:
ldx #$f0 ; 2
bcs plot_c_done ; 2nt/3
plot_even:
ldx #$0f ; 2
plot_c_done:
stx MASK ; 3
asl ; shift back (now even) ; 2
tay
lda gr_offsets,Y ; lookup low-res memory address ; 4
clc ; 2
adc XPOS ; 3
sta GBASL ; 3
iny ; 2
lda gr_offsets,Y ; 4
adc DRAW_PAGE ; add in draw page offset ; 3
sta GBASH ; 3
ldy #0 ; 2
plot_write:
lda MASK ; 3
eor #$ff ; 2
and (GBASL),Y ; 5
sta COLOR_MASK ; 3
lda COLOR ; 3
and MASK ; 3
ora COLOR_MASK ; 3
sta (GBASL),Y ; 5
rts ; 6

View File

@ -10,10 +10,11 @@ $(DOS33):
cd ../dos33fs-utils && make
mode7.dsk: $(DOS33) MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
SCROLL_DEMO SKY_DEMO STARFIELD_DEMO
PLOT_TEST SCROLL_DEMO SKY_DEMO STARFIELD_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 SCROLL_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 SKY_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 STARFIELD_DEMO
@ -69,6 +70,13 @@ mode7_rainbow.o: mode7.s rainbow_lookup.s \
../asm_routines/text_print.s
ca65 -o mode7_rainbow.o mode7.s -D RAINBOW_MAP=1 -l mode7.lst
PLOT_TEST: plot_test.o
ld65 -o PLOT_TEST plot_test.o -C ./apple2_1000.inc
plot_test.o: plot_test.s \
../asm_routines/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
@ -118,5 +126,5 @@ background.o: background.c
clean:
rm -f *~ *.o scroller background \
MODE7 MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
SCROLL_DEMO *.lst
PLOT_TEST SCROLL_DEMO *.lst

67
mode7/plot_test.s Normal file
View File

@ -0,0 +1,67 @@
.include "zp.inc"
plot_test:
jsr clear_screens ; clear top/bottom of page 0/1
jsr set_gr_page0
;===============
; Init Variables
;===============
lda #0
sta DRAW_PAGE
ldx #0
ldy #0
plot_loop:
txa
and #$0f
sta TEMP
tya
asl
asl
asl
asl
ora TEMP
sta COLOR
stx XPOS
sty YPOS
jsr plot
ldx XPOS
ldy YPOS
inx
cpx #16
bne plot_loop
ldx #0
iny
cpy #16
bne plot_loop
blah:
jmp blah
;===============================================
; External modules
;===============================================
.include "../asm_routines/pageflip.s"
.include "../asm_routines/gr_setpage.s"
;.include "../asm_routines/keypress.s"
;.include "../asm_routines/gr_putsprite.s"
.include "../asm_routines/gr_offsets.s"
.include "../asm_routines/gr_fast_clear.s"
.include "../asm_routines/gr_plot.s"