aboutsummaryrefslogtreecommitdiff
path: root/lib/cpcrslib/cpc_CollSp.s
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-11-05 11:22:55 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-11-05 11:31:28 +0000
commit2fbdf974338bde8576efdae40a819a76b2391033 (patch)
tree64d41a37470143f142344f9a439d96de3e7918c2 /lib/cpcrslib/cpc_CollSp.s
downloadkitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.tar.gz
kitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.zip
Initial import of the open source release
Diffstat (limited to 'lib/cpcrslib/cpc_CollSp.s')
-rw-r--r--lib/cpcrslib/cpc_CollSp.s126
1 files changed, 126 insertions, 0 deletions
diff --git a/lib/cpcrslib/cpc_CollSp.s b/lib/cpcrslib/cpc_CollSp.s
new file mode 100644
index 0000000..08bd02a
--- /dev/null
+++ b/lib/cpcrslib/cpc_CollSp.s
@@ -0,0 +1,126 @@
+.globl _cpc_CollSp
+
+_cpc_CollSp::
+;first parameter sprite
+;second parameter value
+ ld hl,#2
+ add hl,sp
+
+ ;ld ix,#2
+ ;add ix,sp
+; ld e,2 (ix)
+; ld d,3 (ix)
+ ;A=x value
+; ld l,0 (ix)
+; ld h,1 (ix)
+
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ push de
+ inc hl
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ push de
+
+ pop iy ;ix sprite2 data
+
+ pop ix ;iy sprite1 data
+
+ ;Sprite coords & sprite dims
+
+;COLISION_sprites
+
+
+
+;entran sprite1 y sprite 2 y se actualizan los datos
+;ix apunta a sprite1
+;iy apunta a sprite2
+
+;coordenadas
+ ld l,8 (ix)
+ ld h,9 (ix)
+ LD (#SPR2X),HL
+
+ ld l,8 (iy)
+ ld h,9 (iy)
+ LD (#SPR1X),HL
+
+;dimensiones sprite 1
+ ld l,0 (ix)
+ ld h,1 (ix)
+ ld b,(hl)
+ inc hl
+ ld c,(hl)
+;dimensiones sprite 12
+ ld l,0 (iy)
+ ld h,1 (iy)
+ ld d,(hl)
+ inc hl
+ ld e,(hl)
+
+
+ ;ld e,(ix+6)
+ ;ld d,(ix+7)
+
+
+
+;ld de,DIMENSIONES_SP_PPAL ;dimensiones sprite 2
+;ld bc,DIMENSIONES_SP_PPAL ;dimensiones sprite 1
+CALL TOCADO
+;RET NC ;vuelve si no hay colision
+ld h,#0
+JP nc,no_colision
+;Aquí hay colisión
+ld l,#1
+RET
+
+no_colision:
+ld l,h
+ret
+
+TOCADO:
+ LD HL,#SPR2X
+ LD A,(#SPR1X)
+ CP (HL)
+ jp C,C1
+ LD A,(HL)
+ ADD A,B ;alto del sprite1
+ LD B,A
+ LD A,(#SPR1X)
+ SUB B
+ RET NC
+ jp COMPROBAR
+C1:
+ ADD A,D ;alto sprite2
+ LD D,A
+ LD A,(HL)
+ SUB D
+ RET NC
+COMPROBAR:
+ INC HL
+ LD A,(#SPR1Y)
+ CP (HL)
+ jp C,C2
+ LD A,(HL)
+ ADD A,C
+ LD C,A
+ LD A,(#SPR1Y)
+ SUB C
+ RET
+C2:
+ ADD A,E
+ LD E,A
+ LD A,(HL)
+ SUB E
+ RET
+
+SPR1X:
+.db 0
+SPR1Y:
+.db 0
+SPR2X:
+.db 0
+SPR2Y:
+.db 0