dos33fsprogs/graphics/hgr/tiny_triangles/mod9.s

178 lines
2.2 KiB
ArmAsm
Raw Normal View History

2021-04-10 05:14:59 +00:00
; Sort of plotting (X^Y) % 9
; but in hires
; by Vince `deater` Weaver <vince@deater.net>
2021-04-10 03:33:27 +00:00
GBASL = $26
GBASH = $27
HGRPAGE = $E6
HGR_BITS = $1C
HGR_X = $E0
HGR_Y = $E2
HGR_COLOR = $E4
HGR_HORIZ = $E5
2021-04-10 05:14:59 +00:00
OUR_MASK = $FB
YY = $FC
2021-04-10 03:33:27 +00:00
SAVEX = $FD
TEMP = $FE
OLD = $FF
2021-04-10 05:14:59 +00:00
PAGE0 = $C054
PAGE1 = $C055
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
COLORTBL = $F6F6
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
HGR2 = $F3D8
HGR = $F3E2
HCLR = $F3F2
HPOSN = $F411
HPLOT0 = $F457 ; plot at (Y,X), (A)
HPLOT1 = $F45A ; skip the HPOSN call
COLOR_SHIFT = $F47E ; shift color for odd/even Y (0..7 or 7..13)
MOVE_RIGHT = $F48A ; move next plot location one to the right
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
HCOLOR1 = $F6F0 ; set HGR_COLOR to value in X
WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
2021-04-10 03:33:27 +00:00
mod9_lookup = $1000
2021-04-10 05:14:59 +00:00
;==============================
; mod9 start
;==============================
2021-04-10 03:33:27 +00:00
mod9_start:
2021-04-10 05:14:59 +00:00
jsr make_mod9_lookup ; setup modulo 9 lookup table
; could inline it here
2021-04-10 03:33:27 +00:00
jsr HGR2 ; clear page1
; A is 0 after
2021-04-10 05:14:59 +00:00
sta OUR_MASK
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
mod9_reset:
2021-04-10 03:33:27 +00:00
ldy #0
2021-04-10 05:14:59 +00:00
sty YY
mod9_yloop:
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
ldy #0
ldx #0 ; XX = 0
lda YY ; Y co-ord
jsr HPOSN ; set cursor position to (Y,X), (A)
2021-04-10 03:33:27 +00:00
ldx #0
tiny_xloop:
stx SAVEX
;===============here
txa
2021-04-10 05:14:59 +00:00
eor YY
2021-04-10 03:33:27 +00:00
tax
lda mod9_lookup,X
2021-04-10 05:14:59 +00:00
;=================
ldx OUR_MASK
bne weird_pattern
cmp #0
beq store_color
lda #3
store_color:
jmp color_ready
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
weird_pattern:
and OUR_MASK
color_ready:
2021-04-10 03:33:27 +00:00
tax
tya
lsr ; check even or odd
php
lda COLORTBL,X
sta HGR_BITS
plp
bcc no_shift
jsr COLOR_SHIFT ; if odd then color shift
no_shift:
2021-04-10 05:14:59 +00:00
jsr HPLOT1 ; plot at current position
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
jsr MOVE_RIGHT ; move current position right (trashes A)
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
ldx SAVEX ; restore X
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
;==================================
2021-04-10 03:33:27 +00:00
inx
2021-04-10 05:14:59 +00:00
bne tiny_xloop ; repeat until X=256
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
;==================================
inc YY ; repeat until Y=192
ldy YY
2021-04-10 03:33:27 +00:00
cpy #192
2021-04-10 05:14:59 +00:00
bne mod9_yloop
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
;==================================
change_pattern:
inc OUR_MASK ; change pattern
lda OUR_MASK
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
check_4:
cmp #4
bne check_9
lda #8
sta OUR_MASK
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
check_9:
cmp #9
bne done_check
lda #0
sta OUR_MASK
2021-04-10 03:33:27 +00:00
2021-04-10 05:14:59 +00:00
done_check:
jmp mod9_reset
;=============================
; setup the mod9 lookup table
;=============================
2021-04-10 03:33:27 +00:00
make_mod9_lookup:
ldy #0
m9_xreset:
ldx #0
m9_loop:
txa
sta mod9_lookup,Y
2021-04-10 05:14:59 +00:00
2021-04-10 03:33:27 +00:00
iny
beq m9_done
2021-04-10 05:14:59 +00:00
2021-04-10 03:33:27 +00:00
inx
cpx #9
beq m9_xreset
bne m9_loop
2021-04-10 05:14:59 +00:00
2021-04-10 03:33:27 +00:00
m9_done:
rts
2021-04-12 05:33:27 +00:00