From a47d943b8b878656170e78e50c1fda0b8da23187 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 26 Jan 2025 19:43:51 +0100 Subject: [PATCH] collision: Removed dead code --- src/collision.s | 94 ------------------------------------------------- src/player.s | 22 ------------ 2 files changed, 116 deletions(-) diff --git a/src/collision.s b/src/collision.s index 6c8abec..a0562d8 100644 --- a/src/collision.s +++ b/src/collision.s @@ -1,99 +1,5 @@ - ; collision shapes: - ; a collision shape is a collection of dots - ; relative to a sprite - ; structure: - ; N: Amount of dots - ; Y: y position - ; X: x position - ; y and x repeat until N is reached - ; player -> act collision - ; each sprite will check statically for collision - ; with the player by using pt -> rec collision - - ; act -> act collision - ; actors should flag their current location in map flags - ; actors should simply avoid moving onto tiles that are already busy - - ; defines a collision header - ; inputs: - ; $1: N -#macro col_head - .db $1 -#endmacro - - ; defines a collsion point - ; inputs: - ; $1: y - ; $2: x -#macro col_point - .db $1, $2 -#endmacro - -collision_player: - col_head 1 - col_point 0, 0 - - - ; checks an entire collision table based on an original point - ; and a ptr to a collision point table - ; inputs: - ; hl: ptr to y/x position - ; de: collision point table - ; ct_mask: bit mask for flag to check - ; returns: - ; a = 0 -> no collision - ; a = 1 -> collision -collision_tile_table_check: - ld a, [hl+] - ld [ct_poy], a ; y buffer - ld a, [hl] - ld [ct_pox], a ; x buffer - - ld a, [de] ; load loop counter - inc de ; de + 1 = first point y coordinate -@loop: - push af - - ld a, [de] - ld l, a - ld a, [ct_poy] - add a, l ; a = y + collision y offset - ld l, a ; store y result in l for now - inc de ; de++ == x pos - - ld a, [de] - ld h, a - ld a, [ct_pox] - add a, h ; a = x + collision x offset - inc de ; de++ == next y - push de ; save de for next iteratin - - ld d, l ; d = y - ld e, a ; e = x - - call collision_tile - cp a, 0 - jr nz, @done REL - - pop de - pop af - - dec a ; a-- - cp a, 0 ; again if not 0 - jp nz, @loop - - ret -@done: - ; we need to pop before ret! - ; the register values - ; do not matter too much at this point - ; but a needs to be preserved - pop de - pop de - ret - ; checks a point ; with a map's meta tile ; if the tile has collision flag set diff --git a/src/player.s b/src/player.s index 272ad92..531213e 100644 --- a/src/player.s +++ b/src/player.s @@ -51,28 +51,6 @@ player_init: ret - ; performs a simple collision check - ; inputs: - ; $1: collision table - ; hl: y/x coordinate - ; returns: - ; z/nz -> collision hit or not -#macro player_collision_check - ; check collision - ; 1) save registers - push hl - push de - - ; 2) hl = player_y already - ; 3) load correct collision points - ld de, $1 - call collision_tile_table_check - pop de - pop hl - - cp a, 0 -#endmacro - ; update the player ; players do not behave like regular actors ; and are not allocate to the regular -- 2.30.2