dice: wip dice display
authorLukas Krickl <lukas@krickl.dev>
Thu, 5 Jun 2025 07:18:09 +0000 (09:18 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 5 Jun 2025 07:18:09 +0000 (09:18 +0200)
src/defs.s
src/rand.s
src/wram.s

index 25b9a250eb5d7d20e39ddd1c57e0c7c55b4877c1..e36c8684a9f0969eefdf90844e42a70ff9140596 100644 (file)
 ; and interprets the next 
 ; byte as a number
 #define TEXT_NUMBER 0x80
+
+  ; dice display
+
+  ; constants
+#define DD_TIME 90 
+#define DD_D0_TILE 0x10 
+#define DD_CROSS_TILE 0x20
index 1fb95f1b9355852da9e8e414159509a178dc27e0..a8382d35ab44e754fc183e44ee6eaf03c1fa8969 100644 (file)
@@ -92,3 +92,45 @@ roll_d16:
   pop hl
   ret
 
+
+
+  ; draws the last d16 result 
+  ; at a tile position for n frames
+  ; inputs:
+  ;   b/c: y/x tile
+  ;     a: dice display flags/0
+  ;   d16: roll to display
+dice_display_set:
+  ; set flags
+  ld a, [dd_flags]
+
+  ; set timer
+  ld a, DD_TIME
+  ld [dd_timer], a
+
+  ; set position
+  ld a, b
+  ld [dd_y], a
+  ld a, c
+  ld [dd_x], a
+
+  ld b, DD_D0_TILE
+  ld a, [d16]
+  add a, b ; d0 + roll value of d16
+  ld a, [dd_d16] ; tile to display 
+
+
+  ret
+  
+  ; updates dice display if the timer is not 0
+dice_display_update:
+  ld a, [dd_timer]
+  cp a, 0
+  ret z
+
+  dec a ; timer--
+  ld [dd_timer], a
+  
+  
+
+  ret
index 90e40cca44175baad1ffb4e000ceff5cc82cd66e..d5a2a98c9e64dd723b4a0f90956772495a9e0b16 100644 (file)
@@ -19,6 +19,15 @@ game_mode: .adv st_size
   ; status text buffer
 status_text: .adv 32
 
+; dice display
+; display the last d16 result 
+; at tile y/x for time frames
+dd_d16: .adv 1
+dd_flags: .adv 1
+dd_y: .adv 1
+dd_x: .adv 1
+dd_timer: .adv 1
+
 ; current best init found in units_next
 unit_next_best_init: .adv 1
 unit_next_best_act_ptr: .adv 2