orb: add orb

also acciedntally update a few others
This commit is contained in:
Vince Weaver 2022-02-02 00:20:56 -05:00
parent 41641d2f8d
commit dbd4351b0e
10 changed files with 588 additions and 4 deletions

View File

@ -18,6 +18,7 @@
; 510 bytes -- unneeded reload of A
; 517 bytes -- made flyer go back and forth
; 512 bytes -- removed extra cc, merged to common ZP zero init
; 510 bytes -- optimize page flip
; zero page locations
@ -81,7 +82,7 @@ tracker_song = peasant_song
; start the music playing
cli
; cli
animate_loop:
clc
@ -238,6 +239,8 @@ check_keypress:
lda KEYPRESS
bmi quiet
cli
jmp animate_loop
quiet:

53
demos/l/orb_256/Makefile Normal file
View File

@ -0,0 +1,53 @@
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
LINKERSCRIPTS = ../../../linker_scripts
EMPTYDISK = ../../../empty_disk
all: combo.dsk
$(DOS33):
cd ../../utils/dos33fs-utils && make
combo.dsk: $(DOS33) HELLO COMBO
cp $(EMPTYDISK)/empty.dsk combo.dsk
$(DOS33) -y combo.dsk SAVE A HELLO
$(DOS33) -y combo.dsk BSAVE -a 0xc00 COMBO
###
submit: combo_256.zip
combo_256.zip: BOXES boxes.s file_id.diz combo.dsk
mkdir -p lovebyte2022_combo_256
cp BOXES ./lovebyte2022_combo_256
cp boxes.s ./lovebyte2022_combo_256
cp file_id.diz ./lovebyte2022_combo_256
cp combo.dsk ./lovebyte2022_combo_256
cp combo_256_720p.mp4 ./lovebyte2022_combo_256
zip -r combo_256.zip lovebyte2022_combo_256
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
COMBO: combo.o
ld65 -o COMBO combo.o -C $(LINKERSCRIPTS)/apple2_c00.inc
combo.o: combo.s orb.s staggered.s boxes.s
ca65 -o combo.o combo.s -l combo.lst
###
clean:
rm -f *~ *.o HELLO COMBO *.lst

69
demos/l/orb_256/boxes.s Normal file
View File

@ -0,0 +1,69 @@
; boxes
; box drawing code, but we ran off the end
; we are indexing into ROM for both data and for "color" data
; zero page
YRUN = $F0
XRUN = $F1
Y1 = $F2
X1 = $F3
COLOR = $F4
boxes64:
outer_boxes:
ldx #5 ; grab 5 bytes
; YRUN, XRUN, Y1, X1, COLOR
data_smc:
lda $f180
sta YRUN-1,X ; store reverse for some reason
inc data_smc+1 ; move to next
dex
bne data_smc
lda YRUN
and #$3f
sta YRUN
rectangle_loop:
lda COLOR
; swap colors between rows
; nibble swap by david galloway
asl
adc #$80
rol
asl
adc #$80
rol
sta COLOR
and #$f
tax
jsr HCOLOR1
; lda COLORTBL,X ; index into color table
; sta HGR_COLOR ; and store
ldx X1 ; X1 into X
lda Y1 ; Y1 into A
ldy #0 ; always 0
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
lda XRUN ; XRUN into A
and #$3f
ldx #0 ; always 0
ldy #0 ; relative Y is 0
jsr HLINRL ; (X,A),(Y)
blah:
inc Y1
dec YRUN
bne rectangle_loop
beq outer_boxes ; bra

64
demos/l/orb_256/combo.s Normal file
View File

