From 4331b0a8cbe6bd56ed8abb2eebf5629ea41ba27d Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Thu, 5 Jun 2025 09:18:09 +0200 Subject: [PATCH] dice: wip dice display --- src/defs.s | 7 +++++++ src/rand.s | 42 ++++++++++++++++++++++++++++++++++++++++++ src/wram.s | 9 +++++++++ 3 files changed, 58 insertions(+) diff --git a/src/defs.s b/src/defs.s index 25b9a25..e36c868 100644 --- a/src/defs.s +++ b/src/defs.s @@ -197,3 +197,10 @@ ; 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 diff --git a/src/rand.s b/src/rand.s index 1fb95f1..a8382d3 100644 --- a/src/rand.s +++ b/src/rand.s @@ -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 diff --git a/src/wram.s b/src/wram.s index 90e40cc..d5a2a98 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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 -- 2.30.2