dos33fsprogs/graphics/gr/sier/sier.s

207 lines
3.2 KiB
ArmAsm
Raw Normal View History

2021-01-31 21:17:09 +00:00
; sierpinski-like demo
; based on the code from Hellmood's Memories demo
2021-01-31 05:21:00 +00:00
2021-03-02 00:21:55 +00:00
; by Vince `deater` Weaver <vince@deater.net>
; for Lovebyte 2021
2021-01-31 21:07:12 +00:00
2021-01-31 21:17:09 +00:00
; the simple sierpinski you more or less just plot
; X AND Y
2021-01-31 21:07:12 +00:00
2021-01-31 21:17:09 +00:00
; Hellmood's you plot something more or less like
; COLOR = ( (Y-(X*T)) & (X+(Y*T) ) & 0xf0
; where T is an incrementing frame value
2021-01-31 18:18:00 +00:00
2021-01-31 21:17:09 +00:00
; to get speed on 6502/Apple II we change the multiplies to
; a series of 16-bit 8.8 fixed point adds
2021-01-31 18:18:00 +00:00
2021-03-02 00:21:55 +00:00
; 140 bytes -- bot demo version
2021-03-02 00:39:49 +00:00
; 137 bytes -- remove & jump
2021-03-02 00:21:55 +00:00
; 135 bytes -- init with HGR, which sets A=0
2021-03-02 00:39:49 +00:00
; 133 bytes -- remove ldx #0 in page flip code
2021-03-02 00:21:55 +00:00
; 130 bytes -- load in zero page
; 128 bytes -- init T_L, T_H as part of zero page since we live there
2021-03-02 00:39:49 +00:00
; 126 bytes -- shorter 16-bit increment of T_L
; 122 bytes -- use trick of jumping mid-PLOT for MASK calculation
; LoveByte requires 124 bytes
2021-03-02 00:21:55 +00:00
; zero page
2021-01-31 05:21:00 +00:00
2021-01-31 06:25:34 +00:00
GBASH = $27
MASK = $2E
COLOR = $30
2021-03-02 00:21:55 +00:00
2021-01-31 21:07:12 +00:00
;XX = $F7
XX_TH = $F8
XX_TL = $F9
;YY = $FA
YY_TH = $FB
YY_TL = $FC
2021-03-02 00:21:55 +00:00
;T_L = $FD
;T_H = $FE
2021-01-31 18:18:00 +00:00
SAVED = $FF
2021-03-02 00:21:55 +00:00
; Soft switches
FULLGR = $C052
PAGE1 = $C054
PAGE2 = $C055
LORES = $C056 ; Enable LORES graphics
; ROM routines
HGR = $F3E2
HGR2 = $F3D8
PLOT1 = $F80E ;; PLOT at (GBASL),Y (need MASK to be $0f or $f0)
GBASCALC= $F847 ;; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear)
SETGR = $FB40
.zeropage
.globalzp T_L,T_H
2021-01-31 06:25:34 +00:00
2021-01-31 05:21:00 +00:00
;================================
; Clear screen and setup graphics
;================================
sier:
2021-03-02 00:21:55 +00:00
jsr HGR2 ; set FULLGR, sets A=0
; be sure to avoid code at E6 if we do this
bit LORES ; drop down to lo-res
2021-01-31 05:21:00 +00:00
2021-03-02 00:21:55 +00:00
; lda #0 ; start with multiplier 0
; sta T_L
; sta T_H
2021-01-31 18:18:00 +00:00
2021-01-31 06:25:34 +00:00
sier_outer:
2021-01-31 21:17:09 +00:00
ldx #0 ; YY starts at 0
2021-03-02 00:21:55 +00:00
2021-01-31 21:07:12 +00:00
stx YY_TL
stx YY_TH
2021-01-31 06:25:34 +00:00
sier_yloop:
2021-01-31 21:07:12 +00:00
; calc YY_T (8.8 fixed point add)
2021-01-31 21:17:09 +00:00
; save space by skipping clc as it's only a slight variation w/o
2021-01-31 21:07:12 +00:00
; clc
2021-01-31 18:18:00 +00:00
lda YY_TL
adc T_L
sta YY_TL
lda YY_TH
adc T_H
sta YY_TH
2021-01-31 06:25:34 +00:00
2021-01-31 21:17:09 +00:00
txa ; YY ; plot call needs Y/2
2021-01-31 06:25:34 +00:00
lsr
2021-01-31 21:07:12 +00:00
2021-03-02 00:39:49 +00:00
php
; bcc even_mask
; ldy #$f0
; .byte $2C ; bit hack
;even_mask:
; ldy #$0f
; sty MASK
2021-01-31 06:25:34 +00:00
jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear)
lda GBASH
2021-01-31 21:17:09 +00:00
draw_page_smc:
adc #0
sta GBASH ; adjust for PAGE1/PAGE2 ($400/$800)
2021-03-02 00:39:49 +00:00
plp
jsr $f806 ; trick to calculate MASK by jumping
; into middle of PLOT routine
2021-01-31 21:07:12 +00:00
; reset XX to 0
ldy #0 ; XX
sty XX_TL
sty XX_TH
2021-01-31 05:21:00 +00:00
sier_xloop:
2021-01-31 06:25:34 +00:00
; want (YY-(XX*T)) & (XX+(YY*T)
2021-01-31 18:18:00 +00:00
; SAVED = XX+(Y*T)
2021-01-31 21:07:12 +00:00
; clc
tya ; XX
2021-01-31 18:18:00 +00:00
adc YY_TH
2021-01-31 06:25:34 +00:00
sta SAVED
2021-01-31 18:18:00 +00:00
; calc XX*T
2021-01-31 21:07:12 +00:00
; clc
2021-01-31 18:18:00 +00:00
lda XX_TL
adc T_L
sta XX_TL
lda XX_TH
adc T_H
sta XX_TH
2021-01-31 05:21:00 +00:00
2021-01-31 18:18:00 +00:00
; calc (YY-X_T)
2021-01-31 21:07:12 +00:00
txa ; lda YY
2021-01-31 06:25:34 +00:00
sec
2021-01-31 18:18:00 +00:00
sbc XX_TH
; want (YY-(XX*T)) & (XX+(YY*T)
2021-01-31 06:25:34 +00:00
and SAVED
2021-01-31 21:07:12 +00:00
and #$f0
2021-01-31 05:21:00 +00:00
2021-01-31 21:17:09 +00:00
beq green
2021-01-31 05:21:00 +00:00
black:
2021-01-31 06:25:34 +00:00
lda #00 ; black
.byte $2C ; bit trick
2021-01-31 21:17:09 +00:00
green:
lda #$CC ; green
2021-01-31 05:21:00 +00:00
sta COLOR
2021-01-31 21:17:09 +00:00
; XX value already in Y
2021-01-31 05:21:00 +00:00
2021-01-31 06:25:34 +00:00
jsr PLOT1 ; PLOT AT (GBASL),Y
2021-01-31 05:21:00 +00:00
2021-01-31 21:17:09 +00:00
iny ; XX
2021-01-31 21:07:12 +00:00
cpy #40
2021-01-31 18:18:00 +00:00
bne sier_xloop
2021-01-31 05:21:00 +00:00
2021-01-31 21:17:09 +00:00
inx ; YY
2021-01-31 21:07:12 +00:00
cpx #48
2021-01-31 18:18:00 +00:00
bne sier_yloop
2021-01-31 06:25:34 +00:00
2021-01-31 18:18:00 +00:00
; inc T
2021-01-31 21:07:12 +00:00
; clc
2021-01-31 18:18:00 +00:00
lda T_L
2021-01-31 21:07:12 +00:00
blah_smc:
2021-01-31 18:18:00 +00:00
adc #1
sta T_L
2021-03-02 00:39:49 +00:00
bcc no_carry
inc T_H
no_carry:
2021-01-31 06:25:34 +00:00
2021-01-31 21:17:09 +00:00
; speed up the zoom as it goes
2021-01-31 21:07:12 +00:00
inc blah_smc+1
2021-01-31 06:25:34 +00:00
2021-03-02 00:21:55 +00:00
; x is 48
flip_pages:
2021-01-31 06:25:34 +00:00
lda draw_page_smc+1 ; DRAW_PAGE
beq done_page
inx
done_page:
2021-03-02 00:21:55 +00:00
; X=48 ($30) PAGE1=$C054-$30=$C024
ldy $C024,X ; set display page to PAGE1 or PAGE2
2021-01-31 06:25:34 +00:00
eor #$4 ; flip draw page between $400/$800
sta draw_page_smc+1 ; DRAW_PAGE
2021-03-02 00:21:55 +00:00
jmp sier_outer ; what can we branch on?
2021-01-31 21:17:09 +00:00
2021-03-02 00:21:55 +00:00
T_L: .byte $00
T_H: .byte $00
2021-01-31 21:17:09 +00:00