diff --git a/Makefile b/Makefile index 8c88b65..e24d8ee 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,6 @@ all: dist/hpemu dist/hpemu: src/bus.o \ src/color.o \ src/cpu.o \ - src/disasm.o \ src/display.o \ src/emulator.o \ src/gui.o \ diff --git a/src/bus.h b/src/bus.h index 91cf863..eeb92ff 100644 --- a/src/bus.h +++ b/src/bus.h @@ -57,17 +57,17 @@ extern word crc; // FAST_PEEK_MAX must not be greater than the size of the hdw registers (64) #define FAST_PEEK_MAX 64 -void bus_init( void ); -void bus_exit( void ); +extern void bus_init( void ); +extern void bus_exit( void ); -void bus_read( byte* buf, address adr, address len ); -void bus_write( byte* buf, address adr, address len ); -byte* bus_fast_peek( byte* buf, address adr, address* len ); +extern void bus_read( byte* buf, address adr, address len ); +extern void bus_write( byte* buf, address adr, address len ); +extern byte* bus_fast_peek( byte* buf, address adr, address* len ); -void bus_remap( void ); -void bus_configure( address adr ); -void bus_unconfigure( address adr ); -void bus_reset( void ); -address bus_get_id(); +extern void bus_remap( void ); +extern void bus_configure( address adr ); +extern void bus_unconfigure( address adr ); +extern void bus_reset( void ); +extern address bus_get_id(); #endif diff --git a/src/color.c b/src/color.c index d3c4beb..19deeed 100644 --- a/src/color.c +++ b/src/color.c @@ -3,6 +3,8 @@ #define RESERVED_LCD 128 +enum LCD_Modes { LCD_MODE_SIMPLE, LCD_MODE_GRAY4, LCD_MODE_GRAY8, LCD_MODE_EXP }; + int color[ C_COUNT ]; typedef struct RGB { diff --git a/src/color.h b/src/color.h index f88437d..96c6f6a 100644 --- a/src/color.h +++ b/src/color.h @@ -1,8 +1,6 @@ #ifndef __COLOR_H #define __COLOR_H -enum LCD_Modes { LCD_MODE_SIMPLE, LCD_MODE_GRAY4, LCD_MODE_GRAY8, LCD_MODE_EXP }; - enum Colors { C_BACKGROUND, C_PANEL_BACK, @@ -19,9 +17,6 @@ enum Colors { extern int color[ C_COUNT ]; -void color_lcd( int r0, int g0, int b0, int r1, int g1, int b1 ); -void color_lcd_mode( int mode ); -void color_set_emu( int i, int r, int g, int b ); -void color_init( void ); +extern void color_init( void ); #endif diff --git a/src/cpu.h b/src/cpu.h index c7fe368..292acd0 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -34,7 +34,7 @@ enum RegisterNames { A, B, C, D }; extern Cpu cpu; -void cpu_interrupt( void ); -void execute_instruction( void ); +extern void cpu_interrupt( void ); +extern void execute_instruction( void ); #endif diff --git a/src/disasm.c b/src/disasm.c deleted file mode 100644 index 78777f1..0000000 --- a/src/disasm.c +++ /dev/null @@ -1,283 +0,0 @@ -#include -#include "types.h" -#include "opcodes.h" -#include "opinline.h" -#include "disasm.h" - -static const char hex_tab[ 16 ] = "0123456789ABCDEF"; - -static const char r_tab[ 11 ][ 16 ] = { - "ABCDABCDBCACBCAC", // p - "BCAC1111ABCDABCD", // q - "ABCDBCACABCDBCAC", // r - "BCACABCDBCACABCD", // s - "ABCDABCDBCACABCD", // t - "ABCDABCDABCDABCD", // u (different than in opcodes.c) - "BCACBCACBCACBCAC", // v (different than in opcodes.c) - "BCACABCDABCD1111", // w - "ABCDABCDBCACABAC", // x - "0000BCACABCDBCCD", // y - "BCACBCAC00000000", // z -}; - -static const char* f_tab[ 8 ] = { "P", "WP", "XS", "X", "S", "M", "B", "W" }; - -#define HEX( x ) ( hex_tab[ x ] ) - -#define ADD_OFFSET( x, s ) \ - do { \ - if ( *( s ) == '+' ) { \ - ( s )++; \ - ( x ) += *( s )++ - '0'; \ - } \ - } while ( 0 ) - -static void expand( char* dest, char* src, byte* ptr ) -{ - int i, n; - int x; - - while ( *src ) { - if ( *src != '%' ) { - *dest++ = *src++; - } else { - src++; - switch ( *src++ ) { - - case 'I': // One digit integer - i = *src++ - '0'; - x = ptr[ i ]; - ADD_OFFSET( x, src ); - if ( x >= 10 ) { - *dest++ = '0' + x / 10; - *dest++ = '0' + x % 10; - } else { - *dest++ = '0' + x; - } - break; - - case 'X': // Hexadecimal number - i = *src++ - '0'; - n = *src++ - '0'; - while ( n-- ) { - *dest++ = HEX( ptr[ i + n ] ); - } - break; - - case 'N': // Variable length hexadecimal number - i = *src++ - '0'; - n = ptr[ i ] + 1; - while ( n ) { - *dest++ = HEX( ptr[ i + n ] ); - n--; - } - break; - - case 'R': // Relative address - i = *src++ - '0'; - n = *src++ - '0'; - x = nib_to_signed( ptr + i, n ); - ADD_OFFSET( x, src ); - if ( x < 0 ) { - *dest++ = '-'; - x = -x; - } else { - *dest++ = '+'; - } - while ( n-- ) { - *dest++ = HEX( ( x >> ( n * 4 ) ) & 0xF ); - } - break; - - case 'T': // Relative address for tests - i = *src++ - '0'; - n = *src++ - '0'; - x = nib_to_signed( ptr + i, n ); - if ( x == 0 ) { - ADD_OFFSET( x, src ); // skip over the optional "+i" - break; - } - ADD_OFFSET( x, src ); - if ( x < 0 ) { - *dest++ = '-'; - x = -x; - } else { - *dest++ = '+'; - } - while ( n-- ) { - *dest++ = HEX( ( x >> ( n * 4 ) ) & 0xF ); - } - break; - - case 'G': // "GO" or "RTN" for tests - i = *src++ - '0'; - n = *src++ - '0'; - x = nib_to_signed( ptr + i, n ); - if ( x == 0 ) { - *dest++ = 'R'; - *dest++ = 'T'; - *dest++ = 'N'; - } else { - *dest++ = 'G'; - *dest++ = 'O'; - } - break; - - case 'F': // Field name - i = *src++ - '0'; - if ( *src == 'A' ) { - src++; - if ( ptr[ i ] == 0xF ) { - *dest++ = 'A'; - break; - } - } - *dest++ = f_tab[ ptr[ i ] & 7 ][ 0 ]; - if ( f_tab[ ptr[ i ] & 7 ][ 1 ] ) - *dest++ = f_tab[ ptr[ i ] & 7 ][ 1 ]; - break; - - case 'B': // Field A or B - i = *src++ - '0'; - *dest++ = ( ptr[ i ] & 8 ) ? 'B' : 'A'; - break; - - case 'p': // Subtraction source 1 - case 'q': // Subtraction source 2 - case 'r': // Logic destination & source 1 - case 's': // Logic source 2 - case 't': // Arithmethic destination & addition source 1 - case 'u': // Compare source 1 - case 'v': // Compare source 2 for <, >, <= and >= - case 'w': // Addition source 2 - case 'x': // Assignment destination - case 'y': // Assignment source - case 'z': // Compare source 2 for = and # - i = *src++ - '0'; - *dest++ = r_tab[ src[ -2 ] - 'p' ][ ptr[ i ] ]; - break; - - case 'a': // "A" or "C" - i = *src++ - '0'; - *dest++ = ( ptr[ i ] & 8 ) ? 'C' : 'A'; - break; - - case 'i': // R-register number - i = *src++ - '0'; - *dest++ = '0' + ( ( ptr[ i ] & 7 ) > 4 ? ptr[ i ] & 3 : ptr[ i ] & 7 ); - break; - - case '#': // "#" or "=" for comparisons - i = *src++ - '0'; - *dest++ = ( ptr[ i ] & 4 ) ? '#' : '='; - break; - - case '>': // ">", "<", ">=" or "<=" for comparisons - i = *src++ - '0'; - *dest++ = ( ptr[ i ] & 4 ) ? '<' : '>'; - if ( ptr[ i ] & 8 ) - *dest++ = '='; - break; - - case '=': // Conditional "=" for assignments - i = *src++ - '0'; - if ( ptr[ i ] < 0xC ) - *dest++ = '='; - break; - - case 'E': // Conditionsl "EX" for assignments - i = *src++ - '0'; - if ( ptr[ i ] >= 0xC ) { - *dest++ = 'E'; - *dest++ = 'X'; - } - break; - - case '+': // "+" or "-" for add / dec - i = *src++ - '0'; - *dest++ = ( ptr[ i ] < 0xC ) ? '+' : '-'; - break; - - case '-': // "-" or "+" for sub / inc - i = *src++ - '0'; - *dest++ = ( ( ptr[ i ] & 0xC ) != 0x4 ) ? '-' : '+'; - break; - - case '~': // "+" or "-" for +con and -con - i = *src++ - '0'; - *dest++ = ( ptr[ i ] & 8 ) ? '-' : '+'; - break; - - case '&': // "&" or "!" for and / or - i = *src++ - '0'; - *dest++ = ( ptr[ i ] & 8 ) ? '!' : '&'; - break; - - case 'D': // DATi=r or r=DATi - i = *src++ - '0'; - if ( !( ptr[ i ] & 2 ) ) { - *dest++ = 'D'; - *dest++ = 'A'; - *dest++ = 'T'; - *dest++ = '0' + ( ptr[ i ] & 1 ); - *dest++ = '='; - *dest++ = 'A' + ( ( ptr[ i ] & 4 ) >> 1 ); - } else { - *dest++ = 'A' + ( ( ptr[ i ] & 4 ) >> 1 ); - *dest++ = '='; - *dest++ = 'D'; - *dest++ = 'A'; - *dest++ = 'T'; - *dest++ = '0' + ( ptr[ i ] & 1 ); - } - break; - - case '%': // Litteral % - *( dest++ ) = '%'; - break; - } - } - } - *dest = '\0'; -} - -char* disassemble( byte* ptr ) -{ - static char buffer[ 64 ]; - - Opcode* op = opcodes; - int i = 0; - - while ( op[ ptr[ i ] ].next ) { - op = op[ ptr[ i ] ].next; - i++; - } - if ( op[ ptr[ i ] ].dissasm ) { - expand( buffer, op[ ptr[ i ] ].dissasm, ptr ); - } else { - sprintf( buffer, "Unknown (%s)", nib_to_hex( ptr, i + 1 ) ); - } - return buffer; -} - -char* nib_to_hex( byte* nib, int n ) -{ - static char buffer[ 17 ]; - - buffer[ n ] = '\0'; - while ( n-- ) { - buffer[ n ] = HEX( nib[ n ] ); - } - return buffer; -} - -char* nib_to_hex_rev( byte* nib, int n ) -{ - static char buffer[ 17 ]; - - buffer[ n ] = '\0'; - while ( n-- ) { - buffer[ n ] = HEX( *nib++ ); - } - return buffer; -} diff --git a/src/disasm.h b/src/disasm.h deleted file mode 100644 index a8770af..0000000 --- a/src/disasm.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __DISASM_H -#define __DISASM_H - -#include "types.h" - -char* disassemble( byte* ptr ); -char* nib_to_hex( byte* nib, int n ); -char* nib_to_hex_rev( byte* nib, int n ); - -#endif diff --git a/src/display.h b/src/display.h index 10f26bb..537e660 100644 --- a/src/display.h +++ b/src/display.h @@ -1,8 +1,9 @@ #ifndef __DISPLAY_H #define __DISPLAY_H -#include #include +#include + #include "types.h" extern address menu_base; @@ -13,9 +14,9 @@ extern byte display_height; extern byte display_offset; extern bool display_enable; -void display_init( void ); -void display_exit( void ); -void display_update( void ); -void display_show(); +extern void display_init( void ); +extern void display_exit( void ); +extern void display_update( void ); +extern void display_show( void ); #endif diff --git a/src/emulator.c b/src/emulator.c index 1ba3208..042417f 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -41,8 +41,6 @@ static int emulator_state = EMULATOR_RUN; void emulator_set_state( int state ) { emulator_state = state; } -int emulator_get_state( void ) { return emulator_state; } - void emulator_init( void ) { static bool locked = false; diff --git a/src/emulator.h b/src/emulator.h index 9694718..9aa6035 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -5,16 +5,13 @@ enum EmulatorStates { EMULATOR_STOP, EMULATOR_STEP, EMULATOR_RUN }; -void true_speed_proc( void ); - extern volatile bool please_exit; extern dword emulator_speed; -void emulator_init( void ); -void emulator_exit( void ); -bool emulator_run( void ); +extern void emulator_init( void ); +extern void emulator_exit( void ); +extern bool emulator_run( void ); -void emulator_set_state( int state ); -int emulator_get_state( void ); +extern void emulator_set_state( int state ); #endif diff --git a/src/gui.c b/src/gui.c index f54fb02..93a1bbc 100644 --- a/src/gui.c +++ b/src/gui.c @@ -4,6 +4,7 @@ #include #include + #include "color.h" #include "pcalc.h" #include "pfiles.h" diff --git a/src/gui.h b/src/gui.h index 434ef13..80ba4a9 100644 --- a/src/gui.h +++ b/src/gui.h @@ -29,10 +29,10 @@ typedef struct { #define BUTTON_B2TOGGLE 0x08 // Mouse button 2 toggles this button #define BUTTON_B1RELEASE 0x10 // Releaseing mouse button 1 anywhere unpushes the button -void gui_initKeyboard( Button* calcbuttons ); +extern void gui_initKeyboard( Button* calcbuttons ); -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 ); +extern void button_draw_all( /*BITMAP *bmp,*/ Button* buttons ); +extern int button_mouse_down( /*BITMAP *bmp,*/ Button* butons, int mx, int my, int mb ); +extern int button_mouse_up( /*BITMAP *bmp,*/ Button* buttons, int mx, int my, int mb ); #endif diff --git a/src/hdw.h b/src/hdw.h index cd543a8..26c8222 100644 --- a/src/hdw.h +++ b/src/hdw.h @@ -3,10 +3,10 @@ #include "types.h" -void hdw_init( void ); -void hdw_exit( void ); +extern void hdw_init( void ); +extern void hdw_exit( void ); -byte hdw_read_nibble( address adr ); -void hdw_write_nibble( byte data, address adr ); +extern byte hdw_read_nibble( address adr ); +extern void hdw_write_nibble( byte data, address adr ); #endif diff --git a/src/keyboard.h b/src/keyboard.h index 3138b8d..9e5caa5 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -5,10 +5,10 @@ extern bool kbd_on; -void kbd_out_changed( void ); -void kbd_key_pressed( int row, int col ); -void kbd_key_released( int row, int col ); -void kbd_on_pressed( void ); -void kbd_on_released( void ); +extern void kbd_out_changed( void ); +extern void kbd_key_pressed( int row, int col ); +extern void kbd_key_released( int row, int col ); +extern void kbd_on_pressed( void ); +extern void kbd_on_released( void ); #endif diff --git a/src/pcalc.c b/src/pcalc.c index efec35d..83b60a4 100644 --- a/src/pcalc.c +++ b/src/pcalc.c @@ -257,11 +257,6 @@ void pcalc_show() button_draw_all( calc_buttons ); } -void pcalc_hide( void ) -{ - // calc_bmp = NULL; -} - void pcalc_down( int mx, int my, int mb ) { button_mouse_down( calc_buttons, mx, my, mb ); } void pcalc_up( int mx, int my, int mb ) { button_mouse_up( calc_buttons, mx, my, mb ); } diff --git a/src/pcalc.h b/src/pcalc.h index 4eb1c3d..b4d10c2 100644 --- a/src/pcalc.h +++ b/src/pcalc.h @@ -2,6 +2,7 @@ #define __PCALC_H #include + #include "types.h" typedef struct { @@ -10,12 +11,11 @@ typedef struct { void ( *up )( bool action ); } KBMapping; -void pcalc_init(); -void pcalc_show(); -void pcalc_hide( void ); -void pcalc_down( int mx, int my, int mb ); -void pcalc_up( int mx, int my, int mb ); -void pcalc_kb_down( SDL_Keycode sdl_event ); -void pcalc_kb_up( SDL_Keycode sdl_event ); +extern void pcalc_init(); +extern void pcalc_show(); +extern void pcalc_down( int mx, int my, int mb ); +extern void pcalc_up( int mx, int my, int mb ); +extern void pcalc_kb_down( SDL_Keycode sdl_event ); +extern void pcalc_kb_up( SDL_Keycode sdl_event ); #endif diff --git a/src/pfiles.h b/src/pfiles.h index 11e541f..9310215 100644 --- a/src/pfiles.h +++ b/src/pfiles.h @@ -5,7 +5,6 @@ extern char WorkingPath[ 512 ]; -extern void getExePath(); extern int file_size( char* name ); extern void load_file( char* name ); diff --git a/src/ports.h b/src/ports.h index 6395186..7e82463 100644 --- a/src/ports.h +++ b/src/ports.h @@ -6,9 +6,9 @@ #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 ); -byte ports_card_detect( void ); +extern void ports_init( void ); +extern void ports_exit( void ); +extern void ports_switch_bank( address adr ); +extern byte ports_card_detect( void ); #endif diff --git a/src/ram.h b/src/ram.h index 004b5bd..0f30a15 100644 --- a/src/ram.h +++ b/src/ram.h @@ -1,7 +1,7 @@ #ifndef __RAM_H #define __RAM_H -void ram_init( void ); -void ram_exit( void ); +extern void ram_init( void ); +extern void ram_exit( void ); #endif diff --git a/src/rom.c b/src/rom.c index c4c5aa9..8eaa9dc 100644 --- a/src/rom.c +++ b/src/rom.c @@ -12,11 +12,9 @@ void rom_init( void ) { - printf( "rom_init..\n" ); int size; char* name = "hpemu.rom"; byte *buf, *ptr1, *ptr2; - // PACKFILE *f; FILE* f; size = file_size( name ); diff --git a/src/rom.h b/src/rom.h index 4f87d81..31fe943 100644 --- a/src/rom.h +++ b/src/rom.h @@ -1,7 +1,7 @@ #ifndef __ROM_H #define __ROM_H -void rom_init( void ); -void rom_exit( void ); +extern void rom_init( void ); +extern void rom_exit( void ); #endif diff --git a/src/rpl.h b/src/rpl.h index f47128f..0518af5 100644 --- a/src/rpl.h +++ b/src/rpl.h @@ -3,9 +3,7 @@ #include "types.h" -int rpl_object_size( byte* obj ); -address rpl_make_temp( address size ); -void rpl_push( address adr ); -int rpl_push_object( byte* obj, address size ); +extern int rpl_object_size( byte* obj ); +extern int rpl_push_object( byte* obj, address size ); #endif diff --git a/src/timers.h b/src/timers.h index 60fa762..bf4f8b4 100644 --- a/src/timers.h +++ b/src/timers.h @@ -8,7 +8,7 @@ extern byte timer2_control; extern byte timer1_value; extern dword timer2_value; -void timer1_update( void ); -void timer2_update( void ); +extern void timer1_update( void ); +extern void timer2_update( void ); #endif