https://scalibq.wordpress.com/2023/01/07/when-is-a-pc-not-a-pc-the-pc-98/ Scali's OpenBlog(tm) Programming, graphics, hardware, maths, and that sort of thing [path] Skip to content * Home * About * Just keeping it real, a series of articles on oldskool/ retro programming * Thoughts on software development - Why I left the 8088 MPH team When is a PC not a PC? The PC-98 Posted on January 7, 2023 by Scali I've covered PC compatibility in the past, and tried to explain how just having an x86 CPU and running DOS does not necessarily make your machine compatible with an IBM PC. At the time, this was mainly about the IBM PCjr (and its clone, the Tandy 1000), which is still relatively close to a regular PC. As such you could create software that would run on both IBM PCs and compatibles, and on the PCjr/ Tandy, with custom code paths for specific functionality, such as sound and graphics. But pretty much all other DOS/x86-based machines failed, as their hardware was too different, and their marketshare was too small for developers to bother adding support. In fact, the main reason that the Tandy 1000 existed at all, is because the earlier Tandy 2000 was falling into the trap of not being compatible enough. The Tandy 1000 may actually not be a very good example, as Tandy tried to make it nearly 100% compatible, fixing the main reason why the IBM PCjr also failed. So later Tandy 1000 models were more or less a 'best of both worlds': nearly 100% compatible with IBM PC, but also offering the enhanced graphics and sound capabilities of the PCjr. Meanwhile, in Japan... In Japan however, things took a different turn. The Japanese do not just use the Latin alphabet that is used on all Western machines, including the IBM PC. The Japanese language uses more complex glyphs. They have multiple systems, such as kanji, katakana and hiragana. To display these in a comfortably readable form, you need a high-resolution display. Also, where Latin letters encode sounds, a kanji glyph encodes a word or part of a word. This means that your glyph alphabet contains over 50000 characters, a lot more than the maximum of 256 characters in your usual 8-bit Western character set. So the Japanese market had very specific requirements, that PCs could not fulfill in the early DOS days. You couldn't just replace the character ROM on your PC and make it display Japanese text (IBM did later develop the 5550 and the JX, a derivative of the PCjr, specifically for the Japanese market, and later, they developed the DOS/V variant, which added support for Japanese text to their PS/2 line, using standard VGA hardware, which by now had caught up in terms of resolution). Instead, Japanese companies jumped into the niche of developing business machines for the home market. Most notably NEC. In 1981 they introduced the PC-8800 series, an 8-bit home computer based on a Z80 CPU and BASIC. In 1982, the PC-9800 series followed, a more high-end 16-bit business-oriented personal computer based on an 8086 CPU and MS-DOS. These families of machines became known as PC-88 and PC-98 respectively (Note that the 'PC' name here is not a reference to IBM, as NEC had already released the PC-8000 series in 1979). In this article, I will be looking at the PC-98 specifically. So let's start by doing that literally: here are some pictures to give an impression of what these machines looked like. They look very much like IBM PC clones, don't they? [800px-pc98] [800px-pc98] [799px-pc98] [800px-pc98] [pc9801vx2] For more machines, specs and background info, I suggest this NEC Retro site. How compatible is it? It has an 8086 CPU, an NEC 765 floppy controller, an 8237 DMA controller, an 8253 programmable interval timer, and two 8259A programmable interrupt controllers. Sounds just like a PC, doesn't it (okay, two PICs sounds more like an AT actually, so NEC was ahead of its time here)? Well it would be, if it used the same IO addresses for these devices. But it doesn't. What makes it especially weird is that since it has always been a system with a 16-bit bus (using an 8086 as opposed to the 8088 in early PCs), NEC chose to map any IO registers of 8-bit devices either on even addresses only, or on odd addresses only (so the 16-bit bus is seen as two 8-bit buses). For example, where the first 8259A on a PC is mapped to ports 0x20 and 0x22, the PC-98 places it at 0x00 and 0x02, leaving 0x01 as a 'gap' in between. The 8237 DMA controller is actually mapped on address 0x01, 0x03 and so on. Another major difference is that the base frequency of the PIT is not 1.19 MHz like on the PC, but depending on the model, it can be either 1.99 MHz or 2.46 MHz. And like the PCjr and the Tandy 1000EX/HX models, it has an expansion bus, but it is not the ISA bus. The PC-98 uses the C-bus. So you cannot use standard expansion cards for IBM PCs in this machine. Clearly the video system isn't compatible with any PC standard either. It does not even use int 10h as the video BIOS. Speaking of BIOS, the PC-98 BIOS is not compatible with the IBM PC BIOS either. But as said, the video system was far superior to the IBM PC at the time. The first version in 1982 already supported 640x400 with 8 colours, based on NEC's own uPD7220 video controller. In 1985 they extended this with a palette of 4096 colours to choose from, and an optional 16 colour mode if an extra RAM board was installed. In 1986 the extra RAM became standard on new models, and they also added a hardware blitter for block transfers, raster operations and bit shifting. What's also interesting is that they chose to actually use TWO uPD7220 chips in a single machine. One of them is used for text mode, the other for bitmapped graphics mode. They each have their own video memory, and are used in parallel. So you can actually overlay text and graphics on a single screen. [image] But, on the other hand... There are two things that we can use to our advantage: 1. It runs (an NEC PC-98 OEM version of) MS-DOS 2. A lot of the hardware is the same as on the PC So this means that for basic functionality such as file and text I/O, memory management and such, we don't need the BIOS. We can use MS-DOS for that, which abstracts the machine-specific BIOS stuff away. Also, if we write code that uses the 8237, 8253, 8259A or other similar hardware, in most cases we only need to change the I/O-addresses they use, and adjust for the different PIT frequency (and other minor details, such as the different cascaded configuration of the two PICs and different IRQs for devices), and we can make it work on the PC-98. So just like with Tandy and PCjr, we can write DOS programs and make them work on PC-98. We can even write a single program that can run on both types of systems, even though it is a bit more complicated than on Tandy/PCjr (on those you mainly had to avoid using DMA, and you should be aware that the keyboard is different, so you should only access it via BIOS, or have separate routines for the different machines). Challenge accepted I decided to give this a try. I have made my own little 'SDK' of headers and library functions for ASM and C over the years, which includes quite a few constants for addressing I/O ports or memory areas of all sorts of PC and Tandy/PCjr hardware (I modeled it after the Amiga NDK). I figured I would try a PC-98 emulator and port my VGM player over to the PC-98, and update the SDK with PC-98 support in the process. A convenient emulator is DOSBox-X. It is a fork of DOSBox, which adds a PC-98 machine, among other features, and like DOSBox, the BIOS and DOS emulation is built-in, and you can just mount host directories as drives, so you don't have to juggle all sorts of ROMs and disk images to get the system running. If you want a more serious emulator though, Neko Project 21/W is one of the more compatible/accurate ones. And indeed, you can just use OpenWatcom C to write a DOS application, and it will work, as the basic runtime only requires DOS interrupts, no BIOS or direct hardware access. All the BIOS and direct hardware access is done via my 'SDK' anyway, so as long as I write the correct code for PC-98 BIOS and addresses, I can use any hardware from C (or assembly of course). What's more, it turns out to be relatively simple to detect whether you are running on an IBM PC-compatible or a PC-98 compatible machine. A trick that is used is to call int 10h with AH=0Fh. On an IBM PC-compatible, this will return information about the current video mode, with AH containing the number of columns. On the PC-98, this will not be implemented, so after the call, the value of AH will be unaffected. Since there is no video mode with 15 columns, you can assume that if AH is 0Fh after the call, that you are running on a PC-98 machine. Anyway, before long I had a basic version of my VGM player working on both the IBM PC and the PC-98. It's a pretty fun and quirky platform so far. So I might be looking into the graphics chip in the near future. If you also like to play around with DOS and x86, and want to give the PC-98 a try, here are some good resources (you might need to translate, as most documentation can only be found in Japanese): http://radioc.web.fc2.com/column/pc98bas/index_en.htm https://www.webtech.co.jp/company/doc/undocumented_mem/ Advertisement Share this: * Twitter * Facebook * Like this: Like Loading... Related This entry was posted in Oldskool/retro programming, Software development and tagged 8086, DOS/V, IBM, MS-DOS, NEC, PC, PC DOS, PC-98, uPD7220, x86, XT. Bookmark the permalink. - Why I left the 8088 MPH team Leave a Reply Cancel reply Enter your comment here... [ ] Fill in your details below or click an icon to log in: * * * * Gravatar Email (required) (Address never made public) [ ] Name (required) [ ] Website [ ] WordPress.com Logo You are commenting using your WordPress.com account. ( Log Out / Change ) Twitter picture You are commenting using your Twitter account. ( Log Out / Change ) Facebook photo You are commenting using your Facebook account. ( Log Out / Change ) Cancel Connecting to %s [ ] Notify me of new comments via email. [ ] Notify me of new posts via email. [Post Comment] [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] * Search for: [ ] [Search] * Recent Posts + When is a PC not a PC? The PC-98 + Why I left the 8088 MPH team + A new MPU-401 solution: The Music Quest clone + A new game for DOS/EGA/AdLib: Super Space Fuel Inc. + Windows 7: the end is nigh * Recent Comments When is a PC not a P... on Putting the things togeth... When is a PC not a P... on Putting the things togeth... When is a PC not a P... on More PC(jr) incompatibilities! When is a PC not a P... on PC-compatibility, it's a... [1da3a] bananaboy on The myth of the vertical retra... * Archives + January 2023 + December 2022 + November 2022 + September 2022 + August 2022 + June 2022 + May 2022 + March 2022 + January 2022 + December 2021 + December 2020 + November 2020 + October 2020 + August 2020 + June 2020 + May 2020 + February 2020 + December 2019 + October 2019 + September 2019 + August 2019 + July 2019 + May 2019 + March 2019 + January 2019 + May 2018 + April 2018 + March 2018 + February 2018 + January 2018 + November 2017 + October 2017 + May 2017 + March 2017 + February 2017 + January 2017 + December 2016 + August 2016 + July 2016 + June 2016 + May 2016 + April 2016 + March 2016 + February 2016 + January 2016 + December 2015 + November 2015 + September 2015 + August 2015 + June 2015 + April 2015 + January 2015 + December 2014 + November 2014 + October 2014 + September 2014 + August 2014 + July 2014 + June 2014 + April 2014 + March 2014 + February 2014 + December 2013 + November 2013 + October 2013 + September 2013 + August 2013 + July 2013 + June 2013 + May 2013 + April 2013 + March 2013 + February 2013 + January 2013 + December 2012 + November 2012 + October 2012 + September 2012 + August 2012 + July 2012 + June 2012 + May 2012 + April 2012 + March 2012 + February 2012 + January 2012 + December 2011 + November 2011 + October 2011 + September 2011 + August 2011 + July 2011 + June 2011 + May 2011 + March 2011 + February 2011 + January 2011 + December 2010 + November 2010 + October 2010 + September 2010 + August 2010 + July 2010 + June 2010 + May 2010 + April 2010 + March 2010 + February 2010 + January 2010 + December 2009 + November 2009 + October 2009 + September 2009 + August 2009 + July 2009 + June 2009 + May 2009 + January 2009 * Categories + Direct3D + Hardware news + Oldskool/retro programming + OpenCL + OpenGL + Science or pseudoscience? + Software development + Software news + Uncategorized + Vulkan * Meta + Register + Log in + Entries feed + Comments feed + WordPress.com Scali's OpenBlog(tm) Blog at WordPress.com. [Close and accept] Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more, including how to control cookies, see here: Cookie Policy * Follow Following + [wpcom-] Scali's OpenBlog(tm) Join 129 other followers [ ] Sign me up + Already have a WordPress.com account? Log in now. * + [wpcom-] Scali's OpenBlog(tm) + Customize + Follow Following + Sign up + Log in + Copy shortlink + Report this content + View post in Reader + Manage subscriptions + Collapse this bar Loading Comments... Write a Comment... [ ] Email (Required) [ ] Name (Required) [ ] Website [ ] [Post Comment] %d bloggers like this: [b]