Skip to content

Commit

Permalink
Merge branch 'master' into usescancodes
Browse files Browse the repository at this point in the history
  • Loading branch information
joncampbell123 authored Jul 17, 2023
2 parents 3810bcf + ad58da4 commit b72bf1b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Next
- Imported IBM Music Feature Card support from DOSBox Staging. (Allofich)
- Set usescancodes=true when non-US keyboards are detected. (Linux / MacOS
builds) (maron2000)
- Fix day of week detection (INT 21h 0x2Ah). (maron2000)
- Refine KEYB and CHCP command (maron2000)
2023.05.01
- IMGMAKE will choose LBA partition types for 2GB or larger disk
images, but the user can also use -chs and -lba options to override
Expand Down
14 changes: 10 additions & 4 deletions src/dos/dos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,10 +1498,16 @@ static Bitu DOS_21Handler(void) {
reg_dl = dos.date.day;

// calculate day of week (we could of course read it from CMOS, but never mind)
unsigned int a = (14u - reg_dh) / 12u;
unsigned int y = reg_cl - a;
unsigned int m = reg_dh + 12u * a - 2u;
reg_al = (reg_dl + y + (y / 4u) - (y / 100u) + (y / 400u) + (31u * m) / 12u) % 7u;
/* Use Zeller's congruence */
uint16_t year = reg_cx, month = reg_dh, day = reg_dl;
int8_t weekday;
if(month <= 2) {
year--;
month += 12;
}
weekday = (year + year / 4u - year / 100u + year / 400u + (13u * month + 8u) / 5u + day) % 7;
reg_al = weekday < 0 ? weekday + 7 : weekday;
/* Sunday=0, Monday=1, ... */
}
break;
case 0x2b: /* Set System Date */
Expand Down
11 changes: 9 additions & 2 deletions src/dos/dos_programs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7741,6 +7741,8 @@ class TITLE : public Program {
}
};

bool CodePageGuestToHostUTF8(char *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/);

void TITLE::Run()
{
// Hack To allow long commandlines
Expand All @@ -7751,8 +7753,13 @@ void TITLE::Run()
PrintUsage();
return;
}
char *args=(char *)cmd->GetRawCmdline().c_str();
dosbox_title=trim(args);
char *args=trim((char *)cmd->GetRawCmdline().c_str());
char title[4096];
if(CodePageGuestToHostUTF8(title, args)) {
dosbox_title=title;
} else {
dosbox_title=args;
}
SetVal("dosbox", "title", dosbox_title);
GFX_SetTitle(-1,-1,-1,false);
}
Expand Down

0 comments on commit b72bf1b

Please sign in to comment.