joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.68k stars 381 forks source link

PC-98: Support for FDD images that boot into N88 ROM BASIC #732

Open joncampbell123 opened 6 years ago

joncampbell123 commented 6 years ago

Every FDD disk image I have, where track 0 head 0 is 128 bytes/sector and the rest of the disk is 256 bytes/sector, appears to load data from disk into memory, and then RETF to E800:0002.

I'm guessing that E800:0002 might be N88 ROM BASIC, but I'm not sure.

@yksoft1 Any comments?

joncampbell123 commented 6 years ago

There's code in Neko Project II that suggests the BIOS starts at E800:0000 and is 96KB in size.

joncampbell123 commented 6 years ago

Boot sectors loads itself to E00:0000, loads data to 1000:0000

yksoft1 commented 6 years ago

According to my knowledge PC-98 BIOS had 8 banks, the bootloader (ITF) (BANK4) is loaded into F800:0000 and the N88-BASIC (BANK5) is loaded into E800:0000.

yksoft1 commented 6 years ago

And there is another custom format that may look strange to you. 256b/sector in track 0 and 1024b/sector in other tracks. For example, Nihon Falcom's earlier 2HD format.

joncampbell123 commented 6 years ago

Oh, that is weird.

1024 bytes/sector, 5 sectors/track, except track 0 which ALSO has 256 bytes/sector with the same sector IDs. So track 0 has TWO sectors addressed as sector=1/head=0/track=0, one is 256 bytes/sector and the other is 1024 bytes/sector.

Naturally, DOSBox-X currently tries to boot the 1024 bytes/sector version and comes up with a sector full of zeros.

yksoft1 commented 6 years ago

I think there might be bugs in that image format convertor (VFIC) I mainly use. Is there any tool that can make FDD images from real floppies? However if you use VFIC to convert those images to .d88 format, they will boot in Neko Project II. Neko Project II natively support .d88 floppy images.

BTW: Anyone interested to port D88 disk image format support from Neko Project II?

joncampbell123 commented 6 years ago

I'm not aware of any tool, but I've been considering writing a tool in the DOSLIB project to write that format since that project now has a low-level disk reader program (for IBM PC/AT and compatibles, so far). Assuming the FDD format can represent either PC-98 or IBM formats, FDD would be a good fit for recording various IBM floppies I have with games that use weird sector layouts and/or bad sectors for copy protection.

yksoft1 commented 6 years ago

Do you have any plan to try loading BIOS.ROM for other emulators for booting such disks?

joncampbell123 commented 6 years ago

Eventually.

I tried loading a PC-9821 ROM BIOS to get N88 BASIC and it seems like all the code is mixed together that makes it difficult to do. I got ROM BASIC to get as far as it's prompt before crashing.

joncampbell123 commented 6 years ago

I forgot to mention, the last time I tried it, N88 BASIC taken from a PC-9821 BIOS image apparently likes to make full use of the HMA area, meaning it will unmask the A20 line and execute most of itself from segment FFFF

joncampbell123 commented 6 years ago

@yksoft1 I haven't yet gotten N88 BASIC to run, but I just added .D88 image support using struct typedefs copied from Neko Project II. I could not find anything on D88 from Google or DuckDuckGo so I had to use the typedefs in NP2 which seem to work well.

I'm well aware that D88 is typically for PC-88 games (which use the Z80) but I also understand from your videos that there is a PC-88 emulator for PC-98 that lets you run PC-88 games, so this should help with that.

yksoft1 commented 6 years ago

PC-88 didn't have a floppy drive that support 2DD/2HD disks until end of life and almost nothing in PC-88 use any floppy disk format beyond 2D. In fact, a lot of PC-98 games are distributed in D88 disk images. Commonly there are 3 formats used to distribute PC-98 disk images with N88-BASIC and other non-standard floppy formats, T98-Next's NFD, D88 and FDD(VFD) format, and most NFD and FDD images can be safely converted to D88 format. Why just disable boot support for smaller D88 files (2D format) and D88 files with multiple disks stored for now?

In addition, here is the document for NFD disk image format: http://www.geocities.jp/t98next/nfdr0.txt (NFD r0 format "T98FDDIMAGE.R0") http://www.geocities.jp/t98next/nfdr1.txt (NFD r1 format "T98FDDIMAGE.R1")

yksoft1 commented 6 years ago

@joncampbell123 By the way, old MinGW (not mingw-w64) doesn't have strcasestr.

joncampbell123 commented 6 years ago

@yksoft1 Agreed. DOSBox-X does not yet interpret the fd type field, but that could be exposed somehow to the BOOT command to reject the 2D format.

joncampbell123 commented 6 years ago

@yksoft1 In the meantime, I'd like to know if this improves your use with the PC-88 emulator in PC-98 mode you showed in one YouTube video.

yksoft1 commented 6 years ago

I don't think D88 support had any relation with P88SR as neither PC-88 use MS-DOS format disks, nor P88SR boots from real floppy drives. However now if you map VF keys in mapper, P88SR is almost fully working in Dosbox-X.

joncampbell123 commented 6 years ago

I just found some D88 images with PC-98 games, and so far, it's working fine. I updated the BOOT command to allow booting D88 unless the fd_type field suggests PC-88 software.

yksoft1 commented 6 years ago

According to my test games not booting in FDD format also won't boot within D88 format, as expected.

joncampbell123 commented 6 years ago

There's usually one extra check they do with the BIOS that prevents it.

Some code was committed yesterday that should allow MEGDOS based PC-98 games to boot now.

MEGDOS it seems likes to poll the sectors going by the head using INT 1Bh before attempting to read the disk. If INT 1Bh doesn't show any movement or the sectors IDs it expects, it won't try to read the disk. Yesterday's commit added code to fake that.

yksoft1 commented 6 years ago

@joncampbell123 Would you try those non-N88-BASIC special disk format (such as Nihon Falcom's 256/1024 byte sector format)?

joncampbell123 commented 6 years ago

I have tried those FDD images. DOSBox-X identifies as 1024 bytes/sector and tries to boot the 1024 bytes/sector boot sector, which is zeros.

At that point, if the FDD image is broken to have two sectors per sector ID on a track, it should be fixed with a tool instead of adding more hacks.

yksoft1 commented 6 years ago

I would upload those disk images in D88 format for you. Those FDD images are converted from NFD or D88 format using VFIC, and such converter might itself had some bugs.

joncampbell123 commented 6 years ago

Ah, the original D88 file lists the original 256 bytes/sector sectors on track 0 and it does NOT have the extra 1024 byte/sector sectors on track 0. Better! I can support that.

Nope, actually another D88 image has the extra sectors.

yksoft1 commented 6 years ago

@joncampbell123 I've found another strange format. 2DD disk with fixed CHS 80/2/16 256 bytes/sector instead of CHS 80/2/8 512 bytes/sector. One Nihon Falcom game (Sorcerian and all its scenario expansions) uses this.