X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fcommon%2Ftimers.c;h=89eb42db1d8e912b18538837eed46068d677dec3;hb=00deadc94f868a45431b58e34e707d235cf02b47;hp=53c2fb19533d97ceeb0ca20f095c6d45e9bfdb62;hpb=8bfc53036ae2e040287a92c8a9e8f84571a19080;p=emu8051.git diff --git a/src/common/timers.c b/src/common/timers.c index 53c2fb1..89eb42d 100644 --- a/src/common/timers.c +++ b/src/common/timers.c @@ -54,16 +54,16 @@ timer_increment_check_overflow(uint8_t counter_address, uint8_t tf_mask) { unsigned int tmp; - tmp = memory_read_direct(counter_address); + tmp = mem_read_direct(counter_address); tmp++; tmp &= 0xFF; if (tmp == 0) { /* If overflow set TFx */ - memory_write_direct(_TCON_, - memory_read_direct(_TCON_) | tf_mask); + mem_write_direct(_TCON_, + mem_read_direct(_TCON_) | tf_mask); } - memory_write_direct(counter_address, tmp); /* Save new value. */ + mem_write_direct(counter_address, tmp); /* Save new value. */ } static void @@ -72,11 +72,11 @@ timer_with_prescaler(uint8_t tl, uint8_t th, uint8_t tf_mask, { unsigned int prescaler; - prescaler = memory_read_direct(tl); + prescaler = mem_read_direct(tl); prescaler++; prescaler &= (1 << prescaler_width) - 1; /* Keep only required bits */ - memory_write_direct(tl, prescaler); + mem_write_direct(tl, prescaler); if (prescaler == 0) timer_increment_check_overflow(th, tf_mask); @@ -99,17 +99,17 @@ process_timer(uint8_t tl, uint8_t th, uint8_t tf_mask, uint8_t TR, uint8_t mode, break; case 2: /* Mode 2, 8-bits counter with Auto-Reload */ - tmp = memory_read_direct(tl); + tmp = mem_read_direct(tl); tmp++; tmp &= 0xFF; if (tmp == 0) { /* If overflow -> reload and set TF0 */ - memory_write_direct( + mem_write_direct( _TCON_, - memory_read_direct(_TCON_) | tf_mask); - memory_write_direct(tl, memory_read_direct(th)); + mem_read_direct(_TCON_) | tf_mask); + mem_write_direct(tl, mem_read_direct(th)); } else { - memory_write_direct(tl, tmp); + mem_write_direct(tl, tmp); } break; case 3: @@ -126,7 +126,7 @@ process_timer(uint8_t tl, uint8_t th, uint8_t tf_mask, uint8_t TR, uint8_t mode, timer_increment_check_overflow(tl, tf_mask); /* TH0 uses TR1 et TF1. */ - TR = memory_read_direct(_TCON_) & 0x40; + TR = mem_read_direct(_TCON_) & 0x40; if (TR) timer_increment_check_overflow(th, 0x80); @@ -145,20 +145,20 @@ timers_check(void) unsigned int timer_counter; /* Timer 0 */ - tr = memory_read_direct(_TCON_) & 0x10; - mode = memory_read_direct(_TMOD_) & 0x03; - gate = memory_read_direct(_TMOD_) & 0x08; - timer_counter = memory_read_direct(_TMOD_) & 0x04; + tr = mem_read_direct(_TCON_) & 0x10; + mode = mem_read_direct(_TMOD_) & 0x03; + gate = mem_read_direct(_TMOD_) & 0x08; + timer_counter = mem_read_direct(_TMOD_) & 0x04; if ((tr && !gate && !timer_counter) || (mode == 3)) process_timer(_TL0_, _TH0_, 0x20, tr, mode, gate, timer_counter); /* Timer 1 */ - tr = memory_read_direct(_TCON_) & 0x40; - mode = (memory_read_direct(_TMOD_) & 0x30) >> 4; - gate = memory_read_direct(_TMOD_) & 0x80; - timer_counter = memory_read_direct(_TMOD_) & 0x40; + tr = mem_read_direct(_TCON_) & 0x40; + mode = (mem_read_direct(_TMOD_) & 0x30) >> 4; + gate = mem_read_direct(_TMOD_) & 0x80; + timer_counter = mem_read_direct(_TMOD_) & 0x40; if (tr && !gate && !timer_counter) process_timer(_TL1_, _TH1_, 0x80, tr, mode, gate,