home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 September / CHIP_CD_1997_09_PL.iso / software / news / wspecem / sources / initem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-23  |  2.1 KB  |  76 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. void init_emul(HINSTANCE hInst)
  37. {
  38.    USHORT i = 0;
  39.    char szModuleName[260];
  40.    WORD kernel;
  41.  
  42.  
  43.    /* Open Z80 emulation with 64Kb of RAM */
  44.    Init_Z80Emu((char *)NULL);
  45.  
  46.    /* init RAM with random values -- just to remember the good old
  47.      days
  48.     */
  49.    srand(NULL);
  50.    for(i=0x4000; i<0xFFFE; i++)
  51.       writebyte(i, rand()/256);
  52.  
  53.    /* Find WSpecem directory (it isn't the default if the programmed was called with a double-
  54.     click in a associated icon
  55.     */
  56.    GetModuleFileName(hInst, szModuleName, sizeof(szModuleName));
  57.  
  58.    i = strlen(szModuleName);
  59.    while(szModuleName[i] != '\\')
  60.       i--;
  61.    szModuleName[i] = '\0'; /* Directory name */
  62.  
  63.    strcat(szModuleName, "\\spectrum.rom" );
  64.  
  65.    /* open rom file --- spectrum.rom */
  66.    if(open_sna((LPSTR)szModuleName))
  67.    {
  68.       Panic("Couldn't open file spectrum.rom!");
  69.       /* cleans screen address */
  70.       for(i=0x4000; i<0xFFFE; i++)
  71.      writebyte(i, 0);
  72.    }
  73. }
  74.  
  75. /* EOF: InitMem.c */
  76.