more cleaning and fiddling
This commit is contained in:
parent
36cf9a1aac
commit
ce63fac57e
19 changed files with 273 additions and 474 deletions
17
src/bus.c
17
src/bus.c
|
@ -7,17 +7,23 @@
|
|||
#include "hdw.h"
|
||||
#include "bus.h"
|
||||
|
||||
#define SEG_OF( adr ) ( ( adr ) >> 12 )
|
||||
#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 ) )
|
||||
#define MAP_WRITE( adr ) ( write_map[ SEG_OF( adr ) ] + OFFSET_OF( adr ) )
|
||||
|
||||
BusInfo bus_info = {
|
||||
// hdw ram sz ram ce1 sz ce1 ce2 sz ce2 nce3 sz nce3
|
||||
0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000, 0x00000,
|
||||
0x00000, // base or size
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // base or size
|
||||
false, false, false, false, false, false, false, false, false, // configured
|
||||
false, false, false, // read only
|
||||
// ce1_bs da19 ben
|
||||
false, false, false,
|
||||
// rom ram ce1 ce2 nce3
|
||||
NULL, NULL, NULL, NULL, NULL, // data
|
||||
0x00000, 0x00000, 0x00000, 0x00000, 0x00000 // mask
|
||||
NULL, NULL, NULL, NULL, NULL, // data
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0 // mask
|
||||
};
|
||||
|
||||
static byte* read_map[ 256 ];
|
||||
|
@ -29,7 +35,6 @@ word crc;
|
|||
void bus_init( void )
|
||||
{
|
||||
rom_init();
|
||||
hdw_init();
|
||||
ram_init();
|
||||
ports_init();
|
||||
bus_reset();
|
||||
|
@ -38,9 +43,7 @@ void bus_init( 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 ); }
|
||||
|
|
|
@ -3,15 +3,6 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
#define SEG_OF( adr ) ( ( adr ) >> 12 )
|
||||
#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 ) )
|
||||
#define MAP_WRITE( adr ) ( write_map[ SEG_OF( adr ) ] + OFFSET_OF( adr ) )
|
||||
|
||||
#define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
|
||||
|
||||
typedef struct {
|
||||
address hdw_base;
|
||||
address ram_size;
|
||||
|
|
28
src/color.c
28
src/color.c
|
@ -8,10 +8,6 @@ enum LCD_Modes { LCD_MODE_SIMPLE, LCD_MODE_GRAY4, LCD_MODE_GRAY8, LCD_MODE_EXP }
|
|||
|
||||
int color[ C_COUNT ];
|
||||
|
||||
typedef struct RGB {
|
||||
unsigned char r, g, b;
|
||||
} RGB;
|
||||
|
||||
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;
|
||||
|
@ -39,9 +35,7 @@ typedef int ( *lcd_color_func )( int i );
|
|||
|
||||
lcd_color_func lcd_color_functions[] = { simple_color, gray4_color, gray8_color, exp_color };
|
||||
|
||||
void build_lcd_palette( void ) {}
|
||||
|
||||
void color_lcd( int r0, int g0, int b0, int r1, int g1, int b1 )
|
||||
static inline 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;
|
||||
|
@ -49,33 +43,15 @@ void color_lcd( int r0, int g0, int b0, int r1, int g1, int b1 )
|
|||
lcd_1_r = r1 >> 2;
|
||||
lcd_1_g = g1 >> 2;
|
||||
lcd_1_b = b1 >> 2;
|
||||
build_lcd_palette();
|
||||
}
|
||||
|
||||
void color_lcd_mode( int mode )
|
||||
{
|
||||
lcd_mode = mode;
|
||||
build_lcd_palette();
|
||||
}
|
||||
|
||||
void color_set_emu( int i, int r, int g, int b ) {}
|
||||
static inline void color_lcd_mode( int mode ) { lcd_mode = mode; }
|
||||
|
||||
void color_init( void )
|
||||
{
|
||||
for ( int i = 0; i < C_COUNT; i++ )
|
||||
color[ i ] = RESERVED_LCD + i;
|
||||
|
||||
color_set_emu( C_BACKGROUND, 0, 0, 0 );
|
||||
color_set_emu( C_PANEL_BACK, 64, 64, 64 );
|
||||
color_set_emu( C_PANEL_BORDER, 128, 128, 128 );
|
||||
color_set_emu( C_PANEL_TEXT, 255, 255, 255 );
|
||||
color_set_emu( C_PANEL_DISABLED, 128, 128, 128 );
|
||||
color_set_emu( C_BUTTON_BACK, 64, 64, 64 );
|
||||
color_set_emu( C_BUTTON_BORDER, 128, 128, 128 );
|
||||
color_set_emu( C_BUTTON_PUSHED, 128, 128, 128 );
|
||||
color_set_emu( C_BUTTON_TEXT, 255, 255, 255 );
|
||||
color_set_emu( C_BUTTON_DISABLED, 128, 128, 128 );
|
||||
|
||||
color_lcd( 128, 192, 128, 0, 0, 64 );
|
||||
color_lcd_mode( LCD_MODE_GRAY4 );
|
||||
}
|
||||
|
|
36
src/cpu.c
36
src/cpu.c
|
@ -10,6 +10,24 @@ Cpu cpu;
|
|||
|
||||
#define MAX_OPC_LEN 21
|
||||
|
||||
static inline void decode( byte* ptr )
|
||||
{
|
||||
Opcode* op = opcodes;
|
||||
int i = 0;
|
||||
|
||||
while ( op[ ptr[ i ] ].next ) {
|
||||
op = op[ ptr[ i ] ].next;
|
||||
i++;
|
||||
}
|
||||
|
||||
if ( op[ ptr[ i ] ].exec ) {
|
||||
op[ ptr[ i ] ].exec( ptr );
|
||||
cpu.pc &= 0xFFFFF;
|
||||
cpu.inst_cnt++;
|
||||
} else
|
||||
emulator_set_state( EMULATOR_STOP );
|
||||
}
|
||||
|
||||
void cpu_interrupt( void )
|
||||
{
|
||||
if ( !cpu.inte )
|
||||
|
@ -21,24 +39,6 @@ void cpu_interrupt( void )
|
|||
cpu.pc = 0x0000F;
|
||||
}
|
||||
|
||||
static void decode( byte* ptr )
|
||||
{
|
||||
Opcode* op = opcodes;
|
||||
int i = 0;
|
||||
|
||||
while ( op[ ptr[ i ] ].next ) {
|
||||
op = op[ ptr[ i ] ].next;
|
||||
i++;
|
||||
}
|
||||
if ( op[ ptr[ i ] ].exec ) {
|
||||
op[ ptr[ i ] ].exec( ptr );
|
||||
cpu.pc &= 0xFFFFF;
|
||||
cpu.inst_cnt++;
|
||||
} else {
|
||||
emulator_set_state( EMULATOR_STOP );
|
||||
}
|
||||
}
|
||||
|
||||
void execute_instruction( void )
|
||||
{
|
||||
static byte buffer[ FAST_PEEK_MAX ];
|
||||
|
|
|
@ -40,28 +40,6 @@ extern SDL_Texture* texTarget;
|
|||
extern SDL_Texture* tex2Target;
|
||||
extern SDL_Texture* faceplateTexture;
|
||||
|
||||
void clearLCD()
|
||||
{
|
||||
SDL_SetRenderDrawColor( renderer, 48, 68, 90, 0xFF ); // bleu foncé
|
||||
SDL_RenderClear( renderer );
|
||||
|
||||
if ( faceplateTexture ) {
|
||||
SDL_Rect r3 = { 8, 0, 504, 1124 };
|
||||
SDL_RenderCopy( renderer, faceplateTexture, NULL, &r3 );
|
||||
}
|
||||
}
|
||||
|
||||
void endLCD()
|
||||
{
|
||||
SDL_Rect r1 = { 0, 0, 131, 64 };
|
||||
SDL_Rect r2 = { LCD_X, LCD_Y, 524, 256 };
|
||||
SDL_RenderCopyEx( renderer, texTarget, &r1, &r2, 0, NULL, SDL_FLIP_NONE );
|
||||
|
||||
pcalc_show();
|
||||
}
|
||||
|
||||
void renderLCD() {}
|
||||
|
||||
static address draw_lcd_line( address adr, int y )
|
||||
{
|
||||
int x = 0;
|
||||
|
@ -73,9 +51,8 @@ static address draw_lcd_line( address adr, int y )
|
|||
|
||||
// Horisontal pixel offset
|
||||
if ( !in_menu ) {
|
||||
if ( display_offset > 3 ) {
|
||||
if ( display_offset > 3 )
|
||||
ptr++;
|
||||
}
|
||||
|
||||
data = *ptr++;
|
||||
data >>= display_offset & 3;
|
||||
|
@ -102,37 +79,29 @@ static address draw_lcd_line( address adr, int y )
|
|||
byte prev2_pixel = prev2_lcdScreen[ x + y * 131 ];
|
||||
|
||||
if ( drawGS == true ) {
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\0' && pixel == '\0' ) {
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\0' && pixel == '\0' )
|
||||
pixelGS = '\0';
|
||||
}
|
||||
|
||||
if ( prev2_pixel == '\3' && prev_pixel == '\3' && pixel == '\3' ) {
|
||||
if ( prev2_pixel == '\3' && prev_pixel == '\3' && pixel == '\3' )
|
||||
pixelGS = '\3';
|
||||
}
|
||||
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\3' && pixel == '\3' ) {
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\3' && pixel == '\3' )
|
||||
pixelGS = '\2';
|
||||
}
|
||||
|
||||
if ( prev2_pixel == '\3' && prev_pixel == '\0' && pixel == '\0' ) {
|
||||
if ( prev2_pixel == '\3' && prev_pixel == '\0' && pixel == '\0' )
|
||||
pixelGS = '\1';
|
||||
}
|
||||
|
||||
if ( prev2_pixel == '\3' && prev_pixel == '\3' && pixel == '\0' ) {
|
||||
if ( prev2_pixel == '\3' && prev_pixel == '\3' && pixel == '\0' )
|
||||
pixelGS = '\2';
|
||||
}
|
||||
|
||||
if ( prev2_pixel == '\3' && prev_pixel == '\0' && pixel == '\3' ) {
|
||||
if ( prev2_pixel == '\3' && prev_pixel == '\0' && pixel == '\3' )
|
||||
pixelGS = '\2';
|
||||
}
|
||||
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\0' && pixel == '\3' ) {
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\0' && pixel == '\3' )
|
||||
pixelGS = '\1';
|
||||
}
|
||||
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\3' && pixel == '\0' ) {
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\3' && pixel == '\0' )
|
||||
pixelGS = '\1';
|
||||
}
|
||||
|
||||
lcdScreenGS[ x + y * 131 ] = pixelGS;
|
||||
}
|
||||
|
@ -145,10 +114,6 @@ static address draw_lcd_line( address adr, int y )
|
|||
return ( adr + 0x22 + ( !in_menu && ( display_offset & 4 ) ? 2 : 0 ) ) & 0xFFFFF;
|
||||
}
|
||||
|
||||
void display_init( void ) {}
|
||||
|
||||
void display_exit( void ) {}
|
||||
|
||||
void display_show()
|
||||
{
|
||||
SDL_SetRenderDrawColor( renderer, 48, 68, 90, 0xFF ); // bleu foncé
|
||||
|
@ -167,13 +132,11 @@ void display_show()
|
|||
int access;
|
||||
Uint32 format;
|
||||
|
||||
if ( SDL_QueryTexture( texTarget, &format, &access, &w, &h ) != 0 ) {
|
||||
if ( SDL_QueryTexture( texTarget, &format, &access, &w, &h ) != 0 )
|
||||
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() );
|
||||
}
|
||||
|
||||
SDL_PixelFormat* pixelFormat = SDL_AllocFormat( format );
|
||||
|
||||
|
@ -245,12 +208,11 @@ void display_update( void )
|
|||
}
|
||||
|
||||
if ( !off_cnt ) { /* Display is on */
|
||||
|
||||
cur_adr = draw_lcd_line( cur_adr, display_line_count );
|
||||
|
||||
if ( !in_menu ) {
|
||||
if ( !in_menu )
|
||||
cur_adr += display_line_offset;
|
||||
}
|
||||
|
||||
if ( display_line_count == display_height ) {
|
||||
in_menu = 1;
|
||||
cur_adr = menu_base;
|
||||
|
@ -266,19 +228,12 @@ void display_update( void )
|
|||
shouldRender = true;
|
||||
|
||||
screen_draw_count++;
|
||||
if ( screen_draw_count == 3 ) {
|
||||
|
||||
if ( screen_draw_count == 3 )
|
||||
screen_draw_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( screen_draw_count == 0 ) {
|
||||
drawGS = true;
|
||||
} else {
|
||||
drawGS = false;
|
||||
}
|
||||
drawGS = screen_draw_count == 0;
|
||||
|
||||
} else if ( off_cnt <= 7 ) { /* Display is off and still fading */
|
||||
} else if ( off_cnt <= 7 ) /* Display is off and still fading */
|
||||
off_cnt = 8;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ extern byte display_height;
|
|||
extern byte display_offset;
|
||||
extern bool display_enable;
|
||||
|
||||
extern void display_init( void );
|
||||
extern void display_exit( void );
|
||||
extern void display_update( void );
|
||||
extern void display_show( void );
|
||||
|
||||
|
|
|
@ -46,19 +46,14 @@ void emulator_init( void )
|
|||
static bool locked = false;
|
||||
|
||||
bus_init();
|
||||
display_init();
|
||||
|
||||
if ( !locked )
|
||||
locked = true;
|
||||
}
|
||||
|
||||
void emulator_exit( void )
|
||||
{
|
||||
display_exit();
|
||||
bus_exit();
|
||||
}
|
||||
void emulator_exit( void ) { bus_exit(); }
|
||||
|
||||
void throttle( bool is_needed )
|
||||
static inline void throttle( bool is_needed )
|
||||
{
|
||||
if ( !is_needed )
|
||||
return;
|
||||
|
|
133
src/gui.c
133
src/gui.c
|
@ -29,7 +29,7 @@ SDL_Texture* textD[ 49 ];
|
|||
|
||||
#define PANEL_FLAG_VISIBLE 0x01
|
||||
|
||||
void drawText( int index, int x, int y, int btn_w, int btn_h )
|
||||
static inline void drawText( int index, int x, int y, int btn_w, int btn_h )
|
||||
{
|
||||
SDL_Surface* letterSurface = surfA[ index ];
|
||||
SDL_Texture* letterTexture = textA[ index ];
|
||||
|
@ -157,86 +157,7 @@ void gui_initKeyboard( Button* calcbuttons )
|
|||
}
|
||||
}
|
||||
|
||||
/* void gui_exit( void ) */
|
||||
/* { */
|
||||
/* /\* int i; *\/ */
|
||||
|
||||
/* /\* for ( i = 0; i < PANEL_COUNT; i++ ) { *\/ */
|
||||
/* /\* gui_hide_panel( i ); *\/ */
|
||||
/* /\* } *\/ */
|
||||
/* } */
|
||||
|
||||
/* 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 &&
|
||||
*/
|
||||
/* y < panels[ i ].y + panels[ i ].h ) { */
|
||||
/* break; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return i; */
|
||||
/* } */
|
||||
|
||||
/* void gui_update( void ) */
|
||||
/* { */
|
||||
/* /\* */
|
||||
/* static int down_panel = -1; */
|
||||
/* static int down_mb = 0; */
|
||||
/* int mx, my, mb; */
|
||||
|
||||
/* mx = mouse_x; */
|
||||
/* my = mouse_y; */
|
||||
/* mb = mouse_b; */
|
||||
|
||||
/* if (!down_mb && (mb & 1)) { */
|
||||
/* down_panel = panel_at(mx, my); */
|
||||
/* if (down_panel >= 0) { */
|
||||
/* down_mb = 1; */
|
||||
/* panels[down_panel].mouse_down(mx - panels[down_panel].x, my - */
|
||||
/* panels[down_panel].y, down_mb); */
|
||||
/* } */
|
||||
/* } else if (!down_mb && (mb & 2)) { */
|
||||
/* down_panel = panel_at(mx, my); */
|
||||
/* if (down_panel >= 0) { */
|
||||
/* down_mb = 2; */
|
||||
/* panels[down_panel].mouse_down(mx - panels[down_panel].x, my - */
|
||||
/* panels[down_panel].y, down_mb); */
|
||||
/* } */
|
||||
/* } else if (down_mb && !(mb & 3)) { */
|
||||
/* panels[down_panel].mouse_up(mx - panels[down_panel].x, my - */
|
||||
/* panels[down_panel].y, down_mb); down_mb = 0; down_panel = -1; */
|
||||
/* } */
|
||||
/* *\/ */
|
||||
/* } */
|
||||
|
||||
/* void gui_show_panel( int i ) */
|
||||
/* { */
|
||||
/* /\* */
|
||||
/* if (!(panels[i].flags & PANEL_FLAG_VISIBLE)) { */
|
||||
/* panels[i].flags |= PANEL_FLAG_VISIBLE; */
|
||||
/* panels[i].bmp = create_sub_bitmap(screen, panels[i].x, panels[i].y, */
|
||||
/* panels[i].w, panels[i].h); acquire_screen(); scare_mouse(); rect(screen, */
|
||||
/* panels[i].x-1, panels[i].y-1, panels[i].x+panels[i].w, panels[i].y+panels[i].h, */
|
||||
/* color[C_PANEL_BORDER]); panels[i].show(panels[i].bmp); unscare_mouse(); */
|
||||
/* release_screen(); */
|
||||
/* }*\/ */
|
||||
/* } */
|
||||
|
||||
/* void gui_hide_panel( int i ) */
|
||||
/* { */
|
||||
/* /\* */
|
||||
/* if (panels[i].flags & PANEL_FLAG_VISIBLE) { */
|
||||
/* panels[i].flags &= ~PANEL_FLAG_VISIBLE; */
|
||||
/* panels[i].hide(); */
|
||||
/* destroy_bitmap(panels[i].bmp); */
|
||||
/* panels[i].bmp = NULL; */
|
||||
/* }*\/ */
|
||||
/* } */
|
||||
|
||||
void button_draw( Button* b )
|
||||
static inline void button_draw( Button* b )
|
||||
{
|
||||
SDL_Rect rectToDraw = { b->x * 2, b->y * 2, b->w * 2, b->h * 2 };
|
||||
|
||||
|
@ -245,9 +166,6 @@ void button_draw( Button* b )
|
|||
|
||||
drawText( b->index, b->x * 2, 10 + b->y * 2, b->w * 2, b->h * 2 );
|
||||
|
||||
/* 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 );
|
||||
SDL_RenderDrawRect( renderer, &rectToDraw );
|
||||
|
@ -256,20 +174,6 @@ void button_draw( Button* b )
|
|||
SDL_SetRenderDrawColor( renderer, 0xFF, 0xFF, 0xFF, 0xFF );
|
||||
SDL_RenderDrawRect( renderer, &rectToDraw );
|
||||
}
|
||||
|
||||
/*
|
||||
int c;
|
||||
|
||||
c = color[(b->flags&BUTTON_PUSHED) ? C_BUTTON_PUSHED : C_BUTTON_BACK];
|
||||
text_mode(c);
|
||||
acquire_bitmap(bmp);
|
||||
scare_mouse();
|
||||
rect(bmp, b->x-1, b->y-1, b->x+b->w, b->y+b->h, color[C_BUTTON_BORDER]);
|
||||
rectfill(bmp, b->x, b->y, b->x+b->w-1, b->y+b->h-1, c);
|
||||
c = color[(b->flags&BUTTON_DISABLED) ? C_BUTTON_DISABLED : C_BUTTON_TEXT];
|
||||
textout_centre(bmp, font, b->text, b->x+b->w/2, b->y+(b->h-text_height
|
||||
(font))/2, c); unscare_mouse(); release_bitmap(bmp);
|
||||
*/
|
||||
}
|
||||
|
||||
void button_draw_all( Button* buttons )
|
||||
|
@ -283,73 +187,70 @@ void button_draw_all( Button* buttons )
|
|||
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++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int button_mouse_down( Button* buttons, int mx, int my, int mb )
|
||||
{
|
||||
Button* b = find_button( buttons, mx, my );
|
||||
if ( !b ) {
|
||||
if ( !b )
|
||||
return 0;
|
||||
}
|
||||
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 ( b->flags & BUTTON_PUSHED ) {
|
||||
b->flags &= ~BUTTON_PUSHED;
|
||||
// button_draw(bmp, b);
|
||||
|
||||
if ( b->up )
|
||||
b->up( true );
|
||||
b->up();
|
||||
} else {
|
||||
b->flags |= BUTTON_PUSHED;
|
||||
// button_draw(bmp, b);
|
||||
|
||||
if ( b->down )
|
||||
b->down();
|
||||
}
|
||||
} else if ( mb == 1 && !( b->flags & BUTTON_PUSHED ) ) {
|
||||
b->flags |= BUTTON_PUSHED;
|
||||
// button_draw(bmp, b);
|
||||
|
||||
if ( b->down )
|
||||
b->down();
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my, int mb )
|
||||
int button_mouse_up( Button* buttons, int mx, int my, int mb )
|
||||
{
|
||||
Button* b = find_button( buttons, mx, my );
|
||||
int ret = ( b != NULL );
|
||||
if ( b ) {
|
||||
printf( "Release %s\n", b->text );
|
||||
}
|
||||
|
||||
if ( b && !( b->flags & BUTTON_DISABLED ) ) {
|
||||
if ( mb == 1 && ( b->flags & BUTTON_PUSHED ) && !( b->flags & BUTTON_B1TOGGLE ) ) {
|
||||
b->flags &= ~BUTTON_PUSHED;
|
||||
// button_draw(bmp, b);
|
||||
|
||||
if ( b->up )
|
||||
b->up( true );
|
||||
b->up();
|
||||
}
|
||||
}
|
||||
if ( mb == 1 ) {
|
||||
for ( b = buttons; b->text; b++ ) {
|
||||
if ( ( b->flags & ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) == ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) {
|
||||
b->flags &= ~BUTTON_PUSHED;
|
||||
// button_draw(bmp, b);
|
||||
|
||||
if ( b->up )
|
||||
b->up( false );
|
||||
b->up();
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ typedef struct {
|
|||
char* textC;
|
||||
char* textD;
|
||||
void ( *down )( void );
|
||||
void ( *up )( bool action );
|
||||
void ( *up )( void );
|
||||
} Button;
|
||||
|
||||
/* Button flags:
|
||||
|
|
|
@ -7,14 +7,9 @@
|
|||
|
||||
static byte hdw_ram[ 64 ];
|
||||
|
||||
void hdw_init( void ) {}
|
||||
|
||||
void hdw_exit( void ) {}
|
||||
|
||||
byte hdw_read_nibble( address adr )
|
||||
{
|
||||
switch ( adr ) {
|
||||
|
||||
case 0x00:
|
||||
return display_offset | ( display_enable ? 0x8 : 0x0 );
|
||||
|
||||
|
@ -66,8 +61,6 @@ byte hdw_read_nibble( address adr )
|
|||
|
||||
void hdw_write_nibble( byte data, address adr )
|
||||
{
|
||||
int tmp;
|
||||
|
||||
switch ( adr ) {
|
||||
|
||||
case 0x00:
|
||||
|
@ -139,7 +132,7 @@ void hdw_write_nibble( byte data, address adr )
|
|||
display_height &= 0x0F;
|
||||
display_height |= ( data & 3 ) << 4;
|
||||
hdw_ram[ 0x29 ] = data & 0x4;
|
||||
tmp = bus_info.da19;
|
||||
int tmp = bus_info.da19;
|
||||
bus_info.da19 = ( data & 0x8 ) ? true : false;
|
||||
if ( tmp != bus_info.da19 ) {
|
||||
bus_remap();
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
extern void hdw_init( void );
|
||||
extern void hdw_exit( void );
|
||||
|
||||
extern byte hdw_read_nibble( address adr );
|
||||
extern void hdw_write_nibble( byte data, address adr );
|
||||
|
||||
|
|
309
src/pcalc.c
309
src/pcalc.c
|
@ -8,107 +8,106 @@
|
|||
#include "pfiles.h"
|
||||
|
||||
static void dn00( void ) { kbd_key_pressed( 0, 0 ); }
|
||||
static void up00( bool action ) { kbd_key_released( 0, 0 ); }
|
||||
static void up00( void ) { kbd_key_released( 0, 0 ); }
|
||||
static void dn01( void ) { kbd_key_pressed( 0, 1 ); }
|
||||
static void up01( bool action ) { kbd_key_released( 0, 1 ); }
|
||||
static void up01( void ) { kbd_key_released( 0, 1 ); }
|
||||
static void dn02( void ) { kbd_key_pressed( 0, 2 ); }
|
||||
static void up02( bool action ) { kbd_key_released( 0, 2 ); }
|
||||
static void up02( void ) { kbd_key_released( 0, 2 ); }
|
||||
static void dn03( void ) { kbd_key_pressed( 0, 3 ); }
|
||||
static void up03( bool action ) { kbd_key_released( 0, 3 ); }
|
||||
static void up03( void ) { kbd_key_released( 0, 3 ); }
|
||||
static void dn04( void ) { kbd_key_pressed( 0, 4 ); }
|
||||
static void up04( bool action ) { kbd_key_released( 0, 4 ); }
|
||||
static void up04( void ) { kbd_key_released( 0, 4 ); }
|
||||
static void dn10( void ) { kbd_key_pressed( 1, 0 ); }
|
||||
static void up10( bool action ) { kbd_key_released( 1, 0 ); }
|
||||
static void up10( void ) { kbd_key_released( 1, 0 ); }
|
||||
static void dn11( void ) { kbd_key_pressed( 1, 1 ); }
|
||||
static void up11( bool action ) { kbd_key_released( 1, 1 ); }
|
||||
static void up11( void ) { kbd_key_released( 1, 1 ); }
|
||||
static void dn12( void ) { kbd_key_pressed( 1, 2 ); }
|
||||
static void up12( bool action ) { kbd_key_released( 1, 2 ); }
|
||||
static void up12( void ) { kbd_key_released( 1, 2 ); }
|
||||
static void dn13( void ) { kbd_key_pressed( 1, 3 ); }
|
||||
static void up13( bool action ) { kbd_key_released( 1, 3 ); }
|
||||
static void up13( void ) { kbd_key_released( 1, 3 ); }
|
||||
static void dn14( void ) { kbd_key_pressed( 1, 4 ); }
|
||||
static void up14( bool action ) { kbd_key_released( 1, 4 ); }
|
||||
static void up14( void ) { kbd_key_released( 1, 4 ); }
|
||||
static void dn15( void ) { kbd_key_pressed( 1, 5 ); }
|
||||
static void up15( bool action ) { kbd_key_released( 1, 5 ); }
|
||||
static void up15( void ) { kbd_key_released( 1, 5 ); }
|
||||
static void dn20( void ) { kbd_key_pressed( 2, 0 ); }
|
||||
static void up20( bool action ) { kbd_key_released( 2, 0 ); }
|
||||
static void up20( void ) { kbd_key_released( 2, 0 ); }
|
||||
static void dn21( void ) { kbd_key_pressed( 2, 1 ); }
|
||||
static void up21( bool action ) { kbd_key_released( 2, 1 ); }
|
||||
static void up21( void ) { kbd_key_released( 2, 1 ); }
|
||||
static void dn22( void ) { kbd_key_pressed( 2, 2 ); }
|
||||
static void up22( bool action ) { kbd_key_released( 2, 2 ); }
|
||||
static void up22( void ) { kbd_key_released( 2, 2 ); }
|
||||
static void dn23( void ) { kbd_key_pressed( 2, 3 ); }
|
||||
static void up23( bool action ) { kbd_key_released( 2, 3 ); }
|
||||
static void up23( void ) { kbd_key_released( 2, 3 ); }
|
||||
static void dn24( void ) { kbd_key_pressed( 2, 4 ); }
|
||||
static void up24( bool action ) { kbd_key_released( 2, 4 ); }
|
||||
static void up24( void ) { kbd_key_released( 2, 4 ); }
|
||||
static void dn25( void ) { kbd_key_pressed( 2, 5 ); }
|
||||
static void up25( bool action ) { kbd_key_released( 2, 5 ); }
|
||||
static void up25( void ) { kbd_key_released( 2, 5 ); }
|
||||
static void dn30( void ) { kbd_key_pressed( 3, 0 ); }
|
||||
static void up30( bool action ) { kbd_key_released( 3, 0 ); }
|
||||
static void up30( void ) { kbd_key_released( 3, 0 ); }
|
||||
static void dn31( void ) { kbd_key_pressed( 3, 1 ); }
|
||||
static void up31( bool action ) { kbd_key_released( 3, 1 ); }
|
||||
static void up31( void ) { kbd_key_released( 3, 1 ); }
|
||||
static void dn32( void ) { kbd_key_pressed( 3, 2 ); }
|
||||
static void up32( bool action ) { kbd_key_released( 3, 2 ); }
|
||||
static void up32( void ) { kbd_key_released( 3, 2 ); }
|
||||
static void dn33( void ) { kbd_key_pressed( 3, 3 ); }
|
||||
static void up33( bool action ) { kbd_key_released( 3, 3 ); }
|
||||
static void up33( void ) { kbd_key_released( 3, 3 ); }
|
||||
static void dn34( void ) { kbd_key_pressed( 3, 4 ); }
|
||||
static void up34( bool action ) { kbd_key_released( 3, 4 ); }
|
||||
static void up34( void ) { kbd_key_released( 3, 4 ); }
|
||||
static void dn35( void ) { kbd_key_pressed( 3, 5 ); }
|
||||
static void up35( bool action ) { kbd_key_released( 3, 5 ); }
|
||||
static void up35( void ) { kbd_key_released( 3, 5 ); }
|
||||
static void dn40( void ) { kbd_key_pressed( 4, 0 ); }
|
||||
static void up40( bool action ) { kbd_key_released( 4, 0 ); }
|
||||
static void up40( void ) { kbd_key_released( 4, 0 ); }
|
||||
static void dn41( void ) { kbd_key_pressed( 4, 1 ); }
|
||||
static void up41( bool action ) { kbd_key_released( 4, 1 ); }
|
||||
static void up41( void ) { kbd_key_released( 4, 1 ); }
|
||||
static void dn42( void ) { kbd_key_pressed( 4, 2 ); }
|
||||
static void up42( bool action ) { kbd_key_released( 4, 2 ); }
|
||||
static void up42( void ) { kbd_key_released( 4, 2 ); }
|
||||
static void dn43( void ) { kbd_key_pressed( 4, 3 ); }
|
||||
static void up43( bool action ) { kbd_key_released( 4, 3 ); }
|
||||
static void up43( void ) { kbd_key_released( 4, 3 ); }
|
||||
static void dn44( void ) { kbd_key_pressed( 4, 4 ); }
|
||||
static void up44( bool action ) { kbd_key_released( 4, 4 ); }
|
||||
static void up44( void ) { kbd_key_released( 4, 4 ); }
|
||||
static void dn50( void ) { kbd_key_pressed( 5, 0 ); }
|
||||
static void up50( bool action ) { kbd_key_released( 5, 0 ); }
|
||||
static void up50( void ) { kbd_key_released( 5, 0 ); }
|
||||
static void dn51( void ) { kbd_key_pressed( 5, 1 ); }
|
||||
static void up51( bool action ) { kbd_key_released( 5, 1 ); }
|
||||
static void up51( void ) { kbd_key_released( 5, 1 ); }
|
||||
static void dn52( void ) { kbd_key_pressed( 5, 2 ); }
|
||||
static void up52( bool action ) { kbd_key_released( 5, 2 ); }
|
||||
static void up52( void ) { kbd_key_released( 5, 2 ); }
|
||||
static void dn53( void ) { kbd_key_pressed( 5, 3 ); }
|
||||
static void up53( bool action ) { kbd_key_released( 5, 3 ); }
|
||||
static void up53( void ) { kbd_key_released( 5, 3 ); }
|
||||
static void dn54( void ) { kbd_key_pressed( 5, 4 ); }
|
||||
static void up54( bool action ) { kbd_key_released( 5, 4 ); }
|
||||
static void up54( void ) { kbd_key_released( 5, 4 ); }
|
||||
static void dn60( void ) { kbd_key_pressed( 6, 0 ); }
|
||||
static void up60( bool action ) { kbd_key_released( 6, 0 ); }
|
||||
static void up60( void ) { kbd_key_released( 6, 0 ); }
|
||||
static void dn61( void ) { kbd_key_pressed( 6, 1 ); }
|
||||
static void up61( bool action ) { kbd_key_released( 6, 1 ); }
|
||||
static void up61( void ) { kbd_key_released( 6, 1 ); }
|
||||
static void dn62( void ) { kbd_key_pressed( 6, 2 ); }
|
||||
static void up62( bool action ) { kbd_key_released( 6, 2 ); }
|
||||
static void up62( void ) { kbd_key_released( 6, 2 ); }
|
||||
static void dn63( void ) { kbd_key_pressed( 6, 3 ); }
|
||||
static void up63( bool action ) { kbd_key_released( 6, 3 ); }
|
||||
static void up63( void ) { kbd_key_released( 6, 3 ); }
|
||||
static void dn64( void ) { kbd_key_pressed( 6, 4 ); }
|
||||
static void up64( bool action ) { kbd_key_released( 6, 4 ); }
|
||||
static void up64( void ) { kbd_key_released( 6, 4 ); }
|
||||
static void dn70( void ) { kbd_key_pressed( 7, 0 ); }
|
||||
static void up70( bool action ) { kbd_key_released( 7, 0 ); }
|
||||
static void up70( void ) { kbd_key_released( 7, 0 ); }
|
||||
static void dn71( void ) { kbd_key_pressed( 7, 1 ); }
|
||||
static void up71( bool action ) { kbd_key_released( 7, 1 ); }
|
||||
static void up71( void ) { kbd_key_released( 7, 1 ); }
|
||||
static void dn72( void ) { kbd_key_pressed( 7, 2 ); }
|
||||
static void up72( bool action ) { kbd_key_released( 7, 2 ); }
|
||||
static void up72( void ) { kbd_key_released( 7, 2 ); }
|
||||
static void dn73( void ) { kbd_key_pressed( 7, 3 ); }
|
||||
static void up73( bool action ) { kbd_key_released( 7, 3 ); }
|
||||
static void up73( void ) { kbd_key_released( 7, 3 ); }
|
||||
static void dn74( void ) { kbd_key_pressed( 7, 4 ); }
|
||||
static void up74( bool action ) { kbd_key_released( 7, 4 ); }
|
||||
static void up74( void ) { kbd_key_released( 7, 4 ); }
|
||||
static void dn80( void ) { kbd_key_pressed( 8, 0 ); }
|
||||
static void up80( bool action ) { kbd_key_released( 8, 0 ); }
|
||||
static void up80( void ) { kbd_key_released( 8, 0 ); }
|
||||
static void dn81( void ) { kbd_key_pressed( 8, 1 ); }
|
||||
static void up81( bool action ) { kbd_key_released( 8, 1 ); }
|
||||
static void up81( void ) { kbd_key_released( 8, 1 ); }
|
||||
static void dn82( void ) { kbd_key_pressed( 8, 2 ); }
|
||||
static void up82( bool action ) { kbd_key_released( 8, 2 ); }
|
||||
static void up82( void ) { kbd_key_released( 8, 2 ); }
|
||||
static void dn83( void ) { kbd_key_pressed( 8, 3 ); }
|
||||
static void up83( bool action ) { kbd_key_released( 8, 3 ); }
|
||||
static void up83( void ) { kbd_key_released( 8, 3 ); }
|
||||
static void dn84( void ) { kbd_key_pressed( 8, 4 ); }
|
||||
static void up84( bool action ) { kbd_key_released( 8, 4 ); }
|
||||
static void up84( void ) { kbd_key_released( 8, 4 ); }
|
||||
static void dnON( void ) { kbd_on_pressed(); }
|
||||
static void upON( bool action ) { kbd_on_released(); }
|
||||
static void upON( void ) { kbd_on_released(); }
|
||||
|
||||
static void dnZelda( void ) {}
|
||||
static void upZelda( bool action ) { load_file( "zeldahp.dir" ); }
|
||||
// static void upZelda(bool action) { load_file("Arkalite.lib"); }
|
||||
static void upZelda( void ) { load_file( "zeldahp.dir" ); }
|
||||
|
||||
const int pox = 2;
|
||||
const int poy = 55;
|
||||
|
@ -137,117 +136,116 @@ static KBMapping kb_sdl_mapping[] = {
|
|||
};
|
||||
|
||||
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,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "DEL", "CLEAR", "", "", dn41, up41},
|
||||
{ 28, enter_w - pow1 + pox + xstart + ( xspacing * 4 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
|
||||
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<-", "DROP", "", "", dn40, up40},
|
||||
|
||||
{ 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,
|
||||
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,
|
||||
upZelda },
|
||||
{ 50, pox + xstart, poy, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
{ 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, NULL}
|
||||
};
|
||||
|
||||
void pcalc_init() { gui_initKeyboard( calc_buttons ); }
|
||||
|
@ -264,8 +262,8 @@ void pcalc_up( int mx, int my, int mb ) { button_mouse_up( calc_buttons, mx, my,
|
|||
|
||||
void pcalc_kb_down( SDL_Keycode sdl_event )
|
||||
{
|
||||
/* printf( "%d\n", SDLK_0 ); */
|
||||
KBMapping* mapping = kb_sdl_mapping;
|
||||
|
||||
while ( mapping->SDL_event_id ) {
|
||||
if ( sdl_event == mapping->SDL_event_id ) {
|
||||
mapping->down();
|
||||
|
@ -278,9 +276,10 @@ void pcalc_kb_down( 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 ) {
|
||||
mapping->up( true );
|
||||
mapping->up();
|
||||
break;
|
||||
}
|
||||
mapping++;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
typedef struct {
|
||||
SDL_Keycode SDL_event_id;
|
||||
void ( *down )( void );
|
||||
void ( *up )( bool action );
|
||||
void ( *up )( void );
|
||||
} KBMapping;
|
||||
|
||||
extern void pcalc_init();
|
||||
|
|
|
@ -19,7 +19,6 @@ void getExePath()
|
|||
memset( programPath, 0, sizeof( programPath ) );
|
||||
memset( temp, 0, sizeof( temp ) );
|
||||
|
||||
// setWorkingPath(programPath);
|
||||
char result[ PATH_MAX ];
|
||||
ssize_t count = readlink( "/proc/self/exe", result, PATH_MAX );
|
||||
const char* path;
|
||||
|
@ -70,20 +69,17 @@ void load_file( char* name )
|
|||
if ( !buf )
|
||||
return;
|
||||
|
||||
// f = pack_fopen(name, "r");
|
||||
f = fopen( name, "r" );
|
||||
if ( !f ) {
|
||||
free( buf );
|
||||
return;
|
||||
}
|
||||
int res = ( int )fread( buf, sizeof( char ), fsize, f );
|
||||
if ( res != fsize ) { // pack_fread
|
||||
if ( res != fsize ) {
|
||||
free( buf );
|
||||
// pack_fclose(f);
|
||||
fclose( f );
|
||||
return;
|
||||
}
|
||||
// pack_fclose(f);
|
||||
fclose( f );
|
||||
|
||||
if ( memcmp( buf, "HPHP48-", 7 ) ) {
|
||||
|
|
17
src/ports.c
17
src/ports.c
|
@ -4,6 +4,9 @@
|
|||
#include "bus.h"
|
||||
#include "ports.h"
|
||||
|
||||
#define PORT1_SIZE ( 256 * 1024 ) /* 128Kio in nibbles */
|
||||
#define PORT2_SIZE ( 256 * 1024 ) /* 128Kio in nibbles */
|
||||
|
||||
static byte current_bank;
|
||||
static byte* port2;
|
||||
static address port2mask;
|
||||
|
@ -32,8 +35,6 @@ void ports_init( void )
|
|||
current_bank = 0;
|
||||
}
|
||||
|
||||
void ports_exit( void ) {}
|
||||
|
||||
void ports_switch_bank( address adr )
|
||||
{
|
||||
bool need_remap = false;
|
||||
|
@ -42,20 +43,19 @@ void ports_switch_bank( address adr )
|
|||
current_bank = ( ( byte )adr >> 1 ) & 0x1F;
|
||||
if ( port2 ) {
|
||||
bus_info.nce3_data = port2 + ( ( current_bank << 18 ) & port2mask );
|
||||
if ( bus_info.nce3_cfg ) {
|
||||
|
||||
if ( bus_info.nce3_cfg )
|
||||
need_remap = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !bus_info.ben != !( adr & 0x40 ) ) {
|
||||
bus_info.ben = ( adr & 0x40 ) ? true : false;
|
||||
if ( bus_info.nce3_cfg ) {
|
||||
|
||||
if ( bus_info.nce3_cfg )
|
||||
need_remap = true;
|
||||
}
|
||||
}
|
||||
if ( need_remap ) {
|
||||
if ( need_remap )
|
||||
bus_remap();
|
||||
}
|
||||
}
|
||||
|
||||
byte ports_card_detect( void )
|
||||
|
@ -69,5 +69,6 @@ byte ports_card_detect( void )
|
|||
x |= 0x4;
|
||||
if ( !bus_info.ce2_r_o )
|
||||
x |= 0x8;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
|
|
@ -3,11 +3,7 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
#define PORT1_SIZE ( 256 * 1024 ) /* 128Kio in nibbles */
|
||||
#define PORT2_SIZE ( 256 * 1024 ) /* 128Kio in nibbles */
|
||||
|
||||
extern void ports_init( void );
|
||||
extern void ports_exit( void );
|
||||
extern void ports_switch_bank( address adr );
|
||||
extern byte ports_card_detect( void );
|
||||
|
||||
|
|
|
@ -9,12 +9,10 @@ static address ram_size = 256 * 1024; // in nibbles, not bytes!
|
|||
|
||||
void ram_init( void )
|
||||
{
|
||||
byte* buf;
|
||||
|
||||
buf = malloc( ram_size );
|
||||
if ( !buf ) {
|
||||
byte* buf = malloc( ram_size );
|
||||
if ( !buf )
|
||||
exit( 0x20 );
|
||||
}
|
||||
|
||||
memset( buf, 0, ram_size );
|
||||
bus_info.ram_data = buf;
|
||||
bus_info.ram_mask = ram_size - 1;
|
||||
|
|
74
src/timers.c
74
src/timers.c
|
@ -19,52 +19,50 @@ dword timer2_value;
|
|||
|
||||
void timer1_update( void )
|
||||
{
|
||||
if ( timer2_control & TIMER_RUN ) {
|
||||
timer1_value--;
|
||||
timer1_value &= 0xF;
|
||||
if ( !( timer2_control & TIMER_RUN ) )
|
||||
return;
|
||||
|
||||
if ( timer1_value & 0x8 ) {
|
||||
if ( timer1_control & TIMER1_WAKE ) {
|
||||
timer1_control |= TIMER1_SRQ;
|
||||
timer1_value--;
|
||||
timer1_value &= 0xF;
|
||||
|
||||
if ( cpu.shutdown ) {
|
||||
cpu.shutdown = false;
|
||||
timer1_control &= ~TIMER1_WAKE;
|
||||
}
|
||||
if ( timer1_value & 0x8 ) {
|
||||
if ( timer1_control & TIMER1_WAKE ) {
|
||||
timer1_control |= TIMER1_SRQ;
|
||||
|
||||
if ( cpu.shutdown ) {
|
||||
cpu.shutdown = false;
|
||||
timer1_control &= ~TIMER1_WAKE;
|
||||
}
|
||||
if ( timer1_control & TIMER1_INT ) {
|
||||
timer1_control |= TIMER1_SRQ;
|
||||
|
||||
if ( !cpu.shutdown ) {
|
||||
cpu_interrupt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
timer1_control &= ~TIMER1_SRQ;
|
||||
}
|
||||
}
|
||||
if ( timer1_control & TIMER1_INT ) {
|
||||
timer1_control |= TIMER1_SRQ;
|
||||
|
||||
if ( !cpu.shutdown )
|
||||
cpu_interrupt();
|
||||
}
|
||||
} else
|
||||
timer1_control &= ~TIMER1_SRQ;
|
||||
}
|
||||
|
||||
void timer2_update( void )
|
||||
{
|
||||
if ( timer2_control & TIMER_RUN ) {
|
||||
timer2_value--;
|
||||
if ( timer2_value & 0x80000000 ) {
|
||||
if ( timer2_control & TIMER2_WAKE ) {
|
||||
timer2_control |= TIMER2_SRQ;
|
||||
if ( cpu.shutdown ) {
|
||||
cpu.shutdown = 0;
|
||||
timer2_control &= ~TIMER2_WAKE;
|
||||
}
|
||||
if ( !( timer2_control & TIMER_RUN ) )
|
||||
return;
|
||||
|
||||
timer2_value--;
|
||||
if ( timer2_value & 0x80000000 ) {
|
||||
if ( timer2_control & TIMER2_WAKE ) {
|
||||
timer2_control |= TIMER2_SRQ;
|
||||
if ( cpu.shutdown ) {
|
||||
cpu.shutdown = 0;
|
||||
timer2_control &= ~TIMER2_WAKE;
|
||||
}
|
||||
if ( timer2_control & TIMER2_INT ) {
|
||||
timer2_control |= TIMER2_SRQ;
|
||||
if ( !cpu.shutdown ) {
|
||||
cpu_interrupt();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
timer2_control &= ~TIMER2_SRQ;
|
||||
}
|
||||
}
|
||||
if ( timer2_control & TIMER2_INT ) {
|
||||
timer2_control |= TIMER2_SRQ;
|
||||
if ( !cpu.shutdown )
|
||||
cpu_interrupt();
|
||||
}
|
||||
} else
|
||||
timer2_control &= ~TIMER2_SRQ;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned int dword;
|
||||
|
|
Loading…
Reference in a new issue