Ignore:
Timestamp:
Apr 12, 2019, 1:34:47 AM (6 years ago)
Author:
chronos
Message:
  • Added: Drawing to video memory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/virtualcpu4/UMachine.pas

    r174 r175  
    1111  TScreen = class
    1212    Size: TPoint;
     13    MemoryBase: Integer;
    1314  end;
    1415
     
    1920    function CpuInput(Port: TAddress): TRegister;
    2021    procedure CpuOutput(Port: TAddress; Value: TRegister);
     22    function GetMemorySize: Integer;
     23    procedure SetMemorySize(AValue: Integer);
    2124  public
    22     Memory: array of Byte;
     25    Memory: Pointer;
    2326    Cpu: TCpu;
    2427    Screen: TScreen;
     
    2730    LockInput: TCriticalSection;
    2831    LockOutput: TCriticalSection;
     32    property MemorySize: Integer read GetMemorySize write SetMemorySize;
    2933    constructor Create;
    3034    destructor Destroy; override;
     
    4246  Cpu.OnInput := CpuInput;
    4347  Cpu.OnOutput := CpuOutput;
    44   Cpu.DataSize := bw16;
    45   Cpu.AddressSize := bw16;
     48  Cpu.DataSize := bw32;
     49  Cpu.AddressSize := bw32;
    4650  Screen := TScreen.Create;
    4751  Screen.Size := Point(320, 240);
    48   SetLength(Memory, 1000);
     52  Screen.MemoryBase := $100;
     53  MemorySize := $1000000;
    4954  Cpu.Memory := Memory;
    5055end;
     
    7681      LockInput.Release;
    7782    end;
     83    1: case Cpu.DataSize of
     84      bw8: Result.B := Screen.Size.X;
     85      bw16: Result.W := Screen.Size.X;
     86      bw32: Result.D := Screen.Size.X;
     87      bw64: Result.Q := Screen.Size.X;
     88    end;
     89    2: case Cpu.DataSize of
     90      bw8: Result.B := Screen.Size.Y;
     91      bw16: Result.W := Screen.Size.Y;
     92      bw32: Result.D := Screen.Size.Y;
     93      bw64: Result.Q := Screen.Size.Y;
     94    end;
     95    3: case Cpu.DataSize of
     96      bw8: Result.B := Screen.MemoryBase;
     97      bw16: Result.W := Screen.MemoryBase;
     98      bw32: Result.D := Screen.MemoryBase;
     99      bw64: Result.Q := Screen.MemoryBase;
     100    end;
    78101  end;
    79102end;
     
    87110      LockOutput.Release;
    88111    end;
     112    1: case Cpu.DataSize of
     113      bw8: Screen.Size.X := Value.B;
     114      bw16: Screen.Size.X := Value.W;
     115      bw32: Screen.Size.X := Value.D;
     116      bw64: Screen.Size.X := Value.Q;
     117    end;
     118    2: case Cpu.DataSize of
     119      bw8: Screen.Size.Y := Value.B;
     120      bw16: Screen.Size.Y := Value.W;
     121      bw32: Screen.Size.Y := Value.D;
     122      bw64: Screen.Size.Y := Value.Q;
     123    end;
     124    3: case Cpu.DataSize of
     125      bw8: Screen.MemoryBase := Value.B;
     126      bw16: Screen.MemoryBase := Value.W;
     127      bw32: Screen.MemoryBase := Value.D;
     128      bw64: Screen.MemoryBase := Value.Q;
     129    end;
    89130  end;
     131end;
     132
     133function TMachine.GetMemorySize: Integer;
     134begin
     135  Result := MemSize(Memory);
     136end;
     137
     138procedure TMachine.SetMemorySize(AValue: Integer);
     139begin
     140  Memory := ReAllocMem(Memory, AValue);
    90141end;
    91142
Note: See TracChangeset for help on using the changeset viewer.