demos: more work

keep making git mistakes urgh
This commit is contained in:
Vince Weaver 2021-01-05 22:52:10 -05:00
parent 8c445868b5
commit e0febd1a90
341 changed files with 1880 additions and 624 deletions

2
demos/TODO Normal file
View File

@ -0,0 +1,2 @@
lores_escape -- get the mockingboard access under 10 cycles

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,10 +1,12 @@
include ../Makefile.inc
include ../../Makefile.inc
DOS33 = ../../utils/dos33fs-utils/dos33
PNG_TO_40x96 = ../../utils/gr-utils/png_to_40x96
PNG_TO_40x48D = ../../utils/gr-utils/png_to_40x48d
PNG2RLE = ../../utils/gr-utils/png2rle
B2D = ../../utils/bmp2dhr/b2d
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
DOS33 = ../dos33fs-utils/dos33
PNG_TO_40x96 = ../gr-utils/png_to_40x96
PNG_TO_40x48D = ../gr-utils/png_to_40x48d
PNG2RLE = ../gr-utils/png2rle
B2D = ../bmp2dhr/b2d
all: memories.dsk
@ -23,13 +25,13 @@ memories.dsk: HELLO CIRCLES.BAS CIRCLES CHECKERS CHECKERS_SMALL PLANE \
$(DOS33) -y memories.dsk BSAVE -a 0x300 CIRCLES_NORMAL
CIRCLES: circles.o
ld65 -o CIRCLES circles.o -C ../linker_scripts/apple2_70_zp.inc
ld65 -o CIRCLES circles.o -C ../../linker_scripts/apple2_70_zp.inc
circles.o: circles.s
ca65 -o circles.o circles.s -l circles.lst
CIRCLES_NORMAL: circles_normal.o
ld65 -o CIRCLES_NORMAL circles_normal.o -C ../linker_scripts/apple2_300.inc
ld65 -o CIRCLES_NORMAL circles_normal.o -C ../../linker_scripts/apple2_300.inc
circles_normal.o: circles_normal.s
ca65 -o circles_normal.o circles_normal.s -l circles_normal.lst
@ -37,7 +39,7 @@ circles_normal.o: circles_normal.s
###
CHECKERS: checkers.o
ld65 -o CHECKERS checkers.o -C ../linker_scripts/apple2_70_zp.inc
ld65 -o CHECKERS checkers.o -C ../../linker_scripts/apple2_70_zp.inc
checkers.o: checkers.s
ca65 -o checkers.o checkers.s -l checkers.lst
@ -45,7 +47,7 @@ checkers.o: checkers.s
###
PLANE: plane.o
ld65 -o PLANE plane.o -C ../linker_scripts/apple2_1000.inc
ld65 -o PLANE plane.o -C ../../linker_scripts/apple2_1000.inc
plane.o: plane.s
ca65 -o plane.o plane.s -l plane.lst
@ -53,7 +55,7 @@ plane.o: plane.s
###
SIER: sier.o
ld65 -o SIER sier.o -C ../linker_scripts/apple2_1000.inc
ld65 -o SIER sier.o -C ../../linker_scripts/apple2_1000.inc
sier.o: sier.s fast_plot.s
ca65 -o sier.o sier.s -l sier.lst
@ -61,7 +63,7 @@ sier.o: sier.s fast_plot.s
###
TUNNEL: tunnel.o
ld65 -o TUNNEL tunnel.o -C ../linker_scripts/apple2_1000.inc
ld65 -o TUNNEL tunnel.o -C ../../linker_scripts/apple2_1000.inc
tunnel.o: tunnel.s
ca65 -o tunnel.o tunnel.s -l tunnel.lst
@ -69,7 +71,7 @@ tunnel.o: tunnel.s
###
TNM: tunnel_nm.o
ld65 -o TNM tunnel_nm.o -C ../linker_scripts/apple2_1000.inc
ld65 -o TNM tunnel_nm.o -C ../../linker_scripts/apple2_1000.inc
tunnel_nm.o: tunnel_nm.s
ca65 -o tunnel_nm.o tunnel_nm.s -l tunnel_nm.lst
@ -79,7 +81,7 @@ tunnel_nm.o: tunnel_nm.s
###
CHECKERS_SMALL: checkers_small.o
ld65 -o CHECKERS_SMALL checkers_small.o -C ../linker_scripts/apple2_70_zp.inc
ld65 -o CHECKERS_SMALL checkers_small.o -C ../../linker_scripts/apple2_70_zp.inc
checkers_small.o: checkers_small.s
ca65 -o checkers_small.o checkers_small.s -l checkers_small.lst
@ -88,15 +90,16 @@ checkers_small.o: checkers_small.s
HELLO: hello.bas
../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO
$(TOKENIZE) < hello.bas > HELLO
CIRCLES.BAS: zooming_circles.bas
../asoft_basic-utils/tokenize_asoft < zooming_circles.bas > CIRCLES.BAS
$(TOKENIZE) < zooming_circles.bas > CIRCLES.BAS
####
clean:
rm -f *~ *.o *.lst HELLO CIRCLES.BAS CIRCLES CHECKERS \
CHECKERS_SMALL PLANE SIER TUNNEL TNM
CHECKERS_SMALL PLANE SIER TUNNEL TNM \
division_table

