From 0d8e4d7d6c7d7ee674efd8708566a3b281270f33 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 6 Jan 2021 10:20:10 -0500 Subject: [PATCH] gr: work on splitting things up --- graphics/gr/Makefile | 28 +-- graphics/gr/mode7/Makefile | 118 +++++----- graphics/gr/mode7/bg_scroll.s | 79 +++++++ graphics/gr/mode7/gr_fast_clear.s | 193 ++++++++++++++++ graphics/gr/mode7/gr_hlin.s | 124 ++++++++++ graphics/gr/mode7/gr_offsets.s | 5 + graphics/gr/mode7/gr_plot.s | 48 ++++ graphics/gr/mode7/gr_putsprite.s | 101 +++++++++ graphics/gr/mode7/gr_scroll.s | 195 ++++++++++++++++ graphics/gr/mode7/gr_setpage.s | 20 ++ graphics/gr/mode7/keypress.s | 111 +++++++++ graphics/gr/mode7/mode7.s | 22 +- graphics/gr/mode7/multiply_fast.s | 351 +++++++++++++++++++++++++++++ graphics/gr/mode7/pageflip.s | 24 ++ graphics/gr/mode7/plot_test.s | 14 +- graphics/gr/mode7/rasterbars.s | 10 +- graphics/gr/mode7/scroll_demo.s | 10 +- graphics/gr/mode7/sky_demo.s | 14 +- graphics/gr/mode7/starfield_1k.s | 16 +- graphics/gr/mode7/starfield_demo.s | 16 +- graphics/gr/mode7/text_demo.s | 14 +- graphics/gr/mode7/text_print.s | 80 +++++++ graphics/gr/rotate/Makefile | 23 ++ graphics/gr/{ => rotate}/README | 0 graphics/gr/{ => rotate}/empty.dsk | Bin graphics/gr/{ => rotate}/gr.dsk | Bin graphics/gr/{ => rotate}/snow.s | 0 27 files changed, 1478 insertions(+), 138 deletions(-) create mode 100644 graphics/gr/mode7/bg_scroll.s create mode 100644 graphics/gr/mode7/gr_fast_clear.s create mode 100644 graphics/gr/mode7/gr_hlin.s create mode 100644 graphics/gr/mode7/gr_offsets.s create mode 100644 graphics/gr/mode7/gr_plot.s create mode 100644 graphics/gr/mode7/gr_putsprite.s create mode 100644 graphics/gr/mode7/gr_scroll.s create mode 100644 graphics/gr/mode7/gr_setpage.s create mode 100644 graphics/gr/mode7/keypress.s create mode 100644 graphics/gr/mode7/multiply_fast.s create mode 100644 graphics/gr/mode7/pageflip.s create mode 100644 graphics/gr/mode7/text_print.s create mode 100644 graphics/gr/rotate/Makefile rename graphics/gr/{ => rotate}/README (100%) rename graphics/gr/{ => rotate}/empty.dsk (100%) rename graphics/gr/{ => rotate}/gr.dsk (100%) rename graphics/gr/{ => rotate}/snow.s (100%) diff --git a/graphics/gr/Makefile b/graphics/gr/Makefile index 2f49708c..a92b9380 100644 --- a/graphics/gr/Makefile +++ b/graphics/gr/Makefile @@ -1,23 +1,9 @@ -include ../../Makefile.inc +all: + cd mode7 && make + cd rotate && make -DOS33 = ../../utils/dos33fs-utils/dos33 -TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft +clean: + cd mode7 && make clean + cd rotate && make clean + rm -f *~ -all: gr.dsk - -gr.dsk: SNOW - cp empty.dsk gr.dsk - $(DOS33) -y gr.dsk BSAVE -a 0x0300 SNOW - -### - -SNOW: snow.o - ld65 -o SNOW snow.o -C ../../linker_scripts/apple2_300.inc - -snow.o: snow.s - ca65 -o snow.o snow.s -l snow.lst - -### - -clean: - rm -f *~ *.o *.lst SNOW diff --git a/graphics/gr/mode7/Makefile b/graphics/gr/mode7/Makefile index af7153b9..81c61f28 100644 --- a/graphics/gr/mode7/Makefile +++ b/graphics/gr/mode7/Makefile @@ -1,15 +1,15 @@ -include ../../Makefile.inc +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 +DOS33 = ../../../utils/dos33fs-utils/dos33 +PNG2GR = ../../../utils/gr-utils/png2gr +PNG2RLE = ../../../utils/gr-utils/png2rle +TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft all: mode7.dsk scroller background $(DOS33): - cd ../../utils/dos33fs-utils && make + cd ../../../utils/dos33fs-utils && make mode7.dsk: $(DOS33) MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \ PLOT_TEST RASTERBARS SCROLL_DEMO SKY_DEMO \ @@ -34,14 +34,14 @@ MODE7_ISLAND: mode7_island.o mode7_island.o: mode7.s island_lookup.s island_map.inc \ zp.inc sprites.inc \ - ../../asm_routines/gr_hlin.s \ - ../../asm_routines/multiply_fast.s \ - ../../asm_routines/gr_fast_clear.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s \ - ../../asm_routines/keypress.s \ - ../../asm_routines/gr_putsprite.s \ - ../../asm_routines/text_print.s + gr_hlin.s \ + multiply_fast.s \ + gr_fast_clear.s \ + pageflip.s \ + gr_setpage.s \ + keypress.s \ + gr_putsprite.s \ + text_print.s ca65 -o mode7_island.o mode7.s -D ISLAND_MAP=1 -l mode7.lst MODE7_CHECKERBOARD: mode7_checkerboard.o @@ -49,16 +49,16 @@ MODE7_CHECKERBOARD: mode7_checkerboard.o mode7_checkerboard.o: mode7.s checkerboard_lookup.s \ zp.inc sprites.inc \ - ../../asm_routines/gr_hlin.s \ - ../../asm_routines/multiply_fast.s \ - ../../asm_routines/gr_fast_clear.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s \ - ../../asm_routines/keypress.s \ - ../../asm_routines/gr_putsprite.s \ - ../../asm_routines/text_print.s \ - ../../asm_routines/gr_scroll.s \ - ../../asm_routines/bg_scroll.s + gr_hlin.s \ + multiply_fast.s \ + gr_fast_clear.s \ + pageflip.s \ + gr_setpage.s \ + keypress.s \ + gr_putsprite.s \ + text_print.s \ + gr_scroll.s \ + bg_scroll.s ca65 -o mode7_checkerboard.o mode7.s -D CHECKERBOARD_MAP=1 -l mode7.lst MODE7_RAINBOW: mode7_rainbow.o @@ -66,21 +66,21 @@ MODE7_RAINBOW: mode7_rainbow.o mode7_rainbow.o: mode7.s rainbow_lookup.s \ zp.inc sprites.inc \ - ../../asm_routines/multiply_fast.s \ - ../../asm_routines/gr_fast_clear.s \ - ../../asm_routines/gr_hlin.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s \ - ../../asm_routines/keypress.s \ - ../../asm_routines/gr_putsprite.s \ - ../../asm_routines/text_print.s + multiply_fast.s \ + gr_fast_clear.s \ + gr_hlin.s \ + pageflip.s \ + gr_setpage.s \ + keypress.s \ + gr_putsprite.s \ + 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 + gr_setpage.s ca65 -o plot_test.o plot_test.s -l plot_test.lst SCROLL_DEMO: scroll_demo.o @@ -88,11 +88,11 @@ SCROLL_DEMO: scroll_demo.o scroll_demo.o: scroll_demo.s \ deater_scroll.inc \ - ../../asm_routines/gr_hlin.s \ - ../../asm_routines/gr_fast_clear.s \ - ../../asm_routines/gr_scroll.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s + gr_hlin.s \ + gr_fast_clear.s \ + gr_scroll.s \ + pageflip.s \ + gr_setpage.s ca65 -o scroll_demo.o scroll_demo.s -l scroll_demo.lst SKY_DEMO: sky_demo.o @@ -100,21 +100,21 @@ SKY_DEMO: sky_demo.o sky_demo.o: sky_demo.s \ starry_sky.scroll \ - ../../asm_routines/gr_hlin.s \ - ../../asm_routines/gr_fast_clear.s \ - ../../asm_routines/gr_scroll.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s + gr_hlin.s \ + gr_fast_clear.s \ + gr_scroll.s \ + pageflip.s \ + gr_setpage.s ca65 -o sky_demo.o sky_demo.s -l sky_demo.lst STARFIELD_DEMO: starfield_demo.o ld65 -o STARFIELD_DEMO starfield_demo.o -C ./apple2_1000.inc starfield_demo.o: starfield_demo.s \ - ../../asm_routines/gr_scroll.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s \ - ../../asm_routines/gr_fast_clear.s + gr_scroll.s \ + pageflip.s \ + gr_setpage.s \ + gr_fast_clear.s ca65 -o starfield_demo.o starfield_demo.s -l starfield_demo.lst @@ -122,10 +122,10 @@ RASTERBARS: rasterbars.o ld65 -o RASTERBARS rasterbars.o -C ./apple2_1000.inc rasterbars.o: rasterbars.s \ - ../../asm_routines/gr_scroll.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s \ - ../../asm_routines/gr_fast_clear.s + gr_scroll.s \ + pageflip.s \ + gr_setpage.s \ + gr_fast_clear.s ca65 -o rasterbars.o rasterbars.s -l rasterbars.lst @@ -133,10 +133,10 @@ STARFIELD_1K: starfield_1k.o ld65 -o STARFIELD_1K starfield_1k.o -C ./apple2_1000.inc starfield_1k.o: starfield_1k.s \ - ../../asm_routines/gr_scroll.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s \ - ../../asm_routines/gr_fast_clear.s + gr_scroll.s \ + pageflip.s \ + gr_setpage.s \ + gr_fast_clear.s ca65 -o starfield_1k.o starfield_1k.s -l starfield_1k.lst @@ -144,10 +144,10 @@ TEXT_DEMO: text_demo.o ld65 -o TEXT_DEMO text_demo.o -C ./apple2_1000.inc text_demo.o: text_demo.s \ - ../../asm_routines/gr_scroll.s \ - ../../asm_routines/pageflip.s \ - ../../asm_routines/gr_setpage.s \ - ../../asm_routines/gr_fast_clear.s + gr_scroll.s \ + pageflip.s \ + gr_setpage.s \ + gr_fast_clear.s ca65 -o text_demo.o text_demo.s -l text_demo.lst scroller: scroller.o diff --git a/graphics/gr/mode7/bg_scroll.s b/graphics/gr/mode7/bg_scroll.s new file mode 100644 index 00000000..64444f24 --- /dev/null +++ b/graphics/gr/mode7/bg_scroll.s @@ -0,0 +1,79 @@ + ;================== + ; scroll background + ;================== + ; background already loaded + ; ANGLE 0-15 sets angle + ; CV is Y position to display at + ; 182/220... 220/16 = 13.75 + ; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + ; 0 11 22 34 45 56 68 79 91 102 113 125 136 147 159 170 182 + +scroll_offsets: + .byte 0,11,22,34,45,56,68,79,91,102,113,125,136,147,159,170 + +scroll_background: + ldy ANGLE ; use angle + lda scroll_offsets,Y ; lookup in table + sta OFFSET ; calculate offset + + ldx #0 + + ldy CV ; lookup Y co-ord + lsr ; and set up self-modify code + + lda gr_offsets,Y ; get position + sta bgsm1+1 + lda gr_offsets+2,Y ; get position + sta bgsm2+1 + lda gr_offsets+4,Y ; get position + sta bgsm3+1 + lda gr_offsets+6,Y ; get position + sta bgsm4+1 + + + iny + + clc + + lda gr_offsets,Y ; get position + adc DRAW_PAGE + sta bgsm1+2 + lda gr_offsets+2,Y ; get position + adc DRAW_PAGE + sta bgsm2+2 + lda gr_offsets+4,Y ; get position + adc DRAW_PAGE + sta bgsm3+2 + lda gr_offsets+6,Y ; get position + adc DRAW_PAGE + sta bgsm4+2 + + ldy OFFSET + + +bgdraw_loop: + + lda scroll_row1,Y +bgsm1: + sta $400,X + + lda scroll_row2,Y +bgsm2: + sta $480,X + + lda scroll_row3,Y +bgsm3: + sta $500,X + + lda scroll_row4,Y +bgsm4: + sta $580,X + + iny + inx + cpx #40 + bne bgdraw_loop + + rts + + diff --git a/graphics/gr/mode7/gr_fast_clear.s b/graphics/gr/mode7/gr_fast_clear.s new file mode 100644 index 00000000..e291e63f --- /dev/null +++ b/graphics/gr/mode7/gr_fast_clear.s @@ -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 diff --git a/graphics/gr/mode7/gr_hlin.s b/graphics/gr/mode7/gr_hlin.s new file mode 100644 index 00000000..29efa598 --- /dev/null +++ b/graphics/gr/mode7/gr_hlin.s @@ -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 + + diff --git a/graphics/gr/mode7/gr_offsets.s b/graphics/gr/mode7/gr_offsets.s new file mode 100644 index 00000000..f9f575be --- /dev/null +++ b/graphics/gr/mode7/gr_offsets.s @@ -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 diff --git a/graphics/gr/mode7/gr_plot.s b/graphics/gr/mode7/gr_plot.s new file mode 100644 index 00000000..1ad15895 --- /dev/null +++ b/graphics/gr/mode7/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/graphics/gr/mode7/gr_putsprite.s b/graphics/gr/mode7/gr_putsprite.s new file mode 100644 index 00000000..6aecf782 --- /dev/null +++ b/graphics/gr/mode7/gr_putsprite.s @@ -0,0 +1,101 @@ + ;============================================= + ; put_sprite + ;============================================= + ; Sprite to display in INH,INL + ; Location is XPOS,YPOS + ; Note, only works if YPOS is multiple of two? + +put_sprite: + + ldy #0 ; byte 0 is xsize ; 2 + lda (INL),Y ; 5 + sta CH ; xsize is in CH ; 3 + iny ; 2 + + lda (INL),Y ; byte 1 is ysize ; 5 + sta CV ; ysize is in CV ; 3 + iny ; 2 + + lda YPOS ; make a copy of ypos ; 3 + sta TEMPY ; as we modify it ; 3 + ;=========== + ; 28 +put_sprite_loop: + sty TEMP ; save sprite pointer ; 3 + + ldy TEMPY ; 3 + lda gr_offsets,Y ; lookup low-res memory address ; 5 + clc ; 2 + adc XPOS ; add in xpos ; 3 + sta OUTL ; store out low byte of addy ; 3 + lda gr_offsets+1,Y ; look up high byte ; 5 + adc DRAW_PAGE ; ; 3 + sta OUTH ; and store it out ; 3 + ldy TEMP ; restore sprite pointer ; 3 + + ; OUTH:OUTL now points at right place + + ldx CH ; load xsize into x ; 3 + ;=========== + ; 36 +put_sprite_pixel: + lda (INL),Y ; get sprite colors ; 5 + iny ; increment sprite pointer ; 2 + + sty TEMP ; save sprite pointer ; 3 + ldy #$0 ; 2 + + ; check if completely transparent + ; if so, skip + + cmp #$0 ; if all zero, transparent ; 2 + beq put_sprite_done_draw ; don't draw it ; 2nt/3 + ; FIXME: use BIT? ;============== + ; 17 + + sta COLOR ; save color for later ; 3 + + ; check if top pixel transparent + + and #$f0 ; check if top nibble zero ; 2 + bne put_sprite_bottom ; if not skip ahead ; 2nt/3 + + lda #$f0 ; setup mask ; 2 + sta MASK ; 3 + bmi put_sprite_mask ; 2nt/3 + +put_sprite_bottom: + lda COLOR ; re-load color ; 3 + and #$0f ; check if bottom nibble zero ; 2 + bne put_sprite_all ; if not, skip ahead ; 2nt/3 + lda #$0f ; 2 + sta MASK ; setup mask ; 3 + +put_sprite_mask: + lda (OUTL),Y ; get color at output ; 5 + and MASK ; mask off unneeded part ; 3 + ora COLOR ; or the color in ; 3 + sta (OUTL),Y ; store it back ; 5 + + jmp put_sprite_done_draw ; we are done ; 3 + +put_sprite_all: + lda COLOR ; load color ; 3 + sta (OUTL),Y ; and write it out ; 5 + + +put_sprite_done_draw: + + ldy TEMP ; restore sprite pointer ; 3 + + inc OUTL ; increment output pointer ; 5 + dex ; decrement x counter ; 2 + bne put_sprite_pixel ; if not done, keep looping ; 2nt/3 + + inc TEMPY ; each line has two y vars ; 5 + inc TEMPY ; 5 + dec CV ; decemenet total y count ; 5 + bne put_sprite_loop ; loop if not done ; 2nt/3 + + rts ; return ; 6 + diff --git a/graphics/gr/mode7/gr_scroll.s b/graphics/gr/mode7/gr_scroll.s new file mode 100644 index 00000000..d92d27ec --- /dev/null +++ b/graphics/gr/mode7/gr_scroll.s @@ -0,0 +1,195 @@ +.ifndef scroll_row1 +scroll_row1 EQU $8A00 +scroll_row2 EQU $8B00 +scroll_row3 EQU $8C00 +scroll_row4 EQU $8D00 +.endif + +SCROLL_LENGTH EQU $61 +OFFSET EQU $62 + + + ;======================== + ; scroll some text + ;======================== + ; RLE compressed data in INL/INH + ; CV is Y position to display at + +gr_scroll: + lda #0 + sta OFFSET + + ;======================= + ; decompress scroll text + ;======================= + + jsr decompress_scroll + + +scroll_loop: + + ldx #0 + + ldy CV + lsr + + lda gr_offsets,Y ; get position + sta sm1+1 + lda gr_offsets+2,Y ; get position + sta sm2+1 + lda gr_offsets+4,Y ; get position + sta sm3+1 + lda gr_offsets+6,Y ; get position + sta sm4+1 + + + iny + + clc + + lda gr_offsets,Y ; get position + adc DRAW_PAGE + sta sm1+2 + lda gr_offsets+2,Y ; get position + adc DRAW_PAGE + sta sm2+2 + lda gr_offsets+4,Y ; get position + adc DRAW_PAGE + sta sm3+2 + lda gr_offsets+6,Y ; get position + adc DRAW_PAGE + sta sm4+2 + + ldy OFFSET + +draw_loop: + + lda scroll_row1,Y +sm1: + sta $400,X + + lda scroll_row2,Y +sm2: + sta $480,X + + lda scroll_row3,Y +sm3: + sta $500,X + + lda scroll_row4,Y +sm4: + sta $580,X + + iny + inx + cpx #40 + bne draw_loop + + ;================== + ; flip pages + ;================== + + jsr page_flip ; 6 + + ;================== + ; delay + ;================== + + lda #125 + jsr WAIT + + + ;================== + ; loop forever + ;================== + clc + lda OFFSET + adc #40 + cmp SCROLL_LENGTH + beq done_scrolling + inc OFFSET + jmp scroll_loop ; 3 + +done_scrolling: + rts + + ;======================= + ; decompress scroll + ;======================= +decompress_scroll: + ldy #0 + jsr scroll_load_and_increment + sta SCROLL_LENGTH + + lda #scroll_row1 + sta OUTH + +decompress_scroll_loop: + jsr scroll_load_and_increment ; load compressed value + + cmp #$A1 ; EOF marker + beq done_decompress_scroll ; if EOF, exit + + pha ; save + + and #$f0 ; mask + cmp #$a0 ; see if special AX + beq decompress_scroll_special + + pla ; note, PLA sets flags! + + ldx #$1 ; only want to print 1 + bne decompress_scroll_run + +decompress_scroll_special: + pla + + and #$0f ; check if was A0 + + bne decompress_scroll_color ; if A0 need to read run, color + +decompress_scroll_large: + jsr scroll_load_and_increment ; get run length + +decompress_scroll_color: + tax ; put runlen into X + jsr scroll_load_and_increment ; get color + +decompress_scroll_run: + sta (OUTL),Y + pha + + clc ; increment 16-bit pointer + lda OUTL + adc #$1 + sta OUTL + lda OUTH + adc #$0 + sta OUTH + + pla + + dex ; repeat for X times + bne decompress_scroll_run + + beq decompress_scroll_loop ; get next run + +done_decompress_scroll: + rts + + +scroll_load_and_increment: + lda (INL),Y ; load and increment 16-bit pointer + pha + clc + lda INL + adc #$1 + sta INL + lda INH + adc #$0 + sta INH + pla + rts + diff --git a/graphics/gr/mode7/gr_setpage.s b/graphics/gr/mode7/gr_setpage.s new file mode 100644 index 00000000..c54bd570 --- /dev/null +++ b/graphics/gr/mode7/gr_setpage.s @@ -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 + diff --git a/graphics/gr/mode7/keypress.s b/graphics/gr/mode7/keypress.s new file mode 100644 index 00000000..e8422f2d --- /dev/null +++ b/graphics/gr/mode7/keypress.s @@ -0,0 +1,111 @@ + + ;========================================================== + ; Wait until keypressed + ;========================================================== + ; + +wait_until_keypressed: + lda KEYPRESS ; check if keypressed + bpl wait_until_keypressed ; if not, loop + jmp figure_out_key + + + ;========================================================== + ; Get Key + ;========================================================== + ; + +get_key: + +check_paddle_button: + + ; check for paddle button + + bit PADDLE_BUTTON0 ; 4 + bpl no_button ; 2nt/3 + lda #' '+128 ; 2 + jmp save_key ; 3 + +no_button: + lda KEYPRESS ; 3 + bpl no_key ; 2nt/3 + +figure_out_key: + cmp #' '+128 ; the mask destroys space ; 2 + beq save_key ; so handle it specially ; 2nt/3 + + and #$5f ; mask, to make upper-case ; 2 +check_right_arrow: + cmp #$15 ; 2 + bne check_left_arrow ; 2nt/3 + lda #'D' ; 2 +check_left_arrow: + cmp #$08 ; 2 + bne check_up_arrow ; 2nt/3 + lda #'A' ; 2 +check_up_arrow: + cmp #$0B ; 2 + bne check_down_arrow ; 2nt/3 + lda #'W' ; 2 +check_down_arrow: + cmp #$0A ; 2 + bne check_escape ; 2nt/3 + lda #'S' ; 2 +check_escape: + cmp #$1B ; 2 + bne save_key ; 2nt/3 + lda #'Q' ; 2 + jmp save_key ; 3 + +no_key: + bit PADDLE_STATUS ; 3 + bpl no_key_store ; 2nt/3 + + ; check for paddle action + ; code from http://web.pdx.edu/~heiss/technotes/aiie/tn.aiie.06.html + + inc PADDLE_STATUS ; 5 + lda PADDLE_STATUS ; 3 + and #$03 ; 2 + beq check_paddles ; 2nt/3 + jmp no_key_store ; 3 + +check_paddles: + lda PADDLE_STATUS ; 3 + and #$80 ; 2 + sta PADDLE_STATUS ; 3 + + ldx #$0 ; 2 + LDA PTRIG ;TRIGGER PADDLES ; 4 + LDY #0 ;INIT COUNTER ; 2 + NOP ;COMPENSATE FOR 1ST COUNT ; 2 + NOP ; 2 +PREAD2: LDA PADDL0,X ;COUNT EVERY 11 uSEC. ; 4 + BPL RTS2D ;BRANCH WHEN TIMED OUT ; 2nt/3 + INY ;INCREMENT COUNTER ; 2 + BNE PREAD2 ;CONTINUE COUNTING ; 2nt/3 + DEY ;COUNTER OVERFLOWED ; 2 +RTS2D: ;RETURN W/VALUE 0-255 + + cpy #96 ; 2 + bmi paddle_left ; 2nt/3 + cpy #160 ; 2 + bmi no_key_store ; 2nt/3 + lda #'D' ; 2 + jmp save_key ; 3 +paddle_left: + lda #'A' ; 2 + jmp save_key ; 3 + +no_key_store: + lda #0 ; no key, so save a zero ; 2 + +save_key: + sta LASTKEY ; save the key to our buffer ; 2 + bit KEYRESET ; clear the keyboard buffer ; 4 + rts ; 6 + ;============ + ; 33=nokey + ; 48=worstkey + + diff --git a/graphics/gr/mode7/mode7.s b/graphics/gr/mode7/mode7.s index fe9a4784..b1db4dd7 100644 --- a/graphics/gr/mode7/mode7.s +++ b/graphics/gr/mode7/mode7.s @@ -1114,18 +1114,18 @@ exit: ; External modules ;=============================================== -.include "../../asm_routines/gr_hlin.s" -.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/text_print.s" -.include "../../asm_routines/gr_offsets.s" -.include "../../asm_routines/gr_fast_clear.s" +.include "gr_hlin.s" +.include "pageflip.s" +.include "gr_setpage.s" +.include "keypress.s" +.include "gr_putsprite.s" +.include "text_print.s" +.include "gr_offsets.s" +.include "gr_fast_clear.s" .if .def(CHECKERBOARD_MAP) -.include "../../asm_routines/gr_scroll.s" -.include "../../asm_routines/bg_scroll.s" +.include "gr_scroll.s" +.include "bg_scroll.s" .endif @@ -1143,7 +1143,7 @@ exit: .include "starry_sky.scroll" .endif -.include "../../asm_routines/multiply_fast.s" +.include "multiply_fast.s" ; 8.8 fixed point diff --git a/graphics/gr/mode7/multiply_fast.s b/graphics/gr/mode7/multiply_fast.s new file mode 100644 index 00000000..f59736cc --- /dev/null +++ b/graphics/gr/mode7/multiply_fast.s @@ -0,0 +1,351 @@ +; Fast mutiply + + +; Note for our purposes we only care about 8.8 x 8.8 fixed point +; with 8.8 result, which means we only care about the middle two bytes +; of the 32 bit result. So we disable generation of the high and low byte +; to save some cycles. + +; +; The old routine took around 700 cycles for a 16bitx16bit=32bit mutiply +; This routine, at an expense of 2kB of looku tables, takes around 250 +; If you reuse a term the next time this drops closer to 200 + +; This routine was described by Stephen Judd and found +; in The Fridge and in the C=Hacking magazine +; http://codebase64.org/doku.php?id=base:seriously_fast_multiplication + +; The key thing to note is that +; (a+b)^2 (a-b)^2 +; a*b = ------- - -------- +; 4 4 +; So if you have tables of the squares of 0..511 you can lookup and subtract +; instead of multiplying. + +; Table generation: I:0..511 +; square1_lo = <((I*I)/4) +; square1_hi = >((I*I)/4) +; square2_lo = <(((I-255)*(I-255))/4) +; square2_hi = >(((I-255)*(I-255))/4) + +; Note: DOS3.3 starts at $9600 + +.ifndef square1_lo +square1_lo EQU $8E00 +square1_hi EQU $9000 +square2_lo EQU $9200 +square2_hi EQU $9400 +.endif + +; for(i=0;i<512;i++) { +; square1_lo[i]=((i*i)/4)&0xff; +; square1_hi[i]=(((i*i)/4)>>8)&0xff; +; square2_lo[i]=( ((i-255)*(i-255))/4)&0xff; +; square2_hi[i]=(( ((i-255)*(i-255))/4)>>8)&0xff; +; } + +init_multiply_tables: + + ; Build the add tables + + ldx #$00 + txa + .byte $c9 ; CMP #immediate - skip TYA and clear carry flag +lb1: tya + adc #$00 ; 0 +ml1: sta square1_hi,x ; square1_hi[0]=0 + tay ; y=0 + cmp #$40 ; subtract 64 and update flags (c=0) + txa ; a=0 + ror ; rotate +ml9: adc #$00 ; add 0 + sta ml9+1 ; update add value + inx ; x=1 +ml0: sta square1_lo,x ; square1_lo[0]=1 + bne lb1 ; if not zero, loop + inc ml0+2 ; increment values + inc ml1+2 ; increment values + clc ; c=0 + iny ; y=1 + bne lb1 ; loop + + ; Build the subtract tables based on the existing one + + ldx #$00 + ldy #$ff +second_table: + lda square1_hi+1,x + sta square2_hi+$100,x + lda square1_hi,x + sta square2_hi,y + lda square1_lo+1,x + sta square2_lo+$100,x + lda square1_lo,x + sta square2_lo,y + dey + inx + bne second_table + + + rts + + +; Fast 16x16 bit unsigned multiplication, 32-bit result +; Input: NUM1H:NUM1L * NUM2H:NUM2L +; Result: RESULT3:RESULT2:RESULT1:RESULT0 +; +; Does self-modifying code to hard-code NUM1H:NUM1L into the code +; carry=0: re-use previous NUM1H:NUM1L +; carry=1: reload NUM1H:NUM1L (58 cycles slower) +; +; clobbered: RESULT, X, A, C +; Allocation setup: T1,T2 and RESULT preferably on Zero-page. +; +; NUM1H (x_i), NUM1L (x_f) +; NUM2H (y_i), NUM2L (y_f) + +; NUM1L * NUM2L = AAaa +; NUM1L * NUM2H = BBbb +; NUM1H * NUM2L = CCcc +; NUM1H * NUM2H = DDdd +; +; AAaa +; BBbb +; CCcc +; + DDdd +; ---------- +; RESULT + +;fixed_16x16_mul_unsigned: + +multiply: + + bcc num1_same_as_last_time ; 2nt/3 + + ;============================ + ; Set up self-modifying code + ; this changes the code to be hard-coded to multiply by NUM1H:NUM1L + ;============================ + + lda NUM1L ; load the low byte ; 3 + sta sm1a+1 ; 3 + sta sm3a+1 ; 3 + sta sm5a+1 ; 3 + sta sm7a+1 ; 3 + eor #$ff ; invert the bits for subtracting ; 2 + sta sm2a+1 ; 3 + sta sm4a+1 ; 3 + sta sm6a+1 ; 3 + sta sm8a+1 ; 3 + lda NUM1H ; load the high byte ; 3 + sta sm1b+1 ; 3 + sta sm3b+1 ; 3 + sta sm5b+1 ; 3 +; sta sm7b+1 ; + eor #$ff ; invert the bits for subtractin ; 2 + sta sm2b+1 ; 3 + sta sm4b+1 ; 3 + sta sm6b+1 ; 3 +; sta sm8b+1 ; + ;=========== + ; 52 + +num1_same_as_last_time: + + ;========================== + ; Perform NUM1L * NUM2L = AAaa + ;========================== + + ldx NUM2L ; (low le) ; 3 + sec ; 2 +sm1a: + lda square1_lo,x ; 4 +sm2a: + sbc square2_lo,x ; 4 + + ; a is _aa + +; sta RESULT+0 ; + +sm3a: + lda square1_hi,x ; 4 +sm4a: + sbc square2_hi,x ; 4 + ; a is _AA + sta _AA+1 ; 3 + ;=========== + ; 24 + + ; Perform NUM1H * NUM2L = CCcc + sec ; 2 +sm1b: + lda square1_lo,x ; 4 +sm2b: + sbc square2_lo,x ; 4 + ; a is _cc + sta _cc+1 ; 3 +sm3b: + lda square1_hi,x ; 4 +sm4b: + sbc square2_hi,x ; 4 + ; a is _CC + sta _CC+1 ; 3 + ;=========== + ; 24 + + ;========================== + ; Perform NUM1L * NUM2H = BBbb + ;========================== + ldx NUM2H ; 3 + sec ; 2 +sm5a: + lda square1_lo,x ; 4 +sm6a: + sbc square2_lo,x ; 4 + ; a is _bb + sta _bb+1 ; 3 + +sm7a: + lda square1_hi,x ; 4 +sm8a: + sbc square2_hi,x ; 4 + ; a is _BB + sta _BB+1 ; 3 + ;=========== + ; 27 + + ;========================== + ; Perform NUM1H * NUM2H = DDdd + ;========================== + sec ; 2 +sm5b: + lda square1_lo,x ; 4 +sm6b: + sbc square2_lo,x ; 4 + ; a is _dd + sta _dd+1 ; 3 +;sm7b: +; lda square1_hi,x ; +;sm8b: +; sbc square2_hi,x ; + ; a = _DD +; sta RESULT+3 ; + ;=========== + ; 13 + + ;=========================================== + ; Add the separate multiplications together + ;=========================================== + + clc ; 2 +_AA: + lda #0 ; loading _AA ; 2 +_bb: + adc #0 ; adding in _bb ; 2 + sta RESULT+1 ; 3 + ;========== + ; 9 + ; product[2]=_BB+_CC+c + +_BB: + lda #0 ; loading _BB ; 2 +_CC: + adc #0 ; adding in _CC ; 2 + sta RESULT+2 ; 3 + ;=========== + ; 7 + + ; product[3]=_DD+c + +; bcc dd_no_carry1 ; +; inc RESULT+3 ; + clc ; 2 + ;============= + ; 2 +dd_no_carry1: + + ; product[1]=_AA+_bb+_cc + +_cc: + lda #0 ; load _cc ; 2 + adc RESULT+1 ; 3 + sta RESULT+1 ; 3 + + ; product[2]=_BB+_CC+_dd+c + +_dd: + lda #0 ; load _dd ; 2 + adc RESULT+2 ; 3 + sta RESULT+2 ; 3 + + ;=========== + ; 16 + ; product[3]=_DD+c + + +; bcc dd_no_carry2 ; +; inc RESULT+3 ; + + ;============= + ; 0 + +dd_no_carry2: + +; *z_i=product[1]; +; *z_f=product[0]; + +; rts ; 6 + + + ;================= + ; Signed multiply + ;================= + +;multiply: + +; jsr fixed_16x16_mul_unsigned ; 6 + + lda NUM1H ; x_i ; 3 + ;=========== + ; 12 + + + bpl x_positive ;^3/2nt + + sec ; 2 + lda RESULT+2 ; 3 + sbc NUM2L ; 3 + sta RESULT+2 ; 3 +; lda RESULT+3 ; +; sbc NUM2H ; +; sta RESULT+3 ; + ;============ + ; 10 + +x_positive: + + lda NUM2H ; y_i ; 3 + ;============ + ; ; 6 + + bpl y_positive ;^3/2nt + + + sec ; 2 + lda RESULT+2 ; 3 + sbc NUM1L ; 3 + sta RESULT+2 ; 3 +; lda RESULT+3 ; +; sbc NUM1H ; +; sta RESULT+3 ; + ;=========== + ; 10 + +y_positive: + ldx RESULT+2 ; *z_i=product[2]; ; 3 + lda RESULT+1 ; *z_f=product[1]; ; 3 + + rts ; 6 + ;========== + ; 12 + diff --git a/graphics/gr/mode7/pageflip.s b/graphics/gr/mode7/pageflip.s new file mode 100644 index 00000000..f199f5be --- /dev/null +++ b/graphics/gr/mode7/pageflip.s @@ -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 + diff --git a/graphics/gr/mode7/plot_test.s b/graphics/gr/mode7/plot_test.s index 6e0ffdb0..fcc65722 100644 --- a/graphics/gr/mode7/plot_test.s +++ b/graphics/gr/mode7/plot_test.s @@ -56,12 +56,12 @@ 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" +.include "pageflip.s" +.include "gr_setpage.s" +;.include "keypress.s" +;.include "gr_putsprite.s" +.include "gr_offsets.s" +.include "gr_fast_clear.s" +.include "gr_plot.s" diff --git a/graphics/gr/mode7/rasterbars.s b/graphics/gr/mode7/rasterbars.s index 564eebd0..e93dcf68 100644 --- a/graphics/gr/mode7/rasterbars.s +++ b/graphics/gr/mode7/rasterbars.s @@ -207,11 +207,11 @@ finish_line: ; External modules ;=============================================== -.include "../../asm_routines/pageflip.s" -.include "../../asm_routines/gr_setpage.s" -.include "../../asm_routines/gr_offsets.s" -.include "../../asm_routines/gr_fast_clear.s" -.include "../../asm_routines/gr_hlin.s" +.include "pageflip.s" +.include "gr_setpage.s" +.include "gr_offsets.s" +.include "gr_fast_clear.s" +.include "gr_hlin.s" ;====================== ; some arrays diff --git a/graphics/gr/mode7/scroll_demo.s b/graphics/gr/mode7/scroll_demo.s index ce9d3e9f..4354e0a1 100644 --- a/graphics/gr/mode7/scroll_demo.s +++ b/graphics/gr/mode7/scroll_demo.s @@ -36,11 +36,11 @@ scroll_forever: ;=============================================== ; Routines ;=============================================== -.include "../../asm_routines/gr_fast_clear.s" -.include "../../asm_routines/gr_scroll.s" -.include "../../asm_routines/pageflip.s" -.include "../../asm_routines/gr_setpage.s" -.include "../../asm_routines/gr_offsets.s" +.include "gr_fast_clear.s" +.include "gr_scroll.s" +.include "pageflip.s" +.include "gr_setpage.s" +.include "gr_offsets.s" ;=============================================== ; Variables diff --git a/graphics/gr/mode7/sky_demo.s b/graphics/gr/mode7/sky_demo.s index fc52d0ca..24d22db4 100644 --- a/graphics/gr/mode7/sky_demo.s +++ b/graphics/gr/mode7/sky_demo.s @@ -51,13 +51,13 @@ scroll_forever: ;=============================================== ; Routines ;=============================================== -.include "../../asm_routines/gr_fast_clear.s" -.include "../../asm_routines/gr_scroll.s" -.include "../../asm_routines/pageflip.s" -.include "../../asm_routines/gr_setpage.s" -.include "../../asm_routines/keypress.s" -.include "../../asm_routines/bg_scroll.s" -.include "../../asm_routines/gr_offsets.s" +.include "gr_fast_clear.s" +.include "gr_scroll.s" +.include "pageflip.s" +.include "gr_setpage.s" +.include "keypress.s" +.include "bg_scroll.s" +.include "gr_offsets.s" ;=============================================== ; Variables diff --git a/graphics/gr/mode7/starfield_1k.s b/graphics/gr/mode7/starfield_1k.s index a0abd961..24b45d57 100644 --- a/graphics/gr/mode7/starfield_1k.s +++ b/graphics/gr/mode7/starfield_1k.s @@ -280,14 +280,14 @@ clear_x: ; 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" -.include "../../asm_routines/multiply_fast.s" +.include "pageflip.s" +.include "gr_setpage.s" +;.include "keypress.s" +;.include "gr_putsprite.s" +.include "gr_offsets.s" +.include "gr_fast_clear.s" +.include "gr_plot.s" +.include "multiply_fast.s" ;====================== diff --git a/graphics/gr/mode7/starfield_demo.s b/graphics/gr/mode7/starfield_demo.s index 766897fa..5423b5bd 100644 --- a/graphics/gr/mode7/starfield_demo.s +++ b/graphics/gr/mode7/starfield_demo.s @@ -342,14 +342,14 @@ random_star: ; 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" -.include "../../asm_routines/multiply_fast.s" +.include "pageflip.s" +.include "gr_setpage.s" +.include "keypress.s" +.include "gr_putsprite.s" +.include "gr_offsets.s" +.include "gr_fast_clear.s" +.include "gr_plot.s" +.include "multiply_fast.s" .include "sprites.inc" diff --git a/graphics/gr/mode7/text_demo.s b/graphics/gr/mode7/text_demo.s index 18705f53..0d355f6e 100644 --- a/graphics/gr/mode7/text_demo.s +++ b/graphics/gr/mode7/text_demo.s @@ -318,10 +318,10 @@ thankz: ; External modules ;=============================================== -.include "../../asm_routines/pageflip.s" -.include "../../asm_routines/gr_setpage.s" -;.include "../../asm_routines/keypress.s" -.include "../../asm_routines/gr_offsets.s" -.include "../../asm_routines/gr_fast_clear.s" -.include "../../asm_routines/gr_hlin.s" -.include "../../asm_routines/text_print.s" +.include "pageflip.s" +.include "gr_setpage.s" +;.include "keypress.s" +.include "gr_offsets.s" +.include "gr_fast_clear.s" +.include "gr_hlin.s" +.include "text_print.s" diff --git a/graphics/gr/mode7/text_print.s b/graphics/gr/mode7/text_print.s new file mode 100644 index 00000000..96fa0376 --- /dev/null +++ b/graphics/gr/mode7/text_print.s @@ -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 + diff --git a/graphics/gr/rotate/Makefile b/graphics/gr/rotate/Makefile new file mode 100644 index 00000000..2f49708c --- /dev/null +++ b/graphics/gr/rotate/Makefile @@ -0,0 +1,23 @@ +include ../../Makefile.inc + +DOS33 = ../../utils/dos33fs-utils/dos33 +TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft + +all: gr.dsk + +gr.dsk: SNOW + cp empty.dsk gr.dsk + $(DOS33) -y gr.dsk BSAVE -a 0x0300 SNOW + +### + +SNOW: snow.o + ld65 -o SNOW snow.o -C ../../linker_scripts/apple2_300.inc + +snow.o: snow.s + ca65 -o snow.o snow.s -l snow.lst + +### + +clean: + rm -f *~ *.o *.lst SNOW diff --git a/graphics/gr/README b/graphics/gr/rotate/README similarity index 100% rename from graphics/gr/README rename to graphics/gr/rotate/README diff --git a/graphics/gr/empty.dsk b/graphics/gr/rotate/empty.dsk similarity index 100% rename from graphics/gr/empty.dsk rename to graphics/gr/rotate/empty.dsk diff --git a/graphics/gr/gr.dsk b/graphics/gr/rotate/gr.dsk similarity index 100% rename from graphics/gr/gr.dsk rename to graphics/gr/rotate/gr.dsk diff --git a/graphics/gr/snow.s b/graphics/gr/rotate/snow.s similarity index 100% rename from graphics/gr/snow.s rename to graphics/gr/rotate/snow.s