コード例 #1
0
        byte ReadLogPort(object sender, ushort address)
        {
            switch (address & 0xFF)
            {
            case 0x00:     // D-Bus
                return(3); //DBus.ReadLines();

            case 0x01:     // Keypad
                return(Keypad.Read());

            case 0x02:     // TODO: System status
                // Bit 1 is the LCD ready timer.
                return((byte)(1 | 2 | (Mapper.FlashWriteEnable ? 4 : 0) | 0xE0));

            case 0x03:                                                                                                                        // Interrupt mask
                // TODO: DBus interrupt enable
                return((byte)((Keypad.OnInterruptEnable ? 1 : 0) | (Apd.GenerateInterrupt ? 2 : 0) | (PApd.GenerateInterrupt ? 4 : 0) | 16)); // | (DBus.I));

            case 0x04:                                                                                                                        // Interrupt ID
                return((byte)((Keypad.OnKey ? 0 : 8) | ((byte)Interrupts & 0xFF) | (CrystalTimer1.HasExpired ? 0x20 : 0) | (CrystalTimer2.HasExpired ? 0x40 : 0) | (CrystalTimer3.HasExpired ? 0x80 : 0)));

            case 0x05:     // Memory page C
                return((byte)Mapper.PageC);

            case 0x06:     // Memory page A lower bits
                return((byte)((Mapper.PageA & 0x7F) | (Mapper.PageAIsRam ? 0x80 : 0)));

            case 0x07:     // Memory page B lower bits
                return((byte)((Mapper.PageB & 0x7F) | (Mapper.PageBIsRam ? 0x80 : 0)));

            case 0x08:     // TODO: UART enable
                return(0x80);

            case 0x09:     // TODO: UART status & signaling rate 0
                return(0);

            case 0x0A:     // TODO: UART read buffer
                return(0);

            case 0x0B:     // TODO
            case 0x0C:     // TODO
            case 0x0D:     // UART write buffer
                return(0);

            case 0x0E:     // Memory page A upper bits
                return((byte)(Mapper.PageA >> 7));

            case 0x0F:     // Memory page B upper bits
                return((byte)(Mapper.PageB >> 7));

            case 0x10:     // LCD command port
            case 0x12:
                return(Lcd.GetCurrentRegister());

            case 0x11:     // LCD data port
            case 0x13:
                return(Lcd.ReadData());

            case 0x14:     // Flash write enable
                return(0);

            case 0x15:     // Gate array ID
                return(0x45);

            case 0x16:     // Does nothing; this port's function has been moved.
                return(0);

            case 0x17:     // "Reserved for debug," whatever that means.
                return(0);

            case 0x18:     // TODO: MD5 ports
            case 0x19:     // See http://www.faqs.org/rfcs/rfc1321.html
            case 0x1A:
            case 0x1B:
            case 0x1C:
            case 0x1D:
            case 0x1E:
            case 0x1F:
                return(0);

            case 0x20:     // CPU speed
                return((byte)CpuSpeed);

            case 0x21:     // Flash & RAM size
                return((byte)((Mapper.FlashType) | (Mapper.RamType << 4)));

            case 0x22:     // Flash execution lower limit
                return((byte)(Mapper.FlashLowerLimit));

            case 0x23:     // Flash execution upper limit
                return((byte)Mapper.FlashUpperLimit);

            case 0x24:     // Flash execution limit hight bits
                return((byte)((Mapper.FlashLowerLimit >> 8) | ((Mapper.FlashUpperLimit >> 7) & 2)));

            case 0x25:     // RAM execution lower limit
                return((byte)(Mapper.RamLowerLimit));

            case 0x26:     // RAM execution upper limit
                return((byte)(Mapper.RamUpperLimit));

            case 0x27:     // Stack space always present
                return((byte)(Mapper.UpperPageAlwaysPresentAmount));

            case 0x28:     // System variables always present
                return((byte)(Mapper.LowerPageAlwaysPresentAmount));

            case 0x29:     // CPU mode 0 delays
            case 0x2A:
            case 0x2B:
            case 0x2C:
                return(0); // Whatever.

            case 0x2D:     // 32768 Hz crystal control
                return(3);

            case 0x2E:     // Memory access delay
                return(0);

            case 0x2F:
                return(0x4B);

            case 0x30:     // Crystal timer 1 frequency
                return(CrystalTimer1.GetMode());

            case 0x31:     // Crystal timer 1 loop control
                return(CrystalTimer1.GetLoopStatus());

            case 0x32:     // Crystal timer 1 count
                return(CrystalTimer1.GetCount());

            case 0x33:     // Crystal timer 2 frequency
                return(CrystalTimer2.GetMode());

            case 0x34:     // Crystal timer 2 loop control
                return(CrystalTimer2.GetLoopStatus());

            case 0x35:     // Crystal timer 2 count
                return(CrystalTimer2.GetCount());

            case 0x36:     // Crystal timer 3 frequency
                return(CrystalTimer3.GetMode());

            case 0x37:     // Crystal timer 3 loop control
                return(CrystalTimer3.GetLoopStatus());

            case 0x38:     // Crystal timer 3 count
                return(CrystalTimer3.GetCount());

            case 0x39:     // GPIO direction
                return(GpioDirection);

            case 0x3A:     // GPIO data
                return(GpioData);

            // Dummy USB implementation
            case 0x4A:
                return(0x24);

            case 0x4C:
                return(0x22);

            case 0x4D:
                return(0xA5);

            case 0x55:
                return(0x1F);

            case 0x56:
                return(0x50);

            case 0x57:
                return(0x50);

            case 0x5B:
                return(0);

            case 0x80:
                return(0);

            case 0x49:
            case 0x4B:
            case 0x4E:
            case 0x4F:
            case 0x50:
            case 0x51:
            case 0x52:
            case 0x53:
            case 0x54:
            case 0x58:
            case 0x59:
            case 0x5A:
            case 0x5C:
            case 0x5D:
            case 0x5E:
            case 0x5F:
            case 0x81:
            case 0x82:
            case 0x83:
            case 0x84:
            case 0x85:
            case 0x86:
            case 0x87:
            case 0x88:
            case 0x89:
            case 0x8A:
            case 0x8B:
            case 0x8C:
            case 0x8D:
            case 0x8E:
            case 0x8F:
            case 0xA0:
            case 0xA1:
            case 0xA2:
            case 0xA3:
            case 0xA4:
            case 0xA5:
            case 0xA6:
            case 0xA7:
            case 0xA8:
            case 0xA9:
            case 0xAA:
            case 0xAB:
            case 0xAC:
            case 0xAD:
            case 0xAE:
            case 0xAF:
                return(255);
            }
            return(0);
        }