View File

@ -0,0 +1,2 @@
some attempts at porting Hellmood's Memories to Apple II

View File

@ -0,0 +1,92 @@
; Checkers, based on the code in Hellmood's Memories
; 42 bytes
; could be shorter if you're not picky about colors
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
BASL = $28
BASH = $29
H2 = $2C
COLOR = $30
X1 = $F0
X2 = $F1
Y1 = $F2
Y2 = $F3
TEMP = $FA
TEMPY = $FB
FRAME = $FC
TEMPX = $FD
; Soft Switches
KEYPRESS= $C000
KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
PAGE0 = $C054 ; Page0
PAGE1 = $C055 ; Page1
LORES = $C056 ; Enable LORES graphics
; ROM routines
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved)
SETCOL = $F864
TEXT = $FB36 ;; Set text mode
BASCALC = $FBC1
SETGR = $FB40
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
HLINE = $F819
.zeropage
; orig = 42
; make 32x32
checkers:
;===================
; init screen
jsr SETGR ; 3
; bit FULLGR ; 3
;====
; 6
checkers_forever:
inc FRAME ; 2
; ldx #39 ; 2
yloop:
; ldy #39 ; 2
xloop:
; sec ; 1
tya ; 1
sbc FRAME ; 2
sta X2 ; 2
txa ; 1
sbc #0 ; 2
eor X2 ; 2
ora #$DC ; 2
; adc #1 ; 2
sta COLOR
; jsr SETCOL ; 3
txa ; A==Y1 ; 1
jsr PLOT ; (X2,Y1) ; 3
dey ; 1
bpl xloop ; 2
dex ; 1
bpl yloop ; 2
bmi checkers_forever ; 2

View File

@ -0,0 +1,92 @@
; Checkers, based on the code in Hellmood's Memories
; 42 bytes
; could be shorter if you're not picky about colors
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
BASL = $28
BASH = $29
H2 = $2C
COLOR = $30
X1 = $F0
X2 = $F1
Y1 = $F2
Y2 = $F3
TEMP = $FA
TEMPY = $FB
FRAME = $FC
TEMPX = $FD
; Soft Switches
KEYPRESS= $C000
KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
PAGE0 = $C054 ; Page0
PAGE1 = $C055 ; Page1
LORES = $C056 ; Enable LORES graphics
; ROM routines
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved)
SETCOL = $F864
TEXT = $FB36 ;; Set text mode
BASCALC = $FBC1
SETGR = $FB40
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
HLINE = $F819
.zeropage
; orig = 42
; make 32x32
checkers:
;===================
; init screen
jsr SETGR ; 3
; bit FULLGR ; 3
;====
; 6
checkers_forever:
inc FRAME ; 2
; ldx #39 ; 2
yloop:
ldy #39 ; 2
xloop:
; sec ; 1
tya ; 1
sbc FRAME ; 2
sta X2 ; 2
txa ; 1
sbc #0 ; 2
eor X2 ; 2
ora #$DC ; 2
; adc #1 ; 2
sta COLOR
; jsr SETCOL ; 3
txa ; A==Y1 ; 1
jsr PLOT ; (X2,Y1) ; 3
dey ; 1
bpl xloop ; 2
dex ; 1
bpl yloop ; 2
bmi checkers_forever ; 2

View File

@ -0,0 +1,94 @@
; Checkers, based on the code in Hellmood's Memories
; 42 bytes
; could be shorter if you're not picky about colors
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
BASL = $28
BASH = $29
H2 = $2C
COLOR = $30
X1 = $F0
X2 = $F1
Y1 = $F2
Y2 = $F3
TEMP = $FA
TEMPY = $FB
FRAME = $FC
TEMPX = $FD
; Soft Switches
KEYPRESS= $C000
KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
PAGE0 = $C054 ; Page0
PAGE1 = $C055 ; Page1
LORES = $C056 ; Enable LORES graphics
; ROM routines
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved)
SETCOL = $F864
TEXT = $FB36 ;; Set text mode
BASCALC = $FBC1
SETGR = $FB40
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
HLINE = $F819
.zeropage
; orig = 42
; make 32x32
checkers:
;===================
; init screen
jsr SETGR ; 3
; bit FULLGR ; 3
;====
; 6
checkers_forever:
inc FRAME ; 2
ldx #39 ; 2
yloop:
ldy #39 ; 2
xloop:
; sec ; 1
tya ; 1
sbc FRAME ; 2
;sta X2 ; 2
sta COLOR ; 2
txa ; 1
sbc #0 ; 2
; eor X2 ; 2
eor COLOR ; 2
ora #$DC ; 2
; adc #1 ; 2
; sta COLOR
; jsr SETCOL ; 3
txa ; A==Y1 ; 1
jsr PLOT ; (X2,Y1) ; 3
dey ; 1
bpl xloop ; 2
dex ; 1
bpl yloop ; 2
bmi checkers_forever ; 2

