Luotu main workloadit joita käyttää raskaisiin koko ruudun alustusoperaatioihin. Poistaa rasteriajan ylimenot tekstin ja kuvien välissä siirtymisessä.

This commit is contained in:
gimulnautti 2023-02-19 19:08:57 +02:00
parent dd9e93958d
commit fde541ab41
2 changed files with 108 additions and 47 deletions

View File

@ -40,7 +40,7 @@ remove_unused_symbols = 1
ignore_initial_jump = 0 ignore_initial_jump = 0
current_file = piraatti_intro.ras current_file = piraatti_intro.ras
output_type = prg output_type = prg
exomizer_toggle = 1 exomizer_toggle = 0
use_track_19 = 1 use_track_19 = 1
disable_compiler_comments = 0 disable_compiler_comments = 0
charset_ = :resources/character.rom charset_ = :resources/character.rom

View File

@ -338,6 +338,16 @@ text : string = (@cmoveto, 6,10,
tempPtr1, tempPtr2 : pointer; tempPtr1, tempPtr2 : pointer;
tempInt : integer; tempInt : integer;
/*
Workloads for main loop
*/
@define notWorking 0
@define mainText 1
@define mainPicture 2
mainWorkState : byte = 0;
//=========================================================================================================== //===========================================================================================================
// Raster interrupt forward declarations // Raster interrupt forward declarations
//=========================================================================================================== //===========================================================================================================
@ -377,6 +387,23 @@ begin
RasterIrq(RasterMainPartScroller(), rasterLineMainScroller, @useKernal); RasterIrq(RasterMainPartScroller(), rasterLineMainScroller, @useKernal);
end; end;
//===========================================================================================================
// Main Work state functions
//===========================================================================================================
function isMainWorking() : boolean;
var result : boolean;
begin
if (mainWorkState = @notWorking) then result := false
else result := true;
isMainWorking := result;
end;
procedure startMainWork(s : byte);
begin
mainWorkState := s;
end;
/** /**
* Assembly setup for a character set copy in RAM * Assembly setup for a character set copy in RAM
*/ */
@ -1063,6 +1090,7 @@ begin
begin begin
purpleBounceOfs := 0; purpleBounceOfs := 0;
spriteBounceOfs := 0; spriteBounceOfs := 0;
spriteWobbleOfs := 245;
end; end;
if (part = @partMain) then if (part = @partMain) then
begin begin
@ -1122,53 +1150,19 @@ begin
if (mainState = @mainShowText) then if (mainState = @mainShowText) then
begin begin
//tempPtr1 := #screen_char_loc2 + 840; startMainWork(@mainText);
Fill(^$4740, 0, 80);
//tempPtr1 := #screen_col_loc + 800;
FillFast(^$DB20, 0, 80);
WriteMainText();
if (tp[0] = @cstop) then tp := #mainText; // back to first page when done
//tempPtr2 := #screen_col_loc + 960; // keep color for scroll text
fillfast(^$DBC0, $a, 40);
end; end;
if (mainState = @mainPicture) then if (mainState = @mainPicture) then
begin begin
setmulticolormode(); startMainWork(@mainPicture);
setbitmapmode();
//tempPtr1 := AddressTable(#colorAddressTable, 0, 21);
FillFast(^$4748, 0, 120);
//tempPtr2 := #screen_col_loc + 960; // keep color for scroll text
fillfast(^$DBC0, $a, 40);
// set current picture
currentNaamaX := naamatCoordinates[currentNaama * 4];
currentNaamaY := naamatCoordinates[currentNaama * 4 + 1];
currentNaamaWidth := naamatCoordinates[currentNaama * 4 + 2];
currentNaamaHeight := naamatCoordinates[currentNaama * 4 + 3];
// todo write these in main loop instead of raster interrupt
PrintCharToSprite(numbersPtr[0], @mainPartSmallFontLoc, @numberSpriteCopies);
PrintCharToSprite(numbersPtr[1], @mainPartSmallFontLoc, @numberSpriteCopies + 64);
PrintCharToSprite(numbersPtr[2], @mainPartSmallFontLoc, @numberSpriteCopies + 128);
numbersPtr += 3;
if (numbersPtr[0] = @cstop) then numbersPtr := #naamatNumbers;
// print the name
WriteMainName();
if (namesPtr[0] = @cstop) then namesPtr := #naamatNames;
plasmaHeight := 2;
end; end;
end; end;
procedure UpdateMainPart(); procedure UpdateMainPart();
begin begin
if (mainState = @mainShowText) then
if (mainState = @mainShowText and not isMainWorking()) then
begin begin
textPlStartX := 0; textPlStartX := 0;
i := lo(textFade); i := lo(textFade);
@ -1181,6 +1175,7 @@ begin
if (mod(textFade, 10) = 0) then inc(plasmaHeight); if (mod(textFade, 10) = 0) then inc(plasmaHeight);
if (plasmaHeight > 9) then plasmaHeight := 9; if (plasmaHeight > 9) then plasmaHeight := 9;
end; end;
if (mainState = @mainFadeToPicture and textFade < 210) then if (mainState = @mainFadeToPicture and textFade < 210) then
begin begin
i := lo(textFade); i := lo(textFade);
@ -1200,7 +1195,18 @@ begin
inc(textFade); inc(textFade);
end; end;
if (mainState = @mainPicture) then if (mainState = @mainPicture) then
if (isMainWorking()) then
begin
sprite_color[0]:=0;
sprite_color[1]:=0;
sprite_color[2]:=0;
sprite_color[3]:=0;
sprite_color[4]:=0;
sprite_color[5]:=0;
end
else
begin begin
// copy picture one row at a time // copy picture one row at a time
if (pictureFade < currentNaamaHeight) then if (pictureFade < currentNaamaHeight) then
@ -1245,6 +1251,7 @@ begin
memcpyfast(#textFadeLumi, 0, tempPtr1, 20); memcpyfast(#textFadeLumi, 0, tempPtr1, 20);
end; end;
end; end;
if (mainState = @mainFadeToText) then if (mainState = @mainFadeToText) then
begin begin
// blank out picture one row at a time // blank out picture one row at a time
@ -1270,9 +1277,9 @@ begin
sprite_color[0]:=0; sprite_color[0]:=0;
sprite_color[1]:=0; sprite_color[1]:=0;
sprite_color[2]:=0; sprite_color[2]:=0;
sprite_color[3]:=$0; sprite_color[3]:=0;
sprite_color[4]:=$0; sprite_color[4]:=0;
sprite_color[5]:=$0; sprite_color[5]:=0;
end; end;
if (mainTime > 50 and nameFade < 150) then if (mainTime > 50 and nameFade < 150) then
@ -1315,6 +1322,7 @@ var lastSpriteWoblOfs : byte;
wobblePause : boolean = false; wobblePause : boolean = false;
wobblePauseTimer : integer = 0; wobblePauseTimer : integer = 0;
cEqualsChangeFlag : boolean = false; cEqualsChangeFlag : boolean = false;
fillPart : byte = 0;
begin begin
if (part >= @partOpenBar) then Call(SIDFILE_1_PLAY); if (part >= @partOpenBar) then Call(SIDFILE_1_PLAY);
@ -1359,16 +1367,25 @@ begin
if (fadeStateCurrent = @fadeStateText) then if (fadeStateCurrent = @fadeStateText) then
begin begin
fadeTemp := textFadeLumi[fadeOfsCurrent]; fadeTemp := textFadeLumi[fadeOfsCurrent];
if (fillPart = 0) then
begin
Fill(screen_col_loc, fadeTemp, 255); Fill(screen_col_loc, fadeTemp, 255);
FillFast(screen_col_loc + 256, fadeTemp, 127); FillFast(screen_col_loc + 256, fadeTemp, 127);
fadeOfsCurrent -= 1;
end;
if (fillPart = 1) then
begin
Fill(screen_col_loc + 511, fadeTemp, 255); Fill(screen_col_loc + 511, fadeTemp, 255);
Fill(screen_col_loc + 766, fadeTemp, 234); Fill(screen_col_loc + 766, fadeTemp, 234);
end;
GoToPurpleBarRasterStart(); GoToPurpleBarRasterStart();
if (fadeOfsCurrent >= @textFadeLumiLast) then if (fadeOfsCurrent >= @textFadeLumiLast) then
begin begin
fadeStateCurrent := @fadeStateAll; fadeStateCurrent := @fadeStateAll;
fadeOfsCurrent := 0; fadeOfsCurrent := 0;
end; end;
inc(fillPart);
if (fillPart = 2) then fillPart := 0;
end; end;
if (fadeStateCurrent = @fadeStateAll) then if (fadeStateCurrent = @fadeStateAll) then
begin begin
@ -1522,6 +1539,50 @@ begin
while (true) do while (true) do
begin begin
// Main loop "work tasks" here // Main loop "work tasks" here
if (mainWorkState = @mainText) then
begin
//tempPtr1 := #screen_char_loc2 + 840;
Fill(^$4740, 0, 80);
//tempPtr1 := #screen_col_loc + 800;
FillFast(^$DB20, 0, 80);
WriteMainText();
if (tp[0] = @cstop) then tp := #mainText; // back to first page when done
//tempPtr2 := #screen_col_loc + 960; // keep color for scroll text
fillfast(^$DBC0, $a, 40);
mainWorkState := @notWorking;
end;
if (mainWorkState = @mainPicture) then
begin
//tempPtr1 := AddressTable(#colorAddressTable, 0, 21);
FillFast(^$4748, 0, 120);
//tempPtr2 := #screen_col_loc + 960; // keep color for scroll text
fillfast(^$DBC0, $a, 40);
// set current picture
currentNaamaX := naamatCoordinates[currentNaama * 4];
currentNaamaY := naamatCoordinates[currentNaama * 4 + 1];
currentNaamaWidth := naamatCoordinates[currentNaama * 4 + 2];
currentNaamaHeight := naamatCoordinates[currentNaama * 4 + 3];
PrintCharToSprite(numbersPtr[0], @mainPartSmallFontLoc, @numberSpriteCopies);
PrintCharToSprite(numbersPtr[1], @mainPartSmallFontLoc, @numberSpriteCopies + 64);
PrintCharToSprite(numbersPtr[2], @mainPartSmallFontLoc, @numberSpriteCopies + 128);
numbersPtr += 3;
if (numbersPtr[0] = @cstop) then numbersPtr := #naamatNumbers;
// print the name
WriteMainName();
if (namesPtr[0] = @cstop) then namesPtr := #naamatNames;
plasmaHeight := 2;
mainWorkState := @notWorking;
end;
end; end;
end. end.