clean a lot of dead code
This commit is contained in:
parent
e5e6c74749
commit
080d4ef025
24 changed files with 196 additions and 1298 deletions
3
Makefile
3
Makefile
|
@ -17,11 +17,8 @@ dist/hpemu: src/bus.o \
|
|||
src/keyboard.o \
|
||||
src/main.o \
|
||||
src/opcodes.o \
|
||||
src/pabout.o \
|
||||
src/pcalc.o \
|
||||
src/pdebug.o \
|
||||
src/pfiles.o \
|
||||
src/pmenu.o \
|
||||
src/ports.o \
|
||||
src/ram.o \
|
||||
src/rom.o \
|
||||
|
|
|
@ -42,7 +42,7 @@ void bus_exit( void )
|
|||
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 )
|
||||
{
|
||||
|
|
44
src/color.c
44
src/color.c
|
@ -9,18 +9,10 @@ typedef struct RGB {
|
|||
unsigned char r, g, b;
|
||||
} RGB;
|
||||
|
||||
// static PALETTE palette;
|
||||
|
||||
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 int bit_count( unsigned int i )
|
||||
{
|
||||
int n = 0;
|
||||
|
@ -44,17 +36,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 )
|
||||
{
|
||||
/*
|
||||
int i;
|
||||
|
||||
for (i = 0; i < RESERVED_LCD; i++) {
|
||||
set_lcd_color(i, lcd_color_functions[lcd_mode](i));
|
||||
}
|
||||
*/
|
||||
// set_palette_range(palette, 0, RESERVED_LCD-1, false);
|
||||
}
|
||||
void build_lcd_palette( void ) {}
|
||||
|
||||
void color_lcd( int r0, int g0, int b0, int r1, int g1, int b1 )
|
||||
{
|
||||
|
@ -73,27 +55,12 @@ void color_lcd_mode( int mode )
|
|||
build_lcd_palette();
|
||||
}
|
||||
|
||||
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;
|
||||
// palette[color[i]].b = b >> 2;
|
||||
// set_color(color[i], palette + color[i]);
|
||||
// } else {
|
||||
// color[i] = makecol(r, g, b);
|
||||
// }
|
||||
}
|
||||
void color_set_emu( int i, int r, int g, int b ) {}
|
||||
|
||||
void color_init( void )
|
||||
{
|
||||
int i;
|
||||
|
||||
// if (bitmap_color_depth(screen) == 8) {
|
||||
for ( i = 0; i < C_COUNT; i++ ) {
|
||||
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 );
|
||||
|
@ -108,9 +75,4 @@ void color_init( void )
|
|||
|
||||
color_lcd( 128, 192, 128, 0, 0, 64 );
|
||||
color_lcd_mode( LCD_MODE_GRAY4 );
|
||||
// set_palette(palette);
|
||||
// set_mouse_sprite(NULL);
|
||||
// gui_bg_color = color[C_PANEL_BACK];
|
||||
// gui_mg_color = color[C_PANEL_DISABLED];
|
||||
// gui_fg_color = color[C_PANEL_TEXT];
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ Cpu cpu;
|
|||
|
||||
void cpu_interrupt( void )
|
||||
{
|
||||
/* printf( "cpu_interrupt\n" ); */
|
||||
if ( !cpu.inte )
|
||||
return;
|
||||
|
||||
|
@ -52,9 +51,8 @@ void execute_instruction( void )
|
|||
adr = cpu.pc;
|
||||
ptr = bus_fast_peek( buffer, adr, &len );
|
||||
old_map_cnt = bus_info.map_cnt;
|
||||
if ( ptr == buffer ) { // Not direct memory access
|
||||
old_map_cnt--; // Force new peek next time
|
||||
}
|
||||
if ( ptr == buffer ) // Not direct memory access
|
||||
old_map_cnt--; // Force new peek next time
|
||||
}
|
||||
decode( ptr + cpu.pc - adr );
|
||||
}
|
||||
|
|
16
src/disasm.c
16
src/disasm.c
|
@ -1,6 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include "types.h"
|
||||
#include "opcodes.h"
|
||||
#include "opinline.h"
|
||||
#include "disasm.h"
|
||||
|
||||
static const char hex_tab[ 16 ] = "0123456789ABCDEF";
|
||||
|
@ -31,21 +32,6 @@ 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 )
|
||||
{
|
||||
int x;
|
||||
|
||||
len--;
|
||||
x = nib[ len ];
|
||||
if ( x & 8 )
|
||||
x -= 16;
|
||||
while ( len-- ) {
|
||||
x <<= 4;
|
||||
x |= nib[ len ];
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
static void expand( char* dest, char* src, byte* ptr )
|
||||
{
|
||||
int i, n;
|
||||
|
|
|
@ -40,65 +40,32 @@ extern SDL_Texture* faceplateTexture;
|
|||
|
||||
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é
|
||||
SDL_RenderClear( renderer );
|
||||
|
||||
if ( faceplateTexture ) {
|
||||
// SDL_Rect r3 = {-10,0,534,1100};
|
||||
SDL_Rect r3 = { 8, 0, 504, 1124 };
|
||||
SDL_RenderCopy( renderer, faceplateTexture, NULL, &r3 );
|
||||
}
|
||||
// SDL_SetRenderTarget(renderer, texTarget);
|
||||
}
|
||||
|
||||
void endLCD()
|
||||
{
|
||||
// Reset render target
|
||||
// SDL_SetRenderTarget( renderer, NULL );
|
||||
|
||||
// Show rendered to texture
|
||||
// gTargetTexture.render( 0, 0, NULL, angle, &screenCenter );
|
||||
SDL_Rect r1 = { 0, 0, 131, 64 };
|
||||
// SDL_Rect r2 = {LCD_X,LCD_Y,262,128};
|
||||
SDL_Rect r2 = { LCD_X, LCD_Y, 524, 256 };
|
||||
// SDL_Rect r2 = {LCD_X,LCD_Y,436,214};
|
||||
// SDL_Rect r2 = {LCD_X,LCD_Y,393,192};
|
||||
SDL_RenderCopyEx( renderer, texTarget, &r1, &r2, 0, NULL, SDL_FLIP_NONE );
|
||||
|
||||
pcalc_show();
|
||||
}
|
||||
|
||||
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; */
|
||||
|
||||
/* 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++; */
|
||||
/* } */
|
||||
/* *\/ */
|
||||
/* } */
|
||||
void renderLCD() {}
|
||||
|
||||
static address draw_lcd_line( address adr, int y )
|
||||
{
|
||||
// printf("draw_lcd_line %d ", y);
|
||||
|
||||
int x = 0;
|
||||
int bit = 0;
|
||||
byte data = 0; // Initialized to remove warning
|
||||
byte* ptr;
|
||||
// byte *lcd_line0 = (byte *)lcd->line[y*2];
|
||||
// byte *lcd_line1 = (byte *)lcd->line[y*2+1];
|
||||
|
||||
ptr = bus_fast_peek( NULL, adr, NULL );
|
||||
|
||||
|
@ -119,22 +86,18 @@ static address draw_lcd_line( address adr, int y )
|
|||
bit = 4;
|
||||
}
|
||||
|
||||
byte pixel = ( ( data & 1 ) << 6 ); // (lcd_line0[x*2] >> 1) | ((data & 1) << 6);
|
||||
if ( pixel != '\0' ) {
|
||||
byte pixel = ( ( data & 1 ) << 6 );
|
||||
if ( pixel != '\0' )
|
||||
pixel = '\3';
|
||||
// printf("%c ", pixel);
|
||||
}
|
||||
|
||||
byte pixelGS = lcdScreenGS[ x + y * 131 ];
|
||||
|
||||
// prev3_lcdScreen[x+y*131] = prev2_lcdScreen[x+y*131];
|
||||
prev2_lcdScreen[ x + y * 131 ] = prev_lcdScreen[ x + y * 131 ];
|
||||
prev_lcdScreen[ x + y * 131 ] = lcdScreen[ x + y * 131 ];
|
||||
lcdScreen[ x + y * 131 ] = pixel;
|
||||
|
||||
byte prev_pixel = prev_lcdScreen[ x + y * 131 ];
|
||||
byte prev2_pixel = prev2_lcdScreen[ x + y * 131 ];
|
||||
// byte prev3_pixel = prev3_lcdScreen[x+y*131];
|
||||
|
||||
if ( drawGS == true ) {
|
||||
if ( prev2_pixel == '\0' && prev_pixel == '\0' && pixel == '\0' ) {
|
||||
|
@ -172,9 +135,6 @@ static address draw_lcd_line( address adr, int y )
|
|||
lcdScreenGS[ x + y * 131 ] = pixelGS;
|
||||
}
|
||||
|
||||
// lcd_line0[x*2] = lcd_line0[x*2+1] = lcd_line1[x*2] = lcd_line1[x*2+1]
|
||||
// = (lcd_line0[x*2] >> 1) | ((data & 1) << 6);
|
||||
|
||||
data >>= 1;
|
||||
bit--;
|
||||
x++;
|
||||
|
@ -183,17 +143,9 @@ static address draw_lcd_line( address adr, int y )
|
|||
return ( adr + 0x22 + ( !in_menu && ( display_offset & 4 ) ? 2 : 0 ) ) & 0xFFFFF;
|
||||
}
|
||||
|
||||
void display_init( void )
|
||||
{
|
||||
// lcd = create_bitmap_ex(8, 131*2, 64*2);
|
||||
// clear_to_color(lcd, 0);
|
||||
}
|
||||
void display_init( void ) {}
|
||||
|
||||
void display_exit( void )
|
||||
{
|
||||
// destroy_bitmap (lcd);
|
||||
// lcd = NULL;
|
||||
}
|
||||
void display_exit( void ) {}
|
||||
|
||||
void display_show()
|
||||
{
|
||||
|
@ -201,7 +153,6 @@ void display_show()
|
|||
SDL_RenderClear( renderer );
|
||||
|
||||
if ( faceplateTexture ) {
|
||||
// SDL_Rect r3 = {-10,0,534,1100};
|
||||
SDL_Rect r3 = { 8, 0, 504, 1124 };
|
||||
SDL_RenderCopy( renderer, faceplateTexture, NULL, &r3 );
|
||||
}
|
||||
|
@ -231,9 +182,7 @@ void display_show()
|
|||
int G = 0;
|
||||
int B = 0;
|
||||
|
||||
// byte hp48pixel = lcdScreen[x+y*131];
|
||||
byte hp48pixel = lcdScreenGS[ x + y * 131 ];
|
||||
// printf("%d ", hp48pixel);
|
||||
|
||||
if ( hp48pixel == '\0' ) {
|
||||
R = 119;
|
||||
|
@ -297,12 +246,6 @@ void display_update( void )
|
|||
|
||||
cur_adr = draw_lcd_line( cur_adr, display_line_count );
|
||||
|
||||
// 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();
|
||||
// release_screen();
|
||||
|
||||
if ( !in_menu ) {
|
||||
cur_adr += display_line_offset;
|
||||
}
|
||||
|
@ -334,31 +277,6 @@ void display_update( void )
|
|||
}
|
||||
|
||||
} else if ( off_cnt <= 7 ) { /* Display is off and still fading */
|
||||
|
||||
off_cnt = 8; // julien
|
||||
|
||||
/*
|
||||
fade_lcd_line(off_cur_line);
|
||||
|
||||
// acquire_screen();
|
||||
// scare_mouse_area(LCD_X, LCD_Y+off_cur_line*2, 131*2, 2);
|
||||
// blit(lcd, screen, 0, off_cur_line*2, LCD_X, LCD_Y+off_cur_line*2, 131*2,
|
||||
2);
|
||||
// unscare_mouse();
|
||||
// release_screen();
|
||||
|
||||
off_cur_line++;
|
||||
if (off_cur_line == 64) {
|
||||
off_cur_line = 0;
|
||||
}
|
||||
if (off_cur_line == off_line) {
|
||||
off_cnt++;
|
||||
}*/
|
||||
}
|
||||
|
||||
if ( shouldRender == true ) {
|
||||
// shouldRender = false;
|
||||
// shouldClear = true;
|
||||
// endLCD();
|
||||
off_cnt = 8;
|
||||
}
|
||||
}
|
||||
|
|
168
src/emulator.c
168
src/emulator.c
|
@ -9,14 +9,8 @@
|
|||
#include "timers.h"
|
||||
#include "display.h"
|
||||
#include "gui.h"
|
||||
#include "pdebug.h"
|
||||
#include "emulator.h"
|
||||
|
||||
/* Define true_TIMER2 to make timer2 run in true speed (8192 hz).
|
||||
* If it is not defined timer2 is syncronized to the cpu speed.
|
||||
*/
|
||||
// #define true_TIMER2
|
||||
|
||||
#define MAX_DELTA 4000
|
||||
|
||||
typedef struct {
|
||||
|
@ -41,74 +35,11 @@ static CycleEvent cycle_events[] = {
|
|||
{ 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},
|
||||
#ifdef true_TIMER2
|
||||
{ 0, 1000000 / 8192 /*BPS_TO_TIMER(8192)*/, false, timer2_update },
|
||||
#endif
|
||||
{ 0, 0, false, NULL }
|
||||
};
|
||||
|
||||
volatile bool please_exit = false;
|
||||
dword emulator_speed = 4000000;
|
||||
static int emulator_state = EMULATOR_RUN; // EMULATOR_STOP;
|
||||
static int emulator_state = EMULATOR_RUN;
|
||||
|
||||
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 start_timer_proc( void ( *proc )( void ) )
|
||||
{
|
||||
TimerEvent* ptr = timer_events;
|
||||
|
||||
while ( ptr->proc && ptr->proc != proc ) {
|
||||
ptr++;
|
||||
}
|
||||
if ( ptr->proc && !ptr->running ) {
|
||||
ptr->value = 0;
|
||||
ptr->running = true;
|
||||
|
||||
// printf("ptr->speed = %d\n", ptr->speed);
|
||||
// install_param_int_ex(timer_event_proc, (void *)ptr, ptr->speed);
|
||||
}
|
||||
}
|
||||
|
||||
static void stop_timer_proc( void ( *proc )( void ) )
|
||||
{
|
||||
TimerEvent* ptr = timer_events;
|
||||
|
||||
while ( ptr->proc && ptr->proc != proc ) {
|
||||
ptr++;
|
||||
}
|
||||
if ( ptr->proc && ptr->running ) {
|
||||
ptr->value = 0;
|
||||
ptr->running = false;
|
||||
|
||||
// remove_param_int(timer_event_proc, (void *)ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void emulator_set_state( int state )
|
||||
{
|
||||
/* printf( "emulator_set_state\n" ); */
|
||||
#ifdef true_TIMER2
|
||||
if ( state != EMULATOR_STOP ) {
|
||||
start_timer_proc( timer2_update );
|
||||
} else {
|
||||
stop_timer_proc( timer2_update );
|
||||
}
|
||||
#endif
|
||||
emulator_state = state;
|
||||
pdebug_state_changed();
|
||||
}
|
||||
void emulator_set_state( int state ) { emulator_state = state; }
|
||||
|
||||
int emulator_get_state( void ) { return emulator_state; }
|
||||
|
||||
|
@ -119,11 +50,8 @@ void emulator_init( void )
|
|||
bus_init();
|
||||
display_init();
|
||||
|
||||
if ( !locked ) {
|
||||
// LOCK_VARIABLE(timer_events);
|
||||
// LOCK_FUNCTION(timer_event_proc);
|
||||
if ( !locked )
|
||||
locked = true;
|
||||
}
|
||||
}
|
||||
|
||||
void emulator_exit( void )
|
||||
|
@ -154,82 +82,42 @@ void throttle( bool is_needed )
|
|||
bool emulator_run( void )
|
||||
{
|
||||
CycleEvent* cep;
|
||||
TimerEvent* tep;
|
||||
dword delta;
|
||||
|
||||
static bool first_run = false;
|
||||
if ( first_run == false && emulator_state == EMULATOR_RUN ) {
|
||||
if ( first_run == false && emulator_state == EMULATOR_RUN )
|
||||
first_run = true;
|
||||
start_timer_proc( gui_update );
|
||||
start_timer_proc( true_speed_proc );
|
||||
}
|
||||
|
||||
if ( please_exit ) {
|
||||
if ( please_exit )
|
||||
return false;
|
||||
}
|
||||
|
||||
// while (!please_exit)
|
||||
{
|
||||
if ( emulator_state != EMULATOR_STOP ) {
|
||||
|
||||
// draw_cpu();
|
||||
|
||||
if ( !cpu.shutdown ) {
|
||||
execute_instruction();
|
||||
|
||||
throttle( true );
|
||||
|
||||
if ( emulator_state == EMULATOR_STEP ) {
|
||||
emulator_set_state( EMULATOR_STOP );
|
||||
}
|
||||
} else {
|
||||
delta = MAX_DELTA;
|
||||
for ( cep = cycle_events; cep->proc; cep++ ) {
|
||||
delta = MIN( delta, cep->next - cpu.cycles + 1 );
|
||||
}
|
||||
cpu.cycles += delta;
|
||||
}
|
||||
|
||||
for ( cep = cycle_events; cep->proc; cep++ ) {
|
||||
if ( ( cep->next - cpu.cycles ) & 0x80000000 ) {
|
||||
cep->next += emulator_speed / cep->freq;
|
||||
cep->proc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( tep = timer_events; tep->proc; tep++ ) {
|
||||
if ( tep->running && tep->value ) {
|
||||
tep->value--;
|
||||
tep->proc();
|
||||
}
|
||||
}
|
||||
|
||||
// printf("emulator_state = %d\n", emulator_state);
|
||||
|
||||
if ( emulator_state == EMULATOR_STOP ) {
|
||||
// rest(10);
|
||||
SDL_Delay( 10 );
|
||||
} else {
|
||||
// yield_timeslice ();
|
||||
// SDL_Delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef true_TIMER2
|
||||
if ( emulator_state != EMULATOR_STOP ) {
|
||||
stop_timer_proc( timer2_update );
|
||||
}
|
||||
#endif
|
||||
if ( !cpu.shutdown ) {
|
||||
execute_instruction();
|
||||
|
||||
if ( first_run == true && emulator_state == EMULATOR_STOP ) {
|
||||
#ifdef true_TIMER2
|
||||
stop_timer_proc( timer2_update ); //
|
||||
#endif
|
||||
throttle( true );
|
||||
|
||||
stop_timer_proc( true_speed_proc );
|
||||
stop_timer_proc( gui_update );
|
||||
if ( emulator_state == EMULATOR_STEP ) {
|
||||
emulator_set_state( EMULATOR_STOP );
|
||||
}
|
||||
} else {
|
||||
delta = MAX_DELTA;
|
||||
for ( cep = cycle_events; cep->proc; cep++ ) {
|
||||
delta = MIN( delta, cep->next - cpu.cycles + 1 );
|
||||
}
|
||||
cpu.cycles += delta;
|
||||
}
|
||||
|
||||
for ( cep = cycle_events; cep->proc; cep++ ) {
|
||||
if ( ( cep->next - cpu.cycles ) & 0x80000000 ) {
|
||||
cep->next += emulator_speed / cep->freq;
|
||||
cep->proc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( emulator_state == EMULATOR_STOP )
|
||||
SDL_Delay( 10 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
184
src/gui.c
184
src/gui.c
|
@ -1,17 +1,14 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "color.h"
|
||||
#include "pmenu.h"
|
||||
#include "pcalc.h"
|
||||
#include "pdebug.h"
|
||||
#include "pfiles.h"
|
||||
#include "pabout.h"
|
||||
#include "gui.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "color.h"
|
||||
#include "pcalc.h"
|
||||
#include "pfiles.h"
|
||||
#include "gui.h"
|
||||
|
||||
extern SDL_Renderer* renderer;
|
||||
extern SDL_Texture* faceplateTexture;
|
||||
extern TTF_Font* ttffont;
|
||||
|
@ -31,30 +28,6 @@ SDL_Texture* textD[ 49 ];
|
|||
|
||||
#define PANEL_FLAG_VISIBLE 0x01
|
||||
|
||||
typedef struct GuiPanel {
|
||||
int x, y;
|
||||
int w, h;
|
||||
int flags;
|
||||
// BITMAP *bmp;
|
||||
// void (*show)(BITMAP *bmp);
|
||||
void ( *hide )( void );
|
||||
void ( *mouse_down )( int mx, int my, int mb );
|
||||
void ( *mouse_up )( int mx, int my, int mb );
|
||||
} GuiPanel;
|
||||
|
||||
static GuiPanel panels[ PANEL_COUNT ] = {
|
||||
/*
|
||||
{ 10, 10, 620, 20, 0, NULL, pmenu_show, pmenu_hide,
|
||||
pmenu_down, pmenu_up }, { 360, 40, 270, 430, 0, NULL,
|
||||
pcalc_show, pcalc_hide, pcalc_down, pcalc_up }, { 10, 40, 340,
|
||||
430, 0, NULL, pdebug_show, pdebug_hide,
|
||||
pdebug_down, pdebug_up }, { 10, 40, 340, 430, 0, NULL,
|
||||
pfiles_show, pfiles_hide, pfiles_down, pfiles_up }, { 10, 40,
|
||||
340, 430, 0, NULL, pabout_show, pabout_hide, pabout_down,
|
||||
pabout_up },
|
||||
*/
|
||||
};
|
||||
|
||||
void drawText( int index, int x, int y, int btn_w, int btn_h )
|
||||
{
|
||||
SDL_Surface* letterSurface = surfA[ index ];
|
||||
|
@ -183,85 +156,84 @@ void gui_initKeyboard( Button* calcbuttons )
|
|||
}
|
||||
}
|
||||
|
||||
void gui_init( void ) {}
|
||||
/* void gui_exit( void ) */
|
||||
/* { */
|
||||
/* /\* int i; *\/ */
|
||||
|
||||
void gui_exit( void )
|
||||
{
|
||||
int i;
|
||||
/* /\* for ( i = 0; i < PANEL_COUNT; i++ ) { *\/ */
|
||||
/* /\* gui_hide_panel( i ); *\/ */
|
||||
/* /\* } *\/ */
|
||||
/* } */
|
||||
|
||||
for ( i = 0; i < PANEL_COUNT; i++ ) {
|
||||
gui_hide_panel( i );
|
||||
}
|
||||
}
|
||||
/* static inline int panel_at( int x, int y ) */
|
||||
/* { */
|
||||
/* int 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; */
|
||||
/* } */
|
||||
|
||||
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; */
|
||||
|
||||
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; */
|
||||
|
||||
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; */
|
||||
/* } */
|
||||
/* *\/ */
|
||||
/* } */
|
||||
|
||||
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_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 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 )
|
||||
{
|
||||
|
@ -307,7 +279,7 @@ void button_draw_all( Button* 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) {
|
||||
|
|
10
src/gui.h
10
src/gui.h
|
@ -5,8 +5,6 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
enum Panels { PANEL_MENU, PANEL_CALC, PANEL_DEBUG, PANEL_FILES, PANEL_ABOUT, PANEL_COUNT };
|
||||
|
||||
typedef struct {
|
||||
int index;
|
||||
int x, y;
|
||||
|
@ -32,15 +30,7 @@ typedef struct {
|
|||
#define BUTTON_B1RELEASE 0x10 // Releaseing mouse button 1 anywhere unpushes the button
|
||||
|
||||
void gui_initKeyboard( Button* calcbuttons );
|
||||
void gui_init( void );
|
||||
void gui_exit( void );
|
||||
void gui_update( void );
|
||||
void gui_show_panel( int i );
|
||||
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_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my, int mb );
|
||||
|
|
|
@ -44,28 +44,26 @@ void kbd_key_pressed( int row, int col )
|
|||
bool 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.inte ) {
|
||||
cpu.keyintp = false;
|
||||
cpu_interrupt();
|
||||
} else {
|
||||
} else
|
||||
cpu.keyintp = true;
|
||||
}
|
||||
} else if ( !cpu.in[ 0 ] && !cpu.in[ 1 ] && !cpu.in[ 3 ] ) {
|
||||
|
||||
} else if ( !cpu.in[ 0 ] && !cpu.in[ 1 ] && !cpu.in[ 3 ] )
|
||||
cpu.keyintp = false;
|
||||
}
|
||||
}
|
||||
|
||||
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 ] ) {
|
||||
if ( !cpu.in[ 0 ] && !cpu.in[ 1 ] && !cpu.in[ 3 ] )
|
||||
cpu.keyintp = false;
|
||||
}
|
||||
}
|
||||
|
||||
void kbd_on_pressed( void )
|
||||
|
@ -73,12 +71,11 @@ void kbd_on_pressed( void )
|
|||
bool no_key = !cpu.in[ 3 ];
|
||||
kbd_on = true;
|
||||
cpu.in[ 3 ] |= 8;
|
||||
if ( cpu.shutdown && no_key ) {
|
||||
if ( cpu.shutdown && no_key )
|
||||
cpu.shutdown = false;
|
||||
}
|
||||
if ( cpu.inte && no_key ) {
|
||||
|
||||
if ( cpu.inte && no_key )
|
||||
cpu_interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
void kbd_on_released( void )
|
||||
|
|
268
src/main.c
268
src/main.c
|
@ -28,136 +28,18 @@ SDL_Texture* faceplateTexture = NULL;
|
|||
TTF_Font* ttffont = NULL;
|
||||
TTF_Font* ttffont2 = NULL;
|
||||
|
||||
SDL_TimerID my_timer0_id;
|
||||
SDL_TimerID my_timer1_id;
|
||||
SDL_TimerID my_timer2_id;
|
||||
SDL_TimerID my_timer3_id;
|
||||
SDL_TimerID my_timer4_id;
|
||||
|
||||
bool SDL_ready = false;
|
||||
|
||||
unsigned int framecount = 0;
|
||||
unsigned int emuframecount = 0;
|
||||
|
||||
unsigned int currentTime;
|
||||
unsigned int currentTime_emu;
|
||||
unsigned int lastTime_timer_fps = 0;
|
||||
unsigned int lastTime_timer_emu = 0;
|
||||
|
||||
/*
|
||||
|
||||
{ 0, 16, timer1_update },
|
||||
#ifndef true_TIMER2
|
||||
{ 0, 8192, timer2_update },
|
||||
#endif
|
||||
{ 0, 4096, display_update },
|
||||
|
||||
static TimerEvent timer_events[] = {
|
||||
{ 0, 1000000/20 , false, gui_update }, // BPS_TO_TIMER(20)
|
||||
{ 0, 1000000, false, true_speed_proc }, // BPS_TO_TIMER(1)
|
||||
{ 0, 1000000/8192 , false, timer2_update }, // BPS_TO_TIMER(8192)
|
||||
*/
|
||||
|
||||
// display_update
|
||||
unsigned int lastTime_timer1 = 0;
|
||||
unsigned int delay_timer1 = 4096; // 4096;
|
||||
|
||||
// true_speed_proc
|
||||
unsigned int lastTime_timer2 = 0;
|
||||
unsigned int delay_timer2 = 60; // 1000;
|
||||
|
||||
// timer1
|
||||
unsigned int lastTime_timer3 = 0;
|
||||
unsigned int delay_timer3 = 60;
|
||||
|
||||
// timer2
|
||||
unsigned int lastTime_timer4 = 0;
|
||||
unsigned int delay_timer4 = 8192; // 8192;
|
||||
|
||||
// display show
|
||||
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; */
|
||||
|
||||
/* userevent.type = SDL_USEREVENT; */
|
||||
/* userevent.code = 1; */
|
||||
/* userevent.data1 = &gui_update; */
|
||||
/* userevent.data2 = NULL; // param; */
|
||||
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
/* 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; */
|
||||
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
/* 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; */
|
||||
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
/* 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; */
|
||||
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
/* 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; */
|
||||
|
||||
/* event.type = SDL_USEREVENT; */
|
||||
/* event.user = userevent; */
|
||||
|
||||
/* SDL_PushEvent( &event ); */
|
||||
/* return ( interval ); */
|
||||
/* } */
|
||||
|
||||
static int fullscreen = false;
|
||||
|
||||
static void parse_args( int argc, char* argv[] )
|
||||
|
@ -207,20 +89,6 @@ static void program_init( void )
|
|||
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");
|
||||
if(faceplate) {
|
||||
//printf("init text2 %s\n", buttons->text);
|
||||
|
||||
faceplateTexture = SDL_CreateTextureFromSurface( renderer, faceplate
|
||||
);
|
||||
}*/
|
||||
|
||||
// SDL_SetRenderTarget(renderer, texTarget);
|
||||
// SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
// SDL_RenderClear(renderer);
|
||||
// SDL_SetRenderTarget(renderer, NULL);
|
||||
|
||||
SDL_UpdateWindowSurface( window );
|
||||
|
||||
pcalc_init();
|
||||
|
@ -232,26 +100,8 @@ static void program_init( void )
|
|||
SDL_ready = true;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
static void program_exit( void )
|
||||
{
|
||||
/*
|
||||
//SDL_RemoveTimer(my_timer0_id);
|
||||
SDL_RemoveTimer(my_timer1_id);
|
||||
SDL_RemoveTimer(my_timer2_id);
|
||||
SDL_RemoveTimer(my_timer3_id);
|
||||
SDL_RemoveTimer(my_timer4_id);
|
||||
*/
|
||||
TTF_CloseFont( ttffont );
|
||||
TTF_CloseFont( ttffont2 );
|
||||
TTF_Quit();
|
||||
|
@ -264,10 +114,8 @@ static void program_exit( void )
|
|||
bool refreshSDL()
|
||||
{
|
||||
SDL_Event event;
|
||||
// SDL_WaitEvent(&event);
|
||||
while ( SDL_PollEvent( &event ) )
|
||||
// if(SDL_PollEvent(&event))
|
||||
{
|
||||
|
||||
while ( SDL_PollEvent( &event ) ) {
|
||||
switch ( event.type ) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
|
@ -286,8 +134,6 @@ bool refreshSDL()
|
|||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
/* printf( "%d %d\n", event.key.keysym.sym, event.key.keysym.scancode ); */
|
||||
|
||||
pcalc_kb_down( event.key.keysym.scancode );
|
||||
|
||||
switch ( event.key.keysym.scancode ) {
|
||||
|
@ -527,41 +373,14 @@ bool refreshSDL()
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
case SDLK_LEFT:
|
||||
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
kbd_key_released (1, 3);
|
||||
break;
|
||||
case SDLK_UP:
|
||||
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
|
||||
break;
|
||||
case SDLK_ESCAPE:
|
||||
|
||||
break;
|
||||
*/
|
||||
break;
|
||||
|
||||
case SDL_USEREVENT:
|
||||
{
|
||||
printf( "SDL_USEREVENT\n" );
|
||||
// if(event.user.code == 1)
|
||||
|
||||
// void (*p) (void*) = event.user.data1;
|
||||
// p(event.user.data2);
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
{
|
||||
please_exit = true;
|
||||
// emulator_state = EMULATOR_STOP;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -569,72 +388,29 @@ bool refreshSDL()
|
|||
return true;
|
||||
}
|
||||
|
||||
void mainloop()
|
||||
static inline void mainloop()
|
||||
{
|
||||
if ( please_exit == true ) {
|
||||
printf( "please exit\n" );
|
||||
if ( please_exit || !SDL_ready )
|
||||
return;
|
||||
|
||||
currentTime = SDL_GetTicks();
|
||||
|
||||
emulator_run();
|
||||
|
||||
// display_update
|
||||
if ( currentTime > lastTime_timer1 + delay_timer1 ) {
|
||||
lastTime_timer1 = currentTime;
|
||||
display_update();
|
||||
}
|
||||
if ( SDL_ready == true ) {
|
||||
|
||||
currentTime = SDL_GetTicks();
|
||||
|
||||
emulator_run();
|
||||
|
||||
/*
|
||||
framecount++;
|
||||
|
||||
if (currentTime >= lastTime_timer_fps + 1000) {
|
||||
//printf("Report(2) %dmsec: %d\n", delay_timer2, currentTime -
|
||||
lastTime_timer2); lastTime_timer_fps = currentTime; printf("FPS = %d\n",
|
||||
framecount); framecount = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
// printf("mainloop() currentTime = %d\n", currentTime);
|
||||
|
||||
// true_speed_proc
|
||||
if ( currentTime > lastTime_timer2 + delay_timer2 ) {
|
||||
// printf("Report(2) %dmsec: %d\n", delay_timer2, currentTime -
|
||||
// lastTime_timer2);
|
||||
lastTime_timer2 = currentTime;
|
||||
true_speed_proc();
|
||||
}
|
||||
|
||||
// display_update
|
||||
if ( currentTime > lastTime_timer1 + delay_timer1 ) {
|
||||
// printf("Report(1) %dmsec: %d\n", delay_timer1, currentTime -
|
||||
// lastTime_timer1);
|
||||
lastTime_timer1 = currentTime;
|
||||
display_update();
|
||||
}
|
||||
|
||||
// timer1
|
||||
if ( currentTime > lastTime_timer3 + delay_timer3 ) {
|
||||
// printf("Report(3) %dmsec: %d\n", delay_timer3, currentTime -
|
||||
// lastTime_timer3);
|
||||
lastTime_timer3 = currentTime;
|
||||
timer1_update();
|
||||
}
|
||||
|
||||
// timer2
|
||||
if ( currentTime > lastTime_timer4 + delay_timer4 ) {
|
||||
// printf("Report(4) %dmsec: %d\n", delay_timer4, currentTime -
|
||||
// lastTime_timer4);
|
||||
lastTime_timer4 = currentTime;
|
||||
timer2_update();
|
||||
}
|
||||
|
||||
// display show
|
||||
if ( currentTime > lastTime_timer5 + delay_timer5 ) {
|
||||
lastTime_timer5 = currentTime;
|
||||
display_show();
|
||||
}
|
||||
|
||||
if ( refreshSDL() == false ) {
|
||||
return;
|
||||
}
|
||||
// display show
|
||||
if ( currentTime > lastTime_timer5 + delay_timer5 ) {
|
||||
lastTime_timer5 = currentTime;
|
||||
display_show();
|
||||
}
|
||||
|
||||
if ( !refreshSDL() )
|
||||
return;
|
||||
}
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
|
@ -643,14 +419,10 @@ int main( int argc, char* argv[] )
|
|||
|
||||
program_init();
|
||||
emulator_init();
|
||||
// gui_init();
|
||||
|
||||
// start_timers();
|
||||
|
||||
while ( please_exit == false )
|
||||
mainloop();
|
||||
|
||||
gui_exit();
|
||||
emulator_exit();
|
||||
program_exit();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ static const int regv[ 16 ] = { B, C, A, C, A, B, C, D, A, B, C, D, B, C, A, C }
|
|||
#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;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "emulator.h"
|
||||
#include "cpu.h"
|
||||
|
||||
static __inline void load( byte* reg, byte* data, int start, int len )
|
||||
inline void load( byte* reg, byte* data, int start, int len )
|
||||
{
|
||||
if ( start + len <= 16 ) {
|
||||
memcpy( reg + start, data, len );
|
||||
|
@ -15,7 +15,7 @@ static __inline void load( byte* reg, byte* data, int start, int len )
|
|||
}
|
||||
}
|
||||
|
||||
static __inline unsigned int nib_to_unsigned( byte* nib, int len )
|
||||
inline unsigned int nib_to_unsigned( byte* nib, int len )
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
|
@ -26,7 +26,7 @@ static __inline unsigned int nib_to_unsigned( byte* nib, int len )
|
|||
return x;
|
||||
}
|
||||
|
||||
static __inline int nib_to_signed( byte* nib, int len )
|
||||
inline int nib_to_signed( byte* nib, int len )
|
||||
{
|
||||
int x;
|
||||
|
||||
|
@ -41,7 +41,7 @@ static __inline int nib_to_signed( byte* nib, int len )
|
|||
return x;
|
||||
}
|
||||
|
||||
static __inline void unsigned_to_nib( byte* nib, int x, int len )
|
||||
inline void unsigned_to_nib( byte* nib, int x, int len )
|
||||
{
|
||||
while ( len-- ) {
|
||||
*nib++ = x & 0xF;
|
||||
|
@ -49,7 +49,7 @@ static __inline void unsigned_to_nib( byte* nib, int x, int len )
|
|||
}
|
||||
}
|
||||
|
||||
static __inline address rstk_pop( void )
|
||||
inline address rstk_pop( void )
|
||||
{
|
||||
address adr = cpu.rstk[ cpu.rstk_ptr ];
|
||||
cpu.rstk[ cpu.rstk_ptr ] = 0x00000;
|
||||
|
@ -57,13 +57,13 @@ static __inline address rstk_pop( void )
|
|||
return adr;
|
||||
}
|
||||
|
||||
static __inline void rstk_push( address adr )
|
||||
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 )
|
||||
inline void goyes( byte* opc, int offset )
|
||||
{
|
||||
if ( cpu.carry ) {
|
||||
address rel = nib_to_signed( opc + offset, 2 );
|
||||
|
@ -78,9 +78,9 @@ static __inline void goyes( byte* opc, int offset )
|
|||
}
|
||||
}
|
||||
|
||||
static __inline void reg_zero( byte* reg, int len ) { memset( reg, 0, len ); }
|
||||
inline void reg_zero( byte* reg, int len ) { memset( reg, 0, len ); }
|
||||
|
||||
static __inline void reg_bit( byte* reg, int bit, int value )
|
||||
inline void reg_bit( byte* reg, int bit, int value )
|
||||
{
|
||||
if ( value ) {
|
||||
reg[ bit >> 2 ] |= 1 << ( bit & 3 );
|
||||
|
@ -89,20 +89,20 @@ 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 ); }
|
||||
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 )
|
||||
inline void reg_ex( byte* reg1, byte* reg2, int len )
|
||||
{
|
||||
static byte tmp[ 16 ];
|
||||
byte tmp[ 16 ];
|
||||
|
||||
memcpy( tmp, reg1, len );
|
||||
memcpy( reg1, reg2, 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; }
|
||||
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 )
|
||||
inline void comp_zero( byte* reg, int len )
|
||||
{
|
||||
while ( len-- ) {
|
||||
if ( *reg++ ) {
|
||||
|
@ -113,7 +113,7 @@ static __inline void comp_zero( byte* reg, int len )
|
|||
cpu.carry = true;
|
||||
}
|
||||
|
||||
static __inline void comp_eq( byte* reg1, byte* reg2, int len )
|
||||
inline void comp_eq( byte* reg1, byte* reg2, int len )
|
||||
{
|
||||
while ( len-- ) {
|
||||
if ( *reg1++ != *reg2++ ) {
|
||||
|
@ -124,14 +124,14 @@ 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 )
|
||||
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 )
|
||||
inline void alu_add( byte* dest, byte* src, int len )
|
||||
{
|
||||
byte c = 0;
|
||||
byte base = cpu.dec ? 10 : 16;
|
||||
|
@ -152,7 +152,7 @@ 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 )
|
||||
inline void alu_sub( byte* dest, byte* src, int len )
|
||||
{
|
||||
byte c = 0;
|
||||
byte base = cpu.dec ? 10 : 16;
|
||||
|
@ -171,7 +171,7 @@ 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 )
|
||||
inline void alu_sub2( byte* dest, byte* src, int len )
|
||||
{
|
||||
byte c = 0;
|
||||
byte base = cpu.dec ? 10 : 16;
|
||||
|
@ -190,7 +190,7 @@ 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 )
|
||||
inline void alu_add_con( byte* reg, byte con, int i, int len )
|
||||
{
|
||||
reg[ i ] += con;
|
||||
while ( len-- ) {
|
||||
|
@ -205,7 +205,7 @@ 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 )
|
||||
inline void alu_sub_con( byte* reg, byte con, int i, int len )
|
||||
{
|
||||
reg[ i ] -= con;
|
||||
while ( len-- ) {
|
||||
|
@ -220,7 +220,7 @@ 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 )
|
||||
inline void alu_inc( byte* reg, int len )
|
||||
{
|
||||
if ( cpu.dec ) {
|
||||
byte c = 1;
|
||||
|
@ -251,7 +251,7 @@ static __inline void alu_inc( byte* reg, int len )
|
|||
}
|
||||
}
|
||||
|
||||
static __inline void alu_dec( byte* reg, int len )
|
||||
inline void alu_dec( byte* reg, int len )
|
||||
{
|
||||
byte base = cpu.dec ? 10 : 16;
|
||||
|
||||
|
@ -267,7 +267,7 @@ static __inline void alu_dec( byte* reg, int len )
|
|||
cpu.carry = true;
|
||||
}
|
||||
|
||||
static __inline void alu_neg( byte* reg, int len )
|
||||
inline void alu_neg( byte* reg, int len )
|
||||
{
|
||||
byte base = cpu.dec ? 10 : 16;
|
||||
|
||||
|
@ -292,7 +292,7 @@ static __inline void alu_neg( byte* reg, int len )
|
|||
}
|
||||
}
|
||||
|
||||
static __inline void alu_not( byte* reg, int len )
|
||||
inline void alu_not( byte* reg, int len )
|
||||
{
|
||||
byte base = cpu.dec ? 9 : 15;
|
||||
|
||||
|
@ -305,21 +305,21 @@ static __inline void alu_not( byte* reg, int len )
|
|||
cpu.carry = false;
|
||||
}
|
||||
|
||||
static __inline void alu_and( byte* dest, byte* src, int len )
|
||||
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 )
|
||||
inline void alu_or( byte* dest, byte* src, int len )
|
||||
{
|
||||
while ( len-- ) {
|
||||
*dest++ |= *src++;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline void alu_sl( byte* reg, int len )
|
||||
inline void alu_sl( byte* reg, int len )
|
||||
{
|
||||
while ( --len ) {
|
||||
reg[ len ] = reg[ len - 1 ];
|
||||
|
@ -327,7 +327,7 @@ static __inline void alu_sl( byte* reg, int len )
|
|||
reg[ 0 ] = 0;
|
||||
}
|
||||
|
||||
static __inline void alu_slc( byte* reg, int len )
|
||||
inline void alu_slc( byte* reg, int len )
|
||||
{
|
||||
byte tmp = reg[ len - 1 ];
|
||||
|
||||
|
@ -337,7 +337,7 @@ static __inline void alu_slc( byte* reg, int len )
|
|||
reg[ 0 ] = tmp;
|
||||
}
|
||||
|
||||
static __inline void alu_sr( byte* reg, int len )
|
||||
inline void alu_sr( byte* reg, int len )
|
||||
{
|
||||
if ( reg[ 0 ] )
|
||||
cpu.hst |= HST_SB;
|
||||
|
@ -349,7 +349,7 @@ static __inline void alu_sr( byte* reg, int len )
|
|||
reg[ 0 ] = 0;
|
||||
}
|
||||
|
||||
static __inline void alu_src( byte* reg, int len )
|
||||
inline void alu_src( byte* reg, int len )
|
||||
{
|
||||
byte tmp = reg[ 0 ];
|
||||
|
||||
|
@ -360,7 +360,7 @@ static __inline void alu_src( byte* reg, int len )
|
|||
reg[ 0 ] = tmp;
|
||||
}
|
||||
|
||||
static __inline void alu_srb( byte* reg, int len )
|
||||
inline void alu_srb( byte* reg, int len )
|
||||
{
|
||||
if ( *reg & 1 )
|
||||
cpu.hst |= HST_SB;
|
||||
|
|
87
src/pabout.c
87
src/pabout.c
|
@ -1,87 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include "color.h"
|
||||
#include "gui.h"
|
||||
#include "pabout.h"
|
||||
|
||||
// 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 void draw_about( void ) { */
|
||||
/* /\* */
|
||||
/* int i, y; */
|
||||
|
||||
/* text_mode(color[C_PANEL_BACK]); */
|
||||
|
||||
/* 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; */
|
||||
/* } */
|
||||
|
||||
/* unscare_mouse(); */
|
||||
/* release_bitmap(about_bmp);*\/ */
|
||||
/* } */
|
||||
|
||||
/*
|
||||
void pabout_show(BITMAP *bmp)
|
||||
{
|
||||
about_bmp = bmp;
|
||||
|
||||
clear_to_color(about_bmp, color[C_PANEL_BACK]);
|
||||
draw_about();
|
||||
}
|
||||
*/
|
||||
|
||||
void pabout_hide( void )
|
||||
{
|
||||
// about_bmp = NULL;
|
||||
}
|
||||
|
||||
void pabout_down( int mx, int my, int mb ) {}
|
||||
|
||||
void pabout_up( int mx, int my, int mb ) {}
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef __PABOUT_H
|
||||
#define __PABOUT_H
|
||||
|
||||
// void pabout_show(BITMAP *bmp);
|
||||
void pabout_hide( void );
|
||||
void pabout_down( int mx, int my, int mb );
|
||||
void pabout_up( int mx, int my, int mb );
|
||||
|
||||
#endif
|
252
src/pdebug.c
252
src/pdebug.c
|
@ -1,252 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "types.h"
|
||||
#include "emulator.h"
|
||||
#include "cpu.h"
|
||||
#include "bus.h"
|
||||
#include "disasm.h"
|
||||
#include "color.h"
|
||||
#include "gui.h"
|
||||
#include "pdebug.h"
|
||||
|
||||
/* static void run_up( bool action ); */
|
||||
/* static void break_up( bool action ); */
|
||||
/* static void step_up( bool action ); */
|
||||
|
||||
/* 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
|
||||
#define STEP_BUTTON 2
|
||||
|
||||
// static BITMAP *debug_bmp;
|
||||
|
||||
static void update_buttons( void )
|
||||
{
|
||||
/*
|
||||
if (emulator_get_state() == EMULATOR_STOP) {
|
||||
if (debug_buttons[RUN_BUTTON].flags & BUTTON_DISABLED) {
|
||||
debug_buttons[RUN_BUTTON].flags &= ~BUTTON_DISABLED;
|
||||
if (debug_bmp) button_draw(debug_bmp, debug_buttons + RUN_BUTTON);
|
||||
}
|
||||
if (!(debug_buttons[BREAK_BUTTON].flags & BUTTON_DISABLED)) {
|
||||
debug_buttons[BREAK_BUTTON].flags |= BUTTON_DISABLED;
|
||||
if (debug_bmp) button_draw(debug_bmp, debug_buttons + BREAK_BUTTON);
|
||||
}
|
||||
if (debug_buttons[STEP_BUTTON].flags & BUTTON_DISABLED) {
|
||||
debug_buttons[STEP_BUTTON].flags &= ~BUTTON_DISABLED;
|
||||
if (debug_bmp) button_draw(debug_bmp, debug_buttons + STEP_BUTTON);
|
||||
}
|
||||
} else {
|
||||
if (!(debug_buttons[RUN_BUTTON].flags & BUTTON_DISABLED)) {
|
||||
debug_buttons[RUN_BUTTON].flags |= BUTTON_DISABLED;
|
||||
if (debug_bmp) button_draw(debug_bmp, debug_buttons + RUN_BUTTON);
|
||||
}
|
||||
if (debug_buttons[BREAK_BUTTON].flags & BUTTON_DISABLED) {
|
||||
debug_buttons[BREAK_BUTTON].flags &= ~BUTTON_DISABLED;
|
||||
if (debug_bmp) button_draw(debug_bmp, debug_buttons + BREAK_BUTTON);
|
||||
}
|
||||
if (!(debug_buttons[STEP_BUTTON].flags & BUTTON_DISABLED)) {
|
||||
debug_buttons[STEP_BUTTON].flags |= BUTTON_DISABLED;
|
||||
if (debug_bmp) button_draw(debug_bmp, debug_buttons + STEP_BUTTON);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/* static void run_up( bool action ) */
|
||||
/* { */
|
||||
/* if ( action ) { */
|
||||
/* emulator_set_state( EMULATOR_RUN ); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* static void break_up( bool action ) */
|
||||
/* { */
|
||||
/* if ( action ) { */
|
||||
/* emulator_set_state( EMULATOR_STOP ); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* static void step_up( bool 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; */
|
||||
|
||||
// if (!debug_bmp) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// text_mode(color[C_PANEL_BACK]);
|
||||
|
||||
// acquire_bitmap(debug_bmp);
|
||||
// scare_mouse();
|
||||
|
||||
/* tmp = disassemble( bus_fast_peek( NULL, cpu.pc, NULL ) ); */
|
||||
|
||||
/* printf( "PC = #%05X %-24s\n", ( int )cpu.pc, tmp ); */
|
||||
|
||||
/*
|
||||
printf("A = #%s ", nib_to_hex_rev(cpu.reg[A], 16));
|
||||
printf("B = #%s ", nib_to_hex_rev(cpu.reg[B], 16));
|
||||
printf("C = #%s ", nib_to_hex_rev(cpu.reg[C], 16));
|
||||
printf("D = #%s ", nib_to_hex_rev(cpu.reg[D], 16));
|
||||
printf("\n");
|
||||
//printf("%*c%*c ", (int) 16-cpu.p, 'P', (int) cpu.p+1, '\0');
|
||||
//printf("\n");
|
||||
printf("R0 = #%s ", nib_to_hex_rev(cpu.reg_r[0], 16));
|
||||
printf("R1 = #%s ", nib_to_hex_rev(cpu.reg_r[1], 16));
|
||||
printf("R2 = #%s ", nib_to_hex_rev(cpu.reg_r[2], 16));
|
||||
printf("R3 = #%s ", nib_to_hex_rev(cpu.reg_r[3], 16));
|
||||
printf("R4 = #%s ", nib_to_hex_rev(cpu.reg_r[4], 16));
|
||||
printf("\n");
|
||||
|
||||
tmp = nib_to_hex(bus_fast_peek(NULL, cpu.d[0], NULL), 16);
|
||||
printf("D0 = #%05X (%s)\n", (int) cpu.d[0], tmp);
|
||||
tmp = nib_to_hex(bus_fast_peek(NULL, cpu.d[1], NULL), 16);
|
||||
printf("D1 = #%05X (%s)\n", (int) cpu.d[1], tmp);
|
||||
|
||||
//printf("RSTK", 10, 190, c1);
|
||||
for (i = 0; i < 8; i++) {
|
||||
printf(" #%05X\n", (int) cpu.rstk[(cpu.rstk_ptr+i)&7]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
||||
printf("P = #%X ", (int) cpu.p);
|
||||
|
||||
printf("OUT = #%s ", nib_to_hex_rev(cpu.out, 3));
|
||||
printf("IN = #%s ", nib_to_hex_rev(cpu.in, 4));
|
||||
printf("ST = #%s ", nib_to_hex_rev(cpu.st, 4));
|
||||
|
||||
printf("\n");
|
||||
*/
|
||||
|
||||
/*
|
||||
textout(debug_bmp, font, "MP", 200, 120, (cpu.hst & 0x8) ? c1 : c2);
|
||||
textout(debug_bmp, font, "SR", 224, 120, (cpu.hst & 0x4) ? c1 : c2);
|
||||
textout(debug_bmp, font, "SB", 248, 120, (cpu.hst & 0x2) ? c1 : c2);
|
||||
textout(debug_bmp, font, "XM", 272, 120, (cpu.hst & 0x1) ? c1 : c2);
|
||||
|
||||
textout(debug_bmp, font, "CARRY", 200, 130, cpu.carry ? c1 : c2);
|
||||
textout(debug_bmp, font, cpu.dec ? "DEC" : "HEX", 200, 140, c1);
|
||||
|
||||
textout(debug_bmp, font, "SHUTDOWN", 10, 280, cpu.shutdown ? c1 : c2);
|
||||
textout(debug_bmp, font, "KEYSCAN", 90, 280, cpu.keyscan ? c1 : c2);
|
||||
textout(debug_bmp, font, "INTE", 170, 280, cpu.inte ? c1 : c2);
|
||||
textout(debug_bmp, font, "KEYINTP", 250, 280, cpu.keyintp ? c1 : c2);
|
||||
|
||||
textout(debug_bmp, font, "HDWREG RAM CE1 CE2 NCE3", 58, 310, c1);
|
||||
textout(debug_bmp, font, "Mask", 10, 320, c1);
|
||||
textout(debug_bmp, font, "-----", 58, 320, c1);
|
||||
if (bus_info.ram_sz_cfg) {
|
||||
textprintf(debug_bmp, font, 114, 320, c1, "%05X",
|
||||
bus_info.ram_size); } else { textout(debug_bmp, font, "-----", 114, 320, c1);
|
||||
}
|
||||
if (bus_info.ce1_sz_cfg) {
|
||||
textprintf(debug_bmp, font, 170, 320, c1, "%05X",
|
||||
bus_info.ce1_size); } else { textout(debug_bmp, font, "-----", 170, 320, c1);
|
||||
}
|
||||
if (bus_info.ce2_sz_cfg) {
|
||||
textprintf(debug_bmp, font, 226, 320, c1, "%05X",
|
||||
bus_info.ce2_size); } else { textout(debug_bmp, font, "-----", 226, 320, c1);
|
||||
}
|
||||
if (bus_info.nce3_sz_cfg) {
|
||||
textprintf(debug_bmp, font, 282, 320, c1, "%05X",
|
||||
bus_info.nce3_size); } else { textout(debug_bmp, font, "-----", 282, 320, c1);
|
||||
}
|
||||
textout(debug_bmp, font, "Base", 10, 330, c1);
|
||||
if (bus_info.hdw_cfg) {
|
||||
textprintf(debug_bmp, font, 58, 330, c1, "%05X", bus_info.hdw_base);
|
||||
} else {
|
||||
textout(debug_bmp, font, "-----", 58, 330, c1);
|
||||
}
|
||||
if (bus_info.ram_cfg) {
|
||||
textprintf(debug_bmp, font, 114, 330, c1, "%05X", bus_info.ram_base);
|
||||
} else {
|
||||
textout(debug_bmp, font, "-----", 114, 330, c1);
|
||||
}
|
||||
if (bus_info.ce1_cfg) {
|
||||
textprintf(debug_bmp, font, 170, 330, c1, "%05X", bus_info.ce1_base);
|
||||
} else {
|
||||
textout(debug_bmp, font, "-----", 170, 330, c1);
|
||||
}
|
||||
if (bus_info.ce2_cfg) {
|
||||
textprintf(debug_bmp, font, 226, 330, c1, "%05X", bus_info.ce2_base);
|
||||
} else {
|
||||
textout(debug_bmp, font, "-----", 226, 330, c1);
|
||||
}
|
||||
if (bus_info.nce3_cfg) {
|
||||
textprintf(debug_bmp, font, 282, 330, c1, "%05X", bus_info.nce3_base);
|
||||
} else {
|
||||
textout(debug_bmp, font, "-----", 282, 330, c1);
|
||||
}
|
||||
|
||||
textprintf(debug_bmp, font, 10, 380, c1, "Instruction count = %u",
|
||||
cpu.inst_cnt); textprintf(debug_bmp, font, 10, 390, c1, "Cycle count = %u",
|
||||
cpu.cycles);
|
||||
*/
|
||||
// unscare_mouse();
|
||||
// release_bitmap(debug_bmp);
|
||||
}
|
||||
|
||||
void pdebug_draw_true_speed( dword speed )
|
||||
{
|
||||
// printf("True speed: %10u Hz\n", speed);
|
||||
|
||||
// if (!debug_bmp) {
|
||||
// return;
|
||||
// }
|
||||
// text_mode(color[C_PANEL_BACK]);
|
||||
// acquire_bitmap(debug_bmp);
|
||||
// scare_mouse();
|
||||
// textprintf(debug_bmp, font, 10, 410, color[C_PANEL_TEXT], "True speed:
|
||||
// %10u Hz", speed); unscare_mouse(); release_bitmap(debug_bmp);
|
||||
}
|
||||
|
||||
void pdebug_state_changed( void )
|
||||
{
|
||||
update_buttons();
|
||||
draw_cpu();
|
||||
}
|
||||
|
||||
/*
|
||||
void pdebug_show(BITMAP *bmp)
|
||||
{
|
||||
update_buttons();
|
||||
|
||||
debug_bmp = bmp;
|
||||
|
||||
clear_to_color(debug_bmp, color[C_PANEL_BACK]);
|
||||
button_draw_all(debug_bmp, debug_buttons);
|
||||
draw_cpu();
|
||||
}
|
||||
*/
|
||||
|
||||
void pdebug_hide( void )
|
||||
{
|
||||
// debug_bmp = NULL;
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
// button_mouse_up(debug_bmp, debug_buttons, mx, my, mb);
|
||||
}
|
16
src/pdebug.h
16
src/pdebug.h
|
@ -1,16 +0,0 @@
|
|||
#ifndef __PDEBUG_H
|
||||
#define __PDEBUG_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void draw_cpu( void );
|
||||
|
||||
void pdebug_state_changed( void );
|
||||
void pdebug_draw_true_speed( dword speed );
|
||||
|
||||
// void pdebug_show(BITMAP *bmp);
|
||||
void pdebug_hide( void );
|
||||
void pdebug_down( int mx, int my, int mb );
|
||||
void pdebug_up( int mx, int my, int mb );
|
||||
|
||||
#endif
|
78
src/pfiles.c
78
src/pfiles.c
|
@ -10,20 +10,9 @@
|
|||
#include <unistd.h> // readlink
|
||||
#include <linux/limits.h> // PATH_MAX
|
||||
|
||||
// static void load_up(bool action);
|
||||
char WorkingPath[ 512 ];
|
||||
|
||||
/*
|
||||
static Button files_buttons[] = {
|
||||
{ 0, 0, 0, 79, 20, BUTTON_B1RELEASE, "Load", NULL,
|
||||
load_up
|
||||
}, { 1, 0, 0, 0, 0, 0, NULL, NULL, NULL }
|
||||
};
|
||||
*/
|
||||
// static BITMAP *files_bmp;
|
||||
|
||||
static char WorkingPath[ 512 ];
|
||||
|
||||
static void getExePath()
|
||||
void getExePath()
|
||||
{
|
||||
char programPath[ 1024 ];
|
||||
char temp[ 1024 ];
|
||||
|
@ -43,7 +32,7 @@ static void getExePath()
|
|||
strcpy( WorkingPath, programPath );
|
||||
}
|
||||
|
||||
static int file_size( char* name )
|
||||
int file_size( char* name )
|
||||
{
|
||||
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
||||
getExePath();
|
||||
|
@ -64,27 +53,8 @@ static int file_size( char* name )
|
|||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
static int file_size(char *name)
|
||||
{
|
||||
FILE *f;
|
||||
f = fopen(name, "r");
|
||||
if(!f) {
|
||||
return NULL;
|
||||
}
|
||||
fseek(f, 0, SEEK_END); // seek to end of file
|
||||
int size = ftell(f); // get current file pointer
|
||||
fseek(f, 0, SEEK_SET); // seek back to beginning of file
|
||||
// proceed with allocating memory and reading the file
|
||||
fclose(f);
|
||||
return size;
|
||||
}
|
||||
*/
|
||||
|
||||
// static
|
||||
void load_file( char* name )
|
||||
{
|
||||
// PACKFILE *f;
|
||||
FILE* f;
|
||||
byte* buf;
|
||||
byte* obj;
|
||||
|
@ -141,45 +111,3 @@ void load_file( char* name )
|
|||
rpl_push_object( obj, size );
|
||||
free( obj );
|
||||
}
|
||||
|
||||
#define PATH_SIZE 1024
|
||||
|
||||
// /Users/admin/Documents/GIT/jsEmu48/jsEmu48/emutest2/emutest2/arkalite
|
||||
|
||||
// static
|
||||
void load_up( bool action )
|
||||
{
|
||||
/* static char path[ PATH_SIZE ] = ""; */
|
||||
|
||||
/* if ( action ) { */
|
||||
/* // if (file_select_ex("Load Object", path, NULL, PATH_SIZE, */
|
||||
/* // 0, 0)) { */
|
||||
/* // load_file(path); */
|
||||
/* // } */
|
||||
/* } */
|
||||
}
|
||||
|
||||
/*
|
||||
void pfiles_show(BITMAP *bmp)
|
||||
{
|
||||
files_bmp = bmp;
|
||||
|
||||
clear_to_color(files_bmp, color[C_PANEL_BACK]);
|
||||
button_draw_all(files_bmp, files_buttons);
|
||||
}
|
||||
*/
|
||||
|
||||
void pfiles_hide( void )
|
||||
{
|
||||
// files_bmp = NULL;
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
// button_mouse_up(files_bmp, files_buttons, mx, my, mb);
|
||||
}
|
||||
|
|
10
src/pfiles.h
10
src/pfiles.h
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
void load_up( bool action );
|
||||
void load_file( char* name );
|
||||
void pfiles_hide( void );
|
||||
void pfiles_down( int mx, int my, int mb );
|
||||
void pfiles_up( int mx, int my, int mb );
|
||||
extern char WorkingPath[ 512 ];
|
||||
|
||||
extern void getExePath();
|
||||
extern int file_size( char* name );
|
||||
extern void load_file( char* name );
|
||||
|
||||
#endif
|
||||
|
|
93
src/pmenu.c
93
src/pmenu.c
|
@ -1,93 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include "emulator.h"
|
||||
#include "color.h"
|
||||
#include "gui.h"
|
||||
#include "pmenu.h"
|
||||
|
||||
/* static void exit_up( bool action ); */
|
||||
/* static void debug_up( bool action ); */
|
||||
/* static void files_up( bool action ); */
|
||||
/* static void about_up( bool 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 } */
|
||||
/* }; */
|
||||
|
||||
enum MenuButtons { MENU_EXIT, MENU_DEBUG, MENU_FILES, MENU_ABOUT, MENU_COUNT };
|
||||
|
||||
// static BITMAP *menu_bmp;
|
||||
|
||||
/* static void exit_up( bool action ) */
|
||||
/* { */
|
||||
/* if ( action ) { */
|
||||
/* please_exit = true; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* static void debug_up( bool 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( bool 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( bool 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)
|
||||
{
|
||||
menu_bmp = bmp;
|
||||
|
||||
clear_to_color(menu_bmp, color[C_PANEL_BACK]);
|
||||
button_draw_all(menu_bmp, menu_buttons);
|
||||
}
|
||||
*/
|
||||
|
||||
void pmenu_hide( void )
|
||||
{
|
||||
// menu_bmp = NULL;
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
// button_mouse_up(menu_bmp, menu_buttons, mx, my, mb);
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef __PMENU_H
|
||||
#define __PMENU_H
|
||||
|
||||
// void pmenu_show(BITMAP *bmp);
|
||||
void pmenu_hide( void );
|
||||
void pmenu_down( int mx, int my, int mb );
|
||||
void pmenu_up( int mx, int my, int mb );
|
||||
|
||||
#endif
|
|
@ -15,13 +15,11 @@ void ports_init( void )
|
|||
bus_info.ce1_r_o = true;
|
||||
bus_info.ce1_bs = true;
|
||||
|
||||
#define PORT1_SIZE ( 256 * 1024 ) /* 128Kio in nibbles */
|
||||
// ce2 = port1 (plugged)
|
||||
bus_info.ce2_data = malloc( PORT1_SIZE );
|
||||
bus_info.ce2_mask = PORT1_SIZE - 1;
|
||||
bus_info.ce2_r_o = false;
|
||||
|
||||
#define PORT2_SIZE ( 256 * 1024 ) /* 128Kio in nibbles */
|
||||
// nce3 = port2 (plugged)
|
||||
port2 = malloc( PORT2_SIZE );
|
||||
port2mask = PORT2_SIZE - 1;
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
#define PORT1_SIZE ( 256 * 1024 ) /* 128Kio in nibbles */
|
||||
#define PORT2_SIZE ( 256 * 1024 ) /* 128Kio in nibbles */
|
||||
|
||||
void ports_init( void );
|
||||
void ports_exit( void );
|
||||
void ports_switch_bank( address adr );
|
||||
|
|
53
src/rom.c
53
src/rom.c
|
@ -1,59 +1,14 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
#include "bus.h"
|
||||
#include "rom.h"
|
||||
|
||||
#include <libgen.h> // dirname
|
||||
#include <unistd.h> // readlink
|
||||
#include <linux/limits.h> // PATH_MAX
|
||||
|
||||
static char WorkingPath[ 512 ];
|
||||
|
||||
static void getExePath()
|
||||
{
|
||||
char programPath[ 1024 ] = ".";
|
||||
char temp[ 1024 ];
|
||||
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;
|
||||
if ( count != -1 ) {
|
||||
path = dirname( result );
|
||||
strcpy( programPath, path );
|
||||
}
|
||||
|
||||
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
||||
strcpy( WorkingPath, programPath );
|
||||
|
||||
printf( "exec path = %s\n", WorkingPath );
|
||||
}
|
||||
|
||||
static int file_size( char* name )
|
||||
{
|
||||
memset( WorkingPath, 0, sizeof( WorkingPath ) );
|
||||
getExePath();
|
||||
|
||||
FILE* f;
|
||||
char fullpath[ 1024 ];
|
||||
sprintf( fullpath, "%s/%s", WorkingPath, name );
|
||||
printf( "%s\n", fullpath );
|
||||
f = fopen( fullpath, "r" );
|
||||
if ( !f ) {
|
||||
return 0;
|
||||
}
|
||||
fseek( f, 0, SEEK_END ); // seek to end of file
|
||||
int size = ( int )ftell( f ); // get current file pointer
|
||||
fseek( f, 0, SEEK_SET ); // seek back to beginning of file
|
||||
// proceed with allocating memory and reading the file
|
||||
fclose( f );
|
||||
return size;
|
||||
}
|
||||
#include "types.h"
|
||||
#include "bus.h"
|
||||
#include "rom.h"
|
||||
#include "pfiles.h"
|
||||
|
||||
void rom_init( void )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue