update Makefile; compile without warnings/errors; remove #ifdef SDL_TTF
This commit is contained in:
parent
8ffc5792a6
commit
de2796d944
28 changed files with 1456 additions and 1358 deletions
|
@ -1,18 +1,59 @@
|
||||||
---
|
---
|
||||||
IndentCaseLabels: 'true'
|
Language: Cpp
|
||||||
IndentPPDirectives: None
|
ColumnLimit: 140
|
||||||
IndentWidth: '4'
|
IndentWidth: 4
|
||||||
PointerAlignment: Left
|
PPIndentWidth: 2
|
||||||
SortIncludes: 'false'
|
UseTab: Never
|
||||||
SpaceAfterTemplateKeyword: 'false'
|
|
||||||
SpaceBeforeAssignmentOperators: 'true'
|
|
||||||
SpaceBeforeParens: ControlStatements
|
|
||||||
SpaceBeforeRangeBasedForLoopColon: 'true'
|
|
||||||
SpaceInEmptyParentheses: 'false'
|
|
||||||
SpacesInAngles: 'true'
|
|
||||||
SpacesInCStyleCastParentheses: 'true'
|
|
||||||
SpacesInContainerLiterals: 'true'
|
|
||||||
SpacesInParentheses: 'true'
|
|
||||||
SpacesInSquareBrackets: 'true'
|
|
||||||
|
|
||||||
|
AlignArrayOfStructures: Left
|
||||||
|
|
||||||
|
IndentCaseBlocks: true
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentGotoLabels: false
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
|
||||||
|
InsertBraces: false
|
||||||
|
InsertNewlineAtEOF: true
|
||||||
|
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReferenceAlignment: Left
|
||||||
|
QualifierAlignment: Left
|
||||||
|
|
||||||
|
SortIncludes: false
|
||||||
|
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesInAngles: true
|
||||||
|
SpacesInCStyleCastParentheses: true
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInParentheses: true
|
||||||
|
SpacesInSquareBrackets: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
...
|
...
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -1,7 +1,6 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LIBS = $(shell pkg-config --libs sdl2 SDL2_ttf)
|
LIBS = $(shell pkg-config --libs sdl2 SDL2_ttf)
|
||||||
CFLAGS = -Wall -Werror -O3 -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=missing-braces -Wno-error=incompatible-pointer-types
|
CFLAGS = -Wall -Werror -O3 -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-but-set-variable -Wno-error=missing-braces -Wno-error=incompatible-pointer-types
|
||||||
CFLAGS += -DSDL_TTF=1 #-DFONT_FILENAME="/usr/share/fonts/TTF/unifont.ttf"
|
|
||||||
|
|
||||||
.PHONY: all clean clean-all pretty-code install mrproper
|
.PHONY: all clean clean-all pretty-code install mrproper
|
||||||
|
|
||||||
|
|
127
src/bus.c
127
src/bus.c
|
@ -36,7 +36,7 @@
|
||||||
BusInfo bus_info = {
|
BusInfo bus_info = {
|
||||||
// hdw ram sz ram ce1 sz ce1 ce2 sz ce2 nce3 sz nce3
|
// hdw ram sz ram ce1 sz ce1 ce2 sz ce2 nce3 sz nce3
|
||||||
0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
|
0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
|
||||||
0x00000, // base or size
|
0x00000, // base or size
|
||||||
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, // configured
|
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, // configured
|
||||||
FALSE, FALSE, FALSE, // read only
|
FALSE, FALSE, FALSE, // read only
|
||||||
// ce1_bs da19 ben
|
// ce1_bs da19 ben
|
||||||
|
@ -52,7 +52,8 @@ static address hdw_seg;
|
||||||
|
|
||||||
word crc;
|
word crc;
|
||||||
|
|
||||||
void bus_init( void ) {
|
void bus_init( void )
|
||||||
|
{
|
||||||
rom_init();
|
rom_init();
|
||||||
hdw_init();
|
hdw_init();
|
||||||
ram_init();
|
ram_init();
|
||||||
|
@ -60,23 +61,22 @@ void bus_init( void ) {
|
||||||
bus_reset();
|
bus_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bus_exit( void ) {
|
void bus_exit( void )
|
||||||
|
{
|
||||||
rom_exit();
|
rom_exit();
|
||||||
hdw_exit();
|
hdw_exit();
|
||||||
ram_exit();
|
ram_exit();
|
||||||
ports_exit();
|
ports_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void update_crc( byte nibble ) {
|
static __inline void update_crc( byte nibble ) { crc = ( crc >> 4 ) ^ ( ( ( crc ^ nibble ) & 0xF ) * 0x1081 ); }
|
||||||
crc = ( crc >> 4 ) ^ ( ( ( crc ^ nibble ) & 0xF ) * 0x1081 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void bus_read( byte* buf, address adr, address len ) {
|
void bus_read( byte* buf, address adr, address len )
|
||||||
|
{
|
||||||
int n, i;
|
int n, i;
|
||||||
|
|
||||||
while ( TRUE ) {
|
while ( TRUE ) {
|
||||||
if ( hdw_seg == SEG_OF( adr ) &&
|
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||||
( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
|
||||||
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
||||||
for ( i = 0; i < n; i++ ) {
|
for ( i = 0; i < n; i++ ) {
|
||||||
buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i );
|
buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i );
|
||||||
|
@ -85,8 +85,7 @@ void bus_read( byte* buf, address adr, address len ) {
|
||||||
update_crc( buf[ n - 1 ] );
|
update_crc( buf[ n - 1 ] );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( hdw_seg == SEG_OF( adr ) &&
|
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||||
( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
|
||||||
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
||||||
} else {
|
} else {
|
||||||
n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
|
n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
|
||||||
|
@ -97,8 +96,7 @@ void bus_read( byte* buf, address adr, address len ) {
|
||||||
for ( i = 0; i < n; i++ ) {
|
for ( i = 0; i < n; i++ ) {
|
||||||
buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD;
|
buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD;
|
||||||
}
|
}
|
||||||
if ( bus_info.ce1_bs && bus_info.ce1_cfg &&
|
if ( bus_info.ce1_bs && bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
|
||||||
( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
|
|
||||||
ports_switch_bank( OFFSET_OF( adr + n ) );
|
ports_switch_bank( OFFSET_OF( adr + n ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,19 +114,18 @@ void bus_read( byte* buf, address adr, address len ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bus_write( byte* buf, address adr, address len ) {
|
void bus_write( byte* buf, address adr, address len )
|
||||||
|
{
|
||||||
int n, i;
|
int n, i;
|
||||||
|
|
||||||
while ( TRUE ) {
|
while ( TRUE ) {
|
||||||
if ( hdw_seg == SEG_OF( adr ) &&
|
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||||
( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
|
||||||
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
||||||
for ( i = 0; i < n; i++ ) {
|
for ( i = 0; i < n; i++ ) {
|
||||||
hdw_write_nibble( buf[ i ], ( adr & 0x3F ) + i );
|
hdw_write_nibble( buf[ i ], ( adr & 0x3F ) + i );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( hdw_seg == SEG_OF( adr ) &&
|
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||||
( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
|
||||||
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
||||||
} else {
|
} else {
|
||||||
n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
|
n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
|
||||||
|
@ -136,8 +133,7 @@ void bus_write( byte* buf, address adr, address len ) {
|
||||||
if ( CAN_WRITE( adr ) ) {
|
if ( CAN_WRITE( adr ) ) {
|
||||||
memcpy( MAP_WRITE( adr ), buf, n );
|
memcpy( MAP_WRITE( adr ), buf, n );
|
||||||
} else if ( bus_info.ce1_bs ) {
|
} else if ( bus_info.ce1_bs ) {
|
||||||
if ( bus_info.ce1_cfg &&
|
if ( bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
|
||||||
( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
|
|
||||||
if ( !bus_info.nce3_r_o ) {
|
if ( !bus_info.nce3_r_o ) {
|
||||||
ports_switch_bank( OFFSET_OF( adr + n - 1 ) );
|
ports_switch_bank( OFFSET_OF( adr + n - 1 ) );
|
||||||
} else if ( ( adr + n ) & 1 ) {
|
} else if ( ( adr + n ) & 1 ) {
|
||||||
|
@ -158,19 +154,18 @@ void bus_write( byte* buf, address adr, address len ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bus_peek( byte* buf, address adr, address len ) {
|
static void bus_peek( byte* buf, address adr, address len )
|
||||||
|
{
|
||||||
int n, i;
|
int n, i;
|
||||||
|
|
||||||
while ( TRUE ) {
|
while ( TRUE ) {
|
||||||
if ( hdw_seg == SEG_OF( adr ) &&
|
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||||
( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
|
||||||
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
||||||
for ( i = 0; i < n; i++ ) {
|
for ( i = 0; i < n; i++ ) {
|
||||||
buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i );
|
buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( hdw_seg == SEG_OF( adr ) &&
|
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||||
( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
|
||||||
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
||||||
} else {
|
} else {
|
||||||
n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
|
n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
|
||||||
|
@ -194,7 +189,8 @@ static void bus_peek( byte* buf, address adr, address len ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call only when you know that hdw is not in the range of nibbles read */
|
/* Call only when you know that hdw is not in the range of nibbles read */
|
||||||
static void bus_peek_no_hdw( byte* buf, address adr, address len ) {
|
static void bus_peek_no_hdw( byte* buf, address adr, address len )
|
||||||
|
{
|
||||||
int n, i;
|
int n, i;
|
||||||
|
|
||||||
while ( TRUE ) {
|
while ( TRUE ) {
|
||||||
|
@ -226,7 +222,8 @@ static void bus_peek_no_hdw( byte* buf, address adr, address len ) {
|
||||||
* actual number of nibbles that can safetly be read through the pointer (can be
|
* actual number of nibbles that can safetly be read through the pointer (can be
|
||||||
* more or less then the original).
|
* more or less then the original).
|
||||||
*/
|
*/
|
||||||
byte* bus_fast_peek( byte* buf, address adr, int* len ) {
|
byte* bus_fast_peek( byte* buf, address adr, int* len )
|
||||||
|
{
|
||||||
static byte tmp_buf[ FAST_PEEK_MAX ];
|
static byte tmp_buf[ FAST_PEEK_MAX ];
|
||||||
static int tmp_len;
|
static int tmp_len;
|
||||||
address adr2;
|
address adr2;
|
||||||
|
@ -245,23 +242,20 @@ byte* bus_fast_peek( byte* buf, address adr, int* len ) {
|
||||||
adr2 = adr + *len - 1;
|
adr2 = adr + *len - 1;
|
||||||
|
|
||||||
if ( ( SEG_OF( adr ) == hdw_seg || SEG_OF( adr2 ) == hdw_seg ) &&
|
if ( ( SEG_OF( adr ) == hdw_seg || SEG_OF( adr2 ) == hdw_seg ) &&
|
||||||
( ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ||
|
( ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 || ( ( bus_info.hdw_base ^ adr2 ) & 0xFFFC0 ) == 0 ) ) {
|
||||||
( ( bus_info.hdw_base ^ adr2 ) & 0xFFFC0 ) == 0 ) ) {
|
|
||||||
bus_peek( buf, adr, *len );
|
bus_peek( buf, adr, *len );
|
||||||
return buf;
|
return buf;
|
||||||
} else if ( !CAN_READ( adr ) ) {
|
} else if ( !CAN_READ( adr ) ) {
|
||||||
bus_peek_no_hdw( buf, adr, *len );
|
bus_peek_no_hdw( buf, adr, *len );
|
||||||
return buf;
|
return buf;
|
||||||
} else if ( SEG_OF( adr ) == SEG_OF( adr2 ) ) {
|
} else if ( SEG_OF( adr ) == SEG_OF( adr2 ) ) {
|
||||||
if ( hdw_seg == SEG_OF( adr ) &&
|
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||||
( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
|
||||||
*len = ( bus_info.hdw_base & 0xFFFC0 ) - adr;
|
*len = ( bus_info.hdw_base & 0xFFFC0 ) - adr;
|
||||||
} else {
|
} else {
|
||||||
*len = 0x1000 - OFFSET_OF( adr );
|
*len = 0x1000 - OFFSET_OF( adr );
|
||||||
}
|
}
|
||||||
return MAP_READ( adr );
|
return MAP_READ( adr );
|
||||||
} else if ( CAN_READ( adr2 ) &&
|
} else if ( CAN_READ( adr2 ) && MAP_READ( adr ) + *len - 1 == MAP_READ( adr2 ) ) {
|
||||||
MAP_READ( adr ) + *len - 1 == MAP_READ( adr2 ) ) {
|
|
||||||
if ( hdw_seg == SEG_OF( adr2 ) ) {
|
if ( hdw_seg == SEG_OF( adr2 ) ) {
|
||||||
*len = ( bus_info.hdw_base & 0xFFFC0 ) - adr;
|
*len = ( bus_info.hdw_base & 0xFFFC0 ) - adr;
|
||||||
} else {
|
} else {
|
||||||
|
@ -274,24 +268,19 @@ byte* bus_fast_peek( byte* buf, address adr, int* len ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bus_remap( void ) {
|
void bus_remap( void )
|
||||||
|
{
|
||||||
int adr;
|
int adr;
|
||||||
|
|
||||||
for ( adr = 0; adr < 0x100000; adr += 0x01000 ) {
|
for ( adr = 0; adr < 0x100000; adr += 0x01000 ) {
|
||||||
if ( bus_info.ram_cfg &&
|
if ( bus_info.ram_cfg && ( ( bus_info.ram_base ^ adr ) & bus_info.ram_size ) == 0 ) {
|
||||||
( ( bus_info.ram_base ^ adr ) & bus_info.ram_size ) == 0 ) {
|
read_map[ SEG_OF( adr ) ] = bus_info.ram_data + ( adr & bus_info.ram_mask );
|
||||||
read_map[ SEG_OF( adr ) ] =
|
write_map[ SEG_OF( adr ) ] = bus_info.ram_data + ( adr & bus_info.ram_mask );
|
||||||
bus_info.ram_data + ( adr & bus_info.ram_mask );
|
} else if ( bus_info.ce2_cfg && ( ( bus_info.ce2_base ^ adr ) & bus_info.ce2_size ) == 0 ) {
|
||||||
write_map[ SEG_OF( adr ) ] =
|
|
||||||
bus_info.ram_data + ( adr & bus_info.ram_mask );
|
|
||||||
} else if ( bus_info.ce2_cfg &&
|
|
||||||
( ( bus_info.ce2_base ^ adr ) & bus_info.ce2_size ) == 0 ) {
|
|
||||||
if ( bus_info.ce2_data ) {
|
if ( bus_info.ce2_data ) {
|
||||||
read_map[ SEG_OF( adr ) ] =
|
read_map[ SEG_OF( adr ) ] = bus_info.ce2_data + ( adr & bus_info.ce2_mask );
|
||||||
bus_info.ce2_data + ( adr & bus_info.ce2_mask );
|
|
||||||
if ( !bus_info.ce2_r_o ) {
|
if ( !bus_info.ce2_r_o ) {
|
||||||
write_map[ SEG_OF( adr ) ] =
|
write_map[ SEG_OF( adr ) ] = bus_info.ce2_data + ( adr & bus_info.ce2_mask );
|
||||||
bus_info.ce2_data + ( adr & bus_info.ce2_mask );
|
|
||||||
} else {
|
} else {
|
||||||
write_map[ SEG_OF( adr ) ] = NULL;
|
write_map[ SEG_OF( adr ) ] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -299,14 +288,11 @@ void bus_remap( void ) {
|
||||||
read_map[ SEG_OF( adr ) ] = NULL;
|
read_map[ SEG_OF( adr ) ] = NULL;
|
||||||
write_map[ SEG_OF( adr ) ] = NULL;
|
write_map[ SEG_OF( adr ) ] = NULL;
|
||||||
}
|
}
|
||||||
} else if ( bus_info.ce1_cfg &&
|
} else if ( bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) == 0 ) {
|
||||||
( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) == 0 ) {
|
|
||||||
if ( bus_info.ce1_data ) {
|
if ( bus_info.ce1_data ) {
|
||||||
read_map[ SEG_OF( adr ) ] =
|
read_map[ SEG_OF( adr ) ] = bus_info.ce1_data + ( adr & bus_info.ce1_mask );
|
||||||
bus_info.ce1_data + ( adr & bus_info.ce1_mask );
|
|
||||||
if ( !bus_info.ce1_r_o ) {
|
if ( !bus_info.ce1_r_o ) {
|
||||||
write_map[ SEG_OF( adr ) ] =
|
write_map[ SEG_OF( adr ) ] = bus_info.ce1_data + ( adr & bus_info.ce1_mask );
|
||||||
bus_info.ce1_data + ( adr & bus_info.ce1_mask );
|
|
||||||
} else {
|
} else {
|
||||||
write_map[ SEG_OF( adr ) ] = NULL;
|
write_map[ SEG_OF( adr ) ] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -314,14 +300,11 @@ void bus_remap( void ) {
|
||||||
read_map[ SEG_OF( adr ) ] = NULL;
|
read_map[ SEG_OF( adr ) ] = NULL;
|
||||||
write_map[ SEG_OF( adr ) ] = NULL;
|
write_map[ SEG_OF( adr ) ] = NULL;
|
||||||
}
|
}
|
||||||
} else if ( bus_info.nce3_cfg && ( ( bus_info.nce3_base ^ adr ) &
|
} else if ( bus_info.nce3_cfg && ( ( bus_info.nce3_base ^ adr ) & bus_info.nce3_size ) == 0 ) {
|
||||||
bus_info.nce3_size ) == 0 ) {
|
|
||||||
if ( bus_info.nce3_data && bus_info.ben && !bus_info.da19 ) {
|
if ( bus_info.nce3_data && bus_info.ben && !bus_info.da19 ) {
|
||||||
read_map[ SEG_OF( adr ) ] =
|
read_map[ SEG_OF( adr ) ] = bus_info.nce3_data + ( adr & bus_info.nce3_mask );
|
||||||
bus_info.nce3_data + ( adr & bus_info.nce3_mask );
|
|
||||||
if ( !bus_info.nce3_r_o ) {
|
if ( !bus_info.nce3_r_o ) {
|
||||||
write_map[ SEG_OF( adr ) ] =
|
write_map[ SEG_OF( adr ) ] = bus_info.nce3_data + ( adr & bus_info.nce3_mask );
|
||||||
bus_info.nce3_data + ( adr & bus_info.nce3_mask );
|
|
||||||
} else {
|
} else {
|
||||||
write_map[ SEG_OF( adr ) ] = NULL;
|
write_map[ SEG_OF( adr ) ] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -330,9 +313,7 @@ void bus_remap( void ) {
|
||||||
write_map[ SEG_OF( adr ) ] = NULL;
|
write_map[ SEG_OF( adr ) ] = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
read_map[ SEG_OF( adr ) ] =
|
read_map[ SEG_OF( adr ) ] = bus_info.rom_data + ( adr & bus_info.rom_mask & ( bus_info.da19 ? 0xFFFFF : 0x7FFFF ) );
|
||||||
bus_info.rom_data + ( adr & bus_info.rom_mask &
|
|
||||||
( bus_info.da19 ? 0xFFFFF : 0x7FFFF ) );
|
|
||||||
write_map[ SEG_OF( adr ) ] = NULL;
|
write_map[ SEG_OF( adr ) ] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,7 +321,8 @@ void bus_remap( void ) {
|
||||||
// invalid
|
// invalid
|
||||||
}
|
}
|
||||||
|
|
||||||
void bus_configure( address adr ) {
|
void bus_configure( address adr )
|
||||||
|
{
|
||||||
if ( !bus_info.hdw_cfg ) {
|
if ( !bus_info.hdw_cfg ) {
|
||||||
bus_info.hdw_base = adr & 0xFFFC0;
|
bus_info.hdw_base = adr & 0xFFFC0;
|
||||||
bus_info.hdw_cfg = TRUE;
|
bus_info.hdw_cfg = TRUE;
|
||||||
|
@ -376,34 +358,32 @@ void bus_configure( address adr ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bus_unconfigure( address adr ) {
|
void bus_unconfigure( address adr )
|
||||||
|
{
|
||||||
if ( bus_info.hdw_cfg && ( ( adr ^ bus_info.hdw_base ) & 0xFFFC0 ) == 0 ) {
|
if ( bus_info.hdw_cfg && ( ( adr ^ bus_info.hdw_base ) & 0xFFFC0 ) == 0 ) {
|
||||||
bus_info.hdw_cfg = FALSE;
|
bus_info.hdw_cfg = FALSE;
|
||||||
hdw_seg = -1;
|
hdw_seg = -1;
|
||||||
} else if ( bus_info.ram_cfg &&
|
} else if ( bus_info.ram_cfg && ( ( adr ^ bus_info.ram_base ) & bus_info.ram_size ) == 0 ) {
|
||||||
( ( adr ^ bus_info.ram_base ) & bus_info.ram_size ) == 0 ) {
|
|
||||||
bus_info.ram_cfg = FALSE;
|
bus_info.ram_cfg = FALSE;
|
||||||
bus_info.ram_sz_cfg = FALSE;
|
bus_info.ram_sz_cfg = FALSE;
|
||||||
bus_remap();
|
bus_remap();
|
||||||
} else if ( bus_info.ce2_cfg &&
|
} else if ( bus_info.ce2_cfg && ( ( adr ^ bus_info.ce2_base ) & bus_info.ce2_size ) == 0 ) {
|
||||||
( ( adr ^ bus_info.ce2_base ) & bus_info.ce2_size ) == 0 ) {
|
|
||||||
bus_info.ce2_cfg = FALSE;
|
bus_info.ce2_cfg = FALSE;
|
||||||
bus_info.ce2_sz_cfg = FALSE;
|
bus_info.ce2_sz_cfg = FALSE;
|
||||||
bus_remap();
|
bus_remap();
|
||||||
} else if ( bus_info.ce1_cfg &&
|
} else if ( bus_info.ce1_cfg && ( ( adr ^ bus_info.ce1_base ) & bus_info.ce1_size ) == 0 ) {
|
||||||
( ( adr ^ bus_info.ce1_base ) & bus_info.ce1_size ) == 0 ) {
|
|
||||||
bus_info.ce1_cfg = FALSE;
|
bus_info.ce1_cfg = FALSE;
|
||||||
bus_info.ce1_sz_cfg = FALSE;
|
bus_info.ce1_sz_cfg = FALSE;
|
||||||
bus_remap();
|
bus_remap();
|
||||||
} else if ( bus_info.nce3_cfg &&
|
} else if ( bus_info.nce3_cfg && ( ( adr ^ bus_info.nce3_base ) & bus_info.nce3_size ) == 0 ) {
|
||||||
( ( adr ^ bus_info.nce3_base ) & bus_info.nce3_size ) == 0 ) {
|
|
||||||
bus_info.nce3_cfg = FALSE;
|
bus_info.nce3_cfg = FALSE;
|
||||||
bus_info.nce3_sz_cfg = FALSE;
|
bus_info.nce3_sz_cfg = FALSE;
|
||||||
bus_remap();
|
bus_remap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bus_reset( void ) {
|
void bus_reset( void )
|
||||||
|
{
|
||||||
bus_info.hdw_base = 0x00000;
|
bus_info.hdw_base = 0x00000;
|
||||||
bus_info.hdw_cfg = FALSE;
|
bus_info.hdw_cfg = FALSE;
|
||||||
|
|
||||||
|
@ -431,7 +411,8 @@ void bus_reset( void ) {
|
||||||
bus_remap();
|
bus_remap();
|
||||||
}
|
}
|
||||||
|
|
||||||
address bus_get_id( void ) {
|
address bus_get_id( void )
|
||||||
|
{
|
||||||
if ( !bus_info.hdw_cfg ) {
|
if ( !bus_info.hdw_cfg ) {
|
||||||
return bus_info.hdw_base | 0x00019;
|
return bus_info.hdw_base | 0x00019;
|
||||||
} else if ( !bus_info.ram_sz_cfg ) {
|
} else if ( !bus_info.ram_sz_cfg ) {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#define SEG_OF( adr ) ( ( adr ) >> 12 )
|
#define SEG_OF( adr ) ( ( adr ) >> 12 )
|
||||||
#define OFFSET_OF( adr ) ( ( adr )&0xFFF )
|
#define OFFSET_OF( adr ) ( ( adr ) & 0xFFF )
|
||||||
#define CAN_READ( adr ) ( read_map[ SEG_OF( adr ) ] != NULL )
|
#define CAN_READ( adr ) ( read_map[ SEG_OF( adr ) ] != NULL )
|
||||||
#define CAN_WRITE( adr ) ( write_map[ SEG_OF( adr ) ] != NULL )
|
#define CAN_WRITE( adr ) ( write_map[ SEG_OF( adr ) ] != NULL )
|
||||||
#define MAP_READ( adr ) ( read_map[ SEG_OF( adr ) ] + OFFSET_OF( adr ) )
|
#define MAP_READ( adr ) ( read_map[ SEG_OF( adr ) ] + OFFSET_OF( adr ) )
|
||||||
|
|
31
src/color.c
31
src/color.c
|
@ -43,13 +43,14 @@ static int lcd_0_r, lcd_0_g, lcd_0_b;
|
||||||
static int lcd_1_r, lcd_1_g, lcd_1_b;
|
static int lcd_1_r, lcd_1_g, lcd_1_b;
|
||||||
static int lcd_mode;
|
static int lcd_mode;
|
||||||
|
|
||||||
static void set_lcd_color( int i, int v ) {
|
/* static void set_lcd_color( int i, int v ) { */
|
||||||
// palette[i].r = (lcd_0_r * (255 - v) + lcd_1_r * v) / 255;
|
/* // palette[i].r = (lcd_0_r * (255 - v) + lcd_1_r * v) / 255; */
|
||||||
// palette[i].g = (lcd_0_g * (255 - v) + lcd_1_g * v) / 255;
|
/* // palette[i].g = (lcd_0_g * (255 - v) + lcd_1_g * v) / 255; */
|
||||||
// palette[i].b = (lcd_0_b * (255 - v) + lcd_1_b * v) / 255;
|
/* // palette[i].b = (lcd_0_b * (255 - v) + lcd_1_b * v) / 255; */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
static int bit_count( unsigned int i ) {
|
static int bit_count( unsigned int i )
|
||||||
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
while ( i ) {
|
while ( i ) {
|
||||||
|
@ -69,10 +70,10 @@ static int exp_color( int i ) { return i * 255 / 127; }
|
||||||
|
|
||||||
typedef int ( *lcd_color_func )( int i );
|
typedef int ( *lcd_color_func )( int i );
|
||||||
|
|
||||||
lcd_color_func lcd_color_functions[] = { simple_color, gray4_color, gray8_color,
|
lcd_color_func lcd_color_functions[] = { simple_color, gray4_color, gray8_color, exp_color };
|
||||||
exp_color };
|
|
||||||
|
|
||||||
void build_lcd_palette( void ) {
|
void build_lcd_palette( void )
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -83,7 +84,8 @@ void build_lcd_palette( void ) {
|
||||||
// set_palette_range(palette, 0, RESERVED_LCD-1, FALSE);
|
// set_palette_range(palette, 0, RESERVED_LCD-1, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void color_lcd( int r0, int g0, int b0, int r1, int g1, int b1 ) {
|
void color_lcd( int r0, int g0, int b0, int r1, int g1, int b1 )
|
||||||
|
{
|
||||||
lcd_0_r = r0 >> 2;
|
lcd_0_r = r0 >> 2;
|
||||||
lcd_0_g = g0 >> 2;
|
lcd_0_g = g0 >> 2;
|
||||||
lcd_0_b = b0 >> 2;
|
lcd_0_b = b0 >> 2;
|
||||||
|
@ -93,12 +95,14 @@ void color_lcd( int r0, int g0, int b0, int r1, int g1, int b1 ) {
|
||||||
build_lcd_palette();
|
build_lcd_palette();
|
||||||
}
|
}
|
||||||
|
|
||||||
void color_lcd_mode( int mode ) {
|
void color_lcd_mode( int mode )
|
||||||
|
{
|
||||||
lcd_mode = mode;
|
lcd_mode = mode;
|
||||||
build_lcd_palette();
|
build_lcd_palette();
|
||||||
}
|
}
|
||||||
|
|
||||||
void color_set_emu( int i, int r, int g, int b ) {
|
void color_set_emu( int i, int r, int g, int b )
|
||||||
|
{
|
||||||
// if (bitmap_color_depth(screen) == 8) {
|
// if (bitmap_color_depth(screen) == 8) {
|
||||||
// palette[color[i]].r = r >> 2;
|
// palette[color[i]].r = r >> 2;
|
||||||
// palette[color[i]].g = g >> 2;
|
// palette[color[i]].g = g >> 2;
|
||||||
|
@ -109,7 +113,8 @@ void color_set_emu( int i, int r, int g, int b ) {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void color_init( void ) {
|
void color_init( void )
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// if (bitmap_color_depth(screen) == 8) {
|
// if (bitmap_color_depth(screen) == 8) {
|
||||||
|
|
|
@ -28,12 +28,7 @@
|
||||||
#ifndef __COLOR_H
|
#ifndef __COLOR_H
|
||||||
#define __COLOR_H
|
#define __COLOR_H
|
||||||
|
|
||||||
enum LCD_Modes {
|
enum LCD_Modes { LCD_MODE_SIMPLE, LCD_MODE_GRAY4, LCD_MODE_GRAY8, LCD_MODE_EXP };
|
||||||
LCD_MODE_SIMPLE,
|
|
||||||
LCD_MODE_GRAY4,
|
|
||||||
LCD_MODE_GRAY8,
|
|
||||||
LCD_MODE_EXP
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Colors {
|
enum Colors {
|
||||||
C_BACKGROUND,
|
C_BACKGROUND,
|
||||||
|
|
12
src/cpu.c
12
src/cpu.c
|
@ -36,7 +36,8 @@ Cpu cpu;
|
||||||
|
|
||||||
#define MAX_OPC_LEN 21
|
#define MAX_OPC_LEN 21
|
||||||
|
|
||||||
void cpu_interrupt( void ) {
|
void cpu_interrupt( void )
|
||||||
|
{
|
||||||
printf( "cpu_interrupt\n" );
|
printf( "cpu_interrupt\n" );
|
||||||
if ( cpu.inte ) {
|
if ( cpu.inte ) {
|
||||||
cpu.inte = FALSE;
|
cpu.inte = FALSE;
|
||||||
|
@ -46,7 +47,8 @@ void cpu_interrupt( void ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decode( byte* ptr ) {
|
static void decode( byte* ptr )
|
||||||
|
{
|
||||||
Opcode* op = opcodes;
|
Opcode* op = opcodes;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
@ -63,15 +65,15 @@ static void decode( byte* ptr ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void execute_instruction( void ) {
|
void execute_instruction( void )
|
||||||
|
{
|
||||||
static byte buffer[ FAST_PEEK_MAX ];
|
static byte buffer[ FAST_PEEK_MAX ];
|
||||||
static byte* ptr;
|
static byte* ptr;
|
||||||
static dword old_map_cnt;
|
static dword old_map_cnt;
|
||||||
static address len;
|
static address len;
|
||||||
static address adr;
|
static address adr;
|
||||||
|
|
||||||
if ( cpu.pc < adr || adr + len < cpu.pc + MAX_OPC_LEN ||
|
if ( cpu.pc < adr || adr + len < cpu.pc + MAX_OPC_LEN || bus_info.map_cnt != old_map_cnt || !ptr ) {
|
||||||
bus_info.map_cnt != old_map_cnt || !ptr ) {
|
|
||||||
len = MAX_OPC_LEN;
|
len = MAX_OPC_LEN;
|
||||||
adr = cpu.pc;
|
adr = cpu.pc;
|
||||||
ptr = bus_fast_peek( buffer, adr, &len );
|
ptr = bus_fast_peek( buffer, adr, &len );
|
||||||
|
|
30
src/disasm.c
30
src/disasm.c
|
@ -50,15 +50,16 @@ static const char* f_tab[ 8 ] = { "P", "WP", "XS", "X", "S", "M", "B", "W" };
|
||||||
|
|
||||||
#define HEX( x ) ( hex_tab[ x ] )
|
#define HEX( x ) ( hex_tab[ x ] )
|
||||||
|
|
||||||
#define ADD_OFFSET( x, s ) \
|
#define ADD_OFFSET( x, s ) \
|
||||||
do { \
|
do { \
|
||||||
if ( *( s ) == '+' ) { \
|
if ( *( s ) == '+' ) { \
|
||||||
( s )++; \
|
( s )++; \
|
||||||
( x ) += *( s )++ - '0'; \
|
( x ) += *( s )++ - '0'; \
|
||||||
} \
|
} \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
static __inline int nib_to_signed( byte* nib, int len ) {
|
static __inline int nib_to_signed( byte* nib, int len )
|
||||||
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
len--;
|
len--;
|
||||||
|
@ -72,7 +73,8 @@ static __inline int nib_to_signed( byte* nib, int len ) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void expand( char* dest, char* src, byte* ptr ) {
|
static void expand( char* dest, char* src, byte* ptr )
|
||||||
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
|
@ -203,8 +205,7 @@ static void expand( char* dest, char* src, byte* ptr ) {
|
||||||
|
|
||||||
case 'i': // R-register number
|
case 'i': // R-register number
|
||||||
i = *src++ - '0';
|
i = *src++ - '0';
|
||||||
*dest++ = '0' + ( ( ptr[ i ] & 7 ) > 4 ? ptr[ i ] & 3
|
*dest++ = '0' + ( ( ptr[ i ] & 7 ) > 4 ? ptr[ i ] & 3 : ptr[ i ] & 7 );
|
||||||
: ptr[ i ] & 7 );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '#': // "#" or "=" for comparisons
|
case '#': // "#" or "=" for comparisons
|
||||||
|
@ -281,7 +282,8 @@ static void expand( char* dest, char* src, byte* ptr ) {
|
||||||
*dest = '\0';
|
*dest = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
char* disassemble( byte* ptr ) {
|
char* disassemble( byte* ptr )
|
||||||
|
{
|
||||||
static char buffer[ 64 ];
|
static char buffer[ 64 ];
|
||||||
|
|
||||||
Opcode* op = opcodes;
|
Opcode* op = opcodes;
|
||||||
|
@ -299,7 +301,8 @@ char* disassemble( byte* ptr ) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* nib_to_hex( byte* nib, int n ) {
|
char* nib_to_hex( byte* nib, int n )
|
||||||
|
{
|
||||||
static char buffer[ 17 ];
|
static char buffer[ 17 ];
|
||||||
|
|
||||||
buffer[ n ] = '\0';
|
buffer[ n ] = '\0';
|
||||||
|
@ -309,7 +312,8 @@ char* nib_to_hex( byte* nib, int n ) {
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* nib_to_hex_rev( byte* nib, int n ) {
|
char* nib_to_hex_rev( byte* nib, int n )
|
||||||
|
{
|
||||||
static char buffer[ 17 ];
|
static char buffer[ 17 ];
|
||||||
|
|
||||||
buffer[ n ] = '\0';
|
buffer[ n ] = '\0';
|
||||||
|
|
|
@ -54,7 +54,7 @@ static boolean in_menu;
|
||||||
static byte off_cur_line;
|
static byte off_cur_line;
|
||||||
static byte off_line;
|
static byte off_line;
|
||||||
static int off_cnt;
|
static int off_cnt;
|
||||||
static boolean shouldClear = TRUE;
|
/* static boolean shouldClear = TRUE; */
|
||||||
static boolean shouldRender = FALSE;
|
static boolean shouldRender = FALSE;
|
||||||
static int screen_draw_count = 0;
|
static int screen_draw_count = 0;
|
||||||
static boolean drawGS = FALSE;
|
static boolean drawGS = FALSE;
|
||||||
|
@ -65,7 +65,8 @@ extern SDL_Texture* texTarget;
|
||||||
extern SDL_Texture* tex2Target;
|
extern SDL_Texture* tex2Target;
|
||||||
extern SDL_Texture* faceplateTexture;
|
extern SDL_Texture* faceplateTexture;
|
||||||
|
|
||||||
void clearLCD() {
|
void clearLCD()
|
||||||
|
{
|
||||||
// SDL_SetRenderDrawColor(renderer, 0x44, 0x44, 0x66, 0xFF);
|
// SDL_SetRenderDrawColor(renderer, 0x44, 0x44, 0x66, 0xFF);
|
||||||
// SDL_SetRenderDrawColor(renderer, 119, 172, 130, 0xFF); // vert clair
|
// SDL_SetRenderDrawColor(renderer, 119, 172, 130, 0xFF); // vert clair
|
||||||
SDL_SetRenderDrawColor( renderer, 48, 68, 90, 0xFF ); // bleu foncé
|
SDL_SetRenderDrawColor( renderer, 48, 68, 90, 0xFF ); // bleu foncé
|
||||||
|
@ -79,7 +80,8 @@ void clearLCD() {
|
||||||
// SDL_SetRenderTarget(renderer, texTarget);
|
// SDL_SetRenderTarget(renderer, texTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void endLCD() {
|
void endLCD()
|
||||||
|
{
|
||||||
// Reset render target
|
// Reset render target
|
||||||
// SDL_SetRenderTarget( renderer, NULL );
|
// SDL_SetRenderTarget( renderer, NULL );
|
||||||
|
|
||||||
|
@ -95,24 +97,27 @@ void endLCD() {
|
||||||
pcalc_show();
|
pcalc_show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderLCD() {
|
void renderLCD()
|
||||||
|
{
|
||||||
// SDL_RenderPresent( renderer );
|
// SDL_RenderPresent( renderer );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fade_lcd_line( int y ) {
|
/* static void fade_lcd_line( int y ) { */
|
||||||
/*
|
/* /\* */
|
||||||
byte *lcd_line0 = (byte *)lcd->line[y*2];
|
/* byte *lcd_line0 = (byte *)lcd->line[y*2]; */
|
||||||
byte *lcd_line1 = (byte *)lcd->line[y*2+1];
|
/* byte *lcd_line1 = (byte *)lcd->line[y*2+1]; */
|
||||||
int x = 0;
|
/* int x = 0; */
|
||||||
|
|
||||||
while (x < 131) {
|
/* while (x < 131) { */
|
||||||
lcd_line0[x*2] = lcd_line0[x*2+1] = lcd_line1[x*2] = lcd_line1[x*2+1] =
|
/* lcd_line0[x*2] = lcd_line0[x*2+1] = lcd_line1[x*2] = lcd_line1[x*2+1] =
|
||||||
(lcd_line0[x*2] >> 1); x++;
|
*/
|
||||||
}
|
/* (lcd_line0[x*2] >> 1); x++; */
|
||||||
*/
|
/* } */
|
||||||
}
|
/* *\/ */
|
||||||
|
/* } */
|
||||||
|
|
||||||
static address draw_lcd_line( address adr, int y ) {
|
static address draw_lcd_line( address adr, int y )
|
||||||
|
{
|
||||||
// printf("draw_lcd_line %d ", y);
|
// printf("draw_lcd_line %d ", y);
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
@ -141,8 +146,7 @@ static address draw_lcd_line( address adr, int y ) {
|
||||||
bit = 4;
|
bit = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte pixel =
|
byte pixel = ( ( data & 1 ) << 6 ); // (lcd_line0[x*2] >> 1) | ((data & 1) << 6);
|
||||||
( ( data & 1 ) << 6 ); // (lcd_line0[x*2] >> 1) | ((data & 1) << 6);
|
|
||||||
if ( pixel != '\0' ) {
|
if ( pixel != '\0' ) {
|
||||||
pixel = '\3';
|
pixel = '\3';
|
||||||
// printf("%c ", pixel);
|
// printf("%c ", pixel);
|
||||||
|
@ -203,21 +207,23 @@ static address draw_lcd_line( address adr, int y ) {
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( adr + 0x22 + ( !in_menu && ( display_offset & 4 ) ? 2 : 0 ) ) &
|
return ( adr + 0x22 + ( !in_menu && ( display_offset & 4 ) ? 2 : 0 ) ) & 0xFFFFF;
|
||||||
0xFFFFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_init( void ) {
|
void display_init( void )
|
||||||
|
{
|
||||||
// lcd = create_bitmap_ex(8, 131*2, 64*2);
|
// lcd = create_bitmap_ex(8, 131*2, 64*2);
|
||||||
// clear_to_color(lcd, 0);
|
// clear_to_color(lcd, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_exit( void ) {
|
void display_exit( void )
|
||||||
|
{
|
||||||
// destroy_bitmap (lcd);
|
// destroy_bitmap (lcd);
|
||||||
// lcd = NULL;
|
// lcd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_show() {
|
void display_show()
|
||||||
|
{
|
||||||
SDL_SetRenderDrawColor( renderer, 48, 68, 90, 0xFF ); // bleu foncé
|
SDL_SetRenderDrawColor( renderer, 48, 68, 90, 0xFF ); // bleu foncé
|
||||||
SDL_RenderClear( renderer );
|
SDL_RenderClear( renderer );
|
||||||
|
|
||||||
|
@ -239,8 +245,7 @@ void display_show() {
|
||||||
printf( "error\n" );
|
printf( "error\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( SDL_LockTexture( texTarget, NULL, ( void** )&pixels, &pitch ) !=
|
if ( SDL_LockTexture( texTarget, NULL, ( void** )&pixels, &pitch ) != 0 ) {
|
||||||
0 ) {
|
|
||||||
printf( "SDL_LockTexture: %s.\n", SDL_GetError() );
|
printf( "SDL_LockTexture: %s.\n", SDL_GetError() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,8 +288,7 @@ void display_show() {
|
||||||
|
|
||||||
// Before setting the color, we need to know where we have to
|
// Before setting the color, we need to know where we have to
|
||||||
// place it.
|
// place it.
|
||||||
Uint32 pixelPosition =
|
Uint32 pixelPosition = y * ( pitch / sizeof( unsigned int ) ) + x;
|
||||||
y * ( pitch / sizeof( unsigned int ) ) + x;
|
|
||||||
|
|
||||||
pixels[ pixelPosition ] = color;
|
pixels[ pixelPosition ] = color;
|
||||||
}
|
}
|
||||||
|
@ -303,7 +307,8 @@ void display_show() {
|
||||||
SDL_RenderPresent( renderer );
|
SDL_RenderPresent( renderer );
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_update( void ) {
|
void display_update( void )
|
||||||
|
{
|
||||||
if ( !display_enable && !off_cnt ) { /* Turn off display */
|
if ( !display_enable && !off_cnt ) { /* Turn off display */
|
||||||
off_cnt = 1;
|
off_cnt = 1;
|
||||||
off_cur_line = off_line = display_line_count;
|
off_cur_line = off_line = display_line_count;
|
||||||
|
@ -322,7 +327,7 @@ void display_update( void ) {
|
||||||
// acquire_screen();
|
// acquire_screen();
|
||||||
// scare_mouse_area(LCD_X, LCD_Y+display_line_count*2, 131*2, 2);
|
// scare_mouse_area(LCD_X, LCD_Y+display_line_count*2, 131*2, 2);
|
||||||
// blit(lcd, screen, 0, display_line_count*2, LCD_X,
|
// blit(lcd, screen, 0, display_line_count*2, LCD_X,
|
||||||
//LCD_Y+display_line_count*2, 131*2, 2); unscare_mouse();
|
// LCD_Y+display_line_count*2, 131*2, 2); unscare_mouse();
|
||||||
// release_screen();
|
// release_screen();
|
||||||
|
|
||||||
if ( !in_menu ) {
|
if ( !in_menu ) {
|
||||||
|
|
|
@ -57,35 +57,41 @@ typedef struct {
|
||||||
void ( *proc )( void );
|
void ( *proc )( void );
|
||||||
} TimerEvent;
|
} TimerEvent;
|
||||||
|
|
||||||
static CycleEvent cycle_events[] = { { 0, 16, timer1_update },
|
static CycleEvent cycle_events[] = {
|
||||||
|
{0, 16, timer1_update },
|
||||||
#ifndef TRUE_TIMER2
|
#ifndef TRUE_TIMER2
|
||||||
{ 0, 8192, timer2_update },
|
{ 0, 8192, timer2_update },
|
||||||
#endif
|
#endif
|
||||||
{ 0, 4096, display_update },
|
{ 0, 4096, display_update},
|
||||||
{ 0, 0, NULL } };
|
{ 0, 0, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static TimerEvent timer_events[] = {
|
static TimerEvent timer_events[] = {
|
||||||
{ 0, 1000000 / 20 /*BPS_TO_TIMER(20)*/, FALSE, gui_update },
|
{0, 1000000 / 20 /*BPS_TO_TIMER(20)*/, FALSE, gui_update },
|
||||||
{ 0, 1000000 /*BPS_TO_TIMER(1)*/, FALSE, true_speed_proc },
|
{ 0, 1000000 /*BPS_TO_TIMER(1)*/, FALSE, true_speed_proc},
|
||||||
#ifdef TRUE_TIMER2
|
#ifdef TRUE_TIMER2
|
||||||
{ 0, 1000000 / 8192 /*BPS_TO_TIMER(8192)*/, FALSE, timer2_update },
|
{ 0, 1000000 / 8192 /*BPS_TO_TIMER(8192)*/, FALSE, timer2_update },
|
||||||
#endif
|
#endif
|
||||||
{ 0, 0, FALSE, NULL } };
|
{ 0, 0, FALSE, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
volatile boolean please_exit = FALSE;
|
volatile boolean please_exit = FALSE;
|
||||||
dword emulator_speed = 4000000;
|
dword emulator_speed = 4000000;
|
||||||
static int emulator_state = EMULATOR_RUN; // EMULATOR_STOP;
|
static int emulator_state = EMULATOR_RUN; // EMULATOR_STOP;
|
||||||
|
|
||||||
void true_speed_proc( void ) {
|
void true_speed_proc( void )
|
||||||
|
{
|
||||||
static dword last_cycles;
|
static dword last_cycles;
|
||||||
|
|
||||||
pdebug_draw_true_speed( cpu.cycles - last_cycles );
|
pdebug_draw_true_speed( cpu.cycles - last_cycles );
|
||||||
last_cycles = cpu.cycles;
|
last_cycles = cpu.cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void timer_event_proc( void* what ) { ( ( TimerEvent* )what )->value++; }
|
/* static void timer_event_proc( void* what ) { ( ( TimerEvent* )what
|
||||||
|
* )->value++; } */
|
||||||
|
|
||||||
static void start_timer_proc( void ( *proc )( void ) ) {
|
static void start_timer_proc( void ( *proc )( void ) )
|
||||||
|
{
|
||||||
TimerEvent* ptr = timer_events;
|
TimerEvent* ptr = timer_events;
|
||||||
|
|
||||||
while ( ptr->proc && ptr->proc != proc ) {
|
while ( ptr->proc && ptr->proc != proc ) {
|
||||||
|
@ -100,7 +106,8 @@ static void start_timer_proc( void ( *proc )( void ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stop_timer_proc( void ( *proc )( void ) ) {
|
static void stop_timer_proc( void ( *proc )( void ) )
|
||||||
|
{
|
||||||
TimerEvent* ptr = timer_events;
|
TimerEvent* ptr = timer_events;
|
||||||
|
|
||||||
while ( ptr->proc && ptr->proc != proc ) {
|
while ( ptr->proc && ptr->proc != proc ) {
|
||||||
|
@ -114,7 +121,8 @@ static void stop_timer_proc( void ( *proc )( void ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void emulator_set_state( int state ) {
|
void emulator_set_state( int state )
|
||||||
|
{
|
||||||
printf( "emulator_set_state\n" );
|
printf( "emulator_set_state\n" );
|
||||||
#ifdef TRUE_TIMER2
|
#ifdef TRUE_TIMER2
|
||||||
if ( state != EMULATOR_STOP ) {
|
if ( state != EMULATOR_STOP ) {
|
||||||
|
@ -129,7 +137,8 @@ void emulator_set_state( int state ) {
|
||||||
|
|
||||||
int emulator_get_state( void ) { return emulator_state; }
|
int emulator_get_state( void ) { return emulator_state; }
|
||||||
|
|
||||||
void emulator_init( void ) {
|
void emulator_init( void )
|
||||||
|
{
|
||||||
static boolean locked = FALSE;
|
static boolean locked = FALSE;
|
||||||
|
|
||||||
bus_init();
|
bus_init();
|
||||||
|
@ -142,12 +151,14 @@ void emulator_init( void ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void emulator_exit( void ) {
|
void emulator_exit( void )
|
||||||
|
{
|
||||||
display_exit();
|
display_exit();
|
||||||
bus_exit();
|
bus_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean emulator_run( void ) {
|
boolean emulator_run( void )
|
||||||
|
{
|
||||||
CycleEvent* cep;
|
CycleEvent* cep;
|
||||||
TimerEvent* tep;
|
TimerEvent* tep;
|
||||||
dword delta;
|
dword delta;
|
||||||
|
|
86
src/gui.c
86
src/gui.c
|
@ -37,16 +37,12 @@
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_image.h>
|
#include <SDL2/SDL_image.h>
|
||||||
#ifdef SDL_TTF
|
|
||||||
#include <SDL2/SDL_ttf.h>
|
#include <SDL2/SDL_ttf.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
extern SDL_Renderer* renderer;
|
extern SDL_Renderer* renderer;
|
||||||
extern SDL_Texture* faceplateTexture;
|
extern SDL_Texture* faceplateTexture;
|
||||||
#ifdef SDL_TTF
|
|
||||||
extern TTF_Font* ttffont;
|
extern TTF_Font* ttffont;
|
||||||
extern TTF_Font* ttffont2;
|
extern TTF_Font* ttffont2;
|
||||||
#endif
|
|
||||||
|
|
||||||
SDL_Surface* surfA[ 49 ];
|
SDL_Surface* surfA[ 49 ];
|
||||||
SDL_Texture* textA[ 49 ];
|
SDL_Texture* textA[ 49 ];
|
||||||
|
@ -86,7 +82,8 @@ pabout_up },
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
void drawText( int index, int x, int y, int btn_w, int btn_h ) {
|
void drawText( int index, int x, int y, int btn_w, int btn_h )
|
||||||
|
{
|
||||||
SDL_Surface* letterSurface = surfA[ index ];
|
SDL_Surface* letterSurface = surfA[ index ];
|
||||||
SDL_Texture* letterTexture = textA[ index ];
|
SDL_Texture* letterTexture = textA[ index ];
|
||||||
if ( letterSurface != NULL && letterTexture != NULL ) {
|
if ( letterSurface != NULL && letterTexture != NULL ) {
|
||||||
|
@ -130,28 +127,25 @@ void drawText( int index, int x, int y, int btn_w, int btn_h ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_initKeyboard( Button* calcbuttons ) {
|
void gui_initKeyboard( Button* calcbuttons )
|
||||||
|
{
|
||||||
printf( "init texts\n" );
|
printf( "init texts\n" );
|
||||||
#ifdef SDL_TTF
|
|
||||||
if ( ttffont == NULL ) {
|
if ( ttffont == NULL ) {
|
||||||
printf( "init texts error Font NULL\n" );
|
printf( "init texts error Font NULL\n" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
SDL_Color couleurBlanche = { 255, 255, 255, 255 };
|
||||||
SDL_Color couleurBlanche = { 255, 255, 255 };
|
SDL_Color couleurGreen = { 125, 215, 235, 255 };
|
||||||
SDL_Color couleurGreen = { 125, 215, 235 };
|
SDL_Color couleurPurple = { 191, 192, 236, 255 };
|
||||||
SDL_Color couleurPurple = { 191, 192, 236 };
|
SDL_Color couleurYellow = { 128, 108, 29, 255 };
|
||||||
SDL_Color couleurYellow = { 128, 108, 29 };
|
|
||||||
|
|
||||||
#ifdef SDL_TTF
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Button* buttons = calcbuttons;
|
Button* buttons = calcbuttons;
|
||||||
while ( buttons->text ) {
|
while ( buttons->text ) {
|
||||||
SDL_Surface* s = NULL;
|
SDL_Surface* s = NULL;
|
||||||
SDL_Texture* t = NULL;
|
SDL_Texture* t = NULL;
|
||||||
if ( buttons->text && strcmp( buttons->text, "" ) != 0 ) {
|
if ( buttons->text && strcmp( buttons->text, "" ) != 0 ) {
|
||||||
s = TTF_RenderUTF8_Blended( ttffont, buttons->text,
|
s = TTF_RenderUTF8_Blended( ttffont, buttons->text, couleurBlanche );
|
||||||
couleurBlanche );
|
|
||||||
if ( s ) {
|
if ( s ) {
|
||||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||||
}
|
}
|
||||||
|
@ -170,8 +164,7 @@ void gui_initKeyboard( Button* calcbuttons ) {
|
||||||
SDL_Surface* s = NULL;
|
SDL_Surface* s = NULL;
|
||||||
SDL_Texture* t = NULL;
|
SDL_Texture* t = NULL;
|
||||||
if ( buttons->textB && strcmp( buttons->textB, "" ) != 0 ) {
|
if ( buttons->textB && strcmp( buttons->textB, "" ) != 0 ) {
|
||||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textB,
|
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textB, couleurPurple );
|
||||||
couleurPurple );
|
|
||||||
if ( s ) {
|
if ( s ) {
|
||||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||||
}
|
}
|
||||||
|
@ -188,8 +181,7 @@ void gui_initKeyboard( Button* calcbuttons ) {
|
||||||
SDL_Surface* s = NULL;
|
SDL_Surface* s = NULL;
|
||||||
SDL_Texture* t = NULL;
|
SDL_Texture* t = NULL;
|
||||||
if ( buttons->textC && strcmp( buttons->textC, "" ) != 0 ) {
|
if ( buttons->textC && strcmp( buttons->textC, "" ) != 0 ) {
|
||||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textC,
|
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textC, couleurGreen );
|
||||||
couleurGreen );
|
|
||||||
if ( s ) {
|
if ( s ) {
|
||||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||||
}
|
}
|
||||||
|
@ -206,8 +198,7 @@ void gui_initKeyboard( Button* calcbuttons ) {
|
||||||
SDL_Surface* s = NULL;
|
SDL_Surface* s = NULL;
|
||||||
SDL_Texture* t = NULL;
|
SDL_Texture* t = NULL;
|
||||||
if ( buttons->textD && strcmp( buttons->textD, "" ) != 0 ) {
|
if ( buttons->textD && strcmp( buttons->textD, "" ) != 0 ) {
|
||||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textD,
|
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textD, couleurYellow );
|
||||||
couleurYellow );
|
|
||||||
if ( s ) {
|
if ( s ) {
|
||||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||||
}
|
}
|
||||||
|
@ -217,13 +208,12 @@ void gui_initKeyboard( Button* calcbuttons ) {
|
||||||
i++;
|
i++;
|
||||||
buttons++;
|
buttons++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_init( void ) {}
|
void gui_init( void ) {}
|
||||||
|
|
||||||
void gui_exit( void ) {
|
void gui_exit( void )
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for ( i = 0; i < PANEL_COUNT; i++ ) {
|
for ( i = 0; i < PANEL_COUNT; i++ ) {
|
||||||
|
@ -231,12 +221,12 @@ void gui_exit( void ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline int panel_at( int x, int y ) {
|
static __inline int panel_at( int x, int y )
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for ( i = PANEL_COUNT; i >= 0; i-- ) {
|
for ( i = PANEL_COUNT; i >= 0; i-- ) {
|
||||||
if ( panels[ i ].flags & PANEL_FLAG_VISIBLE && x >= panels[ i ].x &&
|
if ( panels[ i ].flags & PANEL_FLAG_VISIBLE && x >= panels[ i ].x && x < panels[ i ].x + panels[ i ].w && y >= panels[ i ].y &&
|
||||||
x < panels[ i ].x + panels[ i ].w && y >= panels[ i ].y &&
|
|
||||||
y < panels[ i ].y + panels[ i ].h ) {
|
y < panels[ i ].y + panels[ i ].h ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +234,8 @@ static __inline int panel_at( int x, int y ) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_update( void ) {
|
void gui_update( void )
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
static int down_panel = -1;
|
static int down_panel = -1;
|
||||||
static int down_mb = 0;
|
static int down_mb = 0;
|
||||||
|
@ -275,7 +266,8 @@ panels[down_panel].y, down_mb); down_mb = 0; down_panel = -1;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_show_panel( int i ) {
|
void gui_show_panel( int i )
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
if (!(panels[i].flags & PANEL_FLAG_VISIBLE)) {
|
if (!(panels[i].flags & PANEL_FLAG_VISIBLE)) {
|
||||||
panels[i].flags |= PANEL_FLAG_VISIBLE;
|
panels[i].flags |= PANEL_FLAG_VISIBLE;
|
||||||
|
@ -287,7 +279,8 @@ color[C_PANEL_BORDER]); panels[i].show(panels[i].bmp); unscare_mouse();
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_hide_panel( int i ) {
|
void gui_hide_panel( int i )
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
if (panels[i].flags & PANEL_FLAG_VISIBLE) {
|
if (panels[i].flags & PANEL_FLAG_VISIBLE) {
|
||||||
panels[i].flags &= ~PANEL_FLAG_VISIBLE;
|
panels[i].flags &= ~PANEL_FLAG_VISIBLE;
|
||||||
|
@ -297,7 +290,8 @@ if (panels[i].flags & PANEL_FLAG_VISIBLE) {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void button_draw( Button* b ) {
|
void button_draw( Button* b )
|
||||||
|
{
|
||||||
SDL_Rect rectToDraw = { b->x * 2, b->y * 2, b->w * 2, b->h * 2 };
|
SDL_Rect rectToDraw = { b->x * 2, b->y * 2, b->w * 2, b->h * 2 };
|
||||||
|
|
||||||
SDL_SetRenderDrawColor( renderer, 0x00, 0x00, 0x00, 0x33 );
|
SDL_SetRenderDrawColor( renderer, 0x00, 0x00, 0x00, 0x33 );
|
||||||
|
@ -305,9 +299,8 @@ void button_draw( Button* b ) {
|
||||||
|
|
||||||
drawText( b->index, b->x * 2, 10 + b->y * 2, b->w * 2, b->h * 2 );
|
drawText( b->index, b->x * 2, 10 + b->y * 2, b->w * 2, b->h * 2 );
|
||||||
|
|
||||||
int c;
|
/* int c = color[ ( b->flags & BUTTON_PUSHED ) ? C_BUTTON_PUSHED :
|
||||||
|
* C_BUTTON_BACK ]; */
|
||||||
c = color[ ( b->flags & BUTTON_PUSHED ) ? C_BUTTON_PUSHED : C_BUTTON_BACK ];
|
|
||||||
|
|
||||||
if ( b->flags & BUTTON_PUSHED ) {
|
if ( b->flags & BUTTON_PUSHED ) {
|
||||||
SDL_SetRenderDrawColor( renderer, 0xFF, 0x00, 0x00, 0xFF );
|
SDL_SetRenderDrawColor( renderer, 0xFF, 0x00, 0x00, 0xFF );
|
||||||
|
@ -333,18 +326,19 @@ textout_centre(bmp, font, b->text, b->x+b->w/2, b->y+(b->h-text_height
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void button_draw_all( Button* buttons ) {
|
void button_draw_all( Button* buttons )
|
||||||
|
{
|
||||||
while ( buttons->text ) {
|
while ( buttons->text ) {
|
||||||
button_draw( buttons );
|
button_draw( buttons );
|
||||||
buttons++;
|
buttons++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline Button* find_button( Button* b, int x, int y ) {
|
static __inline Button* find_button( Button* b, int x, int y )
|
||||||
|
{
|
||||||
while ( b->text ) {
|
while ( b->text ) {
|
||||||
// if (x >= b->x && x < b->x+b->w && y >= b->y && y < b->y+b->h) {
|
// if (x >= b->x && x < b->x+b->w && y >= b->y && y < b->y+b->h) {
|
||||||
if ( x >= b->x * 2 && x < b->x * 2 + b->w * 2 && y >= b->y * 2 &&
|
if ( x >= b->x * 2 && x < b->x * 2 + b->w * 2 && y >= b->y * 2 && y < b->y * 2 + b->h * 2 ) {
|
||||||
y < b->y * 2 + b->h * 2 ) {
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
b++;
|
b++;
|
||||||
|
@ -352,7 +346,8 @@ static __inline Button* find_button( Button* b, int x, int y ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int button_mouse_down( Button* buttons, int mx, int my, int mb ) {
|
int button_mouse_down( Button* buttons, int mx, int my, int mb )
|
||||||
|
{
|
||||||
Button* b = find_button( buttons, mx, my );
|
Button* b = find_button( buttons, mx, my );
|
||||||
if ( !b ) {
|
if ( !b ) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -360,8 +355,7 @@ int button_mouse_down( Button* buttons, int mx, int my, int mb ) {
|
||||||
printf( "Press %s\n", b->text );
|
printf( "Press %s\n", b->text );
|
||||||
|
|
||||||
if ( !( b->flags & BUTTON_DISABLED ) ) {
|
if ( !( b->flags & BUTTON_DISABLED ) ) {
|
||||||
if ( ( mb == 2 && ( b->flags & BUTTON_B2TOGGLE ) ) ||
|
if ( ( mb == 2 && ( b->flags & BUTTON_B2TOGGLE ) ) || ( mb == 1 && ( b->flags & BUTTON_B1TOGGLE ) ) ) {
|
||||||
( mb == 1 && ( b->flags & BUTTON_B1TOGGLE ) ) ) {
|
|
||||||
|
|
||||||
if ( b->flags & BUTTON_PUSHED ) {
|
if ( b->flags & BUTTON_PUSHED ) {
|
||||||
b->flags &= ~BUTTON_PUSHED;
|
b->flags &= ~BUTTON_PUSHED;
|
||||||
|
@ -384,8 +378,8 @@ int button_mouse_down( Button* buttons, int mx, int my, int mb ) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my,
|
int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my, int mb )
|
||||||
int mb ) {
|
{
|
||||||
Button* b = find_button( buttons, mx, my );
|
Button* b = find_button( buttons, mx, my );
|
||||||
int ret = ( b != NULL );
|
int ret = ( b != NULL );
|
||||||
if ( b ) {
|
if ( b ) {
|
||||||
|
@ -393,8 +387,7 @@ int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( b && !( b->flags & BUTTON_DISABLED ) ) {
|
if ( b && !( b->flags & BUTTON_DISABLED ) ) {
|
||||||
if ( mb == 1 && ( b->flags & BUTTON_PUSHED ) &&
|
if ( mb == 1 && ( b->flags & BUTTON_PUSHED ) && !( b->flags & BUTTON_B1TOGGLE ) ) {
|
||||||
!( b->flags & BUTTON_B1TOGGLE ) ) {
|
|
||||||
b->flags &= ~BUTTON_PUSHED;
|
b->flags &= ~BUTTON_PUSHED;
|
||||||
// button_draw(bmp, b);
|
// button_draw(bmp, b);
|
||||||
if ( b->up )
|
if ( b->up )
|
||||||
|
@ -403,8 +396,7 @@ int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my,
|
||||||
}
|
}
|
||||||
if ( mb == 1 ) {
|
if ( mb == 1 ) {
|
||||||
for ( b = buttons; b->text; b++ ) {
|
for ( b = buttons; b->text; b++ ) {
|
||||||
if ( ( b->flags & ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) ==
|
if ( ( b->flags & ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) == ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) {
|
||||||
( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) {
|
|
||||||
b->flags &= ~BUTTON_PUSHED;
|
b->flags &= ~BUTTON_PUSHED;
|
||||||
// button_draw(bmp, b);
|
// button_draw(bmp, b);
|
||||||
if ( b->up )
|
if ( b->up )
|
||||||
|
|
24
src/gui.h
24
src/gui.h
|
@ -28,19 +28,11 @@
|
||||||
#ifndef __GUI_H
|
#ifndef __GUI_H
|
||||||
#define __GUI_H
|
#define __GUI_H
|
||||||
|
|
||||||
/* #define SDL_TTF */
|
|
||||||
#define FONT_FILENAME "/usr/share/fonts/TTF/unifont.ttf"
|
#define FONT_FILENAME "/usr/share/fonts/TTF/unifont.ttf"
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
enum Panels {
|
enum Panels { PANEL_MENU, PANEL_CALC, PANEL_DEBUG, PANEL_FILES, PANEL_ABOUT, PANEL_COUNT };
|
||||||
PANEL_MENU,
|
|
||||||
PANEL_CALC,
|
|
||||||
PANEL_DEBUG,
|
|
||||||
PANEL_FILES,
|
|
||||||
PANEL_ABOUT,
|
|
||||||
PANEL_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int index;
|
int index;
|
||||||
|
@ -60,12 +52,11 @@ typedef struct {
|
||||||
* Use BUTTON_B1RELEASE | BUTTON_B2TOGGLE for calculator buttons.
|
* Use BUTTON_B1RELEASE | BUTTON_B2TOGGLE for calculator buttons.
|
||||||
* Use BUTTON_B1TOGGLE for toggle buttons
|
* Use BUTTON_B1TOGGLE for toggle buttons
|
||||||
*/
|
*/
|
||||||
#define BUTTON_PUSHED 0x01 // Set if button is pushed
|
#define BUTTON_PUSHED 0x01 // Set if button is pushed
|
||||||
#define BUTTON_DISABLED 0x02 // If set the button will be grayed out
|
#define BUTTON_DISABLED 0x02 // If set the button will be grayed out
|
||||||
#define BUTTON_B1TOGGLE 0x04 // Mouse button 1 toggles this button
|
#define BUTTON_B1TOGGLE 0x04 // Mouse button 1 toggles this button
|
||||||
#define BUTTON_B2TOGGLE 0x08 // Mouse button 2 toggles this button
|
#define BUTTON_B2TOGGLE 0x08 // Mouse button 2 toggles this button
|
||||||
#define BUTTON_B1RELEASE \
|
#define BUTTON_B1RELEASE 0x10 // Releaseing mouse button 1 anywhere unpushes the button
|
||||||
0x10 // Releaseing mouse button 1 anywhere unpushes the button
|
|
||||||
|
|
||||||
void gui_initKeyboard( Button* calcbuttons );
|
void gui_initKeyboard( Button* calcbuttons );
|
||||||
void gui_init( void );
|
void gui_init( void );
|
||||||
|
@ -78,8 +69,7 @@ void gui_hide_panel( int i );
|
||||||
void button_draw(BITMAP *bmp, Button *buttons);
|
void button_draw(BITMAP *bmp, Button *buttons);
|
||||||
*/
|
*/
|
||||||
void button_draw_all( /*BITMAP *bmp,*/ Button* buttons );
|
void button_draw_all( /*BITMAP *bmp,*/ Button* buttons );
|
||||||
int button_mouse_down( /*BITMAP *bmp,*/ Button* butons, int mx, int my,
|
int button_mouse_down( /*BITMAP *bmp,*/ Button* butons, int mx, int my, int mb );
|
||||||
int mb );
|
|
||||||
int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my, int mb );
|
int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my, int mb );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,7 +38,8 @@ void hdw_init( void ) {}
|
||||||
|
|
||||||
void hdw_exit( void ) {}
|
void hdw_exit( void ) {}
|
||||||
|
|
||||||
byte hdw_read_nibble( address adr ) {
|
byte hdw_read_nibble( address adr )
|
||||||
|
{
|
||||||
switch ( adr ) {
|
switch ( adr ) {
|
||||||
|
|
||||||
case 0x00:
|
case 0x00:
|
||||||
|
@ -59,8 +60,7 @@ byte hdw_read_nibble( address adr ) {
|
||||||
case 0x28:
|
case 0x28:
|
||||||
return display_line_count & 0xF;
|
return display_line_count & 0xF;
|
||||||
case 0x29:
|
case 0x29:
|
||||||
return ( display_line_count >> 4 ) | ( hdw_ram[ 0x29 ] & 0x4 ) |
|
return ( display_line_count >> 4 ) | ( hdw_ram[ 0x29 ] & 0x4 ) | ( bus_info.da19 ? 0x8 : 0x0 );
|
||||||
( bus_info.da19 ? 0x8 : 0x0 );
|
|
||||||
|
|
||||||
case 0x2E:
|
case 0x2E:
|
||||||
return timer1_control;
|
return timer1_control;
|
||||||
|
@ -91,7 +91,8 @@ byte hdw_read_nibble( address adr ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hdw_write_nibble( byte data, address adr ) {
|
void hdw_write_nibble( byte data, address adr )
|
||||||
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
|
|
||||||
switch ( adr ) {
|
switch ( adr ) {
|
||||||
|
|
|
@ -33,7 +33,8 @@ boolean kbd_on;
|
||||||
|
|
||||||
static byte kbd_row[ 9 ];
|
static byte kbd_row[ 9 ];
|
||||||
|
|
||||||
static void update_in( void ) {
|
static void update_in( void )
|
||||||
|
{
|
||||||
byte in = 0;
|
byte in = 0;
|
||||||
|
|
||||||
// TODO: Emulate real HP48 keyboard circuit
|
// TODO: Emulate real HP48 keyboard circuit
|
||||||
|
@ -65,16 +66,15 @@ static void update_in( void ) {
|
||||||
|
|
||||||
void kbd_out_changed( void ) { update_in(); }
|
void kbd_out_changed( void ) { update_in(); }
|
||||||
|
|
||||||
void kbd_key_pressed( int row, int col ) {
|
void kbd_key_pressed( int row, int col )
|
||||||
|
{
|
||||||
boolean no_key = !cpu.in[ 0 ] && !cpu.in[ 1 ] && !cpu.in[ 3 ];
|
boolean no_key = !cpu.in[ 0 ] && !cpu.in[ 1 ] && !cpu.in[ 3 ];
|
||||||
kbd_row[ row ] |= 1 << col;
|
kbd_row[ row ] |= 1 << col;
|
||||||
update_in();
|
update_in();
|
||||||
if ( cpu.shutdown && no_key &&
|
if ( cpu.shutdown && no_key && ( cpu.in[ 0 ] || cpu.in[ 1 ] || cpu.in[ 3 ] ) ) {
|
||||||
( cpu.in[ 0 ] || cpu.in[ 1 ] || cpu.in[ 3 ] ) ) {
|
|
||||||
cpu.shutdown = FALSE;
|
cpu.shutdown = FALSE;
|
||||||
}
|
}
|
||||||
if ( cpu.keyscan && no_key &&
|
if ( cpu.keyscan && no_key && ( cpu.in[ 0 ] || cpu.in[ 1 ] || cpu.in[ 3 ] ) ) {
|
||||||
( cpu.in[ 0 ] || cpu.in[ 1 ] || cpu.in[ 3 ] ) ) {
|
|
||||||
if ( cpu.inte ) {
|
if ( cpu.inte ) {
|
||||||
cpu.keyintp = FALSE;
|
cpu.keyintp = FALSE;
|
||||||
cpu_interrupt();
|
cpu_interrupt();
|
||||||
|
@ -86,7 +86,8 @@ void kbd_key_pressed( int row, int col ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kbd_key_released( int row, int col ) {
|
void kbd_key_released( int row, int col )
|
||||||
|
{
|
||||||
kbd_row[ row ] &= ~( 1 << col );
|
kbd_row[ row ] &= ~( 1 << col );
|
||||||
update_in();
|
update_in();
|
||||||
if ( !cpu.in[ 0 ] && !cpu.in[ 1 ] && !cpu.in[ 3 ] ) {
|
if ( !cpu.in[ 0 ] && !cpu.in[ 1 ] && !cpu.in[ 3 ] ) {
|
||||||
|
@ -94,7 +95,8 @@ void kbd_key_released( int row, int col ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kbd_on_pressed( void ) {
|
void kbd_on_pressed( void )
|
||||||
|
{
|
||||||
boolean no_key = !cpu.in[ 3 ];
|
boolean no_key = !cpu.in[ 3 ];
|
||||||
kbd_on = TRUE;
|
kbd_on = TRUE;
|
||||||
cpu.in[ 3 ] |= 8;
|
cpu.in[ 3 ] |= 8;
|
||||||
|
@ -106,7 +108,8 @@ void kbd_on_pressed( void ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kbd_on_released( void ) {
|
void kbd_on_released( void )
|
||||||
|
{
|
||||||
kbd_on = FALSE;
|
kbd_on = FALSE;
|
||||||
cpu.in[ 3 ] &= ~8;
|
cpu.in[ 3 ] &= ~8;
|
||||||
}
|
}
|
||||||
|
|
908
src/main.c
908
src/main.c
File diff suppressed because it is too large
Load diff
552
src/opcodes.c
552
src/opcodes.c
|
@ -37,16 +37,11 @@
|
||||||
static int fs[ 16 ] = { 0, 0, 2, 0, 15, 3, 0, 0, 0, 0, 2, 0, 15, 3, 0, 0 };
|
static int fs[ 16 ] = { 0, 0, 2, 0, 15, 3, 0, 0, 0, 0, 2, 0, 15, 3, 0, 0 };
|
||||||
static int fl[ 16 ] = { 1, 1, 1, 3, 1, 12, 2, 16, 1, 1, 1, 3, 1, 12, 2, 16 };
|
static int fl[ 16 ] = { 1, 1, 1, 3, 1, 12, 2, 16, 1, 1, 1, 3, 1, 12, 2, 16 };
|
||||||
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||||
static const int regr[ 16 ] = { A, B, C, D, B, C, A, C,
|
static const int regr[ 16 ] = { A, B, C, D, B, C, A, C, A, B, C, D, B, C, A, C };
|
||||||
A, B, C, D, B, C, A, C };
|
static const int regs[ 16 ] = { B, C, A, C, A, B, C, D, B, C, A, C, A, B, C, D };
|
||||||
static const int regs[ 16 ] = { B, C, A, C, A, B, C, D,
|
static const int regt[ 16 ] = { A, B, C, D, A, B, C, D, B, C, A, C, A, B, C, D };
|
||||||
B, C, A, C, A, B, C, D };
|
static const int regu[ 16 ] = { A, B, C, D, B, C, A, C, B, C, A, C, A, B, C, D };
|
||||||
static const int regt[ 16 ] = { A, B, C, D, A, B, C, D,
|
static const int regv[ 16 ] = { B, C, A, C, A, B, C, D, A, B, C, D, B, C, A, C };
|
||||||
B, C, A, C, A, B, C, D };
|
|
||||||
static const int regu[ 16 ] = { A, B, C, D, B, C, A, C,
|
|
||||||
B, C, A, C, A, B, C, D };
|
|
||||||
static const int regv[ 16 ] = { B, C, A, C, A, B, C, D,
|
|
||||||
A, B, C, D, B, C, A, C };
|
|
||||||
|
|
||||||
#define REGr( i ) ( cpu.reg[ regr[ i ] ] )
|
#define REGr( i ) ( cpu.reg[ regr[ i ] ] )
|
||||||
#define REGs( i ) ( cpu.reg[ regs[ i ] ] )
|
#define REGs( i ) ( cpu.reg[ regs[ i ] ] )
|
||||||
|
@ -59,7 +54,8 @@ static const int regv[ 16 ] = { B, C, A, C, A, B, C, D,
|
||||||
#define REGuF( i, f ) ( REGu( i ) + fs[ f ] )
|
#define REGuF( i, f ) ( REGu( i ) + fs[ f ] )
|
||||||
#define REGvF( i, f ) ( REGv( i ) + fs[ f ] )
|
#define REGvF( i, f ) ( REGv( i ) + fs[ f ] )
|
||||||
|
|
||||||
static __inline void update_fields( void ) {
|
static __inline void update_fields( void )
|
||||||
|
{
|
||||||
fs[ 0 ] = fs[ 8 ] = cpu.p;
|
fs[ 0 ] = fs[ 8 ] = cpu.p;
|
||||||
fl[ 1 ] = fl[ 9 ] = cpu.p + 1;
|
fl[ 1 ] = fl[ 9 ] = cpu.p + 1;
|
||||||
}
|
}
|
||||||
|
@ -165,8 +161,7 @@ static void op0E( byte* opc ) // r=r&s f/A / r=r!s f/A
|
||||||
{
|
{
|
||||||
int len = ( opc[ 2 ] == 0xF ) ? 5 : fl[ opc[ 2 ] ];
|
int len = ( opc[ 2 ] == 0xF ) ? 5 : fl[ opc[ 2 ] ];
|
||||||
if ( !( opc[ 3 ] & 8 ) ) {
|
if ( !( opc[ 3 ] & 8 ) ) {
|
||||||
alu_and( REGrF( opc[ 3 ], opc[ 2 ] ), REGsF( opc[ 3 ], opc[ 2 ] ),
|
alu_and( REGrF( opc[ 3 ], opc[ 2 ] ), REGsF( opc[ 3 ], opc[ 2 ] ), len );
|
||||||
len );
|
|
||||||
} else {
|
} else {
|
||||||
alu_or( REGrF( opc[ 3 ], opc[ 2 ] ), REGsF( opc[ 3 ], opc[ 2 ] ), len );
|
alu_or( REGrF( opc[ 3 ], opc[ 2 ] ), REGsF( opc[ 3 ], opc[ 2 ] ), len );
|
||||||
}
|
}
|
||||||
|
@ -213,8 +208,7 @@ static void op12( byte* opc ) // rRiEX
|
||||||
static void op13a( byte* opc ) // Di=r / rDiEX
|
static void op13a( byte* opc ) // Di=r / rDiEX
|
||||||
{
|
{
|
||||||
address tmp = cpu.d[ opc[ 2 ] & 1 ];
|
address tmp = cpu.d[ opc[ 2 ] & 1 ];
|
||||||
cpu.d[ opc[ 2 ] & 1 ] =
|
cpu.d[ opc[ 2 ] & 1 ] = nib_to_unsigned( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], 5 );
|
||||||
nib_to_unsigned( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], 5 );
|
|
||||||
if ( opc[ 2 ] & 2 )
|
if ( opc[ 2 ] & 2 )
|
||||||
unsigned_to_nib( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], tmp, 5 );
|
unsigned_to_nib( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], tmp, 5 );
|
||||||
cpu.pc += 3;
|
cpu.pc += 3;
|
||||||
|
@ -225,8 +219,7 @@ static void op13b( byte* opc ) // Di=rS / rDiEXS
|
||||||
{
|
{
|
||||||
address tmp = cpu.d[ opc[ 2 ] & 1 ];
|
address tmp = cpu.d[ opc[ 2 ] & 1 ];
|
||||||
cpu.d[ opc[ 2 ] & 1 ] &= 0xF0000;
|
cpu.d[ opc[ 2 ] & 1 ] &= 0xF0000;
|
||||||
cpu.d[ opc[ 2 ] & 1 ] |=
|
cpu.d[ opc[ 2 ] & 1 ] |= nib_to_unsigned( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], 4 );
|
||||||
nib_to_unsigned( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], 4 );
|
|
||||||
if ( opc[ 2 ] & 2 )
|
if ( opc[ 2 ] & 2 )
|
||||||
unsigned_to_nib( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], tmp, 4 );
|
unsigned_to_nib( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], tmp, 4 );
|
||||||
cpu.pc += 3;
|
cpu.pc += 3;
|
||||||
|
@ -236,11 +229,9 @@ static void op13b( byte* opc ) // Di=rS / rDiEXS
|
||||||
static void op14( byte* opc ) // DATi=r A/B / r=DATi A/B
|
static void op14( byte* opc ) // DATi=r A/B / r=DATi A/B
|
||||||
{
|
{
|
||||||
if ( !( opc[ 2 ] & 2 ) ) {
|
if ( !( opc[ 2 ] & 2 ) ) {
|
||||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ],
|
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ], ( opc[ 2 ] & 8 ) ? 2 : 5 );
|
||||||
( opc[ 2 ] & 8 ) ? 2 : 5 );
|
|
||||||
} else {
|
} else {
|
||||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ],
|
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ], ( opc[ 2 ] & 8 ) ? 2 : 5 );
|
||||||
( opc[ 2 ] & 8 ) ? 2 : 5 );
|
|
||||||
cpu.cycles++;
|
cpu.cycles++;
|
||||||
}
|
}
|
||||||
cpu.pc += 3;
|
cpu.pc += 3;
|
||||||
|
@ -250,11 +241,9 @@ static void op14( byte* opc ) // DATi=r A/B / r=DATi A/B
|
||||||
static void op15a( byte* opc ) // DATi=r f / r=DATi f
|
static void op15a( byte* opc ) // DATi=r f / r=DATi f
|
||||||
{
|
{
|
||||||
if ( !( opc[ 2 ] & 2 ) ) {
|
if ( !( opc[ 2 ] & 2 ) ) {
|
||||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ] + fs[ opc[ 3 ] ],
|
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ] + fs[ opc[ 3 ] ], cpu.d[ opc[ 2 ] & 1 ], fl[ opc[ 3 ] ] );
|
||||||
cpu.d[ opc[ 2 ] & 1 ], fl[ opc[ 3 ] ] );
|
|
||||||
} else {
|
} else {
|
||||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ] + fs[ opc[ 3 ] ],
|
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ] + fs[ opc[ 3 ] ], cpu.d[ opc[ 2 ] & 1 ], fl[ opc[ 3 ] ] );
|
||||||
cpu.d[ opc[ 2 ] & 1 ], fl[ opc[ 3 ] ] );
|
|
||||||
cpu.cycles++;
|
cpu.cycles++;
|
||||||
}
|
}
|
||||||
cpu.pc += 4;
|
cpu.pc += 4;
|
||||||
|
@ -264,11 +253,9 @@ static void op15a( byte* opc ) // DATi=r f / r=DATi f
|
||||||
static void op15b( byte* opc ) // DATi=r n / r=DATi n
|
static void op15b( byte* opc ) // DATi=r n / r=DATi n
|
||||||
{
|
{
|
||||||
if ( !( opc[ 2 ] & 2 ) ) {
|
if ( !( opc[ 2 ] & 2 ) ) {
|
||||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ],
|
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ], opc[ 3 ] + 1 );
|
||||||
opc[ 3 ] + 1 );
|
|
||||||
} else {
|
} else {
|
||||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ],
|
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ], opc[ 3 ] + 1 );
|
||||||
opc[ 3 ] + 1 );
|
|
||||||
cpu.cycles++;
|
cpu.cycles++;
|
||||||
}
|
}
|
||||||
cpu.pc += 4;
|
cpu.pc += 4;
|
||||||
|
@ -527,9 +514,7 @@ static void op814_7( byte* opc ) // rSRC
|
||||||
|
|
||||||
static void op818( byte* opc ) // r=r+CON f/A / r=r-CON f/A
|
static void op818( byte* opc ) // r=r+CON f/A / r=r-CON f/A
|
||||||
{
|
{
|
||||||
int len = ( opc[ 3 ] == 0xF )
|
int len = ( opc[ 3 ] == 0xF ) ? 5 : ( ( fl[ opc[ 3 ] ] == 1 ) ? 17 : fl[ opc[ 3 ] ] );
|
||||||
? 5
|
|
||||||
: ( ( fl[ opc[ 3 ] ] == 1 ) ? 17 : fl[ opc[ 3 ] ] );
|
|
||||||
// Note: What happens if opc[4]&4
|
// Note: What happens if opc[4]&4
|
||||||
if ( !( opc[ 4 ] & 8 ) ) {
|
if ( !( opc[ 4 ] & 8 ) ) {
|
||||||
alu_add_con( cpu.reg[ opc[ 4 ] & 3 ], opc[ 5 ], fs[ opc[ 3 ] ], len );
|
alu_add_con( cpu.reg[ opc[ 4 ] & 3 ], opc[ 5 ], fs[ opc[ 3 ] ], len );
|
||||||
|
@ -552,8 +537,7 @@ static void op81Af0( byte* opc ) // Ri=r f/A
|
||||||
{
|
{
|
||||||
int i = ( opc[ 5 ] & 7 ) > 4 ? opc[ 5 ] & 3 : opc[ 5 ] & 7;
|
int i = ( opc[ 5 ] & 7 ) > 4 ? opc[ 5 ] & 3 : opc[ 5 ] & 7;
|
||||||
int len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
int len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
||||||
reg_cpy( cpu.reg_r[ i ] + fs[ opc[ 3 ] ],
|
reg_cpy( cpu.reg_r[ i ] + fs[ opc[ 3 ] ], cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ], len );
|
||||||
cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ], len );
|
|
||||||
cpu.pc += 6;
|
cpu.pc += 6;
|
||||||
cpu.cycles += 6 + len;
|
cpu.cycles += 6 + len;
|
||||||
}
|
}
|
||||||
|
@ -562,8 +546,7 @@ static void op81Af1( byte* opc ) // r=Ri f/A
|
||||||
{
|
{
|
||||||
int i = ( opc[ 5 ] & 7 ) > 4 ? opc[ 5 ] & 3 : opc[ 5 ] & 7;
|
int i = ( opc[ 5 ] & 7 ) > 4 ? opc[ 5 ] & 3 : opc[ 5 ] & 7;
|
||||||
int len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
int len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
||||||
reg_cpy( cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ],
|
reg_cpy( cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ], cpu.reg_r[ i ] + fs[ opc[ 3 ] ], len );
|
||||||
cpu.reg_r[ i ] + fs[ opc[ 3 ] ], len );
|
|
||||||
cpu.pc += 6;
|
cpu.pc += 6;
|
||||||
cpu.cycles += 6 + len;
|
cpu.cycles += 6 + len;
|
||||||
}
|
}
|
||||||
|
@ -572,8 +555,7 @@ static void op81Af2( byte* opc ) // rRiEX f/A
|
||||||
{
|
{
|
||||||
int i = ( opc[ 5 ] & 7 ) > 4 ? opc[ 5 ] & 3 : opc[ 5 ] & 7;
|
int i = ( opc[ 5 ] & 7 ) > 4 ? opc[ 5 ] & 3 : opc[ 5 ] & 7;
|
||||||
int len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
int len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
||||||
reg_ex( cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ],
|
reg_ex( cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ], cpu.reg_r[ i ] + fs[ opc[ 3 ] ], len );
|
||||||
cpu.reg_r[ i ] + fs[ opc[ 3 ] ], len );
|
|
||||||
cpu.pc += 6;
|
cpu.pc += 6;
|
||||||
cpu.cycles += 6 + len;
|
cpu.cycles += 6 + len;
|
||||||
}
|
}
|
||||||
|
@ -686,8 +668,7 @@ static void op8F( byte* opc ) // GOSBVL
|
||||||
static void op9a( byte* opc ) // ?u=v f / ?u#v f / ?u=0 f / ?u#0 f
|
static void op9a( byte* opc ) // ?u=v f / ?u#v f / ?u=0 f / ?u#0 f
|
||||||
{
|
{
|
||||||
if ( !( opc[ 2 ] & 8 ) ) {
|
if ( !( opc[ 2 ] & 8 ) ) {
|
||||||
comp_eq( REGuF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
comp_eq( REGuF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
fl[ opc[ 1 ] ] );
|
|
||||||
} else {
|
} else {
|
||||||
comp_zero( cpu.reg[ opc[ 2 ] & 3 ] + fs[ opc[ 1 ] ], fl[ opc[ 1 ] ] );
|
comp_zero( cpu.reg[ opc[ 2 ] & 3 ] + fs[ opc[ 1 ] ], fl[ opc[ 1 ] ] );
|
||||||
}
|
}
|
||||||
|
@ -699,8 +680,7 @@ static void op9a( byte* opc ) // ?u=v f / ?u#v f / ?u=0 f / ?u#0 f
|
||||||
|
|
||||||
static void op9b( byte* opc ) // ?u>v f / u<v f / u>=v f / u<=v f
|
static void op9b( byte* opc ) // ?u>v f / u<v f / u>=v f / u<=v f
|
||||||
{
|
{
|
||||||
comp_gt( REGuF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
comp_gt( REGuF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
fl[ opc[ 1 ] ] );
|
|
||||||
if ( opc[ 2 ] & 8 )
|
if ( opc[ 2 ] & 8 )
|
||||||
cpu.carry = !cpu.carry;
|
cpu.carry = !cpu.carry;
|
||||||
goyes( opc, 3 );
|
goyes( opc, 3 );
|
||||||
|
@ -713,8 +693,7 @@ static void opAa( byte* opc ) // t=t+v f / t=t-1 f
|
||||||
case 0x0:
|
case 0x0:
|
||||||
case 0x4:
|
case 0x4:
|
||||||
case 0x8:
|
case 0x8:
|
||||||
alu_add( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
alu_add( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
fl[ opc[ 1 ] ] );
|
|
||||||
break;
|
break;
|
||||||
case 0xC:
|
case 0xC:
|
||||||
alu_dec( REGtF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
alu_dec( REGtF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
|
@ -732,12 +711,10 @@ static void opAb( byte* opc ) // t=0 f / t=r f / trEX f
|
||||||
break;
|
break;
|
||||||
case 0x4:
|
case 0x4:
|
||||||
case 0x8:
|
case 0x8:
|
||||||
reg_cpy( REGtF( opc[ 2 ], opc[ 1 ] ), REGrF( opc[ 2 ], opc[ 1 ] ),
|
reg_cpy( REGtF( opc[ 2 ], opc[ 1 ] ), REGrF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
fl[ opc[ 1 ] ] );
|
|
||||||
break;
|
break;
|
||||||
case 0xC:
|
case 0xC:
|
||||||
reg_ex( REGtF( opc[ 2 ], opc[ 1 ] ), REGrF( opc[ 2 ], opc[ 1 ] ),
|
reg_ex( REGtF( opc[ 2 ], opc[ 1 ] ), REGrF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
fl[ opc[ 1 ] ] );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cpu.pc += 3;
|
cpu.pc += 3;
|
||||||
|
@ -749,15 +726,13 @@ static void opBa( byte* opc ) // t=t-v f / t=t+1 f / t=v-t f
|
||||||
switch ( opc[ 2 ] & 0xC ) {
|
switch ( opc[ 2 ] & 0xC ) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
case 0x8:
|
case 0x8:
|
||||||
alu_sub( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
alu_sub( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
fl[ opc[ 1 ] ] );
|
|
||||||
break;
|
break;
|
||||||
case 0x4:
|
case 0x4:
|
||||||
alu_inc( REGtF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
alu_inc( REGtF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
break;
|
break;
|
||||||
case 0xC:
|
case 0xC:
|
||||||
alu_sub2( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
alu_sub2( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||||
fl[ opc[ 1 ] ] );
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cpu.pc += 3;
|
cpu.pc += 3;
|
||||||
|
@ -872,220 +847,325 @@ static void opFC_F( byte* opc ) // r=-r-1 A
|
||||||
cpu.cycles += 7;
|
cpu.cycles += 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Opcode opcodes0[ 16 ] = { { op00, NULL, "RTNSXM" },
|
static Opcode opcodes0[ 16 ] = {
|
||||||
{ op01, NULL, "RTN" },
|
{op00, NULL, "RTNSXM" },
|
||||||
{ op02_3, NULL, "RTNSC" },
|
{ op01, NULL, "RTN" },
|
||||||
{ op02_3, NULL, "RTNCC" },
|
{ op02_3, NULL, "RTNSC" },
|
||||||
{ op04_5, NULL, "SETHEX" },
|
{ op02_3, NULL, "RTNCC" },
|
||||||
{ op04_5, NULL, "SETDEC" },
|
{ op04_5, NULL, "SETHEX" },
|
||||||
{ op06, NULL, "RSTK=C" },
|
{ op04_5, NULL, "SETDEC" },
|
||||||
{ op07, NULL, "C=RSTK" },
|
{ op06, NULL, "RSTK=C" },
|
||||||
{ op08, NULL, "CLRST" },
|
{ op07, NULL, "C=RSTK" },
|
||||||
{ op09, NULL, "C=ST" },
|
{ op08, NULL, "CLRST" },
|
||||||
{ op0A, NULL, "ST=C" },
|
{ op09, NULL, "C=ST" },
|
||||||
{ op0B, NULL, "CSTEX" },
|
{ op0A, NULL, "ST=C" },
|
||||||
{ op0C, NULL, "P=P+1" },
|
{ op0B, NULL, "CSTEX" },
|
||||||
{ op0D, NULL, "P=P-1" },
|
{ op0C, NULL, "P=P+1" },
|
||||||
{ op0E, NULL, "%r3=%r3%&3%s3 %F2A" },
|
{ op0D, NULL, "P=P-1" },
|
||||||
{ op0F, NULL, "RTI" } };
|
{ op0E, NULL, "%r3=%r3%&3%s3 %F2A"},
|
||||||
|
{ op0F, NULL, "RTI" }
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes13[ 16 ] = {
|
static Opcode opcodes13[ 16 ] = {
|
||||||
{ op13a, NULL, "D0=A" }, { op13a, NULL, "D1=A" },
|
{op13a, NULL, "D0=A" },
|
||||||
{ op13a, NULL, "AD0EX" }, { op13a, NULL, "AD1EX" },
|
{ op13a, NULL, "D1=A" },
|
||||||
{ op13a, NULL, "D0=C" }, { op13a, NULL, "D1=C" },
|
{ op13a, NULL, "AD0EX" },
|
||||||
{ op13a, NULL, "CD0EX" }, { op13a, NULL, "CD1EX" },
|
{ op13a, NULL, "AD1EX" },
|
||||||
{ op13b, NULL, "D0=AS" }, { op13b, NULL, "D1=AS" },
|
{ op13a, NULL, "D0=C" },
|
||||||
{ op13b, NULL, "AD0EXS" }, { op13b, NULL, "AD1EXS" },
|
{ op13a, NULL, "D1=C" },
|
||||||
{ op13b, NULL, "D0=CS" }, { op13b, NULL, "D1=CS" },
|
{ op13a, NULL, "CD0EX" },
|
||||||
{ op13b, NULL, "CD0EXS" }, { op13b, NULL, "CD1EXS" } };
|
{ op13a, NULL, "CD1EX" },
|
||||||
|
{ op13b, NULL, "D0=AS" },
|
||||||
|
{ op13b, NULL, "D1=AS" },
|
||||||
|
{ op13b, NULL, "AD0EXS"},
|
||||||
|
{ op13b, NULL, "AD1EXS"},
|
||||||
|
{ op13b, NULL, "D0=CS" },
|
||||||
|
{ op13b, NULL, "D1=CS" },
|
||||||
|
{ op13b, NULL, "CD0EXS"},
|
||||||
|
{ op13b, NULL, "CD1EXS"}
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes15[ 16 ] = {
|
static Opcode opcodes15[ 16 ] = {
|
||||||
{ op15a, NULL, "%D2 %F3" }, { op15a, NULL, "%D2 %F3" },
|
{op15a, NULL, "%D2 %F3" },
|
||||||
{ op15a, NULL, "%D2 %F3" }, { op15a, NULL, "%D2 %F3" },
|
{ op15a, NULL, "%D2 %F3" },
|
||||||
{ op15a, NULL, "%D2 %F3" }, { op15a, NULL, "%D2 %F3" },
|
{ op15a, NULL, "%D2 %F3" },
|
||||||
{ op15a, NULL, "%D2 %F3" }, { op15a, NULL, "%D2 %F3" },
|
{ op15a, NULL, "%D2 %F3" },
|
||||||
{ op15b, NULL, "%D2 %I3+1" }, { op15b, NULL, "%D2 %I3+1" },
|
{ op15a, NULL, "%D2 %F3" },
|
||||||
{ op15b, NULL, "%D2 %I3+1" }, { op15b, NULL, "%D2 %I3+1" },
|
{ op15a, NULL, "%D2 %F3" },
|
||||||
{ op15b, NULL, "%D2 %I3+1" }, { op15b, NULL, "%D2 %I3+1" },
|
{ op15a, NULL, "%D2 %F3" },
|
||||||
{ op15b, NULL, "%D2 %I3+1" }, { op15b, NULL, "%D2 %I3+1" } };
|
{ op15a, NULL, "%D2 %F3" },
|
||||||
|
{ op15b, NULL, "%D2 %I3+1"},
|
||||||
|
{ op15b, NULL, "%D2 %I3+1"},
|
||||||
|
{ op15b, NULL, "%D2 %I3+1"},
|
||||||
|
{ op15b, NULL, "%D2 %I3+1"},
|
||||||
|
{ op15b, NULL, "%D2 %I3+1"},
|
||||||
|
{ op15b, NULL, "%D2 %I3+1"},
|
||||||
|
{ op15b, NULL, "%D2 %I3+1"},
|
||||||
|
{ op15b, NULL, "%D2 %I3+1"}
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes1[ 16 ] = {
|
static Opcode opcodes1[ 16 ] = {
|
||||||
{ op10, NULL, "R%i2=%a2" }, { op11, NULL, "%a2=R%i2" },
|
{op10, NULL, "R%i2=%a2" },
|
||||||
{ op12, NULL, "%a2R%i2EX" }, { NULL, opcodes13, NULL },
|
{ op11, NULL, "%a2=R%i2" },
|
||||||
{ op14, NULL, "%D2 %B2" }, { NULL, opcodes15, NULL },
|
{ op12, NULL, "%a2R%i2EX" },
|
||||||
{ op16_7, NULL, "D0=D0+ %I2+1" }, { op16_7, NULL, "D1=D1+ %I2+1" },
|
{ NULL, opcodes13, NULL },
|
||||||
{ op18_C, NULL, "D0=D0- %I2+1" }, { op19_D, NULL, "D0=(2) %X22" },
|
{ op14, NULL, "%D2 %B2" },
|
||||||
{ op1A_E, NULL, "D0=(4) %X24" }, { op1B_F, NULL, "D0=(5) %X25" },
|
{ NULL, opcodes15, NULL },
|
||||||
{ op18_C, NULL, "D1=D1- %I2+1" }, { op19_D, NULL, "D1=(2) %X22" },
|
{ op16_7, NULL, "D0=D0+ %I2+1"},
|
||||||
{ op1A_E, NULL, "D1=(4) %X24" }, { op1B_F, NULL, "D1=(5) %X25" },
|
{ op16_7, NULL, "D1=D1+ %I2+1"},
|
||||||
|
{ op18_C, NULL, "D0=D0- %I2+1"},
|
||||||
|
{ op19_D, NULL, "D0=(2) %X22" },
|
||||||
|
{ op1A_E, NULL, "D0=(4) %X24" },
|
||||||
|
{ op1B_F, NULL, "D0=(5) %X25" },
|
||||||
|
{ op18_C, NULL, "D1=D1- %I2+1"},
|
||||||
|
{ op19_D, NULL, "D1=(2) %X22" },
|
||||||
|
{ op1A_E, NULL, "D1=(4) %X24" },
|
||||||
|
{ op1B_F, NULL, "D1=(5) %X25" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static Opcode opcodes808[ 16 ] = {
|
static Opcode opcodes808[ 16 ] = {
|
||||||
{ op8080, NULL, "INTON" },
|
{op8080, NULL, "INTON" },
|
||||||
{ op8081, NULL, "RSI" },
|
{ op8081, NULL, "RSI" },
|
||||||
{ op8082, NULL, "LA #%N4" },
|
{ op8082, NULL, "LA #%N4" },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ op8084_5_8_9, NULL, "ABIT=0 %I4" },
|
{ op8084_5_8_9, NULL, "ABIT=0 %I4" },
|
||||||
{ op8084_5_8_9, NULL, "ABIT=1 %I4" },
|
{ op8084_5_8_9, NULL, "ABIT=1 %I4" },
|
||||||
{ op8086_7_A_B, NULL, "?ABIT=0 %I4, %G52YES %T52+5" },
|
{ op8086_7_A_B, NULL, "?ABIT=0 %I4, %G52YES %T52+5"},
|
||||||
{ op8086_7_A_B, NULL, "?ABIT=1 %I4, %G52YES %T52+5" },
|
{ op8086_7_A_B, NULL, "?ABIT=1 %I4, %G52YES %T52+5"},
|
||||||
{ op8084_5_8_9, NULL, "CBIT=0 %I4" },
|
{ op8084_5_8_9, NULL, "CBIT=0 %I4" },
|
||||||
{ op8084_5_8_9, NULL, "CBIT=1 %I4" },
|
{ op8084_5_8_9, NULL, "CBIT=1 %I4" },
|
||||||
{ op8086_7_A_B, NULL, "?CBIT=0 %I4, %G52YES %T52+5" },
|
{ op8086_7_A_B, NULL, "?CBIT=0 %I4, %G52YES %T52+5"},
|
||||||
{ op8086_7_A_B, NULL, "?CBIT=1 %I4, %G52YES %T52+5" },
|
{ op8086_7_A_B, NULL, "?CBIT=1 %I4, %G52YES %T52+5"},
|
||||||
{ op808C_E, NULL, "PC=(A)" },
|
{ op808C_E, NULL, "PC=(A)" },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ op808C_E, NULL, "PC=(C)" },
|
{ op808C_E, NULL, "PC=(C)" },
|
||||||
{ op808F, NULL, "INTOFF" } };
|
{ op808F, NULL, "INTOFF" }
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes80[ 16 ] = {
|
static Opcode opcodes80[ 16 ] = {
|
||||||
{ op800_1, NULL, "OUT=CS" }, { op800_1, NULL, "OUT=C" },
|
{op800_1, NULL, "OUT=CS" },
|
||||||
{ op802_3, NULL, "A=IN" }, { op802_3, NULL, "C=IN" },
|
{ op800_1, NULL, "OUT=C" },
|
||||||
{ op804, NULL, "UNCONFIG" }, { op805, NULL, "CONFIG" },
|
{ op802_3, NULL, "A=IN" },
|
||||||
{ op806, NULL, "C=ID" }, { op807, NULL, "SHUTDN" },
|
{ op802_3, NULL, "C=IN" },
|
||||||
{ NULL, opcodes808, NULL }, { op809, NULL, "C+P+1" },
|
{ op804, NULL, "UNCONFIG"},
|
||||||
{ op80A, NULL, "RESET" }, { NULL, NULL, NULL },
|
{ op805, NULL, "CONFIG" },
|
||||||
{ op80C, NULL, "C=P %I3" }, { op80D, NULL, "P=C %I3" },
|
{ op806, NULL, "C=ID" },
|
||||||
{ NULL, NULL, NULL }, { op80F, NULL, "CPEX %I3" } };
|
{ op807, NULL, "SHUTDN" },
|
||||||
|
{ NULL, opcodes808, NULL },
|
||||||
|
{ op809, NULL, "C+P+1" },
|
||||||
|
{ op80A, NULL, "RESET" },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ op80C, NULL, "C=P %I3" },
|
||||||
|
{ op80D, NULL, "P=C %I3" },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ op80F, NULL, "CPEX %I3"}
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes81Af[ 16 ] = { { op81Af0, NULL, "R%i5=%a5 %F3A" },
|
static Opcode opcodes81Af[ 16 ] = {
|
||||||
{ op81Af1, NULL, "%a5=R%i5 %F3A" },
|
{op81Af0, NULL, "R%i5=%a5 %F3A" },
|
||||||
{ op81Af2, NULL, "%a5R%i5EX %F3A" },
|
{ op81Af1, NULL, "%a5=R%i5 %F3A" },
|
||||||
{ NULL, NULL, NULL },
|
{ op81Af2, NULL, "%a5R%i5EX %F3A"},
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL } };
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes81A[ 16 ] = {
|
static Opcode opcodes81A[ 16 ] = {
|
||||||
{ NULL, opcodes81Af, NULL }, { NULL, opcodes81Af, NULL },
|
{NULL, opcodes81Af, NULL},
|
||||||
{ NULL, opcodes81Af, NULL }, { NULL, opcodes81Af, NULL },
|
{ NULL, opcodes81Af, NULL},
|
||||||
{ NULL, opcodes81Af, NULL }, { NULL, opcodes81Af, NULL },
|
{ NULL, opcodes81Af, NULL},
|
||||||
{ NULL, opcodes81Af, NULL }, { NULL, opcodes81Af, NULL },
|
{ NULL, opcodes81Af, NULL},
|
||||||
{ NULL, opcodes81Af, NULL }, { NULL, opcodes81Af, NULL },
|
{ NULL, opcodes81Af, NULL},
|
||||||
{ NULL, opcodes81Af, NULL }, { NULL, opcodes81Af, NULL },
|
{ NULL, opcodes81Af, NULL},
|
||||||
{ NULL, opcodes81Af, NULL }, { NULL, opcodes81Af, NULL },
|
{ NULL, opcodes81Af, NULL},
|
||||||
{ NULL, opcodes81Af, NULL }, { NULL, opcodes81Af, NULL } };
|
{ NULL, opcodes81Af, NULL},
|
||||||
|
{ NULL, opcodes81Af, NULL},
|
||||||
|
{ NULL, opcodes81Af, NULL},
|
||||||
|
{ NULL, opcodes81Af, NULL},
|
||||||
|
{ NULL, opcodes81Af, NULL},
|
||||||
|
{ NULL, opcodes81Af, NULL},
|
||||||
|
{ NULL, opcodes81Af, NULL},
|
||||||
|
{ NULL, opcodes81Af, NULL},
|
||||||
|
{ NULL, opcodes81Af, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes81B[ 16 ] = {
|
static Opcode opcodes81B[ 16 ] = {
|
||||||
{ NULL, NULL, NULL }, { NULL, NULL, NULL },
|
{NULL, NULL, NULL },
|
||||||
{ op81B2_3, NULL, "PC=A" }, { op81B2_3, NULL, "PC=C" },
|
{ NULL, NULL, NULL },
|
||||||
{ op81B4_5, NULL, "A=PC" }, { op81B4_5, NULL, "C=PC" },
|
{ op81B2_3, NULL, "PC=A"},
|
||||||
{ NULL, NULL, NULL }, { NULL, NULL, NULL },
|
{ op81B2_3, NULL, "PC=C"},
|
||||||
{ NULL, NULL, NULL }, { NULL, NULL, NULL },
|
{ op81B4_5, NULL, "A=PC"},
|
||||||
{ NULL, NULL, NULL }, { NULL, NULL, NULL },
|
{ op81B4_5, NULL, "C=PC"},
|
||||||
{ NULL, NULL, NULL }, { NULL, NULL, NULL },
|
{ NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL }, { NULL, NULL, NULL } };
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL },
|
||||||
|
{ NULL, NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes81[ 16 ] = { { op810_3, NULL, "ASLC" },
|
static Opcode opcodes81[ 16 ] = {
|
||||||
{ op810_3, NULL, "BSLC" },
|
{op810_3, NULL, "ASLC" },
|
||||||
{ op810_3, NULL, "CSLC" },
|
{ op810_3, NULL, "BSLC" },
|
||||||
{ op810_3, NULL, "DSLC" },
|
{ op810_3, NULL, "CSLC" },
|
||||||
{ op814_7, NULL, "ASRC" },
|
{ op810_3, NULL, "DSLC" },
|
||||||
{ op814_7, NULL, "BSRC" },
|
{ op814_7, NULL, "ASRC" },
|
||||||
{ op814_7, NULL, "CSRC" },
|
{ op814_7, NULL, "BSRC" },
|
||||||
{ op814_7, NULL, "DSRC" },
|
{ op814_7, NULL, "CSRC" },
|
||||||
{ op818, NULL, "%u4=%u4%~4CON %F3A, %I6+1" },
|
{ op814_7, NULL, "DSRC" },
|
||||||
{ op819, NULL, "%u4SRB %F3A" },
|
{ op818, NULL, "%u4=%u4%~4CON %F3A, %I6+1"},
|
||||||
{ NULL, opcodes81A, NULL },
|
{ op819, NULL, "%u4SRB %F3A" },
|
||||||
{ NULL, opcodes81B, NULL },
|
{ NULL, opcodes81A, NULL },
|
||||||
{ op81C_F, NULL, "ASRB" },
|
{ NULL, opcodes81B, NULL },
|
||||||
{ op81C_F, NULL, "BSRB" },
|
{ op81C_F, NULL, "ASRB" },
|
||||||
{ op81C_F, NULL, "CSRB" },
|
{ op81C_F, NULL, "BSRB" },
|
||||||
{ op81C_F, NULL, "DSRB" } };
|
{ op81C_F, NULL, "CSRB" },
|
||||||
|
{ op81C_F, NULL, "DSRB" }
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodes8[ 16 ] = {
|
static Opcode opcodes8[ 16 ] = {
|
||||||
{ NULL, opcodes80, NULL },
|
{NULL, opcodes80, NULL },
|
||||||
{ NULL, opcodes81, NULL },
|
{ NULL, opcodes81, NULL },
|
||||||
{ op82, NULL, "HST=0 #%X21" },
|
{ op82, NULL, "HST=0 #%X21" },
|
||||||
{ op83, NULL, "?HST=0 #%X21, %G32YES %T32+3" },
|
{ op83, NULL, "?HST=0 #%X21, %G32YES %T32+3"},
|
||||||
{ op84_5, NULL, "ST=0 %I2" },
|
{ op84_5, NULL, "ST=0 %I2" },
|
||||||
{ op84_5, NULL, "ST=1 %I2" },
|
{ op84_5, NULL, "ST=1 %I2" },
|
||||||
{ op86_7, NULL, "?ST=0 %I2, %G32YES %T32+3" },
|
{ op86_7, NULL, "?ST=0 %I2, %G32YES %T32+3" },
|
||||||
{ op86_7, NULL, "?ST=1 %I2, %G32YES %T32+3" },
|
{ op86_7, NULL, "?ST=1 %I2, %G32YES %T32+3" },
|
||||||
{ op88_9, NULL, "?P# %I2, %G32YES %T32+3" },
|
{ op88_9, NULL, "?P# %I2, %G32YES %T32+3" },
|
||||||
{ op88_9, NULL, "?P= %I2, %G32YES %T32+3" },
|
{ op88_9, NULL, "?P= %I2, %G32YES %T32+3" },
|
||||||
{ op8A, NULL, "?%u2%#2%z2 A, %G32YES %T32+3" },
|
{ op8A, NULL, "?%u2%#2%z2 A, %G32YES %T32+3"},
|
||||||
{ op8B, NULL, "?%u2%>2%v2 A, %G32YES %T32+3" },
|
{ op8B, NULL, "?%u2%>2%v2 A, %G32YES %T32+3"},
|
||||||
{ op8C, NULL, "GOLONG %R24+2" },
|
{ op8C, NULL, "GOLONG %R24+2" },
|
||||||
{ op8D, NULL, "GOVLNG %X25" },
|
{ op8D, NULL, "GOVLNG %X25" },
|
||||||
{ op8E, NULL, "GOSUBL %R24+6" },
|
{ op8E, NULL, "GOSUBL %R24+6" },
|
||||||
{ op8F, NULL, "GOSBVL %X25" },
|
{ op8F, NULL, "GOSBVL %X25" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static Opcode opcodes9[ 16 ] = {
|
static Opcode opcodes9[ 16 ] = {
|
||||||
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3" },
|
{op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3"},
|
||||||
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3" },
|
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3"},
|
||||||
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3" },
|
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3"},
|
||||||
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3" },
|
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3"},
|
||||||
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3" },
|
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3"},
|
||||||
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3" },
|
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3"},
|
||||||
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3" },
|
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3"},
|
||||||
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3" },
|
{ op9a, NULL, "?%u2%#2%z2 %F1, %G32YES %T32+3"},
|
||||||
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3" },
|
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3"},
|
||||||
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3" },
|
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3"},
|
||||||
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3" },
|
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3"},
|
||||||
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3" },
|
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3"},
|
||||||
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3" },
|
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3"},
|
||||||
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3" },
|
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3"},
|
||||||
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3" },
|
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3"},
|
||||||
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3" } };
|
{ op9b, NULL, "?%u2%>2%v2 %F1, %G32YES %T32+3"}
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodesA[ 16 ] = {
|
static Opcode opcodesA[ 16 ] = {
|
||||||
{ opAa, NULL, "%t2=%t2%+2%w2 %F1" }, { opAa, NULL, "%t2=%t2%+2%w2 %F1" },
|
{opAa, NULL, "%t2=%t2%+2%w2 %F1"},
|
||||||
{ opAa, NULL, "%t2=%t2%+2%w2 %F1" }, { opAa, NULL, "%t2=%t2%+2%w2 %F1" },
|
{ opAa, NULL, "%t2=%t2%+2%w2 %F1"},
|
||||||
{ opAa, NULL, "%t2=%t2%+2%w2 %F1" }, { opAa, NULL, "%t2=%t2%+2%w2 %F1" },
|
{ opAa, NULL, "%t2=%t2%+2%w2 %F1"},
|
||||||
{ opAa, NULL, "%t2=%t2%+2%w2 %F1" }, { opAa, NULL, "%t2=%t2%+2%w2 %F1" },
|
{ opAa, NULL, "%t2=%t2%+2%w2 %F1"},
|
||||||
{ opAb, NULL, "%x2%=2%y2%E2 %F1" }, { opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
{ opAa, NULL, "%t2=%t2%+2%w2 %F1"},
|
||||||
{ opAb, NULL, "%x2%=2%y2%E2 %F1" }, { opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
{ opAa, NULL, "%t2=%t2%+2%w2 %F1"},
|
||||||
{ opAb, NULL, "%x2%=2%y2%E2 %F1" }, { opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
{ opAa, NULL, "%t2=%t2%+2%w2 %F1"},
|
||||||
{ opAb, NULL, "%x2%=2%y2%E2 %F1" }, { opAb, NULL, "%x2%=2%y2%E2 %F1" } };
|
{ opAa, NULL, "%t2=%t2%+2%w2 %F1"},
|
||||||
|
{ opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
||||||
|
{ opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
||||||
|
{ opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
||||||
|
{ opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
||||||
|
{ opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
||||||
|
{ opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
||||||
|
{ opAb, NULL, "%x2%=2%y2%E2 %F1" },
|
||||||
|
{ opAb, NULL, "%x2%=2%y2%E2 %F1" }
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodesBb[ 16 ] = {
|
static Opcode opcodesBb[ 16 ] = {
|
||||||
{ opBb0_3, NULL, "ASL %F1" }, { opBb0_3, NULL, "BSL %F1" },
|
{opBb0_3, NULL, "ASL %F1" },
|
||||||
{ opBb0_3, NULL, "CSL %F1" }, { opBb0_3, NULL, "DSL %F1" },
|
{ opBb0_3, NULL, "BSL %F1" },
|
||||||
{ opBb4_7, NULL, "ASR %F1" }, { opBb4_7, NULL, "BSR %F1" },
|
{ opBb0_3, NULL, "CSL %F1" },
|
||||||
{ opBb4_7, NULL, "CSR %F1" }, { opBb4_7, NULL, "DSR %F1" },
|
{ opBb0_3, NULL, "DSL %F1" },
|
||||||
{ opBb8_B, NULL, "A=-A %F1" }, { opBb8_B, NULL, "B=-B %F1" },
|
{ opBb4_7, NULL, "ASR %F1" },
|
||||||
{ opBb8_B, NULL, "C=-C %F1" }, { opBb8_B, NULL, "D=-D %F1" },
|
{ opBb4_7, NULL, "BSR %F1" },
|
||||||
{ opBbC_F, NULL, "A=-A-1 %F1" }, { opBbC_F, NULL, "B=-B-1 %F1" },
|
{ opBb4_7, NULL, "CSR %F1" },
|
||||||
{ opBbC_F, NULL, "C=-C-1 %F1" }, { opBbC_F, NULL, "D=-D-1 %F1" } };
|
{ opBb4_7, NULL, "DSR %F1" },
|
||||||
|
{ opBb8_B, NULL, "A=-A %F1" },
|
||||||
|
{ opBb8_B, NULL, "B=-B %F1" },
|
||||||
|
{ opBb8_B, NULL, "C=-C %F1" },
|
||||||
|
{ opBb8_B, NULL, "D=-D %F1" },
|
||||||
|
{ opBbC_F, NULL, "A=-A-1 %F1"},
|
||||||
|
{ opBbC_F, NULL, "B=-B-1 %F1"},
|
||||||
|
{ opBbC_F, NULL, "C=-C-1 %F1"},
|
||||||
|
{ opBbC_F, NULL, "D=-D-1 %F1"}
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodesB[ 16 ] = {
|
static Opcode opcodesB[ 16 ] = {
|
||||||
{ opBa, NULL, "%t2=%p2%-2%q2 %F1" }, { opBa, NULL, "%t2=%p2%-2%q2 %F1" },
|
{opBa, NULL, "%t2=%p2%-2%q2 %F1"},
|
||||||
{ opBa, NULL, "%t2=%p2%-2%q2 %F1" }, { opBa, NULL, "%t2=%p2%-2%q2 %F1" },
|
{ opBa, NULL, "%t2=%p2%-2%q2 %F1"},
|
||||||
{ opBa, NULL, "%t2=%p2%-2%q2 %F1" }, { opBa, NULL, "%t2=%p2%-2%q2 %F1" },
|
{ opBa, NULL, "%t2=%p2%-2%q2 %F1"},
|
||||||
{ opBa, NULL, "%t2=%p2%-2%q2 %F1" }, { opBa, NULL, "%t2=%p2%-2%q2 %F1" },
|
{ opBa, NULL, "%t2=%p2%-2%q2 %F1"},
|
||||||
{ NULL, opcodesBb, NULL }, { NULL, opcodesBb, NULL },
|
{ opBa, NULL, "%t2=%p2%-2%q2 %F1"},
|
||||||
{ NULL, opcodesBb, NULL }, { NULL, opcodesBb, NULL },
|
{ opBa, NULL, "%t2=%p2%-2%q2 %F1"},
|
||||||
{ NULL, opcodesBb, NULL }, { NULL, opcodesBb, NULL },
|
{ opBa, NULL, "%t2=%p2%-2%q2 %F1"},
|
||||||
{ NULL, opcodesBb, NULL }, { NULL, opcodesBb, NULL } };
|
{ opBa, NULL, "%t2=%p2%-2%q2 %F1"},
|
||||||
|
{ NULL, opcodesBb, NULL },
|
||||||
|
{ NULL, opcodesBb, NULL },
|
||||||
|
{ NULL, opcodesBb, NULL },
|
||||||
|
{ NULL, opcodesBb, NULL },
|
||||||
|
{ NULL, opcodesBb, NULL },
|
||||||
|
{ NULL, opcodesBb, NULL },
|
||||||
|
{ NULL, opcodesBb, NULL },
|
||||||
|
{ NULL, opcodesBb, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
static Opcode opcodesF[ 16 ] = {
|
static Opcode opcodesF[ 16 ] = {
|
||||||
{ opF0_3, NULL, "ASL A" }, { opF0_3, NULL, "BSL A" },
|
{opF0_3, NULL, "ASL A" },
|
||||||
{ opF0_3, NULL, "CSL A" }, { opF0_3, NULL, "DSL A" },
|
{ opF0_3, NULL, "BSL A" },
|
||||||
{ opF4_7, NULL, "ASR A" }, { opF4_7, NULL, "BSR A" },
|
{ opF0_3, NULL, "CSL A" },
|
||||||
{ opF4_7, NULL, "CSR A" }, { opF4_7, NULL, "DSR A" },
|
{ opF0_3, NULL, "DSL A" },
|
||||||
{ opF8_B, NULL, "A=-A A" }, { opF8_B, NULL, "B=-B A" },
|
{ opF4_7, NULL, "ASR A" },
|
||||||
{ opF8_B, NULL, "C=-C A" }, { opF8_B, NULL, "D=-D A" },
|
{ opF4_7, NULL, "BSR A" },
|
||||||
{ opFC_F, NULL, "A=-A-1 A" }, { opFC_F, NULL, "B=-B-1 A" },
|
{ opF4_7, NULL, "CSR A" },
|
||||||
{ opFC_F, NULL, "C=-C-1 A" }, { opFC_F, NULL, "D=-D-1 A" },
|
{ opF4_7, NULL, "DSR A" },
|
||||||
|
{ opF8_B, NULL, "A=-A A" },
|
||||||
|
{ opF8_B, NULL, "B=-B A" },
|
||||||
|
{ opF8_B, NULL, "C=-C A" },
|
||||||
|
{ opF8_B, NULL, "D=-D A" },
|
||||||
|
{ opFC_F, NULL, "A=-A-1 A"},
|
||||||
|
{ opFC_F, NULL, "B=-B-1 A"},
|
||||||
|
{ opFC_F, NULL, "C=-C-1 A"},
|
||||||
|
{ opFC_F, NULL, "D=-D-1 A"},
|
||||||
};
|
};
|
||||||
|
|
||||||
Opcode opcodes[ 16 ] = {
|
Opcode opcodes[ 16 ] = {
|
||||||
{ NULL, opcodes0, NULL }, { NULL, opcodes1, NULL },
|
{NULL, opcodes0, NULL },
|
||||||
{ op2, NULL, "P= %I1" }, { op3, NULL, "LC #%N1" },
|
{ NULL, opcodes1, NULL },
|
||||||
{ op4, NULL, "%G12C %T12+1" }, { op5, NULL, "%G12NC %T12+1" },
|
{ op2, NULL, "P= %I1" },
|
||||||
{ op6, NULL, "GOTO %R13+1" }, { op7, NULL, "GOSUB %R13+4" },
|
{ op3, NULL, "LC #%N1" },
|
||||||
{ NULL, opcodes8, NULL }, { NULL, opcodes9, NULL },
|
{ op4, NULL, "%G12C %T12+1" },
|
||||||
{ NULL, opcodesA, NULL }, { NULL, opcodesB, NULL },
|
{ op5, NULL, "%G12NC %T12+1" },
|
||||||
{ opC, NULL, "%t1=%t1%+1%w1 A" }, { opD, NULL, "%x1%=1%y1%E1 A" },
|
{ op6, NULL, "GOTO %R13+1" },
|
||||||
{ opE, NULL, "%t1=%p1%-1%q1 A" }, { NULL, opcodesF, NULL } };
|
{ op7, NULL, "GOSUB %R13+4" },
|
||||||
|
{ NULL, opcodes8, NULL },
|
||||||
|
{ NULL, opcodes9, NULL },
|
||||||
|
{ NULL, opcodesA, NULL },
|
||||||
|
{ NULL, opcodesB, NULL },
|
||||||
|
{ opC, NULL, "%t1=%t1%+1%w1 A"},
|
||||||
|
{ opD, NULL, "%x1%=1%y1%E1 A" },
|
||||||
|
{ opE, NULL, "%t1=%p1%-1%q1 A"},
|
||||||
|
{ NULL, opcodesF, NULL }
|
||||||
|
};
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
|
|
||||||
static __inline void load( byte* reg, byte* data, int start, int len ) {
|
static __inline void load( byte* reg, byte* data, int start, int len )
|
||||||
|
{
|
||||||
if ( start + len <= 16 ) {
|
if ( start + len <= 16 ) {
|
||||||
memcpy( reg + start, data, len );
|
memcpy( reg + start, data, len );
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,7 +42,8 @@ static __inline void load( byte* reg, byte* data, int start, int len ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline unsigned int nib_to_unsigned( byte* nib, int len ) {
|
static __inline unsigned int nib_to_unsigned( byte* nib, int len )
|
||||||
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
|
@ -51,7 +53,8 @@ static __inline unsigned int nib_to_unsigned( byte* nib, int len ) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline int nib_to_signed( byte* nib, int len ) {
|
static __inline int nib_to_signed( byte* nib, int len )
|
||||||
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
len--;
|
len--;
|
||||||
|
@ -65,26 +68,30 @@ static __inline int nib_to_signed( byte* nib, int len ) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void unsigned_to_nib( byte* nib, int x, int len ) {
|
static __inline void unsigned_to_nib( byte* nib, int x, int len )
|
||||||
|
{
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
*nib++ = x & 0xF;
|
*nib++ = x & 0xF;
|
||||||
x >>= 4;
|
x >>= 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline address rstk_pop( void ) {
|
static __inline address rstk_pop( void )
|
||||||
|
{
|
||||||
address adr = cpu.rstk[ cpu.rstk_ptr ];
|
address adr = cpu.rstk[ cpu.rstk_ptr ];
|
||||||
cpu.rstk[ cpu.rstk_ptr ] = 0x00000;
|
cpu.rstk[ cpu.rstk_ptr ] = 0x00000;
|
||||||
cpu.rstk_ptr = ( cpu.rstk_ptr + 1 ) & 7;
|
cpu.rstk_ptr = ( cpu.rstk_ptr + 1 ) & 7;
|
||||||
return adr;
|
return adr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void rstk_push( address adr ) {
|
static __inline void rstk_push( address adr )
|
||||||
|
{
|
||||||
cpu.rstk_ptr = ( cpu.rstk_ptr - 1 ) & 7;
|
cpu.rstk_ptr = ( cpu.rstk_ptr - 1 ) & 7;
|
||||||
cpu.rstk[ cpu.rstk_ptr ] = adr & 0xFFFFF;
|
cpu.rstk[ cpu.rstk_ptr ] = adr & 0xFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void goyes( byte* opc, int offset ) {
|
static __inline void goyes( byte* opc, int offset )
|
||||||
|
{
|
||||||
if ( cpu.carry ) {
|
if ( cpu.carry ) {
|
||||||
address rel = nib_to_signed( opc + offset, 2 );
|
address rel = nib_to_signed( opc + offset, 2 );
|
||||||
if ( rel ) {
|
if ( rel ) {
|
||||||
|
@ -100,7 +107,8 @@ static __inline void goyes( byte* opc, int offset ) {
|
||||||
|
|
||||||
static __inline void reg_zero( byte* reg, int len ) { memset( reg, 0, len ); }
|
static __inline void reg_zero( byte* reg, int len ) { memset( reg, 0, len ); }
|
||||||
|
|
||||||
static __inline void reg_bit( byte* reg, int bit, int value ) {
|
static __inline void reg_bit( byte* reg, int bit, int value )
|
||||||
|
{
|
||||||
if ( value ) {
|
if ( value ) {
|
||||||
reg[ bit >> 2 ] |= 1 << ( bit & 3 );
|
reg[ bit >> 2 ] |= 1 << ( bit & 3 );
|
||||||
} else {
|
} else {
|
||||||
|
@ -108,11 +116,10 @@ static __inline void reg_bit( byte* reg, int bit, int value ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void reg_cpy( byte* dest, byte* src, int len ) {
|
static __inline void reg_cpy( byte* dest, byte* src, int len ) { memcpy( dest, src, len ); }
|
||||||
memcpy( dest, src, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline void reg_ex( byte* reg1, byte* reg2, int len ) {
|
static __inline void reg_ex( byte* reg1, byte* reg2, int len )
|
||||||
|
{
|
||||||
static byte tmp[ 16 ];
|
static byte tmp[ 16 ];
|
||||||
|
|
||||||
memcpy( tmp, reg1, len );
|
memcpy( tmp, reg1, len );
|
||||||
|
@ -120,11 +127,10 @@ static __inline void reg_ex( byte* reg1, byte* reg2, int len ) {
|
||||||
memcpy( reg2, tmp, len );
|
memcpy( reg2, tmp, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void comp_bit_zero( byte* reg, int bit ) {
|
static __inline void comp_bit_zero( byte* reg, int bit ) { cpu.carry = ( reg[ bit >> 2 ] & ( 1 << ( bit & 3 ) ) ) ? FALSE : TRUE; }
|
||||||
cpu.carry = ( reg[ bit >> 2 ] & ( 1 << ( bit & 3 ) ) ) ? FALSE : TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline void comp_zero( byte* reg, int len ) {
|
static __inline void comp_zero( byte* reg, int len )
|
||||||
|
{
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
if ( *reg++ ) {
|
if ( *reg++ ) {
|
||||||
cpu.carry = FALSE;
|
cpu.carry = FALSE;
|
||||||
|
@ -134,7 +140,8 @@ static __inline void comp_zero( byte* reg, int len ) {
|
||||||
cpu.carry = TRUE;
|
cpu.carry = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void comp_eq( byte* reg1, byte* reg2, int len ) {
|
static __inline void comp_eq( byte* reg1, byte* reg2, int len )
|
||||||
|
{
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
if ( *reg1++ != *reg2++ ) {
|
if ( *reg1++ != *reg2++ ) {
|
||||||
cpu.carry = FALSE;
|
cpu.carry = FALSE;
|
||||||
|
@ -144,13 +151,15 @@ static __inline void comp_eq( byte* reg1, byte* reg2, int len ) {
|
||||||
cpu.carry = TRUE;
|
cpu.carry = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void comp_gt( byte* reg1, byte* reg2, int len ) {
|
static __inline void comp_gt( byte* reg1, byte* reg2, int len )
|
||||||
|
{
|
||||||
while ( --len && reg1[ len ] == reg2[ len ] )
|
while ( --len && reg1[ len ] == reg2[ len ] )
|
||||||
;
|
;
|
||||||
cpu.carry = ( reg1[ len ] > reg2[ len ] ) ? TRUE : FALSE;
|
cpu.carry = ( reg1[ len ] > reg2[ len ] ) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_add( byte* dest, byte* src, int len ) {
|
static __inline void alu_add( byte* dest, byte* src, int len )
|
||||||
|
{
|
||||||
byte c = 0;
|
byte c = 0;
|
||||||
byte base = cpu.dec ? 10 : 16;
|
byte base = cpu.dec ? 10 : 16;
|
||||||
|
|
||||||
|
@ -170,7 +179,8 @@ static __inline void alu_add( byte* dest, byte* src, int len ) {
|
||||||
cpu.carry = c ? TRUE : FALSE;
|
cpu.carry = c ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_sub( byte* dest, byte* src, int len ) {
|
static __inline void alu_sub( byte* dest, byte* src, int len )
|
||||||
|
{
|
||||||
byte c = 0;
|
byte c = 0;
|
||||||
byte base = cpu.dec ? 10 : 16;
|
byte base = cpu.dec ? 10 : 16;
|
||||||
|
|
||||||
|
@ -188,7 +198,8 @@ static __inline void alu_sub( byte* dest, byte* src, int len ) {
|
||||||
cpu.carry = c ? TRUE : FALSE;
|
cpu.carry = c ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_sub2( byte* dest, byte* src, int len ) {
|
static __inline void alu_sub2( byte* dest, byte* src, int len )
|
||||||
|
{
|
||||||
byte c = 0;
|
byte c = 0;
|
||||||
byte base = cpu.dec ? 10 : 16;
|
byte base = cpu.dec ? 10 : 16;
|
||||||
|
|
||||||
|
@ -206,7 +217,8 @@ static __inline void alu_sub2( byte* dest, byte* src, int len ) {
|
||||||
cpu.carry = c ? TRUE : FALSE;
|
cpu.carry = c ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_add_con( byte* reg, byte con, int i, int len ) {
|
static __inline void alu_add_con( byte* reg, byte con, int i, int len )
|
||||||
|
{
|
||||||
reg[ i ] += con;
|
reg[ i ] += con;
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
reg[ i ]++;
|
reg[ i ]++;
|
||||||
|
@ -220,7 +232,8 @@ static __inline void alu_add_con( byte* reg, byte con, int i, int len ) {
|
||||||
cpu.carry = TRUE;
|
cpu.carry = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_sub_con( byte* reg, byte con, int i, int len ) {
|
static __inline void alu_sub_con( byte* reg, byte con, int i, int len )
|
||||||
|
{
|
||||||
reg[ i ] -= con;
|
reg[ i ] -= con;
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
reg[ i ]--;
|
reg[ i ]--;
|
||||||
|
@ -234,7 +247,8 @@ static __inline void alu_sub_con( byte* reg, byte con, int i, int len ) {
|
||||||
cpu.carry = TRUE;
|
cpu.carry = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_inc( byte* reg, int len ) {
|
static __inline void alu_inc( byte* reg, int len )
|
||||||
|
{
|
||||||
if ( cpu.dec ) {
|
if ( cpu.dec ) {
|
||||||
byte c = 1;
|
byte c = 1;
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
|
@ -264,7 +278,8 @@ static __inline void alu_inc( byte* reg, int len ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_dec( byte* reg, int len ) {
|
static __inline void alu_dec( byte* reg, int len )
|
||||||
|
{
|
||||||
byte base = cpu.dec ? 10 : 16;
|
byte base = cpu.dec ? 10 : 16;
|
||||||
|
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
|
@ -279,7 +294,8 @@ static __inline void alu_dec( byte* reg, int len ) {
|
||||||
cpu.carry = TRUE;
|
cpu.carry = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_neg( byte* reg, int len ) {
|
static __inline void alu_neg( byte* reg, int len )
|
||||||
|
{
|
||||||
byte base = cpu.dec ? 10 : 16;
|
byte base = cpu.dec ? 10 : 16;
|
||||||
|
|
||||||
while ( len && *reg == 0 ) {
|
while ( len && *reg == 0 ) {
|
||||||
|
@ -303,7 +319,8 @@ static __inline void alu_neg( byte* reg, int len ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_not( byte* reg, int len ) {
|
static __inline void alu_not( byte* reg, int len )
|
||||||
|
{
|
||||||
byte base = cpu.dec ? 9 : 15;
|
byte base = cpu.dec ? 9 : 15;
|
||||||
|
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
|
@ -315,26 +332,30 @@ static __inline void alu_not( byte* reg, int len ) {
|
||||||
cpu.carry = FALSE;
|
cpu.carry = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_and( byte* dest, byte* src, int len ) {
|
static __inline void alu_and( byte* dest, byte* src, int len )
|
||||||
|
{
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
*dest++ &= *src++;
|
*dest++ &= *src++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_or( byte* dest, byte* src, int len ) {
|
static __inline void alu_or( byte* dest, byte* src, int len )
|
||||||
|
{
|
||||||
while ( len-- ) {
|
while ( len-- ) {
|
||||||
*dest++ |= *src++;
|
*dest++ |= *src++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_sl( byte* reg, int len ) {
|
static __inline void alu_sl( byte* reg, int len )
|
||||||
|
{
|
||||||
while ( --len ) {
|
while ( --len ) {
|
||||||
reg[ len ] = reg[ len - 1 ];
|
reg[ len ] = reg[ len - 1 ];
|
||||||
}
|
}
|
||||||
reg[ 0 ] = 0;
|
reg[ 0 ] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_slc( byte* reg, int len ) {
|
static __inline void alu_slc( byte* reg, int len )
|
||||||
|
{
|
||||||
byte tmp = reg[ len - 1 ];
|
byte tmp = reg[ len - 1 ];
|
||||||
|
|
||||||
while ( --len ) {
|
while ( --len ) {
|
||||||
|
@ -343,7 +364,8 @@ static __inline void alu_slc( byte* reg, int len ) {
|
||||||
reg[ 0 ] = tmp;
|
reg[ 0 ] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_sr( byte* reg, int len ) {
|
static __inline void alu_sr( byte* reg, int len )
|
||||||
|
{
|
||||||
if ( reg[ 0 ] )
|
if ( reg[ 0 ] )
|
||||||
cpu.hst |= HST_SB;
|
cpu.hst |= HST_SB;
|
||||||
|
|
||||||
|
@ -354,7 +376,8 @@ static __inline void alu_sr( byte* reg, int len ) {
|
||||||
reg[ 0 ] = 0;
|
reg[ 0 ] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_src( byte* reg, int len ) {
|
static __inline void alu_src( byte* reg, int len )
|
||||||
|
{
|
||||||
byte tmp = reg[ 0 ];
|
byte tmp = reg[ 0 ];
|
||||||
|
|
||||||
while ( --len ) {
|
while ( --len ) {
|
||||||
|
@ -364,7 +387,8 @@ static __inline void alu_src( byte* reg, int len ) {
|
||||||
reg[ 0 ] = tmp;
|
reg[ 0 ] = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void alu_srb( byte* reg, int len ) {
|
static __inline void alu_srb( byte* reg, int len )
|
||||||
|
{
|
||||||
if ( *reg & 1 )
|
if ( *reg & 1 )
|
||||||
cpu.hst |= HST_SB;
|
cpu.hst |= HST_SB;
|
||||||
|
|
||||||
|
|
110
src/pabout.c
110
src/pabout.c
|
@ -33,62 +33,67 @@
|
||||||
|
|
||||||
// static BITMAP *about_bmp;
|
// static BITMAP *about_bmp;
|
||||||
|
|
||||||
static char* about_line[] = { "C / ",
|
/* static char* about_line[] = { "C / ", */
|
||||||
"C /__ ___ ___ ____ ",
|
/* "C /__ ___ ___ ____ ", */
|
||||||
"C / / / / /__/ / / / / /",
|
/* "C / / / / /__/ / / / / /", */
|
||||||
"C/ / /__/ /__ / / /__/ ",
|
/* "C/ / /__/ /__ / / /__/ ", */
|
||||||
"C / ",
|
/* "C / ", */
|
||||||
"C / version 0.9.0 ",
|
/* "C / version 0.9.0 ", */
|
||||||
"P",
|
/* "P", */
|
||||||
" Copyright 2002 Daniel Nilsson",
|
/* " Copyright 2002 Daniel Nilsson", */
|
||||||
"P",
|
/* "P", */
|
||||||
"JHpemu is free software; you can",
|
/* "JHpemu is free software; you can", */
|
||||||
"Jredistribute it and/or modify it under",
|
/* "Jredistribute it and/or modify it under", */
|
||||||
"Jthe terms of the GNU General Public",
|
/* "Jthe terms of the GNU General Public", */
|
||||||
"JLicense as published by the Free Software",
|
/* "JLicense as published by the Free Software",
|
||||||
"JFoundation; either version 2 of the",
|
*/
|
||||||
"JLicense, or (at your option) any later",
|
/* "JFoundation; either version 2 of the", */
|
||||||
"Jversion.",
|
/* "JLicense, or (at your option) any later", */
|
||||||
"P",
|
/* "Jversion.", */
|
||||||
"JHpemu is distributed in the hope that it",
|
/* "P", */
|
||||||
"Jwill be useful, but WITHOUT ANY WARRANTY;",
|
/* "JHpemu is distributed in the hope that it", */
|
||||||
"Jwithout even the implied warranty of",
|
/* "Jwill be useful, but WITHOUT ANY WARRANTY;",
|
||||||
"JMERCHANTABILITY or FITNESS FOR A",
|
*/
|
||||||
"JPARTICULAR PURPOSE. See the GNU General",
|
/* "Jwithout even the implied warranty of", */
|
||||||
"JPublic License for more details.",
|
/* "JMERCHANTABILITY or FITNESS FOR A", */
|
||||||
"P",
|
/* "JPARTICULAR PURPOSE. See the GNU General", */
|
||||||
"JYou should have received a copy of the",
|
/* "JPublic License for more details.", */
|
||||||
"JGNU General Public License along with",
|
/* "P", */
|
||||||
"Jhpemu; if not, write to the Free Software",
|
/* "JYou should have received a copy of the", */
|
||||||
"JFoundation, Inc., 59 Temple Place,",
|
/* "JGNU General Public License along with", */
|
||||||
"JSuite 330, Boston, MA 02111-1307 USA",
|
/* "Jhpemu; if not, write to the Free Software",
|
||||||
NULL };
|
*/
|
||||||
|
/* "JFoundation, Inc., 59 Temple Place,", */
|
||||||
|
/* "JSuite 330, Boston, MA 02111-1307 USA", */
|
||||||
|
/* NULL }; */
|
||||||
|
|
||||||
static void draw_about( void ) {
|
/* static void draw_about( void ) { */
|
||||||
/*
|
/* /\* */
|
||||||
int i, y;
|
/* int i, y; */
|
||||||
|
|
||||||
text_mode(color[C_PANEL_BACK]);
|
/* text_mode(color[C_PANEL_BACK]); */
|
||||||
|
|
||||||
acquire_bitmap(about_bmp);
|
/* acquire_bitmap(about_bmp); */
|
||||||
scare_mouse();
|
/* scare_mouse(); */
|
||||||
|
|
||||||
y = 10;
|
/* y = 10; */
|
||||||
for (i = 0; about_line[i]; i++) {
|
/* for (i = 0; about_line[i]; i++) { */
|
||||||
switch (about_line[i][0]) {
|
/* switch (about_line[i][0]) { */
|
||||||
case 'C':
|
/* case 'C': */
|
||||||
textout_centre(about_bmp, font, about_line[i]+1, 170, y,
|
/* textout_centre(about_bmp, font, about_line[i]+1, 170, y, */
|
||||||
color[C_PANEL_TEXT]); break; case 'J': textout_justify(about_bmp, font,
|
/* color[C_PANEL_TEXT]); break; case 'J': textout_justify(about_bmp, font,
|
||||||
about_line[i]+1, 10, 330, y, 150, color[C_PANEL_TEXT]); break; case 'P': y
|
*/
|
||||||
+= 5; break; default: textout(about_bmp, font, about_line[i]+1, 10, y,
|
/* about_line[i]+1, 10, 330, y, 150, color[C_PANEL_TEXT]); break; case 'P':
|
||||||
color[C_PANEL_TEXT]); break;
|
* y */
|
||||||
}
|
/* += 5; break; default: textout(about_bmp, font, about_line[i]+1, 10, y, */
|
||||||
y += 10;
|
/* color[C_PANEL_TEXT]); break; */
|
||||||
}
|
/* } */
|
||||||
|
/* y += 10; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
unscare_mouse();
|
/* unscare_mouse(); */
|
||||||
release_bitmap(about_bmp);*/
|
/* release_bitmap(about_bmp);*\/ */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void pabout_show(BITMAP *bmp)
|
void pabout_show(BITMAP *bmp)
|
||||||
|
@ -100,7 +105,8 @@ void pabout_show(BITMAP *bmp)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void pabout_hide( void ) {
|
void pabout_hide( void )
|
||||||
|
{
|
||||||
// about_bmp = NULL;
|
// about_bmp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
285
src/pcalc.c
285
src/pcalc.c
|
@ -151,193 +151,151 @@ const int xspacing2 = ( pow2 + 2 );
|
||||||
const int enter_w = pow1 * 2 + 2;
|
const int enter_w = pow1 * 2 + 2;
|
||||||
|
|
||||||
static KBMapping kb_sdl_mapping[] = {
|
static KBMapping kb_sdl_mapping[] = {
|
||||||
SDL_SCANCODE_KP_0, dn03, up03, SDL_SCANCODE_KP_1, dn13, up13,
|
{SDL_SCANCODE_KP_0, dn03, up03},
|
||||||
SDL_SCANCODE_KP_2, dn12, up12, SDL_SCANCODE_KP_3, dn11, up11,
|
{ SDL_SCANCODE_KP_1, dn13, up13},
|
||||||
SDL_SCANCODE_KP_4, dn23, up23, SDL_SCANCODE_KP_5, dn22, up22,
|
{ SDL_SCANCODE_KP_2, dn12, up12},
|
||||||
SDL_SCANCODE_KP_6, dn21, up21, SDL_SCANCODE_KP_7, dn33, up33,
|
{ SDL_SCANCODE_KP_3, dn11, up11},
|
||||||
SDL_SCANCODE_KP_8, dn32, up32, SDL_SCANCODE_KP_9, dn31, up31,
|
{ SDL_SCANCODE_KP_4, dn23, up23},
|
||||||
|
{ SDL_SCANCODE_KP_5, dn22, up22},
|
||||||
|
{ SDL_SCANCODE_KP_6, dn21, up21},
|
||||||
|
{ SDL_SCANCODE_KP_7, dn33, up33},
|
||||||
|
{ SDL_SCANCODE_KP_8, dn32, up32},
|
||||||
|
{ SDL_SCANCODE_KP_9, dn31, up31},
|
||||||
};
|
};
|
||||||
|
|
||||||
static Button calc_buttons[] = {
|
static Button calc_buttons[] = {
|
||||||
|
|
||||||
{ 0, pox + xstart + ( xspacing * 0 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
{ 0, pox + xstart + ( xspacing * 0 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "A",
|
||||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "A", dn14, up14 },
|
dn14, up14 },
|
||||||
{ 1, pox + xstart + ( xspacing * 1 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
{ 1, pox + xstart + ( xspacing * 1 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "B",
|
||||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "B", dn84, up84 },
|
dn84, up84 },
|
||||||
{ 2, pox + xstart + ( xspacing * 2 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
{ 2, pox + xstart + ( xspacing * 2 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "C",
|
||||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "C", dn83, up83 },
|
dn83, up83 },
|
||||||
{ 3, pox + xstart + ( xspacing * 3 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
{ 3, pox + xstart + ( xspacing * 3 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "D",
|
||||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "D", dn82, up82 },
|
dn82, up82 },
|
||||||
{ 4, pox + xstart + ( xspacing * 4 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
{ 4, pox + xstart + ( xspacing * 4 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "E",
|
||||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "E", dn81, up81 },
|
dn81, up81 },
|
||||||
{ 5, pox + xstart + ( xspacing * 5 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
{ 5, pox + xstart + ( xspacing * 5 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "F",
|
||||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "F", dn80, up80 },
|
dn80, up80 },
|
||||||
|
|
||||||
{ 6, pox + xstart + ( xspacing * 0 ), ystart + ( 1 * yspacing ) + poy + 10,
|
{ 6, pox + xstart + ( xspacing * 0 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "MTH",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "MTH", "RAD", "POLAR",
|
"RAD", "POLAR", "G", dn24, up24 },
|
||||||
"G", dn24, up24 },
|
{ 7, pox + xstart + ( xspacing * 1 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "PRG", "",
|
||||||
{ 7, pox + xstart + ( xspacing * 1 ), ystart + ( 1 * yspacing ) + poy + 10,
|
"CHARS", "H", dn74, up74 },
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "PRG", "", "CHARS", "H",
|
{ 8, pox + xstart + ( xspacing * 2 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "CST", "",
|
||||||
dn74, up74 },
|
"MODES", "I", dn73, up73 },
|
||||||
{ 8, pox + xstart + ( xspacing * 2 ), ystart + ( 1 * yspacing ) + poy + 10,
|
{ 9, pox + xstart + ( xspacing * 3 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "VAR", "",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "CST", "", "MODES", "I",
|
"MEMORY", "J", dn72, up72 },
|
||||||
dn73, up73 },
|
{ 10, pox + xstart + ( xspacing * 4 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "^", "",
|
||||||
{ 9, pox + xstart + ( xspacing * 3 ), ystart + ( 1 * yspacing ) + poy + 10,
|
"STACK", "K", dn71, up71 },
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "VAR", "", "MEMORY", "J",
|
{ 11, pox + xstart + ( xspacing * 5 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "NXT",
|
||||||
dn72, up72 },
|
"PREV", "MENU", "L", dn70, up70 },
|
||||||
{ 10, pox + xstart + ( xspacing * 4 ), ystart + ( 1 * yspacing ) + poy + 10,
|
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "^", "", "STACK", "K",
|
|
||||||
dn71, up71 },
|
|
||||||
{ 11, pox + xstart + ( xspacing * 5 ), ystart + ( 1 * yspacing ) + poy + 10,
|
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "NXT", "PREV", "MENU",
|
|
||||||
"L", dn70, up70 },
|
|
||||||
|
|
||||||
{ 12, pox + xstart + ( xspacing * 0 ), ystart + ( 2 * yspacing ) + poy + 20,
|
{ 12, pox + xstart + ( xspacing * 0 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "'", "UP",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "'", "UP", "HOME", "M",
|
"HOME", "M", dn04, up04 },
|
||||||
dn04, up04 },
|
{ 13, pox + xstart + ( xspacing * 1 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "STO",
|
||||||
{ 13, pox + xstart + ( xspacing * 1 ), ystart + ( 2 * yspacing ) + poy + 20,
|
"REF", "RCL", "N", dn64, up64 },
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "STO", "REF", "RCL", "N",
|
{ 14, pox + xstart + ( xspacing * 2 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EVAL",
|
||||||
dn64, up64 },
|
"->NUM", "UNDO", "O", dn63, up63 },
|
||||||
{ 14, pox + xstart + ( xspacing * 2 ), ystart + ( 2 * yspacing ) + poy + 20,
|
{ 15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EVAL", "->NUM", "UNDO",
|
"PICTURE", "", "P", dn62, up62 },
|
||||||
"O", dn63, up63 },
|
{ 16, pox + xstart + ( xspacing * 4 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "v",
|
||||||
{ 15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20,
|
"VIEW", "", "Q", dn61, up61 },
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<", "PICTURE", "", "P",
|
{ 17, pox + xstart + ( xspacing * 5 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ">",
|
||||||
dn62, up62 },
|
"SWAP", "", "R", dn60, up60 },
|
||||||
{ 16, pox + xstart + ( xspacing * 4 ), ystart + ( 2 * yspacing ) + poy + 20,
|
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "v", "VIEW", "", "Q",
|
|
||||||
dn61, up61 },
|
|
||||||
{ 17, pox + xstart + ( xspacing * 5 ), ystart + ( 2 * yspacing ) + poy + 20,
|
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ">", "SWAP", "", "R",
|
|
||||||
dn60, up60 },
|
|
||||||
|
|
||||||
{ 18, pox + xstart + ( xspacing * 0 ), ystart + ( 3 * yspacing ) + poy + 30,
|
{ 18, pox + xstart + ( xspacing * 0 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SIN",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SIN", "ASIN", "tet", "S",
|
"ASIN", "tet", "S", dn34, up34 },
|
||||||
dn34, up34 },
|
{ 19, pox + xstart + ( xspacing * 1 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "COS",
|
||||||
{ 19, pox + xstart + ( xspacing * 1 ), ystart + ( 3 * yspacing ) + poy + 30,
|
"ACOS", "", "T", dn54, up54 },
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "COS", "ACOS", "", "T",
|
{ 20, pox + xstart + ( xspacing * 2 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "TAN",
|
||||||
dn54, up54 },
|
"ATAN", "Sig", "U", dn53, up53 },
|
||||||
{ 20, pox + xstart + ( xspacing * 2 ), ystart + ( 3 * yspacing ) + poy + 30,
|
{ 21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SQ x",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "TAN", "ATAN", "Sig", "U",
|
"xx", "x SQ y", "V", dn52, up52 },
|
||||||
dn53, up53 },
|
{ 22, pox + xstart + ( xspacing * 4 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "yx",
|
||||||
{ 21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30,
|
"10x", "LOG", "W", dn51, up51 },
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SQ x", "xx", "x SQ y",
|
{ 23, pox + xstart + ( xspacing * 5 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1/x",
|
||||||
"V", dn52, up52 },
|
"ex", "LN", "X", dn50, up50 },
|
||||||
{ 22, pox + xstart + ( xspacing * 4 ), ystart + ( 3 * yspacing ) + poy + 30,
|
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "yx", "10x", "LOG", "W",
|
|
||||||
dn51, up51 },
|
|
||||||
{ 23, pox + xstart + ( xspacing * 5 ), ystart + ( 3 * yspacing ) + poy + 30,
|
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1/x", "ex", "LN", "X",
|
|
||||||
dn50, up50 },
|
|
||||||
|
|
||||||
{ 24, pox + xstart + ( xspacing * 0 ), ystart + ( 4 * yspacing ) + poy + 40,
|
{ 24, pox + xstart + ( xspacing * 0 ), ystart + ( 4 * yspacing ) + poy + 40, enter_w, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ENTER",
|
||||||
enter_w, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ENTER", "EQUATION",
|
"EQUATION", "MATRIX", "", dn44, up44 },
|
||||||
"MATRIX", "", dn44, up44 },
|
{ 25, enter_w - pow1 + pox + xstart + ( xspacing * 1 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||||
{ 25, enter_w - pow1 + pox + xstart + ( xspacing * 1 ),
|
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+/-", "EDIT", "CMD", "Y", dn43, up43 },
|
||||||
ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
{ 26, enter_w - pow1 + pox + xstart + ( xspacing * 2 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+/-", "EDIT", "CMD", "Y", dn43,
|
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EEX", "PURG", "ARG", "Z", dn42, up42 },
|
||||||
up43 },
|
{ 27, enter_w - pow1 + pox + xstart + ( xspacing * 3 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||||
{ 26, enter_w - pow1 + pox + xstart + ( xspacing * 2 ),
|
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "DEL", "CLEAR", "", "", dn41, up41 },
|
||||||
ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
{ 28, enter_w - pow1 + pox + xstart + ( xspacing * 4 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EEX", "PURG", "ARG", "Z", dn42,
|
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<-", "DROP", "", "", dn40, up40 },
|
||||||
up42 },
|
|
||||||
{ 27, enter_w - pow1 + pox + xstart + ( xspacing * 3 ),
|
|
||||||
ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "DEL", "CLEAR", "", "", dn41, up41 },
|
|
||||||
{ 28, enter_w - pow1 + pox + xstart + ( xspacing * 4 ),
|
|
||||||
ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<-", "DROP", "", "", dn40, up40 },
|
|
||||||
|
|
||||||
{ 29, pox + xstart + ( xspacing * 0 ), ystart + ( 5 * yspacing ) + poy + 50,
|
{ 29, pox + xstart + ( xspacing * 0 ), ystart + ( 5 * yspacing ) + poy + 50, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "alpha",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "alpha", "USER", "ENTRY",
|
"USER", "ENTRY", "", dn35, up35 },
|
||||||
"", dn35, up35 },
|
{ 30, pox + xstart + ( xspacing2 * 1 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "7", "",
|
||||||
{ 30, pox + xstart + ( xspacing2 * 1 ),
|
"SOLVE", "", dn33, up33 },
|
||||||
ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2,
|
{ 31, pox + xstart + ( xspacing2 * 2 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "8", "",
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "7", "", "SOLVE", "", dn33, up33 },
|
"PLOT", "", dn32, up32 },
|
||||||
{ 31, pox + xstart + ( xspacing2 * 2 ),
|
{ 32, pox + xstart + ( xspacing2 * 3 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "9", "",
|
||||||
ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2,
|
"SYMBOLIC", "", dn31, up31 },
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "8", "", "PLOT", "", dn32, up32 },
|
{ 33, pox + xstart + ( xspacing2 * 4 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "/",
|
||||||
{ 32, pox + xstart + ( xspacing2 * 3 ),
|
"( )", "#", "", dn30, up30 },
|
||||||
ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "9", "", "SYMBOLIC", "", dn31, up31 },
|
|
||||||
{ 33, pox + xstart + ( xspacing2 * 4 ),
|
|
||||||
ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "/", "( )", "#", "", dn30, up30 },
|
|
||||||
|
|
||||||
{ 34, pox + xstart + ( xspacing * 0 ), ystart + ( 6 * yspacing ) + poy + 60,
|
{ 34, pox + xstart + ( xspacing * 0 ), ystart + ( 6 * yspacing ) + poy + 60, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "red",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "red", "", "", dn25,
|
"", "", dn25, up25 },
|
||||||
up25 },
|
{ 35, pox + xstart + ( xspacing2 * 1 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "4", "",
|
||||||
{ 35, pox + xstart + ( xspacing2 * 1 ),
|
"TIME", "", dn23, up23 },
|
||||||
ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2,
|
{ 36, pox + xstart + ( xspacing2 * 2 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "5", "",
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "4", "", "TIME", "", dn23, up23 },
|
"STAT", "", dn22, up22 },
|
||||||
{ 36, pox + xstart + ( xspacing2 * 2 ),
|
{ 37, pox + xstart + ( xspacing2 * 3 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "6", "",
|
||||||
ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2,
|
"UNITS", "", dn21, up21 },
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "5", "", "STAT", "", dn22, up22 },
|
{ 38, pox + xstart + ( xspacing2 * 4 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "X",
|
||||||
{ 37, pox + xstart + ( xspacing2 * 3 ),
|
"[ ]", "_", "", dn20, up20 },
|
||||||
ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "6", "", "UNITS", "", dn21, up21 },
|
|
||||||
{ 38, pox + xstart + ( xspacing2 * 4 ),
|
|
||||||
ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "X", "[ ]", "_", "", dn20, up20 },
|
|
||||||
|
|
||||||
{ 39, pox + xstart + ( xspacing * 0 ), ystart + ( 7 * yspacing ) + poy + 70,
|
{ 39, pox + xstart + ( xspacing * 0 ), ystart + ( 7 * yspacing ) + poy + 70, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "green", "", dn15,
|
"green", "", dn15, up15 },
|
||||||
up15 },
|
{ 40, pox + xstart + ( xspacing2 * 1 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1", "",
|
||||||
{ 40, pox + xstart + ( xspacing2 * 1 ),
|
"I/O", "", dn13, up13 },
|
||||||
ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2,
|
{ 41, pox + xstart + ( xspacing2 * 2 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "2", "",
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1", "", "I/O", "", dn13, up13 },
|
"LIBRARY", "", dn12, up12 },
|
||||||
{ 41, pox + xstart + ( xspacing2 * 2 ),
|
{ 42, pox + xstart + ( xspacing2 * 3 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "3", "",
|
||||||
ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2,
|
"EQ LIB", "", dn11, up11 },
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "2", "", "LIBRARY", "", dn12, up12 },
|
{ 43, pox + xstart + ( xspacing2 * 4 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "-",
|
||||||
{ 42, pox + xstart + ( xspacing2 * 3 ),
|
"<< >>", "\" \"", "", dn10, up10 },
|
||||||
ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "3", "", "EQ LIB", "", dn11, up11 },
|
|
||||||
{ 43, pox + xstart + ( xspacing2 * 4 ),
|
|
||||||
ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "-", "<< >>", "\" \"", "", dn10,
|
|
||||||
up10 },
|
|
||||||
|
|
||||||
{ 44, pox + xstart + ( xspacing * 0 ), ystart + ( 8 * yspacing ) + poy + 80,
|
{ 44, pox + xstart + ( xspacing * 0 ), ystart + ( 8 * yspacing ) + poy + 80, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ON",
|
||||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ON", "CONT", "OFF",
|
"CONT", "OFF", "CANCEL", dnON, upON },
|
||||||
"CANCEL", dnON, upON },
|
{ 45, pox + xstart + ( xspacing2 * 1 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "0", "=",
|
||||||
{ 45, pox + xstart + ( xspacing2 * 1 ),
|
"->", "", dn03, up03 },
|
||||||
ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2,
|
{ 46, pox + xstart + ( xspacing2 * 2 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ".", ",",
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "0", "=", "->", "", dn03, up03 },
|
"back", "", dn02, up02 },
|
||||||
{ 46, pox + xstart + ( xspacing2 * 2 ),
|
{ 47, pox + xstart + ( xspacing2 * 3 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SPC",
|
||||||
ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2,
|
"pi", "rad", "", dn01, up01 },
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ".", ",", "back", "", dn02, up02 },
|
{ 48, pox + xstart + ( xspacing2 * 4 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+", "{}",
|
||||||
{ 47, pox + xstart + ( xspacing2 * 3 ),
|
": :", "", dn00, up00 },
|
||||||
ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SPC", "pi", "rad", "", dn01, up01 },
|
|
||||||
{ 48, pox + xstart + ( xspacing2 * 4 ),
|
|
||||||
ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2,
|
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+", "{}", ": :", "", dn00, up00 },
|
|
||||||
|
|
||||||
{ 49, pox + xstart, ystart + ( 9 * yspacing ) + poy + 90, 130, 20,
|
{ 49, pox + xstart, ystart + ( 9 * yspacing ) + poy + 90, 130, 20, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", dnZelda,
|
||||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", dnZelda,
|
upZelda },
|
||||||
upZelda },
|
{ 50, pox + xstart, poy, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||||
{ 50, pox + xstart, poy, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } };
|
};
|
||||||
|
|
||||||
void pcalc_init() { gui_initKeyboard( calc_buttons ); }
|
void pcalc_init() { gui_initKeyboard( calc_buttons ); }
|
||||||
|
|
||||||
void pcalc_show() {
|
void pcalc_show()
|
||||||
|
{
|
||||||
// clear_to_color(calc_bmp, color[C_PANEL_BACK]);
|
// clear_to_color(calc_bmp, color[C_PANEL_BACK]);
|
||||||
button_draw_all( calc_buttons );
|
button_draw_all( calc_buttons );
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcalc_hide( void ) {
|
void pcalc_hide( void )
|
||||||
|
{
|
||||||
// calc_bmp = NULL;
|
// calc_bmp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcalc_down( int mx, int my, int mb ) {
|
void pcalc_down( int mx, int my, int mb ) { button_mouse_down( calc_buttons, mx, my, mb ); }
|
||||||
button_mouse_down( calc_buttons, mx, my, mb );
|
|
||||||
}
|
|
||||||
|
|
||||||
void pcalc_up( int mx, int my, int mb ) {
|
void pcalc_up( int mx, int my, int mb ) { button_mouse_up( calc_buttons, mx, my, mb ); }
|
||||||
button_mouse_up( calc_buttons, mx, my, mb );
|
|
||||||
}
|
|
||||||
|
|
||||||
void pcalc_kb_down( SDL_Keycode sdl_event ) {
|
void pcalc_kb_down( SDL_Keycode sdl_event )
|
||||||
|
{
|
||||||
printf( "%d\n", SDLK_0 );
|
printf( "%d\n", SDLK_0 );
|
||||||
KBMapping* mapping = kb_sdl_mapping;
|
KBMapping* mapping = kb_sdl_mapping;
|
||||||
while ( mapping->SDL_event_id ) {
|
while ( mapping->SDL_event_id ) {
|
||||||
|
@ -349,7 +307,8 @@ void pcalc_kb_down( SDL_Keycode sdl_event ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcalc_kb_up( SDL_Keycode sdl_event ) {
|
void pcalc_kb_up( SDL_Keycode sdl_event )
|
||||||
|
{
|
||||||
KBMapping* mapping = kb_sdl_mapping;
|
KBMapping* mapping = kb_sdl_mapping;
|
||||||
while ( mapping->SDL_event_id ) {
|
while ( mapping->SDL_event_id ) {
|
||||||
if ( sdl_event == mapping->SDL_event_id ) {
|
if ( sdl_event == mapping->SDL_event_id ) {
|
||||||
|
|
83
src/pdebug.c
83
src/pdebug.c
|
@ -37,15 +37,16 @@
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "pdebug.h"
|
#include "pdebug.h"
|
||||||
|
|
||||||
static void run_up( boolean action );
|
/* static void run_up( boolean action ); */
|
||||||
static void break_up( boolean action );
|
/* static void break_up( boolean action ); */
|
||||||
static void step_up( boolean action );
|
/* static void step_up( boolean action ); */
|
||||||
|
|
||||||
static Button debug_buttons[] = {
|
/* static Button debug_buttons[] = { */
|
||||||
{ 0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Break", NULL, break_up },
|
/* {0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Break", NULL, NULL, NULL, break_up, NULL}, */
|
||||||
{ 1, 80, 0, 79, 20, BUTTON_B1RELEASE, "Run", NULL, run_up },
|
/* { 1, 80, 0, 79, 20, BUTTON_B1RELEASE, "Run", NULL, NULL, NULL, run_up, NULL}, */
|
||||||
{ 2, 160, 0, 79, 20, BUTTON_B1RELEASE, "Step", NULL, step_up },
|
/* { 2, 160, 0, 79, 20, BUTTON_B1RELEASE, "Step", NULL, NULL, NULL, step_up, NULL}, */
|
||||||
{ 3, 0, 0, 0, 0, 0, NULL, NULL, NULL } };
|
/* { 3, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL} */
|
||||||
|
/* }; */
|
||||||
|
|
||||||
#define BREAK_BUTTON 0
|
#define BREAK_BUTTON 0
|
||||||
#define RUN_BUTTON 1
|
#define RUN_BUTTON 1
|
||||||
|
@ -53,7 +54,8 @@ static Button debug_buttons[] = {
|
||||||
|
|
||||||
// static BITMAP *debug_bmp;
|
// static BITMAP *debug_bmp;
|
||||||
|
|
||||||
static void update_buttons( void ) {
|
static void update_buttons( void )
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
if (emulator_get_state() == EMULATOR_STOP) {
|
if (emulator_get_state() == EMULATOR_STOP) {
|
||||||
if (debug_buttons[RUN_BUTTON].flags & BUTTON_DISABLED) {
|
if (debug_buttons[RUN_BUTTON].flags & BUTTON_DISABLED) {
|
||||||
|
@ -84,29 +86,33 @@ if (emulator_get_state() == EMULATOR_STOP) {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_up( boolean action ) {
|
/* static void run_up( boolean action ) */
|
||||||
if ( action ) {
|
/* { */
|
||||||
emulator_set_state( EMULATOR_RUN );
|
/* if ( action ) { */
|
||||||
}
|
/* emulator_set_state( EMULATOR_RUN ); */
|
||||||
}
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
static void break_up( boolean action ) {
|
/* static void break_up( boolean action ) */
|
||||||
if ( action ) {
|
/* { */
|
||||||
emulator_set_state( EMULATOR_STOP );
|
/* if ( action ) { */
|
||||||
}
|
/* emulator_set_state( EMULATOR_STOP ); */
|
||||||
}
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
static void step_up( boolean action ) {
|
/* static void step_up( boolean action ) */
|
||||||
if ( action ) {
|
/* { */
|
||||||
emulator_set_state( EMULATOR_STEP );
|
/* if ( action ) { */
|
||||||
}
|
/* emulator_set_state( EMULATOR_STEP ); */
|
||||||
}
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
/*static*/ void draw_cpu( void ) {
|
/*static*/ void draw_cpu( void )
|
||||||
int c1 = color[ C_PANEL_TEXT ];
|
{
|
||||||
int c2 = color[ C_PANEL_DISABLED ];
|
/* int c1 = color[ C_PANEL_TEXT ]; */
|
||||||
int i;
|
/* int c2 = color[ C_PANEL_DISABLED ]; */
|
||||||
char* tmp;
|
/* int i; */
|
||||||
|
/* char* tmp; */
|
||||||
|
|
||||||
// if (!debug_bmp) {
|
// if (!debug_bmp) {
|
||||||
// return;
|
// return;
|
||||||
|
@ -117,9 +123,9 @@ static void step_up( boolean action ) {
|
||||||
// acquire_bitmap(debug_bmp);
|
// acquire_bitmap(debug_bmp);
|
||||||
// scare_mouse();
|
// scare_mouse();
|
||||||
|
|
||||||
tmp = disassemble( bus_fast_peek( NULL, cpu.pc, NULL ) );
|
/* tmp = disassemble( bus_fast_peek( NULL, cpu.pc, NULL ) ); */
|
||||||
|
|
||||||
printf( "PC = #%05X %-24s\n", ( int )cpu.pc, tmp );
|
/* printf( "PC = #%05X %-24s\n", ( int )cpu.pc, tmp ); */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
printf("A = #%s ", nib_to_hex_rev(cpu.reg[A], 16));
|
printf("A = #%s ", nib_to_hex_rev(cpu.reg[A], 16));
|
||||||
|
@ -225,7 +231,8 @@ cpu.cycles);
|
||||||
// release_bitmap(debug_bmp);
|
// release_bitmap(debug_bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdebug_draw_true_speed( dword speed ) {
|
void pdebug_draw_true_speed( dword speed )
|
||||||
|
{
|
||||||
// printf("True speed: %10u Hz\n", speed);
|
// printf("True speed: %10u Hz\n", speed);
|
||||||
|
|
||||||
// if (!debug_bmp) {
|
// if (!debug_bmp) {
|
||||||
|
@ -238,7 +245,8 @@ void pdebug_draw_true_speed( dword speed ) {
|
||||||
// %10u Hz", speed); unscare_mouse(); release_bitmap(debug_bmp);
|
// %10u Hz", speed); unscare_mouse(); release_bitmap(debug_bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdebug_state_changed( void ) {
|
void pdebug_state_changed( void )
|
||||||
|
{
|
||||||
update_buttons();
|
update_buttons();
|
||||||
draw_cpu();
|
draw_cpu();
|
||||||
}
|
}
|
||||||
|
@ -256,14 +264,17 @@ void pdebug_show(BITMAP *bmp)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void pdebug_hide( void ) {
|
void pdebug_hide( void )
|
||||||
|
{
|
||||||
// debug_bmp = NULL;
|
// debug_bmp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdebug_down( int mx, int my, int mb ) {
|
void pdebug_down( int mx, int my, int mb )
|
||||||
|
{
|
||||||
// button_mouse_down(debug_bmp, debug_buttons, mx, my, mb);
|
// button_mouse_down(debug_bmp, debug_buttons, mx, my, mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdebug_up( int mx, int my, int mb ) {
|
void pdebug_up( int mx, int my, int mb )
|
||||||
|
{
|
||||||
// button_mouse_up(debug_bmp, debug_buttons, mx, my, mb);
|
// button_mouse_up(debug_bmp, debug_buttons, mx, my, mb);
|
||||||
}
|
}
|
||||||
|
|
61
src/pfiles.c
61
src/pfiles.c
|
@ -35,28 +35,29 @@
|
||||||
#include "pfiles.h"
|
#include "pfiles.h"
|
||||||
|
|
||||||
#if defined( _WIN32 )
|
#if defined( _WIN32 )
|
||||||
#include <windows.h> // memset()
|
# include <windows.h> // memset()
|
||||||
#include <shlwapi.h> // PathRemoveFileSpecA
|
# include <shlwapi.h> // PathRemoveFileSpecA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined( __APPLE__ )
|
||||||
#import <CoreFoundation/CoreFoundation.h>
|
# import <CoreFoundation/CoreFoundation.h>
|
||||||
#include <string.h> // memset()
|
# include <string.h> // memset()
|
||||||
#include <ctype.h> // isalpha
|
# include <ctype.h> // isalpha
|
||||||
#include <unistd.h> // getcwd
|
# include <unistd.h> // getcwd
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( __linux__ )
|
#if defined( __linux__ )
|
||||||
#include <libgen.h> // dirname
|
# include <libgen.h> // dirname
|
||||||
#include <unistd.h> // readlink
|
# include <unistd.h> // readlink
|
||||||
#include <linux/limits.h> // PATH_MAX
|
# include <linux/limits.h> // PATH_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// static void load_up(boolean action);
|
// static void load_up(boolean action);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static Button files_buttons[] = {
|
static Button files_buttons[] = {
|
||||||
{ 0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Load", NULL, load_up
|
{ 0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Load", NULL,
|
||||||
|
load_up
|
||||||
}, { 1, 0, 0, 0, 0, 0, NULL, NULL, NULL }
|
}, { 1, 0, 0, 0, 0, 0, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
@ -64,7 +65,8 @@ static Button files_buttons[] = {
|
||||||
|
|
||||||
static char WorkingPath[ 512 ];
|
static char WorkingPath[ 512 ];
|
||||||
|
|
||||||
static void getExePath() {
|
static void getExePath()
|
||||||
|
{
|
||||||
char programPath[ 1024 ];
|
char programPath[ 1024 ];
|
||||||
char temp[ 1024 ];
|
char temp[ 1024 ];
|
||||||
memset( programPath, 0, sizeof( programPath ) );
|
memset( programPath, 0, sizeof( programPath ) );
|
||||||
|
@ -73,9 +75,8 @@ static void getExePath() {
|
||||||
#if defined( __APPLE__ )
|
#if defined( __APPLE__ )
|
||||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle );
|
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle );
|
||||||
if ( !CFURLGetFileSystemRepresentation(
|
if ( !CFURLGetFileSystemRepresentation( resourcesURL, TRUE, ( UInt8* )programPath,
|
||||||
resourcesURL, TRUE, ( UInt8* )programPath,
|
PATH_MAX ) ) // Error: expected unqualified-id before 'if'
|
||||||
PATH_MAX ) ) // Error: expected unqualified-id before 'if'
|
|
||||||
{
|
{
|
||||||
// error!
|
// error!
|
||||||
}
|
}
|
||||||
|
@ -117,7 +118,8 @@ static void getExePath() {
|
||||||
strcpy( WorkingPath, programPath );
|
strcpy( WorkingPath, programPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int file_size( char* name ) {
|
static int file_size( char* name )
|
||||||
|
{
|
||||||
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
||||||
getExePath();
|
getExePath();
|
||||||
|
|
||||||
|
@ -155,7 +157,8 @@ static int file_size(char *name)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void load_file( char* name ) {
|
void load_file( char* name )
|
||||||
|
{
|
||||||
// PACKFILE *f;
|
// PACKFILE *f;
|
||||||
FILE* f;
|
FILE* f;
|
||||||
byte* buf;
|
byte* buf;
|
||||||
|
@ -219,15 +222,16 @@ void load_file( char* name ) {
|
||||||
// /Users/admin/Documents/GIT/jsEmu48/jsEmu48/emutest2/emutest2/arkalite
|
// /Users/admin/Documents/GIT/jsEmu48/jsEmu48/emutest2/emutest2/arkalite
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void load_up( boolean action ) {
|
void load_up( boolean action )
|
||||||
static char path[ PATH_SIZE ] = "";
|
{
|
||||||
|
/* static char path[ PATH_SIZE ] = ""; */
|
||||||
|
|
||||||
if ( action ) {
|
/* if ( action ) { */
|
||||||
// if (file_select_ex("Load Object", path, NULL, PATH_SIZE,
|
/* // if (file_select_ex("Load Object", path, NULL, PATH_SIZE, */
|
||||||
//0, 0)) {
|
/* // 0, 0)) { */
|
||||||
// load_file(path);
|
/* // load_file(path); */
|
||||||
// }
|
/* // } */
|
||||||
}
|
/* } */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -240,14 +244,17 @@ void pfiles_show(BITMAP *bmp)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void pfiles_hide( void ) {
|
void pfiles_hide( void )
|
||||||
|
{
|
||||||
// files_bmp = NULL;
|
// files_bmp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfiles_down( int mx, int my, int mb ) {
|
void pfiles_down( int mx, int my, int mb )
|
||||||
|
{
|
||||||
// button_mouse_down(files_bmp, files_buttons, mx, my, mb);
|
// button_mouse_down(files_bmp, files_buttons, mx, my, mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pfiles_up( int mx, int my, int mb ) {
|
void pfiles_up( int mx, int my, int mb )
|
||||||
|
{
|
||||||
// button_mouse_up(files_bmp, files_buttons, mx, my, mb);
|
// button_mouse_up(files_bmp, files_buttons, mx, my, mb);
|
||||||
}
|
}
|
||||||
|
|
111
src/pmenu.c
111
src/pmenu.c
|
@ -32,64 +32,68 @@
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "pmenu.h"
|
#include "pmenu.h"
|
||||||
|
|
||||||
static void exit_up( boolean action );
|
/* static void exit_up( boolean action ); */
|
||||||
static void debug_up( boolean action );
|
/* static void debug_up( boolean action ); */
|
||||||
static void files_up( boolean action );
|
/* static void files_up( boolean action ); */
|
||||||
static void about_up( boolean action );
|
/* static void about_up( boolean action ); */
|
||||||
|
|
||||||
static Button menu_buttons[] = {
|
/* static Button menu_buttons[] = { */
|
||||||
{ 0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Exit", NULL, exit_up },
|
/* {0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Exit", NULL, exit_up }, */
|
||||||
{ 1, 80, 0, 79, 20, BUTTON_B1RELEASE, "Debug", NULL, debug_up },
|
/* { 1, 80, 0, 79, 20, BUTTON_B1RELEASE, "Debug", NULL, debug_up}, */
|
||||||
{ 2, 160, 0, 79, 20, BUTTON_B1RELEASE, "Files", NULL, files_up },
|
/* { 2, 160, 0, 79, 20, BUTTON_B1RELEASE, "Files", NULL, files_up}, */
|
||||||
{ 3, 240, 0, 79, 20, BUTTON_DISABLED | BUTTON_B1RELEASE, "About", NULL,
|
/* { 3, 240, 0, 79, 20, BUTTON_DISABLED | BUTTON_B1RELEASE, "About", NULL, about_up}, */
|
||||||
about_up },
|
/* { 4, 0, 0, 0, 0, 0, NULL, NULL, NULL } */
|
||||||
{ 4, 0, 0, 0, 0, 0, NULL, NULL, NULL } };
|
/* }; */
|
||||||
|
|
||||||
enum MenuButtons { MENU_EXIT, MENU_DEBUG, MENU_FILES, MENU_ABOUT, MENU_COUNT };
|
enum MenuButtons { MENU_EXIT, MENU_DEBUG, MENU_FILES, MENU_ABOUT, MENU_COUNT };
|
||||||
|
|
||||||
// static BITMAP *menu_bmp;
|
// static BITMAP *menu_bmp;
|
||||||
|
|
||||||
static void exit_up( boolean action ) {
|
/* static void exit_up( boolean action ) */
|
||||||
if ( action ) {
|
/* { */
|
||||||
please_exit = TRUE;
|
/* if ( action ) { */
|
||||||
}
|
/* please_exit = TRUE; */
|
||||||
}
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
static void debug_up( boolean action ) {
|
/* static void debug_up( boolean action ) */
|
||||||
// if (action) {
|
/* { */
|
||||||
// menu_buttons[MENU_DEBUG].flags |= BUTTON_DISABLED;
|
/* // if (action) { */
|
||||||
// menu_buttons[MENU_FILES].flags &= ~BUTTON_DISABLED;
|
/* // menu_buttons[MENU_DEBUG].flags |= BUTTON_DISABLED; */
|
||||||
// menu_buttons[MENU_ABOUT].flags &= ~BUTTON_DISABLED;
|
/* // menu_buttons[MENU_FILES].flags &= ~BUTTON_DISABLED; */
|
||||||
// button_draw_all(menu_bmp, menu_buttons);
|
/* // menu_buttons[MENU_ABOUT].flags &= ~BUTTON_DISABLED; */
|
||||||
// gui_hide_panel(PANEL_FILES);
|
/* // button_draw_all(menu_bmp, menu_buttons); */
|
||||||
// gui_hide_panel(PANEL_ABOUT);
|
/* // gui_hide_panel(PANEL_FILES); */
|
||||||
// gui_show_panel(PANEL_DEBUG);
|
/* // gui_hide_panel(PANEL_ABOUT); */
|
||||||
// }
|
/* // gui_show_panel(PANEL_DEBUG); */
|
||||||
}
|
/* // } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
static void files_up( boolean action ) {
|
/* static void files_up( boolean action ) */
|
||||||
// if (action) {
|
/* { */
|
||||||
// menu_buttons[MENU_DEBUG].flags &= ~BUTTON_DISABLED;
|
/* // if (action) { */
|
||||||
// menu_buttons[MENU_FILES].flags |= BUTTON_DISABLED;
|
/* // menu_buttons[MENU_DEBUG].flags &= ~BUTTON_DISABLED; */
|
||||||
// menu_buttons[MENU_ABOUT].flags &= ~BUTTON_DISABLED;
|
/* // menu_buttons[MENU_FILES].flags |= BUTTON_DISABLED; */
|
||||||
// button_draw_all(menu_bmp, menu_buttons);
|
/* // menu_buttons[MENU_ABOUT].flags &= ~BUTTON_DISABLED; */
|
||||||
// gui_hide_panel(PANEL_DEBUG);
|
/* // button_draw_all(menu_bmp, menu_buttons); */
|
||||||
// gui_hide_panel(PANEL_ABOUT);
|
/* // gui_hide_panel(PANEL_DEBUG); */
|
||||||
// gui_show_panel(PANEL_FILES);
|
/* // gui_hide_panel(PANEL_ABOUT); */
|
||||||
// }
|
/* // gui_show_panel(PANEL_FILES); */
|
||||||
}
|
/* // } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
static void about_up( boolean action ) {
|
/* static void about_up( boolean action ) */
|
||||||
// if (action) {
|
/* { */
|
||||||
// menu_buttons[MENU_DEBUG].flags &= ~BUTTON_DISABLED;
|
/* // if (action) { */
|
||||||
// menu_buttons[MENU_FILES].flags &= ~BUTTON_DISABLED;
|
/* // menu_buttons[MENU_DEBUG].flags &= ~BUTTON_DISABLED; */
|
||||||
// menu_buttons[MENU_ABOUT].flags |= BUTTON_DISABLED;
|
/* // menu_buttons[MENU_FILES].flags &= ~BUTTON_DISABLED; */
|
||||||
// button_draw_all(menu_bmp, menu_buttons);
|
/* // menu_buttons[MENU_ABOUT].flags |= BUTTON_DISABLED; */
|
||||||
// gui_hide_panel(PANEL_DEBUG);
|
/* // button_draw_all(menu_bmp, menu_buttons); */
|
||||||
// gui_hide_panel(PANEL_FILES);
|
/* // gui_hide_panel(PANEL_DEBUG); */
|
||||||
// gui_show_panel(PANEL_ABOUT);
|
/* // gui_hide_panel(PANEL_FILES); */
|
||||||
// }
|
/* // gui_show_panel(PANEL_ABOUT); */
|
||||||
}
|
/* // } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void pmenu_show(BITMAP *bmp)
|
void pmenu_show(BITMAP *bmp)
|
||||||
|
@ -101,14 +105,17 @@ void pmenu_show(BITMAP *bmp)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void pmenu_hide( void ) {
|
void pmenu_hide( void )
|
||||||
|
{
|
||||||
// menu_bmp = NULL;
|
// menu_bmp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pmenu_down( int mx, int my, int mb ) {
|
void pmenu_down( int mx, int my, int mb )
|
||||||
|
{
|
||||||
// button_mouse_down(menu_bmp, menu_buttons, mx, my, mb);
|
// button_mouse_down(menu_bmp, menu_buttons, mx, my, mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pmenu_up( int mx, int my, int mb ) {
|
void pmenu_up( int mx, int my, int mb )
|
||||||
|
{
|
||||||
// button_mouse_up(menu_bmp, menu_buttons, mx, my, mb);
|
// button_mouse_up(menu_bmp, menu_buttons, mx, my, mb);
|
||||||
}
|
}
|
||||||
|
|
13
src/ports.c
13
src/ports.c
|
@ -34,7 +34,8 @@ static byte current_bank;
|
||||||
static byte* port2;
|
static byte* port2;
|
||||||
static address port2mask;
|
static address port2mask;
|
||||||
|
|
||||||
void ports_init( void ) {
|
void ports_init( void )
|
||||||
|
{
|
||||||
// ce1 = bank switcher
|
// ce1 = bank switcher
|
||||||
bus_info.ce1_data = NULL;
|
bus_info.ce1_data = NULL;
|
||||||
bus_info.ce1_mask = 0x0007F;
|
bus_info.ce1_mask = 0x0007F;
|
||||||
|
@ -47,7 +48,7 @@ void ports_init( void ) {
|
||||||
bus_info.ce2_mask = 0x00000;
|
bus_info.ce2_mask = 0x00000;
|
||||||
bus_info.ce2_r_o = TRUE;
|
bus_info.ce2_r_o = TRUE;
|
||||||
#else
|
#else
|
||||||
#define PORT1_SIZE ( 64 * 1024 ) // Nibbles
|
# define PORT1_SIZE ( 64 * 1024 ) // Nibbles
|
||||||
// ce2 = port1 (plugged)
|
// ce2 = port1 (plugged)
|
||||||
bus_info.ce2_data = malloc( PORT1_SIZE );
|
bus_info.ce2_data = malloc( PORT1_SIZE );
|
||||||
bus_info.ce2_mask = PORT1_SIZE - 1;
|
bus_info.ce2_mask = PORT1_SIZE - 1;
|
||||||
|
@ -62,7 +63,7 @@ void ports_init( void ) {
|
||||||
bus_info.nce3_mask = port2mask & 0x3FFFF;
|
bus_info.nce3_mask = port2mask & 0x3FFFF;
|
||||||
bus_info.nce3_r_o = TRUE;
|
bus_info.nce3_r_o = TRUE;
|
||||||
#else
|
#else
|
||||||
#define PORT2_SIZE ( 512 * 1024 ) // Nibbles
|
# define PORT2_SIZE ( 512 * 1024 ) // Nibbles
|
||||||
// nce3 = port2 (plugged)
|
// nce3 = port2 (plugged)
|
||||||
port2 = malloc( PORT2_SIZE );
|
port2 = malloc( PORT2_SIZE );
|
||||||
port2mask = PORT2_SIZE - 1;
|
port2mask = PORT2_SIZE - 1;
|
||||||
|
@ -77,7 +78,8 @@ void ports_init( void ) {
|
||||||
|
|
||||||
void ports_exit( void ) {}
|
void ports_exit( void ) {}
|
||||||
|
|
||||||
void ports_switch_bank( address adr ) {
|
void ports_switch_bank( address adr )
|
||||||
|
{
|
||||||
boolean need_remap = FALSE;
|
boolean need_remap = FALSE;
|
||||||
|
|
||||||
if ( current_bank != ( ( ( byte )adr >> 1 ) & 0x1F ) ) {
|
if ( current_bank != ( ( ( byte )adr >> 1 ) & 0x1F ) ) {
|
||||||
|
@ -100,7 +102,8 @@ void ports_switch_bank( address adr ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
byte ports_card_detect( void ) {
|
byte ports_card_detect( void )
|
||||||
|
{
|
||||||
byte x = 0;
|
byte x = 0;
|
||||||
if ( bus_info.nce3_data )
|
if ( bus_info.nce3_data )
|
||||||
x |= 0x1;
|
x |= 0x1;
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
|
|
||||||
static address ram_size = 256 * 1024; // in nibbles, not bytes!
|
static address ram_size = 256 * 1024; // in nibbles, not bytes!
|
||||||
|
|
||||||
void ram_init( void ) {
|
void ram_init( void )
|
||||||
|
{
|
||||||
byte* buf;
|
byte* buf;
|
||||||
|
|
||||||
buf = malloc( ram_size );
|
buf = malloc( ram_size );
|
||||||
|
@ -45,7 +46,8 @@ void ram_init( void ) {
|
||||||
bus_info.ram_mask = ram_size - 1;
|
bus_info.ram_mask = ram_size - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ram_exit( void ) {
|
void ram_exit( void )
|
||||||
|
{
|
||||||
free( bus_info.ram_data );
|
free( bus_info.ram_data );
|
||||||
bus_info.ram_data = NULL;
|
bus_info.ram_data = NULL;
|
||||||
bus_info.ram_mask = 0x00000;
|
bus_info.ram_mask = 0x00000;
|
||||||
|
|
35
src/rom.c
35
src/rom.c
|
@ -34,26 +34,27 @@
|
||||||
#include "rom.h"
|
#include "rom.h"
|
||||||
|
|
||||||
#if defined( _WIN32 )
|
#if defined( _WIN32 )
|
||||||
#include <windows.h> // memset()
|
# include <windows.h> // memset()
|
||||||
#include <shlwapi.h> // PathRemoveFileSpecA
|
# include <shlwapi.h> // PathRemoveFileSpecA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined( __APPLE__ )
|
||||||
#import <CoreFoundation/CoreFoundation.h>
|
# import <CoreFoundation/CoreFoundation.h>
|
||||||
#include <string.h> // memset()
|
# include <string.h> // memset()
|
||||||
#include <ctype.h> // isalpha
|
# include <ctype.h> // isalpha
|
||||||
#include <unistd.h> // getcwd
|
# include <unistd.h> // getcwd
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( __linux__ )
|
#if defined( __linux__ )
|
||||||
#include <libgen.h> // dirname
|
# include <libgen.h> // dirname
|
||||||
#include <unistd.h> // readlink
|
# include <unistd.h> // readlink
|
||||||
#include <linux/limits.h> // PATH_MAX
|
# include <linux/limits.h> // PATH_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char WorkingPath[ 512 ];
|
static char WorkingPath[ 512 ];
|
||||||
|
|
||||||
static void getExePath() {
|
static void getExePath()
|
||||||
|
{
|
||||||
char programPath[ 1024 ] = ".";
|
char programPath[ 1024 ] = ".";
|
||||||
char temp[ 1024 ];
|
char temp[ 1024 ];
|
||||||
memset( programPath, 0, sizeof( programPath ) );
|
memset( programPath, 0, sizeof( programPath ) );
|
||||||
|
@ -62,9 +63,8 @@ static void getExePath() {
|
||||||
#if defined( __APPLE__ )
|
#if defined( __APPLE__ )
|
||||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle );
|
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle );
|
||||||
if ( !CFURLGetFileSystemRepresentation(
|
if ( !CFURLGetFileSystemRepresentation( resourcesURL, TRUE, ( UInt8* )programPath,
|
||||||
resourcesURL, TRUE, ( UInt8* )programPath,
|
PATH_MAX ) ) // Error: expected unqualified-id before 'if'
|
||||||
PATH_MAX ) ) // Error: expected unqualified-id before 'if'
|
|
||||||
{
|
{
|
||||||
// error!
|
// error!
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,8 @@ static void getExePath() {
|
||||||
printf( "exec path = %s\n", WorkingPath );
|
printf( "exec path = %s\n", WorkingPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int file_size( char* name ) {
|
static int file_size( char* name )
|
||||||
|
{
|
||||||
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
||||||
getExePath();
|
getExePath();
|
||||||
|
|
||||||
|
@ -128,7 +129,8 @@ static int file_size( char* name ) {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rom_init( void ) {
|
void rom_init( void )
|
||||||
|
{
|
||||||
printf( "rom_init..\n" );
|
printf( "rom_init..\n" );
|
||||||
int size;
|
int size;
|
||||||
char* name = "hpemu.rom";
|
char* name = "hpemu.rom";
|
||||||
|
@ -190,7 +192,8 @@ void rom_init( void ) {
|
||||||
printf( "rom_init succeed!\n" );
|
printf( "rom_init succeed!\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void rom_exit( void ) {
|
void rom_exit( void )
|
||||||
|
{
|
||||||
free( bus_info.rom_data );
|
free( bus_info.rom_data );
|
||||||
bus_info.rom_data = NULL;
|
bus_info.rom_data = NULL;
|
||||||
bus_info.rom_mask = 0x00000;
|
bus_info.rom_mask = 0x00000;
|
||||||
|
|
21
src/rpl.c
21
src/rpl.c
|
@ -38,7 +38,8 @@
|
||||||
#define AVMEM 0x807ED
|
#define AVMEM 0x807ED
|
||||||
#define INTRPPTR 0x8072F
|
#define INTRPPTR 0x8072F
|
||||||
|
|
||||||
int rpl_object_size( byte* obj ) {
|
int rpl_object_size( byte* obj )
|
||||||
|
{
|
||||||
int size;
|
int size;
|
||||||
int prologue;
|
int prologue;
|
||||||
int n;
|
int n;
|
||||||
|
@ -126,7 +127,8 @@ int rpl_object_size( byte* obj ) {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static address read_address( address adr ) {
|
static address read_address( address adr )
|
||||||
|
{
|
||||||
byte buf[ 5 ];
|
byte buf[ 5 ];
|
||||||
word ocrc;
|
word ocrc;
|
||||||
|
|
||||||
|
@ -137,14 +139,16 @@ static address read_address( address adr ) {
|
||||||
return nib_to_unsigned( buf, 5 );
|
return nib_to_unsigned( buf, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_address( address adr, address val ) {
|
static void write_address( address adr, address val )
|
||||||
|
{
|
||||||
byte buf[ 5 ];
|
byte buf[ 5 ];
|
||||||
|
|
||||||
unsigned_to_nib( buf, val, 5 );
|
unsigned_to_nib( buf, val, 5 );
|
||||||
bus_write( buf, adr, 5 );
|
bus_write( buf, adr, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int moveup( address src, address dst, address cnt ) {
|
static int moveup( address src, address dst, address cnt )
|
||||||
|
{
|
||||||
byte* buf = malloc( cnt * sizeof( byte ) );
|
byte* buf = malloc( cnt * sizeof( byte ) );
|
||||||
word ocrc;
|
word ocrc;
|
||||||
|
|
||||||
|
@ -160,7 +164,8 @@ static int moveup( address src, address dst, address cnt ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
address rpl_make_temp( address size ) {
|
address rpl_make_temp( address size )
|
||||||
|
{
|
||||||
address temptop, rsktop, dsktop;
|
address temptop, rsktop, dsktop;
|
||||||
|
|
||||||
size += 6;
|
size += 6;
|
||||||
|
@ -183,7 +188,8 @@ address rpl_make_temp( address size ) {
|
||||||
return temptop + 1;
|
return temptop + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rpl_push( address adr ) {
|
void rpl_push( address adr )
|
||||||
|
{
|
||||||
address dsktop, avmem;
|
address dsktop, avmem;
|
||||||
|
|
||||||
avmem = read_address( AVMEM );
|
avmem = read_address( AVMEM );
|
||||||
|
@ -197,7 +203,8 @@ void rpl_push( address adr ) {
|
||||||
write_address( DSKTOP, dsktop );
|
write_address( DSKTOP, dsktop );
|
||||||
}
|
}
|
||||||
|
|
||||||
int rpl_push_object( byte* obj, address size ) {
|
int rpl_push_object( byte* obj, address size )
|
||||||
|
{
|
||||||
address adr;
|
address adr;
|
||||||
|
|
||||||
adr = rpl_make_temp( size );
|
adr = rpl_make_temp( size );
|
||||||
|
|
|
@ -44,7 +44,8 @@ byte timer2_control;
|
||||||
byte timer1_value;
|
byte timer1_value;
|
||||||
dword timer2_value;
|
dword timer2_value;
|
||||||
|
|
||||||
void timer1_update( void ) {
|
void timer1_update( void )
|
||||||
|
{
|
||||||
if ( timer2_control & TIMER_RUN ) {
|
if ( timer2_control & TIMER_RUN ) {
|
||||||
timer1_value--;
|
timer1_value--;
|
||||||
timer1_value &= 0xF;
|
timer1_value &= 0xF;
|
||||||
|
@ -71,7 +72,8 @@ void timer1_update( void ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer2_update( void ) {
|
void timer2_update( void )
|
||||||
|
{
|
||||||
if ( timer2_control & TIMER_RUN ) {
|
if ( timer2_control & TIMER_RUN ) {
|
||||||
timer2_value--;
|
timer2_value--;
|
||||||
if ( timer2_value & 0x80000000 ) {
|
if ( timer2_value & 0x80000000 ) {
|
||||||
|
|
|
@ -35,8 +35,8 @@ typedef signed int address;
|
||||||
typedef char boolean;
|
typedef char boolean;
|
||||||
|
|
||||||
#ifndef TRUE
|
#ifndef TRUE
|
||||||
#define TRUE -1
|
# define TRUE -1
|
||||||
#define FALSE 0
|
# define FALSE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue