Advertisement
paul_nicholls

Untitled

Sep 26th, 2024
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 8.24 KB | None | 0 0
  1. program scrolly;
  2. uses
  3.   c64_vic;
  4.  
  5. const
  6.   SCREEN0_ADDRESS = 1024;
  7.   SCREEN_WIDTH    = 40;
  8.   row             = 15;
  9.    
  10.   scroll_text : String = 'this is a simple scroller demo written in pascal and compiled using pas6502 into 6502 assembly code.  as you can see, you don''t need pure assembly to do simple effects like this.                                       ';
  11.  
  12.   logo : array[0..1000 - 1] of Byte = (
  13.   32,224,224,224,224,32,224,224,224,224,32,224,224,224,32,224,224,224,224,224,32,224,224,224,224,224,32,224,224,224,224,224,32,96,224,224,224,96,32,32,
  14.   32,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,32,224,224,224,224,224,224,224,224,224,224,224,32,32,
  15.   32,224,224,32,224,224,224,224,32,224,224,224,224,32,32,224,224,32,32,32,32,224,224,32,32,32,32,224,224,32,96,224,224,32,224,32,32,224,224,96,
  16.   32,224,224,224,224,224,224,224,224,224,224,224,224,224,32,224,224,224,224,224,32,224,224,224,224,224,32,224,224,32,96,224,224,96,224,224,224,224,224,96,
  17.   32,224,224,224,224,224,224,224,224,224,224,96,96,224,224,224,224,224,224,224,224,32,224,224,224,224,224,224,224,32,32,224,224,224,224,224,224,224,224,96,
  18.   32,224,224,32,32,96,224,224,96,224,224,32,96,224,224,224,224,32,32,224,224,32,32,32,96,224,224,224,224,32,32,224,224,224,224,32,32,32,32,96,
  19.   32,224,224,32,32,96,224,224,96,224,224,32,32,224,224,224,224,32,32,224,224,32,32,32,96,224,224,224,224,32,32,224,224,224,224,32,32,32,32,32,
  20.   32,224,224,32,32,96,224,224,32,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,32,32,
  21.   32,96,224,32,32,96,32,224,32,32,224,32,224,224,224,32,224,224,224,224,224,32,224,224,224,224,224,32,224,224,224,224,224,32,224,224,224,224,224,32,
  22.   32,32,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,
  23.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  24.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  25.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  26.   67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,
  27.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  28.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  29.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  30.   67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,67,
  31.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  32.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  33.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  34.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  35.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  36.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
  37.   32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32
  38.   );
  39.  
  40.   logo_colours : array[0..1000 - 1] of Byte = (
  41.   14,10,10,10,10,14,10,10,10,10,14,10,10,10,14,1,1,1,1,1,14,1,1,1,1,1,14,1,1,1,1,1,14,1,1,1,1,1,14,14,
  42.   14,10,0,0,10,0,10,0,0,10,0,10,0,0,0,1,0,0,0,0,0,1,0,0,0,1,14,1,0,0,1,1,0,1,0,0,0,1,14,14,
  43.   14,10,0,14,10,0,10,0,14,10,0,10,0,14,14,1,0,14,14,14,14,1,0,14,14,14,14,1,0,14,1,1,0,14,0,14,14,1,0,10,
  44.   14,10,10,10,10,0,10,10,10,10,0,10,10,10,14,1,1,1,1,1,14,1,1,1,1,1,14,1,0,14,1,1,0,1,1,1,1,1,0,10,
  45.   14,10,0,0,0,0,10,0,0,10,0,10,0,10,0,1,0,0,0,1,0,14,0,0,0,1,0,1,0,14,14,1,0,1,0,0,0,0,0,10,
  46.   14,10,0,14,14,0,10,0,0,10,0,14,0,10,0,1,0,14,14,1,0,14,14,14,1,1,0,1,0,14,14,1,0,1,0,14,14,14,14,10,
  47.   14,10,0,14,14,10,10,0,0,10,0,14,14,10,0,1,0,14,14,1,0,14,14,14,1,1,0,1,0,14,14,1,0,1,0,14,14,14,14,14,
  48.   14,10,0,14,14,10,10,0,14,10,0,10,10,10,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,14,14,
  49.   14,10,0,14,14,10,14,0,14,14,0,14,0,0,0,14,0,0,0,0,0,14,0,0,0,0,0,14,0,0,0,0,0,14,0,0,0,0,0,14,
  50.   14,14,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
  51.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  52.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  53.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  54.   10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
  55.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  56.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  57.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  58.   10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
  59.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  60.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  61.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  62.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  63.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  64.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
  65.   14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14
  66. );
  67.    
  68. var
  69.   i              : Byte;
  70.   screen         : Byte absolute SCREEN0_ADDRESS;
  71.   color          : Byte absolute $d800;
  72.   letter_index   : Byte;
  73.  
  74. procedure stabilize(x : byte); assembler;
  75. asm
  76. !:
  77. burn:
  78.   dex
  79.   bne burn
  80. end;
  81.  
  82. procedure initScreen;
  83. begin
  84.   for i := 0 to 250 do begin
  85.     screen[i+000] := logo[i+000];
  86.     screen[i+250] := logo[i+250];
  87.     screen[i+500] := logo[i+500];
  88.     screen[i+750] := logo[i+750];
  89.     color[i+000] := logo_colours[i+000];
  90.     color[i+250] := logo_colours[i+250];
  91.     color[i+500] := logo_colours[i+500];
  92.     color[i+750] := logo_colours[i+750];
  93.   end;
  94.  
  95.   vic.bg_color0 := medium_grey;
  96.   vic.border    := light_grey;
  97. end;
  98.  
  99. procedure hardscroll;
  100. var
  101.   i : Byte;
  102. begin
  103.   for i := 0 to SCREEN_WIDTH - 1 do begin
  104.     screen[SCREEN_WIDTH*row+i] := screen[SCREEN_WIDTH*row + 1+i];
  105.     color[SCREEN_WIDTH*row+i]  := color[SCREEN_WIDTH*row + 1+i];
  106.   end;
  107.  
  108.   screen[SCREEN_WIDTH * row + 39] := scroll_text[letter_index];
  109.   color[SCREEN_WIDTH * row + 39] := vic.border;
  110.  
  111.   letter_index := letter_index + 1;
  112.   if letter_index > length(scroll_text) then letter_index := 1;
  113. end;
  114.  
  115. procedure mainLoop;
  116. var
  117.   scroll : Byte;
  118. begin
  119.   scroll := 7;
  120.  
  121.   while true do begin
  122.     vic_waitForRaster(row * 8 - 1 + 50);
  123.     stabilize(8);
  124.     vic_38_columns();
  125.     vic_set_scroll(scroll and 7,3);
  126.  
  127.     vic_waitForRaster(row * 8 + 7 + 50);
  128.  
  129.     stabilize(23);
  130.     vic_40_columns();
  131.     vic_set_scroll(0,3);
  132.     if scroll = 0 then begin
  133.       scroll := 7;
  134.       hardscroll();
  135.     end else begin
  136.       scroll := scroll - 1;
  137.     end;
  138.   end;
  139. end;  
  140.  
  141. begin
  142.   letter_index := 1;
  143.   disable_irq;
  144.   initScreen;
  145.  
  146.   mainLoop;
  147. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement