mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-23 03:29:05 +00:00
fixed test, verilog; updated slip counter preset
This commit is contained in:
parent
82f01b3fcd
commit
d6a702b929
@ -13,11 +13,17 @@ module ball_slip_counter_top(clk, reset, hsync, vsync, rgb);
|
|||||||
reg [8:0] ball_htimer;
|
reg [8:0] ball_htimer;
|
||||||
reg [8:0] ball_vtimer;
|
reg [8:0] ball_vtimer;
|
||||||
|
|
||||||
reg [8:0] ball_horiz_move = -2;
|
// motion codes
|
||||||
reg [8:0] ball_vert_move = 2;
|
reg [3:0] ball_horiz_move;
|
||||||
|
reg [3:0] ball_vert_move;
|
||||||
localparam ball_horiz_stop = 204;
|
|
||||||
localparam ball_vert_stop = 251;
|
// stop codes
|
||||||
|
localparam ball_horiz_stop = 4'd12;
|
||||||
|
localparam ball_vert_stop = 4'd11;
|
||||||
|
|
||||||
|
// 5-bit constants to load into counters
|
||||||
|
localparam ball_horiz_prefix = 5'b01100; // 192
|
||||||
|
localparam ball_vert_prefix = 5'b01111; // 240
|
||||||
|
|
||||||
hvsync_generator hvsync_gen(
|
hvsync_generator hvsync_gen(
|
||||||
.clk(clk),
|
.clk(clk),
|
||||||
@ -30,15 +36,14 @@ module ball_slip_counter_top(clk, reset, hsync, vsync, rgb);
|
|||||||
);
|
);
|
||||||
|
|
||||||
// update horizontal timer
|
// update horizontal timer
|
||||||
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset) begin
|
||||||
begin
|
if (reset || ball_htimer == 0) begin
|
||||||
if (reset)
|
if (reset) // center-ish of screen
|
||||||
ball_htimer <= ball_horiz_stop - 128;
|
ball_htimer <= {5'b11000, ball_horiz_move};
|
||||||
else if (ball_htimer == 0) begin
|
else if (ball_vtimer == 0) // nudge ball in horiz. dir
|
||||||
if (ball_vtimer == 0)
|
ball_htimer <= {ball_horiz_prefix, ball_horiz_move};
|
||||||
ball_htimer <= ball_horiz_stop + ball_horiz_move;
|
else // reset timer but don't move ball horizontally
|
||||||
else
|
ball_htimer <= {ball_horiz_prefix, ball_horiz_stop};
|
||||||
ball_htimer <= ball_horiz_stop;
|
|
||||||
end else
|
end else
|
||||||
ball_htimer <= ball_htimer + 1;
|
ball_htimer <= ball_htimer + 1;
|
||||||
end
|
end
|
||||||
@ -46,10 +51,10 @@ module ball_slip_counter_top(clk, reset, hsync, vsync, rgb);
|
|||||||
// update vertical timer
|
// update vertical timer
|
||||||
always @(posedge hsync or posedge reset)
|
always @(posedge hsync or posedge reset)
|
||||||
begin
|
begin
|
||||||
if (reset)
|
if (reset) // center-ish of screen
|
||||||
ball_vtimer <= ball_vert_stop - 128;
|
ball_vtimer <= {5'b11000, ball_vert_move};
|
||||||
else if (ball_vtimer == 0)
|
else if (ball_vtimer == 0) // reset timer
|
||||||
ball_vtimer <= ball_vert_stop + ball_vert_move;
|
ball_vtimer <= {ball_vert_prefix, ball_vert_move};
|
||||||
else
|
else
|
||||||
ball_vtimer <= ball_vtimer + 1;
|
ball_vtimer <= ball_vtimer + 1;
|
||||||
end
|
end
|
||||||
@ -59,15 +64,21 @@ module ball_slip_counter_top(clk, reset, hsync, vsync, rgb);
|
|||||||
wire ball_horiz_collide = ball_hgfx && hpos >= 256 && vpos == 255;
|
wire ball_horiz_collide = ball_hgfx && hpos >= 256 && vpos == 255;
|
||||||
|
|
||||||
// vertical bounce
|
// vertical bounce
|
||||||
always @(posedge ball_vert_collide)
|
always @(posedge ball_vert_collide or posedge reset)
|
||||||
begin
|
begin
|
||||||
ball_vert_move <= -ball_vert_move;
|
if (reset)
|
||||||
|
ball_vert_move <= 4'd10;
|
||||||
|
else
|
||||||
|
ball_vert_move <= 4'b0110 ^ ball_vert_move; // change dir.
|
||||||
end
|
end
|
||||||
|
|
||||||
// horizontal bounce
|
// horizontal bounce
|
||||||
always @(posedge ball_horiz_collide)
|
always @(posedge ball_horiz_collide or posedge reset)
|
||||||
begin
|
begin
|
||||||
ball_horiz_move <= -ball_horiz_move;
|
if (reset)
|
||||||
|
ball_horiz_move <= 4'd11;
|
||||||
|
else
|
||||||
|
ball_horiz_move <= 4'b0110 ^ ball_horiz_move; // change dir.
|
||||||
end
|
end
|
||||||
|
|
||||||
// compute ball display
|
// compute ball display
|
||||||
|
@ -13,7 +13,7 @@ export interface Platform {
|
|||||||
getPresets() : Preset[];
|
getPresets() : Preset[];
|
||||||
pause() : void;
|
pause() : void;
|
||||||
resume() : void;
|
resume() : void;
|
||||||
loadROM(title:string, rom:Uint8Array);
|
loadROM(title:string, rom:any); // TODO: Uint8Array
|
||||||
|
|
||||||
inspect?(ident:string) : void;
|
inspect?(ident:string) : void;
|
||||||
disassemble?(addr:number, readfn:(addr:number)=>number) : any; // TODO
|
disassemble?(addr:number, readfn:(addr:number)=>number) : any; // TODO
|
||||||
|
@ -32,11 +32,10 @@ export class CodeProject {
|
|||||||
worker.onmessage = (e) => {
|
worker.onmessage = (e) => {
|
||||||
if (this.pendingWorkerMessages > 1) {
|
if (this.pendingWorkerMessages > 1) {
|
||||||
this.sendBuild();
|
this.sendBuild();
|
||||||
this.pendingWorkerMessages = 0;
|
|
||||||
} else {
|
} else {
|
||||||
this.pendingWorkerMessages = 0;
|
if (this.callbackBuildStatus) this.callbackBuildStatus(false);
|
||||||
}
|
}
|
||||||
if (this.callbackBuildStatus) this.callbackBuildStatus(false);
|
this.pendingWorkerMessages = 0;
|
||||||
if (e.data && !e.data.unchanged) {
|
if (e.data && !e.data.unchanged) {
|
||||||
this.processBuildResult(e.data);
|
this.processBuildResult(e.data);
|
||||||
if (this.callbackBuildResult) this.callbackBuildResult(e.data); // call with data when changed
|
if (this.callbackBuildResult) this.callbackBuildResult(e.data); // call with data when changed
|
||||||
@ -184,6 +183,7 @@ export class CodeProject {
|
|||||||
// TODO: should get rid of this msg format
|
// TODO: should get rid of this msg format
|
||||||
this.worker.postMessage({
|
this.worker.postMessage({
|
||||||
code:text,
|
code:text,
|
||||||
|
path:this.mainpath,
|
||||||
dependencies:depends,
|
dependencies:depends,
|
||||||
platform:this.platform_id,
|
platform:this.platform_id,
|
||||||
tool:this.platform.getToolForFilename(this.mainpath)
|
tool:this.platform.getToolForFilename(this.mainpath)
|
||||||
|
@ -388,7 +388,7 @@ function setCompileOutput(data: WorkerResult) {
|
|||||||
compparams = data.params;
|
compparams = data.params;
|
||||||
// load ROM
|
// load ROM
|
||||||
var rom = data.output;
|
var rom = data.output;
|
||||||
if (rom instanceof Uint8Array) {
|
if (rom) { // TODO instanceof Uint8Array) {
|
||||||
try {
|
try {
|
||||||
//console.log("Loading ROM length", rom.length);
|
//console.log("Loading ROM length", rom.length);
|
||||||
platform.loadROM(getCurrentPresetTitle(), rom);
|
platform.loadROM(getCurrentPresetTitle(), rom);
|
||||||
@ -401,8 +401,10 @@ function setCompileOutput(data: WorkerResult) {
|
|||||||
projectWindows.setErrors([{line:0,msg:e+""}]);
|
projectWindows.setErrors([{line:0,msg:e+""}]);
|
||||||
current_output = null;
|
current_output = null;
|
||||||
}
|
}
|
||||||
|
/* TODO?
|
||||||
} else if (rom.program_rom_variable) { //TODO: a little wonky...
|
} else if (rom.program_rom_variable) { //TODO: a little wonky...
|
||||||
platform.loadROM(rom.program_rom_variable, rom.program_rom);
|
platform.loadROM(rom.program_rom_variable, rom.program_rom);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
// update all windows (listings)
|
// update all windows (listings)
|
||||||
projectWindows.refresh();
|
projectWindows.refresh();
|
||||||
|
@ -1135,7 +1135,7 @@ function compileVerilator(step) {
|
|||||||
});
|
});
|
||||||
var topmod = detectTopModuleName(code);
|
var topmod = detectTopModuleName(code);
|
||||||
var FS = verilator_mod['FS'];
|
var FS = verilator_mod['FS'];
|
||||||
populateFiles(step, FS, {mainFilePath:topmod+".v"});
|
populateFiles(step, FS, {mainFilePath:step.path});
|
||||||
writeDependencies(step.dependencies, FS, errors, function(d, code) {
|
writeDependencies(step.dependencies, FS, errors, function(d, code) {
|
||||||
return compileInlineASM(code, platform, step, errors, null);
|
return compileInlineASM(code, platform, step, errors, null);
|
||||||
});
|
});
|
||||||
@ -1144,8 +1144,9 @@ function compileVerilator(step) {
|
|||||||
verilator_mod.callMain(["--cc", "-O3", "-DEXT_INLINE_ASM", "-DTOPMOD__"+topmod,
|
verilator_mod.callMain(["--cc", "-O3", "-DEXT_INLINE_ASM", "-DTOPMOD__"+topmod,
|
||||||
"-Wall", "-Wno-DECLFILENAME", "-Wno-UNUSED", '--report-unoptflat',
|
"-Wall", "-Wno-DECLFILENAME", "-Wno-UNUSED", '--report-unoptflat',
|
||||||
"--x-assign", "fast", "--noassert", "--pins-bv", "33",
|
"--x-assign", "fast", "--noassert", "--pins-bv", "33",
|
||||||
"--top-module", topmod, topmod+".v"]);
|
"--top-module", topmod, step.path]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
errors.push({line:0,msg:"Compiler internal error: " + e});
|
errors.push({line:0,msg:"Compiler internal error: " + e});
|
||||||
}
|
}
|
||||||
endtime("compile");
|
endtime("compile");
|
||||||
|
@ -47,8 +47,8 @@ global.localStorage = {
|
|||||||
includeInThisContext("localForage/dist/localforage.js");
|
includeInThisContext("localForage/dist/localforage.js");
|
||||||
includeInThisContext("gen/util.js");
|
includeInThisContext("gen/util.js");
|
||||||
includeInThisContext("src/store.js");
|
includeInThisContext("src/store.js");
|
||||||
|
//var wtypes = require("../../gen/workertypes.js");
|
||||||
var prj = require("../../gen/project.js");
|
var prj = require("../../gen/project.js");
|
||||||
var prj = require("../../gen/workertypes.js");
|
|
||||||
|
|
||||||
var test_platform_id = "_TEST";
|
var test_platform_id = "_TEST";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user