Turbo Rascal - Vic Bitmap Mode

You need an actual VIC.

Moderator: Moderators

funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: Turbo Rascal - Vic Bitmap Mode

Post by funkheld »

Hi good afternoon.
trse is great for the vic20.

a sprite 16 byte with vertical collison.
control with a / s / d / w

how do you get the horizontal collison down please?

greeting

Code: Select all

program sprite;

var  

i,b,x,y :byte;

        spr16L : array[] of byte = (
            %11111111,
            %10000001,
            %00111100,
            %00100100,
            %00100100,
            %00111100,
            %10000001,
            %11111111,
            
            %01100110,
            %10011001,
            %01100110,
            %10011001,
            %01100110,
            %10011001,
            %01100110,
            %10011001
        );

        spr16R : array[] of byte = (		
            %01100110,
            %10011001,
            %01100110,
            %10011001,
            %01100110,
            %10011001,
            %01100110,
            %10011001,
            
            %11111111,
            %10000001,
            %00111100,
            %00100100,
            %00100100,
            %00111100,
            %10000001,
            %11111111
        );
        
       spr16L0 : array[8] of integer;  
       spr16M0 : array[8] of integer;  
       spr16R0 : array[8] of integer;  

procedure spritetest();
begin
    if (vbmTestPixel( x+15, y+15 ) = 0) then
    begin
			y := y + 1;
			if (y>176) then y:=176;
    end;
    
    if (vbmTestPixel( x, y+15 ) = 0) then
    begin
			y := y + 1;
			if (y>176) then y:=176;
    end;
    
    if (vbmTestPixel( x+15, y-2 ) = 0) then
    begin
			y := y - 1;
			if (y=255) then y:=0;	
    end;
    
    if (vbmTestPixel( x, y-2 ) = 0) then
    begin
			y := y - 1;
			if (y=255) then y:=0;	
    end;
end;

procedure linien();
begin
for b:=0 to 20 do
	begin
     vbmDrawblot( b,30 );
  end;
  
  for b:=50 to 80 do
	begin
     vbmDrawblot( b,60 );
  end;
  
  for b:=120 to 150 do
	begin
     vbmDrawblot( b,80 );
  end;
  
  for b:=0 to 80 do
	begin
     vbmDrawblot( b,100 );
  end;
  
  for b:=100 to 159 do
	begin
     vbmDrawblot( b,100 );
  end;
  
  for b:=0 to 159 do
	begin
     vbmDrawblot( b,180 );
  end;
end;

begin
	vbmSetDisplayMode( 0 );
	vbmClear(0);	
	vbmClearColor(blue);
	
 	vbmSpriteShiftR( spr16L, ^$a000, 1, 16, spr16L0 ); 
  vbmSpriteShiftL( spr16L, ^$a080, 1, 16, spr16M0 );
        
  vbmSpriteShiftR( spr16R, ^$a100, 1, 16, spr16R0 ); 
  vbmSpriteStitch( ^$a100, ^$a080, 128 );  // 8 x 16 = 128 ($80) bytes to stitch
  vbmSpriteShiftL( spr16R, ^$a100, 1, 16, spr16R0 );
   
  linien();
    
  x:=40;
  y:=70;
  
  while (true) offpage do
	begin
	
		i := getkey();	
		case i of 
			KEY_d: 
			begin
				x:=x+1;
				if (x>144) then x:=144;
			end;
			
			KEY_a: 
			begin
	      x:=x-1;
	      if (x=255) then x:=0;
			end;
			
			KEY_s: 
			begin
				y:=y+1;
				if (y>176) then y:=176;
			end;
			
			KEY_w: 
			begin
	     y:=y-1;	
	     if (y=255) then y:=0;	
			end;
		end;
		
		vbmSetPosition1( x, y ); 
    vbmDrawSprite16e( spr16L0, spr16M0, spr16R0 );  
            
    waitforraster( 0 ); 
    
    vbmSetPosition1( x, y ); 
    vbmDrawSprite16e( spr16L0, spr16M0, spr16R0 );  
    
    spritetest();
	end;
end.
Attachments
spritecolli.jpg
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: Turbo Rascal - Vic Bitmap Mode

Post by funkheld »

Hi good afternoon.

