Skip to content

Commit 7158059

Browse files
committed
no real impact. add comments and enable building on sparc
1 parent 0496a67 commit 7158059

4 files changed

Lines changed: 42 additions & 9 deletions

File tree

djl_os.hxx

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767

6868
#else // Linux, MacOS, etc.
6969

70-
#if !defined( OLDGCC ) && !defined( M68K )
70+
#if !defined( OLDGCC ) && !defined( __mc68000__ )
7171
#include <termios.h>
7272
#endif
7373

74-
#ifdef M68K
74+
#ifdef __mc68000__
7575
extern "C" int nanosleep( const struct timespec * duration, struct timespec * rem );
7676
#endif
7777

@@ -87,7 +87,7 @@ extern "C" int nanosleep( const struct timespec * duration, struct timespec * re
8787

8888
inline void set_process_affinity( uint64_t processAffinityMask )
8989
{
90-
#if !defined(__APPLE__) && !defined( OLDGCC ) && !defined( M68K )
90+
#if !defined(__APPLE__) && !defined( OLDGCC ) && !defined( __mc68000__ )
9191
cpu_set_t mask;
9292
CPU_ZERO( &mask );
9393

@@ -197,6 +197,10 @@ inline const char * target_platform()
197197
return "x86";
198198
#elif defined( __ARM_32BIT_STATE ) // ARM32 on Raspberry PI (and more)
199199
return "arm32";
200+
#elif defined( __mc68000__ )
201+
return "m68000";
202+
#elif defined( sparc )
203+
return "sparc";
200204
#else
201205
return "(other)";
202206
#endif
@@ -326,7 +330,7 @@ inline char printable( uint8_t x )
326330
return x;
327331
} //printable
328332

329-
#if ( ( defined( __clang__ ) || defined( __GNUC__ ) ) && !defined( OLDGCC ) && !defined( M68K ) )
333+
#if ( ( defined( __clang__ ) || defined( __GNUC__ ) ) && !defined( OLDGCC ) && !defined( __mc68000__ ) )
330334

331335
inline uint64_t flip_endian64( uint64_t x ) { return __builtin_bswap64( x ); }
332336
inline uint32_t flip_endian32( uint32_t x ) { return __builtin_bswap32( x ); }
@@ -358,3 +362,33 @@ inline char printable( uint8_t x )
358362

359363
#endif
360364

365+
#ifdef sparc // If using buildroot and wide strings weren't included...
366+
inline size_t wcstombs( char * dst, const wchar_t * src, size_t len ) // simplistic ascii-only version
367+
{
368+
if ( 0 == dst || 0 == src )
369+
return -1;
370+
371+
size_t i = 0;
372+
while ( ( i < ( len - 1 ) ) && src[i] )
373+
{
374+
dst[ i ] = (char) src[ i ];
375+
i++;
376+
}
377+
378+
dst[ i ] = 0;
379+
return i;
380+
} //wcstombs
381+
382+
inline size_t wcslen(const wchar_t *str)
383+
{
384+
size_t len = 0;
385+
while ( *str )
386+
{
387+
len++;
388+
str++;
389+
}
390+
return len;
391+
} //wcslen
392+
#endif
393+
394+

djltrace.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#endif
3030

3131
#if !defined(_WIN32) && !defined(WATCOM)
32-
3332
#include <sys/unistd.h>
3433
#ifdef __APPLE__
3534
#include <unistd.h>

ntvcm.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ void set_bdos_status()
17411741
// CP/M 2.2 generally mandates L = A on return.
17421742
// HiSoft C v3.09 and the apps it generates only look at HL for bdos results, not A or L.
17431743
// So for HiSoft, H must be cleared so 16-bit HL checks just get the result in L.
1744-
// But Andre Adrian's Sargon chess fails if h is modified.
1744+
// But Andre Adrian's Sargon chess fails if h is modified. (the fix is to push and pop H in the character input macro)
17451745

17461746
reg.l = reg.a;
17471747
reg.b = 0;
@@ -3501,7 +3501,7 @@ int main( int argc, char * argv[] )
35013501
exit( 1 );
35023502
}
35033503

3504-
// this old Chess app fails if H is set to 0 during BDOS calls.
3504+
// this old Chess app fails if H is set to 0 during BDOS calls. Apparently it only ever ran on eumulators.
35053505

35063506
if ( ends_with( acCOM, "sargon.com" ) )
35073507
g_clearHOnBDOSReturn = false;

x80.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ not_inlined void x80_trace_state()
17541754
reg.pc, op, op2, op3, reg.a, reg.B(), reg.D(), reg.H(), reg.sp,
17551755
reg.renderFlags(), x80_render_operation( reg.pc ) );
17561756

1757-
//tracer.TraceBinaryData( & memory[ 0x1142 ], 16, 4 );
1757+
// tracer.TraceBinaryData( & memory[ 0x42c5 + 0x16 ], 2, 4 );
17581758
} //x80_trace_state
17591759

17601760
bool check_conditional( uint8_t op ) // checks for conditional jump, call, and return
@@ -1973,7 +1973,7 @@ uint16_t x80_emulate( uint16_t maxcycles )
19731973
case 0xc7: case 0xd7: case 0xe7: case 0xf7: case 0xcf: case 0xdf: case 0xef: case 0xff: // rst
19741974
{
19751975
// bits 5..3 are exp, which form an address 0000000000exp000 that is called.
1976-
// rst is generally invoked by hardware interrupts, which supply the one instruction rst.
1976+
// rst is generally invoked by DDT and hardware interrupts, which supply the one instruction rst.
19771977

19781978
pushword( reg.pc );
19791979
reg.pc = 0x38 & (uint16_t) op;

0 commit comments

Comments
 (0)