diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 265dda1..e2f4030 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -4081,7 +4081,7 @@ bool NativeCodeBasicBlock::LoadOpStoreIndirectValue(InterCodeProcedure* proc, co AsmInsType at = ASMIT_ADC, an = ASMIT_ADC; AsmInsMode am = oins->mSrc[oindex].mTemp < 0 ? ASMIM_IMMEDIATE : ASMIM_ZERO_PAGE, ram = ASMIM_INDIRECT_Y, wam = ASMIM_INDIRECT_Y; - bool reverse = false; + bool reverse = false, sfinal = wins->mSrc[0].mFinal; switch (oins->mOperator) { @@ -4212,6 +4212,9 @@ bool NativeCodeBasicBlock::LoadOpStoreIndirectValue(InterCodeProcedure* proc, co mIns.Push(NativeCodeInstruction(at, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[oins->mSrc[oindex].mTemp] + i)); } + if (!sfinal) + mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[wins->mSrc[0].mTemp] + i)); + at = an; if (wam == ASMIM_INDIRECT_Y) { @@ -6692,6 +6695,29 @@ NativeCodeBasicBlock* NativeCodeBasicBlock::BinaryOperator(InterCodeProcedure* p mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_IMMEDIATE, 0x00)); mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, treg + 1)); } + else if (shift >= 5) + { + if (ins->mSrc[1].mTemp != ins->mDst.mTemp) + { + mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp] + 1)); + mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, treg)); + mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, BC_REG_TMP + proc->mTempOffset[ins->mSrc[1].mTemp])); + } + else + { + mIns.Push(NativeCodeInstruction(ASMIT_LDA, ASMIM_ZERO_PAGE, treg)); + mIns.Push(NativeCodeInstruction(ASMIT_LDX, ASMIM_ZERO_PAGE, treg + 1)); + mIns.Push(NativeCodeInstruction(ASMIT_STX, ASMIM_ZERO_PAGE, treg)); + } + mIns.Push(NativeCodeInstruction(ASMIT_ASL, ASMIM_IMPLIED)); + for (int i = shift; i < 8; i++) + { + mIns.Push(NativeCodeInstruction(ASMIT_ROL, ASMIM_ZERO_PAGE, treg)); + mIns.Push(NativeCodeInstruction(ASMIT_ROL, ASMIM_IMPLIED)); + } + mIns.Push(NativeCodeInstruction(ASMIT_AND, ASMIM_IMMEDIATE, 0xff >> shift)); + mIns.Push(NativeCodeInstruction(ASMIT_STA, ASMIM_ZERO_PAGE, treg + 1)); + } else { if (ins->mSrc[1].mTemp != ins->mDst.mTemp) @@ -14135,6 +14161,21 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(int pass) mIns[i + 2].mType = ASMIT_STY; progress = true; } + else if ( + mIns[i + 0].mType == ASMIT_STA && mIns[i + 0].mMode == ASMIM_ZERO_PAGE && + mIns[i + 1].mType == ASMIT_LDA && !mIns[i + 1].SameEffectiveAddress(mIns[i + 0]) && + mIns[i + 2].IsShift() && mIns[i + 2].SameEffectiveAddress(mIns[i + 0])) + { + AsmInsType type = mIns[i + 2].mType; + + mIns[i + 2] = mIns[i + 1]; + mIns[i + 1] = mIns[i + 0]; + + mIns[i + 0].mType = type; + mIns[i + 0].mMode = ASMIM_IMPLIED; + mIns[i + 0].mLive |= LIVE_CPU_REG_A; + progress = true; + } #if 1 if ( mIns[i + 0].mType == ASMIT_LDY && mIns[i + 0].mMode == ASMIM_IMMEDIATE && mIns[i + 0].mAddress <= 1 && @@ -14716,6 +14757,20 @@ bool NativeCodeBasicBlock::PeepHoleOptimizer(int pass) progress = true; } } + else if ( + mIns[i + 0].mType == ASMIT_LDA && mIns[i + 0].mMode != ASMIM_ZERO_PAGE && + mIns[i + 1].mType == ASMIT_STA && mIns[i + 1].mMode == ASMIM_ZERO_PAGE && + mIns[i + 2].mType == ASMIT_SEC && + mIns[i + 3].mType == ASMIT_LDA && !mIns[i + 3].UsesZeroPage(mIns[i + 1].mAddress) && + mIns[i + 4].mType == ASMIT_SBC && mIns[i + 4].mMode == ASMIM_ZERO_PAGE && mIns[i + 4].mAddress == mIns[i + 1].mAddress && !(mIns[i + 4].mLive & LIVE_MEM)) + { + mIns[i + 4] = mIns[i + 0]; + mIns[i + 4].mType = ASMIT_SBC; + + mIns[i + 0].mType = ASMIT_NOP; mIns[i + 0].mMode = ASMIM_IMPLIED; + mIns[i + 1].mType = ASMIT_NOP; mIns[i + 1].mMode = ASMIM_IMPLIED; + progress = true; + } #endif } @@ -16216,7 +16271,8 @@ void NativeCodeProcedure::CompileInterBlock(InterCodeProcedure* iproc, InterCode iblock->mInstructions[i + 1]->mCode == IC_BINARY_OPERATOR && iblock->mInstructions[i + 1]->mSrc[0].mTemp == ins->mDst.mTemp && iblock->mInstructions[i + 1]->mSrc[0].mFinal && iblock->mInstructions[i + 2]->mCode == IC_STORE && - iblock->mInstructions[i + 2]->mSrc[0].mTemp == iblock->mInstructions[i + 1]->mDst.mTemp && iblock->mInstructions[i + 2]->mSrc[0].mFinal && + iblock->mInstructions[i + 2]->mSrc[0].mTemp == iblock->mInstructions[i + 1]->mDst.mTemp && + (iblock->mInstructions[i + 2]->mSrc[0].mFinal || iblock->mInstructions[i + 2]->mSrc[0].mTemp != ins->mSrc[0].mTemp) && block->LoadOpStoreIndirectValue(iproc, ins, iblock->mInstructions[i + 1], 1, iblock->mInstructions[i + 2])) { i += 2; @@ -16226,7 +16282,8 @@ void NativeCodeProcedure::CompileInterBlock(InterCodeProcedure* iproc, InterCode iblock->mInstructions[i + 1]->mCode == IC_BINARY_OPERATOR && iblock->mInstructions[i + 1]->mSrc[1].mTemp == ins->mDst.mTemp && iblock->mInstructions[i + 1]->mSrc[1].mFinal && iblock->mInstructions[i + 2]->mCode == IC_STORE && - iblock->mInstructions[i + 2]->mSrc[0].mTemp == iblock->mInstructions[i + 1]->mDst.mTemp && iblock->mInstructions[i + 2]->mSrc[0].mFinal && + iblock->mInstructions[i + 2]->mSrc[0].mTemp == iblock->mInstructions[i + 1]->mDst.mTemp && + (iblock->mInstructions[i + 2]->mSrc[0].mFinal || iblock->mInstructions[i + 2]->mSrc[0].mTemp != ins->mSrc[0].mTemp) && block->LoadOpStoreIndirectValue(iproc, ins, iblock->mInstructions[i + 1], 0, iblock->mInstructions[i + 2])) { i += 2; diff --git a/oscar64/oscar64.cpp b/oscar64/oscar64.cpp index 161eb9d..b323353 100644 --- a/oscar64/oscar64.cpp +++ b/oscar64/oscar64.cpp @@ -73,7 +73,7 @@ int main2(int argc, const char** argv) #else strcpy(strProductName, "oscar64"); - strcpy(strProductVersion, "1.4.79"); + strcpy(strProductVersion, "1.4.80"); #ifdef __APPLE__ uint32_t length = sizeof(basePath); diff --git a/oscar64/oscar64.rc b/oscar64/oscar64.rc index e32e466..9dcf7ed 100644 --- a/oscar64/oscar64.rc +++ b/oscar64/oscar64.rc @@ -25,8 +25,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,79,0 - PRODUCTVERSION 1,4,79,0 + FILEVERSION 1,4,80,0 + PRODUCTVERSION 1,4,80,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -43,12 +43,12 @@ BEGIN BEGIN VALUE "CompanyName", "oscar64" VALUE "FileDescription", "oscar64 compiler" - VALUE "FileVersion", "1.4.79.0" + VALUE "FileVersion", "1.4.80.0" VALUE "InternalName", "oscar64.exe" VALUE "LegalCopyright", "Copyright (C) 2021" VALUE "OriginalFilename", "oscar64.exe" VALUE "ProductName", "oscar64" - VALUE "ProductVersion", "1.4.79.0" + VALUE "ProductVersion", "1.4.80.0" END END BLOCK "VarFileInfo" diff --git a/oscar64setup/oscar64setup.vdproj b/oscar64setup/oscar64setup.vdproj index 0c3c570..301656f 100644 --- a/oscar64setup/oscar64setup.vdproj +++ b/oscar64setup/oscar64setup.vdproj @@ -286,6 +286,12 @@ } "Entry" { + "MsmKey" = "8:_67C8F824E02B4211B315AB32AB7ABBB1" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_67F949223D154D92A9EC79A2A9CD1C97" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -316,6 +322,12 @@ } "Entry" { + "MsmKey" = "8:_749F54DFBD4D404DA9C2E2D5BA7CDDBF" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_79985361F09A43299E258E1A8E5ED934" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -430,6 +442,12 @@ } "Entry" { + "MsmKey" = "8:_9D4472D86BDF48E387059DCB67990AA9" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_9D5C03E361EC4766AF0204219047B6C8" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -1745,6 +1763,26 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_67C8F824E02B4211B315AB32AB7ABBB1" + { + "SourcePath" = "8:..\\samples\\games\\breakout.c" + "TargetName" = "8:breakout.c" + "Tag" = "8:" + "Folder" = "8:_BC04C0DDE264410096618981E4E890DA" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_67F949223D154D92A9EC79A2A9CD1C97" { "SourcePath" = "8:..\\samples\\hires\\cube3d.c" @@ -1845,6 +1883,26 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_749F54DFBD4D404DA9C2E2D5BA7CDDBF" + { + "SourcePath" = "8:..\\samples\\resources\\breakoutchars.bin" + "TargetName" = "8:breakoutchars.bin" + "Tag" = "8:" + "Folder" = "8:_758C6547998745659548D0656D380FEA" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_79985361F09A43299E258E1A8E5ED934" { "SourcePath" = "8:..\\include\\gfx\\mcbitmap.c" @@ -2225,6 +2283,26 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9D4472D86BDF48E387059DCB67990AA9" + { + "SourcePath" = "8:..\\samples\\resources\\breakoutsprites.bin" + "TargetName" = "8:breakoutsprites.bin" + "Tag" = "8:" + "Folder" = "8:_758C6547998745659548D0656D380FEA" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_9D5C03E361EC4766AF0204219047B6C8" { "SourcePath" = "8:..\\include\\c64\\sid.c" @@ -3570,15 +3648,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:oscar64" - "ProductCode" = "8:{71389DF5-8242-4F93-B029-00DDD7917F3C}" - "PackageCode" = "8:{62C0C282-BD8F-4744-A840-97FC2BF956FF}" + "ProductCode" = "8:{CDF4A752-EE1A-4826-A688-9C777C33634F}" + "PackageCode" = "8:{8E54BEFF-6BDB-4136-AF7F-5CFFC7A1E100}" "UpgradeCode" = "8:{9AB61EFF-ACAC-4079-9950-8D96615CD4EF}" "AspNetVersion" = "8:2.0.50727.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:1.4.79" + "ProductVersion" = "8:1.4.80" "Manufacturer" = "8:oscar64" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" diff --git a/samples/games/breakout.c b/samples/games/breakout.c index d1e19bf..912b875 100644 --- a/samples/games/breakout.c +++ b/samples/games/breakout.c @@ -25,12 +25,18 @@ byte * const Sprites = (byte *)0xd800; inline void brick_put(char x, char y, char c) { - Screen[40 * y + x + 0] = 96; Color[40 * y + x + 0] = c; - Screen[40 * y + x + 1] = 97; Color[40 * y + x + 1] = c; - Screen[40 * y + x + 2] = 98; Color[40 * y + x + 2] = c; - Screen[40 * y + x + 40] = 99; Color[40 * y + x + 40] = c; - Screen[40 * y + x + 41] = 100; Color[40 * y + x + 41] = c; - Screen[40 * y + x + 42] = 101; Color[40 * y + x + 42] = c; + Screen[40 * y + x + 0] = 128; Color[40 * y + x + 0] = c; + Screen[40 * y + x + 1] = 129; Color[40 * y + x + 1] = c; + Screen[40 * y + x + 2] = 130; Color[40 * y + x + 2] = c; + + Screen[40 * y + x + 40] = 131; Color[40 * y + x + 40] = c; + Screen[40 * y + x + 41] = 132; Color[40 * y + x + 41] = c; + Screen[40 * y + x + 42] = 133; Color[40 * y + x + 42] = c; + Screen[40 * y + x + 43] = 97; Color[40 * y + x + 43] = 15; + + Screen[40 * y + x + 81] = 97; Color[40 * y + x + 81] = 15; + Screen[40 * y + x + 82] = 97; Color[40 * y + x + 82] = 15; + Screen[40 * y + x + 83] = 97; Color[40 * y + x + 83] = 15; } void brick_init(void) @@ -48,9 +54,9 @@ void brick_clr(char x, char y) { char c = Screen[40 * y + x + 0]; - if (c >= 96 && c < 102) + if (c >= 128) { - c -= 96; + c &= 7; if (c >= 3) { @@ -60,15 +66,157 @@ void brick_clr(char x, char y) x -= c; - Screen[40 * y + x + 0] = 32; - Screen[40 * y + x + 1] = 32; - Screen[40 * y + x + 2] = 32; - Screen[40 * y + x + 40] = 32; - Screen[40 * y + x + 41] = 32; - Screen[40 * y + x + 42] = 32; + char * cp = Color + 40 * y + x; + + cp[ 0] = 15; + cp[ 1] = 15; + cp[ 2] = 15; + cp[40] = 15; + cp[41] = 15; + cp[42] = 15; + + char * sp = Screen + 40 * (y - 1) + (x - 1); + + if (sp[ 0] >= 128) + sp[41] = 97; + else + sp[41] = 96; + + if (sp[ 1] >= 128) + sp[42] = 97; + else + sp[42] = 96; + + if (sp[ 2] >= 128) + sp[43] = 97; + else + sp[43] = 96; + + if (sp[40] >= 128) + sp[81] = 97; + else + sp[81] = 96; + + sp[82] = 96; + sp[83] = 96; + if (sp[84] == 97) + sp[84] = 96; + + if (sp[122] == 97) + sp[122] = 96; + if (sp[123] == 97) + sp[123] = 96; + if (sp[124] == 97) + sp[124] = 96; } } +struct Ball +{ + char index; + int sx, sy, vx, vy; +} + +// using 10.6 bit fixed point math + +#define BALL_INT(x) ((x) >> 6) +#define BALL_COORD(x, f) (((x) << 6) + f) + +void ball_init(Ball * ball, char index, int sx, int sy, int vx, int vy) +{ + ball->index = index; + ball->sx = sx; + ball->sy = sy; + ball->vx = vx; + ball->vy = vy; +} + +#define COL_00 1 +#define COL_01 2 +#define COL_10 4 +#define COL_11 8 + +int paddlex, paddlevx; + +void ball_loop(Ball * ball) +{ + ball->sx += ball->vx; + ball->sy += ball->vy; + + bool mirrorX = false, mirrorY = false; + + int ix = BALL_INT(ball->sx), iy = BALL_INT(ball->sy); + int px = BALL_INT(paddlex); + + if (ix + 6 > 320 || ix < 0) + mirrorX = true; + if (iy < 0) + mirrorY = true; + + if (iy + 6 > 190 && iy < 190) + { + if (ix + 3 >= px && ix + 3 < px + 48) + { + mirrorY = true; + if (ix < px && ball->vx > 0) + mirrorX = true; + else if (ix + 6 >= px + 48 && ball->vx < 0) + mirrorX = true; + + ball->vx = (ball->vx * 3 + paddlevx) >> 2; + } + } + + + int x0 = ix >> 3; + int y0 = iy >> 3; + int x1 = (ix + 6) >> 3; + int y1 = (iy + 6) >> 3; + + char col = 0; + + if (y0 >= 0 && Screen[40 * y0 + x0] >= 128) col |= COL_00; + if (y0 >= 0 && Screen[40 * y0 + x1] >= 128) col |= COL_01; + if (y1 < 24 && Screen[40 * y1 + x0] >= 128) col |= COL_10; + if (y1 < 24 && Screen[40 * y1 + x1] >= 128) col |= COL_11; + + if (ball->vx < 0 && ((col & (COL_00 | COL_01)) == COL_00) || ((col & (COL_10 | COL_11)) == COL_10)) + mirrorX = true; + else if (ball->vx > 0 && ((col & (COL_00 | COL_01)) == COL_01) || ((col & (COL_10 | COL_11)) == COL_11)) + mirrorX = true; + + if (ball->vy < 0 && ((col & (COL_00 | COL_10)) == COL_00) || ((col & (COL_01 | COL_11)) == COL_01)) + mirrorY = true; + else if (ball->vy > 0 && ((col & (COL_00 | COL_10)) == COL_10) || ((col & (COL_01 | COL_11)) == COL_11)) + mirrorY = true; + + if (col) + { + brick_clr(x0, y0); + brick_clr(x1, y0); + brick_clr(x0, y1); + brick_clr(x1, y1); + } + + if (mirrorY) + { + ball->vy = - ball->vy; + ball->sy += 2 * ball->vy; + } + if (mirrorX) + { + ball->vx = - ball->vx; + ball->sx += 2 * ball->vx; + } +} + +void ball_move(Ball * ball) +{ + int ix = BALL_INT(ball->sx) + 24, iy = BALL_INT(ball->sy) + 50; + + spr_move(2 * ball->index + 2, ix, iy); + spr_move(2 * ball->index + 3, ix, iy); +} int main(void) { @@ -87,79 +235,71 @@ int main(void) // Change colors vic.color_border = VCOL_BLACK; - vic.color_back = VCOL_BLUE; + vic.color_back = VCOL_BLACK; vic.color_back1 = VCOL_WHITE; vic.color_back2 = VCOL_DARK_GREY; - memset(Screen, ' ', 1000); + vic.spr_mcolor0 = VCOL_DARK_GREY; + vic.spr_mcolor1 = VCOL_WHITE; + + memset(Screen, 96, 1000); + memset(Color, 15, 1000); brick_init(); - float sx = 100, sy = 180, vx = 3.2, vy = -4.0; + spr_set(0, true, 200, 240, 99, 0, false, true, false); + spr_set(1, true, 200, 240, 98, 15, true, true, false); - spr_set(0, true, 200, 200, 96, 1, false, false, false); + spr_set(2, true, 200, 200, 97, 0, false, false, false); + spr_set(3, true, 200, 200, 96, 15, true, false, false); +#if 0 + spr_set(4, true, 200, 200, 97, 0, false, false, false); + spr_set(5, true, 200, 200, 96, 15, true, false, false); + + spr_set(6, true, 200, 200, 97, 0, false, false, false); + spr_set(7, true, 200, 200, 96, 15, true, false, false); +#endif + + Ball balls[3]; + + ball_init(balls + 0, 0, BALL_COORD(100, 0), BALL_COORD(180, 0), BALL_COORD(0, 8), BALL_COORD(-1, 48)) +// ball_init(balls + 1, 1, BALL_COORD(100, 0), BALL_COORD(180, 0), BALL_COORD(2, 11), BALL_COORD(-3, 10)) +// ball_init(balls + 2, 2, BALL_COORD(100, 0), BALL_COORD(180, 0), BALL_COORD(1, 37), BALL_COORD( 4, 11)) for(;;) { - vic.color_border++; + joy_poll(0); - for(char i=0; i<4; i++) + if (joyx[0] == 0) { - sx += vx; - sy += vy; - // vy += 0.01; + if (paddlevx < 0) + paddlevx = (paddlevx + 1) >> 1; + else + paddlevx >>= 1; + } + else + { + paddlevx += joyx[0] * 16; - bool mirrorX = false, mirrorY = false; - - if (sx + 6 > 320 || sx < 0) - mirrorX = true; - if (sy + 6 > 200 || sy < 0) - mirrorY = true; - - int x0 = (int)sx >> 3; - int y0 = (int)sy >> 3; - int x1 = (int)(sx + 6) >> 3; - int y1 = (int)(sy + 6) >> 3; - - bool c00 = y0 >= 0 && Screen[40 * y0 + x0] >= 96; - bool c01 = y0 >= 0 && Screen[40 * y0 + x1] >= 96; - bool c10 = y1 < 24 && Screen[40 * y1 + x0] >= 96; - bool c11 = y1 < 24 && Screen[40 * y1 + x1] >= 96; - - if (vx < 0 && (c00 && !c01 || c10 && !c11)) - mirrorX = true; - else if (vx > 0 && (c01 && !c00 || c11 && !c10)) - mirrorX = true; - - if (vy < 0 && (c00 && !c10 || c01 && !c11)) - mirrorY = true; - else if (vy > 0 && (c10 && !c00 || c11 && !c01)) - mirrorY = true; - - if (c00 || c01 || c10 || c11) - { - brick_clr(x0, y0); - brick_clr(x1, y0); - brick_clr(x0, y1); - brick_clr(x1, y1); - } - - if (mirrorY) - { - vy = -vy; - sy += 2 * vy; - // vy *= 0.99; - } - if (mirrorX) - { - vx = -vx; - sx += 2 * vx; - // vx *= 0.99; - } + if (paddlevx >= 128) + paddlevx = 128; + else if (paddlevx < -128) + paddlevx = -128; } - spr_move(0, sx + 24, sy + 50); + paddlex += paddlevx; + spr_set(0, true, 24 + BALL_INT(paddlex), 240, 99, 0, false, true, false); + spr_set(1, true, 24 + BALL_INT(paddlex), 240, 98, 15, true, true, false); + + vic.color_border++; + for(char i=0; i<4; i++) + { + for(char j=0; j<1; j++) + ball_loop(balls + j) + } + for(char j=0; j<1; j++) + ball_move(balls + j); vic.color_border--; vic_waitFrame(); diff --git a/samples/games/build.sh b/samples/games/build.sh index 38fcf47..4623e79 100644 --- a/samples/games/build.sh +++ b/samples/games/build.sh @@ -3,4 +3,5 @@ ../../bin/oscar64 lander.c -n ../../bin/oscar64 maze3d.c -n ../../bin/oscar64 missile.c -O3 -n +../../bin/oscar64 breakout.c -n diff --git a/samples/memmap/easyflash.crt b/samples/memmap/easyflash.crt index 71c9643..ffdc72a 100644 Binary files a/samples/memmap/easyflash.crt and b/samples/memmap/easyflash.crt differ diff --git a/samples/resources/breakoutchars.bin b/samples/resources/breakoutchars.bin index 15f8687..5bffdee 100644 Binary files a/samples/resources/breakoutchars.bin and b/samples/resources/breakoutchars.bin differ diff --git a/samples/resources/breakoutsprites.bin b/samples/resources/breakoutsprites.bin index efe0641..f174f68 100644 Binary files a/samples/resources/breakoutsprites.bin and b/samples/resources/breakoutsprites.bin differ