dos33fsprogs/graphics/hgr/transitions/rectangle.s

201 lines
2.7 KiB
ArmAsm
Raw Normal View History

2021-12-08 20:15:57 +00:00
; Rectangle Transition
; "night fell like a power point"
2021-12-08 22:01:22 +00:00
; 167 bytes -- original
; 166 bytes -- make end loop beq not jmp
; 156 bytes -- use GBASL/GBASH rather than self-modifying code
; 154 bytes -- countdown X in inner loop
; 153 bytes -- remove unnecessary clc
; 151 bytes -- was setting Y twice
; 147 bytes -- lookup table for XADD/YADD
; 145 bytes -- stop on YY value
; 150 bytes -- have it cycle colors
; 147 bytes -- init zp to 0 in loop
; 144 bytes -- put lookup table in zero page
2021-12-08 20:15:57 +00:00
; zero page
GBASL = $26
GBASH = $27
HGR_X = $E0
HGR_XH = $E1
HGR_Y = $E2
HGR_COLOR = $E4
HGR_PAGE = $E6
2021-12-08 22:01:22 +00:00
GBASH_SAVED = $F5
TABLE = $F0 ; should be 0
TABLE2 = $F1 ; should be 1
TABLE3 = $F2 ; should be 0
TABLE4 = $F3 ; should be -1
TABLE5 = $F4 ; should be 0
2021-12-08 20:15:57 +00:00
XX = $F6
YY = $F7
XADD = $F8
YADD = $F9
XMIN = $FA
XMAX = $FB
YMIN = $FC
YMAX = $FD
FRAME = $FE
LINE = $FF
; soft-switches
FULLGR = $C052
PAGE1 = $C054
; ROM routines
HGR2 = $F3D8
HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y)
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
;================================
; Clear screen and setup graphics
;================================
rectangle:
jsr HGR2 ; set hi-res 140x192, page2, fullscreen
; A and Y both 0 at end
2022-02-28 04:53:06 +00:00
again:
2021-12-08 22:01:22 +00:00
; clear our zp things to 0
ldx #15
clear_loop:
sta $EF,X
dex
bne clear_loop
dec XMIN ; xmin = -1
inc TABLE2
dec TABLE4
2021-12-08 20:15:57 +00:00
ldy #39
sty XMAX ; xmax=39
ldy #24
sty YMAX ; ymax=24
main_loop:
; left to right horizontal
dec YMAX
2021-12-08 22:01:22 +00:00
; XADD=1,YADD=0
2021-12-08 20:15:57 +00:00
jsr draw_line
; top to bottom vertical
2021-12-08 22:01:22 +00:00
inc XMIN
; XADD=0,YADD=1
2021-12-08 20:15:57 +00:00
jsr draw_line
; right to left horizontal
2021-12-08 22:01:22 +00:00
inc YMIN
; XADD=-1,YADD=0
2021-12-08 20:15:57 +00:00
jsr draw_line
; bottom to top vertical
dec XMAX
2021-12-08 22:01:22 +00:00
; XADD=0,YADD=-1
2021-12-08 20:15:57 +00:00
jsr draw_line
2021-12-08 22:01:22 +00:00
; YY is in A here
; X is zero here
2021-12-08 20:15:57 +00:00
cmp #12
bne main_loop
end:
2021-12-08 22:01:22 +00:00
txa ; put zero into A
inc color_smc+1
2022-02-28 04:53:06 +00:00
bne again
2021-12-08 20:15:57 +00:00
2021-12-08 22:01:22 +00:00
;=================================
; draw a horizontal/vertical line
; 8 rows high
2021-12-08 20:15:57 +00:00
draw_line:
2021-12-08 22:01:22 +00:00
get_next:
lda FRAME
and #$3
tax
lda TABLE2,X
sta XADD
lda TABLE,X
sta YADD
inc FRAME
repeat_line:
lda YY ; YY * 8
2021-12-08 20:15:57 +00:00
asl
asl
asl
jsr HPOSN ; (Y,X),(A) (values stores in HGRX,XH,Y)
lda GBASH
2021-12-08 22:01:22 +00:00
sta GBASH_SAVED ; reset top of box
2021-12-08 20:15:57 +00:00
out_loop:
2021-12-08 22:01:22 +00:00
ldx #8
lda GBASH_SAVED
sta GBASH
ldy XX
2022-02-28 04:53:06 +00:00
2021-12-08 20:15:57 +00:00
in_loop:
2021-12-08 22:01:22 +00:00
color_smc:
lda #$7F ; draw white box
2021-12-08 20:15:57 +00:00
output_smc:
2021-12-08 22:01:22 +00:00
sta (GBASL),Y
2021-12-08 20:15:57 +00:00
2021-12-08 22:01:22 +00:00
lda GBASH ; move to next line
2021-12-08 20:15:57 +00:00
clc
adc #$4
2021-12-08 22:01:22 +00:00
sta GBASH
2021-12-08 20:15:57 +00:00
2021-12-08 22:01:22 +00:00
dex
2021-12-08 20:15:57 +00:00
bne in_loop
2022-02-28 04:53:06 +00:00
; A here is $40 - $60 (64 - 96)
; lda #25 ; wait a bit
; jsr WAIT
2021-12-08 20:15:57 +00:00
check_x:
clc
lda XADD
beq check_y
adc XX
sta XX
cmp XMIN
beq done_line
cmp XMAX
beq done_line
bne out_loop
check_y:
2021-12-08 22:01:22 +00:00
; c should already be clear
2021-12-08 20:15:57 +00:00
lda YY
adc YADD
sta YY
cmp YMIN
beq done_line
cmp YMAX
beq done_line
2021-12-08 22:01:22 +00:00
bne repeat_line
2021-12-08 20:15:57 +00:00
done_line:
rts
2021-12-08 22:01:22 +00:00