View File

@ -0,0 +1,92 @@
; Checkers, based on the code in Hellmood's Memories
; 42 bytes
; could be shorter if you're not picky about colors
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
BASL = $28
BASH = $29
H2 = $2C
COLOR = $30
X1 = $F0
X2 = $F1
Y1 = $F2
Y2 = $F3
TEMP = $FA
TEMPY = $FB
FRAME = $FC
TEMPX = $FD
; Soft Switches
KEYPRESS= $C000
KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
PAGE0 = $C054 ; Page0
PAGE1 = $C055 ; Page1
LORES = $C056 ; Enable LORES graphics
; ROM routines
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved)
SETCOL = $F864
TEXT = $FB36 ;; Set text mode
BASCALC = $FBC1
SETGR = $FB40
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
HLINE = $F819
.zeropage
; orig = 42
; make 32x32
checkers:
;===================
; init screen
jsr SETGR ; 3
; bit FULLGR ; 3
;====
; 6
checkers_forever:
inc FRAME ; 2
ldx #39 ; 2
yloop:
ldy #39 ; 2
xloop:
sec ; 1
tya ; 1
sbc FRAME ; 2
sta X2 ; 2
txa ; 1
sbc #0 ; 2
eor X2 ; 2
ora #$DB ; 2
adc #1 ; 2
sta COLOR
; jsr SETCOL ; 3
txa ; A==Y1 ; 1
jsr PLOT ; (X2,Y1) ; 3
dey ; 1
bpl xloop ; 2
dex ; 1
bpl yloop ; 2
bmi checkers_forever ; 2

View File

@ -0,0 +1,117 @@
; Zooming Circles, based on the code in Hellmood's Memories
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
COLOR = $30
TEMP = $FA
TEMPY = $FB
FRAME = $FC
XSAVE = $FD
; Soft Switches
KEYPRESS= $C000
KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
PAGE0 = $C054 ; Page0
PAGE1 = $C055 ; Page1
LORES = $C056 ; Enable LORES graphics
; ROM routines
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved)
SETCOL = $F864
TEXT = $FB36 ;; Set text mode
SETGR = $FB40
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
; 103 bytes
.globalzp squares_table_y
.globalzp color_lookup
.zeropage
zooming_circles:
;===================
; init screen
jsr SETGR ; 3
bit FULLGR ; 3
;====
; 6
circle_forever:
inc FRAME ; 2
ldx #23 ; 2
;===
; 4
yloop:
ldy #19 ; 2
xloop:
clc ; 1
lda squares_table_y+4,y ; 3
asl ; 1
asl ; 1
adc squares_table_y,x ; 3
lsr ; 1
adc FRAME ; 2
and #$1f ; 2
lsr ; 1
lsr ; 1
lsr ; 1
stx XSAVE ; 2
tax ; 1
lda color_lookup,X ; 3
sta COLOR ; 2
ldx XSAVE ; 2
txa ; 1
jsr PLOT ; 3
dey ; 1
bpl xloop ; 2
dex ; 1
bpl yloop ; 2
bmi circle_forever ; 2
color_lookup:
.byte $00,$55,$00,$77
; 48 bytes
squares_table_y:
;.byte $24,$21,$1e,$1b,$19,$16,$14,$12
;.byte $10,$0e,$0c,$0a,$09,$07,$06,$05
;.byte $04,$03,$02,$01,$01,$00,$00,$00
.byte $00,$00,$00,$00,$01,$01,$02,$03
.byte $04,$05,$06,$07,$09,$0a,$0c,$0e
.byte $10,$12,$14,$16,$19,$1b,$1e,$21
; 40 bytes
;squares_table_x:
;.byte $71,$6a,$64,$5d,$57,$51,$4b,$45
;.byte $40,$3a,$35,$31,
;.byte $2c,$28,$24,$20
;.byte $1c,$19,$15,$12,$10,$0d,$0b,$09
;.byte $07,$05,$04,$02,$01,$01,$00,$00
;.byte $00,$00,$00,$01,$01,$02,$04,$05
;.byte $07,$09,$0b,$0d,$10,$12,$15,$19
;.byte $1c,$20,$24,$28 ;,$2c,$31,$35,$3a
;;.byte $40,$45,$4b,$51,$57,$5d,$64,$6a

View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main(int argc, char **argv) {
int yy;
for(yy=10;yy<58;yy++) {
printf("$%02X,",0x3d5/yy);
}
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,25 @@
#include <stdio.h>
int main(int argc, char **argv) {
unsigned int m1,m2;
m1=0x1;
m2=0x1;
printf("%x * %x = %x\n",m1,m2,m1*m2);
m1=0x1;
m2=0xff;
printf("%x * %x = %x\n",m1,m2,m1*m2);
m1=0xff;
m2=0x1;
printf("%x * %x = %x\n",m1,m2,m1*m2);
m1=0xff;
m2=0xff;
printf("%x * %x = %x\n",m1,m2,m1*m2);
return 0;
}

View File

@ -0,0 +1,68 @@
;==========================
; Signed 16x16=32 multiply
;==========================
; multiplies NUM1H:NUM1L by NUM2H:NUM2L
; result in RESULT3:RESULT2:RESULT1:RESULT0
multiply_s16x16:
; check if we need to invert result, save for later
lda NUM1H
eor NUM2H
php
; if NUM1 negative, invert it
lda NUM1H
bpl num1_positive
sec
lda #0
sbc NUM1L
sta NUM1L
lda #0
sbc NUM1H
sta NUM1H
num1_positive:
; if NUM2 negative, invert it
lda NUM2H
bpl num2_positive
sec
lda #0
sbc NUM2L
sta NUM2L
lda #0
sbc NUM2H
sta NUM2H
num2_positive:
jsr multiply_u16x16
; done, see if we need to negate
plp
bpl done_s16x16
sec
lda #0
sbc RESULT0
sta RESULT0
lda #0
sbc RESULT1
sta RESULT1
lda #0
sbc RESULT2
sta RESULT2
lda #0
sbc RESULT3
sta RESULT3
done_s16x16:
rts

View File

@ -0,0 +1,217 @@
; Fast mutiply
; Note for our purposes we only care about 8.8 x 8.8 fixed point
; with 8.8 result, which means we only care about the middle two bytes
; of the 32 bit result. So we disable generation of the high and low byte
; to save some cycles.
;
; The old routine took around 700 cycles for a 16bitx16bit=32bit mutiply
; This routine, at an expense of 2kB of lookup tables, takes around 250
; If you reuse a term the next time this drops closer to 200
; Fast 16x16 bit unsigned multiplication, 32-bit result
; Input: NUM1H:NUM1L * NUM2H:NUM2L
; Result: RESULT3:RESULT2:RESULT1:RESULT0
;
; Does self-modifying code to hard-code NUM1H:NUM1L into the code
; carry=0: re-use previous NUM1H:NUM1L
; carry=1: reload NUM1H:NUM1L (58 cycles slower)
;
; clobbered: RESULT, X, A, C
; Allocation setup: T1,T2 and RESULT preferably on Zero-page.
;
; NUM1H (x_i), NUM1L (x_f)
; NUM2H (y_i), NUM2L (y_f)
; NUM1L * NUM2L = AAaa
; NUM1L * NUM2H = BBbb
; NUM1H * NUM2L = CCcc
; NUM1H * NUM2H = DDdd
;
; AAaa
; BBbb
; CCcc
; + DDdd
; ----------
; RESULT
;fixed_16x16_mul_unsigned:
multiply_u16x16:
;============================
; Set up self-modifying code
; this changes the code to be hard-coded to multiply by NUM1H:NUM1L
;============================
lda NUM1L ; load the low byte ; 3
sta sm1a+1 ; 3
sta sm3a+1 ; 3
sta sm5a+1 ; 3
sta sm7a+1 ; 3
eor #$ff ; invert the bits for subtracting ; 2
sta sm2a+1 ; 3
sta sm4a+1 ; 3
sta sm6a+1 ; 3
sta sm8a+1 ; 3
lda NUM1H ; load the high byte ; 3
sta sm1b+1 ; 3
sta sm3b+1 ; 3
sta sm5b+1 ; 3
sta sm7b+1 ;
eor #$ff ; invert the bits for subtractin ; 2
sta sm2b+1 ; 3
sta sm4b+1 ; 3
sta sm6b+1 ; 3
sta sm8b+1 ;
;===========
; 52
multiply_u16x16_same_num1:
stx TEMP
;==========================
; Perform NUM1L * NUM2L = AAaa
;==========================
ldx NUM2L ; (low le) ; 3
sec ; 2
sm1a:
lda square1_lo,x ; 4
sm2a:
sbc square2_lo,x ; 4
; a is _aa
sta RESULT0 ;
sm3a:
lda square1_hi,x ; 4
sm4a:
sbc square2_hi,x ; 4
; a is _AA
sta _AA+1 ; 3
;===========
; 24
; Perform NUM1H * NUM2L = CCcc
sec ; 2
sm1b:
lda square1_lo,x ; 4
sm2b:
sbc square2_lo,x ; 4
; a is _cc
sta _cc+1 ; 3
sm3b:
lda square1_hi,x ; 4
sm4b:
sbc square2_hi,x ; 4
; a is _CC
sta _CC+1 ; 3
;===========
; 24
;==========================
; Perform NUM1L * NUM2H = BBbb
;==========================
ldx NUM2H ; 3
sec ; 2
sm5a:
lda square1_lo,x ; 4
sm6a:
sbc square2_lo,x ; 4
; a is _bb
sta _bb+1 ; 3
sm7a:
lda square1_hi,x ; 4
sm8a:
sbc square2_hi,x ; 4
; a is _BB
sta _BB+1 ; 3
;===========
; 27
;==========================
; Perform NUM1H * NUM2H = DDdd
;==========================
sec ; 2
sm5b:
lda square1_lo,x ; 4
sm6b:
sbc square2_lo,x ; 4
; a is _dd
sta _dd+1 ; 3
sm7b:
lda square1_hi,x ;
sm8b:
sbc square2_hi,x ;
; a = _DD
sta RESULT3 ;
;===========
; 13
;===========================================
; Add the separate multiplications together
;===========================================
clc ; 2
_AA:
lda #0 ; loading _AA ; 2
_bb:
adc #0 ; adding in _bb ; 2
sta RESULT1 ; 3
;==========
; 9
; product[2]=_BB+_CC+c
_BB:
lda #0 ; loading _BB ; 2
_CC:
adc #0 ; adding in _CC ; 2
sta RESULT2 ; 3
;===========
; 7
; product[3]=_DD+c
bcc dd_no_carry1 ;
inc RESULT3 ;
clc ; 2
;=============
; 2
dd_no_carry1:
; product[1]=_AA+_bb+_cc
_cc:
lda #0 ; load _cc ; 2
adc RESULT1 ; 3
sta RESULT1 ; 3
; product[2]=_BB+_CC+_dd+c
_dd:
lda #0 ; load _dd ; 2
adc RESULT2 ; 3
sta RESULT2 ; 3
;===========
; 16
; product[3]=_DD+c
bcc dd_no_carry2 ;
inc RESULT3 ;
;=============
; 0
dd_no_carry2:
ldx TEMP
rts ; 6

View File

@ -0,0 +1,221 @@
; MODIFIED
; we only care about the result of RESULT1 for sierpinski
; Fast mutiply
; Note for our purposes we only care about 8.8 x 8.8 fixed point
; with 8.8 result, which means we only care about the middle two bytes
; of the 32 bit result. So we disable generation of the high and low byte
; to save some cycles.
;
; The old routine took around 700 cycles for a 16bitx16bit=32bit mutiply
; This routine, at an expense of 2kB of lookup tables, takes around 250
; If you reuse a term the next time this drops closer to 200
; Fast 16x16 bit unsigned multiplication, 32-bit result
; Input: NUM1H:NUM1L * NUM2H:NUM2L
; Result: RESULT3:RESULT2:RESULT1:RESULT0
;
; Does self-modifying code to hard-code NUM1H:NUM1L into the code
; carry=0: re-use previous NUM1H:NUM1L
; carry=1: reload NUM1H:NUM1L (58 cycles slower)
;
; clobbered: RESULT, X, A, C
; Allocation setup: T1,T2 and RESULT preferably on Zero-page.
;
; NUM1H (x_i), NUM1L (x_f)
; NUM2H (y_i), NUM2L (y_f)
; NUM1L * NUM2L = AAaa
; NUM1L * NUM2H = BBbb
; NUM1H * NUM2L = CCcc
; NUM1H * NUM2H = DDdd
;
; AAaa
; BBbb
; CCcc
; + DDdd
; ----------
; RESULT
;fixed_16x16_mul_unsigned:
multiply_u16x16:
;============================
; Set up self-modifying code
; this changes the code to be hard-coded to multiply by NUM1H:NUM1L
;============================
lda NUM1L ; load the low byte ; 3
sta sm1a+1 ; 3
sta sm3a+1 ; 3
sta sm5a+1 ; 3
; sta sm7a+1 ; 3
eor #$ff ; invert the bits for subtracting ; 2
sta sm2a+1 ; 3
sta sm4a+1 ; 3
sta sm6a+1 ; 3
; sta sm8a+1 ; 3
lda NUM1H ; load the high byte ; 3
sta sm1b+1 ; 3
; sta sm3b+1 ; 3
; sta sm5b+1 ; 3
; sta sm7b+1 ;
eor #$ff ; invert the bits for subtractin ; 2
sta sm2b+1 ; 3
; sta sm4b+1 ; 3
; sta sm6b+1 ; 3
; sta sm8b+1 ;
;===========
; 52
multiply_u16x16_same_num1:
stx TEMP
;==========================
; Perform NUM1L * NUM2L = AAaa
;==========================
ldx NUM2L ; (low le) ; 3
sec ; 2
sm1a:
lda square1_lo,x ; 4
sm2a:
sbc square2_lo,x ; 4
; a is _aa
sta RESULT0 ;
sm3a:
lda square1_hi,x ; 4
sm4a:
sbc square2_hi,x ; 4
; a is _AA
sta _AA+1 ; 3
;===========
; 24
; Perform NUM1H * NUM2L = CCcc
sec ; 2
sm1b:
lda square1_lo,x ; 4
sm2b:
sbc square2_lo,x ; 4
; a is _cc
sta _cc+1 ; 3
;sm3b:
; lda square1_hi,x ; 4
;sm4b:
; sbc square2_hi,x ; 4
; ; a is _CC
; sta _CC+1 ; 3
;===========
; 24
;==========================
; Perform NUM1L * NUM2H = BBbb
;==========================
ldx NUM2H ; 3
sec ; 2
sm5a:
lda square1_lo,x ; 4
sm6a:
sbc square2_lo,x ; 4
; a is _bb
sta _bb+1 ; 3
;sm7a:
; lda square1_hi,x ; 4
;sm8a:
; sbc square2_hi,x ; 4
; ; a is _BB
; sta _BB+1 ; 3
;===========
; 27
;==========================
; Perform NUM1H * NUM2H = DDdd
;==========================
; sec ; 2
;sm5b:
; lda square1_lo,x ; 4
;sm6b:
; sbc square2_lo,x ; 4
; ; a is _dd
; sta _dd+1 ; 3
;sm7b:
; lda square1_hi,x ;
;sm8b:
; sbc square2_hi,x ;
; ; a = _DD
; sta RESULT3 ;
;===========
; 13
;===========================================
; Add the separate multiplications together
;===========================================
clc ; 2
_AA:
lda #0 ; loading _AA ; 2
_bb:
adc #0 ; adding in _bb ; 2
sta RESULT1 ; 3
;==========
; 9
; product[2]=_BB+_CC+c
;_BB:
; lda #0 ; loading _BB ; 2
;_CC:
; adc #0 ; adding in _CC ; 2
; sta RESULT2 ; 3
;===========
; 7
; product[3]=_DD+c
; bcc dd_no_carry1 ;
; inc RESULT3 ;
; clc ; 2
;=============
; 2
dd_no_carry1:
; product[1]=_AA+_bb+_cc
_cc:
lda #0 ; load _cc ; 2
adc RESULT1 ; 3
sta RESULT1 ; 3
; product[2]=_BB+_CC+_dd+c
;_dd:
; lda #0 ; load _dd ; 2
; adc RESULT2 ; 3
; sta RESULT2 ; 3
;===========
; 16
; product[3]=_DD+c
; bcc dd_no_carry2 ;
; inc RESULT3 ;
;=============
; 0
;dd_no_carry2:
ldx TEMP
rts ; 6

View File

@ -0,0 +1,122 @@
; Tilted Plane, based on the code in Hellmood's Memories
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
BASL = $28
BASH = $29
H2 = $2C
COLOR = $30
X1 = $F0
X2 = $F1
Y1 = $F2
Y2 = $F3
M1 = $F7
M2 = $F8
TEMP = $FA
TEMPY = $FB
FRAME = $FC
TEMPX = $FD
SCALED = $FE
; Soft Switches
KEYPRESS= $C000
KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
PAGE0 = $C054 ; Page0
PAGE1 = $C055 ; Page1
LORES = $C056 ; Enable LORES graphics
; ROM routines
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved)
SETCOL = $F864
TEXT = $FB36 ;; Set text mode
BASCALC = $FBC1
SETGR = $FB40
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
HLINE = $F819
tilted_plane:
;===================
; init screen
jsr SETGR ; 3
bit FULLGR ; 3
jsr init_multiply_tables
plane_forever:
inc FRAME ; 2
ldx #47 ; yy ; 2
yloop:
ldy #39 ; xx ; 2
xloop:
; clc
; adc #$10 ; adjust top of screen
lda division,X ; scaled=((0x3d5/yy)&0xff);
; reverse divide AL=C/Y'
sta M1
; color=((signed char)((xprime-20)&0xff))*((signed char)(scaled&0xff));
tya
sec
sbc #20
sta M2
jsr multiply_s8x8
lda M1
ror M2
ror
ror M2
ror
and #$f
sta COLOR
; color=(color>>6)&0xff;
sec
lda SCALED
sbc FRAME ; scaled-=frame;
eor COLOR ; color^=(scaled&0xff);
and #$1C ; color&=0x1c; // map colors
jsr SETCOL
txa ; A==Y1 ; 1
jsr PLOT ; (X2,Y1) ; 3
dey ; 1
bpl xloop ; 2
dex ; 1
bpl yloop ; 2
bmi plane_forever ; 2
division:
.byte $62,$59,$51,$4B,$46,$41,$3D,$39,$36,$33
.byte $31,$2E,$2C,$2A,$28,$27,$25,$24,$23,$21
.byte $20,$1F,$1E,$1D,$1C,$1C,$1B,$1A,$19,$19
.byte $18,$17,$17,$16,$16,$15,$15,$14,$14,$14
.byte $13,$13,$12,$12,$12,$11,$11,$11
.include "multiply_tables.s"
.include "multiply_s8x8.s"
.include "multiply_u8x8.s"