I have 2 sprites (8byte) which I can switch with the u / j buttons.
I can move the first sprite with: t / g / f / h
I can move the second sprite with w / s / a / d
both work.
how can you do that when switching
that the one sprite doesn't go away then?

Thank you.
Greeting

Code: Select all

program sprite;

var  

i,a,b,x1,y1,x2,y2,t :byte;


spr1 : array[] of byte = (
  %11111111,
  %10000001,
  %00111100,
  %00100100,
  %00100100,
  %00111100,
  %10000001,
  %11111111
  );
  
spr2 : array[] of byte = (
  %11111111,
  %10000001,
  %10000001,
  %10000001,
  %10000001,
  %10000001,
  %10000001,
  %11111111
  );
    
  spr1L0 : array[8] of integer; 
  spr1R0 : array[8] of integer; 
  
  spr2L0 : array[8] of integer; 
  spr2R0 : array[8] of integer; 
  
procedure spritetest1();
begin
    if (vbmTestPixel( x1+7, y1+7 ) = 0) then
    begin
	y1 := y1 + 1;
	if (y1>184) then y1:=184;
    end;
    
    if (vbmTestPixel( x1, y1+7 ) = 0) then
    begin
			y1 := y1 + 1;
			if (y1>184) then y1:=184;
    end;
    
    if (vbmTestPixel( x1+7, y1-2 ) = 0) then
    begin
	y1 := y1 - 1;
	if (y1=255) then y1:=0;	
    end;
    
    if (vbmTestPixel( x1, y1-2 ) = 0) then
    begin
	y1 := y1 - 1;
	if (y1=255) then y1:=0;	
    end;
end;

procedure spritetest2();
begin
    if (vbmTestPixel( x2+7, y2+7 ) = 0) then
    begin
	y2 := y2 + 1;
	if (y2>184) then y2:=184;
    end;
    
    if (vbmTestPixel( x2, y2+7 ) = 0) then
    begin
	y2 := y2 + 1;
	if (y2>184) then y2:=184;
    end;
    
    if (vbmTestPixel( x2+7, y2-2 ) = 0) then
    begin
	y2 := y2 - 1;
	if (y2=255) then y2:=0;	
    end;
    
    if (vbmTestPixel( x2, y2-2 ) = 0) then
    begin
	y2 := y2 - 1;
	if (y2=255) then y2:=0;	
    end;
end;

procedure linien();
begin
for b:=0 to 20 do
  begin
     vbmDrawblot( b,20 );
  end;
  
  for b:=50 to 80 do
    begin
     vbmDrawblot( b,60 );
  end;
  
  for b:=120 to 150 do
	begin
     vbmDrawblot( b,80 );
  end;
  
  for b:=0 to 80 do
     begin
     vbmDrawblot( b,100 );
  end;
  
  for b:=100 to 159 do
     begin
     vbmDrawblot( b,100 );
  end;
  
  for b:=0 to 159 do
    begin
     vbmDrawblot( b,180 );
  end;
end;

procedure sprite1();
begin
   vbmSetPosition1( x1, y1 ); 
   vbmDrawSprite8e( spr1L0, spr1R0 ); 
    
   waitforraster( 0 ); 

   vbmSetPosition1( x1, y1 ); 
   vbmDrawSprite8e( spr1L0, spr1R0 ); 
end;

procedure sprite2();
begin    
   vbmSetPosition1( x2, y2 ); 
   vbmDrawSprite8e( spr2L0, spr2R0 ); 
    
   waitforraster( 0 ); 

   vbmSetPosition1( x2, y2 ); 
   vbmDrawSprite8e( spr2L0, spr2R0 ); 
