Skip to content

Commit

Permalink
sanyo/mbc200.cpp: Better I/O:
Browse files Browse the repository at this point in the history
* Added Centronics printer port.
* Hooked up most of the PPI connections.
* Added some UART connections (won't work, not clocked).
* Fixed sub CPU I/O mapping.
* Noted missing graphics ROMs (possibly kanji font).
  • Loading branch information
cuavas committed Apr 21, 2023
1 parent 49f6add commit d130995
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/devices/video/mc6845.cpp
Expand Up @@ -48,7 +48,7 @@
#define LOG_CONF (1U << 3)

//#define VERBOSE (LOG_SETUP|LOG_CONF|LOG_REGS)
//#define LOG_OUTPUT_STREAM std::cout
//#define LOG_OUTPUT_FUNC osd_printf_info

#include "logmacro.h"

Expand Down

19 comments on commit d130995

@cuavas
Copy link
Member Author

@cuavas cuavas commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the default to have drives C: and D: absent, as the external drives are optional. They can be enabled the usual way. It also gets rid of the fake third PPI. I expect the missing ROMs are used for extended character sets (e.g. for Japanese).

@zx70 this fixes bidirectional communication between the main and sub CPUs and adds a working Centronics parallel port. The serial port is more complicated due to how the UARTs are clocked.

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I'm busy for some day but I'll surely test it

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention that this current ROM has a Japanese font already, it's similar to the one in the MBC3000 but it's 8x8 while the mbc3000 had a full 8x12 font.
Oddly the terminal implementation adds always blank rows for characters spacing in both 33 or 40 text line modes, which makes it impossible to use continuous vertical lines with the graphic symbols from in the text font.
by the way, a 640x400 video memory map located at $8000 requires 32K, and after the ROM BIOS the display software requires RAM space at $2000, including some spare space to upload user video routines and graphics.
IIRC the schematics refer to a 32K ROM, right?

that's hardly compatible with the current BIOS, perhaps there were differences between the MBC200 and MBC1200, or a different BIOS used the CRTC in text mode.
Another discovery : it existed an MBC-1160 model, with the MBC-1150 non-graphics hardware but the same 80 tracks floppy disk format of the MBC1250, while most of the other CP/M MBC models had 40 tracks.
The emulated MBC-200 can read the 40 tracks format on the virtual disk F:

@cuavas
Copy link
Member Author

@cuavas cuavas commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schematics have four ROM areas:

  • The IPL at 8G (2K or 4K ROM supported, less than 256 bytes used for the dump in MAME)
  • The sub CPU main program at 15J (8K) – I think this is what you’re calling the BIOS?
  • The sub CPU banked data ROMs at 13J, 11H, 10J and 12J (4*32K ROMs for a total of 128K accessed as 8*16K banks, no dumps in MAME)
  • The internal ROM in the 8748 in the KCC AD047 keyboard (also no dump in MAME)

It’s possible there were different ROMs for different countries – Sanyo had separate catalogue numbers for regional variants of the MBC-1100, MBC-1110, MBC-1150, MBC-1160, MBC-1200 and MBC-1250 (variants for at least USA, UK, Germany Canada and Thailand existed).

@cuavas
Copy link
Member Author

@cuavas cuavas commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The memory map for the sub CPU is:

  • 0x0000-0x1fff – main program ROM (fixed)
  • 0x2000-0x3fff – work RAM (fixed)
  • 0x4000-0x7fff – 16K window into banked ROM
  • 0x8000-0xffff – 32K video RAM (fixed)

@cuavas
Copy link
Member Author

@cuavas cuavas commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to mention that this current ROM has a Japanese font already, it's similar to the one in the MBC3000 but it's 8x8 while the mbc3000 had a full 8x12 font.

That would have to just be 7-bit katakana wouldn’t it? There isn’t enough space in the 8K program ROM for a full Japanese font.

by the way, a 640x400 video memory map located at $8000 requires 32K, and after the ROM BIOS the display software requires RAM space at $2000, including some spare space to upload user video routines and graphics.

Yes, there is always 32K video RAM accessible at 0x8000 to 0xffff, also accessible by the video output circuitry. There is also 8K of work RAM for the sub CPU that is always accessible at 0x2000 to 0x3fff, where user video routines and graphics can be uploaded.

IIRC the schematics refer to a 32K ROM, right?

The schematics show four 32K ROMs (128K total) in addition to the 8K program ROM, but only a 16K window is visible at any time. The the three least significant bits of PIA port C (PC0/PC1/PC2) select the which 16K is visible.

that's hardly compatible with the current BIOS, perhaps there were differences between the MBC200 and MBC1200, or a different BIOS used the CRTC in text mode.

I haven’t examined the ROM code in detail. Are you it doesn’t have code for fetching characters from the banked ROM? The hardware can’t support a text mode – the video output circuitry doesn’t have direct access to any of the ROM. It relies entirely on the sub CPU copying the character data to VRAM.

Another discovery : it existed an MBC-1160 model, with the MBC-1150 non-graphics hardware but the same 80 tracks floppy disk format of the MBC1250, while most of the other CP/M MBC models had 40 tracks.

Yes, and there were also MBC-1100 and MBC-1110 models. I think the MBC-4000 and MBC-4050 models may also be related?

The emulated MBC-200 can read the 40 tracks format on the virtual disk F:

That’s actually not an unusual feature on CP/M systems – using different drive letters to access the same physical drive as different formats.

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, I see. I see little in the disassembly for references to the banked ROM.
It is left untouched, though, the stack is set at $4000

https://github.com/z88dk/techdocs/blob/master/targets/mbc_1200/mbc200vid.asm

regarding the floppy drives, there must have been also a BIOS version to support 8" floppy drives. there's also the DPB table in asm source in the boot disk.

@cuavas
Copy link
Member Author

@cuavas cuavas commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SP is initially initialised with the address beyond the bottom of the stack. The SP register is decremented before the value is pushed onto the stack. With SP initialised to 0x4000, the first value pushed onto the stack will be at 0x3ffe (i.e. at the end of work RAM).

The routine at L0700 in that disassemby will display a character from the banked ROM. It calls the routine L078D_3 to set the appropriate ROM bank, then calls the routine at L071F to actually display the character. The missing ROMs are definitely for font data.

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you've been very fast! I'm having lots of fun with this project :)

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the mbc4000 is 16bit stuff, but someone is collecting information on the mbc3000 on github.
It had 8" drives, and different formatting seem to have been used in the time. sadly schematics are missing

