Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <stdint.h>
- #define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
- #define BITTOP 14
- #define true 1
- #define false 0
- #define h 4
- #define v 4
- //typedef unsigned short uint16_t;
- //uint16_t uint16val;
- //0123>>3210
- //shiftal16(int data)
- shiftal16(uint16_t uval16){
- uint16_t b0,b1,b2,b3;
- b0=(uval16>>12)&0xf; //0xxx(B)->xxx0
- b1=(uval16>>8)&0xf; //1 x1xx(B)->xx1x
- b2=(uval16>>4)&0xf; //2 xx2x(B)->x2xx
- b3=(uval16)&0xf; //3 xxx3(B)->3xxx
- return (b3<<12|b2<<8|b1<<4|b0); //align & shift
- }
- //prints bit (dec) value
- int bit(int val){
- int bitcnt=0;
- for(bitcnt=BITTOP;bitcnt>=0;bitcnt--){
- if((val&(1<<bitcnt))) printf("1");
- else printf("0");}
- printf(" (");
- for(bitcnt=BITTOP;bitcnt>=0;bitcnt--){
- printf("[%d",CHECK_BIT(val,bitcnt));
- printf("]");
- }
- printf(") \n");
- }
- //counts hex string
- int hexcnt(int val){
- int pat_cnt=0;while ((val>>pat_cnt)!=0) pat_cnt=pat_cnt+1;
- pat_cnt=pat_cnt/sizeof(val);
- return pat_cnt;
- }
- //strhex(phys_add,start,pattern);
- int strhex(int memseg, int data, int pattern){
- int final=0,*temp,p1,p2;
- typedef unsigned short uint16_t;
- uint16_t uint16p1=0,uint16p2=0,datcnt16,patcnt16;
- temp=(int*)malloc(memseg);//alloc 6MB ram
- if(!temp) printf("error alocating %d bytes",memseg);
- if(!memcpy(temp,&data,sizeof(data))) //copy data into ram
- printf("error copying %d blob to p* %d",data,&temp);
- patcnt16=hexcnt(pattern); //count hex pattern
- datcnt16=hexcnt(data); //count hex data
- for(p1=sizeof(pattern)*(patcnt16+1);p1>0;p1=p1-8){ //1 word pattern 0xff
- uint16p1=(pattern >> p1-8)& 0xff;//word (2byte) pass //pointer-8 starts at index 0
- for(p2=sizeof(data)*(datcnt16+1);p2>0;p2=p2-8){//l00k3r
- uint16p2=(data >> p2-8)& 0xff;
- if(p2==(sizeof(data)*(datcnt16+1))&&p1==(sizeof(pattern)*(patcnt16+1))){
- printf("/hex------------ptr-------------status/ \n---------------------------------------- \n");
- }
- if(uint16p1==uint16p2){
- printf("(0x%x+*%d) (0x%x) found! \n ",memseg,*temp&uint16p2,uint16p2);
- bit(uint16p2);
- printf("-- \n");
- final=final+uint16p2;
- }
- }
- }
- if(final==0)printf("0x%x(0x%x), pattern:0x%x was not found!",memseg,data,pattern);
- //end
- }
- //draw(*stack_collection,n)
- draw(int* obj,int n){
- int x,last=0;
- //*obj+(inccol);
- for(x=0;x<h*n;x++){
- (*((obj+x+last)) & 1) ? printf("(%d)",
- *(obj+x+last)):printf(" - ",(obj+x+last));
- if (((x+1)%4)==0) last=last+12; //mat[0][0]+=16 //next 4x4
- }
- printf("\n");
- last=4;
- for(x=0;x<h*n;x++){
- (*((obj+x+last)) & 1) ? printf("(%d)",
- *(obj+x+last)):printf(" - ",(obj+x+last));
- if (((x+1)%4)==0) last=last+12; //mat[0][0]+=16 //next 4x4
- }
- printf("\n");
- last=8;
- for(x=0;x<h*n;x++){
- (*((obj+x+last)) & 1) ? printf("(%d)",
- *(obj+x+last)):printf(" - ",(obj+x+last));
- if (((x+1)%4)==0) last=last+12; //mat[0][0]+=16 //next 4x4
- }
- printf("\n");
- last=12;
- for(x=0;x<h*n;x++){
- (*((obj+x+last)) & 1) ? printf("(%d)",
- *(obj+x+last)):printf(" - ",(obj+x+last));
- if (((x+1)%4)==0) last=last+12; //mat[0][0]+=16 //next 4x4
- }
- }
- //allocates 4x4*n integer matrix with 0xFF
- create_buffer(int* obj,int buf_size){
- //obj+(16*26);//next buffer from abc_z (free onwards)
- int i;
- for(i=0;i<(h*v)*buf_size;i++){
- memset(obj+(16*26)+i,0xFF,1);
- }
- return 16*26;
- }
- //w_write(word,offset_start,block_size,abc_index)
- w_write(char obj[],int* temp_ptr,int size,int abc_index){
- int i,str_size,*stack_pos,alloc_buf;
- str_size=strlen(obj);
- //we need to create a buffer for n words (as read --> 4*line because printf)
- alloc_buf=create_buffer(temp_ptr,str_size);
- //upon created we point to that buffer, copy word contents to it
- for(i=0;i<str_size;i++){
- switch(*(obj+i)) //word 0x41 -- 0x7a
- {
- case(0x61): //a
- //temp_ptr+16*1; //physical abc_word address
- //obj_copy(*screen_obj,n)
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*1),64);
- break;
- case(0x62): //b
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*2),64);
- break;
- case(0x63): //c
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*3),64);
- break;
- case(0x64): //d
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*4),64);
- break;
- case(0x65): //e
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*5),64);
- break;
- case(0x66): //f
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*6),64);
- break;
- case(0x67): //g
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*7),64);
- break;
- case(0x68): //h
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*8),64);
- break;
- case(0x69): //i
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*9),64);
- break;
- case(0x6a): //j
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*10),64);
- break;
- case(0x6b): //k
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*11),64);
- break;
- case(0x6c): //l
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*12),64);
- break;
- case(0x6d): //m
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*13),64);
- break;
- case(0x6e): //n
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*14),64);
- break;
- case(0x6f): //o
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*15),64);
- break;
- case(0x70): //p
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*16),64);
- break;
- case(0x71): //q
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*17),64);
- break;
- case(0x72): //r
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*18),64);
- break;
- case(0x73): //s
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*19),64);
- break;
- case(0x74): //t
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*20),64);
- break;
- case(0x75): //u
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*21),64);
- break;
- case(0x76): //v
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*22),64);
- break;
- case(0x77): //w1+w2 (16*23 & 16*24)
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*23),64);
- break;
- case(0x78): //x
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*25),64);
- break;
- case(0x79): //y
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*26),64);
- break;
- case(0x7a): //z
- memcpy(temp_ptr+alloc_buf+(16*i),temp_ptr+(16*27),64);
- break;
- }//switch
- }//for
- //then draw
- draw(temp_ptr+alloc_buf,str_size);
- }
- int screen[h][v]={
- 0,1,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0};
- int abc_a[h][v]={
- 1,1,1,1,
- 1,0,0,1,
- 1,1,1,1,
- 1,0,0,1};
- int abc_b[h][v]={
- 1,0,0,0,
- 1,1,1,0,
- 1,0,0,1,
- 1,1,1,1};
- int abc_c[h][v]={
- 1,1,1,1,
- 1,0,0,0,
- 1,0,0,0,
- 1,1,1,1};
- int abc_d[h][v]={
- 1,1,1,0,
- 1,0,0,1,
- 1,0,0,1,
- 1,1,1,0};
- int abc_e[h][v]={
- 1,1,1,0,
- 1,0,1,0,
- 1,1,0,0,
- 1,1,1,1};
- int abc_f[h][v]={
- 1,1,1,1,
- 1,0,0,0,
- 1,1,1,0,
- 1,0,0,0};
- int abc_g[h][v]={
- 1,1,1,1,
- 1,0,0,0,
- 1,0,1,1,
- 1,1,1,1};
- int abc_h[h][v]={
- 1,0,0,1,
- 1,0,0,1,
- 1,1,1,1,
- 1,0,0,1};
- int abc_i[h][v]={
- 0,1,1,1,
- 0,0,1,0,
- 0,0,1,0,
- 0,1,1,1};
- int abc_j[h][v]={
- 0,1,1,1,
- 0,0,1,0,
- 1,0,1,0,
- 0,1,1,0};
- int abc_k[h][v]={
- 1,0,0,1,
- 1,0,1,0,
- 1,1,1,0,
- 1,0,0,1};
- int abc_l[h][v]={
- 1,0,0,0,
- 1,0,0,0,
- 1,0,0,0,
- 1,1,1,0};
- int abc_m[h][v]={
- 1,0,0,1,
- 0,1,1,0,
- 1,0,0,1,
- 1,0,0,1};
- int abc_n[h][v]={
- 1,0,0,1,
- 1,1,0,1,
- 1,0,1,1,
- 1,0,0,1};
- int abc_o[h][v]={
- 0,1,1,0,
- 1,0,0,1,
- 1,0,0,1,
- 0,1,1,0};
- int abc_p[h][v]={
- 1,1,1,1,
- 1,0,0,1,
- 1,1,1,1,
- 1,0,0,0};
- int abc_q[h][v]={
- 0,1,1,0,
- 1,0,0,1,
- 0,1,1,0,
- 0,0,0,1};
- int abc_r[h][v]={
- 1,1,1,0,
- 1,0,0,1,
- 1,1,1,0,
- 1,0,0,1};
- int abc_s[h][v]={
- 0,1,1,1,
- 1,0,0,0,
- 0,0,1,1,
- 1,1,0,0};
- int abc_t[h][v]={
- 0,1,1,1,
- 0,0,1,0,
- 0,0,1,0,
- 0,0,1,0};
- int abc_u[h][v]={
- 1,0,0,1,
- 1,0,0,1,
- 1,0,0,1,
- 0,1,1,0};
- int abc_v[h][v]={
- 1,0,0,1,
- 1,0,0,1,
- 1,0,0,1,
- 0,0,1,0};
- int abc_w1[h][v]={
- 1,0,0,0,
- 1,0,1,0,
- 0,1,0,0,
- 0,0,0,0};
- int abc_w2[h][v]={
- 0,0,1,0,
- 1,0,1,0,
- 0,1,0,0,
- 0,0,0,0};
- int abc_x[h][v]={
- 1,0,0,1,
- 0,1,0,0,
- 0,0,1,0,
- 1,0,0,1};
- int abc_y[h][v]={
- 1,0,1,0,
- 1,0,1,0,
- 0,1,0,0,
- 0,1,0,0};
- int abc_z[h][v]={
- 1,1,1,1,
- 0,0,1,0,
- 0,1,0,0,
- 1,1,1,1};
- int main(){
- //draw[fb]<-draw[font] (word)
- //draw(fb) (4*4)
- // * * * *
- // * * * *
- // * * * *
- // * * * *
- int bl_size=sizeof(screen);//blocksize
- int abc_index=(&abc_z[0][0]-&screen[0][0])/16;//abc index
- //w_write(word,offset_start,blocksize,abc[n])
- w_write("hello gbatemp",*screen,bl_size,abc_index);
- //end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement