home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 3 / FREEWARE.BIN / towns_os / etv / etv.s < prev   
Text File  |  1980-01-02  |  12KB  |  492 lines

  1. /*
  2.                TV☆TOWNS  -リアルタイムエフェクタ-
  3.  
  4.                      Version  1.0       1990/04/25    
  5.  
  6.                          by Pumpkin (MHD00746)     
  7. */
  8.  
  9.           .text
  10.           .data
  11.  
  12.           /* 初期化 */
  13.  
  14.           call   G_INIT
  15.           call   KEY_INIT
  16.  
  17.           movl   %esp,(esp_w)           /* パレットテーブル領域を作る */
  18.           movl   $0x8000,%ecx
  19. ini_lp:   pushw  $0
  20.           loop   ini_lp
  21.           movl   %esp,(table)
  22.  
  23.           movb   $0,%al                 /* 320×240 ロウスキャン */
  24.           movw   $11,%dx
  25.           call   SCREEN_MODE
  26.           mov    $1,%al
  27.           mov    $11,%dx
  28.           call   SCREEN_MODE
  29.  
  30.           movb   $1,%al                 /* レイヤ1が前、レイヤ0非表示 */ 
  31.           movw   $2,%edx
  32.           call   DISPLAY_PAGE
  33.  
  34.           movb   $0x43,%ah
  35.           movb   $0,%bl
  36.           movw   $0x7f7f,%dx
  37.           lcall  %fs:(0x80)             /* ライン入力オン */
  38.  
  39.  
  40.           /* メインルーチン */
  41.  
  42.           movb   $0x31,%dl
  43.  
  44. Main_loop:
  45.  
  46.           cmpb   $13,%dl
  47.           je     Main_Bye
  48.  
  49.           cmpb   $0x31,%dl
  50.           je     normal
  51.  
  52.           cmpb   $0x32,%dl
  53.           je     mono_sub
  54.  
  55.           cmpb   $0x33,%dl
  56.           je     sep_sub 
  57.  
  58.           cmpb   $0x34,%dl
  59.           je     nega_sub
  60.  
  61.           cmpb   $0x35,%dl
  62.           je     c512_sub
  63.  
  64.           cmpb   $0x36,%dl
  65.           je     green_sub
  66.  
  67.           cmpb   $0x37,%dl
  68.           je     red_sub 
  69.  
  70.           cmpb   $0x38,%dl
  71.           je     blue_sub
  72.  
  73. Main_ret:         
  74.           call   effect
  75.  
  76.           jmp    Main_loop
  77.  
  78.  
  79.           /* 後処理 */
  80.  
  81. Main_Bye:
  82.           movb   $0x43,%ah
  83.           movb   $0,%bl
  84.           xorw   %dx,%dx
  85.           lcall  %fs:(0x80)           /* ライン入力オフ */
  86.           
  87.           call   G_INIT
  88.  
  89.           movb   $0,%al               /* MS-DOSの画面 */
  90.           movw   $1,%dx
  91.           call   SCREEN_MODE
  92.           movb   $1,%al
  93.           movw   $1,%dx
  94.           call   SCREEN_MODE
  95.           movb   $1,%al               /* レイヤ1が前、レイヤ全表示 */ 
  96.           movl   $3,%edx
  97.           call   DISPLAY_PAGE
  98.  
  99.           movw   $0x440,%dx           /* 1024 x 512 */
  100.           movb   $0x18,%al
  101.           outb   %al,%dx
  102.           addw   $2,%dx
  103.           movw   $0x80,%ax
  104.           outw   %ax,%dx
  105.  
  106.  
  107.           movl   (esp_w),%esp
  108.  
  109.           movw   $0x4c00,%ax          /* さよなら */
  110.           int    $0x21
  111.  
  112.  
  113.  
  114.           /* 通常表示 */
  115.  
  116. normal:
  117.           mov    $1,%al               /* レイヤ1を透明にする */
  118.           call   WRITE_PAGE
  119.           mov    $0x8000,%edx
  120.           call   BACK_COLOR
  121.           call   CLS
  122.  
  123.           movw   $0x1a81,%ax
  124.           lcall  %fs:(0x20)           /* インポーズオン */
  125.  
  126. no_lp:    call   INKEY                /* while inkey$="":wend */
  127.           cmpb   $0,%dl
  128.           je     no_lp
  129.  
  130. no_jp:    cmpb   $13,%dl              /* キー内容チェック */
  131.           je     no_bye
  132.           cmpb   $0x38,%dl
  133.           jg     no_lp
  134.           cmpb   $0x31,%dl
  135.           jl     no_lp
  136.  
  137. no_bye:
  138.           movw   $0x1a00,%ax
  139.           lcall  %fs:(0x20)           /* インポーズオフ */
  140.  
  141.           jmp    Main_loop
  142.  
  143.  
  144.  
  145.           /* エフェクト表示 */
  146. effect:
  147.           mov    $1,%al               /* レイヤ1を黒にする */
  148.           call   WRITE_PAGE
  149.           xorl   %edx,%edx
  150.           call   BACK_COLOR
  151.           call   CLS
  152.  
  153.           movb   $0,%al               /* デジタイズはレイヤ0へ */
  154.           call   WRITE_PAGE
  155.  
  156.           pushl  $0x104               /* 2画面モードのセグメント */
  157.           pop    %es
  158.  
  159.           movw   $0x1b01,%ax
  160.           movl   $G_work,%edi
  161.           lcall  %fs:(0x20)           /* デジタイズオン */
  162.  
  163.           movl   (table),%ebp         /* レジスタに定数設定 */
  164.           xorl   %ebx,%ebx
  165.  
  166. ef_lp0:
  167.           xorl   %edx,%edx
  168.           movl   $0x40000,%edi
  169.           movl   $239,%ecx
  170. ef_lp1:   push   %ecx
  171.           movl   $159,%ecx
  172. ef_lp2:
  173.           movl   %es:(%edx),%eax      /* レイヤ0からとる */
  174.           movw   %ax,%bx
  175.           leal   (%ebp,%ebx,2),%esi   /* パレットアクセス */
  176.           movsw
  177.           shrl   $16,%eax
  178.           leal   (%ebp,%eax,2),%esi   /* パレットアクセス */
  179.           movsw
  180.           addl   $4,%edx
  181.           loop   ef_lp2
  182.           pop    %ecx
  183.           addl   $388,%edx
  184.           addl   $388,%edi
  185.           loop   ef_lp1
  186.  
  187.           call   INKEY
  188.           cmpb   $0,%dl
  189.           je     ef_lp0
  190.  
  191.           cmpb   $13,%dl              /* キー内容チェック */
  192.           je     ef_bye
  193.           cmpb   $0x38,%dl
  194.           jg     ef_lp0
  195.           cmpb   $0x31,%dl
  196.           jl     ef_lp0
  197.  
  198. ef_bye:
  199.           movw   $0x1b00,%ax
  200.           movl   $G_work,%edi
  201.           lcall  %fs:(0x20)           /* デジタイズオフ */
  202.  
  203.           ret
  204.  
  205.  
  206.           /* モノクロのパレットテーブル作成 */
  207.  
  208. mono_sub:
  209.           movl   (table),%ebp         /* レジスタに定数設定 */
  210.  
  211.           movl   $0,%ecx
  212. mono_lp0: push   %ecx
  213.           sar    $10,%ecx             /* RGBの分離 */
  214.           andl   $0x1f,%ecx
  215.           movl   %ecx,%eax
  216.  
  217.           movl   (%esp),%ecx
  218.           sar    $5,%ecx
  219.           andl   $0x1f,%ecx
  220.           dec    %ecx                 /* 人の目にはG>R>Bと見えるので輝度補正 */
  221.           cmpl   $0,%ecx
  222.           jge    mono_jp1
  223.           xor    %ecx,%ecx
  224. mono_jp1: addl   %ecx,%eax
  225.  
  226.           movl   (%esp),%ecx
  227.           andl   $0x1f,%ecx
  228.           dec    %ecx                 /* 人の目にはG>R>Bと見えるので輝度補正 */
  229.           dec    %ecx
  230.           cmpl   $0,%ecx
  231.           jge    mono_jp2
  232.           xor    %ecx,%ecx
  233. mono_jp2: addl   %ecx,%eax
  234.  
  235.           movb   $3,%cl
  236.           divb   %cl
  237.           andl   $0xff,%eax            /* ahは余りが入っているので */          
  238.           movw   $1057,%cx
  239.           mull   %cx
  240.  
  241.           pop    %ecx
  242.           movw   %ax,(%ebp,%ecx,2)    /* addr=ebp+ecx*2 */
  243.  
  244.           inc    %ecx
  245.           cmpl   $0x8000,%ecx
  246.           jne    mono_lp0
  247.  
  248.           jmp    Main_ret
  249.  
  250.  
  251.           /* セピア色のパレットテーブル作成 */
  252.  
  253. sep_sub:
  254.           movl   (table),%ebp         /* レジスタに定数設定 */
  255.  
  256.           movl   $0,%ecx
  257. sep_lp0:  push   %ecx
  258.           sar    $10,%ecx             /* RGBの分離 */
  259.           andl   $0x1f,%ecx
  260.           movl   %ecx,%eax
  261.  
  262.           movl   (%esp),%ecx
  263.           sar    $5,%ecx
  264.           andl   $0x1f,%ecx
  265.           addl   %ecx,%eax
  266.  
  267.           movl   (%esp),%ecx
  268.           andl   $0x1f,%ecx
  269.           addl   %ecx,%eax
  270.  
  271.           movb   $3,%cl
  272.           divb   %cl
  273.           andl   $0xff,%eax            /* ahは余りが入っているので */
  274.           dec    %eax                  /* セピア色の調合 */
  275.           dec    %eax
  276.           cmpl   $0,%eax
  277.           jge    sep_jp0
  278.           xor    %eax,%eax
  279. sep_jp0:  movl   %eax,(red)
  280.           dec    %eax
  281.           cmpl   $0,%eax
  282.           jge    sep_jp1
  283.           xor    %eax,%eax
  284. sep_jp1:  movl   %eax,(green)
  285.           dec    %eax
  286.           cmpl   $0,%eax
  287.           jge    sep_jp2
  288.           xor    %eax,%eax
  289. sep_jp2:  movl   %eax,(blue)
  290.           movl   (green),%eax
  291.           shl    $5,%eax
  292.           addl   (red),%eax
  293.           shl    $5,%eax
  294.           addl   (blue),%eax
  295.  
  296.           pop    %ecx
  297.           movw   %ax,(%ebp,%ecx,2)    /* addr=ebp+ecx*2 */
  298.  
  299.           inc    %ecx
  300.           cmpl   $0x8000,%ecx
  301.           jne    sep_lp0
  302.  
  303.           jmp    Main_ret
  304.  
  305.  
  306.           /* 反転のパレットテーブル作成 */
  307. nega_sub:
  308.           movl   (table),%ebp         /* レジスタに定数設定 */
  309.  
  310.           movl   $0,%ecx
  311. nega_lp0: movl   %ecx,%eax
  312.           xorw   $0x7fff,%ax
  313.           movw   %ax,(%ebp,%ecx,2)    /* addr=ebp+ecx*2 */
  314.           inc    %ecx
  315.           cmpl   $0x8000,%ecx
  316.           jne    nega_lp0
  317.  
  318.           jmp    Main_ret
  319.  
  320.  
  321.           /* 512色のパレットテーブル作成 */
  322. c512_sub:
  323.           movl   (table),%ebp         /* レジスタに定数設定 */
  324.  
  325.           movl   $0,%ecx
  326. c512_lp0: movl   %ecx,%eax
  327.           andw   $0x739c,%ax
  328.           movw   %ax,(%ebp,%ecx,2)    /* addr=ebp+ecx*2 */
  329.           inc    %ecx
  330.           cmpl   $0x8000,%ecx
  331.           jne    c512_lp0
  332.  
  333.           jmp    Main_ret
  334.  
  335.  
  336.           /* 緑のパレットテーブル作成 */
  337. green_sub:
  338.           movl   (table),%ebp         /* レジスタに定数設定 */
  339.  
  340.           movl   $0,%ecx
  341. green_lp: movl   %ecx,%eax
  342.           andl   $0x7c00,%eax
  343.           movw   %ax,(%ebp,%ecx,2)    /* addr=ebp+ecx*2 */
  344.           inc    %ecx
  345.           cmpl   $0x8000,%ecx
  346.           jne    green_lp
  347.  
  348.           jmp    Main_ret
  349.  
  350.  
  351.           /* 赤のパレットテーブル作成 */
  352. red_sub:
  353.           movl   (table),%ebp         /* レジスタに定数設定 */
  354.  
  355.           movl   $0,%ecx
  356. red_lp:   movl   %ecx,%eax
  357.           andl   $0x3e0,%eax
  358.           movw   %ax,(%ebp,%ecx,2)    /* addr=ebp+ecx*2 */
  359.           inc    %ecx
  360.           cmpl   $0x8000,%ecx
  361.           jne    red_lp
  362.  
  363.           jmp    Main_ret
  364.  
  365.  
  366.           /* 青のパレットテーブル作成 */
  367. blue_sub:
  368.           movl   (table),%ebp         /* レジスタに定数設定 */
  369.  
  370.           movl   $0,%ecx
  371. blue_lp:  movl   %ecx,%eax
  372.           andl   $0x1f,%eax
  373.           movw   %ax,(%ebp,%ecx,2)    /* addr=ebp+ecx*2 */
  374.           inc    %ecx
  375.           cmpl   $0x8000,%ecx
  376.           jne    blue_lp
  377.  
  378.           jmp    Main_ret
  379.  
  380.  
  381.           /* サブルーチン */
  382.           
  383.           /* G-BIOSの初期化 */
  384. G_INIT:
  385.           push   %ds
  386.           pop    %gs
  387.           push   %ds
  388.           pop    %es
  389.           movl   $1536,%ecx
  390.           movl   $G_work,%edi
  391.           movb   $0,%ah
  392.           pushl  $0x0110
  393.           pop    %fs    
  394.           lcall  %fs:(0x20)
  395.           ret
  396.  
  397.           /* スクリーンモードの指定 */
  398. SCREEN_MODE:
  399.           /* al:レイヤ  dx:スクリーンモード  */
  400.           movb   $1,%ah
  401.           movl   $G_work,%edi
  402.           lcall  %fs:(0x20)
  403.           ret
  404.  
  405.           /* 画面表示位置の指定 */
  406. SCREEN_POS:
  407.           /* bx:縦位置 dx:横位置 */
  408.           movw   $0x201,%ax
  409.           movl   $G_work,%edi
  410.           lcall  %fs:(0x20)
  411.           ret
  412.  
  413.           /* 画面拡大率の指定 */
  414. ZOOM_SCREEN:
  415.           /* bx:縦倍率 dx:横倍率 */
  416.           movw   $0x202,%ax
  417.           movl   $G_work,%edi
  418.           lcall  %fs:(0x20)
  419.           ret
  420.  
  421.  
  422.           /* WIDTHの指定 */
  423. SCREEN_WIDTH:
  424.           /* bx:縦ドット数 dx:横ドット数 */
  425.           movw   $0x203,%ax
  426.           movl   $G_work,%edi
  427.           lcall  %fs:(0x20)
  428.           ret
  429.  
  430.           /* 書き込みページの設定 */
  431. WRITE_PAGE:
  432.           /* al:ページ */
  433.           movb  $5,%ah
  434.           movl  $G_work,%edi
  435.           lcall %fs:(0x20)
  436.           ret
  437.  
  438.           /* 表示ページの設定 */
  439. DISPLAY_PAGE:
  440.           /* al:プライオリティ edx:表示データ */
  441.           movb  $6,%ah
  442.           movl  $G_work,%edi
  443.           lcall %fs:(0x20)
  444.           ret
  445.  
  446.           /* 背景色指定 */
  447. BACK_COLOR:
  448.           /* edx:色 */
  449.           mov   $0x701,%ax
  450.           movl  $G_work,%edi
  451.           lcall %fs:(0x20)
  452.           ret
  453.  
  454.           /* 画面消去 */
  455. CLS:
  456.           movb  $0x20,%ah
  457.           movl  $G_work,%edi
  458.           lcall %fs:(0x20)
  459.           ret
  460.  
  461.           /* キー入力の初期化 */
  462. KEY_INIT:
  463.           movb   $0,%ah
  464.           int    $0x90
  465.           ret
  466.  
  467.           /* キー入力を待つ */
  468.  
  469.           .align 4   
  470. KEY_INP:
  471.           movw   $0x900,%ax 
  472.           int    $0x90
  473.           ret
  474.  
  475.           /* キー入力を待たない */
  476.  
  477.           .align 4   
  478. INKEY:
  479.           movw   $0x901,%ax 
  480.           int    $0x90
  481.           ret
  482.  
  483.  
  484.  
  485.           /* ワーク */
  486. green:     .long  0
  487. red:       .long  0
  488. blue:      .long  0
  489. table:     .long  0
  490. esp_w:     .long  0
  491. G_work:    .space 1536
  492.