Skip to content

Commit

Permalink
Version 8.6 is released! This one is all about the Tatung Einstein. S…
Browse files Browse the repository at this point in the history
…ee readme.md for details.
  • Loading branch information
wavemotion-dave committed Aug 31, 2023
1 parent 588b990 commit ba32c04
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 72 deletions.
Binary file modified ColecoDS.nds
Binary file not shown.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include $(DEVKITARM)/ds_rules

export TARGET := ColecoDS
export TOPDIR := $(CURDIR)
export VERSION := 8.5h
export VERSION := 8.6

ICON := -b $(CURDIR)/logo.bmp "ColecoDS $(VERSION);wavemotion-dave;https://github.com/wavemotion-dave/ColecoDS"

Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,18 @@ cat 203.bin 1-or.bin 1-or.bin 202.bin > BASIC.pen

Tatung Einstein Compatibility :
-----------------------
The base 64K machine is emulated. Both .dsk files and .COM files will play. For both, you would load the file and press the START button to load them (for .com files, it will load and auto-run... for .dsk files the START button will emulate the CTRL-BREAK needed to boot the diskette). Out in the interwebs, you will mostly only find .dsk files and the .COM files can be extracted from them. The easiest way is to use one of the following programs:
The base 64K machine is emulated. Both .dsk files and .COM files will play. For both, you would load the file and press the START button to boot them (for .com files, it will load the file at 0x100 and auto-run... for .dsk files the START button will emulate the CTRL-BREAK needed to boot the diskette). Out in the interwebs, you will mostly only find .dsk files and the .COM files can be extracted from them. The easiest way is to use either Charlie Robson's einSDein-vitamins or EDIP to extract .COM files from disk images. Or just stick to .dsk files which are a bit more authentic to the experience of using a Tatung Einstein.

dsktool from https://github.com/charlierobson/einsdein-vitamins
or
EDIP version 1e which you can find in the extras folder on the ColecoDS github page.
Two Tatung Einstein disk drives are supported. The default drive 0: is a standard single-sided, 40 track, 10 sector-per-track diskette with about 190K disk space available. This is the drive that will hold and load your .dsk file image when you run the emulation.

The second drive 1: is a persistant RAM Disk that can be saved back to the SD card on your DS/DSi. This comes pre-formatted (and you can re-initialize it using the DISK icon menu) with 190K of storage. To the emulator, it looks just like a standard second disk drive. You can copy often used programs and utilities to this disk - I use it to stash away a few flavors of XBAS so I've always got the right one on hand to play games.

Both drives support read/write capabilities however, the writing will NOT auto-back those changes to your SD card. I might change that behavior in the future - but for now, any changes written to the emulated disks are transient until you go into the DISK icon menu and save them back to the SD card. I'm fairly confident that the disk write works fine - but until I get more testing hours from field-use, I don't want to inadvettantly screw up an original .dsk image and leave the onus on the user to save out the disk for now.

Speaking of disk images, there are several places to find them... but I would recommend seeking out the 'Tatung Einstein Gamebase' which generally has disk images properly formatted and auto-booting for a more streamlined experience. Seek those out.

Lastly, in addition to the standard 8K einstein.rom BIOS file (required for Einstein emulation), you can optionally provide an einstein2.rom file that will load (up to 8K) into 0x4000. This is the extra ROM slot in a real Einstein and can be used to house diagnostics roms or things like flexi-dos.

With either of these tools, you should be able to extract more than 50 .COM games that currently work. Or you can just stick to .dsk files. For some unknown reason, a few .dsk games like DRUID.dsk will not load and run properly - but if you extract the DRUID.COM program on that disk, it will load up fine. Emulation is rarely perfect.

CreatiVision Compatibility :
-----------------------
Expand Down Expand Up @@ -362,7 +367,7 @@ would personally try them:

Versions :
-----------------------
V8.6: ??-Aug-2023 by wavemotion-dave
V8.6: 31-Aug-2023 by wavemotion-dave
* Added .dsk support for Tatung Einstein games!
* Improved Tatung Einstein keyboard and joystick handling.
* Minor graphical tweaks and improvements as time allowed.
Expand Down
Binary file modified arm9/ColecoDS.elf
Binary file not shown.
Binary file modified arm9/gfx_data/pdev_bg0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 35 additions & 18 deletions arm9/source/colecoDS.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ u8 AdamWRITER[0x8000] = {0}; // We keep the ADAM WRITER.ROM bios around to
u8 SVIBios[0x8000] = {0}; // We keep the SVI 32K BIOS around to swap in/out
u8 Pencil2Bios[0x2000] = {0}; // We keep the 8K Pencil 2 BIOS around to swap in/out
u8 EinsteinBios[0x2000] = {0}; // We keep the 8k Einstein BIOS around
u8 EinsteinBios2[0x1000] = {0}; // We keep the 4k Einstein diagnostics/peripheral BIOS around
u8 EinsteinBios2[0x2000] = {0}; // We keep the 8k Einstein diagnostics/peripheral BIOS around
u8 CreativisionBios[0x800]= {0}; // We keep the 2k Creativision BIOS around
u8 MSX_Bios[0x8000] = {0}; // We store several kinds of MSX bios files in VRAM and copy out the one we want to use in msx_restore_bios() but this is for the ubiquitious MSX.ROM

