mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-16 05:05:11 +00:00
fixed paddle events in verilog (again)
This commit is contained in:
parent
fa4eefba59
commit
0d9c1e5b51
@ -227,8 +227,6 @@ var VerilogPlatform = function(mainElement, options) {
|
|||||||
var current_output;
|
var current_output;
|
||||||
|
|
||||||
// control inputs
|
// control inputs
|
||||||
var paddle_x = 0;
|
|
||||||
var paddle_y = 0;
|
|
||||||
var switches = [0,0,0];
|
var switches = [0,0,0];
|
||||||
|
|
||||||
// inspect feature
|
// inspect feature
|
||||||
@ -340,14 +338,7 @@ var VerilogPlatform = function(mainElement, options) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
// setup mouse events
|
// setup mouse events
|
||||||
topdiv.mousemove( (e) => {
|
video.setupMouseEvents();
|
||||||
var x = e.pageX - vcanvas.offset().left;
|
|
||||||
var y = e.pageY - vcanvas.offset().top;
|
|
||||||
var new_x = Math.floor(x * video.canvas.width / vcanvas.width() - 20);
|
|
||||||
var new_y = Math.floor(y * video.canvas.height / vcanvas.height() - 20);
|
|
||||||
paddle_x = clamp(8, 240, new_x);
|
|
||||||
paddle_y = clamp(8, 240, new_y);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setGenInputs() {
|
setGenInputs() {
|
||||||
@ -482,8 +473,8 @@ var VerilogPlatform = function(mainElement, options) {
|
|||||||
framehsync = false;
|
framehsync = false;
|
||||||
framex = 0;
|
framex = 0;
|
||||||
framey++;
|
framey++;
|
||||||
gen.hpaddle = framey > paddle_x ? 1 : 0;
|
gen.hpaddle = framey > video.paddle_x ? 1 : 0;
|
||||||
gen.vpaddle = framey > paddle_y ? 1 : 0;
|
gen.vpaddle = framey > video.paddle_y ? 1 : 0;
|
||||||
}
|
}
|
||||||
if (framey > maxVideoLines || gen.vsync) {
|
if (framey > maxVideoLines || gen.vsync) {
|
||||||
framevsync = true;
|
framevsync = true;
|
||||||
@ -725,16 +716,16 @@ var VerilogPlatform = function(mainElement, options) {
|
|||||||
}
|
}
|
||||||
saveControlsState() {
|
saveControlsState() {
|
||||||
return {
|
return {
|
||||||
p1x: paddle_x,
|
p1x: video.paddle_x,
|
||||||
p1y: paddle_y,
|
p1y: video.paddle_y,
|
||||||
sw0: switches[0],
|
sw0: switches[0],
|
||||||
sw1: switches[1],
|
sw1: switches[1],
|
||||||
sw2: switches[2],
|
sw2: switches[2],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
loadControlsState(state) {
|
loadControlsState(state) {
|
||||||
paddle_x = state.p1x;
|
video.paddle_x = state.p1x;
|
||||||
paddle_y = state.p1y;
|
video.paddle_y = state.p1y;
|
||||||
switches[0] = state.sw0;
|
switches[0] = state.sw0;
|
||||||
switches[1] = state.sw1;
|
switches[1] = state.sw1;
|
||||||
switches[2] = state.sw2;
|
switches[2] = state.sw2;
|
||||||
|
Loading…
Reference in New Issue
Block a user