mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-22 12:29:06 +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_vtimer;
|
||||
|
||||
reg [8:0] ball_horiz_move = -2;
|
||||
reg [8:0] ball_vert_move = 2;
|
||||
|
||||
localparam ball_horiz_stop = 204;
|
||||
localparam ball_vert_stop = 251;
|
||||
// motion codes
|
||||
reg [3:0] ball_horiz_move;
|
||||
reg [3:0] ball_vert_move;
|
||||
|
||||
// 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(
|
||||
.clk(clk),
|
||||
@ -30,15 +36,14 @@ module ball_slip_counter_top(clk, reset, hsync, vsync, rgb);
|
||||
);
|
||||
|
||||
// update horizontal timer
|
||||
always @(posedge clk or posedge reset)
|
||||
begin
|
||||
if (reset)
|
||||
ball_htimer <= ball_horiz_stop - 128;
|
||||
else if (ball_htimer == 0) begin
|
||||
if (ball_vtimer == 0)
|
||||
ball_htimer <= ball_horiz_stop + ball_horiz_move;
|
||||
else
|
||||
ball_htimer <= ball_horiz_stop;
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset || ball_htimer == 0) begin
|
||||
if (reset) // center-ish of screen
|
||||
ball_htimer <= {5'b11000, ball_horiz_move};
|
||||
else if (ball_vtimer == 0) // nudge ball in horiz. dir
|
||||
ball_htimer <= {ball_horiz_prefix, ball_horiz_move};
|
||||
else // reset timer but don't move ball horizontally
|
||||
ball_htimer <= {ball_horiz_prefix, ball_horiz_stop};
|
||||
end else
|
||||
ball_htimer <= ball_htimer + 1;
|
||||
end
|
||||
@ -46,10 +51,10 @@ module ball_slip_counter_top(clk, reset, hsync, vsync, rgb);
|
||||
// update vertical timer
|
||||
always @(posedge hsync or posedge reset)
|
||||
begin
|
||||
if (reset)
|
||||
ball_vtimer <= ball_vert_stop - 128;
|
||||
else if (ball_vtimer == 0)
|
||||
ball_vtimer <= ball_vert_stop + ball_vert_move;
|
||||
if (reset) // center-ish of screen
|
||||
ball_vtimer <= {5'b11000, ball_vert_move};
|
||||
else if (ball_vtimer == 0) // reset timer
|
||||
ball_vtimer <= {ball_vert_prefix, ball_vert_move};
|
||||
else
|
||||
ball_vtimer <= ball_vtimer + 1;
|
||||
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;
|
||||
|
||||
// vertical bounce
|
||||
always @(posedge ball_vert_collide)
|
||||
always @(posedge ball_vert_collide or posedge reset)
|
||||
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
|
||||
|
||||
// horizontal bounce
|
||||
always @(posedge ball_horiz_collide)
|
||||
always @(posedge ball_horiz_collide or posedge reset)
|
||||
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
|
||||
|
||||
// compute ball display
|
||||
|
@ -13,7 +13,7 @@ export interface Platform {
|
||||
getPresets() : Preset[];
|
||||
pause() : void;
|
||||
resume() : void;
|
||||
loadROM(title:string, rom:Uint8Array);
|
||||
loadROM(title:string, rom:any); // TODO: Uint8Array
|
||||
|
||||
inspect?(ident:string) : void;
|
||||
disassemble?(addr:number, readfn:(addr:number)=>number) : any; // TODO
|
||||
|
@ -32,11 +32,10 @@ export class CodeProject {
|
||||
worker.onmessage = (e) => {
|
||||
if (this.pendingWorkerMessages > 1) {
|
||||
this.sendBuild();
|
||||
this.pendingWorkerMessages = 0;
|
||||
} 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) {
|
||||
this.processBuildResult(e.data);
|
||||
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
|
||||
this.worker.postMessage({
|
||||
code:text,
|
||||
path:this.mainpath,
|
||||
dependencies:depends,
|
||||
platform:this.platform_id,
|
||||
tool:this.platform.getToolForFilename(this.mainpath)
|
||||
|
@ -388,7 +388,7 @@ function setCompileOutput(data: WorkerResult) {
|
||||
compparams = data.params;
|
||||
// load ROM
|
||||
var rom = data.output;
|
||||
if (rom instanceof Uint8Array) {
|
||||
if (rom) { // TODO instanceof Uint8Array) {
|
||||
try {
|
||||
//console.log("Loading ROM length", rom.length);
|
||||
platform.loadROM(getCurrentPresetTitle(), rom);
|
||||
@ -401,8 +401,10 @@ function setCompileOutput(data: WorkerResult) {
|
||||
projectWindows.setErrors([{line:0,msg:e+""}]);
|
||||
current_output = null;
|
||||
}
|
||||
/* TODO?
|
||||
} else if (rom.program_rom_variable) { //TODO: a little wonky...
|
||||
platform.loadROM(rom.program_rom_variable, rom.program_rom);
|
||||
*/
|
||||
}
|
||||
// update all windows (listings)
|
||||
projectWindows.refresh();
|
||||
|
@ -1135,7 +1135,7 @@ function compileVerilator(step) {
|
||||
});
|
||||
var topmod = detectTopModuleName(code);
|
||||
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) {
|
||||
return compileInlineASM(code, platform, step, errors, null);
|
||||
});
|
||||
@ -1144,8 +1144,9 @@ function compileVerilator(step) {
|
||||
verilator_mod.callMain(["--cc", "-O3", "-DEXT_INLINE_ASM", "-DTOPMOD__"+topmod,
|
||||
"-Wall", "-Wno-DECLFILENAME", "-Wno-UNUSED", '--report-unoptflat',
|
||||
"--x-assign", "fast", "--noassert", "--pins-bv", "33",
|
||||
"--top-module", topmod, topmod+".v"]);
|
||||
"--top-module", topmod, step.path]);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
errors.push({line:0,msg:"Compiler internal error: " + e});
|
||||
}
|
||||
endtime("compile");
|
||||
|
@ -47,8 +47,8 @@ global.localStorage = {
|
||||
includeInThisContext("localForage/dist/localforage.js");
|
||||
includeInThisContext("gen/util.js");
|
||||
includeInThisContext("src/store.js");
|
||||
//var wtypes = require("../../gen/workertypes.js");
|
||||
var prj = require("../../gen/project.js");
|
||||
var prj = require("../../gen/workertypes.js");
|
||||
|
||||
var test_platform_id = "_TEST";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user