changeset 1102:c15896605bf2

Clean up symbol visiblity and delete a ltitle bit of dead code
author Michael Pavone <pavone@retrodev.com>
date Mon, 28 Nov 2016 22:45:46 -0800
parents e2d345e351b5
children 22e87b739ad6
files m68k_core.c m68k_core.h m68k_internal.h psg.c render.h render_sdl.c vdp.c vdp.h ym2612.c
diffstat 9 files changed, 100 insertions(+), 134 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_core.c	Tue Nov 15 08:18:57 2016 -0800
+++ b/m68k_core.c	Mon Nov 28 22:45:46 2016 -0800
@@ -100,7 +100,7 @@
 	}
 }
 
-void translate_m68k_lea_pea(m68k_options * opts, m68kinst * inst)
+static void translate_m68k_lea_pea(m68k_options * opts, m68kinst * inst)
 {
 	code_info *code = &opts->gen.code;
 	int8_t dst_reg = inst->op == M68K_PEA ? opts->gen.scratch1 : native_reg(&(inst->dst), opts);
@@ -175,7 +175,7 @@
 	}
 }
 
-void push_const(m68k_options *opts, int32_t value)
+static void push_const(m68k_options *opts, int32_t value)
 {
 	ldi_native(opts, value, opts->gen.scratch1);
 	subi_areg(opts, 4, 7);
@@ -197,7 +197,7 @@
 	//since instruction retranslation patches the original native instruction location
 }
 
-void translate_m68k_bsr(m68k_options * opts, m68kinst * inst)
+static void translate_m68k_bsr(m68k_options * opts, m68kinst * inst)
 {
 	code_info *code = &opts->gen.code;
 	int32_t disp = inst->src.params.immed;
@@ -208,7 +208,7 @@
 	jump_m68k_abs(opts, inst->address + 2 + disp);
 }
 
-void translate_m68k_jmp_jsr(m68k_options * opts, m68kinst * inst)
+static void translate_m68k_jmp_jsr(m68k_options * opts, m68kinst * inst)
 {
 	uint8_t is_jsr = inst->op == M68K_JSR;
 	code_info *code = &opts->gen.code;
@@ -278,7 +278,7 @@
 	}
 }
 
-void translate_m68k_unlk(m68k_options * opts, m68kinst * inst)
+static void translate_m68k_unlk(m68k_options * opts, m68kinst * inst)
 {
 	cycles(&opts->gen, BUS);
 	areg_to_native(opts, inst->dst.params.regs.pri, opts->aregs[7]);
@@ -288,7 +288,7 @@
 	addi_areg(opts, 4, 7);
 }
 
-void translate_m68k_link(m68k_options * opts, m68kinst * inst)
+static void translate_m68k_link(m68k_options * opts, m68kinst * inst)
 {
 	//compensate for displacement word
 	cycles(&opts->gen, BUS);
@@ -302,7 +302,7 @@
 	cycles(&opts->gen, BUS);
 }
 
-void translate_m68k_rts(m68k_options * opts, m68kinst * inst)
+static void translate_m68k_rts(m68k_options * opts, m68kinst * inst)
 {
 	code_info *code = &opts->gen.code;
 	//TODO: Add cycles
@@ -313,7 +313,7 @@
 	jmp_r(code, opts->gen.scratch1);
 }
 
-void translate_m68k_rtr(m68k_options *opts, m68kinst * inst)
+static void translate_m68k_rtr(m68k_options *opts, m68kinst * inst)
 {
 	code_info *code = &opts->gen.code;
 	//Read saved CCR
@@ -330,7 +330,7 @@
 	jmp_r(code, opts->gen.scratch1);
 }
 
-void translate_m68k_trap(m68k_options *opts, m68kinst *inst)
+static void translate_m68k_trap(m68k_options *opts, m68kinst *inst)
 {
 	code_info *code = &opts->gen.code;
 	uint32_t vector, pc = inst->address;
@@ -352,7 +352,7 @@
 	jmp(code, opts->trap);
 }
 
