appleiibot: star nonsense

This commit is contained in:
Vince Weaver 2020-11-10 13:37:14 -05:00
parent 1614d35d1e
commit ffc852641f
5 changed files with 338 additions and 53 deletions

View File

@ -11,9 +11,10 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS \
RASTER4.BAS RASTER5.BAS PUMPKIN.BAS PUMPKIN_SMALL.BAS LADY.BAS \
A2.BAS FOURAM.BAS FLOPPY.BAS QR.BAS A2_4EVER.BAS RLE.BAS RLE2.BAS \
RLEASM.BAS HORIZON.BAS FLYER.BAS STAR.BAS HYPER.BAS FASTAR.BAS \
FASTAR2.BAS
FASTAR2.BAS FASTAR2
cp empty.dsk appleiibot.dsk
$(DOS33) -y appleiibot.dsk BSAVE -a 0x0300 LOAD
$(DOS33) -y appleiibot.dsk BSAVE -a 0x0C00 FASTAR2
$(DOS33) -y appleiibot.dsk SAVE A E2.BAS
$(DOS33) -y appleiibot.dsk SAVE A FLAME.BAS
$(DOS33) -y appleiibot.dsk SAVE A FLAME2.BAS
@ -91,6 +92,15 @@ LOAD: load.o
load.o: load.s
ca65 -o load.o load.s -l load.lst
###
FASTAR2: fastar2.o
ld65 -o FASTAR2 fastar2.o -C ../linker_scripts/apple2_c00.inc
fastar2.o: fastar2.s
ca65 -o fastar2.o fastar2.s -l fastar2.lst
####
QKUMBA2.BAS: qkumba_seasons.bas

View File

@ -1,8 +1,6 @@
0 DIMX(8,20),Y(8,20)
1FORJ=1TO20:FORI=1TO8:A=X(I,J-1):B=Y(I,J-1):C=Z(I)*.1:X(I,J)=A+(A-140)*C:Y(I,J)=B+(B-96)*C:Z(I)=Z(I)+.1
2IFX(I,J)<1ORX(I,J)>279ORY(I,J)<1ORY(I,J)>191THENX(I,J)=RND(1)*280:Y(I,J)=RND(1)*192:Z(I)=0
3NEXTI,J
4HGR:HGR2:HCOLOR=3
5FORJ=1TO20:POKE230,32+32*P:P=NOTP:POKE49236+P,0:CALL-3086
6FORI=1TO8:HPLOTX(I,J-1),Y(I,J-1)TOX(I,J),Y(I,J)
8NEXTI,J:GOTO5
0R=191:DIMX(R),Y(R):FORI=1TOR:C=Z*.1:A=A+(A-140)*C:B=B+(B-96)*C:Z=Z+.1
2IFA<1ORA>279ORB<1ORB>RTHENI=I+1:A=RND(1)*280:B=RND(1)*R:Z=0
3X(I)=A:Y(I)=B:NEXT:HGR2
5FORJ=1TOR:POKE230,32+32*P:P=NOTP:POKE49236+P,0:CALL-3086
6A=X(J-1):IFAANDX(J)THENHPLOTA,Y(J-1)TOX(J),Y(J)
8NEXT:GOTO5

239
appleiibot/fastar2.s Normal file
View File