@ -0,0 +1,64 @@
; combo -- Apple II Hires
; 280 bytes -- initial combo
; 276 bytes -- shave some bytes
; zero page
GBASL = $26
GBASH = $27
; D0+ used by HGR routines
HGR_COLOR = $E4
HGR_PAGE = $E6
COUNT = $F6
XX = $F7
MINUSXX = $F8
YY = $F9
MINUSYY = $FA
D = $FB
R = $FC
FRAME = $FF
; soft-switches
KEYPRESS = $C000
KEYRESET = $C010
; ROM routines
HGR2 = $F3D8 ; set hires page2 and clear $4000-$5fff
HGR = $F3E2 ; set hires page1 and clear $2000-$3fff
HPOSN = $F411
HPLOT0 = $F457 ; plot at (Y,X), (A)
HLINRL = $F530 ; line to (X,A), (Y)
HCOLOR1 = $F6F0 ; set HGR_COLOR to value in X
COLORTBL = $F6F6
PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved)
NEXTCOL = $F85F ; COLOR=COLOR+3
SETCOL = $F864 ; COLOR=A
SETGR = $FB40 ; set graphics and clear LO-RES screen
BELL2 = $FBE4
WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
combo:
lda #$20
sta FRAME
jsr HGR2 ; after, A=0, Y=0
.include "orb.s"
.include "staggered.s"
.include "boxes.s"
even_lookup:
.byte $D7,$DD,$F5,$D5, $D5,$D5,$D5,$D5
odd_lookup:
.byte $AA,$AA,$AA,$AB, $AB,$AE,$BA,$EA

View File

@ -0,0 +1,10 @@
Stargate 128
-
128-byte Intro for Apple II, Lovebyte 2022
by Deater / dSr
Draws some lo-res stars as you approach a stargate.
Made this effect mostly by accident while trying to
convert a BASIC rectangular tunnel effect by
@hisham_hm to assembly language.

10
demos/l/orb_256/hello.bas Normal file
View File

@ -0,0 +1,10 @@
5 HOME
10 PRINT " ORB -- A 256 BYTE APPLE II INTRO"
15 PRINT " BY DEATER / DSR"
18 PRINT
20 PRINT CHR$(4)"CATALOG"
25 PRINT:PRINT "PRESS ANY KEY TO 'BRUN COMBO'"
30 GET A$
35 PRINT
40 PRINT "]BRUN COMBO"
50 PRINT CHR$(4)"BRUN COMBO"

166
demos/l/orb_256/orb.s Normal file
View File

@ -0,0 +1,166 @@
; orb
; this was found accidentally when trying to draw circles
; it's doing Bresenham circle algo I think, which does weird
; things when radius=0
; FIXME: assume hcolor is 3 somehow?
orb:
; a=0, y=0 here
tax ; x=0
dey ; set init color to white
sty HGR_COLOR ; set init color to white
draw_next:
stx R
;===============================
; draw circle
;===============================
; draw circle at (CX,CY) of radius R
; signed 8-bit math so problems if R > 64?
; XX=0 YY=R
; D=3-2*R
; GOTO6
lda #0
sta XX
; lda R
stx YY
lda #3
sec
sbc R
sbc R
sta D
; always odd, never zero
bne do_plots ; bra
circle_loop:
; X=X+1
inc XX
; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10
lda D
bmi else
dec YY
lda XX
sec
sbc YY
asl
asl
clc
adc #10
jmp store_D
else:
; ELSE D=D+4*X+6
lda XX
asl
asl
clc
adc #6
store_D:
adc D
sta D
do_plots:
; setup constants
lda XX
eor #$FF
sta MINUSXX
inc MINUSXX
lda YY
eor #$FF
sta MINUSYY
inc MINUSYY
; HPLOT CX+X,CY+Y
; HPLOT CX-X,CY+Y
; HPLOT CX+X,CY-Y
; HPLOT CX-X,CY-Y
; HPLOT CX+Y,CY+X
; HPLOT CX-Y,CY+X
; HPLOT CX+Y,CY-X
; HPLOT CX-Y,CY-X
lda #3
sta COUNT
pos_loop:
; calc left side
; calc X co-ord
lda COUNT
ora #$1
eor #$2
tay
; lda CX
lda #128
clc
adc XX,Y
tax
; calc y co-ord
ldy COUNT
; lda CY
lda #96
clc
adc XX,Y
ldy #0
jsr HPLOT0 ; plot at (Y,X), (A)
; calc right side
lda COUNT
and #$2
eor #$2
tay
lda XX,Y
asl
ldy #0
ldx #0
jsr HLINRL ; plot relative (X,A), (Y)
; so in our case (0,XX*2),0
dec COUNT
bpl pos_loop
; IFY>=XTHEN4
lda YY
cmp XX
bcs circle_loop
done:
ldx R
inx ; increment radius
jsr HCOLOR1 ; use as color
cpx #48 ; loop
beq rdone
; GOTO1
jmp draw_next
rdone:

