Code: Select all
radiusError+=2*(y-x+1);Code: Select all
radiusError+=2*(y-x+1);Code: Select all
PLL_BASE
#(.BANDWIDTH ("OPTIMIZED"),
.CLK_FEEDBACK ("CLKFBOUT"),
.COMPENSATION ("SYSTEM_SYNCHRONOUS"),
.DIVCLK_DIVIDE (2), //100MHz/2=50MHz*14=700MHz/10=70MHz for 1024x768
.CLKFBOUT_MULT (14), //100MHz/2=50MHz*14=700MHz/28=25MHz for 640x480
.CLKFBOUT_PHASE (0.000), //100MHz/2=50MHz*18=900MHz/60=15MHz for 320x200
.CLKOUT0_DIVIDE (28), //video pixel clk
.CLKOUT0_PHASE (0.000),
.CLKOUT0_DUTY_CYCLE (0.500),
.CLKOUT1_DIVIDE (28), //cpu&system clk
.CLKOUT1_PHASE (0.000),
.CLKOUT1_DUTY_CYCLE (0.500),
.CLKOUT2_DIVIDE (28), //SyncRAM clk
.CLKOUT2_PHASE (90.000),
.CLKOUT2_DUTY_CYCLE (0.500),
.CLKIN_PERIOD (10.0),
.REF_JITTER (0.010))Code: Select all
LDA #300
STA SCRLO ;x position
LDA #375
STA SCRHI ;y position
LDX #76 ;use X reg for easy test for end of y position
CHSH2 LDY #$00
LDWi $0064 ;LDW #100
CHSH LDA (SCRLO),Y
STAiw (SCRLO),W ;STA (SCRLO),W
INW
INY
CPY #76
BNE CHSH
INC SCRHI
DEX
BNE CHSH2Code: Select all
`timescale 1ns / 1ps
module SRAMif( input clk,
input [15:0] cpuDO,
input vramCS, //cpu is reading/writing to videoRAM
input lineCS, //lineGen is writing to videoRAM
input cpuWE,
input RAMWE, //LineGen is drawing
inout [15:0] SRD,
input [15:0] QACCout, //pixel color from cpu
input [9:0] X, //LSB of LineGen address
input [9:0] Y, //MSB
input [20:0] Vaddr, //pixel clock address from HVSync Generator
input [31:0] cpuAB,
output [20:0] SRaddr,
output reg [15:0] SRDO, //to cpu
output SRWEn,
input CB0, //Control Bit 0 from cpu to control page 0 or 1, when page flipping
input CB1, //Control Bit 1 from cpu to control page flipping or scrolling
input CB2, //Control Bit 2 scrolling horizontal or vertical
output reg RDY = 1 //RDY = 0 halts cpu
);
reg SRWEn2;
reg [15:0] SRDI;
always @(posedge clk) begin
SRWEn2 <= SRWEn;
if (RAMWE && !vramCS) begin //hardware module selected
SRDO <= 16'h0000;
SRDI <= QACCout;
RDY <= 1;
end
if (RAMWE && (vramCS && cpuWE)) begin //collision, if both selected favor hardware module
SRDO <= 16'h0000;
SRDI <= QACCout;
RDY <= 1;
end
if (RAMWE && (vramCS && !cpuWE)) begin //collision, favor cpu read from video
SRDO <= SRD;
SRDI <= 16'hZZZZ;
RDY <= 0;
end
if (!RAMWE && (vramCS && cpuWE)) begin //cpu write to video
SRDO <= 16'h0000;
SRDI <= cpuDO;
RDY <= 1;
end
if (!RAMWE && (vramCS && !cpuWE)) begin //cpu read from video
SRDO <= SRD;
SRDI <= 16'hZZZZ;
RDY <= 0;
end
if (!RAMWE && !vramCS) begin //nothing selected
SRDO <= 16'h0000;
SRDI <= 16'hZZZZ;
RDY <= 1;
end
end
reg [20:0] cpuABopt;
always @* //optimize the videoRAM address for plotting (X,Y) in the (LSB,MSB) for indirect indexed
begin //CB1 = 0, page flipping
cpuABopt [20] <= CB0; //bank bit
cpuABopt [19:10] <= cpuAB [31:16]; //Y[9:0]
cpuABopt [9:0] <= cpuAB [15:0]; //X[9:0]
end
assign SRWEn = !(RAMWE || (vramCS && cpuWE));
assign SRaddr = RAMWE ? { CB0, Y, X } : vramCS ? cpuABopt : Vaddr;
assign SRD = SRWEn2 ? 16'hZZZZ : SRDI; //I/O MUX'd latch to SyncRAM databus. High 'Z' during a read
endmoduleCode: Select all
PLTRNG LDA $C0000000 ; READ RNG VALUE
PHA
PHA
PHA
PHA
CLC
LDX TXSTART
PLA ;TENS
AND #%1111000000000000 ;GET TENTHS OF A SECOND BCD DIGIT
LSRAopA12 ;SHIFT IT RIGHT
TAY
LDA HEXLUT,Y
LDY TY
JSR PLTCHR
CLC
LDA TXSTART
ADC #8
TAX
PLA ;HUNDREDS
AND #%0000111100000000
LSRAopA8
TAY
LDA HEXLUT,Y
LDY TY
JSR PLTCHR
CLC
LDA TXSTART
ADC #16
TAX
PLA ;THOUSANDS
AND #%0000000011110000
LSRAopA4
TAY
LDA HEXLUT,Y
LDY TY
JSR PLTCHR
CLC
LDA TXSTART
ADC #24
TAX
PLA ;TEN THOUSANDS
AND #%0000000000001111
TAY
LDA HEXLUT,Y
LDY TY
JSR PLTCHR
RTSCode: Select all
LDA #400
STA TXSTART
LDA #0
STA TY
JSR $00000244