Ignore:
Timestamp:
Apr 12, 2019, 11:43:24 AM (6 years ago)
Author:
chronos
Message:
  • Modified: Optimization of draw only modified part of screen.
Location:
branches/virtualcpu4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/virtualcpu4

    • Property svn:ignore
      •  

        old new  
        44*.lps
        55*.res
         6heaptrclog.trc
  • branches/virtualcpu4/UFormMain.pas

    r175 r176  
    1616    ButtonStart: TButton;
    1717    ButtonStop: TButton;
     18    Image1: TImage;
    1819    Label1: TLabel;
    1920    Label2: TLabel;
     
    2122    ListViewRegisters: TListView;
    2223    Memo1: TMemo;
    23     PaintBox1: TPaintBox;
    2424    Timer1: TTimer;
    2525    TimerDraw: TTimer;
     
    3232    procedure ListViewRegistersData(Sender: TObject; Item: TListItem);
    3333    procedure Memo1KeyPress(Sender: TObject; var Key: char);
    34     procedure PaintBox1Paint(Sender: TObject);
     34    procedure ScreenRepaing;
    3535    procedure PaintBox1Resize(Sender: TObject);
    3636    procedure Timer1Timer(Sender: TObject);
     
    8383begin
    8484  LoadProgram;
     85  PaintBox1Resize(Self);
    8586end;
    8687
     
    123124end;
    124125
    125 procedure TFormMain.PaintBox1Paint(Sender: TObject);
    126 var
    127   X, Y: Integer;
     126procedure TFormMain.ScreenRepaing;
     127var
    128128  B: Byte;
    129   MemorySizeTmp: Integer;
    130   Addr: Integer;
    131 begin
    132   MemorySizeTmp := Machine.MemorySize;
    133   with Machine, Screen do
    134   for Y := 0 to Size.Y - 1 do
    135   for X := 0 to Size.X - 1 do begin
    136     Addr := MemoryBase + Y * Size.X + X;
    137     if Addr < MemorySizeTmp then begin
    138       B := PByte(Memory + Addr)^;
    139       PaintBox1.Canvas.Pixels[X, Y] := B * $010101;
     129  P: Integer;
     130begin
     131  with Machine, Screen do begin
     132    if ChangedAreaFrom < ChangedAreaTo then begin
     133      if (Image1.Picture.Bitmap.Width <> Image1.Width) or
     134      (Image1.Picture.Bitmap.Height <> Image1.Height) then
     135        Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height);
     136      Image1.Picture.Bitmap.BeginUpdate(True);
     137      P := ChangedAreaFrom;
     138      while P <= ChangedAreaTo do begin
     139        B := PByte(Memory + MemoryBase + P)^;
     140        Image1.Canvas.Pixels[P mod Size.X, P div Size.X] := B * $010101;
     141        Inc(P);
     142      end;
     143      ChangedAreaTo := MemoryBase;
     144      ChangedAreaFrom := MemoryBase + MemorySize;
     145      Image1.Picture.Bitmap.EndUpdate;
    140146    end;
    141147  end;
     
    144150procedure TFormMain.PaintBox1Resize(Sender: TObject);
    145151begin
    146   Machine.Screen.Size := Point(PaintBox1.Width, PaintBox1.Height);
     152  Machine.Screen.Size := Point(Image1.Width, Image1.Height);
    147153end;
    148154
     
    160166procedure TFormMain.TimerDrawTimer(Sender: TObject);
    161167begin
    162   PaintBox1.Repaint;
     168  ScreenRepaing;
    163169end;
    164170
     
    196202    Loadi(R2, 12);
    197203  LabelPrint := IP;
    198       DataPrefix8; LoadMem(R3, R1);
     204    DataPrefix8; LoadMem(R3, R1);
    199205    DataPrefix8; Output(0, R3);
    200206    Increment(R1);
     
    213219    Test(R2);
    214220    JumpNotZero(LabelClearScreen);
     221
     222    // Update screen area
     223    Loadi(R1, 0);
     224    Output(4, R1);
     225    Loadi(R1, $10000);
     226    Output(5, R1);
    215227
    216228    // Read keyboard and print to console
Note: See TracChangeset for help on using the changeset viewer.