View File

@ -0,0 +1,53 @@
staggered:
; pulse loop horizontal
lda #$00
tay
tax
sta GBASL
outer_loop:
lda #$40
sta GBASH
inner_loop:
lda even_lookup,X
sta (GBASL),Y
iny
lda odd_lookup,X
sta (GBASL),Y
iny
bne inner_loop
inc GBASH
inx
txa
and #$7
tax
lda #$60
cmp GBASH
bne inner_loop
; lda #100
jsr WAIT
inx
dec FRAME
bne outer_loop
;even_lookup:
;.byte $D7,$DD,$F5,$D5, $D5,$D5,$D5,$D5
;odd_lookup:
;.byte $AA,$AA,$AA,$AB, $AB,$AE,$BA,$EA

View File

@ -8,7 +8,7 @@ EMPTYDISK = ../../../empty_disk/empty.dsk
all: sines.dsk
sines.dsk: HELLO APPROX_SINE THICK_SINE THICK_COS TABLE_SINE ROM_SINE \
OOPS_COS OOPS2_COS OOPS3_COS OOPS4_COS ROTATE
OOPS_COS OOPS2_COS OOPS3_COS OOPS4_COS ROTATE THICK
cp $(EMPTYDISK) sines.dsk
$(DOS33) -y sines.dsk SAVE A HELLO
$(DOS33) -y sines.dsk BSAVE -a 0xc00 APPROX_SINE
@ -21,7 +21,7 @@ sines.dsk: HELLO APPROX_SINE THICK_SINE THICK_COS TABLE_SINE ROM_SINE \
$(DOS33) -y sines.dsk BSAVE -a 0x3f5 OOPS3_COS
$(DOS33) -y sines.dsk BSAVE -a 0x3f5 OOPS4_COS
$(DOS33) -y sines.dsk BSAVE -a 0x3f5 ROTATE
$(DOS33) -y sines.dsk BSAVE -a 0xc00 THICK
###
@ -55,12 +55,21 @@ thick_cos.o: thick_cos.s
###
THICK: thick.o
ld65 -o THICK thick.o -C $(LINKERSCRIPTS)/apple2_c00.inc
thick.o: thick.s
ca65 -o thick.o thick.s -l thick.lst
###
OOPS_COS: oops_cos.o
ld65 -o OOPS_COS oops_cos.o -C $(LINKERSCRIPTS)/apple2_c00.inc
oops_cos.o: oops_cos.s
ca65 -o oops_cos.o oops_cos.s -l oops_cos.lst
###
OOPS2_COS: oops2_cos.o
@ -112,7 +121,7 @@ rom_sine.o: rom_sine.s
###
clean:
rm -f *~ *.o *.lst THICK_SINE THICK_COS \
rm -f *~ *.o *.lst THICK_SINE THICK_COS THICK \
TABLE_SINE ROM_SINE APPROX_SINE \
OOPS_COS OOPS2_COS OOPS3_COS OOPS4_COS ROTATE

147
graphics/hgr/sine/thick.s Normal file
View File

@ -0,0 +1,147 @@
; thick sine
; TODO: could we get this down to 64 bytes?
; put the sine table in the zero page?
; only generate 64 bytes of 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)
; to generate sine table:
; 48 bytes -- initial implementation
;================================
; 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 ; 1
and #$f ; 2
tax ; 1
lda sinetable_base,X ; 3
sta sinetable,Y ; 3
eor #$FF ; 1
sta sinetable+32,Y ; 3
txa ; 1
eor #$FF ; 2
sec ; 1
adc #15 ; 2
tax ; 1
lda sinetable_base,X ; 3
sta sinetable+16,Y ; 3
eor #$FF ; 2
sta sinetable+48,Y ; 3
iny ; 1
cpy #$10 ; 2
bne sinetable_loop ; 2
; 37+17=54
; Y is 0 at this point?
;============================
; main loop
;============================
dey
sty HGR_COLOR ; required
; though in emulator it defaults to $FF
draw_circle:
ldy #0
sty SAVEY
blah_smc:
ldx #0
stx SAVEX
circle_loop:
lda SAVEX
and #$3f
tax
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
;sinetable_base=$F5BA