Skip to content

Commit

Permalink
Cumulative optimizations (#336)
Browse files Browse the repository at this point in the history
* Removing branches and needless loops from ps2, joystick, video_step, vera_spi_step.
* byte -> value: Variable name change: Windows SDK conflict.
* Documentation updates
  • Loading branch information
indigodarkwolf authored and mist64 committed Apr 4, 2021
1 parent 706d916 commit abfe032
Show file tree
Hide file tree
Showing 17 changed files with 459 additions and 408 deletions.
Empty file modified .clang-format
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ Since the emulator tells the computer the *position* of keys that are pressed, y

The following keys can be used for controlling games:

|Keyboard Key | NES Equivalent |
|Keyboard Key | SNES Equivalent |
|--------------|----------------|
|Ctrl | A |
|Alt | B |
|Ctrl | B |
|Alt | Y |
|Space | SELECT |
|Enter | START |
|Cursor Up | UP |
Expand Down
20 changes: 10 additions & 10 deletions i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ i2c_port_t i2c_port;

static int state = STATE_STOP;
static bool read_mode = false;
static uint8_t byte = 0;
static uint8_t value = 0;
static int count = 0;
static uint8_t device;
static uint8_t offset;
Expand Down Expand Up @@ -86,10 +86,10 @@ i2c_step()
if (state < 8) {
if (read_mode) {
if (state == 0) {
byte = i2c_read(device, offset);
value = i2c_read(device, offset);
}
i2c_port.data_out = !!(byte & 0x80);
byte <<= 1;
i2c_port.data_out = !!(value & 0x80);
value <<= 1;
#if LOG_LEVEL >= 4
printf("I2C OUT#%d: %d\n", state, i2c_port.data_out);
#endif
Expand All @@ -98,8 +98,8 @@ i2c_step()
#if LOG_LEVEL >= 4
printf("I2C BIT#%d: %d\n", state, i2c_port.data_in);
#endif
byte <<= 1;
byte |= i2c_port.data_in;
value <<= 1;
value |= i2c_port.data_in;
state++;
}
} else { // state == 8
Expand All @@ -121,17 +121,17 @@ i2c_step()
bool ack = true;
switch (count) {
case 0:
device = byte >> 1;
read_mode = byte & 1;
device = value >> 1;
read_mode = value & 1;
if (device != DEVICE_SMC && device != DEVICE_RTC) {
ack = false;
}
break;
case 1:
offset = byte;
offset = value;
break;
default:
i2c_write(device, offset, byte);
i2c_write(device, offset, value);
offset++;
break;
}
Expand Down
Loading

0 comments on commit abfe032

Please sign in to comment.