From cf89975085eb8149f09d76e1fc8c47d3aa28827a Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Mon, 1 Mar 2021 12:56:56 -0500 Subject: [PATCH] text: add notamoon --- textmode/README | 10 ++ textmode/notamoon/Makefile | 32 ++++++ textmode/notamoon/apple2_70_zp.inc | 12 ++ textmode/notamoon/hello.bas | 2 + textmode/notamoon/notamoon.s | 174 +++++++++++++++++++++++++++++ textmode/notamoon/notamoon_big.s | 167 +++++++++++++++++++++++++++ 6 files changed, 397 insertions(+) create mode 100644 textmode/README create mode 100644 textmode/notamoon/Makefile create mode 100644 textmode/notamoon/apple2_70_zp.inc create mode 100644 textmode/notamoon/hello.bas create mode 100644 textmode/notamoon/notamoon.s create mode 100644 textmode/notamoon/notamoon_big.s diff --git a/textmode/README b/textmode/README new file mode 100644 index 00000000..28f99d5c --- /dev/null +++ b/textmode/README @@ -0,0 +1,10 @@ +various programs using textmode on Apple II + ++ notamoon + Moustext death star demo + ++ moustext + Using mousetext on Apple IIe enhanced+ + ++ textflip + text flipping effect diff --git a/textmode/notamoon/Makefile b/textmode/notamoon/Makefile new file mode 100644 index 00000000..393a15b5 --- /dev/null +++ b/textmode/notamoon/Makefile @@ -0,0 +1,32 @@ +include ../../Makefile.inc + +DOS33 = ../../utils/dos33fs-utils/dos33 +TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft +LINKERSCRIPTS = ../../linker_scripts +EMPTYDISK = ../../empty_disk/empty.dsk + +all: notamoon.dsk + +notamoon.dsk: HELLO NOTAMOON + cp $(EMPTYDISK) notamoon.dsk + $(DOS33) -y notamoon.dsk SAVE A HELLO + $(DOS33) -y notamoon.dsk BSAVE -a 0x70 NOTAMOON + +### + +HELLO: hello.bas + $(TOKENIZE) < hello.bas > HELLO + +### + +NOTAMOON: notamoon.o + ld65 -o NOTAMOON notamoon.o -C ./apple2_70_zp.inc + +notamoon.o: notamoon.s + ca65 -o notamoon.o notamoon.s -l notamoon.lst + + +### + +clean: + rm -f *~ *.o *.lst HELLO NOTAMOON notamoon.dsk diff --git a/textmode/notamoon/apple2_70_zp.inc b/textmode/notamoon/apple2_70_zp.inc new file mode 100644 index 00000000..9737f2d1 --- /dev/null +++ b/textmode/notamoon/apple2_70_zp.inc @@ -0,0 +1,12 @@ +MEMORY { + ZP: start = $70, size = $90, type = rw; + RAM: start = $70, size = $8E00, file = %O; +} + +SEGMENTS { +#CODE: load = RAM, type = ro; +#RODATA: load = RAM, type = ro; +#DATA: load = RAM, type = rw; +#BSS: load = RAM, type = bss, define = yes; +ZEROPAGE: load = ZP, type = ro; +} diff --git a/textmode/notamoon/hello.bas b/textmode/notamoon/hello.bas new file mode 100644 index 00000000..133a44bb --- /dev/null +++ b/textmode/notamoon/hello.bas @@ -0,0 +1,2 @@ +5 HOME +10 PRINT CHR$(4);"CATALOG" diff --git a/textmode/notamoon/notamoon.s b/textmode/notamoon/notamoon.s new file mode 100644 index 00000000..10d45211 --- /dev/null +++ b/textmode/notamoon/notamoon.s @@ -0,0 +1,174 @@ +; That's not a moon.... + +; by Vince `deater` Weaver, dSr, Lovebyte 2021 + +; based on the following BASIC program + +; 1HOME:POKE49167,0 +; 2FORX=0TO64:POKE1024+RND(1)*999,174:NEXT +; 3FORI=0TO1:COLOR=6-I:FORJ=0TO1 +; 4HLIN8,10AT6+J*10+I:HLIN7,11AT8+J*6+I:HLIN6,12AT10+J*2+I:NEXTJ,I +; 6VTAB6:HTAB11:?"()" +; 7FORX=13TO37:POKE1063+X,90:POKE1064+X,91:POKE1065+X,95 +; 8FORI=1TO200:NEXT:VTAB9:HTABX:?" ":NEXT +; 9GOTO7 + +; 167 -- initial implementation +; 170 -- smooth grey support +; 152 -- make death star data byte array +; 148 -- make death star VTAB not hardcoded +; 144 -- move to zero page +; 136 -- index into ROM for "random" numbers +; 133 -- optimize star placement +; 131 -- note when X already 0 +; 130 -- optimize tie erase +; 126 -- more optimize death star drawing +; 124 -- use the DEC CV the instruction before VTAB + +; need 124 for lovebyte + +; zero page +CV = $25 +BASL = $28 +BASH = $29 +SEEDL = $4E +INL = $66 +INH = $67 + +; soft-switches +MOUSETEXT = $C00F ; (write) to enable mouse text + +; rom routines +HOME = $FC58 ; Clear the text screen +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us +VTAB = $FC22 ; calc screen position in CV, put in (BASL) +VTABZ = $FC24 ; calc screen position in A, put in (BASL) + +.zeropage +.globalzp grey_smc,ds_data,star_store_smc,tie_data + + ;======================= + ; Clear screen and setup + ;======================= +sw: + + jsr HOME ; clear the screen + sta MOUSETEXT ; enable mouse text + + ;======================= + ; Display Stars + ;======================= + + ldx #64 +star_loop: + lda $F100,X + eor $F300,X ; fake random + tay + + lda $F800,X + eor $F900,X ; more fake random + and #$3 + ora #$4 + sta star_store_smc+2 + + lda #'.'|$80 +star_store_smc: + sta $400,Y + dex + bne star_loop + + ;======================= + ; Display Death Star + ;======================= + +; ldx #0 ; X already 0 + lda #9 ; count backwards + sta CV +ds_loop: + ;============================ + ; draw grey line + ;============================ +grey_line: + jsr $FC20 ; this is a DEC CV line before VTAB +; jsr VTAB ; position VTAB based on CV + sec + lda #19 + sbc ds_data,X + sta grey_smc+1 + ldy ds_data,X + +; inx +; lda ds_data,X +; sta grey_smc+1 + inx +grey_loop: + clc + tya + and #$1 + adc #$56 ; make it an even grey + sta (BASL),Y + iny +grey_smc: + cpy #0 + bne grey_loop +; inc CV + cpx #6 + bne ds_loop + + ; draw reflector + lda #'('+$80 ; 5,10? + sta $68A + lda #')'+$80 ; 5,11? + sta $68B + + + ;======================= + ; Draw Tie Fighter + ;======================= + +tie_loop: + ldy #12 + +tie_move: + + ; draw tie + + ldx #2 +xloop1: + lda tie_data,X + sta $428,Y ; line 8 (vtab 9) + iny + dex + bpl xloop1 + + ; delay a bit + lda #200 + jsr WAIT + + ; erase + + lda #$A0 ; space (the final frontier) +xloop2: + dey + sta $428,Y ; line 8 (vtab 9) + inx + cpx #2 + bne xloop2 + + iny + cpy #38 + bne tie_move + + beq tie_loop + +tie_data: +.byte 95,91,90 + + +ds_data: +.byte 8;,11 +.byte 7;,12 +.byte 6;,13 +.byte 6;,13 +.byte 7;,12 +.byte 8;,11 diff --git a/textmode/notamoon/notamoon_big.s b/textmode/notamoon/notamoon_big.s new file mode 100644 index 00000000..98eebf04 --- /dev/null +++ b/textmode/notamoon/notamoon_big.s @@ -0,0 +1,167 @@ +; death star? + +; by Vince `deater` Weaver, dSr, Lovebyte 2021 + +; based on the following BASIC program + +; 1HOME:POKE49167,0 +; 2FORX=0TO64:POKE1024+RND(1)*999,174:NEXT +; 3FORI=0TO1:COLOR=6-I:FORJ=0TO1 +; 4HLIN8,10AT6+J*10+I:HLIN7,11AT8+J*6+I:HLIN6,12AT10+J*2+I:NEXTJ,I +; 6VTAB6:HTAB11:?"()" +; 7FORX=13TO37:POKE1063+X,90:POKE1064+X,91:POKE1065+X,95 +; 8FORI=1TO200:NEXT:VTAB9:HTABX:?" ":NEXT +; 9GOTO7 + +; 167 -- initial implementation +; 170 -- smooth grey support +; 152 -- make death star data byte array +; 148 -- make death star VTAB not hardcoded + +; zero page +CV = $25 +BASL = $28 +BASH = $29 +SEEDL = $4E +INL = $66 +INH = $67 +;LINE = $68 +;MAXX = $69 + +; soft-switches +MOUSETEXT = $C00F ; (write) to enable mouse text + +; rom routines +HOME = $FC58 ; Clear the text screen +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us +VTAB = $FC22 ; calc screen position in CV, put in (BASL) +VTABZ = $FC24 ; calc screen position in A, put in (BASL) + + ;======================= + ; Clear screen and setup + ;======================= +sw: + + jsr HOME ; clear the screen + sta MOUSETEXT ; enable mouse text + + ;======================= + ; Display Stars + ;======================= + + ldx #64 + ldy #0 +star_loop: + jsr random8 + sta BASL + + jsr random8 + and #$3 + clc + adc #$4 + sta BASH + lda #'.'|$80 + sta (BASL),Y + dex + bne star_loop + + ;======================= + ; Display Death Star + ;======================= + + ldx #0 + lda #3 + sta CV +ds_loop: + ;============================ + ; draw grey line + ;============================ +grey_line: + jsr VTAB ; position VTAB based on CV + ldy ds_data,X + inx + lda ds_data,X + sta grey_smc+1 + inx +grey_loop: + clc + tya + and #$1 + adc #$56 ; make it an even grey + sta (BASL),Y + iny +grey_smc: + cpy #0 + bne grey_loop + inc CV + cpx #12 + bne ds_loop + + ; draw reflector + lda #'('+$80 ; 5,10? + sta $68A + lda #')'+$80 ; 5,11? + sta $68B + + + ;======================= + ; Draw Tie Fighter + ;======================= + +tie_loop: + ldx #12 +tie_move: + ; draw + lda #90 + sta $428,X ; line 8 (vtab 9) + lda #91 + sta $429,X + lda #95 + sta $42A,X + + ; delay a bit + lda #200 + jsr WAIT + + ; erase + lda #' '|$80 + sta $428,X + sta $429,X + sta $42A,X + + inx + cpx #38 + bne tie_move + + jmp tie_loop + + + ;============================= + ; random8 + ;============================= + ; 8-bit 6502 Random Number Generator + ; Linear feedback shift register PRNG by White Flame + ; http://codebase64.org/doku.php?id=base:small_fast_8-bit_prng + +random8: + lda SEEDL ; 2 + beq doEor ; 2 + asl ; 1 + beq noEor ; if the input was $80, skip the EOR ; 2 + bcc noEor ; 2 +doEor: + eor #$1d ; 2 +noEor: + sta SEEDL + rts + + + + +ds_data: +.byte 8,11 +.byte 7,12 +.byte 6,13 +.byte 6,13 +.byte 7,12 +.byte 8,11