Skip to content

Commit

Permalink
Added agon disk anim
Browse files Browse the repository at this point in the history
  • Loading branch information
leuat committed Feb 19, 2024
1 parent 81f24b2 commit a5f4eea
Show file tree
Hide file tree
Showing 14 changed files with 306 additions and 26 deletions.
Empty file modified Publish/tutorials/AGON/tutorials/05_bitmap.ras
100755 → 100644
Empty file.
69 changes: 69 additions & 0 deletions Publish/tutorials/AGON/tutorials/06_disk_anim.ras
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
program Bitmap_image;


@requirefile "data/disksprite1.bin" "Please run (ctrl+R) the fjong/disk.fjo file before compiling this program"

@use "system/screen"


@macro "include_images" 1

i = 1;
for (i=1;i<p0;i++) {
writeln('image'+i+' : incbin("data/disksprite'+i+'.bin");');
}

@endmacro

@macro "load_images" 1

i = 1;
for (i=1;i<p0;i++) {
writeln(' Screen::LoadBitmap(#image'+i+', sizeof(#image'+i+'), '+(i-1)+');');
}


@endmacro

var
@include_images(65)
// image : incbin("data/disksprite1.bin");
zp:^byte;

sinx : array[256] of byte = buildsinetable(240);
siny : array[256] of byte = buildsinetable(180);
time,frame,t2,i,f,t3 : byte;
delta : byte = 64;
x,y : integer;

const img1 : byte = 0; // ID

begin
Screen::SetMode(Screen::mode_320_200_64);
Screen::DisableCursor();
@load_images(65);
while(true) do
begin
t2:=time;
t3:=time;
f:=frame;
for i:=0 to 24 offpage do
begin
x:=sinx[t2]+32;
y:=siny[t3+delta];
Screen::DrawBitmap(f&63, x,y);
f+=3;
t2+=9;
t3+=11;
end;
time+=1;

if (time&3=0) then
delta+=1;

if (time&3=0) then frame+=1;
for x:=0 to 400 do
wait(100);
Screen::ClearScreen();
end;
end.
2 changes: 1 addition & 1 deletion Publish/tutorials/AGON/tutorials/agon_tutorials.trse
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ post_optimizer_passcmp = 1
post_optimizer_passphapla = 1
machine_state = $35
exomize_toggle = 0
show_all_files = 1
show_all_files = 0
use_vice_c1541 = 0
border_color = 0
background_color = 0
Expand Down
173 changes: 173 additions & 0 deletions Publish/tutorials/AGON/tutorials/fjong/disk.fjo
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
globals = {
camera = { x = 23, y=0, z=0 },
fov = 40,
target = { x = 0, y=0.0, z=0 },
light0 = { direction = {x=1, y=0.0, z=-0.2 },
color = {x=1, y=1, z=1},
},
ambient = { x = 0.0, y = 0.0, z = 0.0 },
raymarch_steps = 30,
raymarch_shadow_steps = 4,
up = {x=0.3, y=1, z=0 },
sky = 0,
shadow_scale = 0.5,
isPaused = 0

}

output = {
-- resolution of 2x2 multicolor sprites (12x21 each)
resolution = { width = 32, height=28},
-- resolution = { width = 320, height=200},
aspect = 1.0,
output_type = 0, -- c64 image type
dither = 2,
ditherStrength = { x = 29, y= 2, z= 2},

-- index_colors = { 0,1,2,3 }
}


MaterialBlue = {
color = { x=1, y=1, z=2 },
reflection = 0.5,
shininess = 50,
shininess_intensity = 0
}

MaterialWhite = {
color = { x=2, y=2, z=2 },
reflection = 0.5,
shininess = 50,
shininess_intensity = 0
}




MaterialBlack = {
color = { x=0, y=0.0, z=0 },
reflection = 0.5,
shininess = 50,
shininess_intensity = 0
}




-- Init is called on start


frame = 0
--noFrames = 24
noFrames = 64

hasSaved = 0

function Init()

w = -0.06
xx = -0
-- Let's draw a diskette! using nothing but boxes and stuff
-- cylinder - hole in the center
AddObject("cylinder","d1","","MaterialBlack",0,0,0+xx, 0.4,0,0.15);
SetRotation("d1",0,0,90);

