From a25a133d6d8f3bd53bacabee6faed5de77521547 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 23 Nov 2021 22:15:05 -0500 Subject: [PATCH] hgr: thick_sine demo --- basic/appleiibot/Makefile | 8 +- basic/appleiibot/thick_sine.bas | 2 + graphics/hgr/plasma/Makefile | 14 +++- graphics/hgr/plasma/thick_sine.s | 133 +++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 basic/appleiibot/thick_sine.bas create mode 100644 graphics/hgr/plasma/thick_sine.s diff --git a/basic/appleiibot/Makefile b/basic/appleiibot/Makefile index 03d088f3..88d1c7b7 100644 --- a/basic/appleiibot/Makefile +++ b/basic/appleiibot/Makefile @@ -19,7 +19,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \ GATOR.BAS CURSOR.BAS STARGATE.BAS TUNNEL.BAS STARFIELD.BAS \ STAROOPS.BAS HGRSTARFIELD.BAS COOL_BOT.BAS WEB.BAS ORB.BAS \ FIREWORKS.BAS THINKING.BAS ARCS.BAS WIRE_HGR.BAS STATIC.BAS \ - OVAL.BAS OVAL_HGR.BAS MOVING.BAS + OVAL.BAS OVAL_HGR.BAS MOVING.BAS THICK_SINE.BAS # cp $(EMPTY_DISK)/empty.dsk appleiibot.dsk cp empty.dsk appleiibot.dsk @@ -102,6 +102,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \ $(DOS33) -y appleiibot.dsk SAVE A OVAL.BAS $(DOS33) -y appleiibot.dsk SAVE A OVAL_HGR.BAS $(DOS33) -y appleiibot.dsk SAVE A MOVING.BAS + $(DOS33) -y appleiibot.dsk SAVE A THICK_SINE.BAS #### @@ -231,6 +232,11 @@ SNOW.BAS: snow.bas #### +THICK_SINE.BAS: thick_sine.bas + $(TOKENIZE) < thick_sine.bas > THICK_SINE.BAS + +#### + MOVE.BAS: move.bas $(TOKENIZE) < move.bas > MOVE.BAS diff --git a/basic/appleiibot/thick_sine.bas b/basic/appleiibot/thick_sine.bas new file mode 100644 index 00000000..00235dd1 --- /dev/null +++ b/basic/appleiibot/thick_sine.bas @@ -0,0 +1,2 @@ +1FORI=0TO102:POKE1013+I,4*PEEK(2126+I)-204+(PEEK(2229+I/3)-35)/4^(I-INT(I/3)*3):NEXT +2&"/foL:Be;569e7W4>qM5\bE4=S3EqM3Y3KYdjS1Tr[3Ip\qb3C75EI\r[38Hpbpljeml94Vq=5bBa3\_BrTlF943-35/5768959:+7:;SW$@#@;&3*$SE%O)CD&/MF-?+5a# diff --git a/graphics/hgr/plasma/Makefile b/graphics/hgr/plasma/Makefile index e745f9cb..6d12dc66 100644 --- a/graphics/hgr/plasma/Makefile +++ b/graphics/hgr/plasma/Makefile @@ -8,9 +8,10 @@ EMPTYDISK = ../../../empty_disk/empty.dsk all: plasma_hgr.dsk plasma_hgr.dsk: HELLO OVAL PURPLE_WAVES ZEBRA JAWS TWIST OVAL_FLIP MOVING \ - MIRROR + MIRROR THICK_SINE cp $(EMPTYDISK) plasma_hgr.dsk $(DOS33) -y plasma_hgr.dsk SAVE A HELLO + $(DOS33) -y plasma_hgr.dsk BSAVE -a 0x3F5 THICK_SINE $(DOS33) -y plasma_hgr.dsk BSAVE -a 0xc00 OVAL $(DOS33) -y plasma_hgr.dsk BSAVE -a 0xc00 PURPLE_WAVES $(DOS33) -y plasma_hgr.dsk BSAVE -a 0xc00 ZEBRA @@ -43,6 +44,14 @@ oval_flip.o: oval_flip.s ### +THICK_SINE: thick_sine.o + ld65 -o THICK_SINE thick_sine.o -C $(LINKERSCRIPTS)/apple2_3f5.inc + +thick_sine.o: thick_sine.s + ca65 -o thick_sine.o thick_sine.s -l thick_sine.lst + +### + MOVING: moving.o ld65 -o MOVING moving.o -C $(LINKERSCRIPTS)/apple2_3f5.inc @@ -96,5 +105,6 @@ purple_waves.o: purple_waves.s ### clean: - rm -f *~ *.o *.lst OVAL PURPLE_WAVES ZEBRA JAWS TWIST OVAL_FLIP + rm -f *~ *.o *.lst OVAL PURPLE_WAVES ZEBRA JAWS TWIST OVAL_FLIP \ + THICK_SINE diff --git a/graphics/hgr/plasma/thick_sine.s b/graphics/hgr/plasma/thick_sine.s new file mode 100644 index 00000000..5917bc45 --- /dev/null +++ b/graphics/hgr/plasma/thick_sine.s @@ -0,0 +1,133 @@ +; thick sine + + +; zero page +GBASL = $26 +GBASH = $27 +YY = $69 +ROW_SUM = $70 + +HGR_X = $E0 +HGR_XH = $E1 +HGR_Y = $E2 +HGR_COLOR = $E4 +HGR_PAGE = $E6 + +FRAME = $FC +SUM = $FD +SAVEX = $FE +SAVEY = $FF + +; soft-switches +FULLGR = $C052 +PAGE1 = $C054 + +; ROM routines + +HGR2 = $F3D8 +HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y) +HPLOT0 = $F457 ; plot at (Y,X), (A) + + ;================================ + ; Clear screen and setup graphics + ;================================ +thick_sine: + + jsr HGR2 ; set hi-res 140x192, page2, fullscreen + ; A and Y both 0 at end + ;================== + ; create sinetable + + ;ldy #0 ; Y is 0 +sinetable_loop: + tya ; 2 + and #$3f ; wrap sine at 63 entries ; 2 + + cmp #$20 + php ; save pos/negative for later + + and #$1f + + cmp #$10 + bcc sin_left ; blt + +sin_right: + ; sec carry should be set here + eor #$FF + adc #$20 ; 32-X +sin_left: + tax + lda sinetable_base,X ; 4+ + + plp + bcc sin_done + +sin_negate: + ; carry set here + eor #$ff + adc #0 ; FIXME: this makes things off by 1 + +sin_done: + sta sinetable,Y + + iny + bne sinetable_loop + + + ;============================ + ; main loop + ;============================ + +draw_circle: + +blah_smc: + ldx #0 + stx SAVEX + + ldy #0 + sty SAVEY + +circle_loop: + ldx SAVEX +; ldy sinetable,X +; sty SAVEY + lda sinetable,X + clc + asl + ; $60 is midscreen + adc #$60 + ldx SAVEY + ldy #0 + + jsr HPLOT0 ; plot at (Y,X), (A) + + inc SAVEX + inc SAVEY + bne circle_loop + +done: + inc blah_smc+1 + + lda SAVEX + and #$3f + cmp #$3f + bne blah + lda HGR_COLOR + eor #$ff + sta HGR_COLOR +blah: + + jmp draw_circle + + +sinetable_base: +; this is actually (32*sin(x)) +.byte $00,$03,$06,$09,$0C,$0F,$11,$14 +.byte $16,$18,$1A,$1C,$1D,$1E,$1F,$1F +.byte $20 + + ; for bot + ; 3F5 - 7d = 378 +; jmp oval + +sinetable=$6000