Skip to content

Commit

Permalink
Fix: FDISK not working on korean MSX computers
Browse files Browse the repository at this point in the history
The problem (visible at least in the Daewoo CPC-400) is that
the CHPUT routine is supposed to not modify the IX and IY registers,
but in this computer it does since it does an inter-slot call to
an internal slot (presumably to handle korean characters); this causes
the PRINTF routine used by FDISK to crash.

Additionally, a small hack is added to print one less "-" character
in the upper and lower rulers when that inter-slot call is performed,
otherwise the FDISK screen isn't printed properly (it introduces an
additional line break for some reason).
  • Loading branch information
Konamiman committed Jul 13, 2022
1 parent 413810c commit 261c1d3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions source/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ bank6/B6.HEX: \
bank5/fdisk.dat bank5/fdisk2.dat: \
bank5/fdisk_crt0.rel \
bank5/fdisk.h \
bank5/fdisk.c \
$(patsubst %.dat,%.c,$@) \
bank5/drivercall.h \
bank5/drivercall.c \
Expand Down
16 changes: 14 additions & 2 deletions source/kernel/bank5/fdisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,9 +1591,19 @@ void InitializeWorkingScreen(char* header)
void PrintRuler()
{
int i;
byte width;

// "Hack" for korean MSX computers that do weird things
// when printing a character at the last column of the screen
if(*((byte*)H_CHPH) != 0xC9) {
width = currentScreenConfig.screenWidth - 1;
}
else {
width = currentScreenConfig.screenWidth;
}

HomeCursor();
for(i = 0; i < currentScreenConfig.screenWidth; i++) {
for(i = 0; i < width; i++) {
chput('-');
}
}
Expand Down Expand Up @@ -1636,10 +1646,12 @@ void chput(char ch) __naked
{
__asm
push ix
ld ix,#4
push iy
ld ix,#6
add ix,sp
ld a,(ix)
call CHPUT
pop iy
pop ix
ret
__endasm;
Expand Down
11 changes: 10 additions & 1 deletion source/tools/C/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,21 @@ static void do_char(const char* buf, char c) __naked
jp z,5
#else
ld a,e
jp z,CHPUT
jr z,DO_CHPUT
#endif

ld (hl),e
ret

;CHPUT shouldnt modify IX and IY but on some buggy MSX models it does
DO_CHPUT:
push ix
push iy
call CHPUT
pop iy
pop ix
ret

__endasm;
}

Expand Down
1 change: 1 addition & 0 deletions source/tools/C/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
#define DAC 0xF7F6
#define SCRMOD 0xFCAF
#define EXPTBL 0xFCC1
#define H_CHPH 0xFDA4

#endif //__SYSTEM_H

0 comments on commit 261c1d3

Please sign in to comment.