Exemplo n.º 1
0
        private void loadcheat(string filename)
        {
            FileInfo   fileInfo   = new FileInfo(filename);
            FileStream fileStream = fileInfo.OpenRead();

            byte[] bytedata = new byte[fileInfo.Length];
            fileStream.Read(bytedata, 0, bytedata.Length);
            fileStream.Close();
            Cheats.add_cheats(bytedata);
        }
Exemplo n.º 2
0
        public static void work()
        {
            cycles += CPU.newticks;

            bool runagain = true;

            while (runagain)
            {
                runagain = false;

                switch (gpustate)
                {
                case GPUState.VISIBLE:
                    if (cycles >= 1008)     // 960 is drawing time
                    {
                        runagain = true;
                        cycles  -= 1008;
                        gpustate = GPUState.HBLANK;
                        GBRegs.Sect_display.DISPSTAT_H_Blank_flag.write(1);
                        DMA.new_hblank = true;
                        if (GBRegs.Sect_display.DISPSTAT_H_Blank_IRQ_Enable.on())
                        {
                            IRP.set_irp_bit(IRP.IRPMASK_LCD_H_Blank);
                        }
                        old_dispstat = GBRegs.data[4];

                        GPU.once_per_hblank();
                        GPU.next_line(line);
                    }
                    break;

                case GPUState.HBLANK:
                    if (cycles >= 224)     // 272
                    {
                        runagain = true;
                        cycles  -= 224;
                        nextline();

                        GBRegs.Sect_display.DISPSTAT_H_Blank_flag.write(0);
                        DMA.new_hblank = false;
                        if (line < 160)
                        {
                            gpustate = GPUState.VISIBLE;
                        }
                        else
                        {
                            gpustate = GPUState.VBLANK;
                            GPU.refpoint_update_all();
                            Cheats.apply_cheats();
                            GBRegs.Sect_display.DISPSTAT_V_Blank_flag.write(1);
                            DMA.new_vblank = true;
                            if (GBRegs.Sect_display.DISPSTAT_V_Blank_IRQ_Enable.on())
                            {
                                IRP.set_irp_bit(IRP.IRPMASK_LCD_V_Blank);
                            }
                        }
                        old_dispstat = GBRegs.data[4];
                    }
                    break;

                case GPUState.VBLANK:
                    if (cycles >= 1008)
                    {
                        runagain = true;
                        cycles  -= 1008;
                        gpustate = GPUState.VBLANKHBLANK;
                        GBRegs.Sect_display.DISPSTAT_H_Blank_flag.write(1);
                        //DMA.new_hblank = true; //!!! don't do here!
                        if (GBRegs.Sect_display.DISPSTAT_H_Blank_IRQ_Enable.on())
                        {
                            IRP.set_irp_bit(IRP.IRPMASK_LCD_H_Blank);     // Note that no H-Blank interrupts are generated within V-Blank period. Really?
                        }
                        old_dispstat = GBRegs.data[4];
                    }
                    break;

                case GPUState.VBLANKHBLANK:
                    if (cycles >= 224)
                    {
                        runagain = true;
                        cycles  -= 224;
                        nextline();
                        GBRegs.Sect_display.DISPSTAT_H_Blank_flag.write(0);
                        DMA.new_hblank = false;
                        GPU.once_per_hblank();
                        if (line == 0)
                        {
                            gpio.framecount++;
                            gpio.update_time();
                            gpustate = GPUState.VISIBLE;
                            //GPU.next_line(line);
                            GBRegs.Sect_display.DISPSTAT_V_Blank_flag.write(0);
                            DMA.new_vblank = false;
                        }
                        else
                        {
                            gpustate = GPUState.VBLANK;
                            if (line == 227)
                            {
                                //GBRegs.Sect_display.DISPSTAT_V_Blank_flag.write(0);
                            }
                        }
                        old_dispstat = GBRegs.data[4];
                    }
                    break;
                }
            }
        }