Skip to content

Commit

Permalink
Merge pull request #95 from jedeoric/master
Browse files Browse the repository at this point in the history
Adding CH376 chip emulation for Orix/telemon30.
  • Loading branch information
pete-gordon committed Feb 4, 2017
2 parents 80b85f2 + b815d29 commit e235c79
Show file tree
Hide file tree
Showing 21 changed files with 2,350 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ x64
/msvc/sdl
/msvc/sdl2
/roms/*.rom
!/roms/orix*.rom
/oricutron.aps
/msvc/Oricutron.psess
/msvc/Oricutron.vcxproj.user
13 changes: 13 additions & 0 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ Credits

Iss

CH376 support
---------------------------

Offset (cpc) & Jede


Thanks
Expand Down Expand Up @@ -412,6 +415,16 @@ ATH0 - disconnect currently connected sockets
ATO - returns from command mode to online
ATD ip:port - connects as client to ip:port. 'ip' can be any host name (ex.:localhost) or the real IP (ex.:127.0.0.1) on LAN or in Internet. ATDP and ATDT are alternative for compatibility.

Ch376 card emulation
============================

Oricutron runs ch376 chip. This chip is able to read a sdcard and a usbkey (and USB port). This chip handles FAT32. usbdrive/ folder is the CH376 emulation folder. It means that when we asked ch376 to read
usbkey, it reads in this folder. Please note, that read/write are emulated. Erase file, mkdir does not work. Please note that emulation runs only in telestrat mode.
Atmos can run this chip, but the rom had not been release yet (and the card with the rom).

Orix (http://orix.oric.org) works with this chip mainly. Don't modify ch376 emulation : contact Jede (jede@oric.org). Because this emulation is used also in ACE emulator (cpc emulation). Offset and me
are trying to keep the same emulation. It's easier to work together than alone.



ROM patch files
Expand Down
23 changes: 23 additions & 0 deletions gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
#include "msgbox.h"
#include "keyboard.h"

#include "plugins/ch376/ch376.h"
#include "plugins/ch376/oric_ch376_plugin.h"

extern SDL_bool fullscreen;

char tapepath[4096], tapefile[512];
Expand Down Expand Up @@ -188,6 +191,7 @@ void inserttape( struct machine *oric, struct osdmenuitem *mitem, int dummy );
void insertdisk( struct machine *oric, struct osdmenuitem *mitem, int drive );
void resetoric( struct machine *oric, struct osdmenuitem *mitem, int dummy );
void toggletapeturbo( struct machine *oric, struct osdmenuitem *mitem, int dummy );
void togglech376(struct machine *oric, struct osdmenuitem *mitem, int dummy);
void toggleautowind( struct machine *oric, struct osdmenuitem *mitem, int dummy );
void toggleautoinsrt( struct machine *oric, struct osdmenuitem *mitem, int dummy );
void togglesymbolsauto( struct machine *oric, struct osdmenuitem *mitem, int dummy );
Expand Down Expand Up @@ -274,6 +278,7 @@ struct osdmenuitem hwopitems[] = { { " Oric-1", "1", SDLK_1,
{ " VSync hack", NULL, 0, togglevsynchack, 0, 0 },
{ " Lightpen", NULL, 0, togglelightpen, 0, 0 },
{ " Serial none ", NULL, 0, toggleaciabackend, 0, 0 },
{ " Ch376 (Telestrat) ", NULL, 0, togglech376, 0, 0 },
// { " Mouse", NULL, 0, NULL, 0, 0 },
{ OSDMENUBAR, NULL, 0, NULL, 0, 0 },
{ "Back", "\x17", SDLK_BACKSPACE,gotomenu, 0, 0 },
Expand Down Expand Up @@ -1499,6 +1504,24 @@ void toggleaciabackend( struct machine *oric, struct osdmenuitem *mitem, int dum
acia_init( &oric->tele_acia, oric );
}

// Toggle ch376 on/off
void togglech376(struct machine *oric, struct osdmenuitem *mitem, int dummy)
{

if (oric->ch376_activated)
{
oric->ch376_activated = SDL_FALSE;
mitem->name = " Ch376 (Telestrat)";
return;
}

oric->ch376_activated = SDL_TRUE;
mitem->name = "\x0e""Ch376 (Telestrat)";
oric->ch376 = ch376_oric_init();
if (oric->ch376 != NULL)
ch376_oric_config(oric->ch376);
}

// Toggle symbols autoload
void togglesymbolsauto( struct machine *oric, struct osdmenuitem *mitem, int dummy )
{
Expand Down
44 changes: 42 additions & 2 deletions machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
#include "disk.h"
#include "monitor.h"
#include "6551.h"

// this plugin is coded for linux and Morphos (and windows), but it had not been tested for oricutron under Morphos
// Emulation's code is a common code for oricutron and ACE (CPC emulator)
// For instance, path for usbdrive is usbdrive/ and sdcard is sdcard/. In the future, it could support an ini file to configure this plugin.

#include "plugins/ch376/ch376.h"
#include "plugins/ch376/oric_ch376_plugin.h"

#include "machine.h"
#include "avi.h"
#include "filereq.h"
Expand Down Expand Up @@ -342,7 +350,8 @@ void telestratwrite( struct m6502 *cpu, unsigned short addr, unsigned char data
{
switch( addr & 0x0f0 )
{
case 0x20:

case 0x20:
via_write( &oric->tele_via, addr, data );
break;

Expand All @@ -353,6 +362,14 @@ void telestratwrite( struct m6502 *cpu, unsigned short addr, unsigned char data
microdisc_write( &oric->md, addr, data );
break;

case 0x40:
if (oric->ch376_activated)
{
if (addr == 0x340 || addr == 0x341)
ch376_oric_write(oric->ch376, addr, data);
break;
}

default:
via_write( &oric->via, addr, data );
break;
Expand Down Expand Up @@ -610,7 +627,8 @@ unsigned char telestratread( struct m6502 *cpu, unsigned short addr )
{
switch( addr & 0x0f0 )
{
case 0x010:

case 0x010:
if( addr >= 0x31c )
{
return acia_read( &oric->tele_acia, addr );
Expand All @@ -620,6 +638,13 @@ unsigned char telestratread( struct m6502 *cpu, unsigned short addr )

case 0x020:
return via_read( &oric->tele_via, addr );

case 0x040:
if (oric->ch376_activated)
{
if (addr == 0x340 || addr == 0x341)
return ch376_oric_read(oric->ch376, addr);
}
}

return via_read( &oric->via, addr );
Expand Down Expand Up @@ -1098,6 +1123,14 @@ SDL_bool emu_event( SDL_Event *ev, struct machine *oric, SDL_bool *needrender )
via_init( &oric->via, oric, VIA_MAIN );
via_init( &oric->tele_via, oric, VIA_TELESTRAT );
acia_init( &oric->tele_acia, oric );

if (oric->ch376_activated)
{
oric->ch376 = ch376_oric_init();
if (oric->ch376 != NULL)
ch376_oric_config(oric->ch376);
}

break;

case SDLK_F5:
Expand Down Expand Up @@ -1712,6 +1745,13 @@ SDL_bool init_machine( struct machine *oric, int type, SDL_bool nukebreakpoints
via_init( &oric->via, oric, VIA_MAIN );
via_init( &oric->tele_via, oric, VIA_TELESTRAT );
acia_init( &oric->tele_acia, oric );

if (oric->ch376_activated)
{
oric->ch376 = ch376_oric_init();
ch376_oric_config(oric->ch376);
}

ay_init( &oric->ay, oric );
joy_setup( oric );
oric->cpu.rastercycles = oric->cyclesperraster;
Expand Down
4 changes: 3 additions & 1 deletion machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ struct machine
struct symboltable tele_banksyms[8];
struct via tele_via;
struct acia tele_acia;
struct ch376 *ch376;
SDL_bool ch376_activated;
int tele_currbank;
unsigned char tele_banktype;

Expand Down Expand Up @@ -152,7 +154,7 @@ struct machine
char diskname[MAX_DRIVES][32];
SDL_bool diskautosave;
SDL_bool auto_jasmin_reset;

FILE *prf;
int prclose, prclock;

Expand Down
2 changes: 2 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ static void load_config( struct start_opts *sto, struct machine *oric )
if( read_config_joykey( &sto->lctmp[i], "kbjoy2_fire1", &oric->kbjoy2[4] ) ) continue;
if( read_config_joykey( &sto->lctmp[i], "kbjoy2_fire2", &oric->kbjoy2[5] ) ) continue;
if( read_config_bool( &sto->lctmp[i], "diskautosave", &oric->diskautosave ) ) continue;
if( read_config_bool( &sto->lctmp[i], "ch376", &oric->ch376_activated) ) continue;
if( read_config_bool( &sto->lctmp[i], "show_keyboard", &oric->show_keyboard ) ) continue;
if( read_config_bool( &sto->lctmp[i], "sticky_mod_keys", &oric->sticky_mod_keys ) )continue;
if( read_config_string( &sto->lctmp[i], "autoload_keyboard_mapping", keymap_file, 4096 ) )
Expand Down Expand Up @@ -631,6 +632,7 @@ SDL_bool init( struct machine *oric, int argc, char *argv[] )
sto->start_syms[0] = 0;
sto->start_snapshot[0] = 0;
sto->start_breakpoint = NULL;
oric->ch376_activated = SDL_FALSE;
fullscreen = SDL_FALSE;
#ifdef WIN32
hwsurface = SDL_TRUE;
Expand Down
10 changes: 7 additions & 3 deletions msvc/Oricutron.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{89EA5DFF-F149-4A3C-9F9F-DD152D43934E}</ProjectGuid>
<RootNamespace>Oricutron</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -103,7 +103,7 @@
<AdditionalOptions>/we4013 /we4115 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>SDL2main.lib;SDL2.lib;ws2_32.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>shlwapi.lib;SDL2main.lib;SDL2.lib;ws2_32.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>sdl\VisualC\$(Platform)\$(Configuration)</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
<IgnoreAllDefaultLibraries>
Expand Down Expand Up @@ -157,7 +157,7 @@
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>SDL2main.lib;SDL2.lib;ws2_32.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>shlwapi.lib;SDL2main.lib;SDL2.lib;ws2_32.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>sdl\VisualC\$(Platform)\$(Configuration)</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
<IgnoreAllDefaultLibraries>
Expand Down Expand Up @@ -253,6 +253,8 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\msgbox_win32.c" />
<ClCompile Include="..\plugins\ch376\ch376.c" />
<ClCompile Include="..\plugins\ch376\oric_ch376_plugin.c" />
<ClCompile Include="..\render_gl.c" />
<ClCompile Include="..\render_null.c" />
<ClCompile Include="..\render_sw.c">
Expand Down Expand Up @@ -288,6 +290,8 @@
<ClInclude Include="..\main.h" />
<ClInclude Include="..\monitor.h" />
<ClInclude Include="..\msgbox.h" />
<ClInclude Include="..\plugins\ch376\ch376.h" />
<ClInclude Include="..\plugins\ch376\oric_ch376_plugin.h" />
<ClInclude Include="..\render_gl.h" />
<ClInclude Include="..\render_null.h" />
<ClInclude Include="..\render_sw.h" />
Expand Down
12 changes: 12 additions & 0 deletions msvc/Oricutron.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@
<ClCompile Include="..\6551_modem.c">
<Filter>Source Files\acia</Filter>
</ClCompile>
<ClCompile Include="..\plugins\ch376\ch376.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\plugins\ch376\oric_ch376_plugin.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\6502.h">
Expand Down Expand Up @@ -245,6 +251,12 @@
<ClInclude Include="..\msgbox.h">
<Filter>Header Files\msgbox</Filter>
</ClInclude>
<ClInclude Include="..\plugins\ch376\ch376.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\plugins\ch376\oric_ch376_plugin.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="make_links.cmd">
Expand Down
4 changes: 4 additions & 0 deletions oricutron.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ kbjoy2_fire2 = 'N'
;show_keyboard = yes
;sticky_mod_keys = yes
;autoload_keyboard_mapping = 'keymap/my_keymap.kma'

; ch376 chip emulation. This chip can read a usbkey. For more information : http://orix.oric.org
; only available in telestrat mode
ch376 = no
Loading

0 comments on commit e235c79

Please sign in to comment.