ootw: intro, lots of elevator work

This commit is contained in:
Vince Weaver 2019-02-05 23:46:31 -05:00
parent a71cc5cd96
commit aac1918c27
4 changed files with 466 additions and 22 deletions

47
ootw/gr_plot.s Normal file
View File

@ -0,0 +1,47 @@
;================================
; plot routine
;================================
; Xcoord in X
; Ycoord in A
; color in COLOR
plot:
stx XPOS
lsr ; shift bottom bit into carry ; 2
bcc plot_even ; 2nt/3
plot_odd:
ldx #$f0 ; 2
bcs plot_c_done ; 2nt/3
plot_even:
ldx #$0f ; 2
plot_c_done:
stx MASK ; 3
asl ; shift back (now even) ; 2
tay
lda gr_offsets,Y ; lookup low-res memory address ; 4
clc ; 2
adc XPOS ; 3
sta GBASL ; 3
iny ; 2
lda gr_offsets,Y ; 4
adc DRAW_PAGE ; add in draw page offset ; 3
sta GBASH ; 3
ldy #0 ; 2
plot_write:
lda MASK ; 3
eor #$ff ; 2
and (GBASL),Y ; 5
sta COLOR_MASK ; 3
lda COLOR ; 3
and MASK ; 3
ora COLOR_MASK ; 3
sta (GBASL),Y ; 5
rts ; 6

54
ootw/gr_vlin.s Normal file
View File

@ -0,0 +1,54 @@
;=========================================
; vlin
;=========================================
; X, V2 at Y
vlin:
sty TEMPY ; save Y (x location)
vlin_loop:
txa ; a=x (get first y)
and #$fe ; Clear bottom bit
tay ;
lda gr_offsets,Y ; lookup low-res memory address low
sta GBASL ; put it into our indirect pointer
iny
lda gr_offsets,Y ; lookup low-res memory address high
clc
adc DRAW_PAGE ; add in draw page offset
sta GBASH ; put into top of indirect
ldy TEMPY ; load back in y (x offset)
txa ; load back in x (current y)
lsr ; check the low bit
bcc vlin_low ; if not set, skip to low
vlin_high:
lda #$F0 ; setup masks
sta MASK
lda #$0f
bcs vlin_too_slow
vlin_low: ; setup masks
lda #$0f
sta MASK
lda #$f0
vlin_too_slow:
and (GBASL),Y ; mask current byte
sta (GBASL),Y ; and store back
lda MASK ; mask the color
and COLOR
ora (GBASL),Y ; or into the right place
sta (GBASL),Y ; store it
inx ; increment X (current y)
cpx V2 ; compare to the limit
bcc vlin_loop ; if <= then loop
rts ; return

View File

