From ed5053bb1e6aa142a0575c79af55fd5a80f268ef Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 14 Apr 2024 22:17:26 -0400 Subject: [PATCH] keen: sort of got collision going on mars map --- games/keen/Makefile | 2 +- games/keen/TODO | 1 + games/keen/common_defines.inc | 2 +- games/keen/draw_tilemap.s | 4 +- games/keen/level1_enemies.s | 6 +-- games/keen/mars.s | 2 + games/keen/mars_keyboard.s | 98 ++++++++++++++++++++++++++++++++++- games/keen/tilemap_lookup.s | 57 ++++++++++++++++++++ 8 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 games/keen/tilemap_lookup.s diff --git a/games/keen/Makefile b/games/keen/Makefile index 298befa4..bbc9faad 100644 --- a/games/keen/Makefile +++ b/games/keen/Makefile @@ -54,7 +54,7 @@ mars.o: mars.s zp.inc hardware.inc game_over.s \ gr_fade.s \ mars_keyboard.s draw_tilemap.s \ mars_sfx.s longer_sound.s \ - text_help.s \ + text_help.s tilemap_lookup.s \ maps/mars_map.zx02 graphics/parts.gr.zx02 ca65 -o mars.o mars.s -l mars.lst diff --git a/games/keen/TODO b/games/keen/TODO index 4bace426..660641e3 100644 --- a/games/keen/TODO +++ b/games/keen/TODO @@ -6,6 +6,7 @@ title mars map ~~~~~~~~ + + make tiles for first level and green level impassable + animate stars + enforce collision detection + proper smooth movement diff --git a/games/keen/common_defines.inc b/games/keen/common_defines.inc index 412aec8a..8e945fa8 100644 --- a/games/keen/common_defines.inc +++ b/games/keen/common_defines.inc @@ -6,5 +6,5 @@ LOAD_KEEN2 = 3 tiles = $9000 big_tilemap = $9400 -tilemap = $BC00 +small_tilemap = $BC00 diff --git a/games/keen/draw_tilemap.s b/games/keen/draw_tilemap.s index 273f6ab5..02627446 100644 --- a/games/keen/draw_tilemap.s +++ b/games/keen/draw_tilemap.s @@ -31,7 +31,7 @@ tilemap_outer_loop: tilemap_loop: ldx TILEMAP_OFFSET ; get actual tile number - lda tilemap,X ; from tilemap + lda small_tilemap,X ; from tilemap asl ; *4 ; point to tile to draw (4 bytes each) asl @@ -144,7 +144,7 @@ skip_odd_row: sta cptl1_smc+2 ; set proper row in big tilemap - lda #big_tilemap + sta INH + ldy MARS_TILEX + iny + + lda (INL),Y + + cmp #32 + bcs done_right_pressed + + move_right: lda TILEMAP_X @@ -202,6 +261,26 @@ check_up: bne check_down up_pressed: + + ; check if allowed to move up + + ldx MARS_TILEY + dex ; look one up + + lda tilemap_lookup_high,X + sta INH + lda tilemap_lookup_low,X + sta INL + + ldy MARS_TILEX + + lda (INL),Y + + cmp #32 + bcs done_up_pressed + + + lda MARS_TILEY cmp #0 ; not needed beq move_keen_up @@ -251,6 +330,24 @@ check_down: bne check_space down_pressed: + ; check if allowed to move down + + ldx MARS_TILEY + inx ; look one down + + lda tilemap_lookup_high,X + sta INH + lda tilemap_lookup_low,X + sta INL + + ldy MARS_TILEX + + lda (INL),Y + + cmp #32 + bcs done_down_pressed + + sec lda MARS_TILEY sbc TILEMAP_Y @@ -324,4 +421,3 @@ no_keypress: bit KEYRESET rts - diff --git a/games/keen/tilemap_lookup.s b/games/keen/tilemap_lookup.s new file mode 100644 index 00000000..f8549fc7 --- /dev/null +++ b/games/keen/tilemap_lookup.s @@ -0,0 +1,57 @@ + + +; we could calculate this if necessary + +tilemap_lookup_high: +.byte (>big_tilemap)+ 0,(>big_tilemap)+ 0 ; 0,1 +.byte (>big_tilemap)+ 1,(>big_tilemap)+ 1 ; 2,3 +.byte (>big_tilemap)+ 2,(>big_tilemap)+ 2 ; 4,5 +.byte (>big_tilemap)+ 3,(>big_tilemap)+ 3 ; 6,7 +.byte (>big_tilemap)+ 4,(>big_tilemap)+ 4 ; 8,9 +.byte (>big_tilemap)+ 5,(>big_tilemap)+ 5 ; 10,11 +.byte (>big_tilemap)+ 6,(>big_tilemap)+ 6 ; 12,13 +.byte (>big_tilemap)+ 7,(>big_tilemap)+ 7 ; 14,15 +.byte (>big_tilemap)+ 8,(>big_tilemap)+ 8 ; 16,17 +.byte (>big_tilemap)+ 9,(>big_tilemap)+ 9 ; 18,19 +.byte (>big_tilemap)+10,(>big_tilemap)+ 0 ; 20,21 +.byte (>big_tilemap)+11,(>big_tilemap)+11 ; 22,23 +.byte (>big_tilemap)+12,(>big_tilemap)+12 ; 24,25 +.byte (>big_tilemap)+13,(>big_tilemap)+13 ; 26,27 +.byte (>big_tilemap)+14,(>big_tilemap)+14 ; 28,29 +.byte (>big_tilemap)+15,(>big_tilemap)+15 ; 30,31 +.byte (>big_tilemap)+16,(>big_tilemap)+16 ; 32,33 +.byte (>big_tilemap)+17,(>big_tilemap)+17 ; 34,35 +.byte (>big_tilemap)+18,(>big_tilemap)+18 ; 36,37 +.byte (>big_tilemap)+19,(>big_tilemap)+19 ; 38,39 +.byte (>big_tilemap)+20,(>big_tilemap)+20 ; 40,41 +.byte (>big_tilemap)+21,(>big_tilemap)+21 ; 42,43 +.byte (>big_tilemap)+22,(>big_tilemap)+22 ; 44,45 +.byte (>big_tilemap)+23,(>big_tilemap)+23 ; 46,47 +.byte (>big_tilemap)+24,(>big_tilemap)+24 ; 48,49 +.byte (>big_tilemap)+25,(>big_tilemap)+25 ; 50,51 +.byte (>big_tilemap)+26,(>big_tilemap)+26 ; 52,53 +.byte (>big_tilemap)+27,(>big_tilemap)+27 ; 54,55 +.byte (>big_tilemap)+28,(>big_tilemap)+28 ; 56,57 +.byte (>big_tilemap)+29,(>big_tilemap)+29 ; 58,59 +.byte (>big_tilemap)+30,(>big_tilemap)+30 ; 60,61 +.byte (>big_tilemap)+31,(>big_tilemap)+31 ; 62,63 +.byte (>big_tilemap)+32,(>big_tilemap)+32 ; 64,65 +.byte (>big_tilemap)+33,(>big_tilemap)+33 ; 66,67 +.byte (>big_tilemap)+34,(>big_tilemap)+34 ; 68,69 +.byte (>big_tilemap)+35,(>big_tilemap)+35 ; 70,71 +.byte (>big_tilemap)+36,(>big_tilemap)+36 ; 72,73 +.byte (>big_tilemap)+37,(>big_tilemap)+37 ; 74,75 +.byte (>big_tilemap)+38,(>big_tilemap)+38 ; 76,77 +.byte (>big_tilemap)+39,(>big_tilemap)+39 ; 78,79 + +tilemap_lookup_low: +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 +.byte $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80