Guest User

Regiment Meditation Amiga Demo

a guest
Mar 31st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     SECTION code,CODE
  2.     JUMPPTR Start
  3.  
  4. INTERLACED = 0
  5.  
  6. SCREEN_W = 320
  7. SCREEN_H = 256
  8. SCREEN_D = 5
  9. SCREEN_COLORS = 1<<SCREEN_D
  10. SCREEN_BYPL = SCREEN_W/8
  11. SCREEN_BYWIDTH = SCREEN_BYPL*SCREEN_D
  12.  
  13. SCREEN_X_MARGIN = 128
  14.  
  15. NUM_SAS = 4
  16. SAS_W = 48
  17. SAS_VISW = 32
  18. SAS_H = 44
  19. SAS_BYTES = 4+4*SAS_H
  20. SAS_ATTACH = NUM_SAS*SAS_BYTES+4
  21.  
  22. GRENADE_W = 16
  23. GRENADE_H = 21
  24. GRENADE_BYTES = 4+4*GRENADE_H
  25. GRENADE_ATTACH = GRENADE_BYTES+4
  26.  
  27. BOOM_H = 16
  28.  
  29. DOOR_W = 80
  30. DOOR_VISW = 64
  31. DOOR_H = 128
  32.  
  33. PELLET_W = 16
  34. PELLET_H = 16
  35.  
  36. AUDIO_LEFT_X = 40
  37.  
  38. NUM_AK47 = 6
  39. NUM_FLOOR_WALK = 6
  40. NUM_GRASS_WALK = 6
  41. NUM_MP5 = 6
  42.  
  43. ; audio_t structure
  44. audio_t.pointer = 0
  45. audio_t.length = 4
  46. audio_t = 8
  47.  
  48. ; copper_t structure
  49. copper_t.bitplanes = 0
  50. copper_t.interlaced = 1
  51. copper_t.bpl1mod = 2
  52. copper_t.bpl2mod = 4
  53. copper_t.diwstrt = 6
  54. copper_t.diwstop = 8
  55. copper_t.ddfstrt = 10
  56. copper_t.ddfstop = 12
  57. copper_t.wait = 14
  58. copper_t = 16
  59.  
  60.  
  61. FPS = 50
  62.  
  63. pusha:  MACRO
  64.     movem.l d0-a6,-(sp)
  65.     ENDM
  66.  
  67. popa:   MACRO
  68.     movem.l (sp)+,d0-a6
  69.     ENDM
  70.  
  71. pushnr: MACRO
  72.     movem.l d1-a6,-(sp)
  73.     ENDM
  74.  
  75. popnr:  MACRO
  76.     movem.l (sp)+,d1-a6
  77.     ENDM
  78.  
  79.  
  80.     ; Args:
  81.     ;   \1 - address to poke to copper
  82.     ;   \2 - copper register listing start where to poke
  83. pokecopper: MACRO
  84.     move.w \1,6(\2)
  85.     swap \1
  86.     move.w \1,2(\2)
  87.     swap \1
  88.     ENDM
  89.  
  90.  
  91. audio_off: MACRO
  92.     move #$f,DMACON(a6)
  93.     ENDM
  94.  
  95.  
  96.     ; Args:
  97.     ;   \1 - address to store
  98.     ;   \2 - address *where* to store
  99. store_address: MACRO
  100.     lea \1,a0
  101.     lea \2,a1
  102.     move.l a0,(a1)
  103.     ENDM
  104.  
  105. delayed_part: MACRO
  106.     move \1,SleepPartTime
  107.     store_address \2,SleepPartNext(pc)
  108.     store_address SleepPart(pc),PartPointer(pc)
  109.     ENDM
  110.  
  111. next_part: MACRO
  112.     store_address \1,PartPointer(pc)
  113.     ENDM
  114.  
  115.  
  116.     ; Args:
  117.     ;   \1 - address register where to store the bullet address
  118.     ;   \2 - data register where the bullet index is
  119. bullet_at_list: MACRO
  120.     lea BulletList(pc),\1
  121.     mulu #bullet_t,\2
  122.     add.l \2,\1
  123.     ENDM
  124.  
  125. fullscreen_part: MACRO
  126.     bsr APlayNullAll
  127.     bsr LoadFullScreenCopper
  128.     bsr LoadScreenToCopper
  129.     ENDM
  130.  
  131.     INCLUDE "hardware.s"
  132.  
  133.     *** MiniWrapper by Photon ***
  134.  
  135. Start:  move.l 4.w,a6           ;Exec library base address in a6
  136.     sub.l a4,a4
  137.     btst #0,297(a6)         ;68000 CPU?
  138.     beq.s .yes68k
  139.     lea .GetVBR(PC),a5      ;else fetch vector base address to a4:
  140.     jsr -30(a6)         ;enter Supervisor mode
  141.  
  142.     *--- save view+coppers ---*
  143.  
  144. .yes68k:lea .GfxLib(PC),a1      ;either way return to here and open
  145.     jsr -408(a6)            ;graphics library
  146.     tst.l d0            ;if not OK,
  147.     beq.s .quit         ;exit program.
  148.     move.l d0,a5            ;a5=gfxbase
  149.  
  150.     move.l a5,a6
  151.     move.l 34(a6),-(sp)
  152.     sub.l a1,a1         ;blank screen to trigger screen switch
  153.     jsr -222(a6)            ;on Amigas with graphics cards
  154.  
  155.     *--- save int+dma ---*
  156.  
  157.     lea $dff000,a6
  158.     bsr.s WaitEOF           ;wait out the current frame
  159.     move.l $1c(a6),-(sp)        ;save intena+intreq
  160.     move.w 2(a6),-(sp)      ;and dma
  161.     move.l $6c(a4),-(sp)        ;and also the VB int vector for sport.
  162.     bsr.s AllOff            ;turn off all interrupts+DMA
  163.  
  164.     *--- call demo ---*
  165.  
  166.     movem.l a4-a6,-(sp)
  167.     bsr.w Demo          ;call our demo \o/
  168.     movem.l (sp)+,a4-a6
  169.  
  170.     *--- restore all ---*
  171.  
  172.     bsr.s WaitEOF           ;wait out the demo's last frame
  173.     bsr.s AllOff            ;turn off all interrupts+DMA
  174.     move.l (sp)+,$6c(a4)        ;restore VB vector
  175.     move.l 38(a5),$80(a6)       ;and copper pointers
  176.     move.l 50(a5),$84(a6)
  177.     addq.w #1,d2            ;$7fff->$8000 = master enable bit
  178.     or.w d2,(sp)
  179.     move.w (sp)+,$96(a6)        ;restore DMA
  180.     or.w d2,(sp)
  181.     move.w (sp)+,$9a(a6)        ;restore interrupt mask
  182.     or.w (sp)+,d2
  183.     bsr.s IntReqD2          ;restore interrupt requests
  184.  
  185.     move.l a5,a6
  186.     move.l (sp)+,a1
  187.     jsr -222(a6)            ;restore OS screen
  188.  
  189.     *--- close lib+exit ---*
  190.  
  191.     move.l a6,a1            ;close graphics library
  192.     move.l 4.w,a6
  193.     jsr -414(a6)
  194. .quit:  moveq #0,d0         ;clear error return code to OS
  195.     rts             ;back to AmigaDOS/Workbench.
  196.  
  197. .GetVBR:dc.w $4e7a,$c801        ;hex for "movec VBR,a4"
  198.     rte             ;return from Supervisor mode
  199.  
  200. .GfxLib:dc.b "graphics.library",0,0
  201.  
  202. WaitEOF:                ;wait for end of frame
  203.     bsr.s WaitBlitter
  204.     move.w #$138,d0
  205. WaitRaster:             ;Wait for scanline d0. Trashes d1.
  206. .l: move.l 4(a6),d1
  207.     lsr.l #1,d1
  208.     lsr.w #7,d1
  209.     cmp.w d0,d1
  210.     bne.s .l            ;wait until it matches (eq)
  211.     rts
  212.  
  213. AllOff: move.w #$7fff,d2        ;clear all bits
  214.     move.w d2,$96(a6)       ;in DMACON,
  215.     move.w d2,$9a(a6)       ;INTENA,
  216. IntReqD2:
  217.     move.w d2,$9c(a6)       ;and INTREQ
  218.     move.w d2,$9c(a6)       ;twice for A4000 compatibility
  219.     rts
  220.  
  221. WaitBlitter:                ;wait until blitter is finished
  222.     tst.w (a6)          ;for compatibility with A1000
  223. .loop:  btst #6,2(a6)
  224.     bne.s .loop
  225.     rts
  226.  
  227.     *** End of MiniWrapper by Photon ***
  228.  
  229.  
  230. Demo:
  231.     pusha
  232.  
  233.     bsr InitGeneric
  234.     bsr StartPart1
  235.  
  236.     move.l #VBint,$6c(a4)
  237.     move #$e020,INTENA(a6) ; Enable master, level 6 and 3 IRQ
  238.  
  239. .waitmouse:
  240.     tst Quit
  241.     bne .quit
  242.     btst #6,CIAAPRA
  243.     bne .waitmouse
  244. .quit:
  245.     popa
  246.     rts
  247. Quit:
  248.     dc.w 0
  249.  
  250. VBint:
  251.     pusha
  252.  
  253.     btst #5,INTREQR+1(a6)
  254.     beq .not_vblank
  255.  
  256.     btst #2,POTGOR(a6)
  257.     beq .paused
  258.  
  259.     jsr Frame(pc)
  260.  
  261.     move #$20,INTREQ(a6)
  262.     move #$20,INTREQ(a6)
  263. .paused:
  264. .not_vblank:
  265.     popa
  266.     rte
  267.  
  268.  
  269. Frame:
  270.     pusha
  271.     move.l PartPointer(pc),a0
  272.     jsr (a0)
  273.     popa
  274.     rts
  275. PartPointer:
  276.     dc.l 0
  277.  
  278.  
  279. SleepPart:
  280.     ; A generic sleep part that waits for a while and then move on to the
  281.     ; next part as specified through SleepPartTime and SleepPartNext.
  282.     pusha
  283.  
  284.     ; Countdown and do nothing if we haven't reached the finish yet.
  285.     lea SleepPartTime(pc),a0
  286.     tst (a0)
  287.     bne .sleep_more
  288.  
  289.     ; We've slept enough. It's time to move to the next part.
  290.     lea SleepPartNext(pc),a1
  291.     move.l (a1),d0
  292.     clr.l (a1)
  293.  
  294.     tst d0
  295.     bne .good_pointer
  296.     lea NoopPart(pc),a1 ; avoid crash by forcing no-op part
  297.     move.l a1,d0
  298. .good_pointer:
  299.     ; Load the next part and reset the variables.
  300.     lea PartPointer(pc),a2
  301.     move.l d0,(a2)
  302.     clr (a0)
  303.     bra .done
  304. .sleep_more:
  305.     subq #1,(a0)
  306. .done:
  307.     popa
  308.     rts
  309.  
  310. SleepPartTime:
  311.     dc.w 0  ; 1s = Vertical Refresh Rate
  312. SleepPartNext:
  313.     dc.l 0
  314.  
  315.  
  316. NoopPart:
  317.     ; A no-op part that does nothing forever.
  318.     audio_off
  319.     rts
  320.  
  321.  
  322. ;;
  323. ;; Generic - stuff for the whole demo
  324. ;;
  325. InitGeneric:
  326.     pusha
  327.  
  328.     bsr LoadScreenToCopper
  329.  
  330.     ; Load sprites
  331.     bsr InitSasSprite
  332.     lea CopperSprite,a0
  333.     bsr PokeCopperSasSprite
  334.  
  335.     lea CopperSprite+8*4,a0
  336.     moveq #4,d0
  337.     bsr PokeCopperNullSprite
  338.  
  339.     lea CopperSprite6,a0
  340.     move.l #BulletSprite,d0
  341.     move.l d0,CurrentBulletSprite
  342.     pokecopper d0,a0
  343.     move #NUM_BULLETS_MAX,CurrentNumBulletsMax
  344.  
  345.     bsr InitGrenadeSprite
  346.  
  347.     ; As there are no bullets yet, this will clear the bullet sprite.
  348.     bsr PaintBullets
  349.  
  350.     bsr AdjustDoorMask
  351.  
  352.     ; Load audio lists
  353.     bsr InitFloorWalkList
  354.     bsr InitGrassWalkList
  355.  
  356.     popa
  357.     rts
  358.  
  359.  
  360. AdjustDoorMask:
  361.     ; Write #$ff to all the bits that are non-zero.
  362.     ; This results in the mask also covering the "transparent" pixels.
  363.     pusha
  364.     lea DoorMask,a0
  365.     move #DoorMask_e-DoorMask,d0
  366. .loop:
  367.     move.b (a0),d1
  368.     tst.b d1
  369.     beq.s .skip
  370.     or.b #$ff,d1
  371. .skip:
  372.     move.b d1,(a0)+
  373.     dbf d0,.loop
  374.     popa
  375.     rts
  376.  
  377.  
  378. PokeCopperSasSprite:
  379.     ; Args:
  380.     ;   a0 - copper list where to load
  381.     pusha
  382.     ; Load SAS head as a sprite.
  383.     ; This is an attached sprite where the attachment is under the same
  384.     ; label and starts immediately after the first sprite.
  385.     move.l #SasLeft,d0
  386.     pokecopper d0,a0
  387.  
  388.     add.l #SAS_ATTACH,d0
  389.     addq.l #8,a0
  390.     pokecopper d0,a0
  391.  
  392.     move.l #SasRight,d0
  393.     addq.l #8,a0
  394.     pokecopper d0,a0
  395.  
  396.     add.l #SAS_ATTACH,d0
  397.     addq.l #8,a0
  398.     pokecopper d0,a0
  399.  
  400.     popa
  401.     rts
  402.  
  403. PokeCopperNullSprite:
  404.     ; Args:
  405.     ;   a0 - copper list where to load
  406.     ;   d0 - how many
  407.     pusha
  408.     move.l #NullSprite,d1
  409.     subq #1,d0
  410. .nullspr_load:
  411.     pokecopper d1,a0
  412.     addq.l #8,a0
  413.     dbf d0,.nullspr_load
  414.     popa
  415.     rts
  416.  
  417.  
  418. InitSasSprite:
  419.     pusha
  420.  
  421.     ; Attach SAS sprites
  422.     move.l #$80,d0
  423.     move.l #NUM_SAS-1,d1
  424.     lea SasLeft,a0
  425.     lea SasRight,a1
  426.     move.l a0,a2
  427.     add.l #SAS_ATTACH,a2
  428.     move.l a1,a3
  429.     add.l #SAS_ATTACH,a3
  430. .attach_sas:
  431.     move.l d0,(a0)
  432.     move.l d0,(a1)
  433.     move.l d0,(a2)
  434.     move.l d0,(a3)
  435.     add.l #SAS_BYTES,a0
  436.     add.l #SAS_BYTES,a1
  437.     add.l #SAS_BYTES,a2
  438.     add.l #SAS_BYTES,a3
  439.     dbf d1,.attach_sas
  440.  
  441.     popa
  442.     rts
  443.  
  444. InitGrenadeSprite:
  445.     ; Grenayd!
  446.     pusha
  447.     lea GrenadeSprite,a0
  448.     move.l #$80,(a0)
  449.     add.l #GRENADE_ATTACH,a0
  450.     move.l #$80,(a0)
  451.     popa
  452.     rts
  453.  
  454.  
  455. ;;
  456. ;; Part1
  457. ;;
  458.  
  459. ; Bitplanes in this picture are saved one after another - not
  460. ; interleaved. LOGO_BYPL is therefore not calculated by lines
  461. ; but is the area of the whole picture.
  462. LOGO_W = 304
  463. LOGO_H = 95
  464. LOGO_D = 3
  465. LOGO_COLORS = 8
  466. LOGO_BYPL = LOGO_W/8*LOGO_H
  467. LOGO_MARGIN = (SCREEN_W-LOGO_W)/2
  468.  
  469. FLASH_TICKS = 50<<16
  470. FLASH_TICKPERIOD = 25<<16
  471.  
  472. FLASH_STAGE_WHITE = 0
  473. FLASH_STAGE_MUSIC = 24
  474. FLASH_STAGE_BLACK = FLASH_STAGE_MUSIC+1
  475. FLASH_STAGE_DONE = FLASH_STAGE_BLACK+50
  476.  
  477. LOGO_FLASH_TICKS = 50<<16
  478. LOGO_FLASH_TICKPERIOD = 25<<16
  479.  
  480.  
  481. StartPart1:
  482.     pusha
  483.  
  484.     ; Play null audio on all channels to prevent sound from coming out
  485.     ; as soon as we start.
  486.     bsr APlayNullAll
  487.  
  488.     ; Load the first part
  489.     next_part Part1(pc)
  490.  
  491.     ; Load the logo into the copper list
  492.     lea P1CopperLogo,a0
  493.     lea Logo,a1
  494.     move.l a1,d1
  495.     moveq #LOGO_D-1,d0
  496. .loop:
  497.     swap d1
  498.     move d1,2(a0)
  499.     swap d1
  500.     move d1,6(a0)
  501.     addq #8,a0
  502.     add.l #LOGO_BYPL,d1
  503.     dbf d0,.loop
  504.  
  505.     ; Enable copper and bitplane DMA and load the copper list
  506.     move #$838f,DMACON(a6)
  507.     move.l #P1Copper,COP1LCH(a6)
  508.  
  509.     popa
  510.     rts
  511.  
  512.  
  513. Part1:
  514. Part1a_Flash:
  515.     pusha
  516.     move.l FlashCountdown(pc),d7
  517.     sub.l #FLASH_TICKPERIOD,d7
  518.     bpl .no_flash
  519.  
  520. ; Transit screen color
  521.     lea FlashColorTable(pc),a0
  522.     move.l a0,a1
  523.     move #LOGO_COLORS-1,d1
  524.  
  525.     move FlashStage(pc),d6
  526.     cmp.w #FLASH_STAGE_WHITE,d6
  527.     beq .flash_white
  528.     cmp.w #FLASH_STAGE_MUSIC,d6
  529.     beq .flash_music
  530.     cmp.w #FLASH_STAGE_BLACK,d6
  531.     beq .flash_black
  532.     cmp.w #FLASH_STAGE_DONE,d6
  533.     beq .flash_done
  534.     addq #1,FlashStage
  535.     bra .no_flash
  536.  
  537. .flash_white:
  538.     add #$0111,(a0)+
  539.     dbf d1,.flash_white
  540.     cmp.w #$0fff,(a1)
  541.     bne .do_flash
  542.     addq #1,FlashStage
  543.     bra .do_flash
  544.  
  545. .flash_music:
  546.     bsr APlayIntro
  547.     addq #1,FlashStage
  548.     bra .no_flash
  549.  
  550. .flash_black:
  551.     addq #2,a0
  552.     subq #1,d1
  553. .flash_black_loop:
  554.     sub #$0111,(a0)+
  555.     dbf d1,.flash_black_loop
  556.     tst.w 2(a1)
  557.     bne .do_flash
  558.     addq #1,FlashStage
  559.     bra .do_flash
  560.  
  561. .flash_done:
  562.     lea Part1b_Logo(pc),a0
  563.     move.l a0,PartPointer
  564.     bra .no_flash
  565.  
  566.  
  567. .do_flash:
  568.     move.l a1,a0
  569.     lea P1CopperColor,a1
  570.     move #LOGO_COLORS,d0
  571.     bsr PokeCopperWords
  572.  
  573.     move.l #FLASH_TICKS,d7
  574. .no_flash:
  575.     move.l d7,FlashCountdown
  576.     popa
  577.     rts
  578.  
  579. .flash_intermission_countdown:
  580.     dc.w 4
  581.  
  582. FlashColorTable:
  583.     dcb.w LOGO_COLORS,0
  584.  
  585. FlashStage:
  586.     dc.w 0
  587. FlashCountdown:
  588.     dc.l FLASH_TICKPERIOD-1
  589.  
  590.  
  591. Part1b_Logo:
  592.     pusha
  593.  
  594.     ; Transit color to show the logo
  595.     move.l .transit_countdown(pc),d7
  596.     sub.l #LOGO_FLASH_TICKPERIOD,d7
  597.     bpl .notransit
  598.  
  599.     ; Fade
  600.     lea LogoDisplayColors(pc),a0
  601.     lea LogoColors(pc),a1
  602.     move #LOGO_COLORS,d0
  603.     move #$0111,d2
  604.     bsr ColorTableFadeTo
  605.  
  606.     ; Check if it's time to move to the next part.
  607.     ; Registers already have correct values so let's reuse that.
  608.     move d0,d1
  609.     bsr MemCmp
  610.     move d0,d6
  611.  
  612.     ; Poke new colors to copper
  613.     ; a0 has the correct value
  614.     lea P1CopperColor,a1
  615.     move #LOGO_COLORS,d0
  616.     bsr PokeCopperWords
  617.  
  618.     ; Is it time?
  619.     cmp #LOGO_COLORS,d6
  620.     bne .no_next_part
  621.  
  622.     ; Load next part
  623.     delayed_part #FPS*3,Part1c_FadeOut(pc)
  624.  
  625. .no_next_part:
  626.     move.l #LOGO_FLASH_TICKS,d7
  627. .notransit:
  628.     move.l d7,.transit_countdown
  629.     popa
  630.     rts
  631.  
  632. .transit_countdown:
  633.     dc.l LOGO_FLASH_TICKPERIOD-1
  634.  
  635.  
  636. Part1c_FadeOut:
  637.     pusha
  638.  
  639.     lea LogoDisplayColors(pc),a0
  640.     lea P1CopperColor,a1
  641.     move #LOGO_COLORS,d0
  642.     bsr DimScreen
  643.  
  644.     lea LogoDisplayColors(pc),a0
  645.     lea BlackColors(pc),a1
  646.     move.l #LOGO_COLORS,d1
  647.     bsr MemCmp
  648.     cmp #LOGO_COLORS,d0
  649.     bne .no_next_part
  650.  
  651.     audio_off
  652.     delayed_part #4,StartPart2(pc)
  653.     bsr StartPart2
  654.  
  655. .no_next_part:
  656.     popa
  657.     rts
  658.  
  659.  
  660. LogoDisplayColors:
  661.     dc.w $0fff
  662.     dcb.w LOGO_COLORS-1,$0000
  663. LogoColors:
  664.     dc.w $0100,$0510,$0321,$0f01
  665.     dc.w $0842,$0e74,$0fa5,$0fd5
  666. BlackColors:
  667.     dcb.w 32,0
  668.  
  669.  
  670. APlayIntro:
  671.     pusha
  672.     lea AIntro,a0
  673.     move #(AIntro_e-AIntro)/2,d0
  674.     move #0,d1
  675.     move #64,d2
  676.     bsr APlay11Khz
  677.     move #1,d1
  678.     bsr APlay11Khz
  679.     popa
  680.     rts
  681.  
  682. ;;
  683. ;; Part2
  684. ;;
  685. GRASS_W = 320
  686. GRASS_H = 256
  687. GRASS_D = 4
  688. GRASS_COLORS = 1<<GRASS_D
  689. GRASS_BYPL = 320/8
  690. GRASS_BYWIDTH = GRASS_BYPL*GRASS_D
  691.  
  692. P2Color:
  693.     dc.w $0331,$0341,$0443,$0553
  694.     dc.w $0563,$0664,$0665,$0785
  695.     dc.w $0784,$0886,$0987,$08a5
  696.     dc.w $08a7,$0bba,$0ac7,$0bb9
  697.     dc.w $00ff,$0111,$0222,$0333
  698.     dc.w $0444,$0555,$0666,$0866
  699.     dc.w $0777,$0888,$0bab,$0000
  700.     dc.w $0000,$0000,$0000,$0000
  701.  
  702.  
  703. LoadP2Copper:
  704.     pusha
  705.     sub #copper_t,sp
  706.     move.l sp,a0
  707.     bsr InitCopperT
  708.     move.b #GRASS_D,copper_t.bitplanes(a0)
  709.     move #GRASS_BYWIDTH-GRASS_BYPL,copper_t.bpl1mod(a0)
  710.     move #GRASS_BYWIDTH-GRASS_BYPL,copper_t.bpl2mod(a0)
  711.     bsr LoadCopper
  712.     bsr LoadScreenToCopper
  713.  
  714.     ; Load colors
  715.     lea P2Color(pc),a0
  716.     bsr LoadColorsToCopper
  717.  
  718.     add #copper_t,sp
  719.     popa
  720.     rts
  721.  
  722.  
  723. StartPart2:
  724.     pusha
  725.  
  726.     bsr LoadP2Copper
  727.  
  728.     ; Part 2 is the first screen that's not baked into CHIP mem section.
  729.     ; We will copy it to the screen using the CPU. Blitter cannot be
  730.     ; used because the source is not in chip mem.
  731.     lea P2Scene,a0
  732.     lea Screen,a1
  733.     move.l #(P2Scene_e-P2Scene)/4,d0
  734. .screen_copy:
  735.     move.l (a0)+,(a1)+
  736.     dbf d0,.screen_copy
  737.  
  738.     ; Shut off all sound
  739.     bsr APlayNullAll
  740.  
  741.     ; Enable copper and sprites
  742.     move #$7fff,DMACON(a6)
  743.     move #$87af,DMACON(a6)
  744.     move.l #Copper,COP1LCH(a6)
  745.  
  746.     ; Set frame pointer to part 2
  747.     delayed_part #FPS,Part2(pc)
  748.  
  749.     popa
  750.     rts
  751.  
  752. Part2:
  753. Part2a:
  754.     ; 4 SAS troopers come in from the right, they move into the screen
  755.     ; X-unevenly and stop somewhere near the right edge X-evenly.
  756.     pusha
  757. _SAS_DST_X = 256
  758.     move.l #_SAS_DST_X,d1
  759.     bsr StepAllSasLeftToX
  760.     move d0,d7
  761.  
  762.     ; play step sound
  763.     move SasGrassWalkVolume(pc),d2
  764.     cmp #$100,d2
  765.     bge .max_volume
  766.     addq #1,d2
  767.     move d2,SasGrassWalkVolume
  768. .max_volume:
  769.     lsr #2,d2
  770.     cmp #1,d7
  771.     beq .one_sas_moving
  772.     tst d7
  773.     beq .all_stop
  774.     bsr APlayGrassWalkManyRight
  775.     bra .done
  776. .one_sas_moving:
  777.     bsr APlayGrassWalkOneRight
  778.     bra .done
  779. .all_stop:
  780.     bsr APlayNullAll
  781.     delayed_part #FPS,Part2b(pc)
  782. .done:
  783.     popa
  784.     rts
  785.  
  786. Part2b:
  787.     pusha
  788.  
  789.     lea ABriefing,a0
  790.     move.l #(ABriefing_e-ABriefing)/2,d0
  791.     move #0,d1
  792.     move #64,d2
  793.     bsr APlay11Khz
  794.     move #1,d1
  795.     bsr APlay11Khz
  796.  
  797.     delayed_part #FPS*2,Part2b_stop_audio(pc)
  798.  
  799.     popa
  800.     rts
  801.  
  802. Part2b_stop_audio:
  803.     pusha
  804.     bsr APlayNullAll
  805.     delayed_part #FPS/2,Part2c_gogogo
  806.     popa
  807.     rts
  808.  
  809. Part2c_gogogo:
  810.     pusha
  811.     lea ASasGoGoGo,a0
  812.     move.l #(ASasGoGoGo_e-ASasGoGoGo)/2,d0
  813.     move #0,d1
  814.     move #64,d2
  815.     bsr APlay11Khz
  816.     move #1,d1
  817.     bsr APlay11Khz
  818.     delayed_part #FPS,Part2d_move_out
  819.     popa
  820.     rts
  821.  
  822. Part2d_move_out:
  823.     pusha
  824.  
  825. _SAS_DST_X_2D = -64
  826.     clr.l d7
  827.     move.l #_SAS_DST_X_2D,d1
  828.  
  829.     move .sas_moveout_countup(pc),d6
  830.     addq #1,d6
  831.  
  832.     ; Move all SAS troopers, but with some irregular delay
  833.     cmp #2,d6
  834.     blt .sas_1
  835.     clr d2
  836.     bsr StepSasLeftToX
  837.     add d0,d7
  838.     bsr PlotSas
  839. .sas_1:
  840.     cmp #8,d6
  841.     blt .sas_2
  842.     moveq.l #1,d2
  843.     bsr StepSasLeftToX
  844.     add d0,d7
  845.     bsr PlotSas
  846. .sas_2:
  847.     moveq.l #2,d2
  848.     bsr StepSasLeftToX
  849.     add d0,d7
  850.     bsr PlotSas
  851. .sas_3:
  852.     cmp #5,d6
  853.     blt .sas_e
  854.     moveq.l #3,d2
  855.     bsr StepSasLeftToX
  856.     add d0,d7
  857.     bsr PlotSas
  858.  
  859. .sas_e:
  860.     move d6,.sas_moveout_countup
  861.  
  862.     ; play step sound
  863.     move SasPos0(pc),d0
  864.     cmp #_SAS_DST_X_2D,d0
  865.     ble .moved_out
  866.     cmp #AUDIO_LEFT_X,d0
  867.     blt .all_move_on_left
  868.  
  869. .all_move_in_center:
  870.     move #64,d2
  871.     cmp #1,d7
  872.     beq .one_sas_moving
  873.     bsr APlayGrassWalkManyBoth
  874.     bra .done
  875. .all_move_on_left:
  876.     bsr APlayNullRight
  877.     move SasGrassWalkVolume(pc),d2
  878.     subq #1,d2
  879.     move d2,SasGrassWalkVolume
  880.     lsr #2,d2
  881.     bsr APlayGrassWalkManyLeft
  882.     bra .done
  883. .one_sas_moving:
  884.     bsr APlayGrassWalkOneBoth
  885.     bra .done
  886. .moved_out:
  887.     bsr APlayNullAll
  888.     delayed_part #5,StartPart3(pc)
  889. .done:
  890.     popa
  891.     rts
  892.  
  893. .sas_moveout_countup:
  894.     dc.w 0
  895.  
  896. ;;
  897. ;; Part3
  898. ;;
  899. P3_PASKUDNY_X = 89
  900. P3_PASKUDNY_Y = 174
  901.  
  902. P3_WIESNIAK_X = 92
  903. P3_WIESNIAK_Y = 14
  904.  
  905. P3_DOOR_X = 0
  906. P3_DOOR_Y = 64
  907.  
  908. PASKUDNY_W = 64
  909. PASKUDNY_VISW = 38
  910. PASKUDNY_H = 44
  911.  
  912. WIESNIAK_W = 48
  913. WIESNIAK_VISW = 32
  914. WIESNIAK_H = 43
  915.  
  916. P3Color:
  917.     dc.w $0111,$0b89,$0b8a,$0742
  918.     dc.w $0665,$0c9a,$0aaa,$0bad
  919.     dc.w $0734,$0745,$0956,$0867
  920.     dc.w $0a68,$0978,$0a77,$0b79
  921.     dc.w $0a89,$0111,$0222,$0333
  922.     dc.w $0444,$0555,$0666,$0866
  923.     dc.w $0777,$0888,$0bab,$0000
  924.     dc.w $0800,$0f00,$0780,$0ff0
  925.  
  926.  
  927. StartPart3:
  928.     pusha
  929.  
  930.     fullscreen_part
  931.  
  932.     ; Copy part 3 scene to screen
  933.     lea P3Scene,a0
  934.     lea Screen,a1
  935.     move.l #(Screen_e-Screen)/4,d0
  936. .screen_copy:
  937.     move.l (a0)+,(a1)+
  938.     dbf d0,.screen_copy
  939.  
  940.     ; Shut off all sound
  941.     bsr APlayNullAll
  942.  
  943.     ; Load colors
  944.     lea P3Color(pc),a0
  945.     bsr LoadColorsToCopper
  946.  
  947.     ; Position SAS
  948.     move #SCREEN_W+2,SasPos0
  949.     move #SCREEN_W+8,SasPos1
  950.     move #SCREEN_W,SasPos2
  951.     move #SCREEN_W+5,SasPos3
  952.  
  953.     ; Enable copper, sprites and blitter
  954.     move #$7fff,DMACON(a6)
  955.     move #$87ef,DMACON(a6)
  956.     move.l #Copper,COP1LCH(a6)
  957.  
  958.     next_part Part3(pc)
  959.  
  960.     popa
  961.     rts
  962.  
  963.  
  964. Part3:
  965. Part3a_move_in:
  966.     pusha
  967.  
  968. _SAS_DST_X_3A = SCREEN_W-48
  969. _ENEMY_SHOUT_3A = 16
  970.     move.l #_SAS_DST_X_3A,d1
  971.     bsr StepAllSasLeftToX
  972.     move d0,d7
  973.  
  974.     move .shouts_counter(pc),d0
  975.     addq #1,d0
  976.     move d0,.shouts_counter
  977.     cmp #_ENEMY_SHOUT_3A,d0
  978.     bne .no_shout
  979.  
  980.     lea AXrayTroopers,a0
  981.     move #(AXrayTroopers_e-AXrayTroopers)/2,d0
  982.     move #0,d1
  983.     move #64,d2
  984.     bsr APlay11Khz
  985.  
  986.     bra .no_stop_shout
  987. .no_shout:
  988.     cmp #_ENEMY_SHOUT_3A+1,d0
  989.     bne .no_stop_shout
  990.     bsr APlayNullLeft
  991. .no_stop_shout:
  992.     ; play step sound
  993.     move #64,d2
  994.     cmp #1,d7
  995.     beq .one_sas_moving
  996.     tst d7
  997.     beq .all_stop
  998.     bsr APlayGrassWalkManyRight
  999.     bra .done
  1000. .one_sas_moving:
  1001.     bsr APlayGrassWalkOneRight
  1002.     bra .done
  1003. .all_stop:
  1004.     bsr APlayNullAll
  1005.     next_part Part3b_enemy_contact(pc)
  1006.     ;delayed_part #4,Part3b_enemy_contact(pc)
  1007. .done:
  1008.     popa
  1009.     rts
  1010.  
  1011. .shouts_counter:
  1012.     dc.w 0
  1013.  
  1014.  
  1015. Part3b_enemy_contact:
  1016.     pusha
  1017.  
  1018.     lea ASasEnemyContact+3000,a0
  1019.     move #(ASasEnemyContact_e-ASasEnemyContact-3000)/2,d0
  1020.     move #1,d1
  1021.     move #64,d2
  1022.     bsr APlay11Khz
  1023.  
  1024.     delayed_part #(FPS/2)+(FPS/4),Part3c_offense(pc)
  1025.  
  1026.     popa
  1027.     rts
  1028.  
  1029. Part3c_offense:
  1030.     pusha
  1031.  
  1032.     bsr APlayNullRight
  1033.  
  1034.     lea AXrayDieUBastards,a0
  1035.     move #(AXrayDieUBastards_e-AXrayDieUBastards)/2,d0
  1036.     move #0,d1
  1037.     move #64,d2
  1038.     bsr APlay11Khz
  1039.  
  1040.     delayed_part #FPS/2,Part3d_shoot_sas(pc)
  1041.  
  1042.     popa
  1043.     rts
  1044.  
  1045.     ; THERE WAS A FIREFIGHT!
  1046. Part3d_shoot_sas:
  1047.     pusha
  1048.  
  1049.     ; Shoot a bullet by "paskudny" at SAS 2
  1050.     move .bullet_shot(pc),d0
  1051.     tst d0
  1052.     bge .already_fired
  1053.  
  1054.     move #P3_PASKUDNY_X+PASKUDNY_VISW,d0
  1055.     move #P3_PASKUDNY_Y+PASKUDNY_H/2,d1
  1056.     move SasPos2(pc),d2 ; SAS x
  1057.     move SasPos2+2(pc),d3   ; SAS y
  1058.     add #SAS_H/2,d3
  1059.     bsr FireBullet
  1060.     move d0,.bullet_shot
  1061.  
  1062.     ; store pointer to bullet
  1063.     bullet_at_list a0,d0
  1064.     move.l a0,.first_bullet
  1065.  
  1066.     ; shut up paskudny
  1067.     move #0,d1
  1068.     bsr APlayNull
  1069.     ; fire AK47
  1070.     lea AAk47_1,a0
  1071.     move #(AAk47_1_e-AAk47_1)/2,d0
  1072.     move #3,d1
  1073.     move #64,d2
  1074.     bsr APlay11Khz
  1075.     bra .done
  1076. .already_fired:
  1077.     ; shut up AK47
  1078.     move #3,d1
  1079.     bsr APlayNull
  1080.  
  1081.     move.l .first_bullet(pc),a0
  1082.     tst bullet_t.live(a0)
  1083.     bne .go_bullet
  1084.  
  1085.     next_part Part3e_sas_hit(pc)
  1086.  
  1087.     bra .done
  1088. .go_bullet:
  1089.     bsr BulletEngine
  1090. .done:
  1091.     popa
  1092.     rts
  1093. .bullet_shot:
  1094.     dc.w $ffff
  1095. .first_bullet:
  1096.     dc.l $0
  1097.  
  1098.  
  1099. Part3e_sas_hit:
  1100.     pusha
  1101.  
  1102.     lea ASasHurt,a0
  1103.     move #(ASasHurt_e-ASasHurt)/2,d0
  1104.     move #1,d1
  1105.     move #64,2
  1106.     bsr APlay11Khz
  1107.  
  1108.     delayed_part #FPS/2,Part3f_sas_die(pc)
  1109.  
  1110.     popa
  1111.     rts
  1112.  
  1113. Part3f_sas_die:
  1114.     pusha
  1115.  
  1116.     lea ADie05,a0
  1117.     move #(ADie05_e-ADie05)/2,d0
  1118.     move #1,d1
  1119.     move #64,2
  1120.     bsr APlay11Khz
  1121.  
  1122.     lea ASasManDown,a0
  1123.     move #(ASasManDown_e-ASasManDown)/2,d0
  1124.     move #2,d1
  1125.     move #64,2
  1126.     bsr APlay11Khz
  1127.  
  1128.     ; Blit dead SAS in place of SAS 2
  1129.     lea P3SasDead,a0
  1130.     lea P3SasDeadMask,a1
  1131.     lea Screen,a2
  1132.     move.l SasPos2(pc),d1
  1133.     move.l d1,d0
  1134.     swap d0
  1135.     move #SCREEN_D,d2
  1136.     move #SAS_W,d3
  1137.     move #SAS_H,d4
  1138.     move #SCREEN_W,d5
  1139.     bsr BlitMaskedXY
  1140.  
  1141.     ; SAS 3 position is now stored at the position of the dead SAS 2
  1142.     ; and SAS 3 is now effectively SAS 2. Previous SAS 2 is replaced
  1143.     ; by a blitted picture of dead SAS.
  1144.     move.l SasPos3(pc),d0
  1145.     move.l #$100,SasPos3
  1146.     move.l d0,SasPos2
  1147.  
  1148.     move #2,d2
  1149.     bsr PlotSas
  1150.     move #3,d2
  1151.     bsr PlotSas
  1152.  
  1153.     delayed_part #FPS/2,Part3g_firefight(pc)
  1154.  
  1155.     popa
  1156.     rts
  1157.  
  1158. Part3g_firefight:
  1159.     pusha
  1160.  
  1161.     ; Shut up SAS troopers
  1162.     move .first(pc),d0
  1163.     tst d0
  1164.     bne .not_first
  1165.     bsr APlayNullRight
  1166.     move #1,.first
  1167.  
  1168.     ; Begin AK47 canonade
  1169.     lea AAk47Burst,a0
  1170.     move.l #(AAk47Burst_e-AAk47Burst)/2-2000,d0
  1171.     move.l #0,d1
  1172.     move.l #64,d2
  1173.     bsr APlay11Khz
  1174.  
  1175. .not_first:
  1176.     bsr BulletEngine
  1177.  
  1178. .paskudny_shoot:
  1179.     move .paskudny_alive(pc),d0
  1180.     tst d0
  1181.     beq .wiesniak_shoot ; paskudny's dead, man
  1182.  
  1183.     move .xray_shoot(pc),d0
  1184.     move d0,d7
  1185.     addq #1,d0
  1186.     move d0,.xray_shoot
  1187.     and #$f,d0
  1188.     tst d0
  1189.     bne .wiesniak_shoot
  1190.  
  1191.     ; They will now shoot *very* inaccurate.
  1192.     move #P3_PASKUDNY_X+PASKUDNY_VISW,d0
  1193.     move #P3_PASKUDNY_Y+PASKUDNY_H/2,d1
  1194.     move #320,d2    ; nothing x
  1195.     move #300,d3    ; nothing y
  1196.     bsr FireBullet
  1197.  
  1198. .wiesniak_shoot:
  1199.     move .wiesniak_alive(pc),d0
  1200.     tst d0
  1201.     beq .dont_xray_shoot    ; wiesniak's dead too, now what we do?
  1202.  
  1203.     ; space his shooting differently than paskudny's
  1204.     and #$f,d7
  1205.     cmp #$8,d7
  1206.     bne .dont_xray_shoot
  1207.  
  1208.     move #P3_WIESNIAK_X+WIESNIAK_VISW,d0
  1209.     move #P3_WIESNIAK_Y+WIESNIAK_H/2,d1
  1210.     move #320,d2
  1211.     move #0,d3
  1212.     bsr FireBullet
  1213.  
  1214. .dont_xray_shoot:
  1215.     move .xray_shoot(pc),d7
  1216.     cmp #$50,d7
  1217.     beq .sas2_shoot
  1218.     cmp #$38,d7
  1219.     bne .track_sas_bullet
  1220.  
  1221. .sas1_shoot:
  1222.     move SasPos1(pc),d0
  1223.     move SasPos1+2(pc),d1
  1224.     add #SAS_H/2,d1
  1225.     move #P3_WIESNIAK_X+WIESNIAK_VISW,d2
  1226.     move #P3_WIESNIAK_Y+WIESNIAK_H/2,d3
  1227.     bsr FireBullet
  1228.     move d0,.sas_bullet_wiesniak
  1229.  
  1230.     lea AMp5_1,a0
  1231.     move #(AMp5_1_e-AMp5_1)/2,d0
  1232.     moveq #1,d1
  1233.     move #64,d2
  1234.     bsr APlay11Khz
  1235.  
  1236.     bra .dont_sas_shoot
  1237. .sas2_shoot:
  1238.     move SasPos2(pc),d0
  1239.     move SasPos2+2(pc),d1
  1240.     add #SAS_H/2-4,d1
  1241.     move #P3_PASKUDNY_X+PASKUDNY_VISW,d2
  1242.     move #P3_PASKUDNY_Y+PASKUDNY_H/2-4,d3
  1243.     bsr FireBullet
  1244.     move d0,.sas_bullet_paskudny
  1245.  
  1246.     lea AMp5_2,a0
  1247.     move #(AMp5_2_e-AMp5_2)/2,d0
  1248.     moveq #2,d1
  1249.     move #64,d2
  1250.     bsr APlay11Khz
  1251.     bra .dont_sas_shoot
  1252.  
  1253. .track_sas_bullet:
  1254.     ; track bullet that kills wiesniak
  1255.     move .sas_bullet_wiesniak(pc),d7
  1256.     cmp #$ffff,d7
  1257.     beq .no_sas_wiesniak_bullet
  1258.  
  1259.     ; bullet was shot, so shut up audio
  1260.     moveq #1,d1
  1261.     bsr APlayNull
  1262.  
  1263.     bullet_at_list a0,d7
  1264.     tst bullet_t.live(a0)
  1265.     bne .no_sas_wiesniak_bullet
  1266.  
  1267.     ; kill wiesniak
  1268.     move #0,.wiesniak_alive
  1269.  
  1270.     lea P3WiesniakDead,a0
  1271.     lea P3WiesniakDeadMask,a1
  1272.     lea Screen,a2
  1273.     move #P3_WIESNIAK_X,d0
  1274.     move #P3_WIESNIAK_Y,d1
  1275.     move #SCREEN_D,d2
  1276.     move #WIESNIAK_W,d3
  1277.     move #WIESNIAK_H,d4
  1278.     move #SCREEN_W,d5
  1279.     bsr BlitMaskedXY
  1280.  
  1281.     lea ADie07,a0
  1282.     move.l #(ADie07_e-ADie07)/2,d0
  1283.     move.l #0,d1
  1284.     move.l #64,d2
  1285.     bsr APlay11Khz
  1286.  
  1287. .no_sas_wiesniak_bullet:
  1288.     ; track bullet that kills paskudny
  1289.     move .sas_bullet_paskudny(pc),d7
  1290.     cmp #$ffff,d7
  1291.     beq .no_sas_paskudny_bullet
  1292.  
  1293.     ; bullet was shot, so shut up audio
  1294.     moveq #2,d1
  1295.     bsr APlayNull
  1296.  
  1297.     bullet_at_list a0,d7
  1298.     tst bullet_t.live(a0)
  1299.     bne .no_sas_paskudny_bullet
  1300.  
  1301.     ; kill paskudny
  1302.     move #0,.paskudny_alive
  1303.  
  1304.     lea P3PaskudnyDead,a0
  1305.     lea P3PaskudnyDeadMask,a1
  1306.     lea Screen,a2
  1307.     move #P3_PASKUDNY_X,d0
  1308.     move #P3_PASKUDNY_Y,d1
  1309.     move #SCREEN_D,d2
  1310.     move #PASKUDNY_W,d3
  1311.     move #PASKUDNY_H,d4
  1312.     move #SCREEN_W,d5
  1313.     bsr BlitMaskedXY
  1314.  
  1315.     lea ADie06,a0
  1316.     move.l #(ADie06_e-ADie06)/2,d0
  1317.     move.l #3,d1
  1318.     move.l #64,d2
  1319.     bsr APlay11Khz
  1320.  
  1321. .no_sas_paskudny_bullet:
  1322. .dont_sas_shoot:
  1323. .check_the_dead:
  1324.     move .wiesniak_alive(pc),d0
  1325.     tst d0
  1326.     bne .done
  1327.     move .paskudny_alive(pc),d0
  1328.     tst d0
  1329.     bne .done
  1330.     next_part Part3h_go(pc)
  1331. .done:
  1332.     popa
  1333.     rts
  1334.  
  1335. .xray_shoot:
  1336.     dc.w $ffff
  1337. .ak47_channel:
  1338.     dc.w 0
  1339. .first:
  1340.     dc.w 0
  1341. .sas_bullet_wiesniak:
  1342.     dc.w $ffff
  1343. .sas_bullet_paskudny:
  1344.     dc.w $ffff
  1345. .wiesniak_alive:
  1346.     dc.w 1
  1347. .paskudny_alive:
  1348.     dc.w 1
  1349.  
  1350.  
  1351. Part3h_go:
  1352.     ; SAS now go for the door and open it
  1353.     pusha
  1354.     move .start(pc),d7
  1355.     tst d7
  1356.     bne .already_started
  1357.     bsr APlayNullAll
  1358. .already_started:
  1359.     addq #1,d7
  1360.     move d7,.start
  1361.     bsr BulletEngine
  1362.  
  1363.     ; Delay a bit
  1364.     cmp #$20,d7
  1365.     blt .done
  1366.  
  1367.     ; Move up to the door
  1368.     move #88,d1
  1369.     move #1,d2
  1370.     bsr StepSasLeftToX
  1371.     bsr PlotSas
  1372.  
  1373.     move d7,d6
  1374.     and #$f,d6
  1375.     tst d6
  1376.     bne .skip_sound
  1377.     move #64,d2
  1378.     bsr APlayGrassWalkOneBoth
  1379. .skip_sound:
  1380.     ; Continue until we're moving
  1381.     tst d0
  1382.     bne .done
  1383.  
  1384.     bsr APlayNullAll
  1385.     delayed_part #FPS/2,Part3i_open_door
  1386.  
  1387. .done:
  1388.     popa
  1389.     rts
  1390. .start:
  1391.     dc.w 0
  1392.  
  1393.  
  1394. Part3i_open_door:
  1395.     pusha
  1396.  
  1397.     move .door_open(pc),d0
  1398.     tst d0
  1399.     bne .next
  1400.  
  1401.     ; OPDOR!
  1402.     lea DoorOpen,a0
  1403.     lea DoorMask,a1
  1404.     lea Screen,a2
  1405.     move #P3_DOOR_X,d0
  1406.     move #P3_DOOR_Y,d1
  1407.     move #SCREEN_D,d2
  1408.     move #DOOR_W,d3
  1409.     move #DOOR_H,d4
  1410.     move #SCREEN_W,d5
  1411.     bsr BlitMaskedXY
  1412.  
  1413.     lea ADoorOpen,a0
  1414.     move #(ADoorOpen_e-ADoorOpen)/2,d0
  1415.     move #1,d1
  1416.     move #64,d2
  1417.     bsr APlay11Khz
  1418.  
  1419.     move #1,.door_open
  1420.     bra .done
  1421. .next:
  1422.     bsr APlayNullAll
  1423.     delayed_part #FPS/2,Part3j_walk_through
  1424. .done:
  1425.     popa
  1426.     rts
  1427. .door_open:
  1428.     dc.w 0
  1429.  
  1430.  
  1431. Part3j_walk_through:
  1432.     pusha
  1433.  
  1434.     move.l #-32,d1
  1435.     move #$7,d2
  1436.     bsr StepMaskSasLeftToX
  1437.  
  1438.     move #NUM_SAS-2,d2
  1439. .plotsas:
  1440.     bsr PlotSas
  1441.     dbf d2,.plotsas
  1442.  
  1443.     ; Continue until screen fades out completely
  1444.     move .fadeout_countdown(pc),d0
  1445.     subq #1,d0
  1446.     move d0,.fadeout_countdown
  1447.     tst d0
  1448.     beq .next
  1449.  
  1450.     and #%11,d0
  1451.     tst d0
  1452.     bne .done
  1453.     move #64,d2
  1454.     bsr APlayGrassWalkManyBoth
  1455.  
  1456. .fadeout:
  1457.     lea P3Color(pc),a0
  1458.     lea CopperColor,a1
  1459.     move #SCREEN_COLORS,d0
  1460.     bsr DimScreen
  1461.     bra .done
  1462. .next:
  1463.     next_part StartPart4(pc)
  1464. .done:
  1465.     popa
  1466.     rts
  1467. .fadeout_countdown:
  1468.     dc.w 64
  1469.  
  1470. ;;
  1471. ;; Part4
  1472. ;;
  1473. P4_SAS0_X = 225
  1474. P4_SAS0_Y = 160
  1475. P4_SAS1_X = 256
  1476. P4_SAS1_Y = 128
  1477. P4_SAS2_X = 256
  1478. P4_SAS2_Y = 192
  1479.  
  1480. P4_BOMB_X = 48
  1481. P4_BOMB_Y = 85
  1482. P4_BOMB_W = 96
  1483. P4_BOMB_H = 171
  1484.  
  1485. P4_DOOR_X = 15
  1486. P4_DOOR_Y = 1
  1487.  
  1488. P4_60S_W = 48
  1489. P4_60S_H = 48
  1490. P4_60S_X = P4_DOOR_X+DOOR_W/2-P4_60S_W/2
  1491. P4_60S_Y = P4_DOOR_Y+DOOR_H-P4_60S_H-5
  1492.  
  1493.  
  1494.  
  1495. P4Color:
  1496.     dc.w $0111,$0b89,$0b8a,$0742
  1497.     dc.w $0665,$0c9a,$0aaa,$0bad
  1498.     dc.w $0734,$0745,$0956,$0867
  1499.     dc.w $0a68,$0978,$0a77,$0b79
  1500.     dc.w $0a89,$0111,$0222,$0333
  1501.     dc.w $0444,$0555,$0666,$0866
  1502.     dc.w $0777,$0888,$0bab,$0000
  1503.     dc.w $0800,$0f00,$0780,$0ff0
  1504.  
  1505.  
  1506. StartPart4:
  1507.     pusha
  1508.  
  1509.     fullscreen_part
  1510.  
  1511.     ; Yet again we need to copy the picture to the screen.
  1512.     ; Background will be used to blit back when we move stuff around.
  1513.     lea P4Scene,a0
  1514.     lea Screen,a1
  1515.     lea Background,a2
  1516.     move.l #(Screen_e-Screen)/4,d0
  1517. .screen_copy:
  1518.     move.l (a0),(a2)+
  1519.     move.l (a0)+,(a1)+
  1520.     dbf d0,.screen_copy
  1521.  
  1522.     ; Load colors
  1523.     lea P4Color(pc),a0
  1524.     bsr LoadColorsToCopper
  1525.  
  1526.     ; Load boom sprite
  1527.     lea CopperSprite7,a0
  1528.     move.l #BoomSprite,d0
  1529.     pokecopper d0,a0
  1530.  
  1531.     ; Reposition SAS troopers (TROOPERS!)
  1532.     ; There will be only one trooper moving at a time so we wish
  1533.     ; to keep only one sprite.
  1534.     move.l #P4_SAS0_X<<16!P4_SAS0_Y,SasPos0
  1535.     move.l #$100,SasPos1
  1536.     move.l #$100,SasPos2
  1537.     move.l #$100,SasPos3
  1538.     moveq #NUM_SAS-1,d2
  1539. .plotsas:
  1540.     bsr PlotSas
  1541.     dbf d2,.plotsas
  1542.  
  1543.     ; Enable copper, sprites and blitter
  1544.     move #$7fff,DMACON(a6)
  1545.     move #$87ef,DMACON(a6)
  1546.     move.l #Copper,COP1LCH(a6)
  1547.  
  1548.     ; Blit the other troopers on to the screen as background elements.
  1549.     ; They will remain stationary for the most part of this scene.
  1550.     lea P3Sas,a0
  1551.     lea P3SasMask,a1
  1552.     lea Screen,a2
  1553.     move.l #P4_SAS1_X,d0
  1554.     move.l #P4_SAS1_Y,d1
  1555.     move #SCREEN_D,d2
  1556.     move #SAS_W,d3
  1557.     move #SAS_H,d4
  1558.     move #SCREEN_W,d5
  1559.     bsr BlitMaskedXY
  1560.  
  1561.     move.l #P4_SAS2_X,d0
  1562.     move.l #P4_SAS2_Y,d1
  1563.     bsr BlitMaskedXY
  1564.  
  1565.     ; Somebody set up us the bomb.
  1566.     lea P4Bomb,a0
  1567.     lea P4BombMask,a1
  1568.     lea Screen,a2
  1569.     move.l #P4_BOMB_X,d0
  1570.     move.l #P4_BOMB_Y,d1
  1571.     move #SCREEN_D,d2
  1572.     move #P4_BOMB_W,d3
  1573.     move #P4_BOMB_H,d4
  1574.     move #SCREEN_W,d5
  1575.     bsr BlitMaskedXY
  1576.  
  1577.     ; Shotgun will be fired here
  1578.     lea CopperSprite6,a0
  1579.     bsr LoadShotgunPelletSprite
  1580.  
  1581.     bsr BlitWait
  1582.  
  1583.     delayed_part #FPS/3,Part4(pc)
  1584.  
  1585.     popa
  1586.     rts
  1587.  
  1588.  
  1589. Part4:
  1590. Part4a:
  1591.     pusha
  1592. _SAS_DST_X_4A = 160
  1593.     clr.l d7
  1594.     move.l #_SAS_DST_X_4A,d1
  1595.  
  1596.     clr d2
  1597.     bsr StepSasLeftToX
  1598.     move d0,d7
  1599.     bsr PlotSas
  1600.  
  1601.     tst d7
  1602.     beq .next
  1603.  
  1604.     move .step_count(pc),d0
  1605.     addq #1,d0
  1606.     move d0,.step_count
  1607.     and #%11,d0
  1608.     tst d0
  1609.     bne .done
  1610.  
  1611.     move #64,d2
  1612.     bsr APlayFloorWalkOneBoth
  1613.     bra .done
  1614. .next:
  1615.     next_part Part4b_door_opens(pc)
  1616. .done:
  1617.     popa
  1618.     rts
  1619. .step_count:
  1620.     dc.w $ffff
  1621.  
  1622.  
  1623. Part4b_door_opens:
  1624.     pusha
  1625.  
  1626.     bsr APlayNullAll
  1627.  
  1628.     ; Open the door ...
  1629.     lea DoorOpen,a0
  1630.     lea DoorMask,a1
  1631.     lea Screen,a2
  1632.     move #P4_DOOR_X,d0
  1633.     move #P4_DOOR_Y,d1
  1634.     move #SCREEN_D,d2
  1635.     move #DOOR_W,d3
  1636.     move #DOOR_H,d4
  1637.     move #SCREEN_W,d5
  1638.     bsr BlitMaskedXY
  1639.  
  1640.     lea ADoorOpen,a0
  1641.     move #(ADoorOpen_e-ADoorOpen)/2,d0
  1642.     move #3,d1
  1643.     move #64,d2
  1644.     bsr APlay11Khz
  1645.  
  1646.     ; ... and reveal THE 60's behind it!
  1647.     lea P460s,a0
  1648.     lea P460sMask,a1
  1649.     lea Screen,a2
  1650.     move #P4_60S_X,d0
  1651.     move #P4_60S_Y,d1
  1652.     move #SCREEN_D,d2
  1653.     move #P4_60S_W,d3
  1654.     move #P4_60S_H,d4
  1655.     move #SCREEN_W,d5
  1656.     bsr BlitMaskedXY
  1657.  
  1658.     delayed_part #FPS/3,Part4c_60s_surprise(pc)
  1659.  
  1660.     popa
  1661.     rts
  1662.  
  1663. Part4c_60s_surprise:
  1664.     pusha
  1665.     bsr APlayNullAll
  1666.     bsr BulletEngine
  1667.  
  1668.     move .shotgun_pellet(pc),d7
  1669.     cmp #$ffff,d7
  1670.     bne .already_fired
  1671.  
  1672.     ; Shoot the 60s with a shotgun, but sadly hit the pointman SAS instead.
  1673.     move #P4_SAS2_X-PELLET_W,d0
  1674.     move #P4_SAS2_Y+SAS_H/2-PELLET_H/2,d1
  1675.  
  1676.     move.l SasPos0,d2
  1677.     move d2,d3
  1678.     swap d2
  1679.     add #PELLET_W/2,d2
  1680.     add #SAS_H/4,d3
  1681.     bsr FireBullet
  1682.     move d0,.shotgun_pellet
  1683.  
  1684.     lea AShotgun,a0
  1685.     move #(AShotgun_e-AShotgun)/2,d0
  1686.     moveq #2,d1
  1687.     move #48,d2
  1688.     bsr APlay11Khz
  1689.     bra .done
  1690. .already_fired:
  1691.     moveq #2,d1
  1692.     bsr APlayNull
  1693.  
  1694.     move .shotgun_pellet(pc),d0
  1695.     bullet_at_list a0,d0
  1696.     tst bullet_t.live(a0)
  1697.     bne .done
  1698. .next:
  1699.     next_part Part4d_sas_die(pc)
  1700. .done:
  1701.     popa
  1702.     rts
  1703. .shotgun_pellet:
  1704.     dc.w $ffff
  1705.  
  1706. Part4d_sas_die:
  1707.     pusha
  1708.  
  1709.     ; Oops! You killed your team mate, you piece of plant life!
  1710.     lea ADie06,a0
  1711.     move #(ADie06_e-ADie06)/2,d0
  1712.     move #3,d1
  1713.     move #32,d2
  1714.     bsr APlay11Khz
  1715.  
  1716.     lea ASasBluOnBlu,a0
  1717.     move #(ASasBluOnBlu_e-ASasBluOnBlu)/2,d0
  1718.     move #2,d1
  1719.     move #64,d2
  1720.     bsr APlay11Khz
  1721.  
  1722.     ; Blit dead SAS in place of SAS 0
  1723.     lea P3SasDead,a0
  1724.     lea P3SasDeadMask,a1
  1725.     lea Screen,a2
  1726.     move.l SasPos0(pc),d1
  1727.     move.l d1,d0
  1728.     swap d0
  1729.     move #SCREEN_D,d2
  1730.     move #SAS_W,d3
  1731.     move #SAS_H,d4
  1732.     move #SCREEN_W,d5
  1733.     bsr BlitMaskedXY
  1734.  
  1735.     move.l #$100,SasPos0
  1736.     clr.l d2
  1737.     bsr PlotSas
  1738.  
  1739.     next_part Part4d2_stop_audio(pc)
  1740.  
  1741.     popa
  1742.     rts
  1743.  
  1744. Part4d2_stop_audio:
  1745.     pusha
  1746.     bsr APlayNullAll
  1747.     delayed_part #FPS,Part4d3_xray_surrender(pc)
  1748.     popa
  1749.     rts
  1750.  
  1751. Part4d3_xray_surrender:
  1752.     pusha
  1753.  
  1754.     ; Don't worry friend, we won't shoot you.
  1755.     lea AXrayDontShoot,a0
  1756.     move #(AXrayDontShoot_e-AXrayDontShoot)/2,d0
  1757.     moveq #3,d1
  1758.     move #56,d2
  1759.     bsr APlay11Khz
  1760.  
  1761.     delayed_part #FPS+FPS/2,Part4e_unpin_grenade(pc)
  1762.  
  1763.     popa
  1764.     rts
  1765.  
  1766.  
  1767. Part4e_unpin_grenade:
  1768.     pusha
  1769.  
  1770.     clr d1
  1771.     bsr APlayNull
  1772.     moveq #1,d1
  1773.     bsr APlayNull
  1774.     moveq #3,d1
  1775.     bsr APlayNull
  1776.  
  1777.     move .unpinned(pc),d0
  1778.     tst d0
  1779.     bne .no_unpin
  1780.  
  1781.     ; Play the audio
  1782.     move #2,d1
  1783.     move #64,d2
  1784.     bsr APlayGrenadeUnpin
  1785.     move #1,.unpinned
  1786.  
  1787.     ; Load the grenade sprite now instead of the SAS sprite.
  1788.     ; Don't plot it yet, but we'll do it soon.
  1789.     lea CopperSprite,a0
  1790.     bsr LoadGrenadeSprite
  1791.  
  1792.     bra .done
  1793. .no_unpin:
  1794.     moveq #2,d1
  1795.     bsr APlayNull
  1796.     delayed_part #FPS/2,Part4f_grenade_throw
  1797. .done:
  1798.     popa
  1799.     rts
  1800. .unpinned:
  1801.     dc.w 0
  1802.  
  1803.  
  1804. P4_GRENADE_X = P4_SAS1_X
  1805. P4_GRENADE_Y = P4_SAS1_Y+SAS_H/2-GRENADE_H/2
  1806. P4_GRENADE_DST_X = 46
  1807. GRENADE_SPEED = 4
  1808.  
  1809. P4GrenadeX:
  1810.     dc.w P4_GRENADE_X
  1811. P4GrenadeY:
  1812.     dc.w P4_GRENADE_Y
  1813.  
  1814.  
  1815. Part4f_grenade_throw:
  1816.     pusha
  1817.  
  1818.     move #2,d1
  1819.     bsr APlayNull
  1820.  
  1821.     ; Now plot the *grenayd!* and fire it left like a rocket.
  1822.     bsr P4PlotGrenade
  1823.  
  1824.     move P4GrenadeX(pc),d0
  1825.     sub #GRENADE_SPEED,d0
  1826.     move d0,P4GrenadeX
  1827.     cmp #P4_GRENADE_DST_X,d0
  1828.     bgt .done
  1829.  
  1830.     next_part Part4g_grenade_drop(pc)
  1831. .done:
  1832.     popa
  1833.     rts
  1834.  
  1835.  
  1836. Part4g_grenade_drop:
  1837.     pusha
  1838.  
  1839.     move #3,d1
  1840.     move #64,d2
  1841.     bsr APlayGrenadeBounce
  1842.  
  1843.     move .bump_bump(pc),d0
  1844.     tst d0
  1845.     beq .next
  1846.  
  1847.     ; Bump it a bit more, albeit slowly
  1848.     subq #1,d0
  1849.     move d0,.bump_bump
  1850.     and #%111,d0
  1851.     tst d0
  1852.     bne .done
  1853.  
  1854.     sub #2,P4GrenadeX
  1855.     bsr P4PlotGrenade
  1856.  
  1857.     bra .done
  1858. .next:
  1859.     next_part Part4h_grenade_boom
  1860. .done:
  1861.     popa
  1862.     rts
  1863. .bump_bump:
  1864.     dc.w 31
  1865.  
  1866.  
  1867. Part4h_grenade_boom:
  1868.     pusha
  1869.  
  1870.     ; Grenade explodes!
  1871.     move #3,d1
  1872.     move #64,d2
  1873.     bsr APlayGrenadeExplode
  1874.  
  1875.     ; There is an explosion!
  1876.     lea BoomSprite,a0
  1877.     move P4GrenadeX(pc),d0
  1878.     swap d0
  1879.     or P4GrenadeY(pc),d0
  1880.     add.l #$80002c,d0
  1881.     move #BOOM_H,d1
  1882.     bsr MoveSprite
  1883.  
  1884.     ; Grenade is gone!
  1885.     move #257,P4GrenadeY
  1886.     bsr P4PlotGrenade
  1887.  
  1888.     ; 60s xray is gone in a true The Regiment fashion!
  1889.     ; Blit the open door again to make him disappear.
  1890.     lea DoorOpen,a0
  1891.     lea DoorMask,a1
  1892.     lea Screen,a2
  1893.     move #P4_DOOR_X,d0
  1894.     move #P4_DOOR_Y,d1
  1895.     move #SCREEN_D,d2
  1896.     move #DOOR_W,d3
  1897.     move #DOOR_H,d4
  1898.     move #SCREEN_W,d5
  1899.     bsr BlitMaskedXY
  1900.  
  1901.     lea ADie05,a0
  1902.     move #(ADie05_e-ADie05)/2,d0
  1903.     move #1,d1
  1904.     move #64,d2
  1905.     bsr APlay11Khz
  1906.  
  1907.     ; The booby trap somehow survives.
  1908.     delayed_part #FPS/2,Part4i_respite(pc)
  1909.  
  1910.     popa
  1911.     rts
  1912.  
  1913.  
  1914. Part4i_respite:
  1915.     pusha
  1916.  
  1917.     bsr APlayNullAll
  1918.  
  1919.     ; Clear the top SAS BOB.
  1920.     lea Background,a0
  1921.     lea Screen,a2
  1922.     move.l #P4_SAS1_X,d0
  1923.     move.l #P4_SAS1_Y,d1
  1924.     move #SCREEN_D,d2
  1925.     move #SAS_W,d3
  1926.     move #SAS_H,d4
  1927.     move #SCREEN_W,d5
  1928.     bsr BlitBackground
  1929.  
  1930.     ; Remove explosion
  1931.     lea BoomSprite,a0
  1932.     move.l #$12c,d0
  1933.     move #BOOM_H,d1
  1934.     bsr MoveSprite
  1935.  
  1936.     ; Reload SAS sprite and replace the top SAS
  1937.     lea CopperSprite,a0
  1938.     bsr PokeCopperSasSprite
  1939.  
  1940.     move.l #P4_SAS1_X<<16!P4_SAS1_Y,SasPos0
  1941.     clr.l d2
  1942.     bsr PlotSas
  1943.  
  1944.     delayed_part #FPS*2,Part4j_sas_move_out(pc)
  1945.  
  1946.     popa
  1947.     rts
  1948.  
  1949. Part4j_sas_move_out:
  1950.     ; Move to the booby trap, trigger it and die there.
  1951.     pusha
  1952. _SAS_DST_X_4J = 145
  1953.     clr.l d7
  1954.     move.l #_SAS_DST_X_4J,d1
  1955.  
  1956.     clr d2
  1957.     bsr StepSasLeftToX
  1958.     move d0,d7
  1959.     bsr PlotSas
  1960.  
  1961.     tst d7
  1962.     beq .next
  1963.  
  1964.     move .step_count(pc),d0
  1965.     addq #1,d0
  1966.     move d0,.step_count
  1967.     and #%11,d0
  1968.     tst d0
  1969.     bne .done
  1970.  
  1971.     move #64,d2
  1972.     bsr APlayFloorWalkOneBoth
  1973.     bra .done
  1974. .next:
  1975.     next_part Part4k_see_trap(pc)
  1976. .done:
  1977.     popa
  1978.     rts
  1979. .step_count:
  1980.     dc.w $ffff
  1981.  
  1982.  
  1983. Part4k_see_trap:
  1984. _SAS_DST_X_4K = 105
  1985.     ; Notice the trap, but keep moving
  1986.     pusha
  1987.  
  1988.     move .noticed(pc),d0
  1989.     tst d0
  1990.     bne .already_noticed
  1991.     move #1,.noticed
  1992.  
  1993.     lea ASasBooby,a0
  1994.     move #(ASasBooby_e-ASasBooby)/2,d0
  1995.     move #2,d1
  1996.     move #64,d2
  1997.     bsr APlay11Khz
  1998.     bra .keep_going
  1999.  
  2000. .already_noticed:
  2001.     bsr APlayNullAll
  2002.  
  2003. .keep_going:
  2004.     clr.l d7
  2005.     move.l #_SAS_DST_X_4K,d1
  2006.  
  2007.     clr d2
  2008.     bsr StepSasLeftToX
  2009.     move d0,d7
  2010.     bsr PlotSas
  2011.  
  2012.     tst d7
  2013.     bne .done
  2014. .next:
  2015.     next_part Part4l_trip_trap(pc)
  2016. .done:
  2017.     popa
  2018.     rts
  2019. .noticed:
  2020.     dc.w 0
  2021.  
  2022.  
  2023. Part4l_trip_trap:
  2024.     ; The "oh shit..." moment
  2025.     pusha
  2026.  
  2027.     move .tripped(pc),d0
  2028.     tst d0
  2029.     bne .next
  2030.     move #1,.tripped
  2031.  
  2032.     lea ABoobyTripped,a0
  2033.     move #(ABoobyTripped_e-ABoobyTripped)/2,d0
  2034.     move #1,d1
  2035.     move #64,d2
  2036.     bsr APlay11Khz
  2037.     bra .done
  2038. .next:
  2039.     bsr APlayNullAll
  2040.     delayed_part #FPS,Part4m_explosion(pc)
  2041. .done:
  2042.     popa
  2043.     rts
  2044. .tripped:
  2045.     dc.w 0
  2046.  
  2047.  
  2048. Part4m_explosion:
  2049.     ; It kills the nearby SAS and clears the whole screen, basically
  2050.     pusha
  2051.  
  2052.     ; Audio canonade
  2053.     lea ABoobyExplode,a0
  2054.     move #(ABoobyExplode_e-ABoobyExplode)/2,d0
  2055.     move #2,d1
  2056.     move #48,d2
  2057.     bsr APlay11Khz
  2058.     move #3,d1
  2059.     bsr APlay11Khz
  2060.  
  2061.     lea ADie07,a0
  2062.     move #(ADie07_e-ADie07)/2,d0
  2063.     move #0,d1
  2064.     move #64,d2
  2065.     bsr APlay11Khz
  2066.  
  2067.     ; Redraw the left part of the screen
  2068.     lea Background,a0
  2069.     lea Screen,a2
  2070.     move #16,d0
  2071.     move #P4_BOMB_Y,d1
  2072.     move #SCREEN_D,d2
  2073.     move #192,d3
  2074.     move #SCREEN_H-P4_BOMB_Y,d4
  2075.     move #SCREEN_W,d5
  2076.     bsr BlitBackground
  2077.  
  2078.     ; Now the final SAS becomes SAS 0
  2079.     move.l #P4_SAS2_X<<16!P4_SAS2_Y,SasPos0
  2080.     clr.l d2
  2081.     bsr PlotSas
  2082.  
  2083.     ; There is another explosion!
  2084.     lea BoomSprite,a0
  2085.     move.l #(P4_BOMB_X+80)<<16+P4_BOMB_Y+BOOM_H/2+$80002c,d0
  2086.     move #BOOM_H,d1
  2087.     bsr MoveSprite
  2088.  
  2089.     ; Blit the open door back
  2090.     lea DoorOpen,a0
  2091.     lea DoorMask,a1
  2092.     lea Screen,a2
  2093.     move #P4_DOOR_X,d0
  2094.     move #P4_DOOR_Y,d1
  2095.     move #SCREEN_D,d2
  2096.     move #DOOR_W,d3
  2097.     move #DOOR_H,d4
  2098.     move #SCREEN_W,d5
  2099.     bsr BlitMaskedXY
  2100.  
  2101.     ; And redraw the background under the SAS
  2102.     lea Background,a0
  2103.     lea Screen,a2
  2104.     move #P4_SAS2_X,d0
  2105.     move #P4_SAS2_Y,d1
  2106.     move #SCREEN_D,d2
  2107.     move #SAS_W,d3
  2108.     move #SAS_H,d4
  2109.     move #SCREEN_W,d5
  2110.     bsr BlitBackground
  2111.  
  2112.     next_part Part4n_aftermath(pc)
  2113.  
  2114.     popa
  2115.     rts
  2116.  
  2117. Part4n_aftermath:
  2118.     pusha
  2119.     bsr APlayNullAll
  2120.     delayed_part #FPS+FPS/2,Part4n2_clear_explosion(pc)
  2121.     popa
  2122.     rts
  2123.  
  2124. Part4n2_clear_explosion:
  2125.     pusha
  2126.     lea BoomSprite,a0
  2127.     move.l #0,(a0)
  2128.  
  2129.     lea ASasMedic,a0
  2130.     move #(ASasMedic_e-ASasMedic)/2,d0
  2131.     move #1,d1
  2132.     move #64,d2
  2133.     bsr APlay11Khz
  2134.  
  2135.     delayed_part #2,Part4n3_nomedic(pc)
  2136.     popa
  2137.     rts
  2138.  
  2139. Part4n3_nomedic:
  2140.     pusha
  2141.     bsr APlayNullAll
  2142.     delayed_part #FPS*2,Part4o_mission_continues(pc)
  2143.     popa
  2144.     rts
  2145.  
  2146. Part4o_mission_continues:
  2147.     pusha
  2148. _SAS_DST_X_4O = 0
  2149.     move.l #_SAS_DST_X_4O,d1
  2150.  
  2151.     clr d2
  2152.     bsr StepSasLeftToX
  2153.     bsr PlotSas
  2154.  
  2155.     ; Continue until screen fades out completely
  2156.     move .fadeout_countdown(pc),d0
  2157.     subq #1,d0
  2158.     move d0,.fadeout_countdown
  2159.     tst d0
  2160.     beq .next
  2161.  
  2162.     and #%111,d0
  2163.     tst d0
  2164.     bne .done
  2165.     move #64,d2
  2166.     bsr APlayFloorWalkOneBoth
  2167.  
  2168. .fadeout:
  2169.     lea P4Color(pc),a0
  2170.     lea CopperColor,a1
  2171.     move #SCREEN_COLORS,d0
  2172.     bsr DimScreen
  2173.     bra .done
  2174. .next:
  2175.     next_part StartPart5(pc)
  2176. .done:
  2177.     popa
  2178.     rts
  2179. .fadeout_countdown:
  2180.     dc.w 128
  2181.  
  2182.  
  2183. P4PlotGrenade:
  2184.     pusha
  2185.  
  2186.     lea GrenadeSprite,a0
  2187.     move P4GrenadeX(pc),d0
  2188.     swap d0
  2189.     or P4GrenadeY(pc),d0
  2190.     add.l #$80002c,d0
  2191.     move #GRENADE_H,d1
  2192.     bsr MoveSprite
  2193.     add.l #GRENADE_ATTACH,a0
  2194.     bsr MoveSprite
  2195.  
  2196.     popa
  2197.     rts
  2198.  
  2199. ;;
  2200. ;; Part 5
  2201. ;;
  2202. P5_SAS0_X = 160
  2203. P5_SAS0_Y = -SAS_H
  2204.  
  2205. P5_SADDAM_X = 135
  2206. P5_SADDAM_Y = 144
  2207. SADDAM_W = 48
  2208. SADDAM_VISW = 32
  2209. SADDAM_H = 52
  2210.  
  2211.  
  2212. P5Color:
  2213.     dc.w $0565,$0776,$0333,$0764
  2214.     dc.w $0455,$0c9a,$0aaa,$0bad
  2215.     dc.w $0734,$0745,$0956,$0867
  2216.     dc.w $0a68,$0978,$0a77,$0b79
  2217.     dc.w $0a89,$0111,$0222,$0333
  2218.     dc.w $0444,$0555,$0666,$0866
  2219.     dc.w $0777,$0888,$0bab,$0000
  2220.     dc.w $0800,$0f00,$0780,$0ff0
  2221.  
  2222.  
  2223. StartPart5:
  2224.     ; Here we are. The lone survivor SAS hero arrives at the final enemy.
  2225.     ; This enemy is Saddam! And he helds the ambassador hostage.
  2226.     ; The ambassador needs some serious saving, but we'll get to
  2227.     ; that later.
  2228.     pusha
  2229.  
  2230.     fullscreen_part
  2231.  
  2232.     ; Load background
  2233.     lea P5Scene,a0
  2234.     lea Screen,a1
  2235.     move.l #(Screen_e-Screen)/4,d0
  2236. .screen_copy:
  2237.     move.l (a0)+,(a1)+
  2238.     dbf d0,.screen_copy
  2239.  
  2240.     ; Load colors
  2241.     lea P5Color(pc),a0
  2242.     bsr LoadColorsToCopper
  2243.  
  2244.     ; Position SAS
  2245.     move #P5_SAS0_X,SasPos0
  2246.     move #P5_SAS0_Y,SasPos0+2
  2247.     clr d2
  2248.     bsr PlotSas
  2249.  
  2250.     ; Shotgun will be fired here
  2251.     lea CopperSprite6,a0
  2252.     bsr LoadShotgunPelletSprite
  2253.  
  2254.     ; Enable copper, sprites and blitter
  2255.     move #$7fff,DMACON(a6)
  2256.     move #$87ef,DMACON(a6)
  2257.     move.l #Copper,COP1LCH(a6)
  2258.  
  2259.     next_part Part5(pc)
  2260.  
  2261.     popa
  2262.     rts
  2263.  
  2264.  
  2265. Part5:
  2266. Part5_lonewolf_sas_moves_in_and_this_can_be_any_length_i_want:
  2267.     pusha
  2268. _SAS_Y_P5 = 16
  2269.     move #_SAS_Y_P5,d1
  2270.     clr d2
  2271.     bsr StepSasBottomToY
  2272.     move d0,d7
  2273.     bsr PlotSas
  2274.  
  2275.     move .step_count(pc),d0
  2276.     addq #1,d0
  2277.     move d0,.step_count
  2278.     and #%111,d0
  2279.     tst d0
  2280.     bne .is_done
  2281.  
  2282.     move #64,d2
  2283.     bsr APlayFloorWalkOneBoth
  2284.  
  2285. .is_done:
  2286.     tst d7
  2287.     bne .done
  2288.  
  2289.     next_part Part5b_saddam_threat(pc)
  2290. .done:
  2291.     popa
  2292.     rts
  2293. .step_count:
  2294.     dc.w 0
  2295.  
  2296. Part5b_saddam_threat:
  2297.     pusha
  2298.     bsr APlayNullAll
  2299.  
  2300.     ; Say THAT threat
  2301.     lea AXrayYouBloodyFools,a0
  2302.     move #(AXrayYouBloodyFools_e-AXrayYouBloodyFools)/2,d0
  2303.     moveq #3,d1
  2304.     move #64,d2
  2305.     bsr APlay11Khz
  2306.  
  2307.     delayed_part #2,Part5b2_saddam_threatens(pc)
  2308.  
  2309.     popa
  2310.     rts
  2311.  
  2312. Part5b2_saddam_threatens:
  2313.     pusha
  2314.     bsr APlayNullAll
  2315.     delayed_part #FPS,Part5c_sas_kill_saddam(pc)
  2316.     popa
  2317.     rts
  2318.  
  2319. Part5c_sas_kill_saddam:
  2320.     pusha
  2321.  
  2322.     ; Fire shotgun at Saddam
  2323.     lea AShotgun,a0
  2324.     move #(AShotgun_e-AShotgun)/2,d0
  2325.     moveq #1,d1
  2326.     move #64,d2
  2327.     bsr APlay11Khz
  2328.  
  2329.     move.l SasPos0(pc),d1
  2330.     move.l d1,d0
  2331.     swap d0
  2332.     add #SAS_H,d1
  2333.     add #4,d0
  2334.     move #P5_SADDAM_X+SADDAM_VISW/2,d2
  2335.     move #P5_SADDAM_Y,d3
  2336.     bsr FireBullet
  2337.     move d0,P5Pellet
  2338.  
  2339.     bullet_at_list a0,d0
  2340.     move.l a0,P5Pellet
  2341.  
  2342.     delayed_part #2,Part5d_track_bullet(pc)
  2343.  
  2344.     popa
  2345.     rts
  2346.  
  2347.  
  2348. Part5d_track_bullet:
  2349.     ; We are doing the same code differently each time.
  2350.     ; Long live the consistency!
  2351.     pusha
  2352.  
  2353.     bsr APlayNullAll
  2354.  
  2355.     bsr BulletEngine
  2356.     move.l P5Pellet(pc),a0
  2357.     move bullet_t.live(a0),d0
  2358.     tst d0
  2359.     bne .done
  2360.  
  2361.     next_part Part5e_saddam_die(pc)
  2362. .done:
  2363.     popa
  2364.     rts
  2365.  
  2366.  
  2367. Part5e_saddam_die:
  2368.     ; Not again...
  2369.     pusha
  2370.  
  2371.     lea ADie05,a0
  2372.     move #(ADie05_e-ADie05)/2,d0
  2373.     moveq #0,d1
  2374.     move #64,d2
  2375.     bsr APlay11Khz
  2376.  
  2377.     lea P5SaddamDead,a0
  2378.     lea P5SaddamMask,a1
  2379.     lea Screen,a2
  2380.     move #P5_SADDAM_X,d0
  2381.     move #P5_SADDAM_Y,d1
  2382.     move #SCREEN_D,d2
  2383.     move #SADDAM_W,d3
  2384.     move #SADDAM_H,d4
  2385.     move #SCREEN_W,d5
  2386.     bsr BlitMaskedXY
  2387.  
  2388.     delayed_part #FPS/2,Part5f_continue_saddam(pc)
  2389.  
  2390.     popa
  2391.     rts
  2392.  
  2393. Part5f_continue_saddam:
  2394.     pusha
  2395.     bsr APlayNullAll
  2396.  
  2397.     ; Saddam threat is a long one and continues when he's dead already.
  2398.     lea AXrayAndItsYourFault,a0
  2399.     move #(AXrayAndItsYourFault_e-AXrayAndItsYourFault)/2,d0
  2400.     moveq #3,d1
  2401.     move #64,d2
  2402.     bsr APlay11Khz
  2403.  
  2404.     next_part Part5f2_respite(pc)
  2405.  
  2406.     popa
  2407.     rts
  2408.  
  2409. Part5f2_respite:
  2410.     pusha
  2411.     bsr APlayNullAll
  2412.     delayed_part #FPS*2,Part5g_approach_ambassador(pc)
  2413.     popa
  2414.     rts
  2415.  
  2416. Part5g_approach_ambassador:
  2417.     ; Copypaste programming is the best when you're running out of time
  2418.     ; and the deadline is just around the corner.
  2419.     pusha
  2420. _SAS_Y_5G = 160
  2421.     move #_SAS_Y_5G,d1
  2422.     clr d2
  2423.     bsr StepSasBottomToY
  2424.     move d0,d7
  2425.     bsr PlotSas
  2426.  
  2427.     move .step_count(pc),d0
  2428.     addq #1,d0
  2429.     move d0,.step_count
  2430.     and #%111,d0
  2431.     tst d0
  2432.     bne .is_done
  2433.  
  2434.     move #64,d2
  2435.     bsr APlayFloorWalkOneBoth
  2436.  
  2437. .is_done:
  2438.     tst d7
  2439.     bne .done
  2440.  
  2441.     next_part Part5h_ambassador_thanks(pc)
  2442. .done:
  2443.     popa
  2444.     rts
  2445. .step_count:
  2446.     dc.w 0
  2447.  
  2448. Part5h_ambassador_thanks:
  2449.     pusha
  2450.     bsr APlayNullAll
  2451.  
  2452.     ; Say "thank you"
  2453.     lea AHostThankYou,a0
  2454.     move #(AHostThankYou_e-AHostThankYou)/2,d0
  2455.     moveq #2,d1
  2456.     move #64,d2
  2457.     bsr APlay11Khz
  2458.  
  2459.     next_part Part5h2(pc)
  2460.     popa
  2461.     rts
  2462.  
  2463. Part5h2:
  2464.     pusha
  2465.     bsr APlayNullAll
  2466.     delayed_part #FPS+FPS/2,Part5i_mission_successful(pc)
  2467.     popa
  2468.     rts
  2469.  
  2470. Part5i_mission_successful:
  2471.     pusha
  2472.  
  2473.     ; Play the success sound.
  2474.     lea AWin,a0
  2475.     move #(AWin_e-AWin)/2,d0
  2476.     moveq #0,d1
  2477.     move #64,d2
  2478.     bsr APlay8Khz
  2479.     moveq #1,d1
  2480.     bsr APlay8Khz
  2481.  
  2482.     ; Screen dims a bit.
  2483.     lea P5Color(pc),a0
  2484.     lea CopperColor,a1
  2485.     move #SCREEN_COLORS,d0
  2486.     bsr DimScreen
  2487.  
  2488.     delayed_part #FPS+FPS/2,Part5j_unpin_grenade(pc)
  2489.     popa
  2490.     rts
  2491.  
  2492. Part5j_unpin_grenade:
  2493.     pusha
  2494.  
  2495.     ; SAS has a present for everyone.
  2496.     move #3,d1
  2497.     move #64,d2
  2498.     bsr APlayGrenadeUnpin
  2499.  
  2500.     ; Screen dims a bit... again.
  2501.     lea P5Color(pc),a0
  2502.     lea CopperColor,a1
  2503.     move #SCREEN_COLORS,d0
  2504.     bsr DimScreen
  2505.  
  2506.     ; Blit SAS as we will be replacing their sprite with a grenade, again.
  2507.     lea P3Sas,a0
  2508.     lea P3SasMask,a1
  2509.     lea Screen,a2
  2510.     move.l SasPos0(pc),d1
  2511.     move.l d1,d0
  2512.     swap d0
  2513.     move #SCREEN_D,d2
  2514.     move #SAS_W,d3
  2515.     move #SAS_H,d4
  2516.     move #SCREEN_W,d5
  2517.     bsr BlitMaskedXY
  2518.  
  2519.     ; Arbitrary values show that I want to get over with this already.
  2520.     sub #8,d0
  2521.     move d0,P5GrenadeX
  2522.     add #20,d1
  2523.     move d1,P5GrenadeY
  2524.  
  2525.     move.l #$100,SasPos0
  2526.     clr d2
  2527.     bsr PlotSas
  2528.  
  2529.     lea CopperSprite,a0
  2530.     bsr LoadGrenadeSprite
  2531.  
  2532.     next_part Part5j2(pc)
  2533.  
  2534.     popa
  2535.     rts
  2536.  
  2537. Part5j2:
  2538.     pusha
  2539.     bsr APlayNullAll
  2540.     delayed_part #FPS+FPS,Part5k_throw(pc)
  2541.     popa
  2542.     rts
  2543.  
  2544. Part5k_throw:
  2545.     pusha
  2546.  
  2547.     move P5GrenadeX(pc),d0
  2548.     add #$80,d0
  2549.     swap d0
  2550.     move P5GrenadeY(pc),d0
  2551.     add #$2c,d0
  2552.     move #GRENADE_H,d1
  2553.     lea GrenadeSprite,a0
  2554.     bsr MoveSprite
  2555.     add.l #GRENADE_ATTACH,a0
  2556.     bsr MoveSprite
  2557.  
  2558.     moveq #3,d1
  2559.     move #64,d2
  2560.     bsr APlayGrenadeBounce
  2561.  
  2562.     delayed_part #FPS/4,Part5k2
  2563.  
  2564.     popa
  2565.     rts
  2566.  
  2567. Part5k2:
  2568.     pusha
  2569.     bsr APlayNullAll
  2570.     lea P5Color(pc),a0
  2571.     lea CopperColor,a1
  2572.     move #SCREEN_COLORS,d0
  2573.     bsr DimScreen
  2574.     delayed_part #FPS+FPS,Part5k3_dimmore(pc)
  2575.     popa
  2576.     rts
  2577.  
  2578. Part5k3_dimmore:
  2579.     pusha
  2580.     bsr APlayNullAll
  2581.     lea P5Color(pc),a0
  2582.     lea CopperColor,a1
  2583.     move #SCREEN_COLORS,d0
  2584.     bsr DimScreen
  2585.     delayed_part #FPS+FPS/2,Part5l_kaboom(pc)
  2586.     popa
  2587.     rts
  2588.  
  2589. Part5l_kaboom:
  2590.     pusha
  2591.  
  2592.     lea P5Color(pc),a0
  2593.     move #SCREEN_COLORS-1,d0
  2594. .blackloop:
  2595.     move #0,(a0)+
  2596.     dbf d0,.blackloop
  2597.  
  2598.     lea P5Color(pc),a0
  2599.     lea CopperColor,a1
  2600.     move #SCREEN_COLORS,d0
  2601.     bsr PokeCopperWords
  2602.  
  2603.     moveq #3,d1
  2604.     move #40,d2
  2605.     bsr APlayGrenadeExplode
  2606.  
  2607.     delayed_part #10,Part5l2(pc)
  2608.  
  2609.     popa
  2610.     rts
  2611.  
  2612. Part5l2:
  2613.     pusha
  2614.     moveq #3,d1
  2615.     bsr APlayNull
  2616.  
  2617.     lea ADie06,a0
  2618.     move #(ADie06_e-ADie06)/2,d0
  2619.     moveq #0,d1
  2620.     move #64,d2
  2621.     bsr APlay11Khz
  2622.  
  2623.     lea ADie07,a0
  2624.     move #(ADie07_e-ADie07)/2,d0
  2625.     moveq #1,d1
  2626.     bsr APlay11Khz
  2627.  
  2628.     next_part Part5l3
  2629.  
  2630.     popa
  2631.     rts
  2632.  
  2633. Part5l3:
  2634.     pusha
  2635.     bsr APlayNullAll
  2636.     delayed_part #FPS*4,StartEndScreen(pc)
  2637.     popa
  2638.     rts
  2639.  
  2640.  
  2641. P5Pellet:
  2642.     dc.l $ffffffff
  2643. P5GrenadeX:
  2644.     dc.w 0
  2645. P5GrenadeY:
  2646.     dc.w 0
  2647.  
  2648. ;;
  2649. ;; Part End
  2650. ;;
  2651. END_W = 320
  2652. END_H = 49
  2653. END_D = 3
  2654. END_BYPL = END_W/8
  2655. END_BYWIDTH = END_BYPL*END_D
  2656.  
  2657. BONUS_W = 116
  2658. BONUS_VISW = 104
  2659. BONUS_H = 128
  2660. BONUS_D = 4
  2661. BONUS_BYPL = BONUS_W/8
  2662. BONUS_BYWIDTH = BONUS_BYPL*BONUS_D
  2663.  
  2664. BONUS_X = (SCREEN_W-BONUS_W)/2
  2665. BONUS_Y = (SCREEN_H-BONUS_H)/2
  2666.  
  2667. ; Offset screen pointer to begin at the top-left corner of the center.
  2668. BONUS_TOPLEFT = SCREEN_W/8*BONUS_D*BONUS_Y+BONUS_X/8
  2669.  
  2670. GURU_W = 304
  2671. GURU_VISW = 293
  2672. GURU_H = 51
  2673. GURU_D = 1
  2674. GURU_BYPL = GURU_W/8
  2675.  
  2676. GURU_X = (SCREEN_W-GURU_W)/2
  2677. GURU_Y = 16
  2678. GURU_TOPLEFT = SCREEN_W/8*GURU_D*GURU_Y+GURU_X/8
  2679.  
  2680.  
  2681.  
  2682. EndColor:
  2683.     dc.w $0332,$0333,$0542,$0851
  2684.     dc.w $0565,$0e80,$0899,$0bcc
  2685.     dcb.w 24,0
  2686.  
  2687.  
  2688. StartEndScreen:
  2689.     pusha
  2690.  
  2691.     bsr LoadEndCopper
  2692.     bsr APlayNullAll
  2693.  
  2694.     bsr ClearScreen
  2695.  
  2696.     ; Copy the screen
  2697.     lea MissionSuccess,a0
  2698.     lea Screen,a1
  2699.     move.l #(MissionSuccess_e-MissionSuccess)/4,d0
  2700. .screen_copy:
  2701.     move.l (a0)+,(a1)+
  2702.     dbf d0,.screen_copy
  2703.  
  2704.     bsr BlitWait
  2705.  
  2706.     ; Enable copper, audio and bitplane DMA and load the copper list
  2707.     move #$7fff,DMACON(a6)
  2708.     move #$87ef,DMACON(a6)
  2709.     move.l #Copper,COP1LCH(a6)
  2710.  
  2711.     next_part MissionEnd(pc)
  2712.  
  2713.     popa
  2714.     rts
  2715.  
  2716. LoadEndCopper:
  2717.     pusha
  2718.     sub #copper_t,sp
  2719.  
  2720.     move.l sp,a0
  2721.     bsr InitCopperT
  2722.     move.b #END_D,copper_t.bitplanes(a0)
  2723.     move #$807f,copper_t.wait(a0)
  2724.     move #END_BYWIDTH-END_BYPL,copper_t.bpl1mod(a0)
  2725.     move #END_BYWIDTH-END_BYPL,copper_t.bpl2mod(a0)
  2726.  
  2727.     bsr LoadCopper
  2728.  
  2729.     bsr LoadScreenToCopper
  2730.  
  2731.     lea EndColor(pc),a0
  2732.     bsr LoadColorsToCopper
  2733.  
  2734.     lea CopperSprite,a0
  2735.     moveq #8,d0
  2736.     bsr PokeCopperNullSprite
  2737.  
  2738.     add #copper_t,sp
  2739.     popa
  2740.     rts
  2741.  
  2742. MissionEnd:
  2743.     pusha
  2744.     bsr APlayIntro
  2745.     delayed_part #FPS*10,StartBonusScreen(pc)
  2746.     popa
  2747.     rts
  2748.  
  2749.  
  2750. BonusColor:
  2751.     dc.w $0100,$0211,$0211,$0311
  2752.     dc.w $0322,$0321,$0421,$0532
  2753.     dc.w $0531,$0642,$0642,$0742
  2754.     dc.w $0743,$0754,$0852,$0864
  2755.     dcb.w 16,0
  2756.  
  2757. StartBonusScreen:
  2758.     pusha
  2759.     bsr LoadBonusCopper
  2760.     bsr APlayNullAll
  2761.  
  2762.     bsr ClearScreen
  2763.  
  2764.     ; Copy the screen
  2765.     ; Bonus screen is not the full width of the screen so we need
  2766.     ; to modulo it correctly. We also need to position it at the center.
  2767.     lea BonusScreen,a0
  2768.     lea Screen+BONUS_TOPLEFT,a1
  2769.     move #(BONUS_H-1)*BONUS_D,d0        ; How many bitplane lines
  2770. .screen_copy:
  2771.     move #BONUS_BYPL-1,d1
  2772. .line_copy:
  2773.     move.b (a0)+,(a1)+
  2774.     dbf d1,.line_copy
  2775.     add.l #SCREEN_BYPL-BONUS_BYPL,a1    ; Shift the screen by modulo
  2776.     dbf d0,.screen_copy
  2777.  
  2778.     bsr BlitWait
  2779.  
  2780.     ; Enable copper, audio and bitplane DMA and load the copper list
  2781.     move #$7fff,DMACON(a6)
  2782.     move #$87ef,DMACON(a6)
  2783.     move.l #Copper,COP1LCH(a6)
  2784.  
  2785.     delayed_part #FPS*2,BonusPart(pc)
  2786.  
  2787.     popa
  2788.     rts
  2789.  
  2790. LoadBonusCopper:
  2791.     pusha
  2792.     sub #copper_t,sp
  2793.  
  2794.     move.l sp,a0
  2795.     bsr InitCopperT
  2796.     move.b #BONUS_D,copper_t.bitplanes(a0)
  2797.     move #SCREEN_BYPL*BONUS_D-SCREEN_BYPL,copper_t.bpl1mod(a0)
  2798.     move #SCREEN_BYPL*BONUS_D-SCREEN_BYPL,copper_t.bpl2mod(a0)
  2799.  
  2800.     bsr LoadCopper
  2801.  
  2802.     bsr LoadScreenToCopper
  2803.  
  2804.     lea BonusColor(pc),a0
  2805.     bsr LoadColorsToCopper
  2806.  
  2807.     lea CopperSprite,a0
  2808.     moveq #8,d0
  2809.     bsr PokeCopperNullSprite
  2810.  
  2811.     add #copper_t,sp
  2812.     popa
  2813.     rts
  2814.  
  2815.  
  2816. BonusPart:
  2817.     pusha
  2818.  
  2819.     lea AMp5_1,a0
  2820.     move #(AMp5_1_e-AMp5_1)/2,d0
  2821.     moveq #2,d1
  2822.     move #64,d2
  2823.     bsr APlay11Khz
  2824.  
  2825.     delayed_part #FPS/2,BonusPartDie(pc)
  2826.     popa
  2827.     rts
  2828.  
  2829. BonusPartDie:
  2830.     pusha
  2831.  
  2832.     bsr APlayNullAll
  2833.  
  2834.     lea ADie05,a0
  2835.     move #(ADie05_e-ADie05)/2,d0
  2836.     moveq #3,d1
  2837.     move #64,d2
  2838.     bsr APlay11Khz
  2839.  
  2840.     delayed_part #FPS/2,BonusPartExplode(pc)
  2841.     popa
  2842.     rts
  2843.  
  2844. BonusPartExplode:
  2845.     pusha
  2846.  
  2847.     bsr APlayNullAll
  2848.  
  2849.     lea ABoobyExplode,a0
  2850.     move #(ABoobyExplode_e-ABoobyExplode)/2,d0
  2851.     moveq #0,d1
  2852.     move #63,d2
  2853.     bsr APlay11Khz
  2854.     moveq #1,d1
  2855.     bsr APlay11Khz
  2856.  
  2857.     delayed_part #FPS,StartGuru(pc)
  2858.  
  2859.     popa
  2860.     rts
  2861.  
  2862. GuruColor:
  2863.     dc.w $0000,$0f00,$0000,$0000
  2864.     dcb.w 28,0
  2865.  
  2866.  
  2867. StartGuru:
  2868.     pusha
  2869.     audio_off
  2870.     bsr LoadGuruCopper
  2871.     bsr APlayNullAll
  2872.  
  2873.     bsr ClearScreen
  2874.  
  2875.     ; Copy the screen
  2876.     lea GuruScreen,a0
  2877.     lea Screen+GURU_TOPLEFT,a1
  2878.     move #(GURU_H-1)*GURU_D,d0
  2879. .screen_copy:
  2880.     move #GURU_BYPL-1,d1
  2881. .line_copy:
  2882.     move.b (a0)+,(a1)+
  2883.     dbf d1,.line_copy
  2884.     add.l #SCREEN_BYPL-GURU_BYPL,a1
  2885.     dbf d0,.screen_copy
  2886.  
  2887.     bsr BlitWait
  2888.  
  2889.     ; Enable copper, audio and bitplane DMA and load the copper list
  2890.     move #$7fff,DMACON(a6)
  2891.     move #$87ef,DMACON(a6)
  2892.     move.l #Copper,COP1LCH(a6)
  2893.  
  2894.     next_part GuruPartRed(pc)
  2895.  
  2896.     popa
  2897.     rts
  2898.  
  2899. LoadGuruCopper:
  2900.     pusha
  2901.     sub #copper_t,sp
  2902.  
  2903.     move.l sp,a0
  2904.     bsr InitCopperT
  2905.     move.b #GURU_D,copper_t.bitplanes(a0)
  2906.     move #SCREEN_BYPL*GURU_D-SCREEN_BYPL,copper_t.bpl1mod(a0)
  2907.     move #SCREEN_BYPL*GURU_D-SCREEN_BYPL,copper_t.bpl2mod(a0)
  2908.  
  2909.     bsr LoadCopper
  2910.  
  2911.     bsr LoadScreenToCopper
  2912.  
  2913.     lea GuruColor(pc),a0
  2914.     bsr LoadColorsToCopper
  2915.  
  2916.     lea CopperSprite,a0
  2917.     moveq #8,d0
  2918.     bsr PokeCopperNullSprite
  2919.  
  2920.     add #copper_t,sp
  2921.     popa
  2922.     rts
  2923.  
  2924. GuruPartRed:
  2925.     ; Just blink until the end of time
  2926.     pusha
  2927.     move #$0f00,GuruColor+2
  2928.     lea GuruColor(pc),a0
  2929.     bsr LoadColorsToCopper
  2930.     delayed_part #FPS,GuruPartBlack(pc)
  2931.     popa
  2932.     rts
  2933.  
  2934. GuruPartBlack:
  2935.     pusha
  2936.     move #$0000,GuruColor+2
  2937.     lea GuruColor(pc),a0
  2938.     bsr LoadColorsToCopper
  2939.  
  2940.     add #1,GuruUntilQuit
  2941.     cmp #10,GuruUntilQuit
  2942.     bne .noquit
  2943.     move #1,Quit
  2944. .noquit:
  2945.     delayed_part #FPS,GuruPartRed(pc)
  2946.     popa
  2947.     rts
  2948.  
  2949. GuruUntilQuit:
  2950.     dc.w 0
  2951.  
  2952. ;;
  2953. ;; SAS
  2954. ;;
  2955.  
  2956.     ; get the SAS trooper position by index
  2957.     ; Arg1 - d-register with index
  2958.     ; Arg2 - a-register where to store the addresss
  2959. SasIdxToPosAddr: MACRO
  2960.     lea SasPos0(pc),\2
  2961.     ext \1
  2962.     mulu #4,\1
  2963.     add.l \1,\2
  2964.     ENDM
  2965.  
  2966. StepAllSasLeftToX:
  2967.     ; Args:
  2968.     ;   d1 - long; X to stepto
  2969.     ; Result:
  2970.     ;   d0 - number of troopers that moved
  2971.     pushnr
  2972.     move #1,d2
  2973.     lsl #NUM_SAS,d2
  2974.     subq #1,d2
  2975.     bsr StepMaskSasLeftToX
  2976.     popnr
  2977.     rts
  2978.  
  2979. StepMaskSasLeftToX:
  2980.     ; Args:
  2981.     ;   d1 - long; X to step to
  2982.     ;   d2 - SAS mask - bits 3-0 -> SAS 3-0
  2983.     ; Result:
  2984.     ;   d0 - number of troopers that moved
  2985.     pushnr
  2986.     move d2,d6
  2987.     clr.l d7
  2988.  
  2989.     btst #0,d6
  2990.     beq .sas_1
  2991.     clr.l d2
  2992.     bsr StepSasLeftToX
  2993.     add d0,d7
  2994.     bsr PlotSas
  2995. .sas_1:
  2996.     btst #1,d6
  2997.     beq .sas_2
  2998.     moveq #1,d2
  2999.     bsr StepSasLeftToX
  3000.     add d0,d7
  3001.     bsr PlotSas
  3002. .sas_2:
  3003.     btst #2,d6
  3004.     beq .sas_3
  3005.     moveq #2,d2
  3006.     bsr StepSasLeftToX
  3007.     add d0,d7
  3008.     bsr PlotSas
  3009. .sas_3:
  3010.     btst #3,d6
  3011.     beq .sas_e
  3012.     moveq #3,d2
  3013.     bsr StepSasLeftToX
  3014.     add d0,d7
  3015.     bsr PlotSas
  3016. .sas_e:
  3017.     move d7,d0
  3018.     ext d0
  3019.     popnr
  3020.     rts
  3021.  
  3022.  
  3023.  
  3024. StepSasLeftToX:
  3025.     ; Args:
  3026.     ;   d1 - long; X to move to
  3027.     ;   d2 - SAS 0, 1, 2 or 3
  3028.     ; Result:
  3029.     ;   d0 - 1 if moved, 0 if not
  3030.     pushnr
  3031.  
  3032.     ; get the SAS trooper position by index
  3033.     SasIdxToPosAddr d2,a0
  3034.  
  3035.     move.l (a0),d0
  3036.     swap d0
  3037.  
  3038.     cmp d1,d0
  3039.     ble .no_move
  3040.  
  3041.     subq #1,d0
  3042.     move d0,d1
  3043.     swap d0
  3044.     move.l d0,(a0)
  3045.  
  3046.     moveq #1,d0
  3047.     bra .move
  3048.  
  3049. .no_move:
  3050.     clr.l d0
  3051. .move:
  3052.     popnr
  3053.     rts
  3054.  
  3055.  
  3056. StepSasBottomToY:
  3057.     ; Args:
  3058.     ;   d1 - long; Y to move to
  3059.     ;   d2 - SAS 0, 1, 2 or 3
  3060.     ; Result:
  3061.     ;   d0 - 1 if moved, 0 if not
  3062.     pushnr
  3063.  
  3064.     ; get the SAS trooper position by index
  3065.     SasIdxToPosAddr d2,a0
  3066.  
  3067.     move 2(a0),d0
  3068.  
  3069.     cmp d1,d0
  3070.     bge .no_move
  3071.  
  3072.     addq #1,d0
  3073.     move d0,2(a0)
  3074.  
  3075.     moveq.l #1,d0
  3076.     bra .move
  3077.  
  3078. .no_move:
  3079.     clr.l d0
  3080. .move:
  3081.     popnr
  3082.     rts
  3083.  
  3084.  
  3085.  
  3086. PlotSas:
  3087.     ; d2 - SAS 0, 1, 2 or 3
  3088.     ;
  3089.     ; SAS 0, 1, 2 and 3 are the same sprite and they cannot occupy the
  3090.     ; same line. They must be separated by at least one blank line.
  3091.     pusha
  3092.  
  3093.     ; get SAS (x,y) in d0
  3094.     move.l d2,d0
  3095.     SasIdxToPosAddr d0,a0
  3096.     move.l (a0),d0
  3097.  
  3098.     ; We need to add both values separately or else the negative values
  3099.     ; won't be added properly (someone didn't do the job proply).
  3100.     add #$2c,d0
  3101.     swap d0
  3102.     add #SCREEN_X_MARGIN,d0
  3103.     swap d0
  3104.  
  3105.     move #SAS_H,d1
  3106.     mulu #SAS_BYTES,d2
  3107.  
  3108.     lea SasLeft,a0
  3109.     lea (a0,d2),a0
  3110.     bsr MoveSprite
  3111.     add.l #SAS_ATTACH,a0
  3112.     bsr MoveSprite
  3113.  
  3114.     add.l #$100000,d0
  3115.     lea SasRight,a0
  3116.     lea (a0,d2),a0
  3117.     bsr MoveSprite
  3118.     add.l #SAS_ATTACH,a0
  3119.     bsr MoveSprite
  3120.  
  3121.     popa
  3122.     rts
  3123.  
  3124. _SAS_X = 420
  3125. _SAS_Y = 25
  3126.  
  3127. SasPos0:
  3128.     dc.w _SAS_X,_SAS_Y
  3129. SasPos1:
  3130.     dc.w _SAS_X+57,_SAS_Y+SAS_H+5+1
  3131. SasPos2:
  3132.     dc.w _SAS_X-3,_SAS_Y+2*SAS_H+10+2
  3133. SasPos3:
  3134.     dc.w _SAS_X+4,_SAS_Y+3*SAS_H+15+3
  3135.  
  3136. SasGrassWalkVolume:
  3137.     dc.w 0
  3138.  
  3139.  
  3140. ;;
  3141. ;; Bullets
  3142. ;;
  3143. BULLET_H = 1
  3144. BULLET_BYTES = 4+4*BULLET_H
  3145. NUM_BULLETS_MAX = 20
  3146.  
  3147. bullet_t.x = 0
  3148. bullet_t.y = 2
  3149. bullet_t.dst_x = 4
  3150. bullet_t.dst_y = 6
  3151. bullet_t.src_x = 8
  3152. bullet_t.src_y = 10
  3153. bullet_t.live = 12
  3154. bullet_t = 14
  3155.  
  3156.  
  3157. BulletEngine:
  3158.     pusha
  3159.     bsr MoveBullets
  3160.     bsr PlotBullets
  3161.     popa
  3162.     rts
  3163.  
  3164.  
  3165. FireBullet:
  3166.     ; Args:
  3167.     ;   d0 - origin x
  3168.     ;   d1 - origin y
  3169.     ;   d2 - target x
  3170.     ;   d3 - target y
  3171.     ; Result:
  3172.     ;   d0 - index of fired bullet, or $ffff if cannot fire
  3173.     pushnr
  3174.  
  3175.     ; Find first free bullet on the list
  3176.     lea BulletList(pc),a0
  3177.     move #NUM_BULLETS_MAX-1,d7
  3178. .loop_bullet_seek:
  3179.     move bullet_t.live(a0),d6
  3180.     tst d6
  3181.     beq .bullet_found
  3182.     add #bullet_t,a0
  3183.     dbf d7,.loop_bullet_seek
  3184.     ; Free bullet not found; bail
  3185.     move #$ffff,d0
  3186.     bra .done
  3187. .bullet_found:
  3188.     ; The free bullet is in a0
  3189.     ; Let's init it
  3190.     move d0,bullet_t.x(a0)
  3191.     move d0,bullet_t.src_x(a0)
  3192.     move d1,bullet_t.y(a0)
  3193.     move d1,bullet_t.src_y(a0)
  3194.     move d2,bullet_t.dst_x(a0)
  3195.     move d3,bullet_t.dst_y(a0)
  3196.     move #1,bullet_t.live(a0)
  3197.  
  3198.     ; Return the index
  3199.     move #NUM_BULLETS_MAX-1,d0
  3200.     sub d7,d0
  3201. .done:
  3202.     popnr
  3203.     rts
  3204.  
  3205.  
  3206. MoveBullets:
  3207.     pusha
  3208.  
  3209.     lea BulletList(pc),a0
  3210.     move #NUM_BULLETS_MAX-1,d7
  3211. .loop:
  3212.     tst bullet_t.live(a0)
  3213.     beq .continue
  3214.  
  3215.     move #4,d6  ; move bullet by many steps at once - bullets are fast
  3216. .bullet_step:
  3217.     move bullet_t.src_x(a0),d0
  3218.     move bullet_t.src_y(a0),d1
  3219.     move bullet_t.dst_x(a0),d2
  3220.     move bullet_t.dst_y(a0),d3
  3221.     move bullet_t.x(a0),d4
  3222.     move bullet_t.y(a0),d5
  3223.  
  3224.     ; Has bullet reached its destination?
  3225.     cmp d2,d4
  3226.     bne .bullet_alive
  3227.     cmp d3,d5
  3228.     bne .bullet_alive
  3229.     ; bullet dead
  3230.     move #0,bullet_t.live(a0)
  3231.     bra .continue
  3232.  
  3233. .bullet_alive:
  3234.     ext.l d0
  3235.     ext.l d1
  3236.     ext.l d2
  3237.     ext.l d3
  3238.     ext.l d4
  3239.     ext.l d5
  3240.     bsr BresenhamStepLine
  3241.     move d0,bullet_t.x(a0)
  3242.     move d1,bullet_t.y(a0)
  3243.  
  3244.     dbf d6,.bullet_step
  3245. .continue:
  3246.     add.l #bullet_t,a0
  3247.     dbf d7,.loop
  3248.  
  3249.     popa
  3250.     rts
  3251.  
  3252.  
  3253. PlotBullets:
  3254.     pusha
  3255.  
  3256.     move CurrentNumBulletsMax(pc),d7
  3257.     subq #1,d7
  3258.     move.l CurrentBulletSprite(pc),a0
  3259.     move #0,d0
  3260. .bullet_loop:
  3261.     bsr NextYBullet
  3262.     tst.l d0
  3263.     beq .done
  3264.  
  3265.     ; plot bullet
  3266.     move.l d0,a1
  3267.     move bullet_t.x(a1),d0
  3268.     swap d0
  3269.     move bullet_t.y(a1),d0
  3270.     add.l #$80002c,d0
  3271.     move BulletHeight(pc),d1
  3272.     bsr MoveSprite
  3273.  
  3274.     add #BULLET_BYTES,a0    ; next bullet sprite
  3275.     move bullet_t.y(a1),d0  ; next y from which to start
  3276.     addq #1,d0
  3277.     dbf d7,.bullet_loop ; dbf is for infinite loop precaution
  3278. .done:
  3279.     ; all remaining sprites must be removed from screen
  3280.     tst d7
  3281.     bmi .all_done
  3282. .sprite_remove:
  3283.     move.l #0,(a0)
  3284.     add #BULLET_BYTES,a0
  3285.     dbf d7,.sprite_remove
  3286. .all_done:
  3287.     popa
  3288.     rts
  3289. BulletHeight:
  3290.     dc.w 1
  3291. CurrentNumBulletsMax:
  3292.     dc.w 1
  3293. CurrentBulletSprite:
  3294.     dc.l $ffffffff
  3295.  
  3296.  
  3297. NextYBullet:
  3298.     ; Gets next bullet from the list that's closest to the passed Y
  3299.     ; Args:
  3300.     ;   d0 - the Y value
  3301.     ; Result;
  3302.     ;   d0 - addr of the closest bullet to the passed Y or 0 if none
  3303.     pushnr
  3304.  
  3305.     move.l #0,a1
  3306.     move #$ffff,d6      ; current Y distance
  3307.     lea BulletList(pc),a0
  3308.     move #NUM_BULLETS_MAX-1,d7
  3309. .loop_bullets:
  3310.     ; dead bullets don't count
  3311.     tst bullet_t.live(a0)
  3312.     beq .continue_bullets
  3313.     ; has this bullet greater Y?
  3314.     cmp.w bullet_t.y(a0),d0
  3315.     bge .continue_bullets
  3316.     ; is this bullet closer than the previous one?
  3317.     move bullet_t.y(a0),d1
  3318.     sub d0,d1
  3319.     cmp d1,d6
  3320.     blo .continue_bullets
  3321.     ; we have a new closest bullet
  3322.     move d1,d6
  3323.     move.l a0,a1
  3324. .continue_bullets:
  3325.     add.l #bullet_t,a0
  3326.     dbf d7,.loop_bullets
  3327.  
  3328.     move.l a1,d0
  3329.     popnr
  3330.     rts
  3331.  
  3332. PaintBullets:
  3333.     pusha
  3334.     lea BulletSprite,a0
  3335.     move #NUM_BULLETS_MAX-1,d0
  3336. .loop:
  3337.     move.b #%11000000,4(a0)
  3338.     move.b #%11000000,6(a0)
  3339.     add.l #8,a0
  3340.     dbf d0,.loop
  3341.     popa
  3342.     rts
  3343.  
  3344.  
  3345. LoadShotgunPelletSprite:
  3346.     ; Args:
  3347.     ;   a0 - copper address for sprite address poke
  3348.     pusha
  3349.     ; Only shotgun will be fired so we can hack the bullet engine
  3350.     ; to draw something else instead of the 1-pixel dot.
  3351.     move.l #PelletSprite,d0
  3352.     move.l d0,CurrentBulletSprite
  3353.     pokecopper d0,a0
  3354.     move #PELLET_H,BulletHeight
  3355.     move #1,CurrentNumBulletsMax
  3356.     popa
  3357.     rts
  3358.  
  3359.  
  3360. BulletList:
  3361.     dcb.b bullet_t*NUM_BULLETS_MAX,0
  3362.     EVEN
  3363.  
  3364. ;;
  3365. ;; Grenade!
  3366. ;;
  3367. LoadGrenadeSprite:
  3368.     ; Args:
  3369.     ;   a0 - Copper list where to load to
  3370.     pusha
  3371.     move.l #GrenadeSprite,d0
  3372.     pokecopper d0,a0
  3373.     add.l #GRENADE_ATTACH,d0
  3374.     addq.l #8,a0
  3375.     pokecopper d0,a0
  3376.     popa
  3377.     rts
  3378.  
  3379. ;;
  3380. ;; SFX
  3381. ;;
  3382.  
  3383. APlayGrenadeUnpin:
  3384.     ; Args:
  3385.     ;   d1 - channel (0 - 3)
  3386.     ;   d2 - Volume (0 - 64)
  3387.     pusha
  3388.     lea AGrenadeUnpin,a0
  3389.     move #(AGrenadeUnpin_e-AGrenadeUnpin)/2,d0
  3390.     bsr APlay11Khz
  3391.     popa
  3392.     rts
  3393.  
  3394. APlayGrenadeBounce:
  3395.     ; Args:
  3396.     ;   d1 - channel (0 - 3)
  3397.     ;   d2 - Volume (0 - 64)
  3398.     pusha
  3399.     lea AGrenadeBounce,a0
  3400.     move #(AGrenadeBounce_e-AGrenadeBounce)/2,d0
  3401.     bsr APlay11Khz
  3402.     popa
  3403.     rts
  3404.  
  3405. APlayGrenadeExplode:
  3406.     ; Args:
  3407.     ;   d1 - channel (0 - 3)
  3408.     ;   d2 - Volume (0 - 64)
  3409.     pusha
  3410.     lea AGrenadeExplode,a0
  3411.     move #(AGrenadeExplode_e-AGrenadeExplode)/2,d0
  3412.     bsr APlay11Khz
  3413.     popa
  3414.     rts
  3415.  
  3416.  
  3417. APlayGrassWalkManyBoth:
  3418.     ; Args:
  3419.     ;   d2 - Volume (0 - 64)
  3420.     pusha
  3421.  
  3422.     bsr NextGrassWalk
  3423.     move.l d0,a0        ; audio_t argument
  3424.  
  3425.     ; Iterate channel
  3426.     move .channel(pc),d1
  3427.     and #%11,d1
  3428.  
  3429.     bsr APlayAudioT8Khz
  3430.     popa
  3431.     rts
  3432. .many_channel:
  3433.     dc.w 0
  3434. .channel:
  3435.     dc.w 0
  3436.  
  3437.  
  3438. APlayFloorWalkOneBoth:
  3439.     ; Args:
  3440.     ;   d2 - Volume (0 - 64)
  3441.     pusha
  3442.  
  3443.     bsr NextFloorWalk
  3444.     move.l d0,a0        ; audio_t argument
  3445.  
  3446.     moveq #0,d1
  3447.     bsr APlayAudioT8Khz
  3448.     moveq #1,d1
  3449.     bsr APlayAudioT8Khz
  3450.  
  3451.     popa
  3452.     rts
  3453.  
  3454.  
  3455. APlayGrassWalkOneBoth:
  3456.     ; Args:
  3457.     ;   d2 - Volume (0 - 64)
  3458.     pusha
  3459.  
  3460.     bsr NextGrassWalk
  3461.     move.l d0,a0        ; audio_t argument
  3462.  
  3463.     moveq #0,d1
  3464.     bsr APlayAudioT8Khz
  3465.     moveq #1,d1
  3466.     bsr APlayAudioT8Khz
  3467.  
  3468.     moveq #2,d1
  3469.     bsr APlayNull
  3470.     moveq #3,d1
  3471.     bsr APlayNull
  3472.  
  3473.     popa
  3474.     rts
  3475.  
  3476.  
  3477. APlayGrassWalkManyRight:
  3478.     ; Args:
  3479.     ;   d2 - Volume (0 - 64)
  3480.     pusha
  3481.  
  3482.     bsr NextGrassWalk
  3483.     move.l d0,a0        ; audio_t argument
  3484.  
  3485.     ; Pick channel
  3486.     moveq #1,d1     ; channel A
  3487.  
  3488.     move .many_channel(pc),d0
  3489.     addq #1,d0
  3490.     move d0,.many_channel
  3491.  
  3492.     btst #0,d0
  3493.     beq .play_it
  3494.     moveq #2,d1     ; channel B
  3495.  
  3496. .play_it:
  3497.     bsr APlayAudioT8Khz
  3498.     popa
  3499.     rts
  3500. .many_channel:
  3501.     dc.w 0
  3502.  
  3503.  
  3504. APlayGrassWalkOneRight:
  3505.     ; Args:
  3506.     ;   d2 - Volume (0 - 64)
  3507.     pusha
  3508.  
  3509.     bsr NextGrassWalk
  3510.     move.l d0,a0        ; audio_t argument
  3511.  
  3512.     moveq #1,d1
  3513.     bsr APlayAudioT8Khz
  3514.  
  3515.     moveq #2,d1
  3516.     bsr APlayNull
  3517.  
  3518.     popa
  3519.     rts
  3520.  
  3521.  
  3522. APlayGrassWalkManyLeft:
  3523.     ; Args:
  3524.     ;   d2 - Volume (0 - 64)
  3525.     pusha
  3526.  
  3527.     bsr NextGrassWalk
  3528.     move.l d0,a0        ; audio_t argument
  3529.  
  3530.     ; Pick channel
  3531.     moveq #0,d1     ; channel A
  3532.  
  3533.     move .many_channel(pc),d0
  3534.     addq #1,d0
  3535.     move d0,.many_channel
  3536.  
  3537.     btst #0,d0
  3538.     beq .play_it
  3539.     moveq #3,d1     ; channel B
  3540.  
  3541. .play_it:
  3542.     bsr APlayAudioT8Khz
  3543.     popa
  3544.     rts
  3545. .many_channel:
  3546.     dc.w 0
  3547.  
  3548.  
  3549. NextAudio:
  3550.     ; Args:
  3551.     ;   d0 - total count of elements on list
  3552.     ;   a0 - audio_t; list address
  3553.     ;   a1 - word; index address
  3554.     ; Result:
  3555.     ;   d0 - address to the current structure on the list,
  3556.     ;   a1 - counter is incremented
  3557.     pushnr
  3558.  
  3559.     ; Load the current sound and iterate the offset to the next one
  3560.     ; until we run out of sounds.
  3561.     move (a1),d7
  3562.     move d7,d6
  3563.     ext d6
  3564.     mulu #audio_t,d6
  3565.  
  3566.     add.l d6,a0
  3567.  
  3568.     addq #1,d7
  3569.     cmp d0,d7
  3570.     blt .loaded
  3571.     clr d7
  3572. .loaded:
  3573.     move d7,(a1)
  3574.     move.l a0,d0
  3575.  
  3576.     popnr
  3577.     rts
  3578.  
  3579.  
  3580. NextGrassWalk:
  3581.     ; Result:
  3582.     ;   d0 - pointer to the audio_t structure
  3583.     pushnr
  3584.     move #NUM_GRASS_WALK,d0
  3585.     lea GrassWalkList(pc),a0
  3586.     lea GrassWalkIndex(pc),a1
  3587.     bsr NextAudio
  3588.     popnr
  3589.     rts
  3590.  
  3591.  
  3592. InitGrassWalkList:
  3593.     pusha
  3594.     lea GrassWalkList(pc),a0
  3595.     lea AGrassWalk1,a1
  3596.     move.l a1,audio_t.pointer(a0)
  3597.     move.l #(AGrassWalk1_e-AGrassWalk1)/2,audio_t.length(a0)
  3598.     add.l #audio_t,a0
  3599.  
  3600.     lea AGrassWalk2,a1
  3601.     move.l a1,audio_t.pointer(a0)
  3602.     move.l #(AGrassWalk2_e-AGrassWalk2)/2,audio_t.length(a0)
  3603.     add.l #audio_t,a0
  3604.  
  3605.     lea AGrassWalk3,a1
  3606.     move.l a1,audio_t.pointer(a0)
  3607.     move.l #(AGrassWalk3_e-AGrassWalk3)/2,audio_t.length(a0)
  3608.     add.l #audio_t,a0
  3609.  
  3610.     lea AGrassWalk4,a1
  3611.     move.l a1,audio_t.pointer(a0)
  3612.     move.l #(AGrassWalk4_e-AGrassWalk4)/2,audio_t.length(a0)
  3613.     add.l #audio_t,a0
  3614.  
  3615.     lea AGrassWalk2,a1
  3616.     move.l a1,audio_t.pointer(a0)
  3617.     move.l #(AGrassWalk2_e-AGrassWalk2)/2,audio_t.length(a0)
  3618.     add.l #audio_t,a0
  3619.  
  3620.     lea AGrassWalk3,a1
  3621.     move.l a1,audio_t.pointer(a0)
  3622.     move.l #(AGrassWalk3_e-AGrassWalk3)/2,audio_t.length(a0)
  3623.     add.l #audio_t,a0
  3624.  
  3625.     popa
  3626.     rts
  3627.  
  3628.  
  3629. GrassWalkList:
  3630.     dcb.b audio_t*NUM_GRASS_WALK,0
  3631. GrassWalkIndex:
  3632.     dc.w 0
  3633.  
  3634.  
  3635. NextFloorWalk:
  3636.     ; Result:
  3637.     ;   d0 - pointer to the audio_t structure
  3638.     pushnr
  3639.     move #NUM_FLOOR_WALK,d0
  3640.     lea FloorWalkList(pc),a0
  3641.     lea FloorWalkIndex(pc),a1
  3642.     bsr NextAudio
  3643.     popnr
  3644.     rts
  3645.  
  3646.  
  3647. InitFloorWalkList:
  3648.     pusha
  3649.     lea FloorWalkList(pc),a0
  3650.     lea AFloorWalk1,a1
  3651.     move.l a1,audio_t.pointer(a0)
  3652.     move.l #(AFloorWalk1_e-AFloorWalk1)/2,audio_t.length(a0)
  3653.     add.l #audio_t,a0
  3654.  
  3655.     lea AFloorWalk2,a1
  3656.     move.l a1,audio_t.pointer(a0)
  3657.     move.l #(AFloorWalk2_e-AFloorWalk2)/2,audio_t.length(a0)
  3658.     add.l #audio_t,a0
  3659.  
  3660.     lea AFloorWalk3,a1
  3661.     move.l a1,audio_t.pointer(a0)
  3662.     move.l #(AFloorWalk3_e-AFloorWalk3)/2,audio_t.length(a0)
  3663.     add.l #audio_t,a0
  3664.  
  3665.     lea AFloorWalk4,a1
  3666.     move.l a1,audio_t.pointer(a0)
  3667.     move.l #(AFloorWalk4_e-AFloorWalk4)/2,audio_t.length(a0)
  3668.     add.l #audio_t,a0
  3669.  
  3670.     lea AFloorWalk2,a1
  3671.     move.l a1,audio_t.pointer(a0)
  3672.     move.l #(AFloorWalk2_e-AFloorWalk2)/2,audio_t.length(a0)
  3673.     add.l #audio_t,a0
  3674.  
  3675.     lea AFloorWalk3,a1
  3676.     move.l a1,audio_t.pointer(a0)
  3677.     move.l #(AFloorWalk3_e-AFloorWalk3)/2,audio_t.length(a0)
  3678.     add.l #audio_t,a0
  3679.  
  3680.     popa
  3681.     rts
  3682.  
  3683.  
  3684. FloorWalkList:
  3685.     dcb.b audio_t*NUM_FLOOR_WALK,0
  3686. FloorWalkIndex:
  3687.     dc.w 0
  3688.  
  3689. ;;
  3690. ;; Routines
  3691. ;;
  3692. InitCopperT:
  3693.     ; Args:
  3694.     ;   a0 - copper_t structure to init
  3695.     pusha
  3696.     move.b #5,copper_t.bitplanes(a0)
  3697.     move.b #INTERLACED,copper_t.interlaced(a0)
  3698.     move #SCREEN_BYWIDTH-SCREEN_BYPL,copper_t.bpl1mod(a0)
  3699.     move #SCREEN_BYWIDTH-SCREEN_BYPL,copper_t.bpl2mod(a0)
  3700.     move #$2c81,copper_t.diwstrt(a0)
  3701.     move #$2cc1,copper_t.diwstop(a0)
  3702.     move #$38,copper_t.ddfstrt(a0)
  3703.     move #$d0,copper_t.ddfstop(a0)
  3704.     move #$0707,copper_t.wait(a0)
  3705.     popa
  3706.     rts
  3707.  
  3708.  
  3709. LoadFullScreenCopper:
  3710.     pusha
  3711.     sub #copper_t,sp
  3712.     move.l sp,a0
  3713.     bsr InitCopperT
  3714.     bsr LoadCopper
  3715.     add #copper_t,sp
  3716.     popa
  3717.     rts
  3718.  
  3719. LoadCopper:
  3720.     ; Loads the 'Copper' copper list with the specifications
  3721.     ; provided by the copper_t structure.
  3722.     ;
  3723.     ; Args:
  3724.     ;   a0 - pointer to a copper_t structure
  3725.     pusha
  3726.  
  3727.     move #$0200,d1
  3728.     move.b copper_t.interlaced(a0),d0
  3729.     tst.b d0
  3730.     beq .progressive
  3731.     or #$4,d1
  3732. .progressive:
  3733.     move d1,CopperBplcon0+2
  3734.     move d1,CopperScreenControl+2
  3735.  
  3736.     move.b copper_t.bitplanes(a0),d0
  3737.     lsl #8,d0
  3738.     lsl #4,d0
  3739.     or d0,CopperScreenControl+2
  3740.  
  3741.     move copper_t.bpl1mod(a0),CopperScreenControl+2*4+2
  3742.     move copper_t.bpl2mod(a0),CopperScreenControl+3*4+2
  3743.  
  3744.     move copper_t.diwstrt(a0),CopperWindowControl+2
  3745.     move copper_t.diwstop(a0),CopperWindowControl+1*4+2
  3746.     move copper_t.ddfstrt(a0),CopperWindowControl+2*4+2
  3747.     move copper_t.ddfstop(a0),CopperWindowControl+3*4+2
  3748.  
  3749.     move copper_t.wait(a0),CopperWait
  3750.  
  3751.     popa
  3752.     rts
  3753.  
  3754.  
  3755. LoadScreenToCopper:
  3756.     ; Load screen bitplane to the copper list
  3757.     pusha
  3758.     move.l #Screen,d0
  3759.     lea CopperScreen,a0
  3760.     move.l #SCREEN_D-1,d1
  3761. .screen_load:
  3762.     pokecopper d0,a0
  3763.     add.l #SCREEN_BYPL,d0
  3764.     addq.l #8,a0
  3765.     dbf d1,.screen_load
  3766.     popa
  3767.     rts
  3768.  
  3769. LoadColorsToCopper:
  3770.     ; Args:
  3771.     ;   a0 - a 32-color table
  3772.     pusha
  3773.     lea CopperColor,a1
  3774.     move #32,d0
  3775.     bsr PokeCopperWords
  3776.     popa
  3777.     rts
  3778.  
  3779. ClearScreen:
  3780.     pusha
  3781.     lea Screen,a0
  3782.     move #(Screen_e-Screen)/4,d0
  3783. .loop:
  3784.     clr.l (a0)+
  3785.     dbf d0,.loop
  3786.     popa
  3787.     rts
  3788.  
  3789.  
  3790.  
  3791. DimScreen:
  3792.     ; Args:
  3793.     ;   a0 - Color table address
  3794.     ;   a1 - Copperlist color list address
  3795.     ;   d0 - Colors count
  3796.     pusha
  3797.     move.l a1,a2
  3798.     lea BlackColors(pc),a1
  3799.     move #$0111,d2
  3800.     bsr ColorTableFadeTo
  3801.     move.l a2,a1
  3802.     bsr PokeCopperWords
  3803.     popa
  3804.     rts
  3805.  
  3806.  
  3807. ColorTableFadeTo:
  3808.     ; Increases or decreases each color to match its counterpart in the
  3809.     ; other table.
  3810.     ; Args:
  3811.     ;   a0 - fade table; contents will be modified
  3812.     ;   a1 - fade-to table; read-only
  3813.     ;   d0 - number of colors
  3814.     ;   d2 - absolute step (one nibble for each RGB)
  3815.     pusha
  3816.     subq #1,d0
  3817.     move d0,d7
  3818. .loop:
  3819.     move (a0),d0
  3820.     move (a1)+,d1
  3821.  
  3822.     ; d2 has the correct value already
  3823.     bsr ColorFadeTo
  3824.     move d0,(a0)+
  3825.  
  3826.     dbf d7,.loop
  3827.     popa
  3828.     rts
  3829.  
  3830.  
  3831. ColorFadeTo:
  3832.     ; Increases or decreases source RGB components to match the target RGB.
  3833.     ; Args:
  3834.     ;   d0 - RGB color to change
  3835.     ;   d1 - target RGB
  3836.     ;   d2 - absolute step (one nibble for each RGB)
  3837.     ; Result:
  3838.     ;   d0 - stepped RGB
  3839.     pushnr
  3840.  
  3841.     move d0,d3
  3842.     move d1,d4
  3843.     move d2,d5
  3844.  
  3845.     ; B
  3846.     and #$f,d0
  3847.     and #$f,d1
  3848.     and #$f,d2
  3849.     bsr NumberFadeTo
  3850.     and #$ff0,d3
  3851.     or d0,d3
  3852.  
  3853.     ; G
  3854.     move d3,d0
  3855.     lsr #4,d0
  3856.     and #$f,d0
  3857.     move d4,d1
  3858.     lsr #4,d1
  3859.     and #$f,d1
  3860.     move d5,d2
  3861.     lsr #4,d2
  3862.     and #$f,d2
  3863.     bsr NumberFadeTo
  3864.     lsl #4,d0
  3865.     and #$f0f,d3
  3866.     or d0,d3
  3867.  
  3868.     ; R
  3869.     move d3,d0
  3870.     lsr #8,d0
  3871.     and #$f,d0
  3872.     move d4,d1
  3873.     lsr #8,d1
  3874.     and #$f,d1
  3875.     move d5,d2
  3876.     lsr #8,d2
  3877.     and #$f,d2
  3878.     bsr NumberFadeTo
  3879.     lsl #8,d0
  3880.     and #$0ff,d3
  3881.     or d0,d3
  3882.  
  3883.     move d3,d0
  3884.     popnr
  3885.     rts
  3886.  
  3887.  
  3888. NumberFadeTo:
  3889.     ; Fades source number to target by given step.
  3890.     ; Operates on words; figures out if step should be positive or negative.
  3891.     ;
  3892.     ; Args:
  3893.     ;   d0 - source number
  3894.     ;   d1 - target number
  3895.     ;   d2 - absolute fade step
  3896.     ; Result:
  3897.     ;   d0 - number faded by step or equal to the target
  3898.     ;
  3899.     ; if abs(target-source) >= step
  3900.     ;   return target
  3901.     ; else
  3902.     ;   if target > source
  3903.     ;       return source + step
  3904.     ;   else
  3905.     ;       return source - step
  3906.     pushnr
  3907.  
  3908.     ; Get absolute delta (d3)
  3909.     move d1,d3
  3910.     sub d0,d3
  3911.     bpl .already_positive
  3912.     neg d3
  3913. .already_positive:
  3914.     ; If delta <= step, return the target
  3915.     cmp d2,d3
  3916.     bgt .do_step
  3917.  
  3918.     move d1,d0
  3919.     bra .done
  3920. .do_step:
  3921.     cmp d0,d1
  3922.     bgt .add
  3923.     sub d2,d0
  3924.     bra .done
  3925. .add:
  3926.     add d2,d0
  3927. .done:
  3928.     popnr
  3929.     rts
  3930.  
  3931.  
  3932. MoveSpriteAttached:
  3933.     ; Args - same as in MoveSprite
  3934.     pusha
  3935.  
  3936.     bsr MoveSprite
  3937.     move d1,d2
  3938.     ext.l d2
  3939.     asl #2,d2 ; multiply by 4 bytes per each line
  3940.     add.l d2,a0
  3941.     add.l #8,a0
  3942.     bsr MoveSprite
  3943.  
  3944.     popa
  3945.     rts
  3946.  
  3947.  
  3948. MoveSprite:
  3949.     ; Moves sprite to a given (x,y) coordinate.
  3950.     ;
  3951.     ; Args:
  3952.     ;   d0
  3953.     ;     - hi-word: x
  3954.     ;     - lo-word: y
  3955.     ;   d1
  3956.     ;     - lo-word: sprite height
  3957.     ;   a0 - sprite address
  3958.     pusha
  3959.  
  3960.     ; y
  3961.     move.b d0,(a0)
  3962.     bclr #2,3(a0)
  3963.     cmp #$ff,d0
  3964.     ble .under_y1_256
  3965.     bset #2,3(a0)
  3966.  
  3967. .under_y1_256:
  3968.     ; h
  3969.     add d0,d1
  3970.     move.b d1,2(a0)
  3971.     bclr #1,3(a0)
  3972.     cmp #$ff,d1
  3973.     ble .under_y2_256
  3974.     bset #1,3(a0)
  3975.  
  3976. .under_y2_256:
  3977.     ; x
  3978.     swap d0
  3979.     bclr #0,3(a0)
  3980.     btst #0,d0
  3981.     beq .even_x
  3982.     bset #0,3(a0)
  3983. .even_x:
  3984.     lsr #1,d0
  3985.     move.b d0,1(a0)
  3986.  
  3987.     popa
  3988.     rts
  3989.  
  3990.  
  3991. BlitMasked:
  3992.     ; Args:
  3993.     ;   a0 - pic to blit
  3994.     ;   a1 - blit mask
  3995.     ;   a2 - blit destination
  3996.     ;   d2 - word; blit depth
  3997.     ;   d3 - word; blit src width
  3998.     ;   d4 - word; blit height
  3999.     ;   d5 - word; blit dst width
  4000.     pusha
  4001.     bsr BlitWait
  4002.  
  4003.     move.l #$0fe20000,BLTCON0(a6)
  4004.     move.l #$ffffffff,BLTAFWM(a6)
  4005.     move.l a0,BLTAPTH(a6)
  4006.     move.l a1,BLTBPTH(a6)
  4007.     move.l a2,BLTCPTH(a6)
  4008.     move.l a2,BLTDPTH(a6)
  4009.     move #0,BLTAMOD(a6)
  4010.     move #0,BLTBMOD(a6)
  4011.  
  4012.     ; destination modulo
  4013.     move d5,d7
  4014.     sub d3,d7
  4015.     lsr #3,d7
  4016.     move d7,BLTCMOD(a6)
  4017.     move d7,BLTDMOD(a6)
  4018.  
  4019.     ; size
  4020.     ext.l d4
  4021.     mulu d2,d4      ; depth
  4022.     lsl #6,d4       ; shift height
  4023.     lsr #4,d3       ; add width in words
  4024.     and #$ffc0,d4
  4025.     or d3,d4
  4026.     move d4,BLTSIZE(a6)
  4027.  
  4028.     popa
  4029.     rts
  4030.  
  4031. BlitMaskedXY:
  4032.     ; Args:
  4033.     ;   a0 - pic to blit
  4034.     ;   a1 - blit mask
  4035.     ;   a2 - blit destination
  4036.     ;   d0 - word; blit x  \ added to
  4037.     ;   d1 - word; blit y  / destination
  4038.     ;   d2 - word; blit depth
  4039.     ;   d3 - word; blit src width
  4040.     ;   d4 - word; blit height
  4041.     ;   d5 - word; blit dst width
  4042.     pusha
  4043.     bsr BlitWait
  4044.  
  4045.     ; Designate the blit shift
  4046.     move d0,d7
  4047.     and.l #$f,d7
  4048.     ext.l d7
  4049.     lsl.l #8,d7
  4050.     lsl.l #4,d7
  4051.     move.l d7,d6
  4052.     swap d6
  4053.     or.l d6,d7
  4054.     or.l #$0fe20000,d7
  4055.  
  4056.     move.l d7,BLTCON0(a6)
  4057.     move.l #$ffffffff,BLTAFWM(a6)
  4058.  
  4059.     ; Designate the x word offset
  4060.     lsr #4,d0
  4061.     lsl #1,d0
  4062.     add d0,a2
  4063.  
  4064.     ; Designate the y offset
  4065.     and.l #$0000ffff,d1
  4066.     move d5,d7
  4067.     lsr #3,d7
  4068.     mulu d7,d1
  4069.     mulu d2,d1
  4070.     add.l d1,a2
  4071.  
  4072.     move.l a0,BLTAPTH(a6)
  4073.     move.l a1,BLTBPTH(a6)
  4074.     move.l a2,BLTCPTH(a6)
  4075.     move.l a2,BLTDPTH(a6)
  4076.     move #0,BLTAMOD(a6)
  4077.     move #0,BLTBMOD(a6)
  4078.  
  4079.     ; destination modulo
  4080.     move d5,d7
  4081.     sub d3,d7
  4082.     lsr #3,d7
  4083.     move d7,BLTCMOD(a6)
  4084.     move d7,BLTDMOD(a6)
  4085.  
  4086.     ; size
  4087.     ext.l d4
  4088.     mulu d2,d4      ; depth
  4089.     lsl #6,d4       ; shift height
  4090.     lsr #4,d3       ; add width in words
  4091.     and #$ffc0,d4
  4092.     or d3,d4
  4093.     move d4,BLTSIZE(a6)
  4094.  
  4095.     popa
  4096.     rts
  4097.  
  4098.  
  4099. BlitBackground:
  4100.     ; Blits selected area of screen background back to its place.
  4101.     ; The blit x must be on the word boundary or else the blit will suck.
  4102.     ;
  4103.     ; Args:
  4104.     ;   a0 - background
  4105.     ;   a2 - blit destination
  4106.     ;   d0 - word; x \ added to background
  4107.     ;   d1 - word; y / and destination
  4108.     ;   d2 - word; blit depth
  4109.     ;   d3 - word; blit width
  4110.     ;   d4 - word; blit height
  4111.     ;   d5 - word; total width
  4112.     pusha
  4113.     bsr BlitWait
  4114.  
  4115.     move.l #$09f00000,BLTCON0(a6)
  4116.     move.l #$ffffffff,BLTAFWM(a6)
  4117.  
  4118.     ; Designate the x word offset
  4119.     lsr #4,d0
  4120.     lsl #1,d0
  4121.     add d0,a0
  4122.     add d0,a2
  4123.  
  4124.     ; Designate the y offset
  4125.     and.l #$0000ffff,d1
  4126.     move d5,d7
  4127.     lsr #3,d7
  4128.     mulu d7,d1
  4129.     mulu d2,d1
  4130.     add.l d1,a0
  4131.     add.l d1,a2
  4132.  
  4133.     move.l a0,BLTAPTH(a6)
  4134.     move.l a2,BLTDPTH(a6)
  4135.  
  4136.     ; modulo
  4137.     move d5,d7
  4138.     sub d3,d7
  4139.     lsr #3,d7
  4140.     move d7,BLTAMOD(a6)
  4141.     move d7,BLTDMOD(a6)
  4142.  
  4143.     ; size
  4144.     ext.l d4
  4145.     mulu d2,d4      ; depth
  4146.     lsl #6,d4       ; shift height
  4147.     lsr #4,d3       ; add width in words
  4148.     and #$ffc0,d4
  4149.     or d3,d4
  4150.     move d4,BLTSIZE(a6)
  4151.  
  4152.     popa
  4153.     rts
  4154.  
  4155.  
  4156. BlitXY:
  4157.     ; Good for blitting rectangles.
  4158.     ;
  4159.     ; Args:
  4160.     ;   a0 - pic to blit
  4161.     ;   a2 - blit destination
  4162.     ;   d0 - word; blit x  \ added to
  4163.     ;   d1 - word; blit y  / destination
  4164.     ;   d2 - word; blit depth
  4165.     ;   d3 - word; blit src width
  4166.     ;   d4 - word; blit height
  4167.     ;   d5 - word; blit dst width
  4168.     pusha
  4169.     bsr BlitWait
  4170.  
  4171.     ; Designate the blit shift
  4172.     move d0,d7
  4173.     and.l #$f,d7
  4174.     ext.l d7
  4175.     lsl.l #8,d7
  4176.     lsl.l #4,d7
  4177.     move.l d7,d6
  4178.     swap d6
  4179.     or.l d6,d7
  4180.     or.l #$09f00000,d7
  4181.  
  4182.     move.l d7,BLTCON0(a6)
  4183.     move.l #$ffffffff,BLTAFWM(a6)
  4184.  
  4185.     ; Designate the x word offset
  4186.     lsr #4,d0
  4187.     lsl #1,d0
  4188.     add d0,a2
  4189.  
  4190.     ; Designate the y offset
  4191.     and.l #$0000ffff,d1
  4192.     move d5,d7
  4193.     lsr #3,d7
  4194.     mulu d7,d1
  4195.     mulu d2,d1
  4196.     add.l d1,a2
  4197.  
  4198.     move.l a0,BLTAPTH(a6)
  4199.     move.l a2,BLTDPTH(a6)
  4200.  
  4201.     ; destination modulo
  4202.     move d5,d7
  4203.     sub d3,d7
  4204.     lsr #3,d7
  4205.     move d7,BLTDMOD(a6)
  4206.  
  4207.     ; size
  4208.     ext.l d4
  4209.     mulu d2,d4      ; depth
  4210.     lsl #6,d4       ; shift height
  4211.     lsr #4,d3       ; add width in words
  4212.     and #$ffc0,d4
  4213.     or d3,d4
  4214.     move d4,BLTSIZE(a6)
  4215.  
  4216.     popa
  4217.     rts
  4218.  
  4219.  
  4220.  
  4221. BlitWait:
  4222.     tst DMACONR(a6)
  4223. .blitwait:
  4224.     btst #6,DMACONR(a6)
  4225.     bne.s .blitwait
  4226.     rts
  4227.  
  4228.  
  4229. BresenhamStepLine:
  4230.     ; Gets next point on a straight line from source (X,Y) to
  4231.     ; destination (X,Y) by using only ints to do so.
  4232.     ;
  4233.     ; All args are long
  4234.     ; Args:
  4235.     ;   d0 - x0
  4236.     ;   d1 - y0
  4237.     ;   d2 - x1
  4238.     ;   d3 - y1
  4239.     ;   d4 - x current
  4240.     ;   d5 - y current
  4241.     ; Result:
  4242.     ;   d0 - next x
  4243.     ;   d1 - next y
  4244.     movem.l d2-a6,-(sp)
  4245.  
  4246.     ; dx, dy = x1 - x0, y1 - y0
  4247.     move.l d2,d7
  4248.     sub.l d0,d7
  4249.     move.l d7,.dx
  4250.  
  4251.     move.l d3,d7
  4252.     sub.l d1,d7
  4253.     move.l d7,.dy
  4254.  
  4255.     ; dx >= 0 ? incx = +1 : incx = -1
  4256.     ; dy >= 0 ? incy = +1 : incy = -1
  4257.     move.l #1,.incx
  4258.     move.l .dx(pc),d7
  4259.     tst.l d7
  4260.     bge .pos_x
  4261.     move.l #-1,.incx
  4262. .pos_x:
  4263.     move.l #1,.incy
  4264.     move.l .dy(pc),d7
  4265.     tst.l d7
  4266.     bge .pos_y
  4267.     move.l #-1,.incy
  4268. .pos_y:
  4269.  
  4270.     ; abs dx,dy
  4271.     move.l .dx(pc),d7
  4272.     bpl .no_abs_dx
  4273.     neg.l d7
  4274.     move.l d7,.dx
  4275. .no_abs_dx:
  4276.     move.l .dy(pc),d7
  4277.     bpl .no_abs_dy
  4278.     neg.l d7
  4279.     move.l d7,.dy
  4280. .no_abs_dy:
  4281.  
  4282.     ; x = 0, y = 0
  4283.     ; the dst values won't be needed anymore
  4284.     clr.l d2
  4285.     clr.l d3
  4286.     move #0,.bail
  4287.  
  4288.     ; the big if/else choice
  4289.     ; dx >= dy
  4290.     move.l .dx(pc),d6
  4291.     move.l .dy(pc),d7
  4292.     cmp d7,d6
  4293.     blt .dx_lesser_than_dy
  4294.  
  4295.     ; it is: dx >= dy
  4296.     ; d = 2*dy-dx
  4297.     ; delta_a = 2*dy
  4298.     ; delta_b = 2*dy-2*dx
  4299.     move.l .dy(pc),d7
  4300.     lsl.l #1,d7
  4301.     move.l d7,.delta_a
  4302.     sub.l .dx(pc),d7
  4303.     move.l d7,.d
  4304.     sub.l .dx(pc),d7
  4305.     move.l d7,.delta_b
  4306.  
  4307.     ; for (i=dx, i>=0, --i)
  4308.     move.l .dx(pc),d6
  4309. .for1:
  4310.     ; if (x == cur_x && y == cur_y)
  4311.     ;   bail in this iteration
  4312.     move.l d0,d7
  4313.     add.l d2,d7
  4314.     cmp.l d4,d7
  4315.     bne .no_bail1
  4316.     move.l d1,d7
  4317.     add.l d3,d7
  4318.     cmp.l d5,d7
  4319.     bne .no_bail1
  4320.     move #1,.bail
  4321. .no_bail1:
  4322.     move.l .d(pc),d7
  4323.     ; if (d > 0)
  4324.     tst.l d7
  4325.     ble .else1
  4326.     ; d += delta_b
  4327.     ; x += incx
  4328.     ; y += incy
  4329.     add.l .delta_b(pc),d7
  4330.     move.l d7,.d
  4331.     add.l .incx(pc),d2
  4332.     add.l .incy(pc),d3
  4333.     bra .continue1
  4334. .else1:
  4335.     ; d += delta_a
  4336.     ; x += incx
  4337.     add.l .delta_a(pc),d7
  4338.     move.l d7,.d
  4339.     add.l .incx(pc),d2
  4340. .continue1:
  4341.     move .bail(pc),d7
  4342.     tst d7
  4343.     bne .done
  4344.     dbf d6,.for1
  4345.     bra .done
  4346. .dx_lesser_than_dy:
  4347.     ; it is: dy < dx
  4348.     ; d = 2*dx-dy
  4349.     ; delta_a = 2*dx
  4350.     ; delta_b = 2*dx-2*dy
  4351.     move.l .dx(pc),d7
  4352.     lsl.l #1,d7
  4353.     move.l d7,.delta_a
  4354.     sub.l .dy(pc),d7
  4355.     move.l d7,.d
  4356.     sub.l .dy(pc),d7
  4357.     move.l d7,.delta_b
  4358.  
  4359.     ; for (i=dy, i>=0, --i)
  4360.     move.l .dy(pc),d6
  4361. .for2:
  4362.     ; if (x == cur_x && y == cur_y)
  4363.     ;   bail in this iteration
  4364.     move.l d0,d7
  4365.     add.l d2,d7
  4366.     cmp.l d4,d7
  4367.     bne .no_bail2
  4368.     move.l d1,d7
  4369.     add.l d3,d7
  4370.     cmp.l d5,d7
  4371.     bne .no_bail2
  4372.     move #1,.bail
  4373. .no_bail2:
  4374.     move.l .d(pc),d7
  4375.     ; if (d > 0)
  4376.     tst.l d7
  4377.     ble .else2
  4378.     ; d += delta_b
  4379.     ; x += incx
  4380.     ; y += incy
  4381.     add.l .delta_b(pc),d7
  4382.     move.l d7,.d
  4383.     add.l .incx(pc),d2
  4384.     add.l .incy(pc),d3
  4385.     bra .continue2
  4386. .else2:
  4387.     ; d += delta_a
  4388.     ; y += incy
  4389.     add.l .delta_a(pc),d7
  4390.     move.l d7,.d
  4391.     add.l .incy(pc),d3
  4392. .continue2:
  4393.     move .bail(pc),d7
  4394.     tst d7
  4395.     bne .done
  4396.     dbf d6,.for2
  4397.  
  4398. .done:
  4399.     add.l d2,d0
  4400.     add.l d3,d1
  4401.     movem.l (sp)+,d2-a6
  4402.     rts
  4403. .dx:
  4404.     dc.l 0
  4405. .dy:
  4406.     dc.l 0
  4407. .incx:
  4408.     dc.l 1
  4409. .incy:
  4410.     dc.l 1
  4411. .d:
  4412.     dc.l 0
  4413. .delta_a:
  4414.     dc.l 0
  4415. .delta_b:
  4416.     dc.l 0
  4417. .bail:
  4418.     dc.w 0
  4419.  
  4420.  
  4421. PokeCopperWords:
  4422.     ; Args:
  4423.     ;   a0 - the word value table in memory
  4424.     ;   a1 - copper register listing start
  4425.     ;   d0 - word; how many values to poke
  4426.     pusha
  4427.  
  4428.     subq #1,d0
  4429. .loop:
  4430.     add #2,a1   ; skip the register
  4431.     move (a0)+,(a1)+
  4432.     dbf d0,.loop
  4433.  
  4434.     popa
  4435.     rts
  4436.  
  4437.  
  4438. APlayAudioT8Khz:
  4439.     ; Args:
  4440.     ;   a0 - audio_t to play
  4441.     ;   d1 - Channel to play on (0 - 3)
  4442.     ;   d2 - Volume (0 - 64)
  4443.     pusha
  4444.     move.l audio_t.length(a0),d0
  4445.     move.l audio_t.pointer(a0),a0
  4446.     bsr APlay8Khz
  4447.     popa
  4448.     rts
  4449.  
  4450.  
  4451. APlayAudioT11Khz:
  4452.     ; Args:
  4453.     ;   a0 - audio_t to play
  4454.     ;   d1 - Channel to play on (0 - 3)
  4455.     ;   d2 - Volume (0 - 64)
  4456.     pusha
  4457.     move.l audio_t.length(a0),d0
  4458.     move.l audio_t.pointer(a0),a0
  4459.     bsr APlay11Khz
  4460.     popa
  4461.     rts
  4462.  
  4463.  
  4464. APlay8Khz:
  4465.     ; Args:
  4466.     ;   a0 - Audio to play
  4467.     ;   d0 - Length of the audio in words
  4468.     ;   d1 - Channel to play on (0 - 3)
  4469.     ;   d2 - Volume (0 - 64)
  4470.     pusha
  4471.  
  4472.     move.l #AUD0LCH,d7
  4473.     mulu #AUD_INTERCHANNEL_OFFSET,d1
  4474.     add.l d1,d7
  4475.  
  4476.     move.l a0,AUDXLCH(a6,d7)
  4477.     move d0,AUDXLEN(a6,d7)
  4478.     move #447,AUDXPER(a6,d7)
  4479.     move d2,AUDXVOL(a6,d7)
  4480.     popa
  4481.     rts
  4482.  
  4483.  
  4484. APlay11Khz:
  4485.     ; Args:
  4486.     ;   a0 - Audio to play
  4487.     ;   d0 - Length of the audio in words
  4488.     ;   d1 - Channel to play on (0 - 3)
  4489.     ;   d2 - Volume (0 - 64)
  4490.     pusha
  4491.  
  4492.     move.l #AUD0LCH,d7
  4493.     mulu #AUD_INTERCHANNEL_OFFSET,d1
  4494.     add.l d1,d7
  4495.  
  4496.     move.l a0,AUDXLCH(a6,d7)
  4497.     move d0,AUDXLEN(a6,d7)
  4498.     move #324,AUDXPER(a6,d7)
  4499.     move d2,AUDXVOL(a6,d7)
  4500.     popa
  4501.     rts
  4502.  
  4503.  
  4504. APlayNullAll:
  4505.     ; Play null audio sample (silence) on all channels.
  4506.     bsr APlayNullLeft
  4507.     bsr APlayNullRight
  4508.     rts
  4509.  
  4510. APlayNullLeft:
  4511.     ; Play null audio sample (silence) on left channels.
  4512.     pusha
  4513.     clr d1
  4514.     bsr APlayNull
  4515.     moveq #3,d1
  4516.     bsr APlayNull
  4517.     popa
  4518.     rts
  4519.  
  4520. APlayNullRight:
  4521.     ; Play null audio sample (silence) on right channels.
  4522.     pusha
  4523.     moveq #1,d1
  4524.     bsr APlayNull
  4525.     moveq #2,d1
  4526.     bsr APlayNull
  4527.     popa
  4528.     rts
  4529.  
  4530. APlayNull:
  4531.     ; Play null audio sample (silence).
  4532.     ; Args:
  4533.     ;   d1 - Channel to play on (0 - 3)
  4534.     pusha
  4535.     move.l #AUD0LCH,d7
  4536.     mulu #AUD_INTERCHANNEL_OFFSET,d1
  4537.     add.l d1,d7
  4538.  
  4539.     lea ANull,a0
  4540.     move #(ANull_e-ANull)/2,d0
  4541.     move.l a0,AUDXLCH(a6,d7)
  4542.     move d0,AUDXLEN(a6,d7)
  4543.  
  4544.     popa
  4545.     rts
  4546.  
  4547.  
  4548. MemCmp:
  4549.     ; Args:
  4550.     ;   a0 - mem area a
  4551.     ;   a1 - mem area b
  4552.     ;   d1 - long; area len
  4553.     ; Result:
  4554.     ;   d0 - equal to d1 if areas are the same, otherwise
  4555.     ;        equal to the length at which the areas differ
  4556.     pushnr
  4557.  
  4558.     clr.l d0
  4559.     subq #1,d1
  4560. .loop:
  4561.     move.b (a0)+,d2
  4562.     cmp.b (a1)+,d2
  4563.     bne .done
  4564.     addq.l #1,d0
  4565.     dbf d1,.loop
  4566. .done:
  4567.     popnr
  4568.     rts
  4569.  
  4570.  
  4571.     SECTION storage,DATA
  4572. P2Scene:
  4573.     incbin "grass.320x256x4.raw"
  4574. P2Scene_e:
  4575. P3Scene:
  4576.     incbin "part3.320x256x5.raw"
  4577. P3Scene_e:
  4578. P4Scene:
  4579.     incbin "part4.320x256x5.raw"
  4580. P4Scene_e:
  4581. P5Scene:
  4582.     incbin "part5.320x256x5.raw"
  4583. P5Scene_e:
  4584. MissionSuccess:
  4585.     incbin "mission_success.320x49x3.raw"
  4586. MissionSuccess_e:
  4587. BonusScreen:
  4588.     incbin "hostbomb.104x128x4.raw"
  4589. BonusScreen_e:
  4590. GuruScreen:
  4591.     incbin "gurumedi.293x51x1.raw"
  4592. GuruScreen_e:
  4593.  
  4594. ;;
  4595. ;; CHIP MEM
  4596. ;;
  4597.  
  4598.     SECTION chip,DATA_C
  4599. SectionChip:
  4600.  
  4601. Logo:
  4602.     incbin "regilogo.300x95x3.raw"
  4603. LogoE:
  4604.  
  4605. DoorOpen:
  4606.     incbin "dooropen.64x128x5.raw"
  4607. DoorOpen_e:
  4608. DoorClosed:
  4609.     incbin "doorclosed.64x128x5.raw"
  4610. DoorClosed_e:
  4611. DoorMask:
  4612.     incbin "door.mask.raw"
  4613. DoorMask_e:
  4614.  
  4615.  
  4616. P3Sas:
  4617.     incbin "p3_sas.32x44x5.raw"
  4618. P3Sas_e:
  4619. P3SasMask:
  4620.     incbin "p3_sas.mask.raw"
  4621. P3SasMask_e:
  4622. P3SasDead:
  4623.     incbin "p3_sas_dead.32x44x5.raw"
  4624. P3SasDead_e:
  4625. P3SasDeadMask:
  4626.     incbin "p3_sas_dead.mask.raw"
  4627. P3SasDeadMask_e:
  4628.  
  4629.  
  4630.  
  4631. P3PaskudnyDead:
  4632.     incbin "p3_paskudny_dead.48x44x5.raw"
  4633. P3PaskudnyDead_e:
  4634. P3PaskudnyDeadMask:
  4635.     incbin "p3_paskudny_dead.mask.raw"
  4636. P3PaskudnyDeadMask_e:
  4637. P3WiesniakDead:
  4638.     incbin "p3_wiesniak_dead.32x43x5.raw"
  4639. P3WiesniakDead_e:
  4640. P3WiesniakDeadMask:
  4641.     incbin "p3_wiesniak_dead.mask.raw"
  4642. P3WiesniakDeadMask_e:
  4643.  
  4644. P460s:
  4645.     incbin "p4_60s.32x48x5.raw"
  4646. P460s_e:
  4647. P460sMask:
  4648.     incbin "p4_60s.mask.raw"
  4649. P460sMask_e:
  4650.  
  4651. P4Bomb:
  4652.     incbin "p4_tnt.96x171x5.raw"
  4653. P4Bomb_e:
  4654. P4BombMask:
  4655.     incbin "p4_tnt.mask.raw"
  4656. P4BombMask_e:
  4657.  
  4658.     EVEN
  4659. P5SaddamDead:
  4660.     incbin "saddam_dead.32x52x5.raw"
  4661. P5SaddamDead_e:
  4662.     EVEN
  4663. P5SaddamMask:
  4664.     incbin "saddam_dead.mask.raw"
  4665. P5SaddamMask_e:
  4666.  
  4667.     EVEN
  4668. AIntro:
  4669.     incbin "intro_begin_11k.raw"
  4670. AIntro_e:
  4671.     EVEN
  4672. ABriefing:
  4673.     incbin "briefing_11k.raw"
  4674. ABriefing_e:
  4675.  
  4676.     EVEN
  4677. ASasBooby:  ; it's less fun than it sounds
  4678.     incbin "sas_booby_11k.raw"
  4679. ASasBooby_e:
  4680.     EVEN
  4681. ASasBluOnBlu:
  4682.     incbin "sas_blu_11k.raw"
  4683. ASasBluOnBlu_e:
  4684.     EVEN
  4685. ASasGoGoGo:
  4686.     incbin "gogogo_11k.raw"
  4687. ASasGoGoGo_e:
  4688.     EVEN
  4689. ASasEnemyContact:
  4690.     incbin "sas_contact_11k.raw"
  4691. ASasEnemyContact_e:
  4692.     EVEN
  4693. ASasManDown:
  4694.     incbin "sas_mandown_01_11k.raw"
  4695. ASasManDown_e:
  4696.     EVEN
  4697. ASasMedic:
  4698.     incbin "sas_medic_11k.raw"
  4699. ASasMedic_e:
  4700.     EVEN
  4701. ASasHurt:
  4702.     incbin "sas_hit_1_11k.raw"
  4703. ASasHurt_e:
  4704.  
  4705.     EVEN
  4706. AXrayDieUBastards:
  4707.     incbin "xray_die_u_bastards_11k.raw"
  4708. AXrayDieUBastards_e:
  4709.     EVEN
  4710. AXrayDontShoot:
  4711.     incbin "xray_dontshoot_11k.raw"
  4712. AXrayDontShoot_e:
  4713.     EVEN
  4714. AXrayTroopers:
  4715.     incbin "xray_troopers_11k.raw"
  4716. AXrayTroopers_e:
  4717.     EVEN
  4718. AXrayYouBloodyFools:
  4719.     incbin "xray_youbloodyfools_11k.raw"
  4720. AXrayYouBloodyFools_e:
  4721.     EVEN
  4722. AXrayAndItsYourFault:
  4723.     incbin "xray_anditsyourfault_11k.raw"
  4724. AXrayAndItsYourFault_e:
  4725.  
  4726.     EVEN
  4727. AHostThankYou:
  4728.     incbin "host_thankyou_11k.raw"
  4729. AHostThankYou_e:
  4730.  
  4731.  
  4732.     EVEN
  4733. ADie05:
  4734.     incbin "die_05_11k.raw"
  4735. ADie05_e:
  4736.     EVEN
  4737. ADie06:
  4738.     incbin "die_06_11k.raw"
  4739. ADie06_e:
  4740.     EVEN
  4741. ADie07:
  4742.     incbin "die_07_11k.raw"
  4743. ADie07_e:
  4744.  
  4745.     EVEN
  4746. AAk47_1:
  4747.     incbin "ak47_01_11k.raw"
  4748. AAk47_1_e:
  4749.     EVEN
  4750.  
  4751.     EVEN
  4752. AAk47Burst:
  4753.     incbin "ak47_burst.raw"
  4754. AAk47Burst_e:
  4755.  
  4756.     EVEN
  4757. AMp5_1:
  4758.     incbin "mp5_01_11k.raw"
  4759. AMp5_1_e:
  4760.     EVEN
  4761. AMp5_2:
  4762.     incbin "mp5_02_11k.raw"
  4763. AMp5_2_e:
  4764.     EVEN
  4765.  
  4766.     EVEN
  4767. AShotgun:
  4768.     incbin "shotgun_11k.raw"
  4769. AShotgun_e:
  4770.  
  4771.  
  4772.     EVEN
  4773. AGrenadeUnpin:
  4774.     incbin "grenade_unpin_11k.raw"
  4775. AGrenadeUnpin_e:
  4776.     EVEN
  4777. AGrenadeBounce:
  4778.     incbin "grenade_bounce_11k.raw"
  4779. AGrenadeBounce_e:
  4780.     EVEN
  4781. AGrenadeExplode:
  4782.     incbin "grenade_explode_11k.raw"
  4783. AGrenadeExplode_e:
  4784.  
  4785.  
  4786.     EVEN
  4787. ABoobyTripped:
  4788.     incbin "booby_tripped_11k.raw"
  4789. ABoobyTripped_e:
  4790.     EVEN
  4791. ABoobyExplode:
  4792.     incbin "big_explode_11k.raw"
  4793. ABoobyExplode_e:
  4794.  
  4795.  
  4796.     EVEN
  4797. ADoorOpen:
  4798.     incbin "dooropen_11k.raw"
  4799. ADoorOpen_e:
  4800.  
  4801.  
  4802.     EVEN
  4803. AGrassWalk1:
  4804.     incbin "grass_walk_01_8k.raw"
  4805. AGrassWalk1_e:
  4806.     EVEN
  4807. AGrassWalk2:
  4808.     incbin "grass_walk_02_8k.raw"
  4809. AGrassWalk2_e:
  4810.     EVEN
  4811. AGrassWalk3:
  4812.     incbin "grass_walk_03_8k.raw"
  4813. AGrassWalk3_e:
  4814.     EVEN
  4815. AGrassWalk4:
  4816.     incbin "grass_walk_04_8k.raw"
  4817. AGrassWalk4_e:
  4818.  
  4819.     EVEN
  4820. AFloorWalk1:
  4821.     incbin "stone_walk_01_8k.raw"
  4822. AFloorWalk1_e:
  4823.     EVEN
  4824. AFloorWalk2:
  4825.     incbin "stone_walk_02_8k.raw"
  4826. AFloorWalk2_e:
  4827.     EVEN
  4828. AFloorWalk3:
  4829.     incbin "stone_walk_03_8k.raw"
  4830. AFloorWalk3_e:
  4831.     EVEN
  4832. AFloorWalk4:
  4833.     incbin "stone_walk_04_8k.raw"
  4834. AFloorWalk4_e:
  4835.  
  4836.     EVEN
  4837. AWin:
  4838.     incbin "win_8k.raw"
  4839. AWin_e:
  4840.  
  4841.  
  4842.     EVEN
  4843. ANull:
  4844.     dc.w 0,0
  4845. ANull_e:
  4846.  
  4847.  
  4848.     EVEN
  4849. BulletSprite:
  4850.     dcb.w 4*NUM_BULLETS_MAX,0
  4851.     dc.w 0,0
  4852.  
  4853.     EVEN
  4854. PelletSprite:
  4855.     dc.w $0,$0
  4856.     dc.w %0000000000000000,%0000011011010000
  4857.     dc.w %0000010011010000,%0000110111011000
  4858.     dc.w %0001011110110100,%0001011110110100
  4859.     dc.w %0001101011011000,%0101101011011000
  4860.     dc.w %0010011011010100,%0010011011010110
  4861.     dc.w %0001010101011000,%1001111101111001
  4862.     dc.w %0011101010101100,%0011111111111110
  4863.     dc.w %0001010111010100,%1001010111010100
  4864.     dc.w %0010110010011100,%1010111011011100
  4865.     dc.w %0101011101100100,%0101011111110110
  4866.     dc.w %0011110110110100,%1011110110111100
  4867.     dc.w %0001011011011100,%0001111011011100
  4868.     dc.w %0111010110110100,%0111011111110110
  4869.     dc.w %0000101001011000,%0011111011011010
  4870.     dc.w %0000011011010000,%0001011011010000
  4871.     dc.w %0000000000000000,%0000101010101000
  4872.     dc.w $0,$0
  4873.  
  4874.     ; Grenade is an attached sprite
  4875.     EVEN
  4876. GrenadeSprite:
  4877.     include "grenade.sprite"
  4878.  
  4879.     EVEN
  4880. BoomSprite:
  4881.     include "boom.sprite"
  4882.  
  4883.     EVEN
  4884. SasLeft:
  4885.     include "sas.sprite_16.s"
  4886. SasLeft_e:
  4887. SasRight:
  4888.     include "sas.sprite_16p2.s"
  4889. SasRight_e:
  4890.  
  4891.     EVEN
  4892. NullSprite:
  4893.     dc.w $2a20,$2b00
  4894.     dc.w 0,0
  4895.     dc.w 0,0
  4896.  
  4897.  
  4898.     EVEN
  4899. P1Copper:
  4900.     dc.w $1fc,0 ; slow fetch mode, AGA compatibility
  4901.     dc.w BPLCON0,$0200!(INTERLACED<<2)
  4902.     dc.w BPLCON1,$0
  4903.  
  4904. P1CopperColor:
  4905.     dc.w $0180,$0,$0182,$0,$0184,$0,$0186,$0
  4906.     dc.w $0188,$0,$018a,$0,$018c,$0,$018e,$0
  4907.  
  4908.     dc.w $8007,$fffe
  4909.  
  4910. P1CopperLogo:
  4911.     dc.w BPL1PTH,0
  4912.     dc.w BPL1PTL,0
  4913.     dc.w BPL2PTH,0
  4914.     dc.w BPL2PTL,0
  4915.     dc.w BPL3PTH,0
  4916.     dc.w BPL3PTL,0
  4917.  
  4918.     dc.w BPLCON0,(LOGO_D<<12)!$204
  4919.     dc.b 0,DIWSTRT,$80,81
  4920.     dc.b 0,DIWSTOP,$2c,$c1-LOGO_MARGIN
  4921.     dc.w DDFSTRT,$38+LOGO_MARGIN/2
  4922.     dc.w DDFSTOP,$d0-LOGO_MARGIN/2
  4923.     dc.w BPL1MOD,0
  4924.     dc.w BPL2MOD,0
  4925.  
  4926.     dc.b $80+LOGO_H,$07,$ff,$fe
  4927.     dc.w BPLCON0,$0200!(INTERLACED<<2)
  4928.  
  4929.     dc.w $ffff,$fffe
  4930.  
  4931.  
  4932.     EVEN
  4933. Copper:
  4934.     dc.w $1fc,0 ; slow fetch mode, AGA compatibility
  4935. CopperBplcon0:
  4936.     dc.w BPLCON0,$0204
  4937.     dc.w BPLCON1,$0
  4938.  
  4939. CopperWindowControl:
  4940.     dc.w DIWSTRT,$2c81
  4941.     dc.w DIWSTOP,$2cc1
  4942.     dc.w DDFSTRT,$38
  4943.     dc.w DDFSTOP,$d0
  4944.  
  4945. CopperColor:
  4946.     dc.w $0180,$0111,$0182,$0b89,$0184,$0b8a,$0186,$0742
  4947.     dc.w $0188,$0665,$018a,$0c9a,$018c,$0aaa,$018e,$0bad
  4948.     dc.w $0190,$0734,$0192,$0745,$0194,$0956,$0196,$0867
  4949.     dc.w $0198,$0a68,$019a,$0978,$019c,$0a77,$019e,$0b79
  4950.     dc.w $01a0,$0a89,$01a2,$0111,$01a4,$0222,$01a6,$0333
  4951.     dc.w $01a8,$0444,$01aa,$0555,$01ac,$0666,$01ae,$0866
  4952.     dc.w $01b0,$0777,$01b2,$0888,$01b4,$0bab,$01b6,$0000
  4953.     dc.w $01b8,$0800,$01ba,$0f00,$01bc,$0780,$01be,$0ff0
  4954.  
  4955. CopperWait:
  4956.     dc.w $0707,$fffe
  4957.  
  4958. CopperSprite:
  4959.     dc.w SPRITE0,0
  4960.     dc.w SPRITE0+2,0
  4961.     dc.w SPRITE1,0
  4962.     dc.w SPRITE1+2,0
  4963.     dc.w SPRITE2,0
  4964.     dc.w SPRITE2+2,0
  4965.     dc.w SPRITE3,0
  4966.     dc.w SPRITE3+2,0
  4967.     dc.w SPRITE4,0
  4968.     dc.w SPRITE4+2,0
  4969.     dc.w SPRITE5,0
  4970.     dc.w SPRITE5+2,0
  4971. CopperSprite6:
  4972.     dc.w SPRITE6,0
  4973.     dc.w SPRITE6+2,0
  4974. CopperSprite7:
  4975.     dc.w SPRITE7,0
  4976.     dc.w SPRITE7+2,0
  4977.  
  4978. CopperScreen:
  4979.     dc.w BPL1PTH,0
  4980.     dc.w BPL1PTL,0
  4981.     dc.w BPL2PTH,0
  4982.     dc.w BPL2PTL,0
  4983.     dc.w BPL3PTH,0
  4984.     dc.w BPL3PTL,0
  4985.     dc.w BPL4PTH,0
  4986.     dc.w BPL4PTL,0
  4987.     dc.w BPL5PTH,0
  4988.     dc.w BPL5PTL,0
  4989.  
  4990. CopperScreenControl:
  4991.     dc.w BPLCON0,(SCREEN_D<<12)!$0204
  4992.     dc.w BPLCON3,$40
  4993.     dc.w BPL1MOD,SCREEN_BYWIDTH-SCREEN_BYPL
  4994.     dc.w BPL2MOD,SCREEN_BYWIDTH-SCREEN_BYPL
  4995.  
  4996.     dc.w $ffff,$fffe
  4997.  
  4998.  
  4999. SectionChip_e:
  5000.  
  5001.     SECTION chip_bss,BSS_C
  5002. Screen:
  5003.     ds.b SCREEN_BYWIDTH*SCREEN_H
  5004. Screen_e:
  5005. Background:
  5006.     ds.b SCREEN_BYWIDTH*SCREEN_H
  5007. BackgroundE:
  5008.  
  5009.     END
  5010.  
  5011.   ABC -> D
  5012.  
  5013. 0 000    0
  5014. 1 001    0
  5015. 2 010    0
  5016. 3 011    0
  5017. 4 100    1
  5018. 5 101    1
  5019. 6 110    1
  5020. 7 111    1
  5021.     $c0
  5022.  
  5023.   ABC -> D
  5024.  
  5025. 0 000    0
  5026. 1 001    1
  5027. 2 010    0
  5028. 3 011    0
  5029. 4 100    0
  5030. 5 101    1
  5031. 6 110    1
  5032. 7 111    1
  5033.     $e2
Add Comment
Please, Sign In to add comment