View File

@ -0,0 +1,135 @@
; Tunnel (no multiply), based on the code by Hellmood
; by deater (Vince Weaver) <vince@deater.net>
; first try (shift/add multiply) = 160 bytes, 14 seconds/frame
; second (lookup table mul) = 251 bytes, 9 seconds/frame
; Zero Page
COLOR = $30
XCOORD = $F0
YCOORD = $F1
DEPTH = $F2
VALUE = $F6
M1 = $F7
M2 = $F8
FRAME = $F9
TEMP = $FA
; Soft Switches
KEYPRESS= $C000
KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
; ROM routines
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved)
SETCOL = $F864
SETGR = $FB40
tunnel:
;===================
; init screen
jsr SETGR ; 3
bit FULLGR ; 3
; jsr init_multiply_tables ; 3
tunnel_forever:
inc FRAME ; 2
ldx #47 ; 2
yloop:
ldy #39 ; 2
xloop:
; Xcoord = (x-10)*4
sec ; 1
tya ; 1
sbc #10 ; 2
asl ; 1
asl ; 1
sta XCOORD ; 2
; Ycoord = (y-10)*4
sec ; 1
txa ; 1
sbc #10 ; 2
asl ; 1
asl ; 1
; center
sbc #24
sta YCOORD ; 2
; set depth to -9 (move backwards)
lda #$f7 ; 2
sta DEPTH ; 2
fx5_loop:
; get ycoord
lda YCOORD ; 2
; 8x8 signed multiply of M1*DEPTH
;sta M1 ; 2
; jsr imul ; 3
; lda M2 ; 2
sta VALUE ; high result in A ; 2
; get xcoord
lda XCOORD ; 2
; add distance to projection (bend right)
clc ; 1
adc DEPTH ; 2
;sta M1 ; 2
; 8x8 signed multiply of M1*DEPTH
; jsr imul ; 3
; do the calculation
dec DEPTH ; 2
beq putpixel ; 2 ; is this needed?
; load the yprojection
lda VALUE ; 2
; xor with the xprojection
eor M2 ; 2
; center walls around 0
clc ; 1
adc #$4 ; 2
; test with -8, see if wall hit
sta VALUE ; 2
and #$f8 ; 2
beq fx5_loop ; 2
putpixel:
; adjust color by frame and set
sec ; 1
lda DEPTH ; 2
sbc FRAME ; 2
eor VALUE ; 2
and #$7 ; 2
;adc #$20
jsr SETCOL ; 3
txa ; A==Y1 ; 1
jsr PLOT ; (X2,Y1) ; 3
dey ; 1
bpl xloop ; 2
dex ; 1
bpl yloop ; 2
bmi tunnel_forever ; 2

