From 103e9bbbb61fd0fb3bc13816dfe2b769e9bb9ebe Mon Sep 17 00:00:00 2001 From: Terr Date: Tue, 1 Aug 2023 18:34:59 +0200 Subject: [PATCH] Make it possible to set date in December An off-by-one error prevented using the DATE shell command (and maybe others?) to set a date in December. It was caused by the actual Month value (1-indexed) being used an index for for the `maxday` array. --- src/dos/dos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index 76145a84147..5c2eb3f2a16 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -1520,7 +1520,7 @@ static Bitu DOS_21Handler(void) { if (reg_cx % 4 == 0 && (reg_cx % 100 != 0 || reg_cx % 400 == 0)) maxday[1]++; - if (reg_cx < 1980 || reg_cx > 9999 || reg_dh < 1 || reg_dh > 12 || reg_dl < 1 || reg_dl > maxday[reg_dh]) + if (reg_cx < 1980 || reg_cx > 9999 || reg_dh < 1 || reg_dh > 12 || reg_dl < 1 || reg_dl > maxday[reg_dh - 1]) { reg_al = 0xff; // error! break; // done