Retrochallenge 2015 – Here we go.

We’re four days into retro challenge and I’ve finally got started.

My plan is to do “something programmy” on a Sharp MZ-700. I’ve set up my stall and now for the programming. I’ve not used C on a Z80 before nor anything beyond “Hello World” on an MZ-700 so I need to find out some basics.

First I’m going to output a character grid using memory mapping (rather than standard output – printf) because I get further, memory mapped screen access will be needed.

I’m using Z88DK to write in and MZ-700 emulator under DOSBOX to test. I’ll try it on a real MZ-700 before I’ve finished.

First, some code…

/*
 * charmap.c
 *
 * A simple memory mapped display of the character and colour map on
 *  the Sharp MZ-700.
 *
 * Andy Collins. July 4th 2015.
 *
 */

#include <stdio.h>
#include <stdint.h>
#include <string.h>

void main(void)
{
  u8_t  *screenRam = 0xD000;         // Start of screen memory. Top left.
  u8_t  *colourRam = 0xD800;         // Start of colour attribute memory. Top left.
  u8_t  xLoop = 0;
  u8_t  yLoop = 0;
  u8_t  currentChar = 0;
  const u8_t myChar = 0x41;

// Output a square with the complete character set.
  screenRam += 4 * 40 + 4;         // Move top left in a bit
  for(xLoop = 0; xLoop < 16; xLoop++)
  {
    for(yLoop = 0; yLoop < 16; yLoop++)
    {
      *screenRam++ = currentChar++;
    }
    
    screenRam += 24;
  }
    
// Now a square of the colour combinations
  screenRam = 0xD000 + 4 * 40 + 20;  // Start of colour square in screen RAM
  colourRam += 4 * 40 + 20;         // Move top left in a bit
  for(xLoop = 0; xLoop < 16; xLoop++)
  {
    for(yLoop = 0; yLoop < 16; yLoop++)
    {
      *colourRam++ = currentChar++;
      *screenRam++ = myChar;
    }
    
    colourRam += 24;
    screenRam += 24;
  }
    
  while(1)
  {
  }
}

And a screenshot…

Screenshot from 2015-07-04 11:44:43Tadaa :-).

 

2 thoughts on “Retrochallenge 2015 – Here we go.”

  1. Sorry for commeting an old blog, but just wanted you to know that this code still compiles without problem in the latest z88sdk.
    BTW, do you have the source for Cellar Scramble for download?

    1. Hi,

      Thanks for your comment. This project has been on the shelf for quite some time now. It’s really not ready for prime time and so I haven’t published it on any site.
      Perhaps one day I’ll resurrect it.

Leave a Reply

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