From: Lukas Krickl Date: Tue, 8 Apr 2025 10:54:24 +0000 (+0200) Subject: cells: wip cell update code X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=c1092503e3bb06cedfc140bdc196b8cca26bc0b1;p=gbrg%2F.git cells: wip cell update code --- diff --git a/src/cells.s b/src/cells.s index e3e4ae6..13c0bf5 100644 --- a/src/cells.s +++ b/src/cells.s @@ -3,9 +3,40 @@ ; does not call c_st_routine if c_head_offset != 0 ; inputs: ; de: cell ptr - ; returns: - ; de: next cell ptr cell_update: + ld hl, c_head_offset + add hl, de ; hl = c_head_offset for current cell + ld a, [hl] ; a = head offset + cp a, 0 + ; if not head cell return + ret nz + + ; save cell ptr + push de + + ; otherwise call update routine + ld hl, c_st_routine + add hl, de ; hl = ptr to routine to call + + push hl + pop bc ; bc = ptr to rotuine to call + ld a, [bc] + ld l, a + inc bc + ld a, [bc] + ld h, a ; hl = update routine + + ; cell ptr has to be passed + ; to call + pop de + call call_hl + + ; restore cell ptr + pop de + + ; TODO: write new s_st_routine + ; if bc is not 0000 + ret ; default road update state