Page 1 of 1

"Buck Rogers"-style perspective scrolling

Posted: Sat Sep 26, 2009 9:01 am
by 4mat/atebit
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.

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,$2a,$2a,$2a,$2a,$2a
.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,$2a,$2a,$2a,$2a,$2a
      
.byte $7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f
.byte $7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f
.byte $7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f     
.byte $7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f
       
.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,$2a,$2a,$2a,$2a,$2a
.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,$2a,$2a,$2a,$2a,$2a

.byte $7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f
.byte $7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f
.byte $7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f     
.byte $7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f,$7f

Posted: Sat Sep 26, 2009 9:03 am
by 4mat/atebit
oops, that should be '64 byte boundries' ^^^^^ :)

Posted: Sat Oct 10, 2009 7:03 am
by Victragic
Wow, thanks for the code..

I had been working on trying to do a Vic20 conversion of the C16 Trailblazer game for a while, but could not get the rolling motion right.

I gave up in frustration, because I couldn't work out the formula.. there were either too many steps visible, or too few, but mostly, the motion just plain sucked - too slow, too jerky, or a 'crawling' effect.

I should dig out my original abandoned code, when I have some more time.

Posted: Sat Oct 10, 2009 7:05 am
by Victragic
so I already have the road graphics, and I think they look pretty good, in case anyone is eager to try this out...

(may need some tweaking to match the raster lines)

Posted: Mon Oct 12, 2009 7:04 am
by Kweepa
I would love to see a demo of this in action.

Posted: Fri Oct 16, 2009 12:55 am
by Victragic
Okay,

firstly excuse the fact it's just all over the shop - this was a 10-minute job.

It's a huge file, in reality it's not - all blank space. Try it it on a VICE PAL Vic + 8K (that's the target for the game)

I just realised when running it - the width of my lines is all wrong... centre line is too wide, lines next to it too narrow.

http://users.adam.com.au/grichards/blazer.prg

SYS8192

Posted: Fri Oct 16, 2009 6:24 am
by Jeff-20
amazing

Posted: Fri Oct 16, 2009 7:03 am
by Pedro Lambrini
Please make this happen! Trailblazer's a great game on other platforms but it would be nice to have a nice port on the wee Vic. :)

Posted: Fri Oct 16, 2009 8:07 am
by 4mat/atebit
Nice job!

Posted: Fri Oct 16, 2009 8:30 am
by orion70
Image
Yes please, please, Trailblazer for the VIC!!!! (infantilization due to overexposure to this forum 8) )

Posted: Fri Oct 16, 2009 10:23 am
by Mayhem
It's certainly a start in the right direction :D

Posted: Fri Oct 16, 2009 10:47 am
by nbla000
Victragic wrote:firstly excuse the fact it's just all over the shop - this was a 10-minute job.
WOW :shock:

I must say that is a very good start point :wink:

Posted: Fri Oct 16, 2009 12:34 pm
by Ivanhoe76
Oh my god!!!! That's the smoothest perspective raster effect I've ever seen since Trailblazer for the "big brother" (C64)!!! I cannot believe it's just a "poor" vic that make it work!!!! Excellent work victragic, go on this way!

Posted: Fri Oct 16, 2009 8:31 pm
by Victragic
Really at this stage it's just an effect thanks to 4mat's code..

I might start a WIP thread with this project as it's going..

this will be based on the original C16 game, one of the finest games I was fortunate to own for my Plus/4..

I reckon they could easily have released a version for Vic +8K.. but no-one was developing for Vic any more by the time this was put out by Gremlin..

Posted: Mon Oct 19, 2009 5:54 am
by nbla000
So a Vic porting of a good C16 game, very nice project :wink:

I'm looking forward for your next WIP thread...