?login_element?

Subversion Repositories NedoOS

Rev

Rev 129 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1. /*
  2.  
  3.   SjASMPlus Z80 Cross Compiler
  4.  
  5.   Copyright (c) 2004-2006 Aprisobal
  6.  
  7.   This software is provided 'as-is', without any express or implied warranty.
  8.   In no event will the authors be held liable for any damages arising from the
  9.   use of this software.
  10.  
  11.   Permission is granted to anyone to use this software for any purpose,
  12.   including commercial applications, and to alter it and redistribute it freely,
  13.   subject to the following restrictions:
  14.  
  15.   1. The origin of this software must not be misrepresented; you must not claim
  16.          that you wrote the original software. If you use this software in a product,
  17.          an acknowledgment in the product documentation would be appreciated but is
  18.          not required.
  19.  
  20.   2. Altered source versions must be plainly marked as such, and must not be
  21.          misrepresented as being the original software.
  22.  
  23.   3. This notice may not be removed or altered from any source distribution.
  24.  
  25. */
  26.  
  27. // devices.h
  28.  
  29. bool IsZXSpectrumDevice(char *name);
  30. int SetDevice(char *id, const aint ramtop = 0);
  31. char* GetDeviceName();
  32.  
  33. class CDevicePage {
  34. public:
  35.         CDevicePage(byte* memory, int32_t size, int number);
  36.         int32_t Size;
  37.         int Number;
  38.         byte* RAM;
  39. private:
  40. };
  41.  
  42. class CDeviceSlot {
  43. public:
  44.         enum ESlotOptions { O_NONE, O_ERROR, O_WARNING, O_NEXT };
  45.  
  46.         CDeviceSlot(int32_t adr, int32_t size);
  47.         ~CDeviceSlot();
  48.         int32_t Address;
  49.         int32_t Size;
  50.         CDevicePage* Page;
  51.         int16_t InitialPage;
  52.         ESlotOptions Option;
  53. private:
  54. };
  55.  
  56. class CDevice {
  57. public:
  58.  
  59.         constexpr static size_t MAX_SLOT_N = 32;
  60.         constexpr static size_t MAX_PAGE_N = 512;
  61.  
  62.         // reset will reinitialize checks, "no emit" will do wrap-only (no machine byte emitted)
  63.         // "emit" will also report error/warning upon boundary, as the machine byte emit is expected
  64.         enum ECheckPageLevel{ CHECK_RESET, CHECK_NO_EMIT, CHECK_EMIT };
  65.  
  66.         CDevice(const char* name, CDevice* parent);
  67.         virtual ~CDevice();
  68.         void AddSlot(int32_t adr, int32_t size);
  69.         void AddPage(byte* memory, int32_t size);
  70.         CDevicePage* GetPage(int);
  71.         CDeviceSlot* GetSlot(int);
  72.         virtual int GetSlotOfA16(int32_t address);
  73.         int GetPageOfA16(int32_t address);
  74.         void CheckPage(const ECheckPageLevel level);
  75.         bool SetSlot(int slotNumber);           // sets "current/active" slot
  76.         CDeviceSlot* GetCurrentSlot();          // returns "current/active" slot
  77.         int32_t GetMemoryOffset(int page, int32_t offset) const;
  78.         void Poke(aint z80adr, byte value);     // write byte into device memory with current page-mapping
  79.         char* ID;
  80.         CDevice* Next;
  81.         int SlotsCount;
  82.         int PagesCount;
  83.         byte* Memory;
  84.         aint ZxRamTop;          // for ZX-like machines, the RAMTOP system variable
  85. private:
  86.         int CurrentSlot;
  87.         CDeviceSlot* Slots[MAX_SLOT_N];
  88.         CDevicePage* Pages[MAX_PAGE_N];
  89.  
  90.         // variables for CheckPage logic
  91.         int previousSlotI;                              // previous machine code write happened into this slot
  92.         CDeviceSlot::ESlotOptions previousSlotOpt;      // its option was
  93.         bool limitExceeded;                             // true if limit exceeded was already reported
  94. };
  95.  
  96. constexpr aint ZX_RAMTOP_DEFAULT = 0x5D5B;      // 0xFF57 is regular ROM default
  97.         // but 0x5D5B is minimum to keep "CLEAR 54321" still working if you return to BASIC (snapshot)
  98. constexpr aint ZX_SYSVARS_ADR = 0x5C00;
  99. constexpr aint ZX_UDG_ADR = 0xFF58;
  100.  
  101. extern const unsigned char ZX_SYSVARS_DATA[256];
  102. extern const unsigned char ZX_STACK_DATA[4];
  103. extern const unsigned char ZX_UDG_DATA[168];
  104.