Skip to content

Commit 8a23a72

Browse files
committed
initial addition of strcpy
1 parent 72386b6 commit 8a23a72

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

keywords.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ void keywords (char **cstatement)
443443
playsfx (statement);
444444
else if (!strncmp (statement[1], "mutesfx", 8))
445445
mutesfx (statement);
446+
else if (!strncmp (statement[1], "strcpy", 6))
447+
dostrcpy (statement);
446448
else if (!strncmp (statement[1], "memcpy", 6))
447449
domemcpy (statement);
448450
else if (!strncmp (statement[1], "memset", 6))

preprocess.lex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ int linenumber=1;
1919
%x speechquotestart
2020
%x songdata
2121
%x songquotestart
22+
%x strcpy
2223
%x plotchars
2324
%x plotquotestart
2425
%x player
@@ -126,6 +127,12 @@ int linenumber=1;
126127
<plotquotestart>['] {printf("%s",yytext);BEGIN(INITIAL);}
127128
<plotquotestart>^\n* printf("%s",yytext);
128129

130+
"strcpy" {printf("%s",yytext);BEGIN(strcpy);}
131+
<strcpy>['] {printf("%s",yytext);BEGIN(plotquotestart);}
132+
<strcpy>[ \t]+ putchar(' ');
133+
<strcpy>[ \t\r]+$
134+
<strcpy>\n {linenumber++;printf("\n");BEGIN(INITIAL);}
135+
129136
"_include" printf("%s", yytext);
130137
"include" {printf("%s",yytext);BEGIN(includes);}
131138
<includes>^\n* printf("%s",yytext);

statements.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,30 @@ int inlinealphadata (char **statement)
18431843
return (quotelen);
18441844
}
18451845

1846+
void dostrcpy(char **statement)
1847+
{
1848+
// 1 2 3
1849+
// strcpy destination 'string literal'
1850+
1851+
1852+
int autotextwidth = 0;
1853+
1854+
assertminimumargs (statement, "strcpy", 2);
1855+
1856+
if (statement[3][0] == '\'')
1857+
autotextwidth = inlinealphadata (statement+1);
1858+
else
1859+
prerror ("strcpy requires a string literal");
1860+
1861+
printf(" ldy #%d\n",autotextwidth);
1862+
printf ("copystr%d\n", templabel);
1863+
printf(" lda [%s-1],y\n",statement[3]);
1864+
printf(" sta [%s-1],y\n",statement[2]);
1865+
printf(" dey\n");
1866+
printf (" bne copystr%d\n", templabel++);
1867+
}
1868+
1869+
18461870
void plotchars (char **statement)
18471871
{
18481872
// 1 2 3 4 5 6

statements.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void adjustvisible (char **);
8888
void gosub (char **);
8989
void doif (char **);
9090
void domemcpy (char **);
91+
void dostrcpy (char **);
9192
void pokechar (char **);
9293
void setfade (char **statement);
9394
void let (char **);

0 commit comments

Comments
 (0)