Expand Down Expand Up @@ -1310,6 +1310,7 @@ void CassetteMenuShow(bool bClearScreen, u8 sel)
DSPrint(9,10+cassete_menu_items,(sel==cassete_menu_items)?2:0, " SAVE DISK "); cassete_menu_items++;
DSPrint(9,10+cassete_menu_items,(sel==cassete_menu_items)?2:0, " SWAP DISK "); cassete_menu_items++;
DSPrint(9,10+cassete_menu_items,(sel==cassete_menu_items)?2:0, " SAVE RAMDISK "); cassete_menu_items++;
DSPrint(9,10+cassete_menu_items,(sel==cassete_menu_items)?2:0, " INIT RAMDISK "); cassete_menu_items++;
DSPrint(9,10+cassete_menu_items,(sel==cassete_menu_items)?2:0, " EXIT MENU "); cassete_menu_items++;
if (disk_unsaved_data) DSPrint(6, 15, 0, "DISK HAS UNSAVED DATA!");
if (ramdisk_unsaved_data) DSPrint(4, 16, 0, "RAMDISK HAS UNSAVED DATA!");
Expand Down Expand Up @@ -1438,10 +1439,10 @@ void CassetteMenu(void)
{
if (showMessage("DO YOU REALLY WANT TO","WRITE RAMDISK DATA?") == ID_SHM_YES)
{
DSPrint(12,0,6, "SAVING");
DSPrint(10,0,6, "SAVING");
einstein_save_ramdisk();
WAITVBL;WAITVBL;
DSPrint(12,0,6, " ");
DSPrint(10,0,6, " ");
break;
}
CassetteMenuShow(true, menuSelection);
Expand All @@ -1459,23 +1460,39 @@ void CassetteMenu(void)
}
if (menuSelection == 3)
{
if (einstein_mode) break;

BufferKey('C');
BufferKey('L');
BufferKey('O');
BufferKey('A');
BufferKey('D');
BufferKey(KBD_KEY_RET);
BufferKey(255);
BufferKey('R');
BufferKey('U');
BufferKey('N');
BufferKey(KBD_KEY_RET);
if (einstein_mode)
{
if (showMessage("DO YOU REALLY WANT TO","INITIALIZE THE RAMDISK?") == ID_SHM_YES)
{
DSPrint(10,0,6, "ERASING");
einstein_init_ramdisk();
einstein_load_ramdisk();
WAITVBL;WAITVBL;
DSPrint(10,0,6, " ");
break;
}
CassetteMenuShow(true, menuSelection);
}
else
{
BufferKey('C');
BufferKey('L');
BufferKey('O');
BufferKey('A');
BufferKey('D');
BufferKey(KBD_KEY_RET);
BufferKey(255);
BufferKey('R');
BufferKey('U');
BufferKey('N');
BufferKey(KBD_KEY_RET);
}
break;
}
if (menuSelection == 4)
{
if (einstein_mode) break;

BufferKey('B');
BufferKey('L');
BufferKey('O');
Expand Down Expand Up @@ -3822,9 +3839,9 @@ void LoadBIOSFiles(void)
if (fp == NULL) fp = fopen("/data/bios/einstein2.rom", "rb");
if (fp != NULL)
{
fread(EinsteinBios2, 0x1000, 1, fp);
fread(EinsteinBios2, 0x2000, 1, fp);
fclose(fp);
} else memset(EinsteinBios2, 0xFF, 0x1000);
} else memset(EinsteinBios2, 0xFF, 0x2000);

// -----------------------------------------------------------
// Next try to load the bioscv.rom (creativision)
Expand Down
2 changes: 1 addition & 1 deletion arm9/source/colecoDS.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <string.h>
#include "C24XX.h"

#define VERSIONCLDS "8.5"
#define VERSIONCLDS "8.6"

extern u32 debug1;
extern u32 debug2;
Expand Down
2 changes: 2 additions & 0 deletions arm9/source/colecomngt.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ extern void memotech_launch_run_file(void);
extern void sordm5_check_keyboard_interrupt(void);
extern void einstein_save_disk(void);
extern void einstein_save_ramdisk(void);
extern void einstein_init_ramdisk(void);
extern void einstein_load_ramdisk(void);
extern void einstein_swap_disk(char *szFileName);