View File

@ -0,0 +1,201 @@
; Tunnel, based on the code in Hellmood's Memories
; by deater (Vince Weaver) <vince@deater.net>
; first try = 160 bytes, 14 seconds/frame
; Zero Page
COLOR = $30
XCOORD = $F0
YCOORD = $F1
DEPTH = $F2
VALUE = $F6
M1 = $F7
M2 = $F8
FRAME = $F9
TEMP = $FA
; Soft Switches
KEYPRESS= $C000
KEYRESET= $C010
SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text
; ROM routines
PLOT = $F800 ; plot, horiz=y, vert=A (A trashed, XY Saved)
SETCOL = $F864
SETGR = $FB40
tunnel:
;===================
; init screen
jsr SETGR ; 3
bit FULLGR ; 3
tunnel_forever:
inc FRAME ; 2
ldx #47 ; 2
yloop:
ldy #39 ; 2
xloop:
; Xcoord = (x-10)*4
sec ; 1
tya ; 1
sbc #10 ; 2
asl ; 1
asl ; 1
sta XCOORD ; 2
; Ycoord = (y-10)*4
sec ; 1
txa ; 1
sbc #10 ; 2
asl ; 1
asl ; 1
; center
sbc #24
sta YCOORD ; 2
; set depth to -9 (move backwards)
lda #$f7 ; 2
sta DEPTH ; 2
fx5_loop:
; get ycoord
lda YCOORD ; 2
; 8x8 signed multiply of M1*DEPTH
;sta M1 ; 2
jsr imul ; 3
; lda M2 ; 2
sta VALUE ; high result in A ; 2
; get xcoord
lda XCOORD ; 2
; add distance to projection (bend right)
clc ; 1
adc DEPTH ; 2
;sta M1 ; 2
; 8x8 signed multiply of M1*DEPTH
jsr imul ; 3
; do the calculation
dec DEPTH ; 2
beq putpixel ; 2 ; is this needed?
; load the yprojection
lda VALUE ; 2
; xor with the xprojection
eor M2 ; 2
; center walls around 0
clc ; 1
adc #$4 ; 2
; test with -8, see if wall hit
sta VALUE ; 2
and #$f8 ; 2
beq fx5_loop ; 2
putpixel:
; adjust color by frame and set
sec ; 1
lda DEPTH ; 2
sbc FRAME ; 2
eor VALUE ; 2
and #$7 ; 2
;adc #$20
jsr SETCOL ; 3
txa ; A==Y1 ; 1
jsr PLOT ; (X2,Y1) ; 3
dey ; 1
bpl xloop ; 2
dex ; 1
bpl yloop ; 2
bmi tunnel_forever ; 2
;=================================================
; A = M1
; DEPTH (preserve) is M2
imul:
stx TEMP ; save as we trash it
sta M1 ; get values in right place
lda DEPTH
sta M2
eor M1 ; calc if we need to adjust at end
; (++ vs +- vs -+ vs --)
php ; save status on stack
; if M1 negative, negate it
lda M1
bpl m1_positive
eor #$ff
clc
adc #0
m1_positive:
sta M1
; if M2 negative, naegate it
lda M2
bpl m2_positive
eor #$ff
clc
adc #0
m2_positive:
sta M2
;==================
; unsigned multiply
; factors in M1 and M2
lda #0
ldx #$8
lsr M1
clc
imul_loop:
bcc no_add
clc
adc M2
no_add:
ror
ror M1
dex
bne imul_loop
sta M2
; done, high result in factor2, low result in factor1
; adjust to be signed
; if m1 and m2 positive, good
; if m1 and m2 negative, good
; otherwise, negate result
plp ; restore saved pos/neg value
bpl done_result
negate_result:
sec
lda #0
sbc M1
lda #0
sbc M2
done_result:
sta M2
ldx TEMP
rts

