From 670df571eab9616e9ccc65dfb0d397fd04b65c82 Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Fri, 2 Jul 2010 23:03:05 +0000 Subject: [PATCH] code cleanup --- source/cart_hw/cart_hw.c | 2 +- source/cart_hw/eeprom.c | 16 ++++++++-------- source/cart_hw/eeprom.h | 4 ++-- source/gen_input.c | 4 ++-- source/genesis.c | 2 +- source/gx/gx_video.c | 4 ++-- source/m68k/m68kcpu.c | 2 +- source/mem68k.c | 4 ++-- source/render.c | 19 +++++++++---------- source/sound/ym2612.c | 4 ++-- source/vdp.c | 16 +++++++--------- source/vdp.h | 2 +- source/z80/z80.c | 6 +++--- source/z80/z80.h | 6 +++--- 14 files changed, 44 insertions(+), 47 deletions(-) diff --git a/source/cart_hw/cart_hw.c b/source/cart_hw/cart_hw.c index 792f6a2..263d25f 100644 --- a/source/cart_hw/cart_hw.c +++ b/source/cart_hw/cart_hw.c @@ -171,7 +171,7 @@ void cart_hw_init() ******************************************************************************************************************/ /* calculate nearest size with factor of 2 */ - int size = 0x10000; + unsigned int size = 0x10000; while (cart.romsize > size) size <<= 1; diff --git a/source/cart_hw/eeprom.c b/source/cart_hw/eeprom.c index 180450b..58b5bc0 100644 --- a/source/cart_hw/eeprom.c +++ b/source/cart_hw/eeprom.c @@ -152,26 +152,26 @@ static inline void Detect_STOP() } } -void eeprom_write(uint32 address, uint32 value, uint32 word_access) +void eeprom_write(unsigned int address, unsigned int data, int word_access) { /* decode SCL and SDA value */ if (word_access) { /* 16-bits access */ - if (eeprom.type.sda_in_adr == address) eeprom.sda = (value >> (8 + eeprom.type.sda_in_bit)) & 1; /* MSB */ - else if (eeprom.type.sda_in_adr == (address | 1)) eeprom.sda = (value >> eeprom.type.sda_in_bit) & 1; /* LSB */ + if (eeprom.type.sda_in_adr == address) eeprom.sda = (data >> (8 + eeprom.type.sda_in_bit)) & 1; /* MSB */ + else if (eeprom.type.sda_in_adr == (address | 1)) eeprom.sda = (data >> eeprom.type.sda_in_bit) & 1; /* LSB */ else eeprom.sda = eeprom.old_sda; - if (eeprom.type.scl_adr == address) eeprom.scl = (value >> (8 + eeprom.type.scl_bit)) & 1; /* MSB */ - else if (eeprom.type.scl_adr == (address | 1)) eeprom.scl = (value >> eeprom.type.scl_bit) & 1; /* LSB */ + if (eeprom.type.scl_adr == address) eeprom.scl = (data >> (8 + eeprom.type.scl_bit)) & 1; /* MSB */ + else if (eeprom.type.scl_adr == (address | 1)) eeprom.scl = (data >> eeprom.type.scl_bit) & 1; /* LSB */ else eeprom.scl = eeprom.old_scl; } else { - if (eeprom.type.sda_in_adr == address) eeprom.sda = (value >> eeprom.type.sda_in_bit) & 1; + if (eeprom.type.sda_in_adr == address) eeprom.sda = (data >> eeprom.type.sda_in_bit) & 1; else eeprom.sda = eeprom.old_sda; - if (eeprom.type.scl_adr == address) eeprom.scl = (value >> eeprom.type.scl_bit) & 1; + if (eeprom.type.scl_adr == address) eeprom.scl = (data >> eeprom.type.scl_bit) & 1; else eeprom.scl = eeprom.old_scl; } @@ -416,7 +416,7 @@ void eeprom_write(uint32 address, uint32 value, uint32 word_access) eeprom.old_sda = eeprom.sda; } -uint32 eeprom_read(uint32 address, uint32 word_access) +unsigned int eeprom_read(int word_access) { uint8 sda_out = eeprom.sda; diff --git a/source/cart_hw/eeprom.h b/source/cart_hw/eeprom.h index cd47b4f..bc20290 100644 --- a/source/cart_hw/eeprom.h +++ b/source/cart_hw/eeprom.h @@ -86,7 +86,7 @@ extern T_EEPROM eeprom; /* Function prototypes */ extern void eeprom_init(); -extern void eeprom_write(uint32 address, uint32 value, uint32 word_access); -extern uint32 eeprom_read(uint32 address, uint32 word_access); +extern void eeprom_write(unsigned int address, unsigned int data, int word_access); +extern unsigned int eeprom_read(int word_access); #endif diff --git a/source/gen_input.c b/source/gen_input.c index 25df048..7796277 100644 --- a/source/gen_input.c +++ b/source/gen_input.c @@ -77,13 +77,13 @@ static const uint8 hc_256[171] = static int x_offset; static int y_offset; -static inline void lightgun_reset(int num) +static void lightgun_reset(int num) { input.analog[num][0] = bitmap.viewport.w >> 1; input.analog[num][1] = bitmap.viewport.h >> 1; } -static inline void lightgun_update(int num) +static void lightgun_update(int num) { if ((input.analog[num][1] == v_counter + y_offset)) { diff --git a/source/genesis.c b/source/genesis.c index cb83e59..8fd6e9a 100644 --- a/source/genesis.c +++ b/source/genesis.c @@ -45,7 +45,7 @@ void gen_init(void) /* initialize CPUs */ m68k_set_cpu_type(M68K_CPU_TYPE_68000); m68k_init(); - z80_init(0,0,0,z80_irq_callback); + z80_init(0,z80_irq_callback); /* initialize 68k mapped memory */ /* $000000-$7fffff is affected to cartridge area (see cart_hw.c) */ diff --git a/source/gx/gx_video.c b/source/gx/gx_video.c index 0fcf0c3..0e30577 100644 --- a/source/gx/gx_video.c +++ b/source/gx/gx_video.c @@ -499,7 +499,7 @@ static void gxSetAspectRatio(int *xscale, int *yscale) } /* Reset GX/VI hardware scaler */ -static void gxResetScaler(u32 width, u32 height) +static void gxResetScaler(u32 width) { int xscale = 0; int yscale = 0; @@ -1419,7 +1419,7 @@ void gx_video_Update(void) rmode = tvmodes[gc_pal*3 + interlaced]; /* update aspect ratio */ - gxResetScaler(vwidth,vheight); + gxResetScaler(vwidth); /* update GX rendering mode */ gxResetMode(rmode); diff --git a/source/m68k/m68kcpu.c b/source/m68k/m68kcpu.c index 0a9f411..15e41eb 100644 --- a/source/m68k/m68kcpu.c +++ b/source/m68k/m68kcpu.c @@ -72,7 +72,7 @@ const char *const m68ki_cpu_names[] = #endif /* M68K_LOG_ENABLE */ /* The CPU core */ -m68ki_cpu_core m68ki_cpu = {0}; +m68ki_cpu_core m68ki_cpu; #if M68K_EMULATE_ADDRESS_ERROR #include diff --git a/source/mem68k.c b/source/mem68k.c index 79b327e..fa3dab9 100644 --- a/source/mem68k.c +++ b/source/mem68k.c @@ -117,7 +117,7 @@ unsigned int eeprom_read_byte(unsigned int address) { if (address == eeprom.type.sda_out_adr) { - return eeprom_read(address, 0); + return eeprom_read(0); } return READ_BYTE(cart.rom, address); } @@ -126,7 +126,7 @@ unsigned int eeprom_read_word(unsigned int address) { if (address == (eeprom.type.sda_out_adr & 0xfffffe)) { - return eeprom_read(address, 1); + return eeprom_read(1); } return *(uint16 *)(cart.rom + address); } diff --git a/source/render.c b/source/render.c index 0fb449c..e8d7bfb 100644 --- a/source/render.c +++ b/source/render.c @@ -907,7 +907,7 @@ static void update_bg_pattern_cache(int index) } } -static uint32 get_hscroll(int line) +static inline uint32 get_hscroll(int line) { switch(reg[11] & 3) { @@ -1544,7 +1544,7 @@ static void render_obj(uint8 *buf, uint8 *table) spr_over = 0; } -static void render_obj_im2(int odd, uint8 *buf, uint8 *table) +static void render_obj_im2(uint8 *buf, uint8 *table, int odd) { uint8 sizetab[] = {8, 16, 24, 32}; @@ -1756,13 +1756,13 @@ void render_line(int line) /* Shadow & Highlight */ merge(&nta_buf[0x20], &ntb_buf[0x20], &bg_buf[0x20], lut[2], width); memset(&obj_buf[0x20], 0, width); - render_obj_im2(odd, obj_buf, lut[3]); + render_obj_im2(obj_buf, lut[3], odd); merge(&obj_buf[0x20], &bg_buf[0x20], &lb[0x20], lut[4], width); } else { merge(&nta_buf[0x20], &ntb_buf[0x20], &lb[0x20], lut[0], width); - render_obj_im2(odd, lb, lut[1]); + render_obj_im2(lb, lut[1], odd); } } else @@ -1904,17 +1904,16 @@ void window_clip(void) void parse_satb(int line) { uint8 sizetab[] = {8, 16, 24, 32}; - uint32 link = 0; - uint32 size, height; - int ypos; - + uint32 size, link = 0; + int ypos, height; + + uint32 count = 0; uint32 limit = (reg[12] & 1) ? 20 : 16; uint32 total = limit << 2; - + uint16 *p = (uint16 *) &vram[satb]; uint16 *q = (uint16 *) &sat[0]; - uint32 count = 0; object *obj_info = object_info[object_which^1]; do diff --git a/source/sound/ym2612.c b/source/sound/ym2612.c index 355e468..55b1c6f 100644 --- a/source/sound/ym2612.c +++ b/source/sound/ym2612.c @@ -955,7 +955,7 @@ INLINE void set_det_mul(FM_CH *CH,FM_SLOT *SLOT,int v) } /* set total level */ -INLINE void set_tl(FM_CH *CH,FM_SLOT *SLOT , int v) +INLINE void set_tl(FM_SLOT *SLOT , int v) { SLOT->tl = (v&0x7f)<<(ENV_BITS-7); /* 7bit TL */ @@ -1564,7 +1564,7 @@ INLINE void OPNWriteReg(int r, int v) break; case 0x40: /* TL */ - set_tl(CH,SLOT,v); + set_tl(SLOT,v); break; case 0x50: /* KS, AR */ diff --git a/source/vdp.c b/source/vdp.c index 8543a92..baff930 100644 --- a/source/vdp.c +++ b/source/vdp.c @@ -280,7 +280,7 @@ void vdp_update_dma() if (left_cycles < 0) left_cycles = 0; /* DMA bytes left */ - int dma_bytes = (left_cycles * rate) / MCYCLES_PER_LINE; + unsigned int dma_bytes = (left_cycles * rate) / MCYCLES_PER_LINE; #ifdef LOGVDP error("[%d(%d)][%d(%d)] DMA type %d (%d access/line)-> %d access (%d remaining) (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE,dma_type/4, rate, dma_length, dma_bytes, m68k_get_reg (NULL, M68K_REG_PC)); @@ -449,8 +449,7 @@ unsigned int vdp_ctrl_r(unsigned int cycles) unsigned int vdp_hvc_r(unsigned int cycles) { /* HVC is frozen (Lightgun games, Sunset Riders) */ - if (hvc_latch) - return (hvc_latch & 0xffff); + if (hvc_latch) return (hvc_latch & 0xffff); /* Horizontal Counter (Striker, Mickey Mania, Skitchin, Road Rash I,II,III, Sonic 3D Blast...) */ uint8 hc = hctab[cycles%MCYCLES_PER_LINE]; @@ -468,10 +467,10 @@ unsigned int vdp_hvc_r(unsigned int cycles) return ((vc << 8) | hc); } -void vdp_test_w(unsigned int value) +void vdp_test_w(unsigned int data) { #ifdef LOGERROR - error("Unused VDP Write 0x%x (%08x)\n", value, m68k_get_reg (NULL, M68K_REG_PC)); + error("Unused VDP Write 0x%x (%08x)\n", data, m68k_get_reg (NULL, M68K_REG_PC)); #endif } @@ -917,15 +916,14 @@ static void reg_w(unsigned int r, unsigned int d) /* background color modified during Horizontal Blanking (Road Rash 1,2,3)*/ if (!(status & 8) && (mcycles_68k <= (mcycles_vdp + 860))) { - /* remap colors */ + /* remap entire line */ remap_buffer(v_counter); #ifdef LOGVDP - error("--> Line remapped\n"); + error("Line remapped\n"); #endif } #ifdef LOGVDP - else - error("--> Line NOT remapped\n"); + else error("Line NOT remapped\n"); #endif } break; diff --git a/source/vdp.h b/source/vdp.h index bc980ed..695c820 100644 --- a/source/vdp.h +++ b/source/vdp.h @@ -84,7 +84,7 @@ extern unsigned int vdp_ctrl_r(unsigned int cycles); extern void vdp_data_w(unsigned int data); extern unsigned int vdp_data_r(void); extern unsigned int vdp_hvc_r(unsigned int cycles); -extern void vdp_test_w(unsigned int value); +extern void vdp_test_w(unsigned int data); extern int vdp_int_ack_callback(int int_level); #endif /* _VDP_H_ */ diff --git a/source/z80/z80.c b/source/z80/z80.c index 9f99966..27f366a 100644 --- a/source/z80/z80.c +++ b/source/z80/z80.c @@ -3270,7 +3270,7 @@ static void take_interrupt(void) /**************************************************************************** * Processor initialization ****************************************************************************/ -void z80_init(int index, int clock, const void *config, int (*irqcallback)(int)) +void z80_init(const void *config, int (*irqcallback)(int)) { int i, p; @@ -3407,7 +3407,7 @@ void z80_exit(void) /**************************************************************************** * Run until given cycle count ****************************************************************************/ -void z80_run(int cycles) +void z80_run(unsigned int cycles) { /* check for NMIs on the way in; they can only be set externally */ /* via timers, and can't be dynamically enabled, so it is safe */ @@ -3443,7 +3443,7 @@ void z80_run(int cycles) /**************************************************************************** * Burn 'cycles' T-states. Adjust R register for the lost time ****************************************************************************/ -void z80_burn(int cycles) +void z80_burn(unsigned int cycles) { if( cycles > 0 ) { diff --git a/source/z80/z80.h b/source/z80/z80.h index 6f73123..b373088 100644 --- a/source/z80/z80.h +++ b/source/z80/z80.h @@ -43,11 +43,11 @@ typedef struct extern Z80_Regs Z80; -void z80_init(int index, int clock, const void *config, int (*irqcallback)(int)); +void z80_init(const void *config, int (*irqcallback)(int)); void z80_reset (void); void z80_exit (void); -void z80_run(int cycles); -void z80_burn(int cycles); +void z80_run(unsigned int cycles); +void z80_burn(unsigned int cycles); void z80_get_context (void *dst); void z80_set_context (void *src); void z80_set_irq_line(int irqline, int state);