@cuavas
Copy link
Member Author

@cuavas cuavas commented on d130995 Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GAIJI.BAS demo program (presumably 外字, external characters) on the boot disk tries to display characters from the missing banked ROM. The program itself has Japanese comments in katakana encoded as Shift-JIS which don’t display correctly in MAME when using LIST.

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the banked mem emulation works it's probably possible to mock up a temporary rom replacement.
Should I?

@cuavas
Copy link
Member Author

@cuavas cuavas commented on d130995 Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no point making fake ROMs. We need someone who has a system with the ROMs populated to dump them. They were likely an extra cost option for people who needed full Japanese language support. Kanji find ROMs are unfortunately missing for quite a few systems.

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Then, if we know how to switch the bank, it is easy for me to create a program which dumps it on disk.

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the mbc4000 is 16bit stuff, but someone is collecting information on the mbc3000 on github.
It had 8" drives, and different formatting seem to have been used in the time. sadly schematics are missing

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the default to have drives C: and D: absent, as the external drives are optional. They can be enabled the usual way. It also gets rid of the fake third PPI. I expect the missing ROMs are used for extended character sets (e.g. for Japanese).

@zx70 this fixes bidirectional communication between the main and sub CPUs

I'm trying to use the video-to-main direction but something goes wrong.
In my understanding the main CPU checks bit 5 on port $EA to test the IBF signal.
I'm using the ESC-HT / ESC-HR features to get a screen dump, save it to file, and load it back.
Sadly it looks like the data is sent also when not requested, I'm not even sure if it is the right data, there's some resemblance of the original information with some stuck bit, etc..

EDIT: ...and probably it is my fault ! Sorry for having bothered, I still have to understand a bad sync situation but most of the problems were due to my bad interpretation of the software BIOS code.

@cuavas
Copy link
Member Author

@cuavas cuavas commented on d130995 Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my understanding the main CPU checks bit 5 on port $EA to test the IBF signal.

Yes, the main CPU should see IBF on bit 5 of PPI 2F port C read at $EA (to know when data is available to read). The sub CPU sees the IBF signal on bit 6 of PPI 9F port A read at $70 (to know when the main CPU can accept data).

Relatively few things use PPI mode 2, so there could conceivably be a bug in the emulation, but the basics should work.

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very close, but my program to dump the screen memory to disk misses the first two bytes.
I noticed that the sw BIOS sometimes does a first data read "on the fly" without wait loop for the IBF signal, but it didn't help.
By the way it was such a powerful machine that the simple console functions plus the "code upload" feature permit a lot of nice tricks already :)

eagle

@zx70
Copy link
Contributor

@zx70 zx70 commented on d130995 Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..the font comparison, MBC-200 vs MBC-3000
fonts

Please sign in to comment.