Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
--- SNES_APU_SD.orig/SNES_APU_SD/APU.cpp 2017-04-09 21:46:31.648099700 +0900
+++ SNES_APU_SD/SNES_APU_SD/APU.cpp 2017-04-09 21:46:31.648099700 +0900
@@ -16,10 +16,10 @@
void APU::init(uint8_t type)
{
#if not (defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__))
- PORTB = 0x0F;
- DDRB = 0x0F;
- DDRC &= 0xC0;
- PORTC &= 0xC0;
+ PORTB = 0x2C;
+ DDRB = 0x2C;
+ DDRC &= 0x01;
+ PORTC &= 0x01;
#else
mega_type = type;
@@ -126,16 +126,16 @@
{
unsigned char data;
- DDRB = 0x0F;
+ DDRB = 0x3C;
DDRD &= ~0xFC;
- PORTB &= ~0x03;
- PORTB |= (address & 0x03);
+ PORTB &= ~0x0C;
+ PORTB |= (address & 0x03) << 2;
- PORTB &= ~0x04;
+ PORTB &= ~0x20;
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
- data=((PINB&0x30)>>4) | (PIND&0xFC);
- PORTB |= 0x04;
+ data=((PINB&0x03) << 6) | ((PIND&0xFC) >> 2);
+ PORTB |= 0x20;
return data;
}
@@ -147,15 +147,15 @@
DDRD |= 0xFC;
PORTD &= ~0xFC;
- PORTD |= (data & 0xFC);
+ PORTD |= ((data << 2) & 0xFC);
- PORTB &= ~0x33;
- PORTB |= (address & 0x03);
- PORTB |= ((data & 0x03)<<4);
- PORTB &= ~0x08;
+ PORTB &= ~0x0F;
+ PORTB |= (address & 0x03) << 2;
+ PORTB |= ((data >> 6) & 0x03);
+ PORTB &= ~0x10;
__asm__ __volatile__ ("nop");
__asm__ __volatile__ ("nop");
- PORTB |= 0x08;
+ PORTB |= 0x10;
}
void APU::reset_arduino()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.