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'
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: '4'
|
||||
PointerAlignment: Left
|
||||
SortIncludes: 'false'
|
||||
SpaceAfterTemplateKeyword: 'false'
|
||||
SpaceBeforeAssignmentOperators: 'true'
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: 'true'
|
||||
SpaceInEmptyParentheses: 'false'
|
||||
SpacesInAngles: 'true'
|
||||
SpacesInCStyleCastParentheses: 'true'
|
||||
SpacesInContainerLiterals: 'true'
|
||||
SpacesInParentheses: 'true'
|
||||
SpacesInSquareBrackets: 'true'
|
||||
Language: Cpp
|
||||
ColumnLimit: 140
|
||||
IndentWidth: 4
|
||||
PPIndentWidth: 2
|
||||
UseTab: Never
|
||||
|
||||
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
|
||||
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 += -DSDL_TTF=1 #-DFONT_FILENAME="/usr/share/fonts/TTF/unifont.ttf"
|
||||
|
||||
.PHONY: all clean clean-all pretty-code install mrproper
|
||||
|
||||
|
|
125
src/bus.c
125
src/bus.c
|
@ -52,7 +52,8 @@ static address hdw_seg;
|
|||
|
||||
word crc;
|
||||
|
||||
void bus_init( void ) {
|
||||
void bus_init( void )
|
||||
{
|
||||
rom_init();
|
||||
hdw_init();
|
||||
ram_init();
|
||||
|
@ -60,23 +61,22 @@ void bus_init( void ) {
|
|||
bus_reset();
|
||||
}
|
||||
|
||||
void bus_exit( void ) {
|
||||
void bus_exit( void )
|
||||
{
|
||||
rom_exit();
|
||||
hdw_exit();
|
||||
ram_exit();
|
||||
ports_exit();
|
||||
}
|
||||
|
||||
static __inline void update_crc( byte nibble ) {
|
||||
crc = ( crc >> 4 ) ^ ( ( ( crc ^ nibble ) & 0xF ) * 0x1081 );
|
||||
}
|
||||
static __inline void update_crc( byte nibble ) { 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;
|
||||
|
||||
while ( TRUE ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) &&
|
||||
( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
||||
for ( i = 0; i < n; 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 ] );
|
||||
}
|
||||
} else {
|
||||
if ( hdw_seg == SEG_OF( adr ) &&
|
||||
( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
||||
} else {
|
||||
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++ ) {
|
||||
buf[ i ] = ( ( i + adr ) & 1 ) ? 0xE : 0xD;
|
||||
}
|
||||
if ( bus_info.ce1_bs && bus_info.ce1_cfg &&
|
||||
( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
|
||||
if ( bus_info.ce1_bs && bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
|
||||
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;
|
||||
|
||||
while ( TRUE ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) &&
|
||||
( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
||||
for ( i = 0; i < n; i++ ) {
|
||||
hdw_write_nibble( buf[ i ], ( adr & 0x3F ) + i );
|
||||
}
|
||||
} else {
|
||||
if ( hdw_seg == SEG_OF( adr ) &&
|
||||
( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
||||
} else {
|
||||
n = MIN( len, 0x1000 - OFFSET_OF( adr ) );
|
||||
|
@ -136,8 +133,7 @@ void bus_write( byte* buf, address adr, address len ) {
|
|||
if ( CAN_WRITE( adr ) ) {
|
||||
memcpy( MAP_WRITE( adr ), buf, n );
|
||||
} else if ( bus_info.ce1_bs ) {
|
||||
if ( bus_info.ce1_cfg &&
|
||||
( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
|
||||
if ( bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) ) {
|
||||
if ( !bus_info.nce3_r_o ) {
|
||||
ports_switch_bank( OFFSET_OF( 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;
|
||||
|
||||
while ( TRUE ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) &&
|
||||
( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) && ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ) {
|
||||
n = MIN( len, 0x40 - ( adr & 0x3F ) );
|
||||
for ( i = 0; i < n; i++ ) {
|
||||
buf[ i ] = hdw_read_nibble( ( adr & 0x3F ) + i );
|
||||
}
|
||||
} else {
|
||||
if ( hdw_seg == SEG_OF( adr ) &&
|
||||
( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||
n = MIN( len, ( bus_info.hdw_base & 0xFFFC0 ) - adr );
|
||||
} else {
|
||||
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 */
|
||||
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;
|
||||
|
||||
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
|
||||
* 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 int tmp_len;
|
||||
address adr2;
|
||||
|
@ -245,23 +242,20 @@ byte* bus_fast_peek( byte* buf, address adr, int* len ) {
|
|||
adr2 = adr + *len - 1;
|
||||
|
||||
if ( ( SEG_OF( adr ) == hdw_seg || SEG_OF( adr2 ) == hdw_seg ) &&
|
||||
( ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 ||
|
||||
( ( bus_info.hdw_base ^ adr2 ) & 0xFFFC0 ) == 0 ) ) {
|
||||
( ( ( bus_info.hdw_base ^ adr ) & 0xFFFC0 ) == 0 || ( ( bus_info.hdw_base ^ adr2 ) & 0xFFFC0 ) == 0 ) ) {
|
||||
bus_peek( buf, adr, *len );
|
||||
return buf;
|
||||
} else if ( !CAN_READ( adr ) ) {
|
||||
bus_peek_no_hdw( buf, adr, *len );
|
||||
return buf;
|
||||
} else if ( SEG_OF( adr ) == SEG_OF( adr2 ) ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) &&
|
||||
( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||
if ( hdw_seg == SEG_OF( adr ) && ( bus_info.hdw_base & 0xFFFC0 ) - adr > 0 ) {
|
||||
*len = ( bus_info.hdw_base & 0xFFFC0 ) - adr;
|
||||
} else {
|
||||
*len = 0x1000 - OFFSET_OF( adr );
|
||||
}
|
||||
return MAP_READ( adr );
|
||||
} else if ( CAN_READ( adr2 ) &&
|
||||
MAP_READ( adr ) + *len - 1 == MAP_READ( adr2 ) ) {
|
||||
} else if ( CAN_READ( adr2 ) && MAP_READ( adr ) + *len - 1 == MAP_READ( adr2 ) ) {
|
||||
if ( hdw_seg == SEG_OF( adr2 ) ) {
|
||||
*len = ( bus_info.hdw_base & 0xFFFC0 ) - adr;
|
||||
} 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;
|
||||
|
||||
for ( adr = 0; adr < 0x100000; adr += 0x01000 ) {
|
||||
if ( bus_info.ram_cfg &&
|
||||
( ( bus_info.ram_base ^ adr ) & bus_info.ram_size ) == 0 ) {
|
||||
read_map[ SEG_OF( adr ) ] =
|
||||
bus_info.ram_data + ( adr & bus_info.ram_mask );
|
||||
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.ram_cfg && ( ( bus_info.ram_base ^ adr ) & bus_info.ram_size ) == 0 ) {
|
||||
read_map[ SEG_OF( adr ) ] = bus_info.ram_data + ( adr & bus_info.ram_mask );
|
||||
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 ) {
|
||||
read_map[ SEG_OF( adr ) ] =
|
||||
bus_info.ce2_data + ( adr & bus_info.ce2_mask );
|
||||
read_map[ SEG_OF( adr ) ] = bus_info.ce2_data + ( adr & bus_info.ce2_mask );
|
||||
if ( !bus_info.ce2_r_o ) {
|
||||
write_map[ SEG_OF( adr ) ] =
|
||||
bus_info.ce2_data + ( adr & bus_info.ce2_mask );
|
||||
write_map[ SEG_OF( adr ) ] = bus_info.ce2_data + ( adr & bus_info.ce2_mask );
|
||||
} else {
|
||||
write_map[ SEG_OF( adr ) ] = NULL;
|
||||
}
|
||||
|
@ -299,14 +288,11 @@ void bus_remap( void ) {
|
|||
read_map[ SEG_OF( adr ) ] = NULL;
|
||||
write_map[ SEG_OF( adr ) ] = NULL;
|
||||
}
|
||||
} else if ( bus_info.ce1_cfg &&
|
||||
( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) == 0 ) {
|
||||
} else if ( bus_info.ce1_cfg && ( ( bus_info.ce1_base ^ adr ) & bus_info.ce1_size ) == 0 ) {
|
||||
if ( bus_info.ce1_data ) {
|
||||
read_map[ SEG_OF( adr ) ] =
|
||||
bus_info.ce1_data + ( adr & bus_info.ce1_mask );
|
||||
read_map[ SEG_OF( adr ) ] = bus_info.ce1_data + ( adr & bus_info.ce1_mask );
|
||||
if ( !bus_info.ce1_r_o ) {
|
||||
write_map[ SEG_OF( adr ) ] =
|
||||
bus_info.ce1_data + ( adr & bus_info.ce1_mask );
|
||||
write_map[ SEG_OF( adr ) ] = bus_info.ce1_data + ( adr & bus_info.ce1_mask );
|
||||
} else {
|
||||
write_map[ SEG_OF( adr ) ] = NULL;
|
||||
}
|
||||
|
@ -314,14 +300,11 @@ void bus_remap( void ) {
|
|||
read_map[ SEG_OF( adr ) ] = NULL;
|
||||
write_map[ SEG_OF( adr ) ] = NULL;
|
||||
}
|
||||
} else if ( bus_info.nce3_cfg && ( ( bus_info.nce3_base ^ adr ) &
|
||||
bus_info.nce3_size ) == 0 ) {
|
||||
} else if ( bus_info.nce3_cfg && ( ( bus_info.nce3_base ^ adr ) & bus_info.nce3_size ) == 0 ) {
|
||||
if ( bus_info.nce3_data && bus_info.ben && !bus_info.da19 ) {
|
||||
read_map[ SEG_OF( adr ) ] =
|
||||
bus_info.nce3_data + ( adr & bus_info.nce3_mask );
|
||||
read_map[ SEG_OF( adr ) ] = bus_info.nce3_data + ( adr & bus_info.nce3_mask );
|
||||
if ( !bus_info.nce3_r_o ) {
|
||||
write_map[ SEG_OF( adr ) ] =
|
||||
bus_info.nce3_data + ( adr & bus_info.nce3_mask );
|
||||
write_map[ SEG_OF( adr ) ] = bus_info.nce3_data + ( adr & bus_info.nce3_mask );
|
||||
} else {
|
||||
write_map[ SEG_OF( adr ) ] = NULL;
|
||||
}
|
||||
|
@ -330,9 +313,7 @@ void bus_remap( void ) {
|
|||
write_map[ SEG_OF( adr ) ] = NULL;
|
||||
}
|
||||
} else {
|
||||
read_map[ SEG_OF( adr ) ] =
|
||||
bus_info.rom_data + ( adr & bus_info.rom_mask &
|
||||
( bus_info.da19 ? 0xFFFFF : 0x7FFFF ) );
|
||||
read_map[ SEG_OF( adr ) ] = bus_info.rom_data + ( adr & bus_info.rom_mask & ( bus_info.da19 ? 0xFFFFF : 0x7FFFF ) );
|
||||
write_map[ SEG_OF( adr ) ] = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +321,8 @@ void bus_remap( void ) {
|
|||
// invalid
|
||||
}
|
||||
|
||||
void bus_configure( address adr ) {
|
||||
void bus_configure( address adr )
|
||||
{
|
||||
if ( !bus_info.hdw_cfg ) {
|
||||
bus_info.hdw_base = adr & 0xFFFC0;
|
||||
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 ) {
|
||||
bus_info.hdw_cfg = FALSE;
|
||||
hdw_seg = -1;
|
||||
} else if ( bus_info.ram_cfg &&
|
||||
( ( adr ^ bus_info.ram_base ) & bus_info.ram_size ) == 0 ) {
|
||||
} else if ( bus_info.ram_cfg && ( ( adr ^ bus_info.ram_base ) & bus_info.ram_size ) == 0 ) {
|
||||
bus_info.ram_cfg = FALSE;
|
||||
bus_info.ram_sz_cfg = FALSE;
|
||||
bus_remap();
|
||||
} else if ( bus_info.ce2_cfg &&
|
||||
( ( adr ^ bus_info.ce2_base ) & bus_info.ce2_size ) == 0 ) {
|
||||
} else if ( bus_info.ce2_cfg && ( ( adr ^ bus_info.ce2_base ) & bus_info.ce2_size ) == 0 ) {
|
||||
bus_info.ce2_cfg = FALSE;
|
||||
bus_info.ce2_sz_cfg = FALSE;
|
||||
bus_remap();
|
||||
} else if ( bus_info.ce1_cfg &&
|
||||
( ( adr ^ bus_info.ce1_base ) & bus_info.ce1_size ) == 0 ) {
|
||||
} else if ( bus_info.ce1_cfg && ( ( adr ^ bus_info.ce1_base ) & bus_info.ce1_size ) == 0 ) {
|
||||
bus_info.ce1_cfg = FALSE;
|
||||
bus_info.ce1_sz_cfg = FALSE;
|
||||
bus_remap();
|
||||
} else if ( bus_info.nce3_cfg &&
|
||||
( ( adr ^ bus_info.nce3_base ) & bus_info.nce3_size ) == 0 ) {
|
||||
} else if ( bus_info.nce3_cfg && ( ( adr ^ bus_info.nce3_base ) & bus_info.nce3_size ) == 0 ) {
|
||||
bus_info.nce3_cfg = FALSE;
|
||||
bus_info.nce3_sz_cfg = FALSE;
|
||||
bus_remap();
|
||||
}
|
||||
}
|
||||
|
||||
void bus_reset( void ) {
|
||||
void bus_reset( void )
|
||||
{
|
||||
bus_info.hdw_base = 0x00000;
|
||||
bus_info.hdw_cfg = FALSE;
|
||||
|
||||
|
@ -431,7 +411,8 @@ void bus_reset( void ) {
|
|||
bus_remap();
|
||||
}
|
||||
|
||||
address bus_get_id( void ) {
|
||||
address bus_get_id( void )
|
||||
{
|
||||
if ( !bus_info.hdw_cfg ) {
|
||||
return bus_info.hdw_base | 0x00019;
|
||||
} else if ( !bus_info.ram_sz_cfg ) {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "types.h"
|
||||
|
||||
#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_WRITE( adr ) ( write_map[ SEG_OF( adr ) ] != NULL )
|
||||
#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_mode;
|
||||
|
||||
static void set_lcd_color( int i, int v ) {
|
||||
// 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].b = (lcd_0_b * (255 - v) + lcd_1_b * v) / 255;
|
||||
}
|
||||
/* static void set_lcd_color( int i, int v ) { */
|
||||
/* // 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].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;
|
||||
|
||||
while ( i ) {
|
||||
|
@ -69,10 +70,10 @@ static int exp_color( int i ) { return i * 255 / 127; }
|
|||
|
||||
typedef int ( *lcd_color_func )( int i );
|
||||
|
||||
lcd_color_func lcd_color_functions[] = { simple_color, gray4_color, gray8_color,
|
||||
exp_color };
|
||||
lcd_color_func lcd_color_functions[] = { simple_color, gray4_color, gray8_color, exp_color };
|
||||
|
||||
void build_lcd_palette( void ) {
|
||||
void build_lcd_palette( void )
|
||||
{
|
||||
/*
|
||||
int i;
|
||||
|
||||
|
@ -83,7 +84,8 @@ void build_lcd_palette( void ) {
|
|||
// 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_g = g0 >> 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();
|
||||
}
|
||||
|
||||
void color_lcd_mode( int mode ) {
|
||||
void color_lcd_mode( int mode )
|
||||
{
|
||||
lcd_mode = mode;
|
||||
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) {
|
||||
// palette[color[i]].r = r >> 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;
|
||||
|
||||
// if (bitmap_color_depth(screen) == 8) {
|
||||
|
|
|
@ -28,12 +28,7 @@
|
|||
#ifndef __COLOR_H
|
||||
#define __COLOR_H
|
||||
|
||||
enum LCD_Modes {
|
||||
LCD_MODE_SIMPLE,
|
||||
LCD_MODE_GRAY4,
|
||||
LCD_MODE_GRAY8,
|
||||
LCD_MODE_EXP
|
||||
};
|
||||
enum LCD_Modes { LCD_MODE_SIMPLE, LCD_MODE_GRAY4, LCD_MODE_GRAY8, LCD_MODE_EXP };
|
||||
|
||||
enum Colors {
|
||||
C_BACKGROUND,
|
||||
|
|
12
src/cpu.c
12
src/cpu.c
|
@ -36,7 +36,8 @@ Cpu cpu;
|
|||
|
||||
#define MAX_OPC_LEN 21
|
||||
|
||||
void cpu_interrupt( void ) {
|
||||
void cpu_interrupt( void )
|
||||
{
|
||||
printf( "cpu_interrupt\n" );
|
||||
if ( cpu.inte ) {
|
||||
cpu.inte = FALSE;
|
||||
|
@ -46,7 +47,8 @@ void cpu_interrupt( void ) {
|
|||
}
|
||||
}
|
||||
|
||||
static void decode( byte* ptr ) {
|
||||
static void decode( byte* ptr )
|
||||
{
|
||||
Opcode* op = opcodes;
|
||||
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* ptr;
|
||||
static dword old_map_cnt;
|
||||
static address len;
|
||||
static address adr;
|
||||
|
||||
if ( cpu.pc < adr || adr + len < cpu.pc + MAX_OPC_LEN ||
|
||||
bus_info.map_cnt != old_map_cnt || !ptr ) {
|
||||
if ( cpu.pc < adr || adr + len < cpu.pc + MAX_OPC_LEN || bus_info.map_cnt != old_map_cnt || !ptr ) {
|
||||
len = MAX_OPC_LEN;
|
||||
adr = cpu.pc;
|
||||
ptr = bus_fast_peek( buffer, adr, &len );
|
||||
|
|
18
src/disasm.c
18
src/disasm.c
|
@ -58,7 +58,8 @@ static const char* f_tab[ 8 ] = { "P", "WP", "XS", "X", "S", "M", "B", "W" };
|
|||
} \
|
||||
} while ( 0 )
|
||||
|
||||
static __inline int nib_to_signed( byte* nib, int len ) {
|
||||
static __inline int nib_to_signed( byte* nib, int len )
|
||||
{
|
||||
int x;
|
||||
|
||||
len--;
|
||||
|
@ -72,7 +73,8 @@ static __inline int nib_to_signed( byte* nib, int len ) {
|
|||
return x;
|
||||
}
|
||||
|
||||
static void expand( char* dest, char* src, byte* ptr ) {
|
||||
static void expand( char* dest, char* src, byte* ptr )
|
||||
{
|
||||
int i, n;
|
||||
int x;
|
||||
|
||||
|
@ -203,8 +205,7 @@ static void expand( char* dest, char* src, byte* ptr ) {
|
|||
|
||||
case 'i': // R-register number
|
||||
i = *src++ - '0';
|
||||
*dest++ = '0' + ( ( ptr[ i ] & 7 ) > 4 ? ptr[ i ] & 3
|
||||
: ptr[ i ] & 7 );
|
||||
*dest++ = '0' + ( ( ptr[ i ] & 7 ) > 4 ? ptr[ i ] & 3 : ptr[ i ] & 7 );
|
||||
break;
|
||||
|
||||
case '#': // "#" or "=" for comparisons
|
||||
|
@ -281,7 +282,8 @@ static void expand( char* dest, char* src, byte* ptr ) {
|
|||
*dest = '\0';
|
||||
}
|
||||
|
||||
char* disassemble( byte* ptr ) {
|
||||
char* disassemble( byte* ptr )
|
||||
{
|
||||
static char buffer[ 64 ];
|
||||
|
||||
Opcode* op = opcodes;
|
||||
|
@ -299,7 +301,8 @@ char* disassemble( byte* ptr ) {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
char* nib_to_hex( byte* nib, int n ) {
|
||||
char* nib_to_hex( byte* nib, int n )
|
||||
{
|
||||
static char buffer[ 17 ];
|
||||
|
||||
buffer[ n ] = '\0';
|
||||
|
@ -309,7 +312,8 @@ char* nib_to_hex( byte* nib, int n ) {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
char* nib_to_hex_rev( byte* nib, int n ) {
|
||||
char* nib_to_hex_rev( byte* nib, int n )
|
||||
{
|
||||
static char buffer[ 17 ];
|
||||
|
||||
buffer[ n ] = '\0';
|
||||
|
|
|
@ -54,7 +54,7 @@ static boolean in_menu;
|
|||
static byte off_cur_line;
|
||||
static byte off_line;
|
||||
static int off_cnt;
|
||||
static boolean shouldClear = TRUE;
|
||||
/* static boolean shouldClear = TRUE; */
|
||||
static boolean shouldRender = FALSE;
|
||||
static int screen_draw_count = 0;
|
||||
static boolean drawGS = FALSE;
|
||||
|
@ -65,7 +65,8 @@ extern SDL_Texture* texTarget;
|
|||
extern SDL_Texture* tex2Target;
|
||||
extern SDL_Texture* faceplateTexture;
|
||||
|
||||
void clearLCD() {
|
||||
void clearLCD()
|
||||
{
|
||||
// SDL_SetRenderDrawColor(renderer, 0x44, 0x44, 0x66, 0xFF);
|
||||
// SDL_SetRenderDrawColor(renderer, 119, 172, 130, 0xFF); // vert clair
|
||||
SDL_SetRenderDrawColor( renderer, 48, 68, 90, 0xFF ); // bleu foncé
|
||||
|
@ -79,7 +80,8 @@ void clearLCD() {
|
|||
// SDL_SetRenderTarget(renderer, texTarget);
|
||||
}
|
||||
|
||||
void endLCD() {
|
||||
void endLCD()
|
||||
{
|
||||
// Reset render target
|
||||
// SDL_SetRenderTarget( renderer, NULL );
|
||||
|
||||
|
@ -95,24 +97,27 @@ void endLCD() {
|
|||
pcalc_show();
|
||||
}
|
||||
|
||||
void renderLCD() {
|
||||
void renderLCD()
|
||||
{
|
||||
// SDL_RenderPresent( renderer );
|
||||
}
|
||||
|
||||
static void fade_lcd_line( int y ) {
|
||||
/*
|
||||
byte *lcd_line0 = (byte *)lcd->line[y*2];
|
||||
byte *lcd_line1 = (byte *)lcd->line[y*2+1];
|
||||
int x = 0;
|
||||
/* static void fade_lcd_line( int y ) { */
|
||||
/* /\* */
|
||||
/* byte *lcd_line0 = (byte *)lcd->line[y*2]; */
|
||||
/* byte *lcd_line1 = (byte *)lcd->line[y*2+1]; */
|
||||
/* int x = 0; */
|
||||
|
||||
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] >> 1); x++;
|
||||
}
|
||||
/* 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] >> 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);
|
||||
|
||||
int x = 0;
|
||||
|
@ -141,8 +146,7 @@ static address draw_lcd_line( address adr, int y ) {
|
|||
bit = 4;
|
||||
}
|
||||
|
||||
byte pixel =
|
||||
( ( data & 1 ) << 6 ); // (lcd_line0[x*2] >> 1) | ((data & 1) << 6);
|
||||
byte pixel = ( ( data & 1 ) << 6 ); // (lcd_line0[x*2] >> 1) | ((data & 1) << 6);
|
||||
if ( pixel != '\0' ) {
|
||||
pixel = '\3';
|
||||
// printf("%c ", pixel);
|
||||
|
@ -203,21 +207,23 @@ static address draw_lcd_line( address adr, int y ) {
|
|||
x++;
|
||||
}
|
||||
|
||||
return ( adr + 0x22 + ( !in_menu && ( display_offset & 4 ) ? 2 : 0 ) ) &
|
||||
0xFFFFF;
|
||||
return ( adr + 0x22 + ( !in_menu && ( display_offset & 4 ) ? 2 : 0 ) ) & 0xFFFFF;
|
||||
}
|
||||
|
||||
void display_init( void ) {
|
||||
void display_init( void )
|
||||
{
|
||||
// lcd = create_bitmap_ex(8, 131*2, 64*2);
|
||||
// clear_to_color(lcd, 0);
|
||||
}
|
||||
|
||||
void display_exit( void ) {
|
||||
void display_exit( void )
|
||||
{
|
||||
// destroy_bitmap (lcd);
|
||||
// lcd = NULL;
|
||||
}
|
||||
|
||||
void display_show() {
|
||||
void display_show()
|
||||
{
|
||||
SDL_SetRenderDrawColor( renderer, 48, 68, 90, 0xFF ); // bleu foncé
|
||||
SDL_RenderClear( renderer );
|
||||
|
||||
|
@ -239,8 +245,7 @@ void display_show() {
|
|||
printf( "error\n" );
|
||||
}
|
||||
|
||||
if ( SDL_LockTexture( texTarget, NULL, ( void** )&pixels, &pitch ) !=
|
||||
0 ) {
|
||||
if ( SDL_LockTexture( texTarget, NULL, ( void** )&pixels, &pitch ) != 0 ) {
|
||||
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
|
||||
// place it.
|
||||
Uint32 pixelPosition =
|
||||
y * ( pitch / sizeof( unsigned int ) ) + x;
|
||||
Uint32 pixelPosition = y * ( pitch / sizeof( unsigned int ) ) + x;
|
||||
|
||||
pixels[ pixelPosition ] = color;
|
||||
}
|
||||
|
@ -303,7 +307,8 @@ void display_show() {
|
|||
SDL_RenderPresent( renderer );
|
||||
}
|
||||
|
||||
void display_update( void ) {
|
||||
void display_update( void )
|
||||
{
|
||||
if ( !display_enable && !off_cnt ) { /* Turn off display */
|
||||
off_cnt = 1;
|
||||
off_cur_line = off_line = display_line_count;
|
||||
|
@ -322,7 +327,7 @@ void display_update( void ) {
|
|||
// acquire_screen();
|
||||
// scare_mouse_area(LCD_X, LCD_Y+display_line_count*2, 131*2, 2);
|
||||
// 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();
|
||||
|
||||
if ( !in_menu ) {
|
||||
|
|
|
@ -57,35 +57,41 @@ typedef struct {
|
|||
void ( *proc )( void );
|
||||
} TimerEvent;
|
||||
|
||||
static CycleEvent cycle_events[] = { { 0, 16, timer1_update },
|
||||
static CycleEvent cycle_events[] = {
|
||||
{0, 16, timer1_update },
|
||||
#ifndef TRUE_TIMER2
|
||||
{ 0, 8192, timer2_update },
|
||||
#endif
|
||||
{ 0, 4096, display_update },
|
||||
{ 0, 0, NULL } };
|
||||
{ 0, 4096, display_update},
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
||||
static TimerEvent timer_events[] = {
|
||||
{ 0, 1000000 / 20 /*BPS_TO_TIMER(20)*/, FALSE, gui_update },
|
||||
{ 0, 1000000 /*BPS_TO_TIMER(1)*/, FALSE, true_speed_proc },
|
||||
{0, 1000000 / 20 /*BPS_TO_TIMER(20)*/, FALSE, gui_update },
|
||||
{ 0, 1000000 /*BPS_TO_TIMER(1)*/, FALSE, true_speed_proc},
|
||||
#ifdef TRUE_TIMER2
|
||||
{ 0, 1000000 / 8192 /*BPS_TO_TIMER(8192)*/, FALSE, timer2_update },
|
||||
#endif
|
||||
{ 0, 0, FALSE, NULL } };
|
||||
{ 0, 0, FALSE, NULL }
|
||||
};
|
||||
|
||||
volatile boolean please_exit = FALSE;
|
||||
dword emulator_speed = 4000000;
|
||||
static int emulator_state = EMULATOR_RUN; // EMULATOR_STOP;
|
||||
|
||||
void true_speed_proc( void ) {
|
||||
void true_speed_proc( void )
|
||||
{
|
||||
static dword last_cycles;
|
||||
|
||||
pdebug_draw_true_speed( cpu.cycles - last_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;
|
||||
|
||||
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;
|
||||
|
||||
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" );
|
||||
#ifdef TRUE_TIMER2
|
||||
if ( state != EMULATOR_STOP ) {
|
||||
|
@ -129,7 +137,8 @@ void emulator_set_state( int state ) {
|
|||
|
||||
int emulator_get_state( void ) { return emulator_state; }
|
||||
|
||||
void emulator_init( void ) {
|
||||
void emulator_init( void )
|
||||
{
|
||||
static boolean locked = FALSE;
|
||||
|
||||
bus_init();
|
||||
|
@ -142,12 +151,14 @@ void emulator_init( void ) {
|
|||
}
|
||||
}
|
||||
|
||||
void emulator_exit( void ) {
|
||||
void emulator_exit( void )
|
||||
{
|
||||
display_exit();
|
||||
bus_exit();
|
||||
}
|
||||
|
||||
boolean emulator_run( void ) {
|
||||
boolean emulator_run( void )
|
||||
{
|
||||
CycleEvent* cep;
|
||||
TimerEvent* tep;
|
||||
dword delta;
|
||||
|
|
86
src/gui.c
86
src/gui.c
|
@ -37,16 +37,12 @@
|
|||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#ifdef SDL_TTF
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#endif
|
||||
|
||||
extern SDL_Renderer* renderer;
|
||||
extern SDL_Texture* faceplateTexture;
|
||||
#ifdef SDL_TTF
|
||||
extern TTF_Font* ttffont;
|
||||
extern TTF_Font* ttffont2;
|
||||
#endif
|
||||
|
||||
SDL_Surface* surfA[ 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_Texture* letterTexture = textA[ index ];
|
||||
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" );
|
||||
#ifdef SDL_TTF
|
||||
if ( ttffont == NULL ) {
|
||||
printf( "init texts error Font NULL\n" );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
SDL_Color couleurBlanche = { 255, 255, 255 };
|
||||
SDL_Color couleurGreen = { 125, 215, 235 };
|
||||
SDL_Color couleurPurple = { 191, 192, 236 };
|
||||
SDL_Color couleurYellow = { 128, 108, 29 };
|
||||
SDL_Color couleurBlanche = { 255, 255, 255, 255 };
|
||||
SDL_Color couleurGreen = { 125, 215, 235, 255 };
|
||||
SDL_Color couleurPurple = { 191, 192, 236, 255 };
|
||||
SDL_Color couleurYellow = { 128, 108, 29, 255 };
|
||||
|
||||
#ifdef SDL_TTF
|
||||
int i = 0;
|
||||
Button* buttons = calcbuttons;
|
||||
while ( buttons->text ) {
|
||||
SDL_Surface* s = NULL;
|
||||
SDL_Texture* t = NULL;
|
||||
if ( buttons->text && strcmp( buttons->text, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont, buttons->text,
|
||||
couleurBlanche );
|
||||
s = TTF_RenderUTF8_Blended( ttffont, buttons->text, couleurBlanche );
|
||||
if ( s ) {
|
||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||
}
|
||||
|
@ -170,8 +164,7 @@ void gui_initKeyboard( Button* calcbuttons ) {
|
|||
SDL_Surface* s = NULL;
|
||||
SDL_Texture* t = NULL;
|
||||
if ( buttons->textB && strcmp( buttons->textB, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textB,
|
||||
couleurPurple );
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textB, couleurPurple );
|
||||
if ( s ) {
|
||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||
}
|
||||
|
@ -188,8 +181,7 @@ void gui_initKeyboard( Button* calcbuttons ) {
|
|||
SDL_Surface* s = NULL;
|
||||
SDL_Texture* t = NULL;
|
||||
if ( buttons->textC && strcmp( buttons->textC, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textC,
|
||||
couleurGreen );
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textC, couleurGreen );
|
||||
if ( s ) {
|
||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||
}
|
||||
|
@ -206,8 +198,7 @@ void gui_initKeyboard( Button* calcbuttons ) {
|
|||
SDL_Surface* s = NULL;
|
||||
SDL_Texture* t = NULL;
|
||||
if ( buttons->textD && strcmp( buttons->textD, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textD,
|
||||
couleurYellow );
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textD, couleurYellow );
|
||||
if ( s ) {
|
||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||
}
|
||||
|
@ -217,13 +208,12 @@ void gui_initKeyboard( Button* calcbuttons ) {
|
|||
i++;
|
||||
buttons++;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void gui_init( void ) {}
|
||||
|
||||
void gui_exit( void ) {
|
||||
void gui_exit( void )
|
||||
{
|
||||
int 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;
|
||||
|
||||
for ( i = PANEL_COUNT; i >= 0; i-- ) {
|
||||
if ( panels[ i ].flags & PANEL_FLAG_VISIBLE && x >= panels[ i ].x &&
|
||||
x < panels[ i ].x + panels[ i ].w && y >= panels[ i ].y &&
|
||||
if ( panels[ i ].flags & PANEL_FLAG_VISIBLE && x >= panels[ i ].x && x < panels[ i ].x + panels[ i ].w && y >= panels[ i ].y &&
|
||||
y < panels[ i ].y + panels[ i ].h ) {
|
||||
break;
|
||||
}
|
||||
|
@ -244,7 +234,8 @@ static __inline int panel_at( int x, int y ) {
|
|||
return i;
|
||||
}
|
||||
|
||||
void gui_update( void ) {
|
||||
void gui_update( void )
|
||||
{
|
||||
/*
|
||||
static int down_panel = -1;
|
||||
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)) {
|
||||
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) {
|
||||
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_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 );
|
||||
|
||||
int c;
|
||||
|
||||
c = color[ ( b->flags & BUTTON_PUSHED ) ? C_BUTTON_PUSHED : C_BUTTON_BACK ];
|
||||
/* int c = color[ ( b->flags & BUTTON_PUSHED ) ? C_BUTTON_PUSHED :
|
||||
* C_BUTTON_BACK ]; */
|
||||
|
||||
if ( b->flags & BUTTON_PUSHED ) {
|
||||
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 ) {
|
||||
button_draw( 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 ) {
|
||||
// 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 &&
|
||||
y < b->y * 2 + b->h * 2 ) {
|
||||
if ( x >= b->x * 2 && x < b->x * 2 + b->w * 2 && y >= b->y * 2 && y < b->y * 2 + b->h * 2 ) {
|
||||
return b;
|
||||
}
|
||||
b++;
|
||||
|
@ -352,7 +346,8 @@ static __inline Button* find_button( Button* b, int x, int y ) {
|
|||
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 );
|
||||
if ( !b ) {
|
||||
return 0;
|
||||
|
@ -360,8 +355,7 @@ int button_mouse_down( Button* buttons, int mx, int my, int mb ) {
|
|||
printf( "Press %s\n", b->text );
|
||||
|
||||
if ( !( b->flags & BUTTON_DISABLED ) ) {
|
||||
if ( ( mb == 2 && ( b->flags & BUTTON_B2TOGGLE ) ) ||
|
||||
( mb == 1 && ( b->flags & BUTTON_B1TOGGLE ) ) ) {
|
||||
if ( ( mb == 2 && ( b->flags & BUTTON_B2TOGGLE ) ) || ( mb == 1 && ( b->flags & BUTTON_B1TOGGLE ) ) ) {
|
||||
|
||||
if ( 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;
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
Button* b = find_button( buttons, mx, my );
|
||||
int ret = ( b != NULL );
|
||||
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 ( mb == 1 && ( b->flags & BUTTON_PUSHED ) &&
|
||||
!( b->flags & BUTTON_B1TOGGLE ) ) {
|
||||
if ( mb == 1 && ( b->flags & BUTTON_PUSHED ) && !( b->flags & BUTTON_B1TOGGLE ) ) {
|
||||
b->flags &= ~BUTTON_PUSHED;
|
||||
// button_draw(bmp, b);
|
||||
if ( b->up )
|
||||
|
@ -403,8 +396,7 @@ int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my,
|
|||
}
|
||||
if ( mb == 1 ) {
|
||||
for ( b = buttons; b->text; b++ ) {
|
||||
if ( ( b->flags & ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) ==
|
||||
( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) {
|
||||
if ( ( b->flags & ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) == ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) {
|
||||
b->flags &= ~BUTTON_PUSHED;
|
||||
// button_draw(bmp, b);
|
||||
if ( b->up )
|
||||
|
|
16
src/gui.h
16
src/gui.h
|
@ -28,19 +28,11 @@
|
|||
#ifndef __GUI_H
|
||||
#define __GUI_H
|
||||
|
||||
/* #define SDL_TTF */
|
||||
#define FONT_FILENAME "/usr/share/fonts/TTF/unifont.ttf"
|
||||
|
||||
#include "types.h"
|
||||
|
||||
enum Panels {
|
||||
PANEL_MENU,
|
||||
PANEL_CALC,
|
||||
PANEL_DEBUG,
|
||||
PANEL_FILES,
|
||||
PANEL_ABOUT,
|
||||
PANEL_COUNT
|
||||
};
|
||||
enum Panels { PANEL_MENU, PANEL_CALC, PANEL_DEBUG, PANEL_FILES, PANEL_ABOUT, PANEL_COUNT };
|
||||
|
||||
typedef struct {
|
||||
int index;
|
||||
|
@ -64,8 +56,7 @@ typedef struct {
|
|||
#define BUTTON_DISABLED 0x02 // If set the button will be grayed out
|
||||
#define BUTTON_B1TOGGLE 0x04 // Mouse button 1 toggles this button
|
||||
#define BUTTON_B2TOGGLE 0x08 // Mouse button 2 toggles this button
|
||||
#define BUTTON_B1RELEASE \
|
||||
0x10 // Releaseing mouse button 1 anywhere unpushes the button
|
||||
#define BUTTON_B1RELEASE 0x10 // Releaseing mouse button 1 anywhere unpushes the button
|
||||
|
||||
void gui_initKeyboard( Button* calcbuttons );
|
||||
void gui_init( void );
|
||||
|
@ -78,8 +69,7 @@ void gui_hide_panel( int i );
|
|||
void button_draw(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 mb );
|
||||
int button_mouse_down( /*BITMAP *bmp,*/ Button* butons, int mx, int my, int mb );
|
||||
int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my, int mb );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,8 @@ void hdw_init( void ) {}
|
|||
|
||||
void hdw_exit( void ) {}
|
||||
|
||||
byte hdw_read_nibble( address adr ) {
|
||||
byte hdw_read_nibble( address adr )
|
||||
{
|
||||
switch ( adr ) {
|
||||
|
||||
case 0x00:
|
||||
|
@ -59,8 +60,7 @@ byte hdw_read_nibble( address adr ) {
|
|||
case 0x28:
|
||||
return display_line_count & 0xF;
|
||||
case 0x29:
|
||||
return ( display_line_count >> 4 ) | ( hdw_ram[ 0x29 ] & 0x4 ) |
|
||||
( bus_info.da19 ? 0x8 : 0x0 );
|
||||
return ( display_line_count >> 4 ) | ( hdw_ram[ 0x29 ] & 0x4 ) | ( bus_info.da19 ? 0x8 : 0x0 );
|
||||
|
||||
case 0x2E:
|
||||
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;
|
||||
|
||||
switch ( adr ) {
|
||||
|
|
|
@ -33,7 +33,8 @@ boolean kbd_on;
|
|||
|
||||
static byte kbd_row[ 9 ];
|
||||
|
||||
static void update_in( void ) {
|
||||
static void update_in( void )
|
||||
{
|
||||
byte in = 0;
|
||||
|
||||
// TODO: Emulate real HP48 keyboard circuit
|
||||
|
@ -65,16 +66,15 @@ static void update_in( void ) {
|
|||
|
||||
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 ];
|
||||
kbd_row[ row ] |= 1 << col;
|
||||
update_in();
|
||||
if ( cpu.shutdown && no_key &&
|
||||
( cpu.in[ 0 ] || cpu.in[ 1 ] || cpu.in[ 3 ] ) ) {
|
||||
if ( cpu.shutdown && no_key && ( cpu.in[ 0 ] || cpu.in[ 1 ] || cpu.in[ 3 ] ) ) {
|
||||
cpu.shutdown = FALSE;
|
||||
}
|
||||
if ( cpu.keyscan && no_key &&
|
||||
( cpu.in[ 0 ] || cpu.in[ 1 ] || cpu.in[ 3 ] ) ) {
|
||||
if ( cpu.keyscan && no_key && ( cpu.in[ 0 ] || cpu.in[ 1 ] || cpu.in[ 3 ] ) ) {
|
||||
if ( cpu.inte ) {
|
||||
cpu.keyintp = FALSE;
|
||||
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 );
|
||||
update_in();
|
||||
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 ];
|
||||
kbd_on = TRUE;
|
||||
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;
|
||||
cpu.in[ 3 ] &= ~8;
|
||||
}
|
||||
|
|
242
src/main.c
242
src/main.c
|
@ -41,13 +41,7 @@
|
|||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#ifdef SDL_TTF
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
const int SCREEN_WIDTH = 524;
|
||||
const int SCREEN_HEIGHT = 750;
|
||||
|
@ -58,10 +52,8 @@ SDL_Texture* texTarget = NULL;
|
|||
SDL_Texture* tex2Target = NULL;
|
||||
SDL_Texture* faceplateTexture = NULL;
|
||||
|
||||
#ifdef SDL_TTF
|
||||
TTF_Font* ttffont = NULL;
|
||||
TTF_Font* ttffont2 = NULL;
|
||||
#endif
|
||||
|
||||
SDL_TimerID my_timer0_id;
|
||||
SDL_TimerID my_timer1_id;
|
||||
|
@ -113,89 +105,90 @@ unsigned int delay_timer4 = 8192; // 8192;
|
|||
unsigned int lastTime_timer5 = 0;
|
||||
unsigned int delay_timer5 = 60; // 60 fps
|
||||
|
||||
Uint32 my_callbackfunc0( Uint32 interval, void* param ) {
|
||||
SDL_Event event;
|
||||
SDL_UserEvent userevent;
|
||||
/* Uint32 my_callbackfunc0( Uint32 interval, void* param ) { */
|
||||
/* SDL_Event event; */
|
||||
/* SDL_UserEvent userevent; */
|
||||
|
||||
userevent.type = SDL_USEREVENT;
|
||||
userevent.code = 1;
|
||||
userevent.data1 = &gui_update;
|
||||
userevent.data2 = NULL; // param;
|
||||
/* userevent.type = SDL_USEREVENT; */
|
||||
/* userevent.code = 1; */
|
||||
/* userevent.data1 = &gui_update; */
|
||||
/* userevent.data2 = NULL; // param; */
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
event.user = userevent;
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
SDL_PushEvent( &event );
|
||||
return ( interval );
|
||||
}
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
Uint32 my_callbackfunc1( Uint32 interval, void* param ) {
|
||||
SDL_Event event;
|
||||
SDL_UserEvent userevent;
|
||||
/* Uint32 my_callbackfunc1( Uint32 interval, void* param ) { */
|
||||
/* SDL_Event event; */
|
||||
/* SDL_UserEvent userevent; */
|
||||
|
||||
userevent.type = SDL_USEREVENT;
|
||||
userevent.code = 1;
|
||||
userevent.data1 = NULL; //&display_update;
|
||||
userevent.data2 = NULL; // param;
|
||||
/* userevent.type = SDL_USEREVENT; */
|
||||
/* userevent.code = 1; */
|
||||
/* userevent.data1 = NULL; //&display_update; */
|
||||
/* userevent.data2 = NULL; // param; */
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
event.user = userevent;
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
SDL_PushEvent( &event );
|
||||
return ( interval );
|
||||
}
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
Uint32 my_callbackfunc2( Uint32 interval, void* param ) {
|
||||
SDL_Event event;
|
||||
SDL_UserEvent userevent;
|
||||
/* Uint32 my_callbackfunc2( Uint32 interval, void* param ) { */
|
||||
/* SDL_Event event; */
|
||||
/* SDL_UserEvent userevent; */
|
||||
|
||||
userevent.type = SDL_USEREVENT;
|
||||
userevent.code = 2;
|
||||
userevent.data1 = &true_speed_proc;
|
||||
userevent.data2 = NULL; // param;
|
||||
/* userevent.type = SDL_USEREVENT; */
|
||||
/* userevent.code = 2; */
|
||||
/* userevent.data1 = &true_speed_proc; */
|
||||
/* userevent.data2 = NULL; // param; */
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
event.user = userevent;
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
SDL_PushEvent( &event );
|
||||
return ( interval );
|
||||
}
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
Uint32 my_callbackfunc3( Uint32 interval, void* param ) {
|
||||
SDL_Event event;
|
||||
SDL_UserEvent userevent;
|
||||
/* Uint32 my_callbackfunc3( Uint32 interval, void* param ) { */
|
||||
/* SDL_Event event; */
|
||||
/* SDL_UserEvent userevent; */
|
||||
|
||||
userevent.type = SDL_USEREVENT;
|
||||
userevent.code = 3;
|
||||
userevent.data1 = &timer1_update;
|
||||
userevent.data2 = NULL; // param;
|
||||
/* userevent.type = SDL_USEREVENT; */
|
||||
/* userevent.code = 3; */
|
||||
/* userevent.data1 = &timer1_update; */
|
||||
/* userevent.data2 = NULL; // param; */
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
event.user = userevent;
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
SDL_PushEvent( &event );
|
||||
return ( interval );
|
||||
}
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
Uint32 my_callbackfunc4( Uint32 interval, void* param ) {
|
||||
SDL_Event event;
|
||||
SDL_UserEvent userevent;
|
||||
/* Uint32 my_callbackfunc4( Uint32 interval, void* param ) { */
|
||||
/* SDL_Event event; */
|
||||
/* SDL_UserEvent userevent; */
|
||||
|
||||
userevent.type = SDL_USEREVENT;
|
||||
userevent.code = 4;
|
||||
userevent.data1 = &display_show; // timer2_update;
|
||||
userevent.data2 = NULL; // param;
|
||||
/* userevent.type = SDL_USEREVENT; */
|
||||
/* userevent.code = 4; */
|
||||
/* userevent.data1 = &display_show; // timer2_update; */
|
||||
/* userevent.data2 = NULL; // param; */
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
event.user = userevent;
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
SDL_PushEvent( &event );
|
||||
return ( interval );
|
||||
}
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
static int fullscreen = FALSE;
|
||||
|
||||
static void parse_args( int argc, char* argv[] ) {
|
||||
static void parse_args( int argc, char* argv[] )
|
||||
{
|
||||
while ( --argc ) {
|
||||
argv++;
|
||||
if ( argv[ 0 ][ 0 ] == '-' ) {
|
||||
|
@ -211,44 +204,35 @@ static void parse_args( int argc, char* argv[] ) {
|
|||
}
|
||||
}
|
||||
|
||||
static void program_init( void ) {
|
||||
static void program_init( void )
|
||||
{
|
||||
if ( SDL_Init( SDL_INIT_VIDEO | IMG_INIT_PNG | SDL_INIT_TIMER ) < 0 ) {
|
||||
printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SDL_TTF
|
||||
if ( TTF_Init() == -1 ) {
|
||||
fprintf( stderr, "Erreur d'initialisation de TTF_Init : %s\n",
|
||||
TTF_GetError() );
|
||||
fprintf( stderr, "Erreur d'initialisation de TTF_Init : %s\n", TTF_GetError() );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
ttffont = TTF_OpenFont( FONT_FILENAME, 14 );
|
||||
ttffont2 = TTF_OpenFont( FONT_FILENAME, 10 );
|
||||
#endif
|
||||
|
||||
window = SDL_CreateWindow( "jsEmu48", SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH,
|
||||
SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
|
||||
window = SDL_CreateWindow( "jsEmu48", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
|
||||
if ( window == NULL ) {
|
||||
printf( "Window could not be created! SDL_Error: %s\n",
|
||||
SDL_GetError() );
|
||||
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
|
||||
return;
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(
|
||||
window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
|
||||
renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
|
||||
if ( renderer == NULL ) {
|
||||
printf( "Erreur lors de la creation d'un renderer : %s",
|
||||
SDL_GetError() );
|
||||
printf( "Erreur lors de la creation d'un renderer : %s", SDL_GetError() );
|
||||
return;
|
||||
}
|
||||
|
||||
tex2Target = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_TEXTUREACCESS_TARGET, 504, 1124 );
|
||||
texTarget = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_TEXTUREACCESS_STREAMING, 504, 1124 );
|
||||
tex2Target = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, 504, 1124 );
|
||||
texTarget = SDL_CreateTexture( renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, 504, 1124 );
|
||||
|
||||
/*
|
||||
SDL_Surface * faceplate = IMG_Load("48face5.png");
|
||||
|
@ -275,16 +259,19 @@ static void program_init( void ) {
|
|||
SDL_ready = TRUE;
|
||||
}
|
||||
|
||||
void start_timers() {
|
||||
void start_timers()
|
||||
{
|
||||
printf( "start_timers\n" );
|
||||
// my_timer0_id = SDL_AddTimer(100, my_callbackfunc0, NULL); // gui_update
|
||||
// my_timer1_id = SDL_AddTimer(50, my_callbackfunc1, NULL); // display
|
||||
// my_timer2_id = SDL_AddTimer(1000, my_callbackfunc2, NULL); // cpu real
|
||||
//speed my_timer3_id = SDL_AddTimer(62, my_callbackfunc3, NULL); // timer1
|
||||
// my_timer4_id = SDL_AddTimer(500, my_callbackfunc4, NULL); // timer2
|
||||
// speed my_timer3_id = SDL_AddTimer(62, my_callbackfunc3, NULL); //
|
||||
// timer1 my_timer4_id = SDL_AddTimer(500, my_callbackfunc4, NULL); //
|
||||
// timer2
|
||||
}
|
||||
|
||||
static void program_exit( void ) {
|
||||
static void program_exit( void )
|
||||
{
|
||||
/*
|
||||
//SDL_RemoveTimer(my_timer0_id);
|
||||
SDL_RemoveTimer(my_timer1_id);
|
||||
|
@ -292,38 +279,41 @@ static void program_exit( void ) {
|
|||
SDL_RemoveTimer(my_timer3_id);
|
||||
SDL_RemoveTimer(my_timer4_id);
|
||||
*/
|
||||
#ifdef SDL_TTF
|
||||
TTF_CloseFont( ttffont );
|
||||
TTF_CloseFont( ttffont2 );
|
||||
TTF_Quit();
|
||||
#endif
|
||||
|
||||
SDL_DestroyRenderer( renderer );
|
||||
SDL_DestroyWindow( window );
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
boolean refreshSDL() {
|
||||
boolean refreshSDL()
|
||||
{
|
||||
SDL_Event event;
|
||||
// SDL_WaitEvent(&event);
|
||||
while ( SDL_PollEvent( &event ) )
|
||||
// if(SDL_PollEvent(&event))
|
||||
{
|
||||
switch ( event.type ) {
|
||||
case SDL_MOUSEBUTTONUP: {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
// printf("mouse up %d %d\n", event.button.x, event.button.y);
|
||||
|
||||
pcalc_up( event.button.x, event.button.y, 1 );
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN: {
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
{
|
||||
// printf("mouse down %d %d\n", event.button.x, event.button.y);
|
||||
|
||||
pcalc_down( event.button.x, event.button.y, 1 );
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
printf( "%d %d\n", event.key.keysym.sym,
|
||||
event.key.keysym.scancode );
|
||||
printf( "%d %d\n", event.key.keysym.sym, event.key.keysym.scancode );
|
||||
|
||||
pcalc_kb_down( event.key.keysym.scancode );
|
||||
|
||||
|
@ -585,15 +575,18 @@ boolean refreshSDL() {
|
|||
*/
|
||||
break;
|
||||
|
||||
case SDL_USEREVENT: {
|
||||
case SDL_USEREVENT:
|
||||
{
|
||||
printf( "SDL_USEREVENT\n" );
|
||||
// if(event.user.code == 1)
|
||||
|
||||
// void (*p) (void*) = event.user.data1;
|
||||
// p(event.user.data2);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_QUIT: {
|
||||
case SDL_QUIT:
|
||||
{
|
||||
please_exit = TRUE;
|
||||
// emulator_state = EMULATOR_STOP;
|
||||
return FALSE;
|
||||
|
@ -603,7 +596,8 @@ boolean refreshSDL() {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void mainloop() {
|
||||
void mainloop()
|
||||
{
|
||||
if ( please_exit == TRUE ) {
|
||||
printf( "please exit\n" );
|
||||
return;
|
||||
|
@ -612,27 +606,8 @@ void mainloop() {
|
|||
|
||||
currentTime = SDL_GetTicks();
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
|
||||
currentTime_emu = currentTime;
|
||||
emuframecount = 0;
|
||||
|
||||
do {
|
||||
emuframecount++;
|
||||
emulator_run();
|
||||
|
||||
currentTime_emu = SDL_GetTicks() - currentTime;
|
||||
} while ( currentTime_emu < 2 );
|
||||
|
||||
// printf("EMU emuframecount = %d | time = %d\n", emuframecount,
|
||||
// currentTime_emu);
|
||||
|
||||
#else
|
||||
|
||||
emulator_run();
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
framecount++;
|
||||
|
||||
|
@ -686,16 +661,13 @@ void mainloop() {
|
|||
#endif
|
||||
|
||||
if ( refreshSDL() == FALSE ) {
|
||||
#ifdef EMSCRIPTEN
|
||||
printf( "emscripten_cancel_main_loop\n" );
|
||||
emscripten_cancel_main_loop();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] ) {
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
parse_args( argc, argv );
|
||||
|
||||
program_init();
|
||||
|
@ -704,27 +676,13 @@ int main( int argc, char* argv[] ) {
|
|||
|
||||
// start_timers();
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
printf( "emscripten_set_main_loop\n" );
|
||||
emscripten_set_main_loop( mainloop, 0, 1 );
|
||||
|
||||
// emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, 0);
|
||||
|
||||
// while(please_exit == FALSE) mainloop();
|
||||
#else
|
||||
printf( "NO emscripten_set_main_loop\n" );
|
||||
while ( please_exit == FALSE )
|
||||
mainloop();
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef EMSCRIPTEN
|
||||
printf("emscripten_set_main_loop\n");
|
||||
emscripten_set_main_loop(mainloop, 1000, 1);
|
||||
#else
|
||||
printf("NO emscripten_set_main_loop\n");
|
||||
while(please_exit == FALSE) mainloop();
|
||||
#endif
|
||||
*/
|
||||
gui_exit();
|
||||
emulator_exit();
|
||||
|
|
430
src/opcodes.c
430
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 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
|
||||
static const int regr[ 16 ] = { 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 regt[ 16 ] = { A, B, C, D, 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 regv[ 16 ] = { B, C, A, C, A, B, C, D,
|
||||
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 };
|
||||
static const int regs[ 16 ] = { B, C, A, C, A, B, C, D, 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 };
|
||||
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 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 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;
|
||||
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 ] ];
|
||||
if ( !( opc[ 3 ] & 8 ) ) {
|
||||
alu_and( REGrF( opc[ 3 ], opc[ 2 ] ), REGsF( opc[ 3 ], opc[ 2 ] ),
|
||||
len );
|
||||
alu_and( REGrF( opc[ 3 ], opc[ 2 ] ), REGsF( opc[ 3 ], opc[ 2 ] ), len );
|
||||
} else {
|
||||
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
|
||||
{
|
||||
address tmp = cpu.d[ opc[ 2 ] & 1 ];
|
||||
cpu.d[ opc[ 2 ] & 1 ] =
|
||||
nib_to_unsigned( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], 5 );
|
||||
cpu.d[ opc[ 2 ] & 1 ] = nib_to_unsigned( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], 5 );
|
||||
if ( opc[ 2 ] & 2 )
|
||||
unsigned_to_nib( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], tmp, 5 );
|
||||
cpu.pc += 3;
|
||||
|
@ -225,8 +219,7 @@ static void op13b( byte* opc ) // Di=rS / rDiEXS
|
|||
{
|
||||
address tmp = cpu.d[ opc[ 2 ] & 1 ];
|
||||
cpu.d[ opc[ 2 ] & 1 ] &= 0xF0000;
|
||||
cpu.d[ opc[ 2 ] & 1 ] |=
|
||||
nib_to_unsigned( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], 4 );
|
||||
cpu.d[ opc[ 2 ] & 1 ] |= nib_to_unsigned( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], 4 );
|
||||
if ( opc[ 2 ] & 2 )
|
||||
unsigned_to_nib( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], tmp, 4 );
|
||||
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
|
||||
{
|
||||
if ( !( opc[ 2 ] & 2 ) ) {
|
||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ],
|
||||
( opc[ 2 ] & 8 ) ? 2 : 5 );
|
||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ], ( opc[ 2 ] & 8 ) ? 2 : 5 );
|
||||
} else {
|
||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ],
|
||||
( opc[ 2 ] & 8 ) ? 2 : 5 );
|
||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ], ( opc[ 2 ] & 8 ) ? 2 : 5 );
|
||||
cpu.cycles++;
|
||||
}
|
||||
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
|
||||
{
|
||||
if ( !( opc[ 2 ] & 2 ) ) {
|
||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ] + fs[ opc[ 3 ] ],
|
||||
cpu.d[ opc[ 2 ] & 1 ], fl[ opc[ 3 ] ] );
|
||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ] + fs[ opc[ 3 ] ], cpu.d[ opc[ 2 ] & 1 ], fl[ opc[ 3 ] ] );
|
||||
} else {
|
||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ] + fs[ opc[ 3 ] ],
|
||||
cpu.d[ opc[ 2 ] & 1 ], fl[ opc[ 3 ] ] );
|
||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ] + fs[ opc[ 3 ] ], cpu.d[ opc[ 2 ] & 1 ], fl[ opc[ 3 ] ] );
|
||||
cpu.cycles++;
|
||||
}
|
||||
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
|
||||
{
|
||||
if ( !( opc[ 2 ] & 2 ) ) {
|
||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ],
|
||||
opc[ 3 ] + 1 );
|
||||
bus_write( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ], opc[ 3 ] + 1 );
|
||||
} else {
|
||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ],
|
||||
opc[ 3 ] + 1 );
|
||||
bus_read( cpu.reg[ ( opc[ 2 ] & 4 ) >> 1 ], cpu.d[ opc[ 2 ] & 1 ], opc[ 3 ] + 1 );
|
||||
cpu.cycles++;
|
||||
}
|
||||
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
|
||||
{
|
||||
int len = ( opc[ 3 ] == 0xF )
|
||||
? 5
|
||||
: ( ( fl[ opc[ 3 ] ] == 1 ) ? 17 : fl[ opc[ 3 ] ] );
|
||||
int len = ( opc[ 3 ] == 0xF ) ? 5 : ( ( fl[ opc[ 3 ] ] == 1 ) ? 17 : fl[ opc[ 3 ] ] );
|
||||
// Note: What happens if opc[4]&4
|
||||
if ( !( opc[ 4 ] & 8 ) ) {
|
||||
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 len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
||||
reg_cpy( cpu.reg_r[ i ] + fs[ opc[ 3 ] ],
|
||||
cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ], len );
|
||||
reg_cpy( cpu.reg_r[ i ] + fs[ opc[ 3 ] ], cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ], len );
|
||||
cpu.pc += 6;
|
||||
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 len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
||||
reg_cpy( cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ],
|
||||
cpu.reg_r[ i ] + fs[ opc[ 3 ] ], len );
|
||||
reg_cpy( cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ], cpu.reg_r[ i ] + fs[ opc[ 3 ] ], len );
|
||||
cpu.pc += 6;
|
||||
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 len = ( opc[ 3 ] == 0xF ) ? 5 : fl[ opc[ 3 ] ];
|
||||
reg_ex( cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ],
|
||||
cpu.reg_r[ i ] + fs[ opc[ 3 ] ], len );
|
||||
reg_ex( cpu.reg[ ( opc[ 5 ] & 8 ) >> 2 ] + fs[ opc[ 3 ] ], cpu.reg_r[ i ] + fs[ opc[ 3 ] ], len );
|
||||
cpu.pc += 6;
|
||||
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
|
||||
{
|
||||
if ( !( opc[ 2 ] & 8 ) ) {
|
||||
comp_eq( REGuF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
||||
fl[ opc[ 1 ] ] );
|
||||
comp_eq( REGuF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||
} else {
|
||||
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
|
||||
{
|
||||
comp_gt( REGuF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
||||
fl[ opc[ 1 ] ] );
|
||||
comp_gt( REGuF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||
if ( opc[ 2 ] & 8 )
|
||||
cpu.carry = !cpu.carry;
|
||||
goyes( opc, 3 );
|
||||
|
@ -713,8 +693,7 @@ static void opAa( byte* opc ) // t=t+v f / t=t-1 f
|
|||
case 0x0:
|
||||
case 0x4:
|
||||
case 0x8:
|
||||
alu_add( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
||||
fl[ opc[ 1 ] ] );
|
||||
alu_add( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||
break;
|
||||
case 0xC:
|
||||
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;
|
||||
case 0x4:
|
||||
case 0x8:
|
||||
reg_cpy( REGtF( opc[ 2 ], opc[ 1 ] ), REGrF( opc[ 2 ], opc[ 1 ] ),
|
||||
fl[ opc[ 1 ] ] );
|
||||
reg_cpy( REGtF( opc[ 2 ], opc[ 1 ] ), REGrF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||
break;
|
||||
case 0xC:
|
||||
reg_ex( REGtF( opc[ 2 ], opc[ 1 ] ), REGrF( opc[ 2 ], opc[ 1 ] ),
|
||||
fl[ opc[ 1 ] ] );
|
||||
reg_ex( REGtF( opc[ 2 ], opc[ 1 ] ), REGrF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||
break;
|
||||
}
|
||||
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 ) {
|
||||
case 0x0:
|
||||
case 0x8:
|
||||
alu_sub( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
||||
fl[ opc[ 1 ] ] );
|
||||
alu_sub( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||
break;
|
||||
case 0x4:
|
||||
alu_inc( REGtF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||
break;
|
||||
case 0xC:
|
||||
alu_sub2( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ),
|
||||
fl[ opc[ 1 ] ] );
|
||||
alu_sub2( REGtF( opc[ 2 ], opc[ 1 ] ), REGvF( opc[ 2 ], opc[ 1 ] ), fl[ opc[ 1 ] ] );
|
||||
break;
|
||||
}
|
||||
cpu.pc += 3;
|
||||
|
@ -872,7 +847,8 @@ static void opFC_F( byte* opc ) // r=-r-1 A
|
|||
cpu.cycles += 7;
|
||||
}
|
||||
|
||||
static Opcode opcodes0[ 16 ] = { { op00, NULL, "RTNSXM" },
|
||||
static Opcode opcodes0[ 16 ] = {
|
||||
{op00, NULL, "RTNSXM" },
|
||||
{ op01, NULL, "RTN" },
|
||||
{ op02_3, NULL, "RTNSC" },
|
||||
{ op02_3, NULL, "RTNCC" },
|
||||
|
@ -886,71 +862,109 @@ static Opcode opcodes0[ 16 ] = { { op00, NULL, "RTNSXM" },
|
|||
{ op0B, NULL, "CSTEX" },
|
||||
{ op0C, NULL, "P=P+1" },
|
||||
{ op0D, NULL, "P=P-1" },
|
||||
{ op0E, NULL, "%r3=%r3%&3%s3 %F2A" },
|
||||
{ op0F, NULL, "RTI" } };
|
||||
{ op0E, NULL, "%r3=%r3%&3%s3 %F2A"},
|
||||
{ op0F, NULL, "RTI" }
|
||||
};
|
||||
|
||||
static Opcode opcodes13[ 16 ] = {
|
||||
{ op13a, NULL, "D0=A" }, { op13a, NULL, "D1=A" },
|
||||
{ op13a, NULL, "AD0EX" }, { op13a, NULL, "AD1EX" },
|
||||
{ op13a, NULL, "D0=C" }, { op13a, NULL, "D1=C" },
|
||||
{ op13a, NULL, "CD0EX" }, { 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" } };
|
||||
{op13a, NULL, "D0=A" },
|
||||
{ op13a, NULL, "D1=A" },
|
||||
{ op13a, NULL, "AD0EX" },
|
||||
{ op13a, NULL, "AD1EX" },
|
||||
{ op13a, NULL, "D0=C" },
|
||||
{ op13a, NULL, "D1=C" },
|
||||
{ op13a, NULL, "CD0EX" },
|
||||
{ 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 ] = {
|
||||
{ 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" },
|
||||
{ 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" } };
|
||||
{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"},
|
||||
{ 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 ] = {
|
||||
{ op10, NULL, "R%i2=%a2" }, { op11, NULL, "%a2=R%i2" },
|
||||
{ op12, NULL, "%a2R%i2EX" }, { NULL, opcodes13, NULL },
|
||||
{ op14, NULL, "%D2 %B2" }, { NULL, opcodes15, NULL },
|
||||
{ op16_7, NULL, "D0=D0+ %I2+1" }, { 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" },
|
||||
{op10, NULL, "R%i2=%a2" },
|
||||
{ op11, NULL, "%a2=R%i2" },
|
||||
{ op12, NULL, "%a2R%i2EX" },
|
||||
{ NULL, opcodes13, NULL },
|
||||
{ op14, NULL, "%D2 %B2" },
|
||||
{ NULL, opcodes15, NULL },
|
||||
{ op16_7, NULL, "D0=D0+ %I2+1"},
|
||||
{ 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 ] = {
|
||||
{ op8080, NULL, "INTON" },
|
||||
{op8080, NULL, "INTON" },
|
||||
{ op8081, NULL, "RSI" },
|
||||
{ op8082, NULL, "LA #%N4" },
|
||||
{ NULL, NULL, NULL },
|
||||
{ op8084_5_8_9, NULL, "ABIT=0 %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=1 %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"},
|
||||
{ op8084_5_8_9, NULL, "CBIT=0 %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=1 %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"},
|
||||
{ op808C_E, NULL, "PC=(A)" },
|
||||
{ NULL, NULL, NULL },
|
||||
{ op808C_E, NULL, "PC=(C)" },
|
||||
{ op808F, NULL, "INTOFF" } };
|
||||
{ op808F, NULL, "INTOFF" }
|
||||
};
|
||||
|
||||
static Opcode opcodes80[ 16 ] = {
|
||||
{ op800_1, NULL, "OUT=CS" }, { op800_1, NULL, "OUT=C" },
|
||||
{ op802_3, NULL, "A=IN" }, { op802_3, NULL, "C=IN" },
|
||||
{ op804, NULL, "UNCONFIG" }, { op805, NULL, "CONFIG" },
|
||||
{ op806, NULL, "C=ID" }, { 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" } };
|
||||
{op800_1, NULL, "OUT=CS" },
|
||||
{ op800_1, NULL, "OUT=C" },
|
||||
{ op802_3, NULL, "A=IN" },
|
||||
{ op802_3, NULL, "C=IN" },
|
||||
{ op804, NULL, "UNCONFIG"},
|
||||
{ op805, NULL, "CONFIG" },
|
||||
{ op806, NULL, "C=ID" },
|
||||
{ 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 ] = {
|
||||
{op81Af0, NULL, "R%i5=%a5 %F3A" },
|
||||
{ op81Af1, NULL, "%a5=R%i5 %F3A" },
|
||||
{ op81Af2, NULL, "%a5R%i5EX %F3A" },
|
||||
{ op81Af2, NULL, "%a5R%i5EX %F3A"},
|
||||
{ NULL, NULL, NULL },
|
||||
{ NULL, NULL, NULL },
|
||||
{ NULL, NULL, NULL },
|
||||
|
@ -963,29 +977,49 @@ static Opcode opcodes81Af[ 16 ] = { { op81Af0, NULL, "R%i5=%a5 %F3A" },
|
|||
{ NULL, NULL, NULL },
|
||||
{ NULL, NULL, NULL },
|
||||
{ NULL, NULL, NULL },
|
||||
{ NULL, NULL, NULL } };
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
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 ] = {
|
||||
{ NULL, NULL, NULL }, { NULL, NULL, NULL },
|
||||
{ op81B2_3, NULL, "PC=A" }, { op81B2_3, NULL, "PC=C" },
|
||||
{ op81B4_5, NULL, "A=PC" }, { 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 },
|
||||
{ op81B2_3, NULL, "PC=A"},
|
||||
{ op81B2_3, NULL, "PC=C"},
|
||||
{ op81B4_5, NULL, "A=PC"},
|
||||
{ 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 }
|
||||
};
|
||||
|
||||
static Opcode opcodes81[ 16 ] = { { op810_3, NULL, "ASLC" },
|
||||
static Opcode opcodes81[ 16 ] = {
|
||||
{op810_3, NULL, "ASLC" },
|
||||
{ op810_3, NULL, "BSLC" },
|
||||
{ op810_3, NULL, "CSLC" },
|
||||
{ op810_3, NULL, "DSLC" },
|
||||
|
@ -993,28 +1027,29 @@ static Opcode opcodes81[ 16 ] = { { op810_3, NULL, "ASLC" },
|
|||
{ op814_7, NULL, "BSRC" },
|
||||
{ op814_7, NULL, "CSRC" },
|
||||
{ op814_7, NULL, "DSRC" },
|
||||
{ op818, NULL, "%u4=%u4%~4CON %F3A, %I6+1" },
|
||||
{ op818, NULL, "%u4=%u4%~4CON %F3A, %I6+1"},
|
||||
{ op819, NULL, "%u4SRB %F3A" },
|
||||
{ NULL, opcodes81A, NULL },
|
||||
{ NULL, opcodes81B, NULL },
|
||||
{ op81C_F, NULL, "ASRB" },
|
||||
{ op81C_F, NULL, "BSRB" },
|
||||
{ op81C_F, NULL, "CSRB" },
|
||||
{ op81C_F, NULL, "DSRB" } };
|
||||
{ op81C_F, NULL, "DSRB" }
|
||||
};
|
||||
|
||||
static Opcode opcodes8[ 16 ] = {
|
||||
{ NULL, opcodes80, NULL },
|
||||
{NULL, opcodes80, NULL },
|
||||
{ NULL, opcodes81, NULL },
|
||||
{ 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=1 %I2" },
|
||||
{ op86_7, NULL, "?ST=0 %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" },
|
||||
{ op8A, NULL, "?%u2%#2%z2 A, %G32YES %T32+3" },
|
||||
{ op8B, NULL, "?%u2%>2%v2 A, %G32YES %T32+3" },
|
||||
{ op8A, NULL, "?%u2%#2%z2 A, %G32YES %T32+3"},
|
||||
{ op8B, NULL, "?%u2%>2%v2 A, %G32YES %T32+3"},
|
||||
{ op8C, NULL, "GOLONG %R24+2" },
|
||||
{ op8D, NULL, "GOVLNG %X25" },
|
||||
{ op8E, NULL, "GOSUBL %R24+6" },
|
||||
|
@ -1022,70 +1057,115 @@ static Opcode opcodes8[ 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" },
|
||||
{ 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" } };
|
||||
{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"}
|
||||
};
|
||||
|
||||
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" },
|
||||
{ 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" } };
|
||||
{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" },
|
||||
{ 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 ] = {
|
||||
{ opBb0_3, NULL, "ASL %F1" }, { opBb0_3, NULL, "BSL %F1" },
|
||||
{ opBb0_3, NULL, "CSL %F1" }, { opBb0_3, NULL, "DSL %F1" },
|
||||
{ opBb4_7, NULL, "ASR %F1" }, { opBb4_7, NULL, "BSR %F1" },
|
||||
{ opBb4_7, NULL, "CSR %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" } };
|
||||
{opBb0_3, NULL, "ASL %F1" },
|
||||
{ opBb0_3, NULL, "BSL %F1" },
|
||||
{ opBb0_3, NULL, "CSL %F1" },
|
||||
{ opBb0_3, NULL, "DSL %F1" },
|
||||
{ opBb4_7, NULL, "ASR %F1" },
|
||||
{ opBb4_7, NULL, "BSR %F1" },
|
||||
{ opBb4_7, NULL, "CSR %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 ] = {
|
||||
{ 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 },
|
||||
{ NULL, opcodesBb, NULL }, { NULL, opcodesBb, NULL },
|
||||
{ NULL, opcodesBb, NULL }, { NULL, opcodesBb, NULL },
|
||||
{ NULL, opcodesBb, NULL }, { NULL, opcodesBb, NULL } };
|
||||
{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 },
|
||||
{ NULL, opcodesBb, NULL },
|
||||
{ NULL, opcodesBb, NULL },
|
||||
{ NULL, opcodesBb, NULL },
|
||||
{ NULL, opcodesBb, NULL },
|
||||
{ NULL, opcodesBb, NULL },
|
||||
{ NULL, opcodesBb, NULL }
|
||||
};
|
||||
|
||||
static Opcode opcodesF[ 16 ] = {
|
||||
{ opF0_3, NULL, "ASL A" }, { opF0_3, NULL, "BSL A" },
|
||||
{ opF0_3, NULL, "CSL A" }, { opF0_3, NULL, "DSL A" },
|
||||
{ opF4_7, NULL, "ASR A" }, { opF4_7, NULL, "BSR A" },
|
||||
{ opF4_7, NULL, "CSR 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" },
|
||||
{opF0_3, NULL, "ASL A" },
|
||||
{ opF0_3, NULL, "BSL A" },
|
||||
{ opF0_3, NULL, "CSL A" },
|
||||
{ opF0_3, NULL, "DSL A" },
|
||||
{ opF4_7, NULL, "ASR A" },
|
||||
{ opF4_7, NULL, "BSR A" },
|
||||
{ opF4_7, NULL, "CSR 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 ] = {
|
||||
{ NULL, opcodes0, NULL }, { NULL, opcodes1, NULL },
|
||||
{ op2, NULL, "P= %I1" }, { op3, NULL, "LC #%N1" },
|
||||
{ op4, NULL, "%G12C %T12+1" }, { op5, NULL, "%G12NC %T12+1" },
|
||||
{ op6, NULL, "GOTO %R13+1" }, { 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 } };
|
||||
{NULL, opcodes0, NULL },
|
||||
{ NULL, opcodes1, NULL },
|
||||
{ op2, NULL, "P= %I1" },
|
||||
{ op3, NULL, "LC #%N1" },
|
||||
{ op4, NULL, "%G12C %T12+1" },
|
||||
{ op5, NULL, "%G12NC %T12+1" },
|
||||
{ op6, NULL, "GOTO %R13+1" },
|
||||
{ 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 "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 ) {
|
||||
memcpy( reg + start, data, len );
|
||||
} 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;
|
||||
|
||||
while ( len-- ) {
|
||||
|
@ -51,7 +53,8 @@ static __inline unsigned int nib_to_unsigned( byte* nib, int len ) {
|
|||
return x;
|
||||
}
|
||||
|
||||
static __inline int nib_to_signed( byte* nib, int len ) {
|
||||
static __inline int nib_to_signed( byte* nib, int len )
|
||||
{
|
||||
int x;
|
||||
|
||||
len--;
|
||||
|
@ -65,26 +68,30 @@ static __inline int nib_to_signed( byte* nib, int len ) {
|
|||
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-- ) {
|
||||
*nib++ = x & 0xF;
|
||||
x >>= 4;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline address rstk_pop( void ) {
|
||||
static __inline address rstk_pop( void )
|
||||
{
|
||||
address adr = cpu.rstk[ cpu.rstk_ptr ];
|
||||
cpu.rstk[ cpu.rstk_ptr ] = 0x00000;
|
||||
cpu.rstk_ptr = ( cpu.rstk_ptr + 1 ) & 7;
|
||||
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[ cpu.rstk_ptr ] = adr & 0xFFFFF;
|
||||
}
|
||||
|
||||
static __inline void goyes( byte* opc, int offset ) {
|
||||
static __inline void goyes( byte* opc, int offset )
|
||||
{
|
||||
if ( cpu.carry ) {
|
||||
address rel = nib_to_signed( opc + offset, 2 );
|
||||
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_bit( byte* reg, int bit, int value ) {
|
||||
static __inline void reg_bit( byte* reg, int bit, int value )
|
||||
{
|
||||
if ( value ) {
|
||||
reg[ bit >> 2 ] |= 1 << ( bit & 3 );
|
||||
} 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 ) {
|
||||
memcpy( dest, src, len );
|
||||
}
|
||||
static __inline void reg_cpy( byte* dest, byte* src, int 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 ];
|
||||
|
||||
memcpy( tmp, reg1, len );
|
||||
|
@ -120,11 +127,10 @@ static __inline void reg_ex( byte* reg1, byte* reg2, int len ) {
|
|||
memcpy( reg2, tmp, len );
|
||||
}
|
||||
|
||||
static __inline void comp_bit_zero( byte* reg, int bit ) {
|
||||
cpu.carry = ( reg[ bit >> 2 ] & ( 1 << ( bit & 3 ) ) ) ? FALSE : TRUE;
|
||||
}
|
||||
static __inline void comp_bit_zero( byte* reg, int bit ) { 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-- ) {
|
||||
if ( *reg++ ) {
|
||||
cpu.carry = FALSE;
|
||||
|
@ -134,7 +140,8 @@ static __inline void comp_zero( byte* reg, int len ) {
|
|||
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-- ) {
|
||||
if ( *reg1++ != *reg2++ ) {
|
||||
cpu.carry = FALSE;
|
||||
|
@ -144,13 +151,15 @@ static __inline void comp_eq( byte* reg1, byte* reg2, int len ) {
|
|||
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 ] )
|
||||
;
|
||||
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 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;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
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;
|
||||
while ( len-- ) {
|
||||
reg[ i ]++;
|
||||
|
@ -220,7 +232,8 @@ static __inline void alu_add_con( byte* reg, byte con, int i, int len ) {
|
|||
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;
|
||||
while ( len-- ) {
|
||||
reg[ i ]--;
|
||||
|
@ -234,7 +247,8 @@ static __inline void alu_sub_con( byte* reg, byte con, int i, int len ) {
|
|||
cpu.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void alu_inc( byte* reg, int len ) {
|
||||
static __inline void alu_inc( byte* reg, int len )
|
||||
{
|
||||
if ( cpu.dec ) {
|
||||
byte c = 1;
|
||||
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;
|
||||
|
||||
while ( len-- ) {
|
||||
|
@ -279,7 +294,8 @@ static __inline void alu_dec( byte* reg, int len ) {
|
|||
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;
|
||||
|
||||
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;
|
||||
|
||||
while ( len-- ) {
|
||||
|
@ -315,26 +332,30 @@ static __inline void alu_not( byte* reg, int len ) {
|
|||
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-- ) {
|
||||
*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-- ) {
|
||||
*dest++ |= *src++;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline void alu_sl( byte* reg, int len ) {
|
||||
static __inline void alu_sl( byte* reg, int len )
|
||||
{
|
||||
while ( --len ) {
|
||||
reg[ len ] = reg[ len - 1 ];
|
||||
}
|
||||
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 ];
|
||||
|
||||
while ( --len ) {
|
||||
|
@ -343,7 +364,8 @@ static __inline void alu_slc( byte* reg, int len ) {
|
|||
reg[ 0 ] = tmp;
|
||||
}
|
||||
|
||||
static __inline void alu_sr( byte* reg, int len ) {
|
||||
static __inline void alu_sr( byte* reg, int len )
|
||||
{
|
||||
if ( reg[ 0 ] )
|
||||
cpu.hst |= HST_SB;
|
||||
|
||||
|
@ -354,7 +376,8 @@ static __inline void alu_sr( byte* reg, int len ) {
|
|||
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 ];
|
||||
|
||||
while ( --len ) {
|
||||
|
@ -364,7 +387,8 @@ static __inline void alu_src( byte* reg, int len ) {
|
|||
reg[ 0 ] = tmp;
|
||||
}
|
||||
|
||||
static __inline void alu_srb( byte* reg, int len ) {
|
||||
static __inline void alu_srb( byte* reg, int len )
|
||||
{
|
||||
if ( *reg & 1 )
|
||||
cpu.hst |= HST_SB;
|
||||
|
||||
|
|
110
src/pabout.c
110
src/pabout.c
|
@ -33,62 +33,67 @@
|
|||
|
||||
// static BITMAP *about_bmp;
|
||||
|
||||
static char* about_line[] = { "C / ",
|
||||
"C /__ ___ ___ ____ ",
|
||||
"C / / / / /__/ / / / / /",
|
||||
"C/ / /__/ /__ / / /__/ ",
|
||||
"C / ",
|
||||
"C / version 0.9.0 ",
|
||||
"P",
|
||||
" Copyright 2002 Daniel Nilsson",
|
||||
"P",
|
||||
"JHpemu is free software; you can",
|
||||
"Jredistribute it and/or modify it under",
|
||||
"Jthe terms of the GNU General Public",
|
||||
"JLicense as published by the Free Software",
|
||||
"JFoundation; either version 2 of the",
|
||||
"JLicense, or (at your option) any later",
|
||||
"Jversion.",
|
||||
"P",
|
||||
"JHpemu is distributed in the hope that it",
|
||||
"Jwill be useful, but WITHOUT ANY WARRANTY;",
|
||||
"Jwithout even the implied warranty of",
|
||||
"JMERCHANTABILITY or FITNESS FOR A",
|
||||
"JPARTICULAR PURPOSE. See the GNU General",
|
||||
"JPublic License for more details.",
|
||||
"P",
|
||||
"JYou should have received a copy of the",
|
||||
"JGNU General Public License along with",
|
||||
"Jhpemu; if not, write to the Free Software",
|
||||
"JFoundation, Inc., 59 Temple Place,",
|
||||
"JSuite 330, Boston, MA 02111-1307 USA",
|
||||
NULL };
|
||||
/* static char* about_line[] = { "C / ", */
|
||||
/* "C /__ ___ ___ ____ ", */
|
||||
/* "C / / / / /__/ / / / / /", */
|
||||
/* "C/ / /__/ /__ / / /__/ ", */
|
||||
/* "C / ", */
|
||||
/* "C / version 0.9.0 ", */
|
||||
/* "P", */
|
||||
/* " Copyright 2002 Daniel Nilsson", */
|
||||
/* "P", */
|
||||
/* "JHpemu is free software; you can", */
|
||||
/* "Jredistribute it and/or modify it under", */
|
||||
/* "Jthe terms of the GNU General Public", */
|
||||
/* "JLicense as published by the Free Software",
|
||||
*/
|
||||
/* "JFoundation; either version 2 of the", */
|
||||
/* "JLicense, or (at your option) any later", */
|
||||
/* "Jversion.", */
|
||||
/* "P", */
|
||||
/* "JHpemu is distributed in the hope that it", */
|
||||
/* "Jwill be useful, but WITHOUT ANY WARRANTY;",
|
||||
*/
|
||||
/* "Jwithout even the implied warranty of", */
|
||||
/* "JMERCHANTABILITY or FITNESS FOR A", */
|
||||
/* "JPARTICULAR PURPOSE. See the GNU General", */
|
||||
/* "JPublic License for more details.", */
|
||||
/* "P", */
|
||||
/* "JYou should have received a copy of the", */
|
||||
/* "JGNU General Public License along with", */
|
||||
/* "Jhpemu; if not, write to the Free Software",
|
||||
*/
|
||||
/* "JFoundation, Inc., 59 Temple Place,", */
|
||||
/* "JSuite 330, Boston, MA 02111-1307 USA", */
|
||||
/* NULL }; */
|
||||
|
||||
static void draw_about( void ) {
|
||||
/*
|
||||
int i, y;
|
||||
/* static void draw_about( void ) { */
|
||||
/* /\* */
|
||||
/* int i, y; */
|
||||
|
||||
text_mode(color[C_PANEL_BACK]);
|
||||
/* text_mode(color[C_PANEL_BACK]); */
|
||||
|
||||
acquire_bitmap(about_bmp);
|
||||
scare_mouse();
|
||||
/* acquire_bitmap(about_bmp); */
|
||||
/* scare_mouse(); */
|
||||
|
||||
y = 10;
|
||||
for (i = 0; about_line[i]; i++) {
|
||||
switch (about_line[i][0]) {
|
||||
case 'C':
|
||||
textout_centre(about_bmp, font, about_line[i]+1, 170, y,
|
||||
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,
|
||||
color[C_PANEL_TEXT]); break;
|
||||
}
|
||||
y += 10;
|
||||
}
|
||||
/* y = 10; */
|
||||
/* for (i = 0; about_line[i]; i++) { */
|
||||
/* switch (about_line[i][0]) { */
|
||||
/* case 'C': */
|
||||
/* textout_centre(about_bmp, font, about_line[i]+1, 170, y, */
|
||||
/* 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, */
|
||||
/* color[C_PANEL_TEXT]); break; */
|
||||
/* } */
|
||||
/* y += 10; */
|
||||
/* } */
|
||||
|
||||
unscare_mouse();
|
||||
release_bitmap(about_bmp);*/
|
||||
}
|
||||
/* unscare_mouse(); */
|
||||
/* release_bitmap(about_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;
|
||||
}
|
||||
|
||||
|
|
279
src/pcalc.c
279
src/pcalc.c
|
@ -151,193 +151,151 @@ const int xspacing2 = ( pow2 + 2 );
|
|||
const int enter_w = pow1 * 2 + 2;
|
||||
|
||||
static KBMapping kb_sdl_mapping[] = {
|
||||
SDL_SCANCODE_KP_0, dn03, up03, SDL_SCANCODE_KP_1, dn13, up13,
|
||||
SDL_SCANCODE_KP_2, dn12, up12, SDL_SCANCODE_KP_3, dn11, up11,
|
||||
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,
|
||||
{SDL_SCANCODE_KP_0, dn03, up03},
|
||||
{ SDL_SCANCODE_KP_1, dn13, up13},
|
||||
{ SDL_SCANCODE_KP_2, dn12, up12},
|
||||
{ SDL_SCANCODE_KP_3, dn11, up11},
|
||||
{ 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[] = {
|
||||
|
||||
{ 0, pox + xstart + ( xspacing * 0 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "A", dn14, up14 },
|
||||
{ 1, pox + xstart + ( xspacing * 1 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "B", dn84, up84 },
|
||||
{ 2, pox + xstart + ( xspacing * 2 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "C", dn83, up83 },
|
||||
{ 3, pox + xstart + ( xspacing * 3 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "D", dn82, up82 },
|
||||
{ 4, pox + xstart + ( xspacing * 4 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "E", dn81, up81 },
|
||||
{ 5, pox + xstart + ( xspacing * 5 ), ystart + ( 0 * yspacing ) + poy, pow1,
|
||||
poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "F", dn80, up80 },
|
||||
{ 0, pox + xstart + ( xspacing * 0 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "A",
|
||||
dn14, up14 },
|
||||
{ 1, pox + xstart + ( xspacing * 1 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "B",
|
||||
dn84, up84 },
|
||||
{ 2, pox + xstart + ( xspacing * 2 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "C",
|
||||
dn83, up83 },
|
||||
{ 3, pox + xstart + ( xspacing * 3 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "D",
|
||||
dn82, up82 },
|
||||
{ 4, pox + xstart + ( xspacing * 4 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "E",
|
||||
dn81, up81 },
|
||||
{ 5, pox + xstart + ( xspacing * 5 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "F",
|
||||
dn80, up80 },
|
||||
|
||||
{ 6, pox + xstart + ( xspacing * 0 ), ystart + ( 1 * yspacing ) + poy + 10,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "MTH", "RAD", "POLAR",
|
||||
"G", dn24, up24 },
|
||||
{ 7, pox + xstart + ( xspacing * 1 ), ystart + ( 1 * yspacing ) + poy + 10,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "PRG", "", "CHARS", "H",
|
||||
dn74, up74 },
|
||||
{ 8, pox + xstart + ( xspacing * 2 ), ystart + ( 1 * yspacing ) + poy + 10,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "CST", "", "MODES", "I",
|
||||
dn73, up73 },
|
||||
{ 9, pox + xstart + ( xspacing * 3 ), ystart + ( 1 * yspacing ) + poy + 10,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "VAR", "", "MEMORY", "J",
|
||||
dn72, up72 },
|
||||
{ 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 },
|
||||
{ 6, pox + xstart + ( xspacing * 0 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "MTH",
|
||||
"RAD", "POLAR", "G", dn24, up24 },
|
||||
{ 7, pox + xstart + ( xspacing * 1 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "PRG", "",
|
||||
"CHARS", "H", dn74, up74 },
|
||||
{ 8, pox + xstart + ( xspacing * 2 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "CST", "",
|
||||
"MODES", "I", dn73, up73 },
|
||||
{ 9, pox + xstart + ( xspacing * 3 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "VAR", "",
|
||||
"MEMORY", "J", dn72, up72 },
|
||||
{ 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,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "'", "UP", "HOME", "M",
|
||||
dn04, up04 },
|
||||
{ 13, pox + xstart + ( xspacing * 1 ), ystart + ( 2 * yspacing ) + poy + 20,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "STO", "REF", "RCL", "N",
|
||||
dn64, up64 },
|
||||
{ 14, pox + xstart + ( xspacing * 2 ), ystart + ( 2 * yspacing ) + poy + 20,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EVAL", "->NUM", "UNDO",
|
||||
"O", dn63, up63 },
|
||||
{ 15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<", "PICTURE", "", "P",
|
||||
dn62, up62 },
|
||||
{ 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 },
|
||||
{ 12, pox + xstart + ( xspacing * 0 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "'", "UP",
|
||||
"HOME", "M", dn04, up04 },
|
||||
{ 13, pox + xstart + ( xspacing * 1 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "STO",
|
||||
"REF", "RCL", "N", dn64, up64 },
|
||||
{ 14, pox + xstart + ( xspacing * 2 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EVAL",
|
||||
"->NUM", "UNDO", "O", dn63, up63 },
|
||||
{ 15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<",
|
||||
"PICTURE", "", "P", dn62, up62 },
|
||||
{ 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,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SIN", "ASIN", "tet", "S",
|
||||
dn34, up34 },
|
||||
{ 19, pox + xstart + ( xspacing * 1 ), ystart + ( 3 * yspacing ) + poy + 30,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "COS", "ACOS", "", "T",
|
||||
dn54, up54 },
|
||||
{ 20, pox + xstart + ( xspacing * 2 ), ystart + ( 3 * yspacing ) + poy + 30,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "TAN", "ATAN", "Sig", "U",
|
||||
dn53, up53 },
|
||||
{ 21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SQ x", "xx", "x SQ y",
|
||||
"V", dn52, up52 },
|
||||
{ 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 },
|
||||
{ 18, pox + xstart + ( xspacing * 0 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SIN",
|
||||
"ASIN", "tet", "S", dn34, up34 },
|
||||
{ 19, pox + xstart + ( xspacing * 1 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "COS",
|
||||
"ACOS", "", "T", dn54, up54 },
|
||||
{ 20, pox + xstart + ( xspacing * 2 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "TAN",
|
||||
"ATAN", "Sig", "U", dn53, up53 },
|
||||
{ 21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SQ x",
|
||||
"xx", "x SQ y", "V", dn52, up52 },
|
||||
{ 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,
|
||||
enter_w, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ENTER", "EQUATION",
|
||||
"MATRIX", "", dn44, up44 },
|
||||
{ 25, enter_w - pow1 + pox + xstart + ( xspacing * 1 ),
|
||||
ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+/-", "EDIT", "CMD", "Y", dn43,
|
||||
up43 },
|
||||
{ 26, enter_w - pow1 + pox + xstart + ( xspacing * 2 ),
|
||||
ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EEX", "PURG", "ARG", "Z", dn42,
|
||||
up42 },
|
||||
{ 27, enter_w - pow1 + pox + xstart + ( xspacing * 3 ),
|
||||
ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||
{ 24, pox + xstart + ( xspacing * 0 ), ystart + ( 4 * yspacing ) + poy + 40, enter_w, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ENTER",
|
||||
"EQUATION", "MATRIX", "", dn44, up44 },
|
||||
{ 25, enter_w - pow1 + pox + xstart + ( xspacing * 1 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+/-", "EDIT", "CMD", "Y", dn43, up43 },
|
||||
{ 26, enter_w - pow1 + pox + xstart + ( xspacing * 2 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EEX", "PURG", "ARG", "Z", dn42, 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,
|
||||
{ 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,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "alpha", "USER", "ENTRY",
|
||||
"", dn35, up35 },
|
||||
{ 30, pox + xstart + ( xspacing2 * 1 ),
|
||||
ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "7", "", "SOLVE", "", dn33, up33 },
|
||||
{ 31, pox + xstart + ( xspacing2 * 2 ),
|
||||
ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "8", "", "PLOT", "", dn32, up32 },
|
||||
{ 32, pox + xstart + ( xspacing2 * 3 ),
|
||||
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 },
|
||||
{ 29, pox + xstart + ( xspacing * 0 ), ystart + ( 5 * yspacing ) + poy + 50, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "alpha",
|
||||
"USER", "ENTRY", "", dn35, up35 },
|
||||
{ 30, pox + xstart + ( xspacing2 * 1 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "7", "",
|
||||
"SOLVE", "", dn33, up33 },
|
||||
{ 31, pox + xstart + ( xspacing2 * 2 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "8", "",
|
||||
"PLOT", "", dn32, up32 },
|
||||
{ 32, pox + xstart + ( xspacing2 * 3 ), 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,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "red", "", "", dn25,
|
||||
up25 },
|
||||
{ 35, pox + xstart + ( xspacing2 * 1 ),
|
||||
ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "4", "", "TIME", "", dn23, up23 },
|
||||
{ 36, pox + xstart + ( xspacing2 * 2 ),
|
||||
ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "5", "", "STAT", "", dn22, up22 },
|
||||
{ 37, pox + xstart + ( xspacing2 * 3 ),
|
||||
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 },
|
||||
{ 34, pox + xstart + ( xspacing * 0 ), ystart + ( 6 * yspacing ) + poy + 60, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "red",
|
||||
"", "", dn25, up25 },
|
||||
{ 35, pox + xstart + ( xspacing2 * 1 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "4", "",
|
||||
"TIME", "", dn23, up23 },
|
||||
{ 36, pox + xstart + ( xspacing2 * 2 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "5", "",
|
||||
"STAT", "", dn22, up22 },
|
||||
{ 37, pox + xstart + ( xspacing2 * 3 ), 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,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "green", "", dn15,
|
||||
up15 },
|
||||
{ 40, pox + xstart + ( xspacing2 * 1 ),
|
||||
ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1", "", "I/O", "", dn13, up13 },
|
||||
{ 41, pox + xstart + ( xspacing2 * 2 ),
|
||||
ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "2", "", "LIBRARY", "", dn12, up12 },
|
||||
{ 42, pox + xstart + ( xspacing2 * 3 ),
|
||||
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 },
|
||||
{ 39, pox + xstart + ( xspacing * 0 ), ystart + ( 7 * yspacing ) + poy + 70, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "",
|
||||
"green", "", dn15, up15 },
|
||||
{ 40, pox + xstart + ( xspacing2 * 1 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1", "",
|
||||
"I/O", "", dn13, up13 },
|
||||
{ 41, pox + xstart + ( xspacing2 * 2 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "2", "",
|
||||
"LIBRARY", "", dn12, up12 },
|
||||
{ 42, pox + xstart + ( xspacing2 * 3 ), 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,
|
||||
pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ON", "CONT", "OFF",
|
||||
"CANCEL", dnON, upON },
|
||||
{ 45, pox + xstart + ( xspacing2 * 1 ),
|
||||
ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "0", "=", "->", "", dn03, up03 },
|
||||
{ 46, pox + xstart + ( xspacing2 * 2 ),
|
||||
ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ".", ",", "back", "", dn02, up02 },
|
||||
{ 47, pox + xstart + ( xspacing2 * 3 ),
|
||||
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 },
|
||||
{ 44, pox + xstart + ( xspacing * 0 ), ystart + ( 8 * yspacing ) + poy + 80, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ON",
|
||||
"CONT", "OFF", "CANCEL", dnON, upON },
|
||||
{ 45, pox + xstart + ( xspacing2 * 1 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "0", "=",
|
||||
"->", "", dn03, up03 },
|
||||
{ 46, pox + xstart + ( xspacing2 * 2 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ".", ",",
|
||||
"back", "", dn02, up02 },
|
||||
{ 47, pox + xstart + ( xspacing2 * 3 ), 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,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", dnZelda,
|
||||
{ 49, pox + xstart, ystart + ( 9 * yspacing ) + poy + 90, 130, 20, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", dnZelda,
|
||||
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_show() {
|
||||
void pcalc_show()
|
||||
{
|
||||
// clear_to_color(calc_bmp, color[C_PANEL_BACK]);
|
||||
button_draw_all( calc_buttons );
|
||||
}
|
||||
|
||||
void pcalc_hide( void ) {
|
||||
void pcalc_hide( void )
|
||||
{
|
||||
// calc_bmp = NULL;
|
||||
}
|
||||
|
||||
void pcalc_down( int mx, int my, int mb ) {
|
||||
button_mouse_down( calc_buttons, mx, my, mb );
|
||||
}
|
||||
void pcalc_down( int mx, int my, int mb ) { button_mouse_down( calc_buttons, mx, my, mb ); }
|
||||
|
||||
void pcalc_up( int mx, int my, int mb ) {
|
||||
button_mouse_up( calc_buttons, mx, my, mb );
|
||||
}
|
||||
void pcalc_up( int mx, int my, int 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 );
|
||||
KBMapping* mapping = kb_sdl_mapping;
|
||||
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;
|
||||
while ( 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 "pdebug.h"
|
||||
|
||||
static void run_up( boolean action );
|
||||
static void break_up( boolean action );
|
||||
static void step_up( boolean action );
|
||||
/* static void run_up( boolean action ); */
|
||||
/* static void break_up( boolean action ); */
|
||||
/* static void step_up( boolean action ); */
|
||||
|
||||
static Button debug_buttons[] = {
|
||||
{ 0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Break", NULL, break_up },
|
||||
{ 1, 80, 0, 79, 20, BUTTON_B1RELEASE, "Run", NULL, run_up },
|
||||
{ 2, 160, 0, 79, 20, BUTTON_B1RELEASE, "Step", NULL, step_up },
|
||||
{ 3, 0, 0, 0, 0, 0, NULL, NULL, NULL } };
|
||||
/* static Button debug_buttons[] = { */
|
||||
/* {0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Break", NULL, NULL, NULL, break_up, NULL}, */
|
||||
/* { 1, 80, 0, 79, 20, BUTTON_B1RELEASE, "Run", NULL, NULL, NULL, run_up, NULL}, */
|
||||
/* { 2, 160, 0, 79, 20, BUTTON_B1RELEASE, "Step", NULL, NULL, NULL, step_up, NULL}, */
|
||||
/* { 3, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL} */
|
||||
/* }; */
|
||||
|
||||
#define BREAK_BUTTON 0
|
||||
#define RUN_BUTTON 1
|
||||
|
@ -53,7 +54,8 @@ static Button debug_buttons[] = {
|
|||
|
||||
// static BITMAP *debug_bmp;
|
||||
|
||||
static void update_buttons( void ) {
|
||||
static void update_buttons( void )
|
||||
{
|
||||
/*
|
||||
if (emulator_get_state() == EMULATOR_STOP) {
|
||||
if (debug_buttons[RUN_BUTTON].flags & BUTTON_DISABLED) {
|
||||
|
@ -84,29 +86,33 @@ if (emulator_get_state() == EMULATOR_STOP) {
|
|||
}*/
|
||||
}
|
||||
|
||||
static void run_up( boolean action ) {
|
||||
if ( action ) {
|
||||
emulator_set_state( EMULATOR_RUN );
|
||||
}
|
||||
}
|
||||
/* static void run_up( boolean action ) */
|
||||
/* { */
|
||||
/* if ( action ) { */
|
||||
/* emulator_set_state( EMULATOR_RUN ); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
static void break_up( boolean action ) {
|
||||
if ( action ) {
|
||||
emulator_set_state( EMULATOR_STOP );
|
||||
}
|
||||
}
|
||||
/* static void break_up( boolean action ) */
|
||||
/* { */
|
||||
/* if ( action ) { */
|
||||
/* emulator_set_state( EMULATOR_STOP ); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
static void step_up( boolean action ) {
|
||||
if ( action ) {
|
||||
emulator_set_state( EMULATOR_STEP );
|
||||
}
|
||||
}
|
||||
/* static void step_up( boolean action ) */
|
||||
/* { */
|
||||
/* if ( action ) { */
|
||||
/* emulator_set_state( EMULATOR_STEP ); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/*static*/ void draw_cpu( void ) {
|
||||
int c1 = color[ C_PANEL_TEXT ];
|
||||
int c2 = color[ C_PANEL_DISABLED ];
|
||||
int i;
|
||||
char* tmp;
|
||||
/*static*/ void draw_cpu( void )
|
||||
{
|
||||
/* int c1 = color[ C_PANEL_TEXT ]; */
|
||||
/* int c2 = color[ C_PANEL_DISABLED ]; */
|
||||
/* int i; */
|
||||
/* char* tmp; */
|
||||
|
||||
// if (!debug_bmp) {
|
||||
// return;
|
||||
|
@ -117,9 +123,9 @@ static void step_up( boolean action ) {
|
|||
// acquire_bitmap(debug_bmp);
|
||||
// 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));
|
||||
|
@ -225,7 +231,8 @@ cpu.cycles);
|
|||
// 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);
|
||||
|
||||
// if (!debug_bmp) {
|
||||
|
@ -238,7 +245,8 @@ void pdebug_draw_true_speed( dword speed ) {
|
|||
// %10u Hz", speed); unscare_mouse(); release_bitmap(debug_bmp);
|
||||
}
|
||||
|
||||
void pdebug_state_changed( void ) {
|
||||
void pdebug_state_changed( void )
|
||||
{
|
||||
update_buttons();
|
||||
draw_cpu();
|
||||
}
|
||||
|
@ -256,14 +264,17 @@ void pdebug_show(BITMAP *bmp)
|
|||
}
|
||||
*/
|
||||
|
||||
void pdebug_hide( void ) {
|
||||
void pdebug_hide( void )
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
59
src/pfiles.c
59
src/pfiles.c
|
@ -35,28 +35,29 @@
|
|||
#include "pfiles.h"
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#include <windows.h> // memset()
|
||||
#include <shlwapi.h> // PathRemoveFileSpecA
|
||||
# include <windows.h> // memset()
|
||||
# include <shlwapi.h> // PathRemoveFileSpecA
|
||||
#endif
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
#include <string.h> // memset()
|
||||
#include <ctype.h> // isalpha
|
||||
#include <unistd.h> // getcwd
|
||||
# import <CoreFoundation/CoreFoundation.h>
|
||||
# include <string.h> // memset()
|
||||
# include <ctype.h> // isalpha
|
||||
# include <unistd.h> // getcwd
|
||||
#endif
|
||||
|
||||
#if defined( __linux__ )
|
||||
#include <libgen.h> // dirname
|
||||
#include <unistd.h> // readlink
|
||||
#include <linux/limits.h> // PATH_MAX
|
||||
# include <libgen.h> // dirname
|
||||
# include <unistd.h> // readlink
|
||||
# include <linux/limits.h> // PATH_MAX
|
||||
#endif
|
||||
|
||||
// static void load_up(boolean action);
|
||||
|
||||
/*
|
||||
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 }
|
||||
};
|
||||
*/
|
||||
|
@ -64,7 +65,8 @@ static Button files_buttons[] = {
|
|||
|
||||
static char WorkingPath[ 512 ];
|
||||
|
||||
static void getExePath() {
|
||||
static void getExePath()
|
||||
{
|
||||
char programPath[ 1024 ];
|
||||
char temp[ 1024 ];
|
||||
memset( programPath, 0, sizeof( programPath ) );
|
||||
|
@ -73,8 +75,7 @@ static void getExePath() {
|
|||
#if defined( __APPLE__ )
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle );
|
||||
if ( !CFURLGetFileSystemRepresentation(
|
||||
resourcesURL, TRUE, ( UInt8* )programPath,
|
||||
if ( !CFURLGetFileSystemRepresentation( resourcesURL, TRUE, ( UInt8* )programPath,
|
||||
PATH_MAX ) ) // Error: expected unqualified-id before 'if'
|
||||
{
|
||||
// error!
|
||||
|
@ -117,7 +118,8 @@ static void getExePath() {
|
|||
strcpy( WorkingPath, programPath );
|
||||
}
|
||||
|
||||
static int file_size( char* name ) {
|
||||
static int file_size( char* name )
|
||||
{
|
||||
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
||||
getExePath();
|
||||
|
||||
|
@ -155,7 +157,8 @@ static int file_size(char *name)
|
|||
*/
|
||||
|
||||
// static
|
||||
void load_file( char* name ) {
|
||||
void load_file( char* name )
|
||||
{
|
||||
// PACKFILE *f;
|
||||
FILE* f;
|
||||
byte* buf;
|
||||
|
@ -219,15 +222,16 @@ void load_file( char* name ) {
|
|||
// /Users/admin/Documents/GIT/jsEmu48/jsEmu48/emutest2/emutest2/arkalite
|
||||
|
||||
// static
|
||||
void load_up( boolean action ) {
|
||||
static char path[ PATH_SIZE ] = "";
|
||||
void load_up( boolean action )
|
||||
{
|
||||
/* static char path[ PATH_SIZE ] = ""; */
|
||||
|
||||
if ( action ) {
|
||||
// if (file_select_ex("Load Object", path, NULL, PATH_SIZE,
|
||||
//0, 0)) {
|
||||
// load_file(path);
|
||||
// }
|
||||
}
|
||||
/* if ( action ) { */
|
||||
/* // if (file_select_ex("Load Object", path, NULL, PATH_SIZE, */
|
||||
/* // 0, 0)) { */
|
||||
/* // load_file(path); */
|
||||
/* // } */
|
||||
/* } */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -240,14 +244,17 @@ void pfiles_show(BITMAP *bmp)
|
|||
}
|
||||
*/
|
||||
|
||||
void pfiles_hide( void ) {
|
||||
void pfiles_hide( void )
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
111
src/pmenu.c
111
src/pmenu.c
|
@ -32,64 +32,68 @@
|
|||
#include "gui.h"
|
||||
#include "pmenu.h"
|
||||
|
||||
static void exit_up( boolean action );
|
||||
static void debug_up( boolean action );
|
||||
static void files_up( boolean action );
|
||||
static void about_up( boolean action );
|
||||
/* static void exit_up( boolean action ); */
|
||||
/* static void debug_up( boolean action ); */
|
||||
/* static void files_up( boolean action ); */
|
||||
/* static void about_up( boolean action ); */
|
||||
|
||||
static Button menu_buttons[] = {
|
||||
{ 0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Exit", NULL, exit_up },
|
||||
{ 1, 80, 0, 79, 20, BUTTON_B1RELEASE, "Debug", NULL, debug_up },
|
||||
{ 2, 160, 0, 79, 20, BUTTON_B1RELEASE, "Files", NULL, files_up },
|
||||
{ 3, 240, 0, 79, 20, BUTTON_DISABLED | BUTTON_B1RELEASE, "About", NULL,
|
||||
about_up },
|
||||
{ 4, 0, 0, 0, 0, 0, NULL, NULL, NULL } };
|
||||
/* static Button menu_buttons[] = { */
|
||||
/* {0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Exit", NULL, exit_up }, */
|
||||
/* { 1, 80, 0, 79, 20, BUTTON_B1RELEASE, "Debug", NULL, debug_up}, */
|
||||
/* { 2, 160, 0, 79, 20, BUTTON_B1RELEASE, "Files", NULL, files_up}, */
|
||||
/* { 3, 240, 0, 79, 20, BUTTON_DISABLED | BUTTON_B1RELEASE, "About", NULL, about_up}, */
|
||||
/* { 4, 0, 0, 0, 0, 0, NULL, NULL, NULL } */
|
||||
/* }; */
|
||||
|
||||
enum MenuButtons { MENU_EXIT, MENU_DEBUG, MENU_FILES, MENU_ABOUT, MENU_COUNT };
|
||||
|
||||
// static BITMAP *menu_bmp;
|
||||
|
||||
static void exit_up( boolean action ) {
|
||||
if ( action ) {
|
||||
please_exit = TRUE;
|
||||
}
|
||||
}
|
||||
/* static void exit_up( boolean action ) */
|
||||
/* { */
|
||||
/* if ( action ) { */
|
||||
/* please_exit = TRUE; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
static void debug_up( boolean action ) {
|
||||
// if (action) {
|
||||
// menu_buttons[MENU_DEBUG].flags |= BUTTON_DISABLED;
|
||||
// menu_buttons[MENU_FILES].flags &= ~BUTTON_DISABLED;
|
||||
// menu_buttons[MENU_ABOUT].flags &= ~BUTTON_DISABLED;
|
||||
// button_draw_all(menu_bmp, menu_buttons);
|
||||
// gui_hide_panel(PANEL_FILES);
|
||||
// gui_hide_panel(PANEL_ABOUT);
|
||||
// gui_show_panel(PANEL_DEBUG);
|
||||
// }
|
||||
}
|
||||
/* static void debug_up( boolean action ) */
|
||||
/* { */
|
||||
/* // if (action) { */
|
||||
/* // menu_buttons[MENU_DEBUG].flags |= BUTTON_DISABLED; */
|
||||
/* // menu_buttons[MENU_FILES].flags &= ~BUTTON_DISABLED; */
|
||||
/* // menu_buttons[MENU_ABOUT].flags &= ~BUTTON_DISABLED; */
|
||||
/* // button_draw_all(menu_bmp, menu_buttons); */
|
||||
/* // gui_hide_panel(PANEL_FILES); */
|
||||
/* // gui_hide_panel(PANEL_ABOUT); */
|
||||
/* // gui_show_panel(PANEL_DEBUG); */
|
||||
/* // } */
|
||||
/* } */
|
||||
|
||||
static void files_up( boolean action ) {
|
||||
// if (action) {
|
||||
// menu_buttons[MENU_DEBUG].flags &= ~BUTTON_DISABLED;
|
||||
// menu_buttons[MENU_FILES].flags |= BUTTON_DISABLED;
|
||||
// menu_buttons[MENU_ABOUT].flags &= ~BUTTON_DISABLED;
|
||||
// button_draw_all(menu_bmp, menu_buttons);
|
||||
// gui_hide_panel(PANEL_DEBUG);
|
||||
// gui_hide_panel(PANEL_ABOUT);
|
||||
// gui_show_panel(PANEL_FILES);
|
||||
// }
|
||||
}
|
||||
/* static void files_up( boolean action ) */
|
||||
/* { */
|
||||
/* // if (action) { */
|
||||
/* // menu_buttons[MENU_DEBUG].flags &= ~BUTTON_DISABLED; */
|
||||
/* // menu_buttons[MENU_FILES].flags |= BUTTON_DISABLED; */
|
||||
/* // menu_buttons[MENU_ABOUT].flags &= ~BUTTON_DISABLED; */
|
||||
/* // button_draw_all(menu_bmp, menu_buttons); */
|
||||
/* // gui_hide_panel(PANEL_DEBUG); */
|
||||
/* // gui_hide_panel(PANEL_ABOUT); */
|
||||
/* // gui_show_panel(PANEL_FILES); */
|
||||
/* // } */
|
||||
/* } */
|
||||
|
||||
static void about_up( boolean action ) {
|
||||
// if (action) {
|
||||
// menu_buttons[MENU_DEBUG].flags &= ~BUTTON_DISABLED;
|
||||
// menu_buttons[MENU_FILES].flags &= ~BUTTON_DISABLED;
|
||||
// menu_buttons[MENU_ABOUT].flags |= BUTTON_DISABLED;
|
||||
// button_draw_all(menu_bmp, menu_buttons);
|
||||
// gui_hide_panel(PANEL_DEBUG);
|
||||
// gui_hide_panel(PANEL_FILES);
|
||||
// gui_show_panel(PANEL_ABOUT);
|
||||
// }
|
||||
}
|
||||
/* static void about_up( boolean action ) */
|
||||
/* { */
|
||||
/* // if (action) { */
|
||||
/* // menu_buttons[MENU_DEBUG].flags &= ~BUTTON_DISABLED; */
|
||||
/* // menu_buttons[MENU_FILES].flags &= ~BUTTON_DISABLED; */
|
||||
/* // menu_buttons[MENU_ABOUT].flags |= BUTTON_DISABLED; */
|
||||
/* // button_draw_all(menu_bmp, menu_buttons); */
|
||||
/* // gui_hide_panel(PANEL_DEBUG); */
|
||||
/* // gui_hide_panel(PANEL_FILES); */
|
||||
/* // gui_show_panel(PANEL_ABOUT); */
|
||||
/* // } */
|
||||
/* } */
|
||||
|
||||
/*
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
13
src/ports.c
13
src/ports.c
|
@ -34,7 +34,8 @@ static byte current_bank;
|
|||
static byte* port2;
|
||||
static address port2mask;
|
||||
|
||||
void ports_init( void ) {
|
||||
void ports_init( void )
|
||||
{
|
||||
// ce1 = bank switcher
|
||||
bus_info.ce1_data = NULL;
|
||||
bus_info.ce1_mask = 0x0007F;
|
||||
|
@ -47,7 +48,7 @@ void ports_init( void ) {
|
|||
bus_info.ce2_mask = 0x00000;
|
||||
bus_info.ce2_r_o = TRUE;
|
||||
#else
|
||||
#define PORT1_SIZE ( 64 * 1024 ) // Nibbles
|
||||
# define PORT1_SIZE ( 64 * 1024 ) // Nibbles
|
||||
// ce2 = port1 (plugged)
|
||||
bus_info.ce2_data = malloc( PORT1_SIZE );
|
||||
bus_info.ce2_mask = PORT1_SIZE - 1;
|
||||
|
@ -62,7 +63,7 @@ void ports_init( void ) {
|
|||
bus_info.nce3_mask = port2mask & 0x3FFFF;
|
||||
bus_info.nce3_r_o = TRUE;
|
||||
#else
|
||||
#define PORT2_SIZE ( 512 * 1024 ) // Nibbles
|
||||
# define PORT2_SIZE ( 512 * 1024 ) // Nibbles
|
||||
// nce3 = port2 (plugged)
|
||||
port2 = malloc( PORT2_SIZE );
|
||||
port2mask = PORT2_SIZE - 1;
|
||||
|
@ -77,7 +78,8 @@ void ports_init( void ) {
|
|||
|
||||
void ports_exit( void ) {}
|
||||
|
||||
void ports_switch_bank( address adr ) {
|
||||
void ports_switch_bank( address adr )
|
||||
{
|
||||
boolean need_remap = FALSE;
|
||||
|
||||
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;
|
||||
if ( bus_info.nce3_data )
|
||||
x |= 0x1;
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
|
||||
static address ram_size = 256 * 1024; // in nibbles, not bytes!
|
||||
|
||||
void ram_init( void ) {
|
||||
void ram_init( void )
|
||||
{
|
||||
byte* buf;
|
||||
|
||||
buf = malloc( ram_size );
|
||||
|
@ -45,7 +46,8 @@ void ram_init( void ) {
|
|||
bus_info.ram_mask = ram_size - 1;
|
||||
}
|
||||
|
||||
void ram_exit( void ) {
|
||||
void ram_exit( void )
|
||||
{
|
||||
free( bus_info.ram_data );
|
||||
bus_info.ram_data = NULL;
|
||||
bus_info.ram_mask = 0x00000;
|
||||
|
|
33
src/rom.c
33
src/rom.c
|
@ -34,26 +34,27 @@
|
|||
#include "rom.h"
|
||||
|
||||
#if defined( _WIN32 )
|
||||
#include <windows.h> // memset()
|
||||
#include <shlwapi.h> // PathRemoveFileSpecA
|
||||
# include <windows.h> // memset()
|
||||
# include <shlwapi.h> // PathRemoveFileSpecA
|
||||
#endif
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
#include <string.h> // memset()
|
||||
#include <ctype.h> // isalpha
|
||||
#include <unistd.h> // getcwd
|
||||
# import <CoreFoundation/CoreFoundation.h>
|
||||
# include <string.h> // memset()
|
||||
# include <ctype.h> // isalpha
|
||||
# include <unistd.h> // getcwd
|
||||
#endif
|
||||
|
||||
#if defined( __linux__ )
|
||||
#include <libgen.h> // dirname
|
||||
#include <unistd.h> // readlink
|
||||
#include <linux/limits.h> // PATH_MAX
|
||||
# include <libgen.h> // dirname
|
||||
# include <unistd.h> // readlink
|
||||
# include <linux/limits.h> // PATH_MAX
|
||||
#endif
|
||||
|
||||
static char WorkingPath[ 512 ];
|
||||
|
||||
static void getExePath() {
|
||||
static void getExePath()
|
||||
{
|
||||
char programPath[ 1024 ] = ".";
|
||||
char temp[ 1024 ];
|
||||
memset( programPath, 0, sizeof( programPath ) );
|
||||
|
@ -62,8 +63,7 @@ static void getExePath() {
|
|||
#if defined( __APPLE__ )
|
||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL( mainBundle );
|
||||
if ( !CFURLGetFileSystemRepresentation(
|
||||
resourcesURL, TRUE, ( UInt8* )programPath,
|
||||
if ( !CFURLGetFileSystemRepresentation( resourcesURL, TRUE, ( UInt8* )programPath,
|
||||
PATH_MAX ) ) // Error: expected unqualified-id before 'if'
|
||||
{
|
||||
// error!
|
||||
|
@ -108,7 +108,8 @@ static void getExePath() {
|
|||
printf( "exec path = %s\n", WorkingPath );
|
||||
}
|
||||
|
||||
static int file_size( char* name ) {
|
||||
static int file_size( char* name )
|
||||
{
|
||||
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
||||
getExePath();
|
||||
|
||||
|
@ -128,7 +129,8 @@ static int file_size( char* name ) {
|
|||
return size;
|
||||
}
|
||||
|
||||
void rom_init( void ) {
|
||||
void rom_init( void )
|
||||
{
|
||||
printf( "rom_init..\n" );
|
||||
int size;
|
||||
char* name = "hpemu.rom";
|
||||
|
@ -190,7 +192,8 @@ void rom_init( void ) {
|
|||
printf( "rom_init succeed!\n" );
|
||||
}
|
||||
|
||||
void rom_exit( void ) {
|
||||
void rom_exit( void )
|
||||
{
|
||||
free( bus_info.rom_data );
|
||||
bus_info.rom_data = NULL;
|
||||
bus_info.rom_mask = 0x00000;
|
||||
|
|
21
src/rpl.c
21
src/rpl.c
|
@ -38,7 +38,8 @@
|
|||
#define AVMEM 0x807ED
|
||||
#define INTRPPTR 0x8072F
|
||||
|
||||
int rpl_object_size( byte* obj ) {
|
||||
int rpl_object_size( byte* obj )
|
||||
{
|
||||
int size;
|
||||
int prologue;
|
||||
int n;
|
||||
|
@ -126,7 +127,8 @@ int rpl_object_size( byte* obj ) {
|
|||
return size;
|
||||
}
|
||||
|
||||
static address read_address( address adr ) {
|
||||
static address read_address( address adr )
|
||||
{
|
||||
byte buf[ 5 ];
|
||||
word ocrc;
|
||||
|
||||
|
@ -137,14 +139,16 @@ static address read_address( address adr ) {
|
|||
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 ];
|
||||
|
||||
unsigned_to_nib( buf, val, 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 ) );
|
||||
word ocrc;
|
||||
|
||||
|
@ -160,7 +164,8 @@ static int moveup( address src, address dst, address cnt ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
address rpl_make_temp( address size ) {
|
||||
address rpl_make_temp( address size )
|
||||
{
|
||||
address temptop, rsktop, dsktop;
|
||||
|
||||
size += 6;
|
||||
|
@ -183,7 +188,8 @@ address rpl_make_temp( address size ) {
|
|||
return temptop + 1;
|
||||
}
|
||||
|
||||
void rpl_push( address adr ) {
|
||||
void rpl_push( address adr )
|
||||
{
|
||||
address dsktop, avmem;
|
||||
|
||||
avmem = read_address( AVMEM );
|
||||
|
@ -197,7 +203,8 @@ void rpl_push( address adr ) {
|
|||
write_address( DSKTOP, dsktop );
|
||||
}
|
||||
|
||||
int rpl_push_object( byte* obj, address size ) {
|
||||
int rpl_push_object( byte* obj, address size )
|
||||
{
|
||||
address adr;
|
||||
|
||||
adr = rpl_make_temp( size );
|
||||
|
|
|
@ -44,7 +44,8 @@ byte timer2_control;
|
|||
byte timer1_value;
|
||||
dword timer2_value;
|
||||
|
||||
void timer1_update( void ) {
|
||||
void timer1_update( void )
|
||||
{
|
||||
if ( timer2_control & TIMER_RUN ) {
|
||||
timer1_value--;
|
||||
timer1_value &= 0xF;
|
||||
|
@ -71,7 +72,8 @@ void timer1_update( void ) {
|
|||
}
|
||||
}
|
||||
|
||||
void timer2_update( void ) {
|
||||
void timer2_update( void )
|
||||
{
|
||||
if ( timer2_control & TIMER_RUN ) {
|
||||
timer2_value--;
|
||||
if ( timer2_value & 0x80000000 ) {
|
||||
|
|
|
@ -35,8 +35,8 @@ typedef signed int address;
|
|||
typedef char boolean;
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE -1
|
||||
#define FALSE 0
|
||||
# define TRUE -1
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue