Cold War Computing

Retrocomputing Blog

1802 RetroShield – SPI RAM

In the original 1802 Monitor + Tiny Basic Arduino code by Erturk Kocalar, the memory map is divided into three sections: ROM, onboard RAM, and external/simulated RAM.

  • ROM is hardcoded in the Arduino’s program memory, is of variable length, and starts at address 0x0000.
  • Onboard RAM starts at 0x8000 and is 6K in length if SPI RAM is not used, or 2K in length if it is not. (The 4K difference is instead used for caching the SPI RAM.)
  • If SPI RAM is used, the remainder of the memory map to 0xFFFF is cached SPI RAM. If SPI RAM is not used, the remainder of the memory map to 0xFFFF is hardcoded to 0xFF.

Instructions for adding 128K SPI RAM to a RetroShield project can be found here, and a discussion of the caching scheme used in the default project is here.

My goal right now is to leave the functionality the same if SPI RAM is not used, but change the behavior when SPI RAM is used so that the full 64K memory map is cached SPI RAM. For now, the ROM will still be located in program memory, but will be copied into RAM at startup. The eventual goal is to have no ROM, instead having system software loaded from SD on startup.

The first change to the default project was to enable the SPI RAM:

////////////////////////////////////////////////////////////////////
// Options
//   USE_SPI_RAM: Enable Microchip 128KB SPI-RAM  (Details coming up)
//   USE_LCD_KEYPAD: Enable LCD/Keyboard Shield
//   outputDEBUG: Print memory access debugging messages.
//   TPB_SOFTWARE: Generate TPB internally so access SC0 signal. 
////////////////////////////////////////////////////////////////////
#define USE_SPI_RAM     1
#define USE_LCD_KEYPAD  0
#define outputDEBUG     0
#define TPB_SOFTWARE    1

Next, I changed the Memory Layout constants to match my desired layout:

////////////////////////////////////////////////////////////////////
// MEMORY LAYOUT
////////////////////////////////////////////////////////////////////

#if (USE_SPI_RAM)
  // 2K MEMORY
  //#define RAM_START   0x8000
  //#define RAM_END     0x87FF
  //byte    RAM[RAM_END-RAM_START+1];
  #define RAM_START 0x0000
  #define RAM_END   0xFFFF
#else
  // 6K MEMORY
  #define RAM_START   0x8000
  #define RAM_END     0x97FF
  byte    RAM[RAM_END-RAM_START+1];
#endif

I changed the code that reads memory so that if SPI RAM is enabled, all reads come from SPI RAM.

#if (USE_SPI_RAM)
    DATA_latched = cache_read_byte(uP_ADDR);
#else
    // ROM?
    if ( (ROM_START <= uP_ADDR) && (uP_ADDR <= ROM_END) )
    {
      DATA_latched = pgm_read_byte_near(rom_bin + (uP_ADDR - ROM_START));
    }
    else
    // Execute from RAM?
    if ( (RAM_START <= uP_ADDR) && (uP_ADDR <= RAM_END) )
      DATA_latched = RAM[uP_ADDR - RAM_START];
    else
      // Dummy 0xFF (eeprom style) out for unmapped memory locations
      DATA_latched = 0xFF;      
#endif

And the same for the code that writes memory.

    // Memory Write
#if (USE_SPI_RAM)
    cache_write_byte(uP_ADDR, DATA_latched);
#else
    if ( (RAM_START <= uP_ADDR) && (uP_ADDR <= RAM_END) )
      RAM[uP_ADDR - RAM_START] = DATA_latched;    
#endif

I added a function to copy the ROM from program memory to SPI-RAM.

#if (USE_SPI_RAM)
void rom_init() {
  unsigned int i;

  for(i=ROM_START; i<=ROM_END; i++) {
    cache_write_byte(i, pgm_read_byte_near(rom_bin + (i - ROM_START)));
  }

  Serial.print(i - ROM_START); Serial.println(" bytes of ROM copied to RAM.");
}
#endif

And finally, I added a call to this function inside the setup() function.

#if (USE_SPI_RAM)
  // Initialize memory subsystem
  spi_init();
  cache_init();
  rom_init();
#endif

0 thoughts on “1802 RetroShield – SPI RAM

  1. SKY PHARMACY CANADA buy metronidazole 500mg no prescription Viagra vs Cialis which is better? – ED Pharmacy Guide: Buy Viagra canadian pharmacy mall 5mg tadalafil generic Tadalafil online pharmacy india Buy Cialis (Tadalafil) Online :: OVERNIGHT Delivery!. Orthopaedic Division of the Canadian Physiotherapy Association (CPA) the real viagra on line non perscripton Hydrochlorothiazide 25 mg online Buy Viagra. Online CanadianDrugStore

  2. NO PRESCRIPTION PHARMACY online pharmacy Viagra Without Prescription, Viagra Uk – Online Pharmacy, Secure northwest pharmacy canada Buy xenical over the counter About Canada, Canada, country, wilderness, civilisation, Canada’s Buy Generic Viagra online no prescription – USA. Canadian National Exhibition canadian pharmacy no prescription Generic viagra sold in united states Viagra Online. Canadian Pharmacy. Our price – 0.69$ per pill Viagra.

  3. RICO RIO PHARMACY 1650 canadian pharmacy online no script Pharmacy Related Journals – The World-Wide Web Virtual Library healthymale Fast viagra delivery Canadian Store: DrugsHaven – Buy Viagra, Levitra, Cialis Online Buy Cialis Online – Lowest Price and Best Quality Guaranteed!. Cheap viagra from pharmacy canada pharmacy 24h Levothyroxine 75mcg buy online cheap CANADA Online Pharmacy: Cialis, Viagra, Tadalafil, Vardenafil

  4. ON LINE PHARMACY canada pharmacy 24 hour drug store Buy Cheap Viagra Online. Approved Canadian Pharmacy Store. sky pharmacy online drugstore Buy viagra online uk Cheap Viagra Online usa canada. #1 OFFICIAL PHARMACY Buy Cialis (Tadalafil) Online From A Certified US Pharmacy. Canadian Drugstore: DrugsPick – Buy Viagra, Cialis, Levitra Online Canadian pharmacy What are the highest mg of cialis Canadian Viagra Online – LOWEST PRICES!

  5. PHARMACY EXPRESS CANADA online pharmacy Generic Topamax (Topiramate) – General health @ goldenpharma24x7.com northwest pharmacy canada Viagra overseas Cheap Viagra Online» #1 Canadian Online Drugstore. FDA Approved How to Buy Real cialis Online at EXTRA LOW PRICES !. Cheapest Viagra Online, Viagra Canada No Prescription online pharmacy www Buy amoxicillin without prescription uk buy tadalafil online – Approved Canadian Healthcare

  6. CANADIAN PHARMACY NO PRESCRIPTION https://www.weightlossbestpills.com Pharmacy Prescription Coupons – Free Drug Discounts, Rebates paxil canada pharmacy no perscription Vosteran sehatnegeriku – Canadian Pharmacy Online – Propecia online canada SPECIAL OFFER : VIAGRA on SALE at $0.75. Generic propecia. Online Canadian Pharmacy. online pharmacy no prescription needed Meds online pharmacies Flagyl canada pharmacy

  7. CIALIS 20MG PRIX EN PHARMACIE canadian pharmacy online no script Online Pharmacy and Drugstore – Manage Prescription Drug Refills online pharmacies without prescription Dapoxetine Free Internet TV Canada Buy Generic Viagra, Cheap Viagra – Official Drugstore!. Canadian Store: DrugsHaven – Buy Viagra, Levitra, Cialis Online healthy man viagra Levothyroxine without us prescription Walmart Viagra Price – Viagra Tablets – Viagra From Canada

  8. CANADIAN PHARMACIES ONLINE online pharmacy without a prescription Medical Specialists Pharmacy – Viagra UK – Buy Genuine Pfizer free viagra samples before buying Buy viagra online with no prescription Generic Viagra : Canadian Store: DrugsHaven – Buy Viagra, Levitra, Cialis Online. Order Cheap Viagra, Buy Viagra – Canadian Pharmacy, Guaranteed canadian pharmacy no prescription Cheap viagra usa cialis 30 day trial offer # From Canada as well as managed

  9. FIRST MEDICINE ONLINE PHARMACY STORE pharmacy no prescripition PharmacyChecker.com – Compare prescription drug prices and online healthy man cialis Trusted site for generic cialis Non prescription Viagra usa canada. #1 OFFICIAL PHARMACY Buy Generic Cialis Online Today – Cheapest And Secure Online Drugstore. malocite’s blog is now http://www.prescriptionpillspharmacyrx.ru Articulo 45 Canadian Pharmacy King – BestBuyRX.com Lower Priced Canada

  10. CANADIAN ONLINE PHARMACIES usa pharmacy no script Cialis / Buy Cialis Online online pharmacy Nizoral Canadian – definition of Canadian by the Free Online Dictionary Página Oficial del Solar Decathlon Europe.. Amoxicillin 500mg – Buy amoxicillin 250, 500 mg online in Canada Online pharmacy Discount cialis online Canada Online – About Canadian Government – Services News Issues

  11. TADALAFIL CANADIAN PHARMACY ONLINE Purchase Viagra Online Generic nexium date :: Online Pharmacy for Prescription Drugs cialis online prices Buy viagra online with no prescription Viagra Price : – Canadian Pharmacy Store AccessRx – Buy Viagra, Cialis, Levitra Online Prescription. Viagra online canadian – Generic Viagra Online Pharmacy supreme suppliersmumbaiindia Online pharmacy Canada TV — Canada Free TV — Watch online the free TV of

Leave a Reply

Your email address will not be published. Required fields are marked *