213 lines
2.9 KiB
ArmAsm
Raw Normal View History

2022-09-27 01:34:56 -04:00
; Parallax HGR
; by deater (Vince Weaver) <vince@deater.net>
2022-09-28 00:22:54 -04:00
; fullscreen:
; frame0: $59396 = 365,462 cycles = roughly 2.7 fps
2022-09-27 01:34:56 -04:00
; Zero Page
GBASL = $26
GBASH = $27
H2 = $2C
COLOR = $30
HGR_X = $E0
HGR_Y = $E2
HGR_COLOR = $E4
HGR_HORIZ = $E5
HGR_PAGE = $E6
FRAME = $F0
FRAME2 = $F1
FRAME4 = $F2
X2 = $FB
COLORS = $FC
; Soft Switches
PAGE1 = $C054 ; Page1
PAGE2 = $C055 ; Page2
; ROM routines
HGR = $F3E2
HGR2 = $F3D8
HCLR = $F3F2
HPLOT0 = $F457 ;; plot at (Y,X), (A)
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y)
hgr_lookup_h = $1000
hgr_lookup_l = $1100
parallax:
;===================
; init screen
2022-09-27 02:24:19 -04:00
jsr HGR
2022-09-27 01:34:56 -04:00
jsr HGR2
;===================
; int tables
ldx #191
init_loop:
txa
pha
jsr HPOSN
pla
tax
lda GBASL
sta hgr_lookup_l,X
lda GBASH
2022-09-27 02:24:19 -04:00
and #$1F ; 20 30 001X 40 50 010X
2022-09-27 01:34:56 -04:00
sta hgr_lookup_h,X
dex
cpx #$ff
bne init_loop
parallax_forever:
inc FRAME ; 2
lda FRAME
lsr
2022-09-27 02:24:19 -04:00
; sta FRAME2
sta frame2_smc+1
2022-09-27 01:34:56 -04:00
lsr
2022-09-27 02:24:19 -04:00
; sta FRAME4
sta frame4_smc+1
2022-09-27 01:34:56 -04:00
;========================
; flip page
2022-09-27 02:24:19 -04:00
lda HGR_PAGE ; $40 or $20
2022-09-27 01:34:56 -04:00
2022-09-27 02:24:19 -04:00
eor #$60 ; flip draw_page
sta HGR_PAGE
2022-09-27 01:34:56 -04:00
2022-09-27 02:24:19 -04:00
asl
asl
rol
eor #$1
tay
lda PAGE1,Y
2022-09-27 01:34:56 -04:00
2022-09-27 02:24:19 -04:00
ldx #100 ; init Y
2022-09-27 01:34:56 -04:00
yloop:
;==============
2022-09-27 02:24:19 -04:00
; point output to current line
2022-09-27 01:34:56 -04:00
lda hgr_lookup_l,X
sta out_smc+1
lda hgr_lookup_h,X
2022-09-27 02:24:19 -04:00
ora HGR_PAGE
2022-09-27 01:34:56 -04:00
sta out_smc+2
;==============
; current column (work backwards)
2022-09-27 02:24:19 -04:00
ldy #29 ; 2
2022-09-27 01:34:56 -04:00
xloop:
;==============
; precalc X2
tya
asl
asl
sta X2
; calculate colors
; color = (XX-FRAME)^(YY)
;===========================
; LARGE
txa
2022-09-27 02:24:19 -04:00
; carry always clear here?
; sec ; subtract frame from Y
2022-09-27 01:34:56 -04:00
sbc FRAME
eor X2
and #$40
beq skip_color_large
lda #$ff
2022-09-27 02:24:19 -04:00
bne draw_color
2022-09-27 01:34:56 -04:00
skip_color_large:
;===========================
; MEDIUM
txa
sec ; subtract frame from Y
2022-09-27 02:24:19 -04:00
frame2_smc:
sbc #0
2022-09-27 01:34:56 -04:00
eor X2
and #$20
beq skip_color_medium
lda #$55
2022-09-27 02:24:19 -04:00
bne draw_color
2022-09-27 01:34:56 -04:00
skip_color_medium:
;===========================
; SMALL
2022-09-27 11:43:30 -04:00
txa ; 2
2022-09-27 01:34:56 -04:00
2022-09-27 11:43:30 -04:00
sec ; subtract frame from YY ; 2
2022-09-27 02:24:19 -04:00
frame4_smc:
2022-09-27 11:43:30 -04:00
sbc #0 ; 2
2022-09-27 01:34:56 -04:00
2022-09-27 11:43:30 -04:00
eor X2 ; 3
and #$10 ; 2
2022-09-27 01:34:56 -04:00
2022-09-27 11:43:30 -04:00
beq skip_color_small ; 2/3
lda #$aa ; 2
2022-09-27 01:34:56 -04:00
2022-09-27 11:43:30 -04:00
bne draw_color ; 2/3
2022-09-27 01:34:56 -04:00
skip_color_small:
2022-09-27 11:43:30 -04:00
; fallthrough is black
lda #$00 ; 2
2022-09-27 01:34:56 -04:00
;========================
; actually draw color
draw_color:
out_smc:
2022-09-27 11:43:30 -04:00
sta $2000,Y ; 5
2022-09-27 01:34:56 -04:00
2022-09-27 11:43:30 -04:00
dey ; 2
cpy #10 ; 2
bne xloop ; 2/3
2022-09-27 01:34:56 -04:00
2022-09-27 11:43:30 -04:00
dex ; 2
2022-09-27 01:34:56 -04:00
2022-09-27 02:24:19 -04:00
; cpx #$FF
2022-09-27 01:34:56 -04:00
2022-09-27 11:43:30 -04:00
bpl yloop ; 2/3
2022-09-27 01:34:56 -04:00
2022-09-27 11:43:30 -04:00
bmi parallax_forever ; 2/3
2022-09-27 01:34:56 -04:00
; for bot
; $3F5 - 127 + 3 = $379
2022-09-27 02:24:19 -04:00
; jmp parallax