home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / asac2p2 / asac2p18bit.s next >
Text File  |  1980-01-03  |  23KB  |  1,199 lines

  1. *-----------------------------------------------------------------------
  2. *                            AsAc2p18bit.s  v1.5   05-10-96
  3. *
  4. *
  5. *         a fast 18bit truecolor ham8 c2p routine by ASA/Cirion
  6. *                Modified from Peter Mcgavins Gloom c2p
  7. *  On 030/28Mhz machine this takes 1.6 frames from processor to convert
  8. *                         ( 160*100 2x2 screen )
  9. *         Then blitter is activated to do 1 blit for every plane
  10. *                     Long word writes to chipmem !
  11. *                           Double buffering !
  12. *                                Linear !
  13. *
  14. *              Remember to thank me if you use this !  =)
  15. *
  16. * tchunky .l = ptr to truecolor chunky area in fast mem  160*100*4 RBGB
  17. * Cbuf = buffer for c2p routine. Processor converts chunky to Cbuf
  18. *        and then blitter converts from Cbuf to screen with 1 blit/plane
  19. * Chip_map2 .l = ptr to 640/8*100*2 area in chip mem for Ham8 Mask bits
  20. * Chip_map .l = ptr to 640/8*100*6 screen 1 in chip mem
  21. * Chip_map3 .l = ptr to 640/8*100*6 screen 2 in chip mem
  22. * c2p_blitter_4pass .w = blitter progress
  23. *                       0-blitter is ready for blits
  24. *                       10- blitting plane 1
  25. *                       11- blitting plane 2
  26. *                       12- blitting plane 3
  27. *                       13- blitting plane 4
  28. *                       14- blitting plane 5
  29. *                       15- blitting plane 6
  30. *                       16- all done   -> 0
  31. *
  32. *
  33. * Works nice... Used in an intro called Hope2 by Cirion at Skenery'96
  34. *               Look at cirhope2.lzx....
  35. *
  36. *  Don't blame me if you destroy your computer/software with this ! ;)
  37. *
  38. * My E-mail address:   juhpin@freenet.hut.fi
  39. *
  40. *
  41. *               And get your ass to Demolition II -party
  42. *                           at Joensuu !!!  22-24 NOV 96
  43. *                  Read demolition.txt for more info !
  44. *-----------------------------------------------------------------------
  45.  
  46.  
  47.  
  48. ;--------------- Made with Trashm'one -------------
  49. ;----- So it works also with other compilers ------
  50. ;-------------- Just compile and run ! ------------
  51. ;---------------- Shows FPS rate (put fpss equ 1)--
  52.  
  53. ;***********************************************************
  54. tasta        equ    1    ; 1-if run from asmone  0-if from shell
  55. ntsc        equ    1    ; 1-NTSC (full screen :-)  0-PAL
  56. fpss        equ    0    ; 1-fps numbers  0-no numbers
  57. hiiri_nappi    equ    1
  58.  
  59. Y_SIZE        equ    100    ; blitter y lines
  60. BLTVERT        equ    Y_SIZE*80/2
  61.  
  62. _LVOAllocMem        equ    -$00c6
  63. _LVOFreeMem        equ    -$00d2
  64.  
  65. call    MACRO
  66.     jsr    _lvo\1(a6)
  67.     ENDM
  68.  
  69. push    MACRO
  70.     movem.l    d0-d7/a0-a6,-(sp)
  71.     ENDM
  72. pull    MACRO
  73.     movem.l    (sp)+,d0-d7/a0-a6
  74.     ENDM
  75.  
  76. waitblit    MACRO
  77. _wait\@:    btst    #14,dmaconr+custom      ; use #6 if this don't work
  78.         bne.s    _wait\@
  79.     ENDM
  80.  
  81. ;---- custom regs...
  82. BLTSIZH    equ    $05e
  83. BLTSIZV    equ    $05c
  84.  
  85. custom  = $dff000
  86.  
  87. bltcon0 = $040
  88. bltcon1 = $042
  89. bltafwm = $044
  90. bltalwm = $046
  91. bltapth = $050
  92. bltbpth = $04c
  93. bltdpth = $054
  94. bltamod = $064
  95. bltbmod = $062
  96. bltdmod = $066
  97. bltcdat = $070
  98.  
  99. bpl1pth = $0e0
  100. bpl1ptl = $0e2
  101. bpl2pth = $0e4
  102. bpl2ptl = $0e6
  103. bpl3pth = $0e8
  104. bpl3ptl = $0ea
  105. bpl4pth = $0ec
  106. bpl4ptl = $0ee
  107. bpl5pth = $0f0
  108. bpl5ptl = $0f2
  109. bpl6pth = $0f4
  110. bpl6ptl = $0f6
  111. bpl7pth = $0f8
  112. bpl7ptl = $0fa
  113. bpl8pth = $0fc
  114. bpl8ptl = $0fe
  115. bplcon0 = $100
  116. bplcon1 = $102
  117. bplcon2 = $104
  118. bplcon3    = $106
  119.  
  120. cop1lch = $080
  121. copjmp1 = $088
  122.  
  123. ddfstrt = $092
  124. ddfstop = $094
  125. diwstrt = $08e
  126. diwstop = $090
  127. dmacon  = $096
  128. dmaconr = $002
  129.  
  130. intena  = $09a
  131. intreq  = $09c
  132. intreqr = $01e
  133.  
  134. spr0pth = $120
  135. spr0ptl = $122
  136. spr1pth = $124
  137. spr1ptl = $126
  138. spr2pth = $128
  139. spr2ptl = $12a
  140. spr3pth = $12c
  141. spr3ptl = $12e
  142. spr4pth = $130
  143. spr4ptl = $132
  144. spr5pth = $134
  145. spr5ptl = $136
  146. spr6pth = $138
  147. spr6ptl = $13a
  148. spr7pth = $13c
  149. spr7ptl = $13e
  150.  
  151.  
  152. EXT_0004    EQU    $DFF01F
  153. FASTME        equ    %10000000000000001
  154. CHIPME        equ    %10000000000000010
  155.  
  156. hiirulainen:    MACRO
  157. ;      btst    #10,potgor+custom    ; rigth mouse
  158.       btst    #6,$bfe001        ; left mouse
  159.       beq    prgrts
  160.     ENDM
  161.  
  162. getmem:    MACRO
  163.     move.l    #\2,d0
  164.     move.l    #\3,d1
  165.     move.l    $4,a6
  166.      call    AllocMem
  167.     move.l    d0,\1
  168.     beq    \4
  169.     ENDM
  170.  
  171. freeit:    MACRO
  172.     move.l    \1,a1
  173.     move.l    #\2,d0
  174.     move.l    $4,a6
  175.     call    FreeMem
  176.     ENDM
  177.  
  178. clossi:    MACRO
  179.     move.l    handle,d1    ;
  180.     move.l    dosbase,a6
  181.     call    Close
  182.     ENDM
  183.  
  184. opni:    MACRO
  185.     move.l    #1005,d2
  186.     move.l    dosbase,a6
  187.     call    Open
  188.     move.l    d0,handle
  189.     ENDM
  190.  
  191. ;**********************************************************************
  192.     section    ohjelma,code
  193.  
  194. wbstartup:
  195.     CLR.L    LAB_0003
  196.     MOVE.L    #$00000000,A1
  197.     MOVE.L    $4,A6
  198.     JSR    -294(A6)        ; findtask
  199.     MOVE.L    D0,A4
  200.     TST.L    172(A4)            ; onko cli?
  201.     BEQ.S    LAB_0000        ; wb
  202.     BRA.S    cli            ; cli
  203. LAB_0000:
  204.     moveq    #0,d0
  205.     cmp    #tasta,d0
  206.     bne    cli
  207.     LEA    92(A4),A0
  208.     MOVE.L    $4,A6
  209.     JSR    -384(A6)        ; waitport
  210.     LEA    92(A4),A0
  211.     MOVE.L    $4,A6
  212.     JSR    -384(A6)        ; waitport
  213.     MOVE.L    D0,LAB_0003
  214.     MOVEM.L    (sp)+,D0/A0
  215. cli:
  216.     BSR.S    LAB_0004
  217.     MOVE.L    D0,-(sp)
  218.     TST.L    LAB_0003
  219.     BEQ.S    LAB_0002
  220.     MOVE.L    $4,A6
  221.     JSR    -132(A6)        ; forbid
  222.     MOVE.L    LAB_0003(PC),A1
  223.     MOVE.L    $4,A6
  224.     JSR    -378(A6)        ; replymsg
  225.  
  226. LAB_0002:
  227.     MOVE.L    (sp)+,D0
  228.     RTS
  229. LAB_0003:
  230.     ORI.B    #$00,D0
  231.  
  232. LAB_0004:
  233.  
  234. ; --- varaa muistia
  235.     getmem    fasti,160*128*4+94000,FASTME,ei_fastia2
  236.  
  237.     getmem    chip_map,80*100*8,CHIPME,ei_chip_map
  238.     getmem    chip_map2,80*100*2,CHIPME,ei_chip_map2
  239.     getmem    chip_map3,80*100*6,CHIPME,ei_chip_map3
  240.     move.l    chip_map,chipbuf
  241.  
  242. ;;;;;;;
  243.     move.l    $4,a6
  244.     move.l    #intuname,A1
  245.     moveq    #0,d0
  246.     jsr    -552(a6)        ; openlibrary
  247.     move.l    d0,intubase
  248.     beq    ei_intu
  249.  
  250.     move.l    $4,a6
  251.     move.l    #gfxname,A1
  252.     moveq    #0,d0
  253.     jsr    -552(a6)        ; openlibrary
  254.     move.l    d0,gfxbase
  255.     beq    ei_gfx
  256.  
  257.  
  258.     waitblit
  259.  
  260.     MOVE.L    gfxbase,A6
  261.     JSR    -456(A6)        ; own blitter
  262.  
  263.     MOVEQ    #0,D0
  264.     MOVE.L    $4,A6
  265.     BTST    #0,297(A6)        ; flags
  266.     BEQ.S    storevbr
  267.     LEA    getvbr0(PC),A5
  268.     JSR    -30(A6)            ; supervisor
  269.     BRA.S    storevbr
  270. getvbr0:
  271.     DC.W    $4E7A
  272.     DC.W    $0801
  273.     RTE
  274.  
  275. _vbr:    dc.l    0
  276.     ORI.B    #$00,D0
  277.  
  278. storevbr:
  279.     MOVE.L    D0,_vbr
  280.  
  281. ;INT3 VBR
  282.     MOVE.L    _vbr(PC),A0
  283.     MOVE.L    108(A0),oldv
  284.  
  285. ; reset screen hardware
  286.     MOVE.L    gfxbase,A6
  287.     MOVE.L    34(A6),oldview
  288.     MOVE.L    #$00000000,A1
  289.     JSR    -222(A6)        ; loadview
  290.  
  291.     MOVE    #25-1,D7
  292. nowaittof:
  293.     MOVE    #$0020,intreq+custom
  294. LAB_000B:
  295.     BTST    #5,EXT_0004
  296.     BEQ.S    LAB_000B
  297.     DBF    D7,nowaittof
  298.  
  299.     MOVE    #$0020,dmacon
  300.     MOVE    #$81C0,dmacon
  301.  
  302. ;******************************************** our program
  303.     BSR    prg
  304. ;******************************************** end of program
  305.  
  306.     MOVE    #$4000,intena+custom        ; remove blitter
  307.     MOVE.L    _vbr(PC),A0
  308.     MOVE.L    oldv,108(A0)
  309.  
  310.     waitblit
  311.     waitblit
  312.     waitblit
  313.  
  314.     MOVE    #$07FC,intreq+custom
  315.     MOVE    #$C000,intena+custom
  316.  
  317.     MOVE.L    gfxbase,A6
  318.     JSR    -462(A6)        ; disown blitter
  319.     MOVE.L    oldview,A1
  320.     JSR    -222(A6)        ; loadview
  321.  
  322.     MOVE    #$0080,dmacon
  323.     MOVE.L    gfxbase,A0
  324.     MOVE.L    38(A0),cop1lch+custom
  325.     MOVE    #$0000,copjmp1+custom
  326.     MOVE    #$81A0,dmacon
  327.  
  328.     MOVE.L    intubase,A6
  329.     JSR    -390(A6)        ; rethinkdisplay
  330.  
  331.     MOVE.L    gfxbase,A1
  332.     MOVE.L    $4,A6
  333.     JSR    -414(A6)        ; closelibrary
  334. ei_gfx:
  335.     MOVE.L    intubase,A1
  336.     MOVE.L    $4,A6
  337.     JSR    -414(A6)        ; closelibrary
  338. ei_intu:
  339.  
  340. ;;;
  341.  
  342.     freeit    chip_map3,80*100*6
  343. ei_chip_map3:
  344.     freeit    chip_map2,80*100*2
  345. ei_chip_map2:
  346.     freeit    chip_map,80*100*8
  347. ei_chip_map:
  348.  
  349.     freeit    fasti,160*128*4+94000
  350. ei_fastia2:
  351.  
  352.     CLR.L    D0
  353.     RTS
  354.  
  355.  
  356. ;**************************************************************
  357.  
  358. prg:
  359.     move.l    chip_map,chipbuf
  360.     move.l    chip_map,dispbuf
  361.  
  362.     move.l    _vbr,a1
  363.     move.l    #vbi1,$6c(a1)
  364.  
  365.  ifne fpss
  366.     moveq    #0,d6
  367.     moveq    #0,d5
  368.     move.l    #font_metal,a0
  369.     move.l    #font_1,a1
  370.     move.w    #80*8-1,d7
  371.     jsr    convaa_flare
  372.  endc
  373.  
  374.  
  375.     clr.w    c2p_blitter_4pass
  376.     move.w    #%1000000001100000,intena+custom    ; blitter/vbi int
  377.     move.w    #%0000010000000000,dmacon+custom
  378.  
  379.     jsr    init_ham8_screen
  380.  
  381.     bsr    ham8_ef
  382.      hiirulainen
  383.  
  384. prgrts:
  385.     clr.w    c2p_blitter_4pass
  386.     rts
  387.  
  388. ;---------------------------------------------------------------------
  389. ham8_ef
  390.     move.w    #160*100-1,d5
  391. tee_koko_kuva
  392.  
  393.     move.l    tchunky,a0    ; ptr to screen
  394.     add.l    menossa,a0
  395.     move.b    luku_r,d0        ; R
  396.     lsl.l    #8,d0
  397.     move.b    luku_b,d0        ; B
  398.     lsl.l    #8,d0
  399.     move.b    luku_g,d0        ; G
  400.     lsl.l    #8,d0
  401.     move.b    luku_b,d0        ; B
  402.     move.l    d0,(a0)        ; RBGB
  403.  
  404.     addq.l    #4,menossa
  405.  
  406.  
  407.     move.w    #30-1,d6
  408. nopeemmin:
  409.     addq.b    #1,luku_b        ; add blue
  410.     cmp.b    #63,luku_b        ; if blue >63
  411.     bls.s    ei_viela_g
  412.      clr.b    luku_b            ; clear blue
  413.      addq.b    #1,luku_g        ; add green
  414. ei_viela_g
  415.  
  416.     cmp.b    #63,luku_g        ; if green >63
  417.     bls.s    ei_viela_r
  418.      clr.w    luku_g            ; clear green
  419.      addq.b    #1,luku_r        ; add red
  420. ei_viela_r
  421.     dbf    d6,nopeemmin
  422.     dbf    d5,tee_koko_kuva
  423.  
  424. loop_ham8
  425. ;/////////////////
  426.     ifne fpss
  427.      jsr    laita_numerot
  428.     endc
  429.  
  430.     jsr    change_buffers
  431.     jsr    convert_tchunky
  432.  
  433.     addq.w    #1,frameja
  434. ;/////////////////
  435.      ifne hiiri_nappi
  436.       btst    #6,$bfe001        ; left mouse
  437. ;      btst    #10,potgor+custom    ; right mouse
  438.       beq.s    vituiks_pois
  439.      endc
  440.     bra    loop_ham8
  441. vituiks_pois
  442.     rts
  443.  
  444. ;////////////////////////////////////////////////////
  445. ;////////////////////////////////////////////////////////////////
  446. init_ham8_screen:
  447.     move.l    #c2p_cop,cop1lch+custom
  448.  
  449.     move.l    chip_map2,d0
  450.     move.l    #bluit,a1
  451.     swap    d0
  452.     move.w    d0,(a1)
  453.     swap    d0
  454.     move.w    d0,4(a1)
  455.     add.l    #80*100,d0
  456.     swap    d0
  457.     move.w    d0,8(a1)
  458.     swap    d0
  459.     move.w    d0,12(a1)
  460.  
  461.     jsr    aseta_disp
  462.  
  463.  move.l    chip_map2,a0        ; tee 1/2 plane valmiiks ham8lle
  464.  move.l    a0,a1
  465.  add.l    #80*100,a1
  466.  move.w    #80*100-1,d7
  467. duu_rgb_plane_class:
  468.  move.b    #%11001100,(a1)+    ; plane 1
  469.  move.b    #%01110111,(a0)+    ; plane 0
  470.  dbf    d7,duu_rgb_plane_class
  471.  
  472.  
  473.     move.l    #tyhja,d0
  474.     move.l    #spruit,a1
  475.     move.w    d0,(a1)
  476.     move.w    d0,4(a1)
  477.     move.w    d0,8(a1)
  478.     move.w    d0,12(a1)
  479.     move.w    d0,16(a1)
  480.     move.w    d0,20(a1)
  481.     move.w    d0,24(a1)
  482.     move.w    d0,28(a1)
  483.     move.l    #spruit2,a1
  484.     swap    d0
  485.     move.w    d0,(a1)
  486.     move.w    d0,4(a1)
  487.     move.w    d0,8(a1)
  488.     move.w    d0,12(a1)
  489.     move.w    d0,16(a1)
  490.     move.w    d0,20(a1)
  491.     move.w    d0,24(a1)
  492.     move.w    d0,28(a1)
  493.  
  494.     move.l    fasti,tchunky
  495.     move.l    tchunky,tchunky_end
  496.     add.l    #160*100*4,tchunky_end
  497.     rts
  498. ;//////////////////////////////////////////////////////
  499. ;////////////////////////////////////////////////////////////////
  500. aseta_disp:
  501.     move.l    #bluit,a1
  502.     move.l    dispbuf,d0
  503.     swap    d0
  504.     move.w    d0,16(a1)
  505.     swap    d0
  506.     move.w    d0,20(a1)
  507.     add.l    #80*100,d0
  508.     swap    d0
  509.     move.w    d0,24(a1)
  510.     swap    d0
  511.     move.w    d0,28(a1)
  512.     add.l    #80*100,d0
  513.     swap    d0
  514.     move.w    d0,32(a1)
  515.     swap    d0
  516.     move.w    d0,36(a1)
  517.     add.l    #80*100,d0
  518.     swap    d0
  519.     move.w    d0,40(a1)
  520.     swap    d0
  521.     move.w    d0,44(a1)
  522.     add.l    #80*100,d0
  523.     swap    d0
  524.     move.w    d0,48(a1)
  525.     swap    d0
  526.     move.w    d0,52(a1)
  527.     add.l    #80*100,d0
  528.     swap    d0
  529.     move.w    d0,56(a1)
  530.     swap    d0
  531.     move.w    d0,60(a1)
  532.     rts
  533. ;//////////////////////////////////////////////////////
  534. change_buffers:
  535.     cmp.w    #1,dbuffer
  536.     beq.s    buffer_1
  537.       move.l    chip_map,chipbuf
  538.       move.l    chip_map3,dispbuf
  539.       move.w    #1,dbuffer
  540.     bra.s    ei_vbi_viel
  541.  
  542. buffer_1
  543.       move.l    chip_map3,chipbuf
  544.       move.l    chip_map,dispbuf
  545.       move.w    #0,dbuffer
  546. ei_vbi_viel
  547.       bsr    aseta_disp
  548.     rts
  549. ;/////////////////////////////////
  550.     cnop    0,4
  551. blitter_4pass_cont:
  552.     cmp.w    #10,c2p_blitter_4pass
  553.     beq.s    _plane_0
  554.     cmp.w    #11,c2p_blitter_4pass
  555.     beq.w    _plane_1
  556.     cmp.w    #12,c2p_blitter_4pass
  557.     beq.w    _plane_2
  558.     cmp.w    #13,c2p_blitter_4pass
  559.     beq.w    _plane_3
  560.     cmp.w    #14,c2p_blitter_4pass
  561.     beq.w    _plane_4
  562.     cmp.w    #15,c2p_blitter_4pass
  563.     beq.w    _plane_5
  564.     cmp.w    #16,c2p_blitter_4pass
  565.     beq.w    _planes_ready
  566.     rts
  567. ;0
  568. _plane_0:
  569.     move.l    #cbuf+4,bltapth+custom
  570.     move.l    #cbuf+2,bltbpth+custom
  571.     move.l    chipbuf,d0
  572.     move.l    d0,bltdpth+custom
  573.     move.w    #%0101010101010101,bltafwm+custom
  574.     move.w    #%0101010101010101,bltalwm+custom
  575.     move.w    #%0101010101010101,bltcdat+custom
  576.     move.w    #2,bltamod+custom
  577.     move.w    #2,bltbmod+custom
  578.     move.w    #0,bltdmod+custom
  579.     move.w    #%0000000000000000,bltcon1+custom
  580.     move.w    #%1111110111111000,bltcon0+custom
  581.     move.w    #BLTVERT,bltsizv+custom
  582.     move.w    #1,bltsizh+custom
  583.     move.w    #11,c2p_blitter_4pass
  584.     rts
  585. ;1
  586. _plane_1:
  587.     move.l    #cbuf,bltapth+custom
  588.     move.l    #cbuf+2,bltbpth+custom
  589.     move.l    chipbuf,d0
  590.     add.l    #8000,d0
  591.     move.l    d0,bltdpth+custom
  592.     move.w    #%1010101010101010,bltafwm+custom
  593.     move.w    #%1010101010101010,bltalwm+custom
  594.     move.w    #%0101010101010101,bltcdat+custom
  595.     move.w    #2,bltamod+custom
  596.     move.w    #2,bltbmod+custom
  597.     move.w    #0,bltdmod+custom
  598.     move.w    #%0001000000000000,bltcon1+custom
  599.     move.w    #%0000110111111000,bltcon0+custom
  600.     move.w    #BLTVERT,bltsizv+custom
  601.     move.w    #1,bltsizh+custom
  602.     move.w    #12,c2p_blitter_4pass
  603.     rts
  604. ;2
  605. _plane_2:
  606.     move.l    #cbuf+8000*2+4,bltapth+custom
  607.     move.l    #cbuf+8000*2+2,bltbpth+custom
  608.     move.l    chipbuf,d0
  609.     add.l    #8000*2,d0
  610.     move.l    d0,bltdpth+custom
  611.     move.w    #%0101010101010101,bltafwm+custom
  612.     move.w    #%0101010101010101,bltalwm+custom
  613.     move.w    #%0101010101010101,bltcdat+custom
  614.     move.w    #2,bltamod+custom
  615.     move.w    #2,bltbmod+custom
  616.     move.w    #0,bltdmod+custom
  617.     move.w    #%0000000000000000,bltcon1+custom
  618.     move.w    #%1111110111111000,bltcon0+custom
  619.     move.w    #BLTVERT,bltsizv+custom
  620.     move.w    #1,bltsizh+custom
  621.     move.w    #13,c2p_blitter_4pass
  622.     rts
  623. ;3
  624. _plane_3:
  625.     move.l    #cbuf+8000*2,bltapth+custom
  626.     move.l    #cbuf+8000*2+2,bltbpth+custom
  627.     move.l    chipbuf,d0
  628.     add.l    #8000*3,d0
  629.     move.l    d0,bltdpth+custom
  630.     move.w    #%1010101010101010,bltafwm+custom
  631.     move.w    #%1010101010101010,bltalwm+custom
  632.     move.w    #%0101010101010101,bltcdat+custom
  633.     move.w    #2,bltamod+custom
  634.     move.w    #2,bltbmod+custom
  635.     move.w    #0,bltdmod+custom
  636.     move.w    #%0001000000000000,bltcon1+custom
  637.     move.w    #%0000110111111000,bltcon0+custom
  638.     move.w    #BLTVERT,bltsizv+custom
  639.     move.w    #1,bltsizh+custom
  640.     move.w    #14,c2p_blitter_4pass
  641.     rts
  642. ;4
  643. _plane_4:
  644.     move.l    #cbuf+8000*4+4,bltapth+custom
  645.     move.l    #cbuf+8000*4+2,bltbpth+custom
  646.     move.l    chipbuf,d0
  647.     add.l    #8000*4,d0
  648.     move.l    d0,bltdpth+custom
  649.     move.w    #%0101010101010101,bltafwm+custom
  650.     move.w    #%0101010101010101,bltalwm+custom
  651.     move.w    #%0101010101010101,bltcdat+custom
  652.     move.w    #2,bltamod+custom
  653.     move.w    #2,bltbmod+custom
  654.     move.w    #0,bltdmod+custom
  655.     move.w    #%0000000000000000,bltcon1+custom
  656.     move.w    #%1111110111111000,bltcon0+custom
  657.     move.w    #BLTVERT,bltsizv+custom
  658.     move.w    #1,bltsizh+custom
  659.     move.w    #15,c2p_blitter_4pass
  660.     rts
  661. ;5
  662. _plane_5:
  663.     move.l    #cbuf+8000*4,bltapth+custom
  664.     move.l    #cbuf+8000*4+2,bltbpth+custom
  665.     move.l    chipbuf,d0
  666.     add.l    #8000*5,d0
  667.     move.l    d0,bltdpth+custom
  668.     move.w    #%1010101010101010,bltafwm+custom
  669.     move.w    #%1010101010101010,bltalwm+custom
  670.     move.w    #%0101010101010101,bltcdat+custom
  671.     move.w    #2,bltamod+custom
  672.     move.w    #2,bltbmod+custom
  673.     move.w    #0,bltdmod+custom
  674.     move.w    #%0001000000000000,bltcon1+custom
  675.     move.w    #%0000110111111000,bltcon0+custom
  676.     move.w    #BLTVERT,bltsizv+custom
  677.     move.w    #1,bltsizh+custom
  678.     move.w    #16,c2p_blitter_4pass
  679.     rts
  680.  
  681. _planes_ready:
  682.     move.w    #0,c2p_blitter_4pass
  683.     rts
  684. ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  685. ;///////////////////////////////////////////////////
  686. ;///////////////////////////////////////////////////
  687. laita_numerot:        ; show fps
  688.  ifne fpss
  689.     moveq    #0,d0
  690.     move.w    fps,d0
  691.     moveq    #0,d5
  692. kymppeja_viela:
  693.     cmp.l    #10,d0
  694.     blt.s    viel_ykoset
  695.     sub.l    #10,d0
  696.     addq.l    #1,d5
  697.     bra    kymppeja_viela
  698. viel_ykoset:
  699.     move.l    #font_1,a0
  700.     lsl.l    #3,d0
  701.      lsl.l    #2,d0        ; rgb
  702.     add.l    d0,a0
  703.     move.l    #296*4,d3    ; x
  704.     bsr.s    skriivaa2
  705.  
  706.     move.l    #font_1,a0
  707.     lsl.l    #3,d5
  708.      lsl.l    #2,d5        ; rgb
  709.     add.l    d5,a0
  710.     move.l    #288*4,d3    ; x
  711.     bsr.s    skriivaa2
  712.  endc
  713.     rts
  714.  
  715.  ifne fpss
  716. skriivaa2:            ; 256x256 chunky
  717.     move.l    tchunky,d4
  718.     add.l    d3,d4
  719.     add.l    #160*4*3,d4
  720.  
  721.     move.w    #8-1,d6
  722. fon_y2:    move.l    d4,a1
  723.     move.w    #8-1,d7
  724. fon_x2:
  725.     move.l    (a0)+,(a1)+
  726.     dbra    d7,fon_x2
  727.  
  728.     lea    80*4-8*4(a0),a0
  729.     add.l    #160*4,d4
  730.     dbra    d6,fon_y2
  731.     rts
  732.  endc
  733. ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  734. ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  735. ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  736. convaa_flare:
  737.      move.w    (a0)+,d0    ; lo
  738.      move.w    (a0)+,d2    ; hi
  739.     ror.w    #8,d0
  740.     move.b    d0,d1
  741.     ror.w    #8,d2
  742.     ror.w    #2,d2        ; 6 bit ei 8
  743.     move.b    d2,d3
  744.     and.b    #%11,d3
  745.     lsl.b    #2,d1
  746.     or.b    d3,d1
  747.     ;     not.b    d1
  748.  and.b    #%00111111,d1
  749. ; lsl.b    #2,d1
  750.  lsr.b    d6,d1
  751.  sub.b    d5,d1
  752.         cmp.b    #63,d1
  753.         bls.s    subbi_siibbi
  754.         moveq    #0,d1
  755. subbi_siibbi:
  756.     move.b    d1,(a1)
  757.  
  758.     rol.w    #4,d0
  759.     move.b    d0,d1
  760.     rol.w    #4,d2
  761.     move.b    d2,d3
  762.     and.b    #%11,d3
  763.     lsl.b    #2,d1
  764.     or.b    d3,d1
  765.     ;     not.b    d1
  766.  and.b    #%00111111,d1
  767. ; lsl.b    #2,d1
  768.  lsr.b    d6,d1
  769.  sub.b    d5,d1
  770.         cmp.b    #63,d1
  771.         bls.s    subbi_siibbi2
  772.         moveq    #0,d1
  773. subbi_siibbi2:
  774.     move.b    d1,2(a1)
  775.  
  776.     rol.w    #4,d0
  777.     move.b    d0,d1
  778.     rol.w    #4,d2
  779.     move.b    d2,d3
  780.     and.b    #%11,d3
  781.     lsl.b    #2,d1
  782.     or.b    d3,d1
  783.     ;     not.b    d1
  784.  and.b    #%00111111,d1
  785. ; lsl.b    #2,d1
  786.  lsr.b    d6,d1
  787.  sub.b    d5,d1
  788.         cmp.b    #63,d1
  789.         bls.s    subbi_siibbi3
  790.         moveq    #0,d1
  791. subbi_siibbi3:
  792.     move.b    d1,1(a1)
  793.     move.b    d1,3(a1)
  794.  
  795.     addq.l    #4,a1
  796.     dbf    d7,convaa_flare
  797.     rts
  798. ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  799. ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  800. convert_tchunky:
  801.     move.l    tchunky,a0
  802.             ;    move.l    chip_map,a1
  803.      move.l    #cbuf,a1
  804.     move.l    #640,d0
  805.     move.l    #100,d1
  806.     move.l    #80*100,d2
  807.     move.l    #80,d3
  808.     jsr    _c2p
  809.  
  810. ei_olla_viel_4pass_tehty_tchu:
  811.     tst.w    c2p_blitter_4pass
  812.     bne.s    ei_olla_viel_4pass_tehty_tchu
  813.  
  814.     move.w    #10,c2p_blitter_4pass
  815.     bsr    blitter_4pass_cont
  816.     rts
  817. ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  818.     section    muita_ohjelmia,code
  819.  
  820. hurja:    dc.w    0
  821. vbi1:
  822. ;*******************************
  823.     move.w    d0,hurja
  824.     move.w    intreqr+custom,d0
  825.     btst    #6,d0
  826.     beq.s    ei_blitter_normaali_vbi22
  827.         push
  828.         jsr    blitter_4pass_cont
  829.         pull
  830.         move.w    #%0000000001000000,intreq+custom
  831. ei_blitter_normaali_vbi22
  832.     btst    #5,d0
  833.     bne.s    edes_vbi_oli_se22
  834.     move.w    #%0000000000100000,intreq+custom
  835.     move.w    hurja,d0
  836.     rte
  837. edes_vbi_oli_se22
  838.     move.w    hurja,d0
  839.  
  840.     push
  841.     addq.l    #1,timer
  842.  
  843.     cmp.l    #50+10*NTSC,timer
  844.     ble.s    lasketaan_FPS22
  845.     move.w    frameja,fps
  846.     clr.l    timer
  847.     clr.w    frameja
  848. lasketaan_FPS22
  849.  
  850. ;*******************************
  851.     move.w    #%0000000000100000,intreq+custom
  852.     pull
  853.     rte
  854.  
  855. timer:    dc.l    0
  856.  
  857. ;////////////////////////////////////////////
  858.     section    rojdua,data
  859.  
  860. dosname:    dc.b    'dos.library',0
  861. intuname:    dc.b    'intuition.library',0
  862. gfxname:    dc.b    'graphics.library',0
  863.     even
  864. dosbase:    dc.l    0
  865. gfxbase:    dc.l    0
  866. intubase:    dc.l    0
  867. handle:        dc.l    0
  868. c2p_blitter_4pass    dc.w    0
  869. menossa:    dc.l    0
  870. fps:        dc.w    0
  871. fasti:        dc.l    0
  872. frameja:    dc.w    1
  873. chip_map:    dc.l    0
  874. chip_map2:    dc.l    0
  875. chip_map3:    dc.l    0
  876. oldv:    dc.l    0
  877. oldview:    dc.l    0
  878. chipbuf:    dc.l    0    ; ptr to draw buffer
  879. dispbuf:    dc.l    0    ; ptr to display buffer
  880. dbuffer:    dc.w    0
  881. tchunky:    dc.l    0
  882. tchunky_end:    dc.l    0
  883.  
  884. luku_r:        dc.b    0
  885. luku_g:        dc.b    0
  886. luku_b:        dc.b    0
  887.     even
  888.  
  889.  ifne fpss
  890.         incdir    hd0:
  891. font_metal:    incbin    fonttia_80x8.rgb
  892. font_1:        blk.l    80*8,0
  893.  endc
  894.  
  895.  
  896. ;------------------------------------------------------------------------
  897.     section kuupperi,data_c
  898. c2p_cop:
  899.             ;    dc.w    $01fc,3
  900.     dc.w    $01fc,3+16384
  901.     dc.w    $108,-80-8
  902.     dc.w    $10a,-8
  903.  
  904.     ifne    ntsc
  905.      dc.w    $1dc,$0        ; NTSC
  906.     endc
  907.  
  908.     ifeq    ntsc
  909.      dc.w    diwstrt,$4481    ; PAL
  910.     else
  911.      dc.w    diwstrt,$2c81    ; NTSC
  912.     endc
  913.     dc.w    diwstop,$0ac1
  914.  
  915.     dc.w    ddfstrt,$38
  916.     dc.w    ddfstop,$d0
  917.  
  918.     dc.w    bplcon1,0
  919.     dc.w    bplcon2,%0000001000000000
  920.     dc.w    bplcon3,%0000000000100000
  921.  
  922.     dc.w    bplcon0,%1000101000010001
  923.  
  924.     dc.w    bpl1pth        ; bitplanes
  925. bluit:    dc.w    0,bpl1ptl
  926.     dc.w    0,bpl2pth
  927.     dc.w    0,bpl2ptl
  928.     dc.w    0,bpl3pth
  929.     dc.w    0,bpl3ptl
  930.     dc.w    0,bpl4pth
  931.     dc.w    0,bpl4ptl
  932.     dc.w    0,bpl5pth
  933.     dc.w    0,bpl5ptl
  934.     dc.w    0,bpl6pth
  935.     dc.w    0,bpl6ptl
  936.     dc.w    0,bpl7pth
  937.     dc.w    0,bpl7ptl
  938.     dc.w    0,bpl8pth
  939.     dc.w    0,bpl8ptl
  940.     dc.w    0
  941.  
  942.     dc.w    spr0ptl        ; sprites
  943. spruit:    dc.w    0
  944.     dc.w    spr1ptl,0
  945.     dc.w    spr2ptl,0
  946.     dc.w    spr3ptl,0
  947.     dc.w    spr4ptl,0
  948.     dc.w    spr5ptl,0
  949.     dc.w    spr6ptl,0
  950.     dc.w    spr7ptl,0
  951.  
  952.     dc.w    spr0pth
  953. spruit2: dc.w    0
  954.     dc.w    spr1pth,0
  955.     dc.w    spr2pth,0
  956.     dc.w    spr3pth,0
  957.     dc.w    spr4pth,0
  958.     dc.w    spr5pth,0
  959.     dc.w    spr6pth,0
  960.     dc.w    spr7pth,0
  961.  
  962. CO    SET $0180        ; black palette for ham8  (first 64 colors)
  963. CB    SET $0
  964.  
  965.     DC.W    $0106,(CB+0)<<13+$000
  966.     DC.W    CO+00,0,CO+02,0,CO+04,0,CO+06,0
  967.     DC.W    CO+08,0,CO+10,0,CO+12,0,CO+14,0
  968.     DC.W    CO+16,0,CO+18,0,CO+20,0,CO+22,0
  969.     DC.W    CO+24,0,CO+26,0,CO+28,0,CO+30,0
  970.     DC.W    CO+32,0,CO+34,0,CO+36,0,CO+38,0
  971.     DC.W    CO+40,0,CO+42,0,CO+44,0,CO+46,0
  972.     DC.W    CO+48,0,CO+50,0,CO+52,0,CO+54,0
  973.     DC.W    CO+56,0,CO+58,0,CO+60,0,CO+62,0
  974.     DC.W    $0106,(CB+1)<<13+$000
  975.     DC.W    CO+00,0,CO+02,0,CO+04,0,CO+06,0
  976.     DC.W    CO+08,0,CO+10,0,CO+12,0,CO+14,0
  977.     DC.W    CO+16,0,CO+18,0,CO+20,0,CO+22,0
  978.     DC.W    CO+24,0,CO+26,0,CO+28,0,CO+30,0
  979.     DC.W    CO+32,0,CO+34,0,CO+36,0,CO+38,0
  980.     DC.W    CO+40,0,CO+42,0,CO+44,0,CO+46,0
  981.     DC.W    CO+48,0,CO+50,0,CO+52,0,CO+54,0
  982.     DC.W    CO+56,0,CO+58,0,CO+60,0,CO+62,0
  983.     DC.W    $0106,(CB+0)<<13+$200
  984.     DC.W    CO+00,0,CO+02,0,CO+04,0,CO+06,0
  985.     DC.W    CO+08,0,CO+10,0,CO+12,0,CO+14,0
  986.     DC.W    CO+16,0,CO+18,0,CO+20,0,CO+22,0
  987.     DC.W    CO+24,0,CO+26,0,CO+28,0,CO+30,0
  988.     DC.W    CO+32,0,CO+34,0,CO+36,0,CO+38,0
  989.     DC.W    CO+40,0,CO+42,0,CO+44,0,CO+46,0
  990.     DC.W    CO+48,0,CO+50,0,CO+52,0,CO+54,0
  991.     DC.W    CO+56,0,CO+58,0,CO+60,0,CO+62,0
  992.     DC.W    $0106,(CB+1)<<13+$200
  993.     DC.W    CO+00,0,CO+02,0,CO+04,0,CO+06,0
  994.     DC.W    CO+08,0,CO+10,0,CO+12,0,CO+14,0
  995.     DC.W    CO+16,0,CO+18,0,CO+20,0,CO+22,0
  996.     DC.W    CO+24,0,CO+26,0,CO+28,0,CO+30,0
  997.     DC.W    CO+32,0,CO+34,0,CO+36,0,CO+38,0
  998.     DC.W    CO+40,0,CO+42,0,CO+44,0,CO+46,0
  999.     DC.W    CO+48,0,CO+50,0,CO+52,0,CO+54,0
  1000.     DC.W    CO+56,0,CO+58,0,CO+60,0,CO+62,0
  1001.  
  1002.     dc.w    bplcon3,%0000000000100000
  1003.  
  1004.     ifne    ntsc
  1005.      dc.w    $f201,$ff00
  1006.      dc.w    bplcon0,%0000000000000001
  1007.     endc
  1008.     dc.l    $fffffffe
  1009.     dc.l    $fffffffe
  1010.  
  1011. tyhja:    dc.l    0,0,0,0
  1012.  
  1013.  
  1014.  
  1015.     section    muunnooni,code
  1016.  
  1017. Suorista:    MACRO
  1018.      move.l    d5,-(sp)
  1019.     move.l    (a0)+,d1
  1020.     move.l    (a0)+,d5
  1021.     move.l    (a0)+,d2
  1022.      move.l    #$ff00ff00,d6
  1023.  
  1024.     move.l    d1,d0
  1025.     and.l    d6,d0
  1026.     eor.l    d0,d1
  1027.     lsl.l    #8,d1
  1028.  
  1029.     move.l    d2,d3
  1030.     and.l    d6,d3
  1031.     eor.l    d3,d2
  1032.  
  1033.     lsr.l    #8,d3
  1034.     or.l    d3,d0
  1035.  
  1036.     or.l    d2,d1
  1037.  
  1038.      move.l    (a0)+,d3
  1039.  
  1040.     move.l    d5,d2
  1041.     and.l    d6,d2
  1042.     eor.l    d2,d5
  1043.     lsl.l    #8,d5
  1044.  
  1045.     move.l    d3,d4
  1046.     and.l    d6,d4
  1047.     eor.l    d4,d3
  1048.  
  1049.     lsr.l    #8,d4
  1050.     or.l    d4,d2
  1051.  
  1052.     or.l    d5,d3
  1053.  
  1054.     move.l    (sp)+,d5
  1055.     move.l    a2,d6
  1056.     ENDM
  1057.  
  1058.  
  1059.     section    planaari,code
  1060. _c2p:
  1061.         movea.l    d2,a5        ; a5 = bpmod
  1062.         lsl.l    #2,d2
  1063.         add.l    a5,d2
  1064.         subq.l    #2*2,d2
  1065.         movea.l    d2,a6        ; a6 = 5*bpmod-2
  1066.  
  1067.         lsr.w    #4,d0
  1068.         ext.l    d0
  1069.         move.l    d0,d4
  1070.         subq.l    #1,d4
  1071.         move.l    d4,-(sp)    ; (4,sp) = num of 16 pix per row - 1
  1072.  
  1073.         add.l    d0,d0        ; num of 8 pix per row (bytesperrow)
  1074.         sub.l    d0,d3
  1075.         sub.l    a6,d3
  1076.         move.l    d3,-(sp)    ; (sp) = linemod-bytesperrow-5*bpmod+2
  1077.  
  1078.         move.w    d1,d7
  1079.         subq.w    #1,d7        ; d7 = height-1
  1080.  
  1081.         movea.l    #$f0f0f0f0,a2    ; a2 = 4 bit mask
  1082.         movea.l    #$cccccccc,a3    ; a3 = 2 bit mask
  1083.         movea.l    #$aaaa5555,a4    ; a4 = 1 bit mask
  1084.         move.l    a2,d6        ; 4 bit mask = #$f0f0f0f0
  1085.  
  1086. ;------------------------------------------------------------------------
  1087. ;------------------------------------------------------------------------
  1088.  
  1089.         swap    d7
  1090.         move.w    6(sp),d7    ; num 16 pix per row - 1
  1091.  
  1092.      suorista
  1093.         move.l    d0,d4
  1094.         and.l    d6,d0
  1095.         eor.l    d0,d4
  1096.         lsl.l    #4,d4
  1097.  
  1098.         bra.w    .same_from_here
  1099.  
  1100.         cnop    0,4
  1101.  
  1102. .outerloop    swap    d7
  1103.         move.w    6(sp),d7    ; num 16 pix per row - 1
  1104.  
  1105.      suorista
  1106.     move.l    d5,(a1)        ; 31 -> plane 4
  1107.     adda.l    a5,a1        ; +bpmod
  1108.  
  1109.         move.l    d0,d4
  1110.         and.l    d6,d0
  1111.         eor.l    d0,d4
  1112.         lsl.l    #4,d4
  1113.  
  1114.         adda.l    (sp),a1        ; +linemod-bytesperrow-5*bpmod+2
  1115.  
  1116.         bra.b    .same_from_here
  1117.  
  1118. .innerloop
  1119.      suorista
  1120.     move.l    d5,(a1)        ; 31 -> plane 4
  1121.     adda.l    a5,a1        ; +bpmod
  1122.  
  1123.  
  1124.         move.l    d0,d4
  1125.         and.l    d6,d0
  1126.         eor.l    d0,d4
  1127.         lsl.l    #4,d4
  1128.  
  1129.         suba.l    a6,a1        ; -5*bpmod+2
  1130.  
  1131. .same_from_here
  1132.         move.l    d2,d5
  1133.         and.l    d6,d5
  1134.         eor.l    d5,d2
  1135.         lsr.l    #4,d5
  1136.  
  1137.         or.l    d5,d0
  1138.         or.l    d4,d2        ; 00x02 -> 10 11
  1139.  
  1140.         move.l    d1,d4
  1141.         and.l    d6,d1
  1142.         eor.l    d1,d4
  1143.  
  1144.         move.l    d3,d5
  1145.         and.l    d6,d5
  1146.         eor.l    d5,d3
  1147.         lsr.l    #4,d5
  1148.         lsl.l    #4,d4
  1149.  
  1150.         or.l    d5,d1
  1151.         or.l    d4,d3        ; 01x03 -> 12 13
  1152.  
  1153.         move.l    a3,d6        ; 2 bit mask = #$cccccccc
  1154.  
  1155.         move.l    d2,d4
  1156.         and.l    d6,d2
  1157.         eor.l    d2,d4
  1158.  
  1159.         move.l    d3,d5
  1160.         and.l    d6,d5
  1161.         eor.l    d5,d3
  1162.  
  1163.         lsl.l    #2,d4
  1164.         or.l    d4,d3        ; 11x13b -> 23
  1165.  
  1166.  
  1167.     move.l    d3,(a1)        ; 33 -> plane 0
  1168.     adda.l    a5,a1        ; +bpmod
  1169.      adda.l    a5,a1        ; +bpmod
  1170.  
  1171.      move.l    a4,d6        ; 1 bit mask = #$aaaa5555
  1172.  
  1173.         lsr.l    #2,d5
  1174.         or.l    d5,d2        ; 11x13a -> 22
  1175.  
  1176.     move.l    d2,(a1)        ; 32 -> plane 2
  1177.     adda.l    a5,a1        ; +bpmod
  1178.      adda.l    a5,a1        ; +bpmod
  1179.  
  1180.         lsl.l    #2,d0
  1181.         or.l    d0,d1        ; 10x12b -> 21
  1182.      move.l    d1,d5
  1183.  
  1184.         dbra    d7,.innerloop
  1185.  
  1186.         swap    d7
  1187.         dbra    d7,.outerloop
  1188.  
  1189.         move.l    d5,(a1)        ; 31 -> plane 4
  1190.  
  1191.         addq.l    #8,sp        ; remove locals
  1192.         rts
  1193.  
  1194. ;-----------------------------------------------------------
  1195.     section feafae,data_c
  1196. cbuf:    blk.b    640/8*100*6,0
  1197.  
  1198.  
  1199.