dos33fsprogs/graphics/gr/sier/sier.s

178 lines
2.6 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-01-31 21:17:09 +00:00
; 140 bytes -- enough for appleiibot plus {B11} directive
; to allow for decompression time
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-01-31 05:21:00 +00:00
.include "hardware.inc"
2021-01-31 06:25:34 +00:00
GBASH = $27
MASK = $2E
COLOR = $30
2021-01-31 21:07:12 +00:00
;XX = $F7
XX_TH = $F8
XX_TL = $F9
;YY = $FA
YY_TH = $FB
YY_TL = $FC
T_L = $FD
T_H = $FE
2021-01-31 18:18:00 +00:00
SAVED = $FF
2021-01-31 06:25:34 +00:00
2021-01-31 05:21:00 +00:00
;================================
; Clear screen and setup graphics
;================================
sier:
jsr SETGR ; set lo-res 40x40 mode
bit FULLGR ; make it 40x48
2021-01-31 18:18:00 +00:00
lda #0 ; start with multiplier 0
sta T_L
sta T_H
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-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-01-31 06:25:34 +00:00
bcc even_mask
2021-01-31 21:07:12 +00:00
ldy #$f0
.byte $C2 ; bit hack
2021-01-31 06:25:34 +00:00
even_mask:
2021-01-31 21:07:12 +00:00
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:07:12 +00:00
2021-01-31 21:17:09 +00:00
draw_page_smc:
adc #0
sta GBASH ; adjust for PAGE1/PAGE2 ($400/$800)
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
lda T_H
adc #0
sta T_H
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
flip_pages:
2021-01-31 21:07:12 +00:00
ldx #0
2021-01-31 06:25:34 +00:00
lda draw_page_smc+1 ; DRAW_PAGE
beq done_page
inx
done_page:
ldy PAGE0,X ; set display page to PAGE1 or PAGE2
eor #$4 ; flip draw page between $400/$800
sta draw_page_smc+1 ; DRAW_PAGE
2021-01-31 21:07:12 +00:00
jmp sier_outer ; just slightly too far???
2021-01-31 06:25:34 +00:00
2021-01-31 21:17:09 +00:00
; for maximum twitter size we enter this program
; by using the "&" operator which jumps to $3F5
; we can't load there though as the code would end up overlapping
; $400 which is the graphics area
2021-01-31 21:07:12 +00:00
; this is at 389
; we want to be at 3F5, so load program at 36C?
jmp sier ; entry point from &