From 535cd7482dfc3c44c3b735d7732c375e0a081274 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sun, 13 May 2018 00:22:40 -0400 Subject: [PATCH] mode7 doc: add code that proves the Woz free DRAM refresh actually works --- mode7_demo/docs/address.c | 119 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 mode7_demo/docs/address.c diff --git a/mode7_demo/docs/address.c b/mode7_demo/docs/address.c new file mode 100644 index 00000000..357deb1b --- /dev/null +++ b/mode7_demo/docs/address.c @@ -0,0 +1,119 @@ +#include + +int main(int argc, char **argv) { + + int h[7],hpe; + int sum_a3,sum_a4,sum_a5,sum_a6; + int v[5],va,vb,vc; + int a[16],addr,i; + // hbl = horizontal blanking gate + int text=1,page1=1,page2=0,hbl=0; + int vcount=0; + int vline=0; + int refresh[128],ra[7],ras,refresh_cycles=0; + + for(i=0;i<128;i++) refresh[i]=0; + + while(1) { + h[0]=(vcount>>0)&1; + h[1]=(vcount>>1)&1; + h[2]=(vcount>>2)&1; + h[3]=(vcount>>3)&1; + h[4]=(vcount>>4)&1; + h[5]=(vcount>>5)&1; + hpe=(vcount>>6)&1; + va=(vcount>>7)&1; + vb=(vcount>>8)&1; + vc=(vcount>>9)&1; + v[0]=(vcount>>10)&1; + v[1]=(vcount>>11)&1; + v[2]=(vcount>>12)&1; + v[3]=(vcount>>13)&1; + v[4]=(vcount>>14)&1; + v[5]=(vcount>>15)&1; + + + /* First 25 cycles */ + hbl=!h[5]&&(!h[3]||!h[4]); + + int x,y,z,sum; + x=0xd; // 1101 + y=(h[5]<<2)|(h[4]<<1)|(h[3]); + z=(v[4]<<3)|(v[3]<<2)|(v[4]<<1)|(v[3]); + sum=x+y+z; + + sum_a6=(sum>>3)&1; + sum_a5=(sum>>2)&1; + sum_a4=(sum>>1)&1; + sum_a3=(sum)&1; + + a[0]=h[0]; + a[1]=h[1]; + a[2]=h[2]; + a[3]=sum_a3; + a[4]=sum_a4; + a[5]=sum_a5; + a[6]=sum_a6; + a[7]=v[0]; + a[8]=v[1]; + a[9]=v[2]; + a[10]=text&page1; + a[11]=text&page2; + a[12]=text&hbl; + a[13]=0; + a[14]=0; + a[15]=0; + + ra[0]=v[0]; + ra[1]=h[2]; + ra[2]=h[0]; + ra[3]=v[1]; + ra[4]=sum_a3; // sum0? + ra[5]=h[1]; + ra[6]=hbl; + + ras=0; + for(i=0;i<7;i++) ras|=(ra[i]<