Ciąg dalszy kodu, bo się nie zmieściło w jednym poście.
loop1
;-----------------------
;- get the all factors -
;-----------------------
;---
lda #$0f
sta dotcount
lda #$00
sta tmpr3
loop1a
ldx dotcount
;---
lda tb_fact3,x
sta vect1+1
ldy mat_F_lo
lda (vect1),y
sta v6 ;(F*fact3)
;---
ldy mat_C_lo
lda (vect1),y
sta v3 ;(C*fact3)
;---
lda tb_fact1,x
sta vect1+1
ldy mat_E_lo
lda (vect1),y
sta v5 ;(E*fact1)
;---
ldy mat_B_lo
lda (vect1),y
sta v2 ;(E*fact1)
;---
lda tb_fact2,x
sta vect1+1
ldy mat_D_lo
lda (vect1),y
sta v4 ;(D*fact2)
;---
ldy mat_A_lo
lda (vect1),y
sta v1 ;(A*fact2)
;-------------------------------------------------------------------------------
; plot 1/2 [ (A*fact2 + B*fact1 + C*fact3) ; (D*fact2 + E*fact1 + F*fact3) ]
;-------------------------------------------------------------------------------
;-------------------------
;- calculations plot 1/2 -
;-------------------------
;lda v1
;acc = v1
adc v2 ;(A*fact2 + B*fact1)
adc v3 ;(A*fact2 + B*fact1 + C*fact3)
tax ;x plot 5/6 ;(A*fact2 + B*fact1 + C*fact3)
ldy tmpr3
lda tbbit,x
sta tb_bit1,y
lda tbbit2,x
sta tb_bit1+1,y
lda v4
adc v5 ;(D*fact2 + E*fact1)
adc v6 ;(D*fact2 + E*fact1 + F*fact3)
tay ;y plot 5/6 ;(D*fact2 + E*fact1 + F*fact3)
;------------------------
;- now prepare plot 1/2 -
;------------------------
;x = (A*fact2 + B*fact1 + C*fact3)
;y = (D*fact2 + E*fact1 + F*fact3)
lda tbadlo,y
clc
adc tabxm,x
stx tmpr4
ldx tmpr3
sta tb_adlo1,x
lda tbadhi,y
adc #0
sta tb_adhi1,x
ldx tmpr4
lda tbadlo2,y
;clc - no - C = 0
adc tabxm2,x
ldx tmpr3
sta tb_adlo1+1,x
lda tbadhi2,y
adc #0
sta tb_adhi1+1,x
;-------------------------------------------------------------------------------
; plot 3/4 [ (A*fact2 + B*fact1 - C*fact3) ; (D*fact2 + E*fact1 - F*fact3) ]
;-------------------------------------------------------------------------------
;-------------------------
;- calculations plot 3/4 -
;-------------------------
lda v1 ;(A*fact2)
adc v2 ;(A*fact2 + B*fact1)
sbc v3 ;(A*fact2 + B*fact1 - C*fact3)
tax ;(A*fact2 + B*fact1 - C*fact3)
ldy tmpr3
lda tbbit,x
sta tb_bit1+2,y
lda tbbit2,x
sta tb_bit1+3,y
lda v4 ;(D*fact2)
adc v5 ;(D*fact2 + E*fact1)
sbc v6 ;(D*fact2 + E*fact1 - F*fact3)
tay ;y plot 1/2 ;(D*fact2 + E*fact1 - F*fact3)
;------------------------
;- now prepare plot 3/4 -
;------------------------
;x = (A*fact2 + B*fact1 - C*fact3)
;y = (D*fact2 + E*fact1 - F*fact3)
lda tbadlo,y
clc
adc tabxm,x
stx tmpr4
ldx tmpr3
sta tb_adlo1+2,x
lda tbadhi,y
adc #0
sta tb_adhi1+2,x
ldx tmpr4
lda tbadlo2,y
adc tabxm2,x
ldx tmpr3
sta tb_adlo1+3,x
lda tbadhi2,y
adc #0
sta tb_adhi1+3,x
;-------------------------------------------------------------------------------
; plot 5/6 [ (A*fact2 - B*fact1 - C*fact3) ; (D*fact2 - E*fact1 + F*fact3) ]
;-------------------------------------------------------------------------------
;-------------------------
;- calculations plot 5/6 -
;-------------------------
lda v1 ;(A*fact2)
sbc v2 ;(A*fact2 - B*fact1)
adc v3 ;(A*fact2 - B*fact1 - C*fact3)
tax ;x plot 3/4 ;(A*fact2 - B*fact1 - C*fact3)
ldy tmpr3
lda tbbit,x
sta tb_bit1+4,y
lda tbbit2,x
sta tb_bit1+5,y
lda v4 ;(D*fact2)
sbc v5 ;(D*fact2 - E*fact1)
adc v6 ;(D*fact2 - E*fact1 + F*fact3)
tay ;y plot 3/4 ;(D*fact2 - E*fact1 + F*fact3)
;------------------------
;- now prepare plot 5/6 -
;------------------------
;x = (A*fact2 - B*fact1 - C*fact3)
;y = (D*fact2 - E*fact1 + F*fact3)
lda tbadlo,y
clc
adc tabxm,x
stx tmpr4
ldx tmpr3
sta tb_adlo1+4,x
lda tbadhi,y
adc #0
sta tb_adhi1+4,x
ldx tmpr4
lda tbadlo2,y
adc tabxm2,x
ldx tmpr3
sta tb_adlo1+5,x
lda tbadhi2,y
adc #0
sta tb_adhi1+5,x
;-------------------------------------------------------------------------------
; plot 7/8 [ (A*fact2 - B*fact1 - C*fact3) ; (D*fact2 - E*fact1 - F*fact3) ]
;-------------------------------------------------------------------------------
;-------------------------
;- calculations plot 7/8 -
;-------------------------
lda v1 ;(A*fact2)
sbc v2 ;(A*fact2 - B*fact1)
sbc v3 ;(A*fact2 - B*fact1 - C*fact3)
tax ;x plot 7/8 ;(A*fact2 - B*fact1 - C*fact3)
ldy tmpr3
lda tbbit,x
sta tb_bit1+6,y
lda tbbit2,x
sta tb_bit1+7,y
lda v4
sbc v5 ;(D*fact2 - E*fact1)
sbc v6 ;(D*fact2 - E*fact1 - F*fact3)
tay ;y plot 7/8 ;(D*fact2 - E*fact1 - F*fact3)
;------------------------
;- now prepare plot 7/8 -
;------------------------
;y = (D*fact2 - E*fact1 - F*fact3)
;x = (A*fact2 - B*fact1 - C*fact3)
lda tbadlo,y
clc
adc tabxm,x
stx tmpr4
ldx tmpr3
sta tb_adlo1+6,x
lda tbadhi,y
adc #0
sta tb_adhi1+6,x
ldx tmpr4
lda tbadlo2,y
adc tabxm2,x
ldx tmpr3
sta tb_adlo1+7,x
lda tbadhi2,y
adc #0
sta tb_adhi1+7,x
;-
lda tmpr3
clc
adc #8
sta tmpr3
dec dotcount
bmi +
jmp loop1a
+ jmp irq_exit
;============
loop2
;-----------------------
;- get the all factors -
;-----------------------
lda #$0f
sta dotcount
lda #$00
sta tmpr3
loop2a
;---
ldx dotcount
;---
lda tb_fact3,x
sta vect1+1
ldy mat_F_lo
lda (vect1),y
sta v6 ;(F*fact3)
;---
ldy mat_C_lo
lda (vect1),y
sta v3 ;(C*fact3)
;---
lda tb_fact1,x
sta vect1+1
ldy mat_E_lo
lda (vect1),y
sta v5 ;(E*fact1)
;---
ldy mat_B_lo
lda (vect1),y
sta v2 ;(E*fact1)
;---
lda tb_fact2,x
sta vect1+1
ldy mat_D_lo
lda (vect1),y
sta v4 ;(D*fact2)
;---
ldy mat_A_lo
lda (vect1),y
sta v1 ;(A*fact2)
;-------------------------
;- calculations plot 1/2 -
;-------------------------
;lda v1
;acc = v1
adc v2
adc v3
tax
ldy tmpr3
lda tbbit,x
sta tb_bit2,y
lda tbbit2,x
sta tb_bit2+1,y
lda v4
adc v5
adc v6
tay
;------------
;- plot 1/2 -
;------------
lda tbadlo,y
clc
adc tabxm,x
stx tmpr4
ldx tmpr3
sta tb_adlo2,x
lda tbadhi,y
adc #0
sta tb_adhi2,x
ldx tmpr4
lda tbadlo2,y
;clc - no - C = 0
adc tabxm2,x
ldx tmpr3
sta tb_adlo2+1,x
lda tbadhi2,y
adc #0
sta tb_adhi2+1,x
;-------------------------
;- calculations plot 3/4 -
;-------------------------
lda v1
adc v2
sbc v3
tax
ldy tmpr3
lda tbbit,x
sta tb_bit2+2,y
lda tbbit2,x
sta tb_bit2+3,y
lda v4
adc v5
sbc v6
tay
;------------
;- plot 3/4 -
;------------
lda tbadlo,y
clc
adc tabxm,x
stx tmpr4
ldx tmpr3
sta tb_adlo2+2,x
lda tbadhi,y
adc #0
sta tb_adhi2+2,x
ldx tmpr4
lda tbadlo2,y
adc tabxm2,x
ldx tmpr3
sta tb_adlo2+3,x
lda tbadhi2,y
adc #0
sta tb_adhi2+3,x
;-------------------------
;- calculations plot 5/6 -
;-------------------------
lda v1
sbc v2
adc v3
tax
ldy tmpr3
lda tbbit,x
sta tb_bit2+4,y
lda tbbit2,x
sta tb_bit2+5,y
lda v4
sbc v5
adc v6
tay
;------------
;- plot 5/6 -
;------------
lda tbadlo,y
clc
adc tabxm,x
stx tmpr4
ldx tmpr3
sta tb_adlo2+4,x
lda tbadhi,y
adc #0
sta tb_adhi2+4,x
ldx tmpr4
lda tbadlo2,y
adc tabxm2,x
ldx tmpr3
sta tb_adlo2+5,x
lda tbadhi2,y
adc #0
sta tb_adhi2+5,x
;-------------------------
;- calculations plot 7/8 -
;-------------------------
lda v1
sbc v2
sbc v3
tax
ldy tmpr3
lda tbbit,x
sta tb_bit2+6,y
lda tbbit2,x
sta tb_bit2+7,y
lda v4
sbc v5
sbc v6
tay
;------------
;- plot 7/8 -
;------------
lda tbadlo,y
clc
adc tabxm,x
stx tmpr4
ldx tmpr3
sta tb_adlo2+6,x
lda tbadhi,y
adc #0
sta tb_adhi2+6,x
ldx tmpr4
lda tbadlo2,y
adc tabxm2,x
ldx tmpr3
sta tb_adlo2+7,x
lda tbadhi2,y
adc #0
sta tb_adhi2+7,x
;-
lda tmpr3
clc
adc #8
sta tmpr3
dec dotcount
bmi +
jmp loop2a
+ jmp irq_exit
;=================================
;******************************
;**** THE END of main stub ****
;******************************
;-----------------------------
;- bellow a helps procedures -
;- to graph init, irq, -
;- calc tables etc... -
;-----------------------------
;==========================
;= simple init irq, init =
;= timer, colors etc... =
;==========================
initirq
lda #$00
sta $d015
lda #<irq
sta $fffe
lda #<nmiex
sta $fffa
lda #>irq
sta $ffff
sta $fffb
lda #$7f
sta $dc0d
lda $dc0d
bit $d011
bpl *-3
lda #$c8
sta $d016
lda #value_d018
sta $d018
lda #value_dd00
sta $dd00
lda #$01
sta $d01a
lda #$0b
sta $d011
lda #$fa
sta $d012
rts
;=====================
;= end init irq... =
;=====================
;=======================================
;= now make all needed tables : =
;= make tbbits for plotting, =
;= tab address of plots and =
;= prepare them to sign (-128/127) =
;=======================================
make_tables
lda #$00
tax
tay
sec
;x=0 y=0 a=0 C=1
;sec ;C=1
- ror
bne *+3
ror
sta tbbit,x
dey
sta tbbit2,y
inx
bne -
;---
;x=0
- txa
and #$f8
sta tabxm,x
lda #0
sta tbadlo,x
lda #>trashcan
sta tbadhi,x
inx
bne -
;---
- lda #>trashcan
sta tb_adhi1,x
sta tb_adhi2,x
lda #0
sta tb_bit1,x
sta tb_bit2,x
sta tb_adlo1,x
sta tb_adlo2,x
inx
bpl -
tax
;---
lda #>screen
sta tmpr4
lda #32 ;many pixel to the rigt
sta tmpr3
;x=0 C=0
calc lda tmpr3
sta tmpr1
sta tbadlo+28,x
lda tmpr4
sta tmpr2
sta tbadhi+28,x
inx
ldy #$07
calc2 inc tmpr1
bne *+4
inc tmpr2
lda tmpr1
sta tbadlo+28,x
lda tmpr2
sta tbadhi+28,x
inx
dey
bne calc2
lda tmpr3
;clc ;C=0
adc #$40
sta tmpr3
lda tmpr4
adc #$01
sta tmpr4
cpx #200
bcc calc
;--- hocus-pocus #1 for tables :)
;============
lda #>tbadlo
sta vect2+1
sty vect2
ldx #3
stx tmpr3
- lda (vect2),y
pha
tya
eor #$80
tay
lda (vect2),y
tax
pla
sta (vect2),y
tya
eor #$80
tay
txa
sta (vect2),y
iny
bpl -
ldy #0
inc vect2+1
dec tmpr3
bne -
;----------
ldx #0
; --- yep :) hocus-pocus #2 for tables...
;x=0
;y=0
- dey
lda tabxm,y
sta tabxm2,x
lda tbadlo,y
sta tbadlo2,x
lda tbadhi,y
sta tbadhi2,x
inx
bne -
rts
;-----------------------------
;- uff... maketables done :) -
;-----------------------------
setup_scr
lda #$34
sta $01
lda #$10 ;fill hires bitmap color ram - plot = white, background = black
ldx #$00
- sta rcolor,x
sta rcolor+$0100,x
sta rcolor+$0200,x
sta rcolor+$0300,x
inx
bne -
inc $01
;-----------------------
;- simple clear screen -
;-----------------------
lda #>screen
sta fll+2
txa ;x=0
ldy #$1f
fll
sta screen,x
inx
bne fll
inc fll +2
dey
bne fll
- sta screen+$1e40,x
inx
bne -
rts
;-------------
;============================
;=== make a ball dots ... ===
;= and place on the sphere =
;============================
;-----------------------
;- to calulation using -
;- [ C F ] where : -
;-----------------------
;--------------
; C = sin(sy)/2
;--------------
;------------------------------
; F = (sin(sy-sx)-sin(sy+sx))/4
;------------------------------
;---
insert_dots
lda #$48
sta t_x
;lda #$48
sta t_y
;---
ldx #many_dots-1
-
lda t_x
sec
sbc #$10
sta t_x
and #$3f
sta hi_angle_x
lda #0
sta hi_angle_z
txa
and #3
cmp #3
bne +
lda t_y
sec
sbc #16
sta t_y
+ lda t_y
eor #$7f
clc
adc #1
sta hi_angle_y
txa ;safe x value
pha
jsr calculate_matrix ;make C and F
pla
tax ;restore x
lsr mat_F_hi ; div 2
lda mat_F_lo
ror
;---
sta tb_fact1,x
pha ;hehe
txa ;fast make 3rd value without calculatons :-)
eor #3
tay
pla
sta tb_fact2,y
lsr mat_C_hi ; div 2
lda mat_C_lo
ror
;---
sta tb_fact3,x
dex
bpl -
ldx #5
- lda delty,x
sta lo_delta_x,x
txa
sta lo_angle_x,x
dex
bpl -
;=======================
lda #>tbscale
sta pointer
ldx #many_dots*3-1
lda #$ff
- sta replic_tab,x
dex
bpl -
;x=#$ff
inx
findloop
txa
tay
iny
lda #0
sta count_check
count_find
lda replic_tab,y
cmp #$ff
bne nofind
lda tb_fact1,x
cmp tb_fact1,y
bne nofind
;find here
lda pointer
sta outp+2
sta outp2+2
sta inp+2
sta replic_tab,x
sta replic_tab,y
inc count_check
nofind iny
cpy #many_dots*3
bcc count_find
lda count_check
beq +
txa
pha ;safe x
;------------------------------------
;- make one block table for a point -
;------------------------------------
;do_one_table
lda tb_fact1,x
;--- ;in acc dot factor value
asl ; muls 4
asl
tay
;clc ;after asl Carry = 0
lda #0
tax
sta tmpr1
sta tmpr2
;---
outp sta tbscale,x
;---
tya
adc tmpr1
sta tmpr1
lda tmpr2
adc #0
sta tmpr2
inx
bpl outp
;-
;x=#$80
ldy #$7f
inv lda #0
sec
inp sbc tbscale,y
outp2 sta tbscale,x
dey
inx
bne inv
;--------------------
pla
tax ;restore x
inc pointer
+ inx
cpx #many_dots*3-1
bcc findloop
-
lda replic_tab,x
sta tb_fact1,x
dex
bpl -
rts
;====================================
;=== the end of inserting dots ====
;====================================
;---------------------------------------
;lo & hi delta rotation x y z (sx;sy;sz)
delty !byte $00,$00,$00,$01,$ff,$ff
;---------------------------------------
;eof
;-