184 lines
2.2 KiB
ArmAsm
Raw Normal View History

2021-01-31 00:21:00 -05:00
; fake sierpinski
2021-01-31 16:07:12 -05:00
; 143 bytes -- sorta working
2021-01-31 13:18:00 -05:00
; x=0..39
; T =0 XX_T = 0 .. 0
; T =1 XX_T = 0 .. 39 ($0027)
; T =2 XX_T = 0 .. 78 ($004E)
; T =3 XX_T = 0 .. 117 ($0075)
; T = 128 XX_T = 0 .. 4992 ($1380)
; T = 255 XX_T = 0 .. 9945 ($26D9)
2021-01-31 00:21:00 -05:00
; just plot X AND Y
2021-01-31 01:25:34 -05:00
;.include "zp.inc"
2021-01-31 00:21:00 -05:00
.include "hardware.inc"
2021-01-31 01:25:34 -05:00
GBASH = $27
MASK = $2E
COLOR = $30
2021-01-31 16:07:12 -05: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 13:18:00 -05:00
SAVED = $FF
2021-01-31 01:25:34 -05:00
2021-01-31 00:21:00 -05:00
;================================
; Clear screen and setup graphics
;================================
sier:
jsr SETGR ; set lo-res 40x40 mode
bit FULLGR ; make it 40x48
2021-01-31 13:18:00 -05:00
lda #0 ; start with multiplier 0
sta T_L
sta T_H
2021-01-31 01:25:34 -05:00
sier_outer:
2021-01-31 16:07:12 -05:00
ldx #0 ; YY
stx YY_TL
stx YY_TH
2021-01-31 01:25:34 -05:00
sier_yloop:
2021-01-31 13:18:00 -05:00
; reset XX to 0
2021-01-31 16:07:12 -05:00
; ldy #0 ; XX
; sty XX_TL
; sty XX_TH
2021-01-31 13:18:00 -05:00
2021-01-31 01:25:34 -05:00
2021-01-31 16:07:12 -05:00
; calc YY_T (8.8 fixed point add)
; clc
2021-01-31 13:18:00 -05:00
lda YY_TL
adc T_L
sta YY_TL
lda YY_TH
adc T_H
sta YY_TH
2021-01-31 01:25:34 -05:00
2021-01-31 16:07:12 -05:00
txa ; YY
2021-01-31 01:25:34 -05:00
lsr
2021-01-31 16:07:12 -05:00
2021-01-31 01:25:34 -05:00
bcc even_mask
2021-01-31 16:07:12 -05:00
ldy #$f0
.byte $C2 ; bit hack
2021-01-31 01:25:34 -05:00
even_mask:
2021-01-31 16:07:12 -05:00
ldy #$0f
sty MASK
2021-01-31 01:25:34 -05:00
2021-01-31 16:07:12 -05:00
; txa ; YY
; lsr
2021-01-31 01:25:34 -05:00
jsr GBASCALC ; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear)
lda GBASH
2021-01-31 16:07:12 -05:00
; reset XX to 0
ldy #0 ; XX
sty XX_TL
sty XX_TH
2021-01-31 01:25:34 -05:00
draw_page_smc:
adc #0
sta GBASH
2021-01-31 00:21:00 -05:00
sier_xloop:
2021-01-31 01:25:34 -05:00
; want (YY-(XX*T)) & (XX+(YY*T)
2021-01-31 13:18:00 -05:00
; SAVED = XX+(Y*T)
2021-01-31 16:07:12 -05:00
; clc
tya ; XX
2021-01-31 13:18:00 -05:00
adc YY_TH
2021-01-31 01:25:34 -05:00
sta SAVED
2021-01-31 13:18:00 -05:00
; calc XX*T
2021-01-31 16:07:12 -05:00
; clc
2021-01-31 13:18:00 -05:00
lda XX_TL
adc T_L
sta XX_TL
lda XX_TH
adc T_H
sta XX_TH
2021-01-31 00:21:00 -05:00
2021-01-31 13:18:00 -05:00
; calc (YY-X_T)
2021-01-31 16:07:12 -05:00
txa ; lda YY
2021-01-31 01:25:34 -05:00
sec
2021-01-31 13:18:00 -05:00
sbc XX_TH
; want (YY-(XX*T)) & (XX+(YY*T)
2021-01-31 01:25:34 -05:00
and SAVED
2021-01-31 16:07:12 -05:00
and #$f0
2021-01-31 00:21:00 -05:00
2021-01-31 16:07:12 -05:00
beq red
2021-01-31 00:21:00 -05:00
black:
2021-01-31 01:25:34 -05:00
lda #00 ; black
.byte $2C ; bit trick
2021-01-31 00:21:00 -05:00
red:
2021-01-31 16:07:12 -05:00
lda #$CC ; red
2021-01-31 00:21:00 -05:00
sta COLOR
2021-01-31 16:07:12 -05:00
; ldy XX
2021-01-31 00:21:00 -05:00
2021-01-31 01:25:34 -05:00
jsr PLOT1 ; PLOT AT (GBASL),Y
2021-01-31 00:21:00 -05:00
2021-01-31 16:07:12 -05:00
iny ; XX
cpy #40
2021-01-31 13:18:00 -05:00
bne sier_xloop
2021-01-31 00:21:00 -05:00
2021-01-31 16:07:12 -05:00
inx
cpx #48
2021-01-31 13:18:00 -05:00
bne sier_yloop
2021-01-31 01:25:34 -05:00
2021-01-31 13:18:00 -05:00
; inc T
2021-01-31 16:07:12 -05:00
; clc
2021-01-31 13:18:00 -05:00
lda T_L
2021-01-31 16:07:12 -05:00
blah_smc:
2021-01-31 13:18:00 -05:00
adc #1
sta T_L
lda T_H
adc #0
sta T_H
2021-01-31 01:25:34 -05:00
2021-01-31 16:07:12 -05:00
; speed up the zoom
inc blah_smc+1
2021-01-31 01:25:34 -05:00
flip_pages:
2021-01-31 16:07:12 -05:00
ldx #0
2021-01-31 01:25:34 -05: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 16:07:12 -05:00
jmp sier_outer ; just slightly too far???
2021-01-31 01:25:34 -05:00
2021-01-31 16:07:12 -05:00
; this is at 389
; we want to be at 3F5, so load program at 36C?
jmp sier ; entry point from &