@ -21,6 +21,8 @@ intro:
lda #0
sta DISP_PAGE
jmp elevator
;===============================
;===============================
; Opening scene with car
@ -112,23 +114,15 @@ intro:
jsr run_sequence
door_loop:
lda KEYPRESS
bpl door_loop
bit KEYRESET
;===============================
;===============================
; Elevator going down
;===============================
;===============================
elevator:
;=============================
; Load background to $c00
; Load background to $c00 and $1000
lda #>(elevator_rle)
sta GBASH
@ -136,19 +130,349 @@ door_loop:
sta GBASL
lda #$c ; load to off-screen $c00
jsr load_rle_gr
lda #>(elevator_rle)
sta GBASH
lda #<(elevator_rle)
sta GBASL
lda #$10 ; load to off-screen $c00
jsr load_rle_gr
;=================================
; copy $c00 to both pages $400/$800
jsr gr_copy_to_current
lda #$66
sta COLOR
; elevator outer door
ldx #39
stx V2
ldx #4
ldy #14
jsr vlin ; X, V2 at Y
ldx #35
stx V2
ldx #7
ldy #18
jsr vlin ; X, V2 at Y
; elevator inner door
ldx #2
stx ELEVATOR_COUNT
elevator_middle:
ldx #38
stx V2
ldx #5
ldy #15
jsr vlin ; X, V2 at Y
ldx #36
stx V2
ldx #6
ldy #17
jsr vlin ; X, V2 at Y
elevator_inner:
ldx #37
stx V2
ldx #5
ldy #16
jsr vlin ; X, V2 at Y
jsr page_flip
jsr gr_copy_to_current
elevator_loop:
lda KEYPRESS
bpl elevator_loop
bit KEYRESET
ldx #50
jsr long_wait
dec ELEVATOR_COUNT
lda ELEVATOR_COUNT
beq elevator_inner
cmp #1
beq elevator_middle
; door closed
jsr page_flip
ldx #100
jsr long_wait
;======================
; yellow line goes down
;======================
lda #0
sta COLOR
lda #5
sta V2
yellow_line_down:
jsr gr_copy_to_current
ldx #5
ldy #16
jsr vlin ; X, V2 at Y
jsr page_flip
ldx #12
jsr long_wait
inc V2
lda V2
cmp #38
bne yellow_line_down
lda DRAW_PAGE
pha
lda #$c ; erase yellow line
sta DRAW_PAGE ; on page $1000 version
ldx #5
ldy #16
jsr vlin ; X, V2 at Y
pla
sta DRAW_PAGE
;========================
; change floor indicators
;========================
lda #$33
sta COLOR
lda #5
sta V2
; 16,1
jsr gr_copy_to_current_1000
ldx #16
lda #1
jsr plot
jsr page_flip
ldx #150
jsr long_wait
; 18,2
jsr gr_copy_to_current_1000
ldx #18
lda #2
jsr plot
jsr page_flip
ldx #150
jsr long_wait
; 14,2
jsr gr_copy_to_current_1000
ldx #14
lda #2
jsr plot
jsr page_flip
ldx #150
jsr long_wait
; 16,3
jsr gr_copy_to_current_1000
ldx #16
lda #3
jsr plot
jsr page_flip
ldx #150
jsr long_wait
; 18,4
jsr gr_copy_to_current_1000
ldx #18
lda #4
jsr plot
jsr page_flip
ldx #150
jsr long_wait
;====================
; dark elevator
;====================
; clear $c00 to black
lda DRAW_PAGE
pha
lda #$8
sta DRAW_PAGE
jsr clear_all
pla
sta DRAW_PAGE
; blue from 20, 30 - 20,34 and yellow (brown?) from 20,0 to 20,30
; scrolls down until all yellow
lda #30
sta ELEVATOR_COUNT
going_down_loop:
jsr gr_copy_to_current ; copy black screen in
; draw the yellow part
lda #$DD
sta COLOR
lda ELEVATOR_COUNT
sta V2
ldx #0
ldy #20
jsr vlin ; X, V2 at Y
lda #$22 ; draw the blue part
sta COLOR
lda ELEVATOR_COUNT
clc
adc #4
cmp #40
bmi not_too_big
lda #40
not_too_big:
sta V2
ldx ELEVATOR_COUNT
ldy #20
jsr vlin ; X, V2 at Y
jsr page_flip
ldx #10 ; pause
jsr long_wait
inc ELEVATOR_COUNT
lda ELEVATOR_COUNT
cmp #40
bne going_down_loop
;=====================
; all yellow for a bit
;=====================
jsr gr_copy_to_current ; copy black screen in
lda #$DD
sta COLOR
lda #40
sta V2
ldx #0
ldy #20
jsr vlin ; X, V2 at Y
jsr page_flip
ldx #100 ; wait a bit
jsr long_wait
; single blue dot
; solid blue line 10 later
lda #2
sta ELEVATOR_CYCLE
going_down_repeat:
lda #1
sta ELEVATOR_COUNT
going_down_blue:
jsr gr_copy_to_current ; copy black screen in
; draw the blue part
lda #$22
sta COLOR
lda ELEVATOR_COUNT
sta V2
ldx #0
ldy #20
jsr vlin ; X, V2 at Y
gdb_smc:
lda #$dd ; draw the blue part
sta COLOR
lda #40
sta V2
ldx ELEVATOR_COUNT
ldy #20
jsr vlin ; X, V2 at Y
jsr page_flip
ldx #10 ; pause
jsr long_wait
inc ELEVATOR_COUNT
lda ELEVATOR_COUNT
cmp #40
bne going_down_blue
dec ELEVATOR_CYCLE
beq elevator_exit
lda #1
sta ELEVATOR_COUNT
going_down_black:
jsr gr_copy_to_current ; copy black screen in
; draw the blue part
lda #$00
sta COLOR
lda ELEVATOR_COUNT
sta V2
ldx #0
ldy #20
jsr vlin ; X, V2 at Y
lda #$22 ; draw the blue part
sta COLOR
lda #40
sta V2
ldx ELEVATOR_COUNT
ldy #20
jsr vlin ; X, V2 at Y
jsr page_flip
ldx #10 ; pause
jsr long_wait
inc ELEVATOR_COUNT
lda ELEVATOR_COUNT
cmp #40
bne going_down_black
lda #$00
sta gdb_smc+1
jmp going_down_repeat
; black, 2, blue, black about 20
; blue until hit bottom, doors open
elevator_exit:
ldx #100 ; pause
jsr long_wait
;===============================
;===============================
@ -171,8 +495,11 @@ elevator_loop:
; copy $c00 to both pages $400/$800
jsr gr_copy_to_current
; 13 14 15 16 17 18 19 20 21 22 23 24 25 26
jsr page_flip
jsr gr_copy_to_current
off_elevator_loop:
lda KEYPRESS
@ -481,6 +808,9 @@ gone_loop:
.include "gr_copy.s"
.include "gr_offsets.s"
.include "gr_overlay.s"
.include "gr_vlin.s"
.include "gr_plot.s"
.include "gr_fast_clear.s"
; background graphics
.include "intro_graphics/01_building/intro_building.inc"
@ -515,11 +845,7 @@ run_sequence_loop:
beq run_sequence_done
tax
run_sequence_timer:
lda #64
jsr WAIT ; delay
dex
bne run_sequence_timer
jsr long_wait
iny
@ -541,6 +867,19 @@ run_sequence_timer:
run_sequence_done:
rts
;=====================
; long(er) wait
; waits approximately ?? ms
long_wait:
lda #64
jsr WAIT ; delay
dex
bne long_wait
rts
;========================
; Car driving up sequence

View File

@ -24,8 +24,10 @@ BASH = $29
H2 = $2C
V2 = $2D
MASK = $2E
COLOR_MASK = $2F
COLOR = $30
SEEDL = $4e
SEEDH = $4f
@ -161,8 +163,10 @@ GAIT = $F6
TENTACLE_X = $F7
TENTACLE_PROGRESS = $F8
SLUGDEATH_PROGRESS = $F8
ELEVATOR_CYCLE = $F8
TENTACLE_GRAB = $F9
SLUGDEATH = $F9
ELEVATOR_COUNT = $F9
TEMP = $FA
TEMPY = $FB
INL = $FC