duke: fix help, work on jumping

This commit is contained in:
Vince Weaver 2020-12-11 01:24:47 -05:00
parent 0734d018e0
commit 07ab4b88f4
8 changed files with 263 additions and 11 deletions

View File

@ -26,7 +26,7 @@ DUKE: duke.o
ld65 -o DUKE duke.o -C ../linker_scripts/apple2_2000.inc
duke.o: duke.s zp.inc hardware.inc duke.s \
print_help.s \
print_help.s gr_fast_clear.s \
graphics/duke_graphics.inc \
maps/level1_map.lzsa \
status_bar.s draw_duke.s gr_putsprite_crop.s \

21
duke/TODO Normal file
View File

@ -0,0 +1,21 @@
collision detection left/right
collision detection up (hit head on jump)
only calculate position once
hook up title screen
mystery level 2
more complete map
status: keep score, proper laser count
Different sprites for left, right, shooting
When land, kicks up dust
Enemy? Little robot, green crawly
Sound effects?
Pick up items? red key inverse-R

View File

@ -93,6 +93,9 @@ check_falling:
; block index below feet is (y+10)*16/4 + (x/2) + 1
; if 18,18 -> 28*16/4 = 112 + 9 = 121 = 7R9
lda DUKE_Y
clc
adc #10
@ -110,17 +113,43 @@ check_falling:
tax
lda TILEMAP,X
; if < 32 then we fall
; if tile# < 32 then we fall
cmp #32
bcs done_check_below
bcs feet_on_ground ; bge
; scroll
;=======================
; falling
; scroll but only if Y=18
lda DUKE_Y
cmp #18
bne scroll_fall
inc DUKE_Y
inc DUKE_Y
jmp done_check_falling
scroll_fall:
inc TILEMAP_Y
jsr copy_tilemap_subset
jmp done_check_falling
feet_on_ground:
; check to see if Y still hi, if so scroll back down
lda DUKE_Y
cmp #18
beq done_check_falling
inc DUKE_Y
inc DUKE_Y
dec TILEMAP_Y ; share w above?
jsr copy_tilemap_subset
done_check_below:
done_check_falling:
rts

View File

@ -150,7 +150,7 @@ done_with_duke:
.include "text_print.s"
.include "gr_offsets.s"
; .include "gr_fast_clear.s"
.include "gr_fast_clear.s"
.include "gr_copy.s"
.include "gr_pageflip.s"
.include "gr_putsprite_crop.s"

201
duke/gr_fast_clear.s Normal file
View File

@ -0,0 +1,201 @@
;clear_screens:
; ;===================================
; ; Clear top/bottom of page 0
; ;===================================
;
; lda #$0
; sta DRAW_PAGE
; jsr clear_top
; jsr clear_bottom
; ;===================================
; ; Clear top/bottom of page 1
; ;===================================
;
; lda #$4
; sta DRAW_PAGE
; jsr clear_top
; jsr clear_bottom
;
; rts
;=========================================================
; clear_top
;=========================================================
; clear DRAW_PAGE
; original = 14,558 cycles(?) 15ms, 70Hz
; OPTIMIZED MAX (page0,48rows): 45*120+4+6 = 5410 = 5.4ms 185Hz
; (pageX,40rows): 50*120+4+6 = 6010 = 6.0ms 166Hz
; 50*120+4+6+37 = 6055 = 6.0ms 166Hz
clear_top:
lda #0 ; 2
clear_top_a:
sta COLOR ; 3
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __ctf+2 ; 3
sta __ctf+5 ; 3
adc #1 ; 2
sta __ctf+8 ; 3
sta __ctf+11 ; 3
adc #1 ; 2
sta __ctf2+2 ; 3
sta __ctf2+5 ; 3
adc #1 ; 2
sta __ctf2+8 ; 3
sta __ctf2+11 ; 3
ldy #120 ; 2
lda COLOR ; 3
clear_top_fast_loop:
__ctf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
cpy #80 ; 2
bpl no_draw_bottom ; 2nt/3
__ctf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
no_draw_bottom:
dey ; 2
bpl clear_top_fast_loop ; 2nt/3
rts ; 6
;=========================================================
; clear_bottom
;=========================================================
; clear bottom of draw page
clear_bottom:
clc ; 2
lda DRAW_PAGE ; 3
adc #6 ; 2
sta __cbf2+2 ; 3
sta __cbf2+5 ; 3
adc #1 ; 2
sta __cbf2+8 ; 3
sta __cbf2+11 ; 3
ldy #120 ; 2
lda #$a0 ; Normal Space ; 2
clear_bottom_fast_loop:
__cbf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
cpy #80 ; 2
bpl clear_bottom_fast_loop ; 2nt/3
rts ; 6
;clear_screens_notext:
;===================================
; Clear top/bottom of page 0
;===================================
; lda #$0
; sta DRAW_PAGE
; jsr clear_all
;===================================
; Clear top/bottom of page 1
;===================================
; lda #$4
; sta DRAW_PAGE
; jsr clear_all
; rts
clear_bottoms:
lda DRAW_PAGE
pha
;===================================
; Clear bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_bottom
;===================================
; Clear bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_bottom
pla
sta DRAW_PAGE
rts
;=========================================================
; clear_all
;=========================================================
; clear 48 rows
clear_all:
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __caf+2 ; 3
sta __caf+5 ; 3
adc #1 ; 2
sta __caf+8 ; 3
sta __caf+11 ; 3
adc #1 ; 2
sta __caf2+2 ; 3
sta __caf2+5 ; 3
adc #1 ; 2
sta __caf2+8 ; 3
sta __caf2+11 ; 3
ldy #120 ; 2
clear_all_color:
lda #' '|$80 ; 2
clear_all_fast_loop:
__caf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
__caf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
bpl clear_all_fast_loop ; 2nt/3
rts ; 6

View File

@ -185,14 +185,14 @@ done_down_pressed:
check_space:
cmp #' '
beq space_pressed
bne check_return
space_pressed:
; jump
lda DUKE_JUMPING
bne done_keypress ; don't jump if already jumping
lda #5
lda #6
sta DUKE_JUMPING
jmp done_keypress

View File

@ -17,8 +17,6 @@ tiles:
tile0f: .byte $00,$76,$f7,$05
tilemap:
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$09,$08,$01,$01,$01,$01
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$05,$06,$06,$06,$06,$06
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$0f,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
@ -27,4 +25,6 @@ tilemap:
.byte $00,$00,$00,$00,$00,$00,$00,$0c,$0d,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$0b,$0e,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$02,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03,$03
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$09,$08,$01,$01,$01,$01
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$05,$06,$06,$06,$06,$06

View File

@ -3,7 +3,8 @@
print_help:
bit KEYRESET ; clear keyboard
bit SET_TEXT
jsr HOME
jsr clear_all
lda #<help_text
sta OUTL