document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. ; tuques - alternative version #2 including a scroll-text
  2. ; 141 byte intro for FEZ which is knitted into tuques
  3. ; code by sy2002 on Dec, 30 2013
  4. ;
  5. ; inspired by fr29b by ByTeGeiZ
  6. ;   http://www.pouet.net/prod.php?which=5028
  7. ;   http://www.codejuggle.dj/29-byte-dos-intro-called-fr29b/
  8. ;
  9. ; compiles to a 16-bit DOS .com executable using NASM (http://www.nasm.us/)
  10. ; using the following settings: nasm -f bin -o tuques2.com tuques2.asm
  11.  
  12. org 0x100
  13.  
  14. ; source code section
  15. section .text
  16.  
  17.     ; set 320*200 graphics mode with 256 colors
  18.     mov     al, 0x13
  19.     int     0x10              
  20.    
  21.     ; use BIOS to print the string (BIOS knows how to paint text
  22.     ; also in graphics modes like the 13h mode)
  23.     mov     ax, ds
  24.     mov     es, ax
  25.     mov     bp, text_data
  26.     mov     ax, 0x1301          ; ah = $13 = write string; al = move cursor
  27.     mov     bx, 00001101b       ; bh = video page = 0; bl = char attribute
  28.     mov     cx, text_size       ; length of string
  29.     xor     dx, dx              ; dh = dl = 0 = initial xy-pos of text
  30.     int     0x10                ; call BIOS
  31.  
  32.     ; remember VGA RAM start adress
  33.     mov     ax, 0xA000
  34.     mov     es, ax
  35.  
  36.     ; start position of the scroll text is top left
  37.     xor     bp, bp
  38.        
  39.     ; copy text as bitpattern to RAM buffer
  40.     ; (this is later used for the repeated copies)
  41.     xor     di, di
  42.     mov     cx, gfx_size
  43. store_bitpattern:
  44.     mov     al, byte [es:di]
  45.     mov     byte [gfx_buffer+di], al
  46.     inc     di
  47.     loop    store_bitpattern
  48.        
  49.     ; main PLASMA routine
  50. next_box:
  51.     rdtsc                       ; read time stamp counter
  52.     xchg    ax, di              ; use it as random offset to vga buffer
  53.     mov     cx, 0x8c            ; use a 140*140 box
  54.    
  55. next_line:
  56.     mov     bx, 0x8c
  57.  
  58. next_pixel:
  59.     inc     byte [es:bx+di]       ; increase color index in this box
  60.     or      byte [es:bx+di], 0x80 ; ensure upper bit is set
  61.     dec     bx
  62.     jnz     next_pixel
  63.     add     di, 0x140           ; add 320 = point to next line
  64.     loop    next_line
  65.  
  66.     ; delete previously painted text at old xy-position (bp)
  67.     dec     byte [paint_mode]   ; equals paint_mode = 0
  68.     call    text_display
  69.  
  70.     ; paint next next at a new xy-position (bp)
  71.     inc     bp
  72.     inc     byte [paint_mode]   ; equals paint_mode = 1
  73.     call    text_display
  74.  
  75.     ; repeat endlessly        
  76.     jmp     next_box
  77.  
  78.     ; paint_mode = 1: add, paint_mode = 0: sub
  79. text_display:
  80.     xor     si, si
  81.     mov     di, bp
  82.     mov     cx, gfx_size
  83. loop_restore_add:
  84.     mov     al, byte [gfx_buffer+si]
  85.     cmp     byte [paint_mode], 1
  86.     jne     loop_restore_sub
  87.     add     byte [es:di], al
  88.     or      byte [es:di], 0x80
  89.     jmp     loop_restore_cont
  90. loop_restore_sub:
  91.     sub     byte [es:di], al
  92. loop_restore_cont:
  93.     inc     si
  94.     inc     di
  95.     loop    loop_restore_add
  96.     ret
  97.        
  98. ; data which is compiled to the .com file          
  99. section .data
  100.  
  101. paint_mode  db      1                   ; toggles between 1 and 0
  102. text_size   equ     16
  103. text_data   db      "tuque FEZ sy2002"  ; may be one line of text at maximum
  104.  
  105. ; uninitialized RAM data
  106. section .bss
  107.  
  108. gfx_size    equ     320*8       ; size of one text line on the screen
  109. gfx_buffer  resb    gfx_size    ; amount of bytes
');