msx vaporware - true or false ?

Pagina 3/24
1 | 2 | | 4 | 5 | 6 | 7 | 8

Van ARTRAG

Enlighted (6569)

afbeelding van ARTRAG

28-05-2012, 21:39

sure, but x4 is simpler to implement in the scripts (and faster to test), and after all not that bad
Let me start with x4, the x2 will be a refinement.
After all, what is relevant is that the sum of the two subsets of tiles (phase 0 and 4 in bank 0 and phase 2 and 6 in bank 1) does not exceed 256, the rest is only a performance issue.

Van ARTRAG

Enlighted (6569)

afbeelding van ARTRAG

29-05-2012, 00:20

the screen 2 coder starts to work (color clash is visible some here and there in odd frames)
http://www.youtube.com/watch?v=TK5gqorO3N4
the tiles dynamically updated in the two banks are here :
http://www.youtube.com/watch?v=C-kQEXUL2ms

In average the optimization updates 2.1 tiles per frame == 34 bytes/frame .!!

Van NYYRIKKI

Enlighted (5889)

afbeelding van NYYRIKKI

29-05-2012, 00:56

Have you seen "True 3D Racer" for MSX2? True or false?

http://www.youtube.com/watch?v=ZbSZmy7ZgQc

B-)

Van ARTRAG

Enlighted (6569)

afbeelding van ARTRAG

29-05-2012, 10:29

Your 3d racer is much truer than my scrolling atm ;-)
I hope to have all encoded data in screen 2 format by tonight, I need "only" to arrange them in a usable manner for the player. I need also to encode the PNT changes, arrange all the stuff in megarom pages, write a "player" to dump data to the screen...
Maybe in few months I could have a first rom :-P

Van ARTRAG

Enlighted (6569)

afbeelding van ARTRAG

03-06-2012, 00:18

I'm continuing the filmotron project. For each frame of the scrolling, I can export the screen 2 conversion of the new tiles entering in the screen and their positions in the PCT/PGT.
I'm encoding the PNT changes and I need a suggestion, as the implementation in asm of the "player" has to be the lightest possible.
My PNT is 16x32 bytes. Due to the fact that at each scroll step the screen moves one tile left, I should (generally) add a new column (16 bytes) right and move all the screen one byte left
The simplest way to do this is to copy the 16x32=512 bytes on themselves shifted of one byte (a LDIR of 511 bytes) and update the new position where needed in column 32. This when one reserves a 512 area to the PNT in RAM.
If I reserve two pages corresponding to 16x64 bytes, I can avoid the LDIR at least for the first 32 steps. I can just update the starting point from where I start loading data to VRAM. At step 32, I need to copy the current page at the beginning of the buffer and start again the loop.
Is there a better way to avoid this LDIR (even if once each 32 scroll steps) ?
Consider that due to the fact I use two tile switched banks, I will need two PNT's in RAM to be used alternatively.

Van mohai

Paladin (932)

afbeelding van mohai

05-06-2012, 20:37

Very nice effect !! Big smile

To make a light rorutine, you can try to use a 2-screen buffer in RAM. It could be something like this:

Draw a map of 2 screens in RAM.
Dump the first one to VRAM.
(Do whatever you do to move it 4 pixels to the left).
Dump the "next step" screen to VRAM and
Overwrite the unused collumn in RAM for the corresponding frame.
Do it until you reach the end of the buffer and then
start from the beginnig of the buffer again.

This way you will only have to overwrite one collumn at every step.

Van ARTRAG

Enlighted (6569)

afbeelding van ARTRAG

06-06-2012, 00:11

Thanks, at moment I'm using a workaround (that does not allows animations, but it is a temporary solution)
Something starts to work:
https://sites.google.com/site/testmsx/Home/double-buffer-in-...
It is still buggy (the update of the tile data in vram are somehow out of sync with the PNT), but it allows to envisage the final result

Van Metalion

Paragon (1451)

afbeelding van Metalion

06-06-2012, 13:23

Can you explain the basic principle behind your scroll engine ?
Thanks.

Van ARTRAG

Enlighted (6569)

afbeelding van ARTRAG

06-06-2012, 20:33

sure, I can
Wink

Van ARTRAG

Enlighted (6569)

afbeelding van ARTRAG

07-06-2012, 08:25

This is how I generate the data for the ASM player (200 bytes on z80 code in the whole)
Note that arry2tile() is custom and converts in screen 2 asm data the current tiles, so if you have matlab and you want to run this script, I have to pass this last function too.

[A,MAP] = imread('nemesislevel.png');

[Y,NEWMAP] = imapprox(A,MAP,16,'nodither');
image(Y);
colormap(NEWMAP)
A = Y;
MAP = NEWMAP;

xstep = 4;

nf = 1+round((size(A,2)-256)/xstep);

Frame           =   cell(nf,1);
Tileset         =   cell(nf,1);
PNT             =   cell(nf,1);
NewTiles        =   cell(nf,1);
FreePositions   =   cell(nf,1);

TSN = [];

Bank = cell(2,1);

Bank{2} =  uint8(5*ones(64,256));
x=1;

figure(2)
image(uint8(ones(192,256)))
colormap(MAP)
axis equal;
axis off;
drawnow;

Bank{1} =  uint8(5*ones(64,256));
Bank{2} =  uint8(5*ones(64,256));

Level = cell(2,1);

Level{1} = ones(16,256);
Level{2} = ones(16,256);

