home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1996 December / PC_Shareware-1996-12.iso / windows / spectrum / sources / initem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-20  |  2.1 KB  |  77 lines

  1. /* InitMem.c : Initialize Spectrum memory.
  2.  *
  3.  * Copyright 1996 Rui Fernando Ferreira Ribeiro.
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. /*
  21.  *                        EmuZ80 v1.0
  22.  *            (c) 1996 Rui Fernando Ferreira Ribeiro
  23.  *
  24.  * -------------------------------------------------------
  25.  *
  26.  * INITEM.C : initialize z80 subsystem
  27.  *
  28.  */
  29.  
  30. #include <windows.h>
  31. #include <string.h>
  32. #include <process.h>
  33. #include <stdlib.h>
  34. #include "env.h"
  35.  
  36. char szROMPath[260];
  37.  
  38. void init_emul(HINSTANCE hInst)
  39. {
  40.    USHORT i = 0;
  41.    WORD kernel;
  42.  
  43.  
  44.    /* Open Z80 emulation with 64Kb of RAM */
  45.    Init_Z80Emu((char *)NULL);
  46.  
  47.    /* init RAM with random values -- just to remember the good old
  48.      days
  49.     */
  50.    srand(NULL);
  51.    for(i=0x4000; i<0xFFFE; i++)
  52.       writebyte(i, rand()/256);
  53.  
  54.    /* Find WSpecem directory (it isn't the default if the programmed was called with a double-
  55.     click in a associated icon
  56.     */
  57.    GetModuleFileName(hInst, szROMPath, sizeof(szROMPath));
  58.  
  59.    i = strlen(szROMPath);
  60.    while(szROMPath[i] != '\\')
  61.       i--;
  62.    szROMPath[i] = '\0'; /* Directory name */
  63.  
  64.    strcat(szROMPath, "\\spectrum.rom" );
  65.  
  66.    /* open rom file --- spectrum.rom */
  67.    if(open_sna((LPSTR)szROMPath))
  68.    {
  69.       Panic("Couldn't open file spectrum.rom!");
  70.       /* cleans screen address */
  71.       for(i=0x4000; i<0xFFFE; i++)
  72.      writebyte(i, 0);
  73.    }
  74. }
  75.  
  76. /* EOF: InitMem.c */
  77.