···304304 cp %00001000
305305 jp nz, .Body5
306306 ; REG_A = REG_D % wCurrentWidth
307307+ push bc ; AND (REG_D % wCurrentWidth) > 0
308308+ ld a, d
309309+ ld hl, wCurrentWidth
310310+ ld c, [hl]
311311+ call Modulo
312312+ pop bc
307313 cp 0
308314 jp nc, .FuncEnd ; RETURN
309315 jp z, .FuncEnd
···312318 ld a, d ; IF REG_D == BIT_DOOR_WEST
313319 cp %00100000
314320 jp nz, .FuncEnd
315315- ; REG_A = REG_D % wCurrentWidth
321321+ push bc ; AND (REG_D % wCurrentWidth) < (wCurrentWidth - 1)
322322+ ld a, d
323323+ ld hl, wCurrentWidth
324324+ ld c, [hl]
325325+ call Modulo
326326+ pop bc
316327 ld hl, wCurrentWidth
317328 ld l, [hl]
318329 dec l
+10
gb/src/utils.asm
···5555 add hl, de
5656 dec b
5757 jp nz, .Loop
5858+ ret
5959+6060+; A = A % C
6161+Modulo::
6262+.Loop
6363+ cp c
6464+ jp c, .Done
6565+ sub b
6666+ jp .Loop
6767+.Done
5868 ret