for ii = 1:nf
    ii
    
% extract current frame    
    Frame{ii} = A(:,x:(x+255));
    B = Frame{ii};
    C = B;
        
% convert in tiles the image
    InpTiles = im2col(B,'indexed',[8 8],'distinct');
    Ntiles = (size(B,1)/8*size(B,2)/8);

% remove duplicated tiles and compute the PNT (== InpMap)
    [Tiles I InpMap] = unique(InpTiles','rows');
    Tileset{ii} = arry2tile(Tiles',MAP);

% compute how many tiles occurs in current frame
    ntiles = size(Tiles,1);

% compute the number for the active bank 
    bn = mod(ii-1,2)+1; 
    
% compute which tiles are new  and not present in the active bank
    NewTiles = setdiff(Tileset{ii}',Bank{bn}','rows')';

% compute which tiles in the bank are common with the new frame
    [C,Ibank,Itileset] = intersect(Bank{bn}',Tileset{ii}','rows');

% find positions of unused tiles in the bank
    FreePositions = setdiff(1:256,Ibank);
    
% permute free positions at random
%    FreePositions = FreePositions(randperm(size(FreePositions,1)));
    
% update active bank with new tiles (if any)
    if (size(NewTiles,2)>0)
      Bank{bn}(:,FreePositions(1:size(NewTiles,2))) = arry2tile(NewTiles,MAP);
      system(['copy pctdata.asm newtiles\pctdata' num2str(ii,'%0.4d') '.asm']);
      system(['copy pgtdata.asm newtiles\pgtdata' num2str(ii,'%0.4d') '.asm']);
      fid = fopen(['newtiles\tilepos' num2str(ii,'%0.4d') '.asm'],'w');
      fprintf(fid,' db %d \n',(FreePositions(1:size(NewTiles,2))-1));
      fclose(fid);
    else
      fid = fopen(['newtiles\tilepos' num2str(ii,'%0.4d') '.asm'],'w');
      fprintf(fid,'  \n');
      fclose(fid);
      fid = fopen(['newtiles\pctdata' num2str(ii,'%0.4d') '.asm'],'w');
      fprintf(fid,'  \n');
      fclose(fid);
      fid = fopen(['newtiles\pgtdata' num2str(ii,'%0.4d') '.asm'],'w');
      fprintf(fid,'  \n');
      fclose(fid);
    end
            
% compute the PNT for the current frame
    [TF,LOC] = ismember(Tileset{ii}',Bank{bn}','rows'); 
    PNT{ii} = LOC(InpMap);

    fid = fopen(['pntdata\pnt' num2str(ii,'%0.4d') '.asm'],'w');
    fprintf(fid,' db %d \n',(PNT{ii}-1));
    fclose(fid);

    t = reshape(PNT{ii},[16 32]);
    if (ii<3)
        Level{bn}(:,1:32)=t;
    else
        Level{bn}(:,(32+fix((ii-1)/2))) = t(:,32);
    end
        
    
% render the resulting image
    C = col2im(Bank{bn}(:,PNT{ii}),[8 8],size(B),'distinct');
    figure(2);
    image(C);
    colormap(MAP)
    axis equal;
    axis off;
    drawnow;
    
    name = ['pngframes\fram' num2str(ii,'%0.4d') '.png'];
    imwrite(C,MAP,name,'PNG');    
    
% store stats
    TSN = [ TSN; [ntiles size(NewTiles,2) size(FreePositions,1)]];

% show the banks
    C = col2im(Bank{1},[8 8],[64 256],'distinct');
    D = col2im(Bank{2},[8 8],[64 256],'distinct');
    figure(3)
    image([C; D])
    colormap(MAP)
    axis equal;
    axis off;
    drawnow;

    x=x+xstep;
end

fid = fopen(['pntdata\level_0.asm'],'w');
fprintf(fid,' db %d \n',Level{1}'-1);
fclose(fid);

fid = fopen(['pntdata\level_1.asm'],'w');
fprintf(fid,' db %d \n',Level{2}'-1);
fclose(fid);



figure(4)
plot(TSN)
grid

max(TSN)
mean(TSN)


delete out*.*

fid = fopen(['includeall.asm'],'w');

fprintf(fid, [' code page 5 \n' ]);
fprintf(fid, ['pages: \n' ]);
for ii = 1:nf
    fprintf(fid,  ' db %d \n',TSN(ii,2) );   
    fprintf(fid, [' db :step' num2str(ii,'%0.4d') '\n' ]);
    fprintf(fid, [' dw ntiles' num2str(ii,'%0.4d') '\n' ]);
    fprintf(fid, [' dw step' num2str(ii,'%0.4d') '\n \n' ]);
end

for ii = 1:nf
    fprintf(fid,  ' code page 5..31 \n');
    fprintf(fid, ['ntiles' num2str(ii,'%0.4d') ':\n' ]);    
    fprintf(fid, [' include newtiles\\tilepos' num2str(ii,'%0.4d') '.asm \n' ]);    
    fprintf(fid, ['step' num2str(ii,'%0.4d') ':\n' ]);        
    fprintf(fid, [' include newtiles\\pgtdata' num2str(ii,'%0.4d') '.asm \n' ]);    
    fprintf(fid, [' include newtiles\\pctdata' num2str(ii,'%0.4d') '.asm \n\n' ]);    
end

fclose(fid);
Pagina 3/24
1 | 2 | | 4 | 5 | 6 | 7 | 8