~ubuntu-branches/ubuntu/breezy/tiemu/breezy

« back to all changes in this revision

Viewing changes to src/core/ti_hw/hardware.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien BLACHE
  • Date: 2005-06-02 16:50:15 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050602165015-59ab24414tl2wzol
Tags: 1.99+svn1460-1
* New snapshot.
* debian/control:
  + Updated build-depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  gtktiemu - a TI89/92/92+ emulator
2
 
 *  (c) Copyright 2000-2001, Romain Lievin and Thomas Corvazier
3
 
 *
4
 
 *  This program is free software; you can redistribute it and/or modify
5
 
 *  it under the terms of the GNU General Public License as published by
6
 
 *  the Free Software Foundation; either version 2 of the License, or
7
 
 *  (at your option) any later version.
8
 
 *
9
 
 *  This program is distributed in the hope that it will be useful,
10
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 *  GNU General Public License for more details.
13
 
 *
14
 
 *  You should have received a copy of the GNU General Public License
15
 
 *  along with this program; if not, write to the Free Software
16
 
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
 */
18
 
 
19
 
/*
20
 
  TI hardware management (ASIC).
21
 
  -> screen, keyboard, linkport, timers.
22
 
*/
23
 
 
24
 
#include <stdlib.h>
25
 
#include <fcntl.h>
26
 
#include <sys/stat.h>
27
 
#include <signal.h>
28
 
#include <time.h>
29
 
 
30
 
#include "uae.h"
31
 
//#include "interface.h"
32
 
#include "images.h"
33
 
#include "memory.h"
34
 
#include "lcd.h"
35
 
#include "keyboard.h"
36
 
#include "linkport.h"
37
 
#include "params.h"
38
 
#include "timer.h"
39
 
#include "ioports.h"
40
 
#include "callbacks.h"
41
 
#include "m68k.h"
42
 
 
43
 
int init_int_tab_offset;
44
 
 
45
 
int cycle_instr = 640;
46
 
int cycle_count = 0;
47
 
 
48
 
 
49
 
/* This function should be called everytime the counter increases */
50
 
void update_hardware()
51
 
{
52
 
  /* Auto-int 5: timer */
53
 
  if(timer_value++ == 0)
54
 
    {
55
 
      timer_value = timer_init;
56
 
      specialflags |= SPCFLAG_INT;
57
 
      if(currIntLev < 5)
58
 
        currIntLev = 5;
59
 
    }
60
 
  else
61
 
    timer_value &= 0xff;
62
 
 
63
 
  /* Auto-int 1: 1/4 of timer rate */
64
 
  if(!(timer_value&3)) 
65
 
    {
66
 
      specialflags |= SPCFLAG_INT;
67
 
      currIntLev = 1;
68
 
    }
69
 
 
70
 
  /* Auto-int 2: keyboard scan */
71
 
  if(!(timer_value&2))
72
 
    {
73
 
    }
74
 
 
75
 
  /* Link status */
76
 
  if(linkport_checkread())
77
 
    ti_io[0xc] |= 0x2;
78
 
 
79
 
  /* Link interrupt */ 
80
 
  if(ti_io[0xc]&0x2) 
81
 
    {
82
 
      specialflags |= SPCFLAG_INT;
83
 
      currIntLev = 4;
84
 
    }
85
 
  
86
 
  /* LCD is refreshed every 16th time */
87
 
  if(!(timer_value&15))
88
 
    {
89
 
      if(lc_internal) 
90
 
        {
91
 
          if(lc_timeout++ >= TO_VALUE) 
92
 
            {
93
 
              DISPLAY("Warning: internal link timeout !!!\n");
94
 
              lc_internal = 0;
95
 
              lc_timeout = 0;
96
 
            }
97
 
        }
98
 
 
99
 
      hw_update_kbd();
100
 
 
101
 
      if(!params.sync_one)
102
 
        cb_update_screen();
103
 
    }
104
 
}
105
 
 
106
 
 
107
 
/*
108
 
  Init hardware...
109
 
  A ROM image must have been loaded before calling this function.
110
 
*/
111
 
 
112
 
void init_hardware() 
113
 
{
114
 
  hw_init_mem();
115
 
  hw_init_io();
116
 
  hw_init_kbd();
117
 
  hw_init_timer();
118
 
  hw_init_lcd();
119
 
  hw_init_dbus();
120
 
  hw_init_m68k();
121
 
}
122
 
 
123
 
void reset_hardware()
124
 
{
125
 
  hw_reset_m68k();
126
 
}
127
 
 
128
 
void exit_hardware(void) 
129
 
{
130
 
  hw_exit_m68k();
131
 
  hw_exit_dbus();
132
 
  hw_exit_lcd();
133
 
  hw_exit_timer();
134
 
  hw_exit_kbd();
135
 
  hw_exit_io();
136
 
  hw_exit_mem();
137
 
}