-void translate_m68k_illegal(m68k_options *opts, m68kinst *inst)
+static void translate_m68k_illegal(m68k_options *opts, m68kinst *inst)
 {
 	code_info *code = &opts->gen.code;
 	cycles(&opts->gen, BUS);
@@ -361,7 +361,7 @@
 	jmp(code, opts->trap);
 }
 
-void translate_m68k_move_usp(m68k_options *opts, m68kinst *inst)
+static void translate_m68k_move_usp(m68k_options *opts, m68kinst *inst)
 {
 	m68k_trap_if_not_supervisor(opts, inst);
 	cycles(&opts->gen, BUS);
@@ -385,7 +385,7 @@
 	}
 }
 
-void translate_m68k_movem(m68k_options * opts, m68kinst * inst)
+static void translate_m68k_movem(m68k_options * opts, m68kinst * inst)
 {
 	code_info *code = &opts->gen.code;
 	int8_t bit,reg,sec_reg;
@@ -525,7 +525,7 @@
 	cycles(&opts->gen, 4);
 }
 
-void translate_m68k_nop(m68k_options *opts, m68kinst *inst)
+static void translate_m68k_nop(m68k_options *opts, m68kinst *inst)
 {
 	cycles(&opts->gen, BUS);
 }
@@ -537,7 +537,7 @@
 	native_to_areg(opts, opts->gen.scratch2, 8);
 }
 
-void translate_m68k_rte(m68k_options *opts, m68kinst *inst)
+static void translate_m68k_rte(m68k_options *opts, m68kinst *inst)
 {
 	m68k_trap_if_not_supervisor(opts, inst);
 	
@@ -614,7 +614,7 @@
 	return address;
 }
 
-void map_native_address(m68k_context * context, uint32_t address, code_ptr native_addr, uint8_t size, uint8_t native_size)
+static void map_native_address(m68k_context * context, uint32_t address, code_ptr native_addr, uint8_t size, uint8_t native_size)
 {
 	native_map_slot * native_code_map = context->native_code_map;
 	m68k_options * opts = context->options;
@@ -674,7 +674,7 @@
 	}
 }
 
-uint8_t get_native_inst_size(m68k_options * opts, uint32_t address)
+static uint8_t get_native_inst_size(m68k_options * opts, uint32_t address)
 {
 	address &= opts->gen.address_mask;
 	uint32_t meta_off = 0;
@@ -701,7 +701,7 @@
 		|| (inst->op == M68K_BCC && inst->extra.cond == COND_TRUE);
 }
 
