From c1dbf70269f402a90622d79b6678b0c264f4616c Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 31 Dec 2017 19:21:31 -0500 Subject: [PATCH] mode7: add common plot routine --- asm_routines/gr_plot.s | 48 ++++++++++++++++++++++++++++++ mode7/Makefile | 12 ++++++-- mode7/plot_test.s | 67 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 asm_routines/gr_plot.s create mode 100644 mode7/plot_test.s diff --git a/asm_routines/gr_plot.s b/asm_routines/gr_plot.s new file mode 100644 index 00000000..1ad15895 --- /dev/null +++ b/asm_routines/gr_plot.s @@ -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 diff --git a/mode7/Makefile b/mode7/Makefile index be9fc712..11001395 100644 --- a/mode7/Makefile +++ b/mode7/Makefile @@ -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 diff --git a/mode7/plot_test.s b/mode7/plot_test.s new file mode 100644 index 00000000..9f09cc58 --- /dev/null +++ b/mode7/plot_test.s @@ -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" + +