View File

@ -1,7 +1,7 @@
include ../Makefile.inc
include ../../Makefile.inc
DOS33 = ../dos33fs-utils/dos33
TOKENIZE = ../asoft_basic-utils/tokenize_asoft
DOS33 = ../../utils/dos33fs-utils/dos33
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
all: kfest18.dsk
@ -16,13 +16,13 @@ RASTER.lz4: RASTER
lz4 -f -16 RASTER
RASTER: raster.o
ld65 -o RASTER raster.o -C ../linker_scripts/apple2_2000.inc
ld65 -o RASTER raster.o -C ../../linker_scripts/apple2_2000.inc
raster_decompress.o: raster_decompress.s RASTER.lz4
ca65 -o raster_decompress.o raster_decompress.s
RASTER_C: raster_decompress.o
ld65 -o RASTER_C raster_decompress.o -C ../linker_scripts/apple2_1000.inc
ld65 -o RASTER_C raster_decompress.o -C ../../linker_scripts/apple2_1000.inc
@ -31,7 +31,7 @@ raster2.o: raster2.s
ca65 -o raster2.o raster2.s -l raster2.lst
RASTER2: raster2.o
ld65 -o RASTER2 raster2.o -C ../linker_scripts/apple2_1000.inc
ld65 -o RASTER2 raster2.o -C ../../linker_scripts/apple2_1000.inc
clean:

