示例#1
0
 public MachineCPU(int cpu_type, int cpu_clock,
     MemoryReadAddress[] memory_read, MemoryWriteAddress[] memory_write,
 IOReadPort[] port_read, IOWritePort[] port_write,
     vblank_interrupt_callback vblank_interrupt, int vblank_interrupts_per_frame,
     vblank_interrupt_callback interrupt = null, int ips = 0)
 {
     this.cpu_type = cpu_type; this.cpu_clock = cpu_clock;
     this.memory_read = memory_read; this.memory_write = memory_write;
     this.port_read = port_read; this.port_write = port_write;
     this.vblank_interrupt = vblank_interrupt; this.vblank_interrupts_per_frame = vblank_interrupts_per_frame;
     this.timed_interrupt = interrupt;
     this.timed_interrupts_per_second = ips;
 }
示例#2
0
        IOReadPort[] install_port_read_handler_common(int cpu, int start, int end, mem_read_handler handler, int install_at_beginning)
        {
            int i, oldsize;

            oldsize = readport_size[cpu];
            readport_size[cpu]++;

            if (readport[cpu] == null)
            {
                readport[cpu] = new IOReadPort[readport_size[cpu]];
            }
            else
            {
                Array.Resize<IOReadPort>(ref readport[cpu], readport_size[cpu]);
            }

            if (readport[cpu] == null) return null;

            if (install_at_beginning != 0)
            {
                /* can't do a single memcpy because it doesn't handle overlapping regions correctly??? */
                for (i = oldsize; i >= 1; i--)
                {
                    Array.Copy(readport[cpu], i - 1, readport[cpu], i, 1);
                    //memcpy(&readport[cpu][i], &readport[cpu][i - 1], sizeof(struct IOReadPort));
                }

                i = 0;
            }
            else
            {
                i = oldsize;
            }

            readport[cpu][i] = new IOReadPort();
            readport[cpu][i].start = start;
            readport[cpu][i].end = end;
            readport[cpu][i].handler = handler;

            return readport[cpu];
        }