end;
  
 
begin
  vbmSetDisplayMode( 0 );
  vbmClear(0);	
  vbmClearColor(blue);
	
  vbmSpriteShiftR( spr1, ^$a000, 1, 8, spr1L0 ); 
  vbmSpriteShiftL( spr1, ^$a040, 1, 8, spr1R0 ); 
 	
  t:=1;
	
  linien();
  x1:=50;
  y1:=20;
  
  x2:=150;
  y2:=120;
  
  while (true) offpage do
	begin
		i := getkey();	
		case i of 
			KEY_d: 
			begin
			  x1:=x1+1;
			  if (x1>152) then x1:=152;
			end;	
			KEY_a: 
			begin
	                  x1:=x1-1;
	                  if (x1=255) then x1:=0;
			end;			
			KEY_s: 
			begin
			y1:=y1+1;
			if (y1>184) then y1:=184;
			end;		
			KEY_w: 
			begin
	                   y1:=y1-1;	
	                  if (y1=255) then y1:=0;	
			end;
			
                       KEY_h: 
			begin
			  x2:=x2+1;
			  if (x2>152) then x2:=152;
			end;		
			KEY_f: 
			begin
	                   x2:=x2-1;
	                   if (x2=255) then x2:=0;
			end;			
			KEY_g: 
			begin
			  y2:=y2+1;
			  if (y2>184) then y2:=184;
			end;		
			KEY_t: 
			begin
	                   y2:=y2-1;	
	                   if (y2=255) then y2:=0;	
			end;
			
                       KEY_g: 
			begin
	                   y2:=y2-1;	
	                   if (y2=255) then y2:=0;	
			end;
			
                         KEY_u: 
			begin
	                   vbmSpriteShiftR( spr1, ^$a000, 1, 8, spr1L0 ); 
                             vbmSpriteShiftL( spr1, ^$a040, 1, 8, spr1R0 ); 
                            t:=1;
			end;
			KEY_j: 
			begin
	                   vbmSpriteShiftR( spr2, ^$a000, 1, 8, spr2L0 ); 
                            vbmSpriteShiftL( spr2, ^$a040, 1, 8, spr2R0 ); 
                             t:=2;
			end;
		 end;	
	  
                if(t=1) then
                begin
	  	  sprite1();
	  	  spritetest1(); 
	        end; 
	        if(t=2) then
                begin
	  	  sprite2(); 
    	          spritetest2();  
               end;
            end;
end.
Attachments
sprite2.jpg
sprite2.jpg (7.28 KiB) Viewed 2342 times
sprite1.jpg
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Turbo Rascal - Vic Bitmap Mode

Post by AndyH »

funkheld wrote: Sun Jan 12, 2020 4:57 am Hello thanks for the information.

---------------------------------
asm(" ldx #152;keep");
vbmScreenShiftright( 50, 191 );
---------------------------------

why is : asm(" ldx #152;keep");

greeting
That’s one of bigs to fix. The TRSE optimiser is being a bit too aggressive and removing an ldx it shouldn’t.
--
AndyH
HEWCO | Vic 20 blog
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: Turbo Rascal - Vic Bitmap Mode

Post by funkheld »

hello thanks für the info.

I'm looking forward to the new version.

greeting
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Turbo Rascal - Vic Bitmap Mode

Post by AndyH »

For next version I have added two commands to deal with saving and restoring parts of the bitmap to a buffer in memory, that way you can draw sprites as normal, or with a mask, and restore the background after.
Click to view animation
Click to view animation
1) Save background (Cyan), 2) Draw sprite (Green) and 3) Restore background (Purple).
--
AndyH
HEWCO | Vic 20 blog
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: Turbo Rascal - Vic Bitmap Mode

Post by funkheld »

hello, you make super things for the vic2o.
I'm looking forward to the renewal.

Thank you.
greeting
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Turbo Rascal - Vic Bitmap Mode

Post by AndyH »

I've had a think about sprites. I have two helper methods for pre-sized sprites (8x8 or 16x16) and you can of course use sprite slices to make any size sprite you want, but it occurs to me that 8x16 is a useful sprite size too. So have added a helper command for that.
Click to play animation
Click to play animation
--
AndyH
HEWCO | Vic 20 blog
funkheld
Vic 20 Devotee
Posts: 241
Joined: Tue Sep 10, 2019 4:23 am

Re: Turbo Rascal - Vic Bitmap Mode

Post by funkheld »

Hi good afternoon.

but you build beautiful things with the sprite.
you are a vic20 specialist.

Thank you.
greeting
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Turbo Rascal - Vic Bitmap Mode

Post by AndyH »

Next demo to show off Small Text that I added today. This was much simpler to implement than I thought it would be.

But more importantly, finally I can make a Llama Face...I mean Omega Race! :-D
Click to view animation
Click to view animation
--
AndyH
HEWCO | Vic 20 blog
Post Reply