extern u8 loadrom(const char *path,u8 * ptr, int nmemb);
Expand Down
99 changes: 53 additions & 46 deletions arm9/source/einstein.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,16 @@ void fdc_state_machine(void)

case 0x20: // Step
case 0x30: // Step
debug1++;
FDC.status = 0x80; // Not handled yet...
break;
case 0x40: // Step in
case 0x50: // Step in
debug1++;
FDC.track++;
FDC.actTrack++;
FDC.status = 0x80;
break;
case 0x60: // Step out
case 0x70: // Step out
debug1++;
if (FDC.track > 0) {FDC.track--; FDC.actTrack--;}
FDC.status = 0x80;
break;
Expand Down Expand Up @@ -227,6 +224,7 @@ void fdc_state_machine(void)
}
else
{
// We're looking for the magic bytes... three F5 bytes followed by an FB to signify start of actual data
if (FDC.data == 0xF5) FDC.write_track_byte_counter++;
else
{
Expand Down Expand Up @@ -356,7 +354,6 @@ void fdc_write(u8 addr, u8 data)

if ((data&0xF0) == 0x90) // Read Sector... multiple
{
debug2++;
memcpy(FDC.track_buffer, &ROM_Memory[((FDC.drive ? 768:512)*1024) + (FDC.actTrack * 5120)], 5120); // Get the track into our buffer
FDC.track_buffer_idx = FDC.sector*512;
FDC.track_buffer_end = 5120;
Expand All @@ -366,7 +363,6 @@ void fdc_write(u8 addr, u8 data)
}
else if ((data&0xF0) == 0x80) // Read Sector... one sector
{
debug3++;
memcpy(FDC.track_buffer, &ROM_Memory[((FDC.drive ? 768:512)*1024) + (FDC.actTrack * 5120)], 5120); // Get the track into our buffer
FDC.track_buffer_idx = FDC.sector*512;
FDC.track_buffer_end = FDC.track_buffer_idx+512;
Expand Down Expand Up @@ -394,11 +390,10 @@ void fdc_write(u8 addr, u8 data)
}
else if ((data&0xF0) == 0xE0) // Read Track
{
debug1++;
// Not implemented yet... only for diagnostics use (nothing I've found uses this raw track read - not even xTal DOS)
}
else if ((data&0xF0) == 0xF0) // Write Track
{
debug4++;
FDC.actTrack = FDC.track;
memcpy(FDC.track_buffer, &ROM_Memory[((FDC.drive ? 768:512)*1024) + (FDC.actTrack * 5120)], 5120); // Get the track into our buffer
FDC.sector = 0;
Expand Down Expand Up @@ -609,7 +604,7 @@ void einstein_restore_bios(void)

memset(BIOS_Memory, 0xFF, 0x10000);
memcpy(BIOS_Memory, EinsteinBios, 0x2000);
memcpy(BIOS_Memory+0x4000, EinsteinBios2, 0x1000);
memcpy(BIOS_Memory+0x4000, EinsteinBios2, 0x2000);

MemoryMap[0] = BIOS_Memory + 0x0000;
MemoryMap[1] = BIOS_Memory + 0x2000;
Expand Down Expand Up @@ -945,6 +940,10 @@ void einstein_load_com_file(void)
JumpZ80(CPU.PC.W);
}


// -------------------------------------------------------------------------------------------------
// This is used for CPC EXTENDED .dsk images which are the kind found for use with Tatung Einstein
// -------------------------------------------------------------------------------------------------
struct SectorInfo_t
{
u8 track;
Expand Down Expand Up @@ -1000,13 +999,16 @@ void einstein_load_disk(void)
}
}

// -----------------------------------------------------------------------------------------------------------
// Our RAMDisk is a standard 200K floppy with no data - just a disk full of 0xE5 bytes ready to be loaded.
// -----------------------------------------------------------------------------------------------------------
unsigned char RAMDisk_Header[] = {
0x45, 0x58, 0x54, 0x45, 0x4e, 0x44, 0x45, 0x44,
0x20, 0x43, 0x50, 0x43, 0x20, 0x44, 0x53, 0x4b,
0x20, 0x46, 0x69, 0x6c, 0x65, 0x0d, 0x0a, 0x44,
0x69, 0x73, 0x6b, 0x2d, 0x49, 0x6e, 0x66, 0x6f,
0x0d, 0x0a, 0x43, 0x50, 0x44, 0x52, 0x65, 0x61,
0x64, 0x20, 0x76, 0x33, 0x2e, 0x32, 0x34, 0x00,
0x0d, 0x0a, 0x43, 0x6f, 0x6c, 0x65, 0x63, 0x6f,
0x44, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00,
0x28, 0x01, 0x00, 0x00, 0x15, 0x15, 0x15, 0x15,
0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
Expand Down Expand Up @@ -1070,45 +1072,49 @@ unsigned char RAMDisk_TrackInfo[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

void einstein_load_RAMdisk(void)

void einstein_init_ramdisk(void)
{
FILE *fp = fopen("einstein.ramd", "wb+");
fwrite(RAMDisk_Header, 1, sizeof(RAMDisk_Header), fp);
for (u8 track=0; track<40; track++)
{
RAMDisk_TrackInfo[0x10] = track;
RAMDisk_TrackInfo[0x18] = track;
RAMDisk_TrackInfo[0x20] = track;
RAMDisk_TrackInfo[0x28] = track;
RAMDisk_TrackInfo[0x30] = track;
RAMDisk_TrackInfo[0x38] = track;
RAMDisk_TrackInfo[0x40] = track;
RAMDisk_TrackInfo[0x48] = track;
RAMDisk_TrackInfo[0x50] = track;
RAMDisk_TrackInfo[0x58] = track;
RAMDisk_TrackInfo[0x60] = track;

RAMDisk_TrackInfo[0x18+2] = 0x00;
RAMDisk_TrackInfo[0x20+2] = 0x01;
RAMDisk_TrackInfo[0x28+2] = 0x02;
RAMDisk_TrackInfo[0x30+2] = 0x03;
RAMDisk_TrackInfo[0x38+2] = 0x04;
RAMDisk_TrackInfo[0x40+2] = 0x05;
RAMDisk_TrackInfo[0x48+2] = 0x06;
RAMDisk_TrackInfo[0x50+2] = 0x07;
RAMDisk_TrackInfo[0x58+2] = 0x08;
RAMDisk_TrackInfo[0x60+2] = 0x09;

fwrite(RAMDisk_TrackInfo, 1, sizeof(RAMDisk_TrackInfo), fp);
memset(FDC.track_buffer, 0xE5, 5120);
fwrite(FDC.track_buffer, 1, 5120, fp);
}
fclose(fp);
}

void einstein_load_ramdisk(void)
{
FILE *fp = fopen("einstein.ramd", "rb");
if (fp == NULL)
{
fp = fopen("einstein.ramd", "wb+");
fwrite(RAMDisk_Header, 1, sizeof(RAMDisk_Header), fp);
for (u8 track=0; track<40; track++)
{
RAMDisk_TrackInfo[0x10] = track;
RAMDisk_TrackInfo[0x18] = track;
RAMDisk_TrackInfo[0x20] = track;
RAMDisk_TrackInfo[0x28] = track;
RAMDisk_TrackInfo[0x30] = track;
RAMDisk_TrackInfo[0x38] = track;
RAMDisk_TrackInfo[0x40] = track;
RAMDisk_TrackInfo[0x48] = track;
RAMDisk_TrackInfo[0x50] = track;
RAMDisk_TrackInfo[0x58] = track;
RAMDisk_TrackInfo[0x60] = track;

RAMDisk_TrackInfo[0x18+2] = 0x00;
RAMDisk_TrackInfo[0x20+2] = 0x01;
RAMDisk_TrackInfo[0x28+2] = 0x02;
RAMDisk_TrackInfo[0x30+2] = 0x03;
RAMDisk_TrackInfo[0x38+2] = 0x04;
RAMDisk_TrackInfo[0x40+2] = 0x05;
RAMDisk_TrackInfo[0x48+2] = 0x06;
RAMDisk_TrackInfo[0x50+2] = 0x07;
RAMDisk_TrackInfo[0x58+2] = 0x08;
RAMDisk_TrackInfo[0x60+2] = 0x09;

fwrite(RAMDisk_TrackInfo, 1, sizeof(RAMDisk_TrackInfo), fp);
memset(FDC.track_buffer, 0xE5, 5120);
fwrite(FDC.track_buffer, 1, 5120, fp);
}

fclose(fp);

einstein_init_ramdisk();
fp = fopen("einstein.ramd", "rb");
}

Expand Down Expand Up @@ -1167,6 +1173,7 @@ void einstein_save_disk(void)
disk_unsaved_data = 0;
}


void einstein_save_ramdisk(void)
{
u8 *trackInfoPtr = ROM_Memory + (256*1024) + 0x100;
Expand Down Expand Up @@ -1236,7 +1243,7 @@ void einstein_reset(void)
if (einstein_mode == 2)
{
einstein_drive_sel(0x01);
einstein_load_RAMdisk(); // First put the RAM disk in place - we don't allow saving this one
einstein_load_ramdisk(); // First put the RAM disk in place - we don't allow saving this one
einstein_load_disk(); // Assemble the sectors of this disk for easy manipulation
}
disk_unsaved_data = 0;
Expand Down

0 comments on commit ba32c04

Please sign in to comment.