@ -0,0 +1,239 @@
DRAW_PAGE = $E6
ZL = $06
ZH = $07
SEEDLO = $4E
SEEDHI = $4F
NUM1 = $F0
NUM1L = $F1
NUM2 = $F2
NUM2L = $F3
RESULT = $F4
RESULT2 = $F5
RESULT3 = $F6
RESULT4 = $F7
XL = $F8
XH = $F9
YL = $FA
YH = $FB
MINUS = $FC
Z = $FD
HGR2 = $F3D8
HPLOT0 = $F457 ; plot (Y,X), (A)
HGLIN = $F53A ; plot to (A,X), (Y)
HCLEAR0 = $F3F2 ; clear current hgr page to blackh
HCOLOR = $F6F0 ; color in X (must be 0..7)
lda #$ff
sta XH
ldx #0
populate_loop:
; Z = XXYY YYYY
; C=Z*.125
; A=A+(A-64)*C
; B=B+(B-64)*C
; check to see if out of bounds
lda XH
bmi redo_point
lda YH
bpl all_good
redo_point:
; store a break in the lines
lda #0
sta $1000,X
sta $1100,X
sta Z ; needed?
inx
jsr rand16
sta XH
jsr rand16
sta YH
all_good:
; X is in NUM1 for this
lda #0
sta MINUS
sec
lda XH
sbc #64
bpl no_minus
set_minus:
inc MINUS
sec
lda #0
sbc XL
sta NUM1
lda #0
sbc XH
sta NUM1+1
jmp do_mult
no_minus:
sta NUM1+1
lda XL
sta NUM1
do_mult:
lda #0
sta NUM2+1
lda Z
sta NUM2
txa
pha
jsr mult16
pla
tax
; result has result but due to our fixed point
; we want to shift the whole thing left by 2
; then grab RESULT+2 as high and RESULT+1 as low
rol RESULT+1
rol RESULT+2
ror RESULT+1
lda RESULT+2
lda RESULT+1 ; low
sta NUM1
lda RESULT+2 ; hight
sta NUM1+1
; add to AA
clc
lda XL
adc NUM1
sta XL
lda XH
adc NUM1+1
sta XH
; Z=Z+.125
clc
lda Z
adc #$8
sta Z
; write out
lda XH
sta $1000,X
lda YH
sta $1100,X
inx
beq done_pop
jmp populate_loop
done_pop:
;=========================
;=========================
;=========================
jsr HGR2
ldx #3
jsr HCOLOR
ldx #0
star_loop:
txa
and #$1
beq page2
page1: ; draw page1, show page2
bit $C055
lda #$20
bne adjust_page
page2:
bit $C054
lda #$40
adjust_page:
sta DRAW_PAGE
; clear background
jsr HCLEAR0
txa
pha
lda $1100,X ; ycoord
beq skip_draw
pha
ldy $1000,X ; xcoord
tya
tax
ldy #0
pla
jsr HPLOT0 ; plot (Y,X), (A)
skip_draw:
pla
tax
inx
jmp star_loop
; make sure seed isn't 0000
rand16:
; batari rand16
lda SEEDHI
lsr
rol SEEDLO
bcc noeor
eor #$B4
noeor:
sta SEEDHI
eor SEEDLO
; we only want 127 bits
and #$7f
rts
;=====================
;=====================
; 16x16 -> 32 multiply
;=====================
;=====================
; destroys NUM2
mult16:
lda #0 ; Initialize RESULT to 0
sta RESULT+2
ldx #16 ; There are 16 bits in NUM2
L1:
lsr NUM2+1 ; top part of 16 bit shift right
ror NUM2
bcc L2 ; 0 or 1?
tay ; If 1, add NUM1 (hi byte of RESULT is in A)
clc
lda NUM1
adc RESULT+2
sta RESULT+2
tya
adc NUM1+1
L2:
ror ; "Stairstep" shift
ror RESULT+2
ror RESULT+1
ror RESULT
dex
bne L1
sta RESULT+3
rts

32
appleiibot/mul16_slow.s Normal file
View File

@ -0,0 +1,32 @@
; from http://nparker.llx.com/a2/mult.html
;=====================
;=====================
; 16x16 -> 32 multiply
;=====================
;=====================
mul16_slow:
lda #0 ; Initialize RESULT to 0
sta RESULT+2
ldx #16 ; There are 16 bits in NUM2
L1:
lsr NUM2+1 ; Get low bit of NUM2 into C
ror NUM2
bcc L2 ; 0 or 1?
tay ; If 1, add NUM1 (hi byte of RESULT is in A)
clc
lda NUM1
adc RESULT+2
sta RESULT+2
tya
adc NUM1+1
L2:
ror ; "Stairstep" shift
ror RESULT+2
ror RESULT+1
ror RESULT
dex
bne L1
sta RESULT+3
rts

View File

@ -14,8 +14,8 @@ int main(int argc, char **argv) {
double outputx[SIZE][REPEAT];
double outputy[SIZE][REPEAT];
for(j=1;j<REPEAT;j++) {
for(i=1;i<SIZE;i++) {
for(j=1;j<REPEAT;j++) {
a=x[i];
b=y[i];
c=z[i]*speed;
@ -24,21 +24,27 @@ int main(int argc, char **argv) {
z[i]=z[i]+speed;
if ((x[i]<0) || (x[i]>279) || (y[i]<0) || (y[i]>191)) {
x[i]=0;
y[i]=0;
i++;
x[i]=rand()%279;
y[i]=rand()%191;
z[i]=0;
}
else {
outputx[i][j]=x[i];
outputy[i][j]=y[i];
// outputx[i][j]=x[i];
// outputy[i][j]=y[i];
//
}
printf("%i:%i: %.1f %.1f %.2f\n",i,j,x[i],y[i],z[i]);
}
}
for(i=1;i<SIZE;i++) {
for(j=1;j<REPEAT;j++) {
printf("%i:%i: %.1f %.1f\n",i,j,outputx[i][j],outputy[i][j]);
}
}
// for(i=1;i<SIZE;i++) {
// for(j=1;j<REPEAT;j++) {
// printf("%i:%i: %.1f %.1f\n",i,j,outputx[i][j],outputy[i][j]);
// }
// }
return 0;
}