; 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