-void m68k_handle_deferred(m68k_context * context)
+static void m68k_handle_deferred(m68k_context * context)
 {
 	m68k_options * opts = context->options;
 	process_deferred(&opts->gen.deferred, context, (native_addr_func)get_native_from_context);
@@ -745,7 +745,7 @@
 #define UNARY_IMPL(inst, mask)  [inst] = { .impl = { .flag_mask = mask }, .itype = UNARY_ARITH }
 #define BINARY_IMPL(inst, mask) [inst] = { .impl = { .flag_mask = mask}, .itype = BINARY_ARITH }
 
-impl_info m68k_impls[] = {
+static impl_info m68k_impls[] = {
 	//math
 	BINARY_IMPL(M68K_ADD, X|N|Z|V|C),
 	BINARY_IMPL(M68K_SUB, X|N|Z|V|C),
@@ -836,7 +836,7 @@
 	RAW_IMPL(M68K_TAS, translate_m68k_tas),
 };
 
-void translate_m68k(m68k_options * opts, m68kinst * inst)
+static void translate_m68k(m68k_options * opts, m68kinst * inst)
 {
 	if (inst->address & 1) {
 		translate_m68k_odd(opts, inst);
--- a/m68k_core.h	Tue Nov 15 08:18:57 2016 -0800
+++ b/m68k_core.h	Mon Nov 28 22:45:46 2016 -0800
@@ -73,7 +73,6 @@
 
 typedef m68k_context *(*m68k_reset_handler)(m68k_context *context);
 
-void translate_m68k(m68k_options * opts, struct m68kinst * inst);
 void translate_m68k_stream(uint32_t address, m68k_context * context);
 void start_68k_context(m68k_context * context, uint32_t address);
 void resume_68k(m68k_context *context);
--- a/m68k_internal.h	Tue Nov 15 08:18:57 2016 -0800
+++ b/m68k_internal.h	Mon Nov 28 22:45:46 2016 -0800
@@ -45,14 +45,10 @@
 void m68k_read_size(m68k_options *opts, uint8_t size);
 void m68k_write_size(m68k_options *opts, uint8_t size, uint8_t lowfirst);
 void m68k_save_result(m68kinst * inst, m68k_options * opts);
-void push_const(m68k_options *opts, int32_t value);
 void jump_m68k_abs(m68k_options * opts, uint32_t address);
 void swap_ssp_usp(m68k_options * opts);
 code_ptr get_native_address(m68k_options *opts, uint32_t address);
-void map_native_address(m68k_context * context, uint32_t address, code_ptr native_addr, uint8_t size, uint8_t native_size);
-uint8_t get_native_inst_size(m68k_options * opts, uint32_t address);
 uint8_t m68k_is_terminal(m68kinst * inst);
-void m68k_handle_deferred(m68k_context * context);
 code_ptr get_native_address_trans(m68k_context * context, uint32_t address);
 void * m68k_retranslate_inst(uint32_t address, m68k_context * context);
 
@@ -60,8 +56,6 @@
 void translate_m68k_bcc(m68k_options * opts, m68kinst * inst);
 void translate_m68k_scc(m68k_options * opts, m68kinst * inst);
 void translate_m68k_dbcc(m68k_options * opts, m68kinst * inst);
-void translate_m68k_rtr(m68k_options *opts, m68kinst * inst);
-void translate_m68k_trap(m68k_options *opts, m68kinst *inst);
 void translate_m68k_trapv(m68k_options *opts, m68kinst *inst);
 void translate_m68k_move(m68k_options * opts, m68kinst * inst);
 void translate_m68k_movep(m68k_options * opts, m68kinst * inst);
--- a/psg.c	Tue Nov 15 08:18:57 2016 -0800
+++ b/psg.c	Mon Nov 28 22:45:46 2016 -0800
@@ -91,7 +91,7 @@
 #define PSG_VOL_DIV 14
 
 //table shamelessly swiped from PSG doc from smspower.org
-int16_t volume_table[16] = {
+static int16_t volume_table[16] = {
 	32767/PSG_VOL_DIV, 26028/PSG_VOL_DIV, 20675/PSG_VOL_DIV, 16422/PSG_VOL_DIV, 13045/PSG_VOL_DIV, 10362/PSG_VOL_DIV,
 	8231/PSG_VOL_DIV, 6568/PSG_VOL_DIV, 5193/PSG_VOL_DIV, 4125/PSG_VOL_DIV, 3277/PSG_VOL_DIV, 2603/PSG_VOL_DIV,
 	2067/PSG_VOL_DIV, 1642/PSG_VOL_DIV, 1304/PSG_VOL_DIV, 0
--- a/render.h	Tue Nov 15 08:18:57 2016 -0800
+++ b/render.h	Mon Nov 28 22:45:46 2016 -0800
@@ -62,16 +62,11 @@
 void render_framebuffer_updated(uint8_t which, int width);
 void render_init(int width, int height, char * title, uint32_t fps, uint8_t fullscreen);
 void render_update_caption(char *title);
-void render_context(vdp_context * context);
 void render_wait_quit(vdp_context * context);
 void render_wait_psg(psg_context * context);
 void render_wait_ym(ym2612_context * context);
-int wait_render_frame(vdp_context * context, int frame_limit);
-void render_fps(uint32_t fps);
 uint32_t render_audio_buffer();
 uint32_t render_sample_rate();
-void render_debug_mode(uint8_t mode);
-void render_debug_pal(uint8_t pal);
 void process_events();
 int render_width();
 int render_height();
--- a/render_sdl.c	Tue Nov 15 08:18:57 2016 -0800
+++ b/render_sdl.c	Mon Nov 28 22:45:46 2016 -0800
@@ -18,38 +18,36 @@
 
 #define MAX_EVENT_POLL_PER_FRAME 2
 
-SDL_Window *main_window;
-SDL_Renderer *main_renderer;
-SDL_Texture  **sdl_textures;
-uint8_t num_textures;
-SDL_Rect      main_clip;
-SDL_GLContext *main_context;
+static SDL_Window *main_window;
+static SDL_Renderer *main_renderer;
+static SDL_Texture  **sdl_textures;
+static uint8_t num_textures;
+static SDL_Rect      main_clip;
+static SDL_GLContext *main_context;
 
-int main_width, main_height, is_fullscreen;
+static int main_width, main_height, is_fullscreen;
 
-uint8_t render_dbg = 0;
-uint8_t debug_pal = 0;
-uint8_t render_gl = 1;
-uint8_t scanlines = 0;
+static uint8_t render_gl = 1;
+static uint8_t scanlines = 0;
 
-uint32_t last_frame = 0;
+static uint32_t last_frame = 0;
 
-uint32_t min_delay;
-uint32_t frame_delay = 1000/60;
+static uint32_t min_delay;
+static uint32_t frame_delay = 1000/60;
 
-int16_t * current_psg = NULL;
-int16_t * current_ym = NULL;
+static int16_t * current_psg = NULL;
+static int16_t * current_ym = NULL;
 
-uint32_t buffer_samples, sample_rate;
-uint32_t missing_count;
+static uint32_t buffer_samples, sample_rate;
+static uint32_t missing_count;
 
-SDL_mutex * audio_mutex;
-SDL_cond * audio_ready;
-SDL_cond * psg_cond;
-SDL_cond * ym_cond;
-uint8_t quitting = 0;
+static SDL_mutex * audio_mutex;
+static SDL_cond * audio_ready;
+static SDL_cond * psg_cond;
+static SDL_cond * ym_cond;
+static uint8_t quitting = 0;
 
-void audio_callback(void * userdata, uint8_t *byte_stream, int len)
+static void audio_callback(void * userdata, uint8_t *byte_stream, int len)
 {
 	//puts("audio_callback");
 	int16_t * stream = (int16_t *)byte_stream;
@@ -85,7 +83,7 @@
 	}
 }
 
-void render_close_audio()
+static void render_close_audio()
 {
 	SDL_LockMutex(audio_mutex);
 		quitting = 1;
@@ -117,18 +115,18 @@
 }
 
 #ifndef DISABLE_OPENGL
-GLuint textures[3], buffers[2], vshader, fshader, program, un_textures[2], un_width, at_pos;
+static GLuint textures[3], buffers[2], vshader, fshader, program, un_textures[2], un_width, at_pos;
 
-GLfloat vertex_data[] = {
+static GLfloat vertex_data[] = {
 	-1.0f, -1.0f,
 	 1.0f, -1.0f,
 	-1.0f,  1.0f,
 	 1.0f,  1.0f
 };
 
-const GLushort element_data[] = {0, 1, 2, 3};
+static const GLushort element_data[] = {0, 1, 2, 3};
 
-GLuint load_shader(char * fname, GLenum shader_type)
+static GLuint load_shader(char * fname, GLenum shader_type)
 {
 	char const * parts[] = {get_home_dir(), "/.config/blastem/shaders/", fname};
 	char * shader_path = alloc_concat_m(3, parts);
@@ -171,8 +169,8 @@
 }
 #endif
 
-uint32_t texture_buf[512 * 256];
-void render_alloc_surfaces()
+static uint32_t texture_buf[512 * 256];
+static void render_alloc_surfaces()
 {
 	static uint8_t texture_init;
 
@@ -233,8 +231,8 @@
 #endif
 }
 
-char * caption = NULL;
-char * fps_caption = NULL;
+static char * caption = NULL;
+static char * fps_caption = NULL;
 
 static void render_quit()
 {
@@ -568,21 +566,7 @@
 	}
 }
 
-void render_debug_mode(uint8_t mode)
-{
-	if (mode < 4) {
-		render_dbg = mode;
-	}
-}
-
-void render_debug_pal(uint8_t pal)
-{
-	if (pal < 4) {
-		debug_pal = pal;
-	}
-}
-
-int find_joystick_index(SDL_JoystickID instanceID)
+static int find_joystick_index(SDL_JoystickID instanceID)
 {
 	for (int i = 0; i < MAX_JOYSTICKS; i++) {
 		if (joysticks[i] && SDL_JoystickInstanceID(joysticks[i]) == instanceID) {
@@ -592,7 +576,7 @@
 	return -1;
 }
 
-int lowest_unused_joystick_index()
+static int lowest_unused_joystick_index()
 {
 	for (int i = 0; i < MAX_JOYSTICKS; i++) {
 		if (!joysticks[i]) {
@@ -602,7 +586,7 @@
 	return -1;
 }
 
-uint8_t scancode_map[SDL_NUM_SCANCODES] = {
+static uint8_t scancode_map[SDL_NUM_SCANCODES] = {
 	[SDL_SCANCODE_A] = 0x1C,
 	[SDL_SCANCODE_B] = 0x32,
 	[SDL_SCANCODE_C] = 0x21,
@@ -706,7 +690,7 @@
 	[SDL_SCANCODE_KP_PERIOD] = 0x71,
 };
 
-int32_t handle_event(SDL_Event *event)
+static int32_t handle_event(SDL_Event *event)
 {
 	switch (event->type) {
 	case SDL_KEYDOWN:
@@ -805,11 +789,6 @@
 	context->buffer_pos = 0;
 }
 
-void render_fps(uint32_t fps)
-{
-	frame_delay = 1000/fps;
-}
-
 uint32_t render_audio_buffer()
 {
 	return buffer_samples;
--- a/vdp.c	Tue Nov 15 08:18:57 2016 -0800
+++ b/vdp.c	Mon Nov 28 22:45:46 2016 -0800
@@ -39,9 +39,9 @@
 #define FIFO_LATENCY    3
 
 int32_t color_map[1 << 12];
-uint8_t levels[] = {0, 27, 49, 71, 87, 103, 119, 130, 146, 157, 174, 190, 206, 228, 255};
+static uint8_t levels[] = {0, 27, 49, 71, 87, 103, 119, 130, 146, 157, 174, 190, 206, 228, 255};
 
-uint8_t debug_base[][3] = {
+static uint8_t debug_base[][3] = {
 	{127, 127, 127}, //BG
 	{0, 0, 127},     //A
 	{127, 0, 0},     //Window
@@ -49,7 +49,7 @@
 	{127, 0, 127}    //Sprites
 };
 
-uint8_t color_map_init_done;
+static uint8_t color_map_init_done;
 
 void init_vdp_context(vdp_context * context, uint8_t region_pal)
 {
@@ -146,7 +146,7 @@
 	free(context);
 }
 
-int is_refresh(vdp_context * context, uint32_t slot)
+static int is_refresh(vdp_context * context, uint32_t slot)
 {
 	if (context->regs[REG_MODE_4] & BIT_H40) {
 		return slot == 250 || slot == 26 || slot == 59 || slot == 90 || slot == 122 || slot == 154;
@@ -159,7 +159,7 @@
 	}
 }
 
-void render_sprite_cells(vdp_context * context)
+static void render_sprite_cells(vdp_context * context)
 {
 	if (context->cur_slot >= context->sprite_draws) {
 		sprite_draw * d = context->sprite_draw_list + context->cur_slot;
@@ -251,7 +251,7 @@
 
 #define DMA_START 0x20
 
-const char * cd_name(uint8_t cd)
+static const char * cd_name(uint8_t cd)
 {
 	switch (cd & 0xF)
 	{
@@ -338,7 +338,7 @@
 	//TODO: Window Group, DMA Group
 }
 
-void scan_sprite_table(uint32_t line, vdp_context * context)
+static void scan_sprite_table(uint32_t line, vdp_context * context)
 {
 	if (context->sprite_index && context->slot_counter) {
 		line += 1;
@@ -406,7 +406,7 @@
 	}
 }
 
-void read_sprite_x(uint32_t line, vdp_context * context)
+static void read_sprite_x(uint32_t line, vdp_context * context)
 {
 	if (context->cur_slot >= context->slot_counter) {
 		if (context->sprite_draws) {
@@ -483,7 +483,7 @@
 	}
 }
 
-void write_cram(vdp_context * context, uint16_t address, uint16_t value)
+static void write_cram(vdp_context * context, uint16_t address, uint16_t value)
 {
 	uint16_t addr = (address/2) & (CRAM_SIZE-1);
 	context->cram[addr] = value;
@@ -496,7 +496,7 @@
 #define VSRAM_BITS 0x7FF
 #define VSRAM_DIRTY_BITS 0xF800
 
-void vdp_advance_dma(vdp_context * context)
+static void vdp_advance_dma(vdp_context * context)
 {
 	context->regs[REG_DMASRC_L] += 1;
 	if (!context->regs[REG_DMASRC_L]) {
@@ -525,7 +525,7 @@
 	context->vdpmem[address] = value;
 }
 
-void external_slot(vdp_context * context)
+static void external_slot(vdp_context * context)
 {
 	if ((context->flags & FLAG_DMA_RUN) && (context->regs[REG_DMASRC_H] & 0xC0) == 0x80 && context->fifo_read < 0) {
 		context->fifo_read = (context->fifo_write-1) & (FIFO_SIZE-1);
@@ -629,7 +629,7 @@
 	}
 }
 
-void run_dma_src(vdp_context * context, int32_t slot)
+static void run_dma_src(vdp_context * context, int32_t slot)
 {
 	//TODO: Figure out what happens if CD bit 4 is not set in DMA copy mode
 	//TODO: Figure out what happens when CD:0-3 is not set to a write mode in DMA operations
@@ -659,7 +659,7 @@
 #define WINDOW_RIGHT 0x80
 #define WINDOW_DOWN  0x80
 
-void read_map_scroll(uint16_t column, uint16_t vsram_off, uint32_t line, uint16_t address, uint16_t hscroll_val, vdp_context * context)
+static void read_map_scroll(uint16_t column, uint16_t vsram_off, uint32_t line, uint16_t address, uint16_t hscroll_val, vdp_context * context)
 {
 	uint16_t window_line_shift, v_offset_mask, vscroll_shift;
 	if (context->double_res) {
@@ -804,17 +804,17 @@
 	}
 }
 
-void read_map_scroll_a(uint16_t column, uint32_t line, vdp_context * context)
+static void read_map_scroll_a(uint16_t column, uint32_t line, vdp_context * context)
 {
 	read_map_scroll(column, 0, line, (context->regs[REG_SCROLL_A] & 0x38) << 10, context->hscroll_a, context);
 }
 
-void read_map_scroll_b(uint16_t column, uint32_t line, vdp_context * context)
+static void read_map_scroll_b(uint16_t column, uint32_t line, vdp_context * context)
 {
 	read_map_scroll(column, 1, line, (context->regs[REG_SCROLL_B] & 0x7) << 13, context->hscroll_b, context);
 }
 
-void render_map(uint16_t col, uint8_t * tmp_buf, uint8_t offset, vdp_context * context)
+static void render_map(uint16_t col, uint8_t * tmp_buf, uint8_t offset, vdp_context * context)
 {
 	uint16_t address;
 	uint16_t vflip_base;
@@ -850,22 +850,22 @@
 	}
 }
 
-void render_map_1(vdp_context * context)
+static void render_map_1(vdp_context * context)
 {
 	render_map(context->col_1, context->tmp_buf_a, context->buf_a_off, context);
 }
 
-void render_map_2(vdp_context * context)
+static void render_map_2(vdp_context * context)
 {
 	render_map(context->col_2, context->tmp_buf_a, context->buf_a_off+8, context);
 }
 
-void render_map_3(vdp_context * context)
+static void render_map_3(vdp_context * context)
 {
 	render_map(context->col_1, context->tmp_buf_b, context->buf_b_off, context);
 }
 
-void render_map_output(uint32_t line, int32_t col, vdp_context * context)
+static void render_map_output(uint32_t line, int32_t col, vdp_context * context)
 {
 	if (line >= 240) {
 		return;
@@ -1015,9 +1015,9 @@
 	context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK;
 }
 
-uint32_t const h40_hsync_cycles[] = {19, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 19};
+static uint32_t const h40_hsync_cycles[] = {19, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 18, 20, 20, 20, 19};
 
-void vdp_advance_line(vdp_context *context)
+static void vdp_advance_line(vdp_context *context)
 {
 	context->vcounter++;
 	context->vcounter &= 0x1FF;
@@ -1151,7 +1151,7 @@
 		CHECK_ONLY
 
 
-void vdp_h40(vdp_context * context, uint32_t target_cycles)
+static void vdp_h40(vdp_context * context, uint32_t target_cycles)
 {
 	uint16_t address;
 	uint32_t mask;
@@ -1311,7 +1311,7 @@
 	}
 }
 
-void vdp_h32(vdp_context * context, uint32_t target_cycles)
+static void vdp_h32(vdp_context * context, uint32_t target_cycles)
 {
 	uint16_t address;
 	uint32_t mask;
@@ -1462,7 +1462,7 @@
 	context->latched_mode = context->regs[REG_MODE_2] & BIT_PAL;
 }
 
-void check_render_bg(vdp_context * context, int32_t line, uint32_t slot)
+static void check_render_bg(vdp_context * context, int32_t line, uint32_t slot)
 {
 	int starti = -1;
 	if (context->regs[REG_MODE_4] & BIT_H40) {
@@ -1830,7 +1830,7 @@
 	}
 }
 
-uint32_t vdp_cycles_hslot_wrap_h40(vdp_context * context)
+static uint32_t vdp_cycles_hslot_wrap_h40(vdp_context * context)
 {
 	if (context->hslot < 183) {
 		return MCLKS_LINE - context->hslot * MCLKS_SLOT_H40;
@@ -1848,7 +1848,7 @@
 	}
 }
 
-uint32_t vdp_cycles_next_line(vdp_context * context)
+static uint32_t vdp_cycles_next_line(vdp_context * context)
 {
 	if (context->regs[REG_MODE_4] & BIT_H40) {
 		if (context->hslot < LINE_CHANGE_H40) {
@@ -1867,7 +1867,7 @@
 	}
 }
 
-uint32_t vdp_cycles_to_line(vdp_context * context, uint32_t target)
+static uint32_t vdp_cycles_to_line(vdp_context * context, uint32_t target)
 {
 	uint32_t jump_start, jump_dst;
 	if (context->flags2 & FLAG2_REGION_PAL) {
@@ -1909,7 +1909,7 @@
 	return MCLKS_LINE * (lines - 1) + vdp_cycles_next_line(context);
 }
 
-uint32_t vdp_frame_end_line(vdp_context * context)
+static uint32_t vdp_frame_end_line(vdp_context * context)
 {
 	uint32_t frame_end;
 	if (context->flags2 & FLAG2_REGION_PAL) {
--- a/vdp.h	Tue Nov 15 08:18:57 2016 -0800
+++ b/vdp.h	Mon Nov 28 22:45:46 2016 -0800
@@ -204,7 +204,6 @@
 void vdp_print_reg_explain(vdp_context * context);
 void latch_mode(vdp_context * context);
 uint32_t vdp_cycles_to_frame_end(vdp_context * context);
-uint32_t vdp_frame_end_line(vdp_context *context);
 void write_vram_byte(vdp_context *context, uint16_t address, uint8_t value);
 
 extern int32_t color_map[1 << 12];
--- a/ym2612.c	Tue Nov 15 08:18:57 2016 -0800
+++ b/ym2612.c	Mon Nov 28 22:45:46 2016 -0800
@@ -39,7 +39,7 @@
 #define BIT_STATUS_TIMERA 0x1
 #define BIT_STATUS_TIMERB 0x2
 
-uint32_t ym_calc_phase_inc(ym2612_context * context, ym_operator * operator, uint32_t op);
+static uint32_t ym_calc_phase_inc(ym2612_context * context, ym_operator * operator, uint32_t op);
 
 enum {
 	PHASE_ATTACK,
@@ -53,14 +53,14 @@
 //memory is cheap so using a half sine table will probably save some cycles
 //a full sine table would be nice, but negative numbers don't get along with log2
 #define SINE_TABLE_SIZE 512
-uint16_t sine_table[SINE_TABLE_SIZE];
+static uint16_t sine_table[SINE_TABLE_SIZE];
 //Similar deal here with the power table for log -> linear conversion
 //According to Nemesis, real hardware only uses a 256 entry table for the fractional part
 //and uses the whole part as a shift amount.
 #define POW_TABLE_SIZE (1 << 13)
-uint16_t pow_table[POW_TABLE_SIZE];
+static uint16_t pow_table[POW_TABLE_SIZE];
 
-uint16_t rate_table_base[] = {
+static uint16_t rate_table_base[] = {
 	//main portion
 	0,1,0,1,0,1,0,1,
 	0,1,0,1,1,1,0,1,
@@ -73,10 +73,10 @@
 	1,2,2,2,1,2,2,2,
 };
 
-uint16_t rate_table[64*8];
+static uint16_t rate_table[64*8];
 
-uint8_t lfo_timer_values[] = {108, 77, 71, 67, 62, 44, 8, 5};
-uint8_t lfo_pm_base[][8] = {
+static uint8_t lfo_timer_values[] = {108, 77, 71, 67, 62, 44, 8, 5};
+static uint8_t lfo_pm_base[][8] = {
 	{0,   0,   0,   0,   0,   0,   0,   0},
 	{0,   0,   0,   0,   4,   4,   4,   4},
 	{0,   0,   0,   4,   4,   4,   8,   8},
@@ -86,7 +86,7 @@
 	{0,   0,0x10,0x18,0x20,0x20,0x28,0x30},
 	{0,   0,0x20,0x30,0x40,0x40,0x50,0x60}
 };
-int16_t lfo_pm_table[128 * 32 * 8];
+static int16_t lfo_pm_table[128 * 32 * 8];
 
 int16_t ams_shift[] = {8, 1, -1, -2};
 
@@ -94,17 +94,17 @@
 #define YM_DIVIDER 2
 #define CYCLE_NEVER 0xFFFFFFFF
 
-uint16_t round_fixed_point(double value, int dec_bits)
+static uint16_t round_fixed_point(double value, int dec_bits)
 {
 	return value * (1 << dec_bits) + 0.5;
 }
 
-FILE * debug_file = NULL;
-uint32_t first_key_on=0;
+static FILE * debug_file = NULL;
+static uint32_t first_key_on=0;
 
-ym2612_context * log_context = NULL;
+static ym2612_context * log_context = NULL;
 
-void ym_finalize_log()
+static void ym_finalize_log()
 {
 	if (!log_context) {
 		return;
@@ -564,7 +564,7 @@
 	context->status |= 0x80;
 }
 
-uint8_t fnum_to_keycode[] = {
+static uint8_t fnum_to_keycode[] = {
 	//F11 = 0
 	0,0,0,0,0,0,0,1,
 	//F11 = 1
@@ -572,7 +572,7 @@
 };
 
 //table courtesy of Nemesis
-uint32_t detune_table[][4] = {
+static uint32_t detune_table[][4] = {
 	{0, 0, 1, 2},   //0  (0x00)
     {0, 0, 1, 2},   //1  (0x01)
     {0, 0, 1, 2},   //2  (0x02)
@@ -607,7 +607,7 @@
     {0, 8,16,22}
 };  //31 (0x1F)
 
-uint32_t ym_calc_phase_inc(ym2612_context * context, ym_operator * operator, uint32_t op)
+static uint32_t ym_calc_phase_inc(ym2612_context * context, ym_operator * operator, uint32_t op)
 {
 	uint32_t chan_num = op / 4;
 	//printf("ym_update_phase_inc | channel: %d, op: %d\n", chan_num, op);