actor: unit_generic_draw now draws 2 objects per actor
authorLukas Krickl <lukas@krickl.dev>
Tue, 1 Jul 2025 14:33:04 +0000 (16:33 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 1 Jul 2025 14:33:04 +0000 (16:33 +0200)
src/defs.s
src/unit.s

index 807ac3a8266f924f1971acc7065125a89648cb13..af6561e1adead5923c2fb0b6d444f835272fc064 100644 (file)
   ; returns:
   ;   bc: null
 .de act_draw, 2
+  
+  ; act_oam_tile + flags
+  ; if using generic draw:
+  ;   2 tiles are used
+  ;   tile 1 is the tile specified here
+  ;   tile 2 is the tile following tile 1
+  ;   flags are used for both tiles
+  ; optional:
+  ;   tile + flags may be a pointer to a
+  ;   tile table. This can be implemented as needed
 .de act_oam_tile, 1
 .de act_oam_flags, 1
   
index bb1152560e33a192a4fecf692f5ec4793cb69dbb..21f1f0b5ea1a963454fc97648d31c5197dbc8784 100644 (file)
@@ -75,8 +75,19 @@ unit_draw:
   ld b, a ; tile
   ld a, [hl]
   ld c, a ; flags
+  ld a, 0 ; no x-offset
+  push bc
   call unit_generic_draw
+  
+  ; draw same tile again 
+  pop bc
   pop de
+  push de
+  inc b ; b++
+  ld a, 8 ; 8 x-offset
+  call unit_generic_draw 
+  pop de
+
   ldnull bc
   ret
 
@@ -145,10 +156,14 @@ unit_generic_draw_adjust_subtile:
   ; draws any unit
   ; inputs:
   ;  de: actor
-  ;   b: tile
+  ;   a: x-offset for tiles
+  ;   b: tile1
   ;   c: flags
 unit_generic_draw:
 #define TMP_OAMFLAG_PRIO scratch
+#define TMP_X_OFFSET scratch+1
+  ld [TMP_X_OFFSET], a ; save for later
+
   push de ; save actor
 
   xor a, a
@@ -185,6 +200,9 @@ unit_generic_draw:
   mul16 a
   add a, OBJ_OFF_X
   sub a, c
+  ld c, a 
+  ld a, [TMP_X_OFFSET]
+  add a, c
   ld [hl+], a
   
   pop bc ; bc = inputs again
@@ -208,6 +226,7 @@ unit_generic_draw:
   ldnull bc
   ret
 #undefine TMP_OAMFLAG_PRIO
+#undefine TMP_X_OFFSET
 
   ; generic unit input handler
   ; inputs: