/* * dump switch table */ void dumpsw (INTPTR_T *ws) /*int ws[];*/ { INTPTR_T i,j; // gdata (); gnlabel (ws[WSTAB]); if (ws[WSCASEP] != swstp) { j = ws[WSCASEP]; while (j < swstp) { defword (); i = 4; while (i--) { outdec (swstcase[j]); outbyte (','); outlabel (swstlab[j++]); if ((i == 0) | (j >= swstp)) { newl (); break; } outbyte (','); } } } defword (); outlabel (ws[WSDEF]); outstr (",0"); newl(); // gtext (); }
int main(int,char *) { copy(Im.all_pts(),0,Im.out()); copy ( line(Pt2di(0,0),Pt2di(99,99)), BLEU, Im.out() ); show(); copy ( line_4c(Pt2di(10,0),Pt2di(89,99)), VERT, Im.out() ); show(); copy ( line ( newl(Pt2di(50,30)) + Pt2di(70,50) + Pt2di(50,70) + Pt2di(30,50) ), NOIR, Im.out() ); show(); copy ( line ( newl(Pt2di(50,30)) + Pt2di(70,50) + Pt2di(50,70) + Pt2di(30,50), true ), NOIR, Im.out() ); show(); copy ( line_4c ( newl(Pt2di(50,30)) + Pt2di(70,50) + Pt2di(50,70) + Pt2di(30,50) ), ROUGE, Im.out() ); show(); return 0; }
int main() { short i, k; int a; for (i = 1; i < 9; i++) { printf("%d)Put in place the number?: ", i); scanf("%d/n", &a); newl(a); } printf("How to show?: "); scanf("%d", &k); for (i = 1; i <= k; i++) { if (i != k) { printf("%d,", ADR2->num); exitl(); } else { printf("%d", ADR2->num); exitl(); } } getchar(); getchar(); return (0); }
void doload_backgroundstatement(void) { /* syntax is name of the beginning of the data pattern : identifier name of the 16 palettes : identifier name of the bat : identifier width (in tiles [8x8] ) : integer height (in tiles [8x8] ) : integer */ flush_ins(); /* David, optimize.c related */ ot("_load_background\t"); if (outnameunderline()) return; if (outcomma()) return; if (outnameunderline()) return; if (outcomma()) return; if (outnameunderline()) return; if (outcomma()) return; if (outconst()) return; if (outcomma()) return; if (outconst()) return; newl(); needbrack(")"); }
void doload_spritesstatement(void) { /* syntax is offset in vram to load data at : integer name of the data to transfert : identifier number of sprites (of size 32x64) to load : integer */ flush_ins(); /* David, optimize.c related */ ot("load_sprites\t"); outconst(); if (outcomma()) return; if (outnameunderline()) return; if (!match(",")) { outstr(",#"); outdec(1); } else { outbyte(','); outconst(); } newl(); needbrack(")"); }
void doset_sprpalstatement(void) { /* syntax is number of the first palette to alter : integer name of the data for loading palettes : identifier [ number of palette to load : integer ] if last argument is missing, 1 is assumed */ flush_ins(); /* David, optimize.c related */ ot("_set_sprpal\t"); outconst(); if (outcomma()) return; if (outnameunderline()) return; if (!match(",")) { outstr(",#"); outdec(1); } else { outbyte(','); outconst(); } newl(); needbrack(")"); }
/* * gnlabel - generate numeric label */ void gnlabel (INTPTR_T nlab) /*int nlab; */ { flush_ins(); /* David - optimize.c related */ outlabel (nlab); col (); newl (); }
/* * glabel - generate label */ void glabel (char *lab) /*char *lab;*/ { flush_ins(); /* David - optimize.c related */ prefix (); outstr (lab); col (); newl (); }
void readline (void) { int k; FILE *unit; FOREVER { if (feof (input)) return; if ((unit = input2) == NULL) unit = input; kill_line (); while ((k = fgetc (unit)) != EOF) { if ((k == '\r') | (k == EOL) | (lptr >= LINEMAX)) break; line[lptr++] = k; } line_number++; line[lptr] = 0; if (k <= 0) if (input2 != NULL) { if (globals_h_in_process) { /* Add special treatment to ensure globals.h stuff appears at the beginning */ dumpglbs(); ol(".code"); globals_h_in_process = 0; } input2 = inclstk[--inclsp]; line_number = inclstk_line[inclsp]; fclose (unit); } if (lptr) { if ((ctext) & (cmode)) { flush_ins(); comment (); outstr (line); newl (); } lptr = 0; return; } } }
void lena_for_ever() { Video_Display Ecr((char *) NULL); Gray_Pal Pgray (30); Disc_Pal Pdisc = Disc_Pal::P8COL(); Elise_Set_Of_Palette SOP(newl(Pgray)+Pdisc); Ecr.load(SOP); Video_Win W (Ecr,SOP,Pt2di(50,50),Pt2di(SZX,SZY)); Elise_File_Im FLena("../IM_ELISE/lena",2,SXY,GenIm::u_int1,1,0); Im2D_U_INT1 I(SZX,SZY); ELISE_COPY ( W.all_pts(), FLena.in(), W.ogray() | I.out() ); bench_dilate_simple(W,I); bench_zonec_simple(W,I); }
void lena_for_ever() { Gray_Pal Pgray (30); Disc_Pal Pdisc = Disc_Pal::P8COL(); Elise_Set_Of_Palette SOP(newl(Pgray)+Pdisc); Video_Display Ecr((char *) NULL); Ecr.load(SOP); Video_Win Wv (Ecr,SOP,Pt2di(50,50),Pt2di(SZX,SZY)); PS_Display disp("TMP/test.ps","Mon beau fichier ps",SOP); Pt2di NBW(4,20); Pt2di sz(200,100); Mat_PS_Window mps(disp,sz,Pt2dr(2.0,2.0),NBW,Pt2dr(0.5,0.1)); for (int x = 0; x < NBW.x ; x++) for (int y = 0; y < NBW.y ; y++) { mps(x,y).fill_rect(Pt2di(0,0),sz,Pgray((y*255)/( NBW.y-1))); mps(x,y).draw_rect(Pt2di(0,0),sz,Pdisc(P8COL::red)); } /* PS_Window Wps = disp.w_centered_max(Pt2di(SZX,SZY),Pt2dr(0.0,8.0)); Elise_File_Im FLena("../IM_ELISE/lena",Pt2di(SZX,SZY),GenIm::u_int1); Im2D_U_INT1 I(SZX,SZY); Col_Pal red = Pdisc(P8COL::red); Col_Pal blue = Pdisc(P8COL::blue); Col_Pal green = Pdisc(P8COL::green); Col_Pal black = Pdisc(P8COL::black); Col_Pal cyan = Pdisc(P8COL::cyan); Col_Pal white = Pdisc(P8COL::white); Col_Pal yellow = Pdisc(P8COL::yellow); El_Window W = Wv|Wps; ELISE_COPY ( Wps.all_pts(), 32*(FLena.in()/32), W.ogray()|I.out() ); W.fill_rect(Pt2dr(100,200),Pt2dr(400,300),yellow); Line_St s1 (red,3); Line_St s2 (green,2); Plot_1d Plot1 (W,s1,s2,Interval(-10,10),newl(PlBox(50,50,300,400))); Plot1.show_axes(); Plot1.show_axes ( newl(PlBox(150,150,250,250)) + PlOriY(0.2) + PlAxeSty(s2) ); Plot_1d Plot2(W,s1,s2,Interval(-100,100)); Plot1.show_box ( newl(PlBox(150,150,250,250)) + PlBoxSty(cyan,2) ); Plot2.set ( newl(PlBox(20,200,400,400)) + PlOriY(0.4) + PlAxeSty(Line_St(Pdisc(P8COL::yellow),1)) + PlBoxSty(Line_St(black,2)) + PlClearSty(white) ); Plot2.show_axes(); Plot2.show_box(); Plot2.plot(10*sin(FX/4.0)); Plot2.plot ( 10*sin(FX/4.0), newl(PlIntervBoxX(-50,50)) + PlotLinSty(red,2) ); Plot2.plot ( 10*sin(FX/4.0), newl( PlotLinSty(blue,2) ) + PlIntervPlotX(-30,70) + PlAutoScalY(true) + PlShAxes(true) + PlAxeSty(cyan,3) ); Plot2.plot ( 10*(1.2+sin(FX/4.0)), newl( PlotLinSty(red,2) ) + PlAutoScalOriY(true) + PlShAxes(true) + PlAxeSty(cyan,2) + PlAutoClear(true) ); Plot2.clear(newl(PlClearSty(Pgray(196)))); Plot2.plot ( 50*cos(FX/9.0), newl(PlotLinSty(Pdisc(P8COL::red))) + PlClipY(false) + PlStepX(1.0) ); Plot2.plot ( 70*sin(square(FX) / 500.0), newl(PlotLinSty(Pdisc(P8COL::blue))) + PlClipY(true) + PlStepX(0.15) ); Plot2.set ( newl(PlBox(20,0,400,200)) ); Plot2.set(newl(PlIntervBoxX(-20,20))); Plot2.clear(); Plot2.plot ( 10 * cos(FX/4.0), newl(PlotFilSty(green)) + PlClipY(false) + PlModePl(Plots::fill_box) ); Plot2.plot ( 10 * cos(FX/4.0), newl(PlotFilSty(red)) + PlClipY(true) + PlModePl(Plots::fill_box) ); Plot2.plot ( 10 * cos(FX/4.0), newl(PlotLinSty(black,2)) + PlClipY(true) + PlModePl(Plots::draw_box) + PlShAxes(true) + PlAxeSty(Line_St(Pdisc(P8COL::blue),2)) ); cout << "aaaaaaaaaa\n"; getchar(); */ }
/* * ol * Input : char* ptr * Output : nothing * * Writes the string ptr to the assembler file, preceded by a tab, ended by * a newline * */ void ol (char *ptr) /*char ptr[]; */ { ot (ptr); newl (); }
void do_inc_ex(int type) { int end; int i; INTPTR_T j; int num; int nb_tile; char label[NAMESIZE]; char label2[NAMESIZE]; char str[NAMESIZE+32]; struct { char fname[FILENAMESIZE]; INTPTR_T arg[5]; } tiles[16]; if(!match("(")) { error("missing '('"); kill_line(); return; } readstr(); /* read the label name */ strcpy(label, litq2); strcpy(label2, litq2); strcpy(str, "__data__"); for(i = (int)strlen(label2), j = 0; i < NAMEMAX; i++) label2[i] = str[j++]; label2[i] = '\0'; addglb(label2, ARRAY, CINT, 0, EXTERN); addglb(label, ARRAY, CINT, 0, EXTERN); if(!match(",")) { error("comma missing"); kill_line(); return; } end = 0; num = 0; nb_tile = 0; while (!end) { // if (match("\\")); if(!readqstr()) { error("not a file name"); kill_line(); return; } if(!match(",")) { error("comma missing"); kill_line(); return; } strcpy(tiles[num].fname, litq2); for (i = 0; i < 5; i++) { // if (match("\\")); if(!number(&tiles[num].arg[i])) { error("not a number"); kill_line(); return; } if (match(")")) { if (i == 4) { kill_line(); end = 1; break; } else { error("arg missing"); kill_line(); return; } } if(!match(",")) { error("comma missing"); kill_line(); return; } while((ch() == ' ') || (ch() == '\t')) gch(); if (ch() == '\0') { error("arg missing"); kill_line(); return; } } nb_tile += tiles[num].arg[2] * tiles[num].arg[3]; num++; if (num == 16) { if(!end) { error("too many args (max 16 files)"); kill_line(); return; } } } /* create const array to hold extra infos */ new_const(); const_val[const_val_idx++] = const_data_idx; /* number of tile */ sprintf(str, "%i", nb_tile); add_buffer(str, '('); const_data[const_data_idx++] = '\0'; const_val[const_val_idx++] = const_data_idx; /* tile size */ sprintf(str, "%i", type); add_buffer(str, '('); const_data[const_data_idx++] = '\0'; const_val[const_val_idx++] = const_data_idx; /* tile bank */ sprintf(str, "BANK(_%s)", label2); add_buffer(str, '('); const_data[const_data_idx++] = '\0'; const_val[const_val_idx++] = const_data_idx; /* tile addr */ sprintf(str, " _%s", label2); add_buffer(str, '('); const_data[const_data_idx++] = '\0'; const_val[const_val_idx++] = -(litptr + 1024); /* pal idx table addr */ add_const(CINT); /* create pal idx table */ for(i = 0; i < num; i++) { j = tiles[i].arg[2] * tiles[i].arg[3]; while (j) { j--; if (litptr < LITMAX) litq[litptr++] = (tiles[i].arg[4] << 4); } } /* dump incchr/tile cmds */ ol(".data"); if (type == 8) ol(".dw $0800"); else ol(".dw $1000"); prefix(); outstr(label2); outstr(":\n"); for(i = 0; i < num; i++) { if (type == 8) ot(".incchr \""); else ot(".inctile \""); outstr(tiles[i].fname); outstr("\""); for (j = 0; j < 4; j++) { outstr(","); outdec(tiles[i].arg[j]); } newl(); } ol(".code"); kill_line(); }
void dopsddef(void) { int numericarg = 0; INTPTR_T dummy; INTPTR_T dummy_array[16]; int i; if (amatch("pal",3)) { if (!match("(")) error("missing ("); readstr(); /* read the label name */ addglb_far(litq2, CINT); if (!match(",")) { error("missing ',' in #defpal"); kill_line(); return; } numericarg = 0; while (!match(")")) { number(&dummy_array[numericarg]); numericarg++; if (numericarg>16) error("No more than 16 colors can be defined at once"); match(","); } ol(".data"); prefix(); outstr(litq2); outstr(":"); ot(".defpal "); for (i = 0; i < numericarg; i++) { outhexfix(dummy_array[i],3); if (i < numericarg - 1) { outstr(","); if (i == 7) { outstr(" \\\n"); ot("\t"); } } } newl(); ol(".code"); kill_line(); } else if (amatch("chr",3)) { if (!match("(")) error("missing ("); ol(".data"); readstr(); /* read the label name */ prefix(); outstr(litq2); outstr(":"); addglb_far(litq2, CINT); if (!match(",")) { error("missing ,"); kill_line(); return; } ot(".defchr "); numericarg = 0; while (!match(")")) { numericarg++; number(&dummy); switch (numericarg) { case 1: outhexfix(dummy,4); outstr(","); break; case 2: outdec(dummy); outstr(",\\"); newl(); break; case 10: outhexfix(dummy,8); break; default: outhexfix(dummy,8); outstr(",\\"); newl(); } match(","); } newl(); ol(".code"); if (numericarg!=10) error("You must enter the VRAM address, the default palette and 8 values for pattern"); kill_line(); } else if (amatch("spr",3)) { if (!match("(")) error("missing ("); ol(".data"); readstr(); /* read the label name */ prefix(); outstr(litq2); outstr(":"); addglb_far(litq2, CINT); if (!match(",")) { error("missing ,"); kill_line(); return; } ot(".defspr "); numericarg = 0; while (!match(")")) { numericarg++; number(&dummy); switch (numericarg) { case 1: outhexfix(dummy,4); outstr(","); break; case 2: outdec(dummy); outstr(",\\"); newl(); break; case 34: outhexfix(dummy,8); break; default: outhexfix(dummy,8); outstr(","); if (!(numericarg & 1)) { outstr("\\"); newl(); } } match(","); } newl(); ol(".code"); if (numericarg!=34) error("You must enter the VRAM address, the default palette and 32 values for pattern"); kill_line(); } else { error("Unknown define directive"); kill_line(); } return; }
void dopsdinc(void) { INTPTR_T dummy; /* Used in the qstr function, I don't know its utility yet */ int numericarg = 0; /* Number of numeric arg to test validity */ if (amatch("pal",3)) { if (!match("(")) error("missing ("); ol(".data"); ol(".dw $0"); readstr(); /* read the label name */ prefix(); outstr(litq2); outstr(":\n"); addglb_far(litq2, CINT); if (!match(",")) { error("missing ,"); kill_line(); return; } ot(".incpal \""); if (readqstr() == 0) /* read the filename */ { error("bad filename in incpal"); kill_line(); return; } outstr(litq2); outstr("\""); if (match(",")) outstr(","); numericarg = 0; while (!match(")")) { numericarg++; number(&dummy); outdec(dummy); if (match(",")) outstr(","); } newl(); ol(".code"); if (numericarg>2) error("Maximum 2 numeric arg for incpal(name,\"filename\" [,start_pal] [,nb_pal])"); kill_line(); } else if (amatch("bin",3)) { if (!match("(")) error("missing ("); ol(".data"); ol(".dw $0"); readstr(); /* read the label name */ prefix(); outstr(litq2); outstr(":\n"); addglb_far(litq2, CCHAR); if (!match(",")) { error("missing ,"); kill_line(); return; } ot(".incbin \""); if (readqstr() == 0) /* read the filename */ { error("bad filename in incbin"); kill_line(); return; } outstr(litq2); outstr("\"\n"); if (!match(")")) error("missing )"); newl(); ol(".code"); kill_line(); } else if (amatch("bat",3)) { if (!match("(")) error("missing ("); ol(".data"); ol(".dw $0"); readstr(); /* read the label name */ prefix(); outstr(litq2); outstr(":\n"); addglb_far(litq2, CINT); if (!match(",")) { error("missing ,"); kill_line(); return; } ot(".incbat \""); if (readqstr() == 0) { error("bad filename in incbat"); kill_line(); return; } outstr(litq2); outstr("\""); if (match(",")) outstr(","); numericarg = 0; while (!match(")")) { numericarg++; number(&dummy); outdec(dummy); if (match(",")) outstr(","); } newl(); ol(".code"); if ((numericarg!=1) && (numericarg!=3) && (numericarg!=5)) error("Either 1,3 or 5 numeric arguments are needed for incbat statement"); kill_line(); } else if (amatch("spr",3)) { if (!match("(")) error("missing ("); ol(".data"); ol(".dw $0"); readstr(); /* read the label name */ prefix(); outstr(litq2); outstr(":\n"); addglb_far(litq2, CINT); if (!match(",")) { error("missing ,"); kill_line(); return; } ot(".incspr \""); if (readqstr() == 0) { error("bad filename in incspr"); kill_line(); return; } outstr(litq2); outstr("\""); if (match(",")) outstr(","); numericarg = 0; while (!match(")")) { numericarg++; number(&dummy); outdec(dummy); if (match(",")) outstr(","); } newl(); ol(".code"); if ((numericarg!=0) && (numericarg!=2) && (numericarg!=4)) error("Either 0,2 or 4 numeric arguments are needed for incspr statement"); kill_line(); } else if (amatch("chr",3)) { if (!match("(")) error("missing ("); ol(".data"); ol(".dw $0800"); readstr(); /* read the label name */ prefix(); outstr(litq2); outstr(":\n"); addglb_far(litq2, CINT); if (!match(",")) { error("missing ,"); kill_line(); return; } ot(".incchr \""); if (readqstr() == 0) { error("bad filename in incchr"); kill_line(); return; } outstr(litq2); outstr("\""); if (match(",")) outstr(","); numericarg = 0; while (!match(")")) { numericarg++; number(&dummy); outdec(dummy); if (match(",")) outstr(","); } newl(); ol(".code"); if ((numericarg!=0) && (numericarg!=2) && (numericarg!=4)) error("Either 0,2 or 4 numeric arguments are needed for incchr statement"); kill_line(); } else if (amatch("chr_ex",6)) { do_inc_ex(8); } else if (amatch("tile",4)) { if (!match("(")) error("missing ("); ol(".data"); ol(".dw $1000"); readstr(); /* read the label name */ prefix(); outstr(litq2); outstr(":\n"); addglb_far(litq2, CINT); if (!match(",")) { error("missing ,"); kill_line(); return; } ot(".inctile \""); if (readqstr() == 0) { error("bad filename in inctile"); kill_line(); return; } outstr(litq2); outstr("\""); if (match(",")) outstr(","); numericarg = 0; while (!match(")")) { numericarg++; number(&dummy); outdec(dummy); if (match(",")) outstr(","); } newl(); ol(".code"); if ((numericarg!=0) && (numericarg!=2) && (numericarg!=4)) error("Either 0,2 or 4 numeric arguments are needed for inctile statement"); kill_line(); } else if (amatch("tile_ex",7)) { do_inc_ex(16); } else { error("Unknown include directive"); kill_line(); } return; }