"Buck Rogers"-style perspective scrolling
Posted: Sat Sep 26, 2009 9:01 am
Hi,
Here's some quick code to do the perspective raster effect. It's also the basis of a 'trailblazer' if you add some road gfx and alternate the multicolours. This is for PAL machines, though I imagine you only need to change the 'nops' in the display routine to get it working on NTSC.
Here's some quick code to do the perspective raster effect. It's also the basis of a 'trailblazer' if you add some road gfx and alternate the multicolours. This is for PAL machines, though I imagine you only need to change the 'nops' in the display routine to get it working on NTSC.
Code: Select all
sei
loop
;; Draw raster landscape from table at $1c00
;; Obviously the huge 'nop' delay can be replaced with something useful, it just moves the
;; raster splits off the screen for tidyness.
ldx #$48
ldy #$00
waitrast
cpx $9004
bne waitrast
lda $1c00,y
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
sta $900f
iny
inx
cpx #$90
bne waitrast
lda #$00
sta $900f
; Calculate perspective table
lda #$00
sta ploton+$01
lda #$04
sta trailts
trailround
ldx trailts
lda trailadd,x
sta trailaddcode+$01
lda trailtime,x
sta trailtemp
lda #$18
sta trailtable+$02
lda #$00
sta trailtable+$01
ldx offset
rast0
txa
trailaddcode adc #$04
tax
trailtable lda $1800,x
ploton sta $1c00
inc ploton+$01
dec trailtemp
lda trailtemp
cmp #$00
bne rast0
stx offset
dec trailts
bpl trailround
clc
lda offset2
; Speed to move through landscape (positive numbers go backwards)
sbc #$04
sta offset2
sta offset
jmp loop
offset .byte $00
offset2 .byte $00
trailts .byte $00
trailtemp .byte $00
; Amount to skip through colour table to create perspective
trailadd .byte $01,$02,$04,$08,$10
; Duration for each stage of perspective.
trailtime .byte $33,$1f,$0f,$07,$03
; Colour table, alternating between red & yellow on 256 byte boundries.
* = $1800
.byte $2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a
.byte $2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$2a,$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