File: spperif.c

package info (click to toggle)
spectemu 0.94a-19
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 1,300 kB
  • ctags: 3,206
  • sloc: ansic: 15,421; asm: 5,160; sh: 1,533; cpp: 377; makefile: 173
file content (126 lines) | stat: -rw-r--r-- 2,842 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* 
 * Copyright (C) 1996-1998 Szeredi Miklos
 * Email: mszeredi@inf.bme.hu
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. See the file COPYING. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include "spperif.h"
#include "z80.h"

int SPNM(quick_load) = 0;
int SPNM(load_trapped);

qbyte SPNM(scr_mark)[SCRMARK_SIZE];
byte SPNM(fe_inport_high)[256];

int SPNM(scline);


unsigned char SPNM(colors)[16];

int SPNM(flash_state);

qbyte *SPNM(scr_f0_table);
qbyte *SPNM(scr_f1_table);

byte SPNM(tape_impinfo)[PORT_TIME_NUM];
byte SPNM(fe_inport_default);
byte SPNM(fe_outport_time)[PORT_TIME_NUM];
byte SPNM(sound_buf)[PORT_TIME_NUM];
signed char SPNM(tape_sound)[TMNUM];
int SPNM(scri)[PORT_TIME_NUM];
int SPNM(coli)[PORT_TIME_NUM];

int SPNM(playing_tape) = 0;
int SPNM(paused) = 0;

char *SPNM(image);
int SPNM(updating);
qbyte SPNM(imag_mark)[192];
qbyte SPNM(imag_horiz);
qbyte SPNM(imag_vert);
int SPNM(border_update);
int SPNM(lastborder);

void SPNM(init_screen_mark)(void)
{
  int i;

  for(i = 0x200; i < 0x2D8; i++) SPNM(scr_mark)[i] = ~((qbyte) 0);

  SPNM(border_update) = 1;
}

static void init_rom(void)
{
  FILE *fp;

  fp = fopen(ROM_IMAGE, "rb");
  if(fp == NULL) {
    fprintf(stderr, "Could not open file %s: %s\n", ROM_IMAGE,
	    strerror(errno));
    exit(1);
  }

  if(fread(PRNM(proc).mem, 1, 0x4000, fp) != 0x4000) {
    fprintf(stderr, "Error reading from %s: %s\n", ROM_IMAGE, strerror(errno));
    fclose(fp);
    exit(1);
  }

  if(fclose(fp)) {
    fprintf(stderr, "Error closing %s: %s\n", ROM_IMAGE, strerror(errno));
  }

  return;
}

void SPNM(init)(void)
{
  int i;

  PRNM(init)();
  PRNM(reset)();

  SPNM(load_trapped) = 0;

  for(i = 0; i < PORTNUM; i++) PRNM(inports)[i] = 0x00;

  DANM(inport_mask) = 0x20;
/* TODO: Kempston is always present, this is not nice */

  SPNM(fe_inport_default) = 0xBF; /* Issue 3 */

  DANM(ula_outport) = 0xFF;

  for(i = 0; i < 256; i++) SPNM(fe_inport_high)[i] = 0xFF;
  
  for(i = 0; i < PORT_TIME_NUM; i++) SPNM(tape_impinfo)[i] = 0;
  DANM(imp_change) = 0;
  DANM(ula_inport) = SPNM(fe_inport_default);

  SPNM(scline) = 0;
  
  init_rom();

  SPNM(init_screen_mark)();
}