graphics: move some thigns around
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
@ -1,7 +1,7 @@
|
||||
all:
|
||||
cd 3d && make
|
||||
cd 3d_glasses && make
|
||||
cd dhgr && make
|
||||
cd dhgr_viewer && make
|
||||
cd dgr_viewer && make
|
||||
cd dgr && make
|
||||
cd galaxy && make
|
||||
cd gr && make
|
||||
@ -10,9 +10,9 @@ all:
|
||||
# cd hgr_viewer && make
|
||||
|
||||
clean:
|
||||
cd 3d && make clean
|
||||
cd 3d_glasses && make clean
|
||||
cd dhgr && make clean
|
||||
cd dhgr_viewer && make clean
|
||||
cd dgr_viewer && make clean
|
||||
cd dgr && make clean
|
||||
cd galaxy && make clean
|
||||
cd gr && make clean
|
||||
|
@ -1,6 +1,6 @@
|
||||
Testbeds for various graphics modes
|
||||
|
||||
+3d
|
||||
+3d_glasses
|
||||
some attempts at getting anaglyph 3d (3d graphics) working
|
||||
on Apple II. Didn't work
|
||||
|
||||
@ -10,8 +10,8 @@ Testbeds for various graphics modes
|
||||
+ dhgr
|
||||
code testing out double-hires
|
||||
|
||||
+ dhgr_viewer
|
||||
a double-hires image viewer
|
||||
+ dgr_viewer
|
||||
a double-lores image viewer
|
||||
|
||||
+ galaxy
|
||||
an implementation of a galaxy algorithm that looked cool
|
||||
|
@ -1,4 +1,4 @@
|
||||
a simple double-hires viewer
|
||||
a simple double-lores viewer
|
||||
|
||||
was used when writing my Kansasfest 2020 talk
|
||||
|
@ -5,8 +5,10 @@ TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
|
||||
|
||||
all: dhgr.dsk
|
||||
|
||||
dhgr.dsk: RASTER RASTER2 RASTER3 RASTER4 BITS LOTS
|
||||
|
||||
dhgr.dsk: HELLO RASTER RASTER2 RASTER3 RASTER4 BITS LOTS
|
||||
cp empty.dsk dhgr.dsk
|
||||
$(DOS33) -y plasma.dsk SAVE A HELLO
|
||||
$(DOS33) -y dhgr.dsk BSAVE -a 0x0300 RASTER
|
||||
$(DOS33) -y dhgr.dsk BSAVE -a 0x0300 RASTER2
|
||||
$(DOS33) -y dhgr.dsk BSAVE -a 0x0300 RASTER3
|
||||
@ -16,6 +18,11 @@ dhgr.dsk: RASTER RASTER2 RASTER3 RASTER4 BITS LOTS
|
||||
|
||||
###
|
||||
|
||||
HELLO: hello.bas
|
||||
$(TOKENIZE) < hello.bas > HELLO
|
||||
|
||||
###
|
||||
|
||||
RASTER: raster.o
|
||||
ld65 -o RASTER raster.o -C ../../linker_scripts/apple2_300.inc
|
||||
|
||||
|
2
graphics/dhgr/hello.bas
Normal file
@ -0,0 +1,2 @@
|
||||
5 HOME
|
||||
10 PRINT CHR$(4);"CATALOG"
|
7
graphics/hgr/README
Normal file
@ -0,0 +1,7 @@
|
||||
some hgr programs
|
||||
|
||||
|
||||
snowflake -- falling snowflake, used in an appleiibot demo
|
||||
|
||||
starfield -- initial work on small starfield
|
||||
|
2
graphics/hgr/snowflake/README
Normal file
@ -0,0 +1,2 @@
|
||||
code for making a falling snowflake
|
||||
|
47
graphics/hgr/snowflake/blah.c
Normal file
@ -0,0 +1,47 @@
|
||||
#include <stdio.h>
|
||||
|
||||
char data[12*6]={
|
||||
0x00,0x00,0x40,0x01,0x00,0x00,
|
||||
0x00,0x00,0x0C,0x18,0x00,0x00,
|
||||
0x00,0x00,0x70,0x07,0x00,0x00,
|
||||
0x00,0x00,0x43,0x61,0x00,0x00,
|
||||
0x00,0x00,0x4C,0x19,0x00,0x00,
|
||||
0x33,0x00,0x70,0x07,0x00,0x66,
|
||||
0x30,0x06,0x40,0x01,0x30,0x06,
|
||||
0x3f,0x06,0x40,0x01,0x30,0x7e,
|
||||
0x40,0x07,0x30,0x06,0x70,0x01,
|
||||
0x7c,0x07,0x30,0x06,0x70,0x1f,
|
||||
0x00,0x18,0x0F,0x78,0x0C,0x00,
|
||||
0x00,0x60,0x40,0x01,0x03,0x00,
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int i,j,k,b,n,total=0,min=72;
|
||||
|
||||
for(k=0;k<255;k++) {
|
||||
for(j=0;j<255;j++) {
|
||||
total=0;
|
||||
for(i=0;i<12*6;i++) {
|
||||
b=data[i];
|
||||
n=b;
|
||||
|
||||
n=n>>j;
|
||||
n=n^k;
|
||||
|
||||
// n=n/2;
|
||||
|
||||
// if ((n<0x20) || (n>0x5f)) {
|
||||
if ((n<0x20) || (n>0x7e)) {
|
||||
// printf("%x %x out of range\n",b,n);
|
||||
total++;
|
||||
}
|
||||
}
|
||||
printf("%d,%d: Total %d / %d\n",j,k,total,12*6);
|
||||
if (total<min) min=total;
|
||||
}
|
||||
}
|
||||
printf("Min=%d\n",min);
|
||||
|
||||
return 0;
|
||||
}
|
45
graphics/hgr/snowflake/blah2.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include <stdio.h>
|
||||
|
||||
char data[12*6]={
|
||||
0x00,0x00,0x40,0x01,0x00,0x00,
|
||||
0x00,0x00,0x0C,0x18,0x00,0x00,
|
||||
0x00,0x00,0x70,0x07,0x00,0x00,
|
||||
0x00,0x00,0x43,0x61,0x00,0x00,
|
||||
0x00,0x00,0x4C,0x19,0x00,0x00,
|
||||
0x33,0x00,0x70,0x07,0x00,0x66,
|
||||
0x30,0x06,0x40,0x01,0x30,0x06,
|
||||
0x3f,0x06,0x40,0x01,0x30,0x7e,
|
||||
0x40,0x07,0x30,0x06,0x70,0x01,
|
||||
0x7c,0x07,0x30,0x06,0x70,0x1f,
|
||||
0x00,0x18,0x0F,0x78,0x0C,0x00,
|
||||
0x00,0x60,0x40,0x01,0x03,0x00,
|
||||
};
|
||||
|
||||
char tokens[100];
|
||||
char freq[100];
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int i,j,b,total=0;
|
||||
|
||||
for(i=0;i<12*6;i++) {
|
||||
b=data[i];
|
||||
for(j=0;j<total;j++) {
|
||||
if (b==tokens[j]) {
|
||||
freq[j]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j==total) {
|
||||
total++;
|
||||
tokens[j]=b;
|
||||
freq[j]=1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Tokens: %d\n",total);
|
||||
for(i=0;i<total;i++) {
|
||||
printf("%d\t%x\n",freq[i],tokens[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
45
graphics/hgr/snowflake/blah3.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include <stdio.h>
|
||||
|
||||
char data[12*6]={
|
||||
0x00,0x00,0x40,0x01,0x00,0x00,
|
||||
0x00,0x00,0x0C,0x18,0x00,0x00,
|
||||
0x00,0x00,0x70,0x07,0x00,0x00,
|
||||
0x00,0x00,0x43,0x61,0x00,0x00,
|
||||
0x00,0x00,0x4C,0x19,0x00,0x00,
|
||||
0x33,0x00,0x70,0x07,0x00,0x66,
|
||||
0x30,0x06,0x40,0x01,0x30,0x06,
|
||||
0x3f,0x06,0x40,0x01,0x30,0x7e,
|
||||
0x40,0x07,0x30,0x06,0x70,0x01,
|
||||
0x7c,0x07,0x30,0x06,0x70,0x1f,
|
||||
0x00,0x18,0x0F,0x78,0x0C,0x00,
|
||||
0x00,0x60,0x40,0x01,0x03,0x00,
|
||||
};
|
||||
|
||||
int tokens[100];
|
||||
int freq[100];
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int i,j,b,total=0;
|
||||
|
||||
for(i=0;i<12*6;i+=2) {
|
||||
b=(data[i]<<8)|data[i+1];
|
||||
for(j=0;j<total;j++) {
|
||||
if (b==tokens[j]) {
|
||||
freq[j]++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j==total) {
|
||||
total++;
|
||||
tokens[j]=b;
|
||||
freq[j]=1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Tokens: %d\n",total);
|
||||
for(i=0;i<total;i++) {
|
||||
printf("%d\t%x\n",freq[i],tokens[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
34
graphics/hgr/starfield/Makefile
Normal file
@ -0,0 +1,34 @@
|
||||
include ../../../Makefile.inc
|
||||
|
||||
DOS33 = ../../../utils/dos33fs-utils/dos33
|
||||
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
|
||||
LINKER_SCRIPTS = ../../../linker_scripts
|
||||
|
||||
all: starfield.dsk
|
||||
|
||||
starfield.dsk: STARS FASTAR
|
||||
cp empty.dsk starfield.dsk
|
||||
$(DOS33) -y starfield.dsk BSAVE -a 0x0300 STARS
|
||||
$(DOS33) -y starfield.dsk BSAVE -a 0x0C00 FASTAR
|
||||
|
||||
###
|
||||
|
||||
FASTAR: fastar.o
|
||||
ld65 -o FASTAR fastar.o -C $(LINKER_SCRIPTS)/apple2_c00.inc
|
||||
|
||||
fastar.o: fastar.s
|
||||
ca65 -o fastar.o fastar.s -l fastar.lst
|
||||
|
||||
|
||||
###
|
||||
|
||||
STARS: stars.o
|
||||
ld65 -o STARS stars.o -C $(LINKER_SCRIPTS)/apple2_300.inc
|
||||
|
||||
stars.o: stars.s
|
||||
ca65 -o stars.o stars.s -l stars.lst
|
||||
|
||||
###
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o *.lst STARS FASTAR
|
2
graphics/hgr/starfield/README
Normal file
@ -0,0 +1,2 @@
|
||||
some initial work on a starfield
|
||||
|
BIN
graphics/hgr/starfield/empty.dsk
Normal file
257
graphics/hgr/starfield/fastar.s
Normal file
@ -0,0 +1,257 @@
|
||||
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
|
||||
|
||||
jmp check_bounds
|
||||
populate_loop:
|
||||
; Z = XXYY YYYY
|
||||
; C=Z*.125
|
||||
; A=A+(A-64)*C
|
||||
; B=B+(B-64)*C
|
||||
|
||||
|
||||
|
||||
; 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 X; subtract if minus
|
||||
lda MINUS
|
||||
beq not_minus
|
||||
|
||||
sec
|
||||
lda #00
|
||||
sbc NUM1
|
||||
sta NUM1
|
||||
lda #00
|
||||
sbc NUM1+1
|
||||
sta NUM1+1
|
||||
|
||||
not_minus:
|
||||
clc
|
||||
lda XL
|
||||
adc NUM1
|
||||
sta XL
|
||||
lda XH
|
||||
adc NUM1+1
|
||||
sta XH
|
||||
|
||||
; Z=Z+.125
|
||||
|
||||
clc
|
||||
lda Z
|
||||
adc #$8
|
||||
sta Z
|
||||
|
||||
|
||||
; check to see if out of bounds
|
||||
check_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:
|
||||
|
||||
|
||||
; 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
|
49
graphics/hgr/starfield/stars.s
Normal file
@ -0,0 +1,49 @@
|
||||
GBASL = $26
|
||||
GBASH = $27
|
||||
HGRPAGE = $E6
|
||||
|
||||
PAGE0 = $C054
|
||||
PAGE1 = $C055
|
||||
|
||||
HGR = $F3E2
|
||||
HGR2 = $F3D8
|
||||
HCLR = $F3F2
|
||||
HPOSN = $F411
|
||||
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
||||
|
||||
stars:
|
||||
jsr HGR
|
||||
jsr HGR2
|
||||
; lda #0
|
||||
; sta ybase
|
||||
lda #$20
|
||||
sta HGRPAGE
|
||||
|
||||
move_stars:
|
||||
lda HGRPAGE
|
||||
cmp #$20
|
||||
beq show_page1
|
||||
show_page2:
|
||||
bit PAGE1
|
||||
lsr HGRPAGE
|
||||
bne doit
|
||||
|
||||
show_page1:
|
||||
bit PAGE0
|
||||
asl HGRPAGE
|
||||
|
||||
doit:
|
||||
jsr HCLR
|
||||
|
||||
; FORI=1TO10
|
||||
; A=X(I)
|
||||
; B=Y(I)
|
||||
; C=Z(I)*.1
|
||||
; X(I)=A+(A-140)*C
|
||||
; Y(I)=B+(B-96)*C
|
||||
; Z(I)=Z(I)+.1
|
||||
; IFX(I)<0ORX(I)>279ORY(I)<0ORY(I)>191THENX(I)=RND(1)*280:Y(I)=RND(1)*192:Z(I)=0:GOTO7
|
||||
;HPLOTA,BTOX(I),Y(I)
|
||||
;NEXTI
|
||||
|
||||
jmp move_stars
|