Giter Site home page Giter Site logo

mock's Introduction

ZX Spectrum Next Mock library

This is a header-only library for mocking Next hardware for quick PC-based prototyping. This will create a single window that will emulate the video modes of the Next, and the various input devices (including keyboard). Eventually, it will emulate sound devices.

This library is ongoing work as I prototype my own Next projects. Feel free to use it for your own prototypes. I welcome pull requests if you cannot wait for me to add features.

It works by allowing an API to access memory and ports to peek, poke, in and out like you normally do on the real hardware. There are a few convenience functions but I prefer my API to be small and close to the "hardware" as possible.

Features currently implemented

  • 4 zoom modes (accessible to function keys 1-4).
  • Original 48K ULA (including border).
  • 512K extra memory (40 pages).
  • Layer 2, including the transparency, paging control port and bank start registers.
  • RAM only paging using ports $7FFD and $DFFD.
  • PNG and NIM graphics file loading and saving.

Features not implemented but planned for the future

  • Screenshot support.
  • Keyboard input.
  • Debug mode (switches border to unique colour and enables debug keyboard commands).
  • Kempston mouse and joystick (via XInput devices).
  • 128K Spectrum ROM paging support.
  • Full Next video support (including ULAnext, Timex modes, sprites & priorities).
  • AY3-8912 support.

How to use the library

Just include it. That's all. However, only one .c/.cpp file MUST define NX_IMPLEMENTATION so that the implementation is pulled into one object file. The typical code to use it looks like this:

Next N = nxOpen();

// Initialise memory and ports here using the memory/port APIs.

while (nxUpdate(N, &MyFrameFunc))
{
    ... Run your code ...
}

nxClose(N);

The function nxUpdate allows a custom function to be called once every 1/50th second after which time the VRAM is re-rendered. All frame sync code should be in this custom function. Any code you want to run that doesn't need to be synchronised with the frame should be inside the while loop.

Please read the top of the header file "next.h" for more information.

NIM file format

This library introduces a simple file format for Next graphics. It uses a 6 byte header followed by the pixel data, which is one byte per pixel. Each pixel byte indexes the current palette. The header format is:

Index Size Description
0 2 File format version
2 2 Width
4 2 Height

The file format version currently is always 0.

Comments, questions, suggestions...

Please send comment suggestions to [email protected] and I will get back to you. If the same questions keep cropping up I might start a FAQ.

mock's People

Contributors

cthutu avatar

Stargazers

Andrey Smorodov avatar Dean H Smith avatar  avatar Filipe Veiga avatar Mitja V. Iskrić avatar

Watchers

Paulo Custodio avatar  avatar James Cloos avatar Filipe Veiga avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.