-- some "text"
AddObject("box","l1","","MaterialBlack",w,-2.5,-1.8+xx, 0.11,0.01,0.6);
AddObject("box","l2","","MaterialBlack",w,-2.0,-1.8+xx, 0.11,0.01,0.6);
AddObject("box","l3","","MaterialBlack",w,-1.5,-1.8+xx, 0.11,0.01,0.6);

AddObject("box","ll1","","MaterialBlack",w,-2.5,0.9+xx, 0.11,0.01,1.2);
AddObject("box","ll2","","MaterialBlack",w,-2.0,0.9+xx, 0.11,0.01,1.2);
AddObject("box","ll3","","MaterialBlack",w,-1.5,0.9+xx, 0.11,0.01,1.2);
-- text ends

-- White "labels"
AddObject("box","d2","","MaterialWhite",w,-2.0,-1.8+xx, 0.11,0.8,0.8);
AddObject("box","d2","","MaterialWhite",w,-2.0,1+xx, 0.11,0.8,1.6);

-- lower disk hole
AddObject("cylinder","c1","","MaterialBlack",0,2,-0+xx, 0.12, 0,0.6);
-- Main disk body
AddObject("box","disk","","MaterialBlue",0,0,0+xx, 0.1,3,3);

UpdateScene()

end



function UpdateScene()

t = ((frame)/(noFrames-1))

tt = t*3.14159*2
dt = 0.2
globals.light0.direction.x = cos(tt+dt)
globals.light0.direction.z = sin(tt+dt)
r=11+3
globals.target.z = 0
globals.camera.x = cos(tt)

globals.camera.z = sin(tt)
globals.camera.y = sin(tt+3.14/1.2+3.14)

-- normaliz all
l = globals.camera.x*globals.camera.x + globals.camera.y*globals.camera.y + globals.camera.z*globals.camera.z;
l = math.sqrt(l)
-- Normalize
globals.camera.x = r*globals.camera.x/l
globals.camera.y = r*globals.camera.y/l
globals.camera.z = r*globals.camera.z/l

end


function Update()

if (frame <=noFrames) then
-- save 4 sprites!
if (hasSaved == 0) then
--#0

AddByte(23);
AddByte(0);
AddByte(192);
AddByte(0);

AddByte(23);
AddByte(27);
AddByte(0);
AddByte(frame);

AddByte(23);
AddByte(27);
AddByte(1);

AddByte(output.resolution.width);
AddByte(0);
AddByte(output.resolution.height);
AddByte(0);

AddRGBALineToData(0,0,output.resolution.width, output.resolution.height);
SaveRawData("data/disksprite"..tonumber(frame)..".bin");

end
end
frame=frame+1


if (frame==noFrames+1) then
hasSaved = 1
Message("SAVED")
Message("You can exit now");
end

UpdateScene()





end
Binary file not shown.
5 changes: 0 additions & 5 deletions source/Compiler/assembler/asm6809.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,8 @@ QString Asm6809::String(QStringList lst, bool term)
mark = "fcc";

for (QString s:lst) {
// for (QString s:lst)
res+=DeclareSingleString(s,mark,byte);

/* if (s!=lst.last())
res=res + "\n";
*/

}
if (term)
res=res + "\t"+byte+"\t0";
Expand Down
19 changes: 19 additions & 0 deletions source/LeLib/limage/compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,25 @@ void Compression::AddToDataX(QByteArray &data, MultiColorImage& img, int xp, int

}

void Compression::AddToRGBAData(QByteArray &data, QImage& img, int xp, int yp, int w, int h)
{
for (int y=0;y<h;y+=1)
for (int x=0;x<w;x+=1) {
int xx = xp+x;
int yy = yp+y;

uint val = img.pixel(x,y);
data.append((val>>16)&255);
data.append((val>>8)&255);
data.append(val&255);
if ((val&255)==0)
data.append((uchar)0);
else
data.append((uchar)255);
}

}

