annotate final_isi/wrapper.c @ 83:d419dc43bde4

Implement memfill().
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 19 Feb 2013 00:39:41 +0200
parents e76a4e19363d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #include "wrapper.h"
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 /** conio stuff **/
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 void gbsound(int ch,int freq)
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 {
51
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
7 if(freq)pwplib_sound_nv(ch,freq<<8,pwplib.setup[SETUP_VOLUME]);
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
8 else pwplib_sound_off(ch);
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 /** fx stuff **/
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
51
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
13 void fillbuf(char*d,short w16,int lgt) /* iku */
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 {
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 short*dd=(short*)d;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 for(;lgt;lgt--)*dd++=w16;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 /** uncrunch **/
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 /* thedraw uncrunch */
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 void uncrunch(unsigned char*src,char*dst,int lgt)
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 {
75
e76a4e19363d Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
25 char attr=0x07,
e76a4e19363d Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
26 *nxtlin = dst + 160;
e76a4e19363d Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
27
e76a4e19363d Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
28 for(;lgt>0;lgt--)
e76a4e19363d Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
29 {
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 int c=*src++;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 if(c>=32){dst[0]=c;dst[1]=attr;dst+=2;}else
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 if(c<16)attr=(attr&0xf0)|c;else
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 if(c<24)attr=(attr&0x8f)|((c-16)<<4);else
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 if(c==24){dst=nxtlin;nxtlin+=160;}else
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 if(c==25){int i=1+*src++;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 for(;i;i--){dst[0]=32;dst[1]=attr;dst+=2;}lgt--;}else
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 if(c==26){int i=1+src[0],t=src[1];src+=2;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 for(;i;i--){dst[0]=t;dst[1]=attr;dst+=2;}lgt-=2;}
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 else if(c==27)attr^=0x80;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 int mul32(int a,int b)
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 {
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 return (a*b)>>16;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 int attr2dump(char*s0,char*s1,char*d,int lgt,int ander) /* fisi */
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 {
51
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
50 int j;
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 char tmp[80*50];d=tmp;lgt=80*50;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 tmp[0]=tmp[1]=tmp[2]=tmp[3]=0;
51
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
53 for(j = lgt;j;j--)*d++=(*s0++&ander)|*s1++;
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 pwplib.videobuf.d=tmp;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 pwplib.dump_rast();
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
51
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
58 void dumpbuf(char*s,char*d,int lgt) /* iku */
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
59 {
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
60 char*tmp=pwplib.videobuf.d;
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
61 pwplib.videobuf.d=s;
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
62 pwplib.dump_rast();
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
63 pwplib.videobuf.d=tmp;
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
64 }
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
65
75
e76a4e19363d Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
66 void attrdump(char*s,char*d,int howmany) /* fisi */
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 {
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 dumpbuf(s,d,howmany>>1);
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 int dump16() /* fisi */
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 {
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 fprintf(stderr,"dump16\n"); /* fisi */
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 int dump216()
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 {
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 fprintf(stderr,"dump216\n"); /* fisi */
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
75
e76a4e19363d Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
80 void dumphybrid(uchar*a,uchar*b,uchar*d) /* fisi */
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 {
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 char tmp[80*50*2];int y=25;d=tmp;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 for(;y;y--){int x=80;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 for(;x;x--)
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 {
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 if(*a!=253){d[0]=*a;d[1]=a[1];}else
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 {int z=(b[0]&0xf0)|(b[80]>>4);
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 d[0]=z?220:32;d[1]=z;}
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 a+=2;d+=2;b++;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 }b+=80;}
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
51
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
93 // pwplib.videobuf.d=tmp;
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
94 // pwplib.dump_ibm();
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 }
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
75
e76a4e19363d Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
97 void polytxloop(sint h,char*di,uint x1,sint dx0,sint dx1,char*txr,
0
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 sint dv,sint du) /* fisi */
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 {
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 int x0=0,u=0,tpv=0;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 for(;h>0;h--){
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 {char*d=di+(x0>>8);int c=(x1>>8)&127,tp=(tpv<<4)&0xf000;
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 if(c>0)for(;c;c--){*d++=txr[(tp>>8)&0xff];tp+=du;}}
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 x0+=dx0;x1+=dx1;di+=80;tpv+=dv;/*dv*/}
acb5694e93d9 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 }
51
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
106
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
107 void memfill(void *buf, int c, size_t n)
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
108 {
83
d419dc43bde4 Implement memfill().
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
109 size_t i;
d419dc43bde4 Implement memfill().
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
110 for (i = 0; i < n; i++)
d419dc43bde4 Implement memfill().
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
111 ((sint16 *)buf)[i] = c;
51
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
112 }
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
113
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
114 void txtmode(int mode)
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
115 {
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
116 }
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
117
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
118 void picmov(char *a, char *b, int xsize, int xclip, int yclip, int method)
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
119 {
53676367d46f Hack Final Isi to "work", kind of. Requires a nasty hack in pwplib to actually run (without it, it quits abruptly .. not yet sure why.)
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
120 }