Repository navigation
Expand file tree
/
Copy pathDrawSurface.java
More file actions
120 lines (111 loc) · 4.03 KB
/
Copy pathDrawSurface.java
File metadata and controls
120 lines (111 loc) · 4.03 KB
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
import java.awt.*;
import java.awt.event.*;
public final class DrawSurface extends Canvas {
Remaster parent;
DrawSurface(Remaster p) {
super();
this.parent = p;
setFocusable(true); // explicit: the canvas must be able to hold the keyboard focus
addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
switch(e.getKeyCode()) {
case 37: // Key LEFT
parent.joy.byte1 &= ~Joystick.JOY1_LEFT;
break;
case 39: // Key RIGHT
parent.joy.byte1 &= ~Joystick.JOY1_RIGHT;
break;
case 38: // Key UP
parent.joy.byte1 &= ~Joystick.JOY1_UP;
break;
case 40: // Key DOWN
parent.joy.byte1 &= ~Joystick.JOY1_DOWN;
break;
case 90: // Key Z
//System.out.println("Fire B");
parent.joy.byte1 &= ~Joystick.JOY1_FIREB;
break;
case 88: // Key X
parent.joy.byte1 &= ~Joystick.JOY1_FIREA;
break;
case 27: // ESC: Soft reset
parent.joy.byte2 &= ~Joystick.RESET;
break;
case 80: // Key P: Console Pause button (NMI)
if(parent.z80 != null) parent.z80.setNMI();
break;
case 32: // SPACE BAR: Hard pause
if(parent.mainloop != null) parent.pauseEmulation();
else parent.resumeEmulation();
break;
case 107: // Numerical PLUS key: Increase frame skip
if(parent.vdp != null) parent.vdp.frameskip++;
break;
case 109: // Numerical MINUS key: Decrease frame skip
if(parent.vdp != null && parent.vdp.frameskip > 1) parent.vdp.frameskip--;
break;
case 49: // Key 1: emulation speed 1x
parent.selectSpeed(1);
break;
case 50: // Key 2: emulation speed 2x
parent.selectSpeed(2);
break;
case 51: // Key 3: emulation speed 3x
parent.selectSpeed(3);
break;
case 52: // Key 4: emulation speed 4x
parent.selectSpeed(4);
break;
case 116: // F5 key - save state in the selected slot
parent.saveGameState();
break;
case 118: // F7 key - restore state from the selected slot
parent.loadGameState();
break;
case 122: // F11 key - borderless fullscreen on/off
parent.screen.toggleFullScreen(parent);
break;
default:
//if(parent.z80 != null) parent.z80.msg.println("Key pressed = " + e.getKeyCode());
}
}
public void keyReleased(KeyEvent e) {
switch(e.getKeyCode()) {
case 37: // Key LEFT
parent.joy.byte1 |= Joystick.JOY1_LEFT;
break;
case 39: // Key RIGHT
parent.joy.byte1 |= Joystick.JOY1_RIGHT;
break;
case 38: // Key UP
parent.joy.byte1 |= Joystick.JOY1_UP;
break;
case 40: // Key DOWN
parent.joy.byte1 |= Joystick.JOY1_DOWN;
break;
case 90: // Key Z
parent.joy.byte1 |= Joystick.JOY1_FIREB;
break;
case 88: // Key X
parent.joy.byte1 |= Joystick.JOY1_FIREA;
break;
case 27: // Key ESC - Soft reset
parent.joy.byte2 |= Joystick.RESET;
break;
}
}
} ); // End of KeyListener definition
}
public void paint(Graphics g) {
// MainThread owns active rendering while emulation is running. Let AWT
// only repaint the fallback surface when no emulation thread exists.
if(parent.mainloop == null) parent.screen.drawScreen(0, 0);
}
public void update(Graphics g) {
paint(g);
}
public void paintAll(Graphics g) {}
public void repaint() {}
public void repaint(long tm, int x, int y, int width, int height){}
public void repaint(int x, int y, int width, int height){}
}