void Compression::AddToVZ200Data(QByteArray &data, LImage &img, int xp, int yp, int w, int h)
{
for (int y=0;y<h;y+=1)
Expand Down
1 change: 1 addition & 0 deletions source/LeLib/limage/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Compression
void AddAtariBitplaneToData(QByteArray& data, MultiColorImage& img,int x, int y, int w, int h);
void AddSingleAtariBitplaneToData(QByteArray& data, MultiColorImage& img,int x, int y, int w, int h, int bpl_select);

void AddToRGBAData(QByteArray &data, QImage& img, int xp, int yp, int w, int h);
int CompareSprites(QByteArray& d1,QByteArray& d2, int sprite1, int sprite2);

void CompressScreenAndCharset(QVector<int>& screen, QByteArray& charset, QVector<int> &sOut, QByteArray& cOut, int sw, int sh, int charSize, int noTargetChar,int bmask);
Expand Down
24 changes: 24 additions & 0 deletions source/LeLib/limage/limageagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,27 @@ void LImageAgon::SaveBin(QFile &file)

}


void LImageAgon::ExportBin(QFile &file)
{
ushort width = m_width;
ushort height = m_height;
ushort tmp = 0;
tmp=23; file.write((char*)&tmp, 1);
tmp=0; file.write((char*)&tmp, 1);
tmp=192; file.write((char*)&tmp, 1);
tmp=0; file.write((char*)&tmp, 1);

tmp=23; file.write((char*)&tmp, 1);
tmp=27; file.write((char*)&tmp, 1);
tmp=0; file.write((char*)&tmp, 1);
tmp=0; file.write((char*)&tmp, 1); // id

tmp=23; file.write((char*)&tmp, 1); // id
tmp=27; file.write((char*)&tmp, 1); // id
tmp=1; file.write((char*)&tmp, 1); // id

file.write((char*)&width, 2);
file.write((char*)&height, 2);
LImageQImage::SaveBinRGBA(file);
}
1 change: 1 addition & 0 deletions source/LeLib/limage/limageagon.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class LImageAgon : public LImageGeneric
void SaveBin(QFile& file) override;

QString getMetaInfo() override;
void ExportBin(QFile &file) override;

private:
};
Expand Down
19 changes: 0 additions & 19 deletions source/LeLib/limage/limagegeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,6 @@ QString LImageGeneric::getMetaInfo()

void LImageGeneric::ExportBin(QFile &file)
{
ushort width = m_width;
ushort height = m_height;
ushort tmp = 0;
tmp=23; file.write((char*)&tmp, 1);
tmp=0; file.write((char*)&tmp, 1);
tmp=192; file.write((char*)&tmp, 1);
tmp=0; file.write((char*)&tmp, 1);

tmp=23; file.write((char*)&tmp, 1);
tmp=27; file.write((char*)&tmp, 1);
tmp=0; file.write((char*)&tmp, 1);
tmp=0; file.write((char*)&tmp, 1); // id

tmp=23; file.write((char*)&tmp, 1); // id
tmp=27; file.write((char*)&tmp, 1); // id
tmp=1; file.write((char*)&tmp, 1); // id

file.write((char*)&width, 2);
file.write((char*)&height, 2);
LImageQImage::SaveBinRGBA(file);
}

Expand Down
2 changes: 1 addition & 1 deletion source/LeLib/limage/limagegeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LImageGeneric : public LImageQImage

virtual QString getMetaInfo() override;

void ExportBin(QFile &file) override;
virtual void ExportBin(QFile &file) override;

private:
};
Expand Down
11 changes: 11 additions & 0 deletions source/dialogeffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,16 @@ static int AddToData(lua_State* L) {
return 0;
}

static int AddRGBAToData(lua_State* L) {
if (!VerifyFjongParameters(L,"AddRGBAToData"))
return 0;

if (m_effect!=nullptr)
m_compression.AddToRGBAData(m_charData, m_effect->m_img ,lua_tonumber(L,1),lua_tonumber(L,2), lua_tonumber(L,3), lua_tonumber(L,4));

return 0;
}

static int AddVZ200Data(lua_State* L) {
if (!VerifyFjongParameters(L,"AddVZ200ToData"))
return 0;
Expand Down Expand Up @@ -1984,6 +1994,7 @@ void DialogEffects::LoadScript(QString file)

// Data registration
lua_register(m_script->L, "AddC64LineToData", AddToData);
lua_register(m_script->L, "AddRGBALineToData", AddRGBAToData);
lua_register(m_script->L, "AddVZ200ToData", AddVZ200Data);
lua_register(m_script->L, "Add4PixelToData", Add4PixelData);
lua_register(m_script->L, "Add4PixelCGAToData", Add4PixelCGAData);
Expand Down
Loading

0 comments on commit a5f4eea

Please sign in to comment.