TRSE : the helicopter propeller is moved by the interrupt

You need an actual VIC.

Moderator: Moderators

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

TRSE : the helicopter propeller is moved by the interrupt

Post by funkheld »

Hi good afternoon.
the helicopter propeller is moved by the interrupt.

start from disk.d64 : intschiebe.p
start sys8192 and control with A /S /D / W. helicopter-color :R /F motor-on : T motor-off : G
I wrote the interrupt myself in asm.

how can you use the interrupt from em trse for this?

greeting

Code: Select all

program schiebeint;

var
charset : array[8] of byte = ( 24,24,60,126,255,24,36,66);
charset1 : array[8] of byte = (255,129,129,129,129,129,129,255 );

a,b,f,ch,x,y : byte;

saddr : array[23] of integer;
caddr : array[23] of integer;

zpcharz: pointer;

procedure  warte(t : byte);
begin
	for a:=0 to t do
	begin 	     
    wait(100);
  end;
end;

procedure setint();
begin
	asm("
	sei
	lda #<irq
	sta $0314
	lda #>irq 
	sta $0315                       
	cli     
	");
end;

procedure endeint();
begin
	asm("
	sei
	lda #<irq1
	sta $0314
	lda #>irq1 
	sta $0315                       
	cli     
	");
end;
  
procedure irq();   
begin
	asm("                             
  bne .exit	
	
	ldx #0
drehe1
  lda #255
	sta 5120
	inx
	cpx #255
	bne drehe1
	
	ldx #0
drehe2
  lda #126
	sta 5120
	inx
	cpx #255
	bne drehe2	
	
	ldx #0
drehe3
  lda #60
	sta 5120
	inx
	cpx #255
	bne drehe3		
	ldx #0
drehe4
  lda #24
	sta 5120
	inx
	cpx #255
	bne drehe4		

.exit                             
	jmp $eabf	
	");
end;

procedure irq1();   
begin
	asm("                             
  bne .exit1	
.exit1                             
	jmp $eabf	
	");
end;

begin
  definescreen();
  ClearScreen(white, screen_col_loc);
  
  CreateAddressTable( saddr,$1000, 22, 23);
  CreateAddressTable( caddr,$9400, 22, 23);
    
  zpcharz:=5120;
  
  poke(^37139,0,0);
  poke(^37154,0,127);
  poke(^36869,0,205);
  
  zpcharz:=5120;
	for b:=0 to 8 do
	begin
		zpcharz[b]:=charset[b];
	end;
	zpcharz:=5128;
	for b:=0 to 8 do
	begin
		zpcharz[b]:=charset1[b];
	end;
	
  x:=10;
  y:=10;
  f:=5;
  ch:=0;
  screenmemory := AddressTable( saddr,x,y );
  screenmemory[0] := ch;
  screenmemory := AddressTable( caddr,x, y );
  screenmemory[0] := f;
  
  while (true) do
	begin
	  waitforraster(0);
	  
    if peek(^197,0)= 18 then 
    begin 
      warte(5);
      x:=x+1;
      if (x>21) then x:=21;
      ch:=0;
      screenmemory := AddressTable( saddr,x, y );
      screenmemory[0] := ch;
      screenmemory := AddressTable( caddr,x, y );
      screenmemory[0] := f;
      ch:=32;
      screenmemory := AddressTable( saddr,x-1, y );
      screenmemory[0] := ch;
    end; 
    
    if peek(^197,0)= 17 then 
    begin
      warte(5);
      x:=x-1;
      if (x=255) then x:=0;
      ch:=0;
      screenmemory := AddressTable( saddr,x, y );
      screenmemory[0] := ch;
      screenmemory := AddressTable( caddr,x, y );
      screenmemory[0] := f; 
      ch:=32;
      screenmemory := AddressTable( saddr,x+1, y );
      screenmemory[0] := ch;
    end; 
    
   if peek(^197,0)= 41 then 
    begin
      warte(5);
      y:=y+1;
      if (y>22) then y:=22;
      ch:=0;
      screenmemory := AddressTable( saddr,x, y );
      screenmemory[0] := ch;
      screenmemory := AddressTable( caddr,x, y );
      screenmemory[0] := f;  
      ch:=32; 
      screenmemory := AddressTable( saddr,x, y-1 );
      screenmemory[0] := ch;    
    end; 
    
   if peek(^197,0)= 9 then 
    begin
      warte(5);
      y:=y-1;
      if (y=255) then y:=0;
      ch:=0;
      screenmemory := AddressTable( saddr,x, y );
      screenmemory[0] := ch;
      screenmemory := AddressTable( caddr,x, y );
      screenmemory[0] := f;  
      ch:=32;
      screenmemory := AddressTable( saddr,x, y+1 );
      screenmemory[0] := ch;  
    end;   
    
    if peek(^197,0)= 10 then 
    begin
      warte(10);
      f:=f+1;
      if (f>7) then f:=7;  
      screenmemory := AddressTable( caddr,x, y );
      screenmemory[0] := f;    
    end;  
    
    if peek(^197,0)= 42 then 
    begin
      warte(10);
      f:=f-1;
      if (f=255) then f:=0;   
      screenmemory := AddressTable( caddr,x, y );
      screenmemory[0] := f;      
    end; 
    
    if peek(^197,0)= 50 then 
    begin
      warte(10); 
      setint();
    end;   
    
    if peek(^197,0)= 19 then 
    begin
      warte(10);
      endeint(); 
    end;  
  end; 
end.
Attachments
disk.zip
(1.53 KiB) Downloaded 70 times
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: TRSE : the helicopter propeller is moved by the interrupt

Post by AndyH »

Nice!

BTW, you can create an interrupt with TRSE. Here's what I use in Pumpkid:

Code: Select all

interrupt vbl();
begin
	StartIRQ(0);

	ticks := mod(ticks + 1, 100);
	if sndFlag = true then UpdateSound();
		
	closeIRQ();
end;
And I set it up with:

Code: Select all

	DisableVIC20IRQ();
	
	if (HSCROLL_REGISTER = 12) then
	begin
	
		// Time the interrupt directly with the raster (PAL);
		// 312 scanlines * 71 cycles -2 = $5686
		VIAIRQ(vbl(), $86, $56);
		GAMETIMERMAX := 25;
	
	end
	else
	begin
	
		// Time the interrupt directly with the raster (NTSC);
		VIAIRQ(vbl(), $43, $42);
		GAMETIMERMAX := 28;
		
	end;
I have a tip for the keyboard detection - peek 197 once and store in a variable for a small optimisation, eg:

k := peek( ^197, 0 );
--
AndyH
HEWCO | Vic 20 blog
Post Reply