diff --git a/include/string.h b/include/string.h index 1fe3754..c79fc18 100644 --- a/include/string.h +++ b/include/string.h @@ -23,6 +23,8 @@ void * memmove(void * dst, const void * src, int size); #pragma intrinsic(strcpy) +#pragma intrinsic(memcpy) + #pragma compile("string.c") #endif diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index ceb65dd..83dca55 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -1895,6 +1895,43 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration* } } } + else if (!strcmp(iname->mString, "memcpy")) + { + if (exp->mRight->mType == EX_LIST) + { + Expression* tex = exp->mRight->mLeft, * sex = exp->mRight->mRight->mLeft, * nex = exp->mRight->mRight->mRight; + if (nex->mDecValue->mType == DT_CONST_INTEGER && nex->mDecValue->mInteger < 128) + { + vl = TranslateExpression(procType, proc, block, tex, breakBlock, continueBlock, inlineMapper); + if (vl.mType->mType == DT_TYPE_ARRAY) + vl = Dereference(proc, block, vl, 1); + else + vl = Dereference(proc, block, vl); + + vr = TranslateExpression(procType, proc, block, sex, breakBlock, continueBlock, inlineMapper); + if (vr.mType->mType == DT_TYPE_ARRAY) + vr = Dereference(proc, block, vr, 1); + else + vr = Dereference(proc, block, vr); + + if (!TheCharPointerTypeDeclaration->CanAssign(vl.mType)) + mErrors->Error(tex->mLocation, EERR_INCOMPATIBLE_TYPES, "Cannot assign incompatible types"); + if (!TheConstCharPointerTypeDeclaration->CanAssign(vr.mType)) + mErrors->Error(sex->mLocation, EERR_INCOMPATIBLE_TYPES, "Cannot assign incompatible types"); + + InterInstruction* ins = new InterInstruction(); + ins->mCode = IC_COPY; + ins->mSrc[0].mType = IT_POINTER; + ins->mSrc[0].mTemp = vr.mTemp; + ins->mSrc[1].mType = IT_POINTER; + ins->mSrc[1].mTemp = vl.mTemp; + ins->mConst.mOperandSize = nex->mDecValue->mInteger; + block->Append(ins); + + return vl; + } + } + } else { mErrors->Error(exp->mLeft->mDecValue->mLocation, EERR_OBJECT_NOT_FOUND, "Unknown intrinsic function", iname->mString); diff --git a/samples/rasterirq/autocrawler.c b/samples/rasterirq/autocrawler.c new file mode 100644 index 0000000..e4ad754 --- /dev/null +++ b/samples/rasterirq/autocrawler.c @@ -0,0 +1,58 @@ +#include +#include +#include + +const char Text[] = + S"LABORUM RERUM QUO. QUASI IN, SEQUI, TENETUR VOLUPTATEM RERUM " + S"PORRO NON ET MAIORES ALIAS ODIO EST EOS. MAGNAM APERIAM CUM ET " + S"ESSE TEMPORE ITAQUE TEMPORA VOLUPTAS ET IPSAM IPSAM EARUM. ID " + S"SUSCIPIT QUIA RERUM REPREHENDERIT ERROR ET UT. DOLOR ID " + S"CORPORIS, EOS? UNDE VERO ISTE QUIA? EAQUE EAQUE. IN. AUT ID " + S"EXPEDITA ILLUM MOLESTIAS, "; + +// Raster interrupt command structure for change to scrolled and back + +RIRQCode scroll, restore; + +static int x; + +// Loop through text +__interrupt void doscroll(void) +{ + // Update raster IRQ for scroll line with new horizontal scroll offset + rirq_data(&scroll, 0, 7 - (x & 7)); + // Copy scrolled version of text when switching over char border + if ((x & 7) == 0) + memcpy((char *)0x0400 + 40 * 24, Text + ((x >> 3) & 255), 40); + x++; +} + +int main(void) +{ + // initialize raster IRQ + rirq_init(true); + + // Build switch to scroll line IRQ + rirq_build(&scroll, 1); + // Change control register two with this IRQ + rirq_write(&scroll, 0, &vic.ctrl2, 0); + // Put it onto the scroll line + rirq_set(0, 50 + 24 * 8, &scroll); + + // Build the switch to normal IRQ + rirq_build(&restore, 2); + // re-enable left and right column and reset horizontal scroll + rirq_write(&restore, 0, &vic.ctrl2, VIC_CTRL2_CSEL); + // call scroll copy code + rirq_call(&restore, 1, doscroll); + // place this at the top of the screen before the display starts + rirq_set(1, 4, &restore); + + // sort the raster IRQs + rirq_sort(); + + // start raster IRQ processing + rirq_start(); + + return 0; +} diff --git a/samples/rasterirq/make.bat b/samples/rasterirq/make.bat index 743f9ed..9566ce4 100644 --- a/samples/rasterirq/make.bat +++ b/samples/rasterirq/make.bat @@ -2,3 +2,4 @@ call ..\..\bin\oscar64 colorbars.c call ..\..\bin\oscar64 openborder.c call ..\..\bin\oscar64 textcrawler.c call ..\..\bin\oscar64 movingbars.c -n +call ..\..\bin\oscar64 autocrawler.c -n