View File

@ -1,11 +1,13 @@
include ../Makefile.inc
include ../../Makefile.inc
DOS33 = ../../utils/dos33fs-utils/dos33
PNG2RLE = ../../utils/gr-utils/png2rle
PNG2LZ4 = ../../utils/gr-utils/png2lz4
PNG_TO_40x96 = ../../utils/gr-utils/png_to_40x96
PNG_TO_40x48D = ../../utils/gr-utils/png_to_40x48d
B2D = ../../utils/bmp2dhr/b2d
TOKENIZE = ../../utils/asoft_basic-utils/tokenize_asoft
DOS33 = ../dos33fs-utils/dos33
PNG2RLE = ../gr-utils/png2rle
PNG2LZ4 = ../gr-utils/png2lz4
PNG_TO_40x96 = ../gr-utils/png_to_40x96
PNG_TO_40x48D = ../gr-utils/png_to_40x48d
B2D = ../bmp2dhr/b2d
all: demosplash2019.dsk
@ -20,13 +22,13 @@ demosplash2019.dsk: HELLO LOADER DEMOSPLASH
HELLO: hello.bas
../asoft_basic-utils/tokenize_asoft < hello.bas > HELLO
$(TOKENIZE) < hello.bas > HELLO
#####
#DEMOSPLASH: demosplash.o
# ld65 -o DEMOSPLASH demosplash.o -C ../linker_scripts/apple2_1700.inc
# ld65 -o DEMOSPLASH demosplash.o -C ../../linker_scripts/apple2_1700.inc
#demosplash.o: demosplash.s \
# zp.inc hardware.inc \
@ -45,7 +47,7 @@ HELLO: hello.bas
#####
DEMOSPLASH: demosplash.o
ld65 -o DEMOSPLASH demosplash.o -C ../linker_scripts/apple2_1400.inc
ld65 -o DEMOSPLASH demosplash.o -C ../../linker_scripts/apple2_1400.inc
demosplash.o: demosplash.s \
zp.inc hardware.inc \
@ -73,7 +75,7 @@ demosplash.o: demosplash.s \
#####
LOADER: loader.o
ld65 -o LOADER loader.o -C ../linker_scripts/apple2_1000.inc
ld65 -o LOADER loader.o -C ../../linker_scripts/apple2_1000.inc
loader.o: loader.s
ca65 -o loader.o loader.s -l loader.lst
@ -112,3 +114,5 @@ k_40_48d.inc: k_40_48d.png
clean:
rm -f *~ *.o *.lst *.lz4 HELLO \
DEMOSPLASH
cd ansi && make clean
cd generator && make clean

13
demos/lores_escape/README Normal file
View File

@ -0,0 +1,13 @@
Apple II Lores Escape Demo
presented at Demosplash 2019 (came in 3rd retro demo)
was doing too much that year
had to fix bugs (with memory not being inited to zero) right before
it was presented
struggled with the sound transition from cycle-counted to interrupt
driven
bass sound still not 100% great much to Dya's disappointment

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 156 KiB

View File

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -23,4 +23,4 @@ offsets2.o: offsets2.c
$(CC) $(CFLAGS) -c offsets2.c
clean:
rm -f *.o creator offsets offsets2
rm -f *~ *.o creator offsets offsets2

Some files were not shown because too many files have changed in this diff Show More