Advertisement
Nightseeker

GameHut4 split SRAM init test source

Mar 12th, 2020
1,308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. GAMEHUT.S
  2. TIMING      EQU 0
  3. ;----------------------------------------------------------
  4. ;       GAMEHUT SHELL
  5. ;       BY JON BURTON - AUG 2018
  6. ;----------------------------------------------------------
  7.         INCLUDE SYSTEM.S        ;INCLUDES LOTS OF SYSTEM CODE TO MAKE ALL THIS POSSIBLE
  8.         INCLUDE RINGS.S
  9.         INCLUDE FLAME.S
  10.         INCLUDE SRAM.S
  11. USERRAM:    EQU FLAMEEND
  12. ;----------------------------------------------------------
  13. ;       VRAM MEMORY MAP IN HEXADECIMAL
  14. ;       (NOTE: CHARACTERS ARE 8 X 8 PIXEL BLOCKS)
  15. ;----------------------------------------------------------
  16. ;       $0000-$0020         BLANK CHARACTER
  17. ;       $0020-$8000         CHARACTERS FOR PLAYFIELDS AND SPRITES
  18. ;       $C000-$D000         CHARACTER MAP FOR PLAYFIELD 1 (4096 BYTES)
  19. ;       $E000-$F000         CHARACTER MAP FOR PLAYFIELD 2 (4096 BYTES)
  20. ;       $F800               SPRITE TABLE (960 BYTES)
  21.  
  22. ;----------------------------------------------------------
  23. ;       USER VARIABLES
  24. ;       - PUT ANY VARIABLES YOU NEED HERE
  25. ;----------------------------------------------------------
  26.         RSSET   USERRAM
  27. PLAYX:      RS.L    0
  28. PLAY1X:     RS.W    1           ;X POSITION OF PLAYFIELD 1
  29. PLAY2X:     RS.W    1           ;X POSITION OF PLAYFIELD 2
  30. PLAYY:      RS.L    0
  31. PLAY1Y:     RS.W    1           ;Y POSITION OF PLAYFIELD 1
  32. PLAY2Y:     RS.W    1           ;Y POSITION OF PLAYFIELD 2
  33. SONICX:     RS.W    1           ;SONIC'S X POSITION
  34. SONICY:     RS.W    1           ;SONIC'S Y POSITION
  35. SONICD:     RS.W    1           ;SONIC'S DIRECTION
  36. TEMPSCREEN: RS.B    4096            ;RAM TO BUILD TEMPORARY SCREEN MAP
  37. ENDVARS:    RS.B    0
  38.  
  39. ;----------------------------------------------------------
  40. ;       INITIALISE USER STUFF
  41. ;       - THIS IS WHERE YOU SET UP STUFF BEFORE YOU BEGIN
  42. ;----------------------------------------------------------
  43. USERINIT:   MOVE.W  #0,PLAY1X       ;SET START PLAYFIELD 1 X POSITION TO ZERO
  44.         MOVE.W  #0,PLAY1Y       ;SET START PLAYFIELD 1 Y POSITION TO ZERO
  45.  
  46.         DMADUMP MAPGFX,4*32,$820    ;DUMP 4 CHARACTERS (SIZE 32 BYTES EACH) TO VRAM LOCATION $820 (MAP GRAPHICS)
  47.         DMADUMP SPRITEGFX,8*32,$1000    ;DUMP 8 CHARACTERS (SIZE 32 BYTES EACH) TO VRAM LOCATION $1000 (SPRITE GRAPHICS)
  48.         DMADUMP RINGGFX,4*32,$1000+$100 ;DUMP 8 CHARACTERS (SIZE 32 BYTES EACH) TO VRAM LOCATION $1100 (SPRITE GRAPHICS, AFTER SONIC)
  49.  
  50.         LEA.L   TEMPSCREEN,A0       ;POINT A0 TO TEMPORARY BUFFER IN RAM TO BUILD MAP BEFORE WE COPY TO VRAM
  51.         MOVE.W  #8-1,D3         ;WE'LL MAKE 8 COPIES OF THIS PATTERN
  52. @L4:        LEA.L   CHARGFX,A1      ;POINT A1 TO CHARGFX, WHICH IS THE 8 CHARACTER X 4 CHARACTER PATTERN WE'LL COPY MULITPLE TIMES
  53.         MOVE.W  #4-1,D1         ;4 ROWS
  54. @L3:        MOVE.W  #8-1,D0         ;COPY EACH ROW REPEATED ACROSS THE SCREEN 8 TIMES HORIZONTALLY
  55. @L2:        MOVE.W  #4-1,D2         ;4 LONG-WORDS = 8 CHARACTERS WIDE
  56. @L1:        MOVE.L  (A1)+,(A0)+     ;COPY FROM CHARGFX TO THE TEMPSCREEN. THE + MEANS INCREMENT THE POINTERS
  57.         DBRA    D2,@L1          ;LOOP BACK TO @L1
  58.         SUB.L   #16,A1          ;POINT BACK TO THE START OF THE CURRENT CHARGFX ROW
  59.         DBRA    D0,@L2          ;LOOP BACK TO @L2
  60.         ADD.L   #16,A1          ;MOVE ONTO THE NEXT CHARGFX ROW
  61.         DBRA    D1,@L3          ;LOOP BACK TO @L3
  62.         DBRA    D3,@L4          ;LOOP BACK TO @L4
  63.  
  64.         DMADUMP TEMPSCREEN,4096,$C000   ;COPY TEMPSCREEN WHICH IS 4096 BYTES IN SIZE TO VRAM ADDRESS $C000
  65.  
  66.         LEA.L   PALETTE1,A0     ;DOWNLOAD A PALETTE FOR THE MAP TO USE
  67.         BSR SETPAL1         ;OVERRIGHT FIRST PALETTE
  68.  
  69.         LEA.L   PALETTE2,A0     ;DOWNLOAD A PALETTE FOR THE SPRITES TO USE
  70.         BSR SETPAL2         ;OVERRIGHT SECOND PALETTE
  71.  
  72.         MOVE.W  #$80+160-8,SONICX   ;SONIC'S X START POSITION
  73.         MOVE.W  #$80+112-13,SONICY  ;SONIC'S Y START POSITION
  74.         MOVE.W  #0,SONICD       ;SONIC'S START DIRECTION
  75.  
  76.         JSR INITFLAME
  77.         JSR RINGINIT
  78.  
  79.         JSR DUMPCOLS        ;COPY ALL PALETTES TO CRAM (COLOUR RAM)
  80.  
  81.         RTS
  82.  
  83. ;------------------------------
  84. ;   MAIN GAME LOOP
  85. ;------------------------------
  86. MAIN:       WAITVBI                 ;WAITS FOR THE START OF THE NEXT FRAME
  87.         IF  TIMING
  88.         WDEST   CRAMW,$0000         ;COLOUR TIMING BAR
  89.         MOVE.W  #$000F,VDP_DATA         ;IN RED
  90.         ENDC
  91.  
  92.         JSR DRAWFLAME
  93.  
  94.         ADD.W   #1,PLAY1X           ;SCROLL PLAYFIELD 1 RIGHT BY ONE PIXEL
  95.         ADD.W   #1,PLAY1Y           ;SCROLL PLAYFIELD 1 UP BY ONE PIXEL
  96. ;ADD SPRITES
  97.         LEA.L   SPRITETEMP,A1           ;POINT TO TEMPORARY MEMORY TO BUILD SPRITE LIST
  98.         MOVE.W  #1,D7               ;SPRITE NUMBER
  99. ;FIRST SONIC
  100.         MOVE.W  SONICY,(A1)+            ;Y POSITION ($80 IS TOP OF SCREEN)
  101.         MOVE.W  #S_2X4,D0           ;SIZE 2X4 CHARACTERS
  102.         ADD.W   D7,D0               ;ADD CURRENT SPRITE NUMBER
  103.         MOVE.W  D0,(A1)+            ;WRITE TO SPRITE TABLE
  104.         MOVE.W  #S_PAL2+$1000/32,D0     ;PALETTE NUMBER+GRAPHIC VRAM LOCATION/32
  105.         ADD.W   SONICD,D0           ;ADD SONIC'S DIRECTION
  106.         MOVE.W  D0,(A1)+            ;WRITE TO SPRITE TABLE
  107.         MOVE.W  SONICX,(A1)+            ;X POSITION ($80 IS LEFT OF SCREEN)
  108.  
  109.         ADDQ.W  #1,D7               ;MOVE ON TO NEXT SPRITE NUMBER
  110.  
  111.         JSR PROCRING            ;ADD ANY RINGS TO SPRITELIST
  112.                             ;A1=POINTER TO NEXT SPRITE ENTRY
  113.                             ;D7=NEXT SPRITE NUMBER
  114.  
  115. ;FINISHED ADDING SPRITES
  116.         MOVE.L  #$10000,(A1)+           ;TERMINATE SPRITE LIST
  117.         MOVE.L  #1,(A1)+            ;   "  "
  118.  
  119.         JSR CONVFLAME
  120.  
  121. ;MOVE SONIC
  122.         BTST    #J_RIGHT,JOYPAD0
  123.         BNE.S   @MOVE1
  124.         ADD.W   #1,SONICX
  125.         MOVE.W  #0,SONICD
  126. @MOVE1:
  127.         BTST    #J_LEFT,JOYPAD0
  128.         BNE.S   @MOVE2
  129.         SUB.W   #1,SONICX
  130.         MOVE.W  #$800,SONICD
  131. @MOVE2:
  132.         BTST    #J_DOWN,JOYPAD0
  133.         BNE.S   @MOVE3
  134.         ADD.W   #1,SONICY
  135. @MOVE3:
  136.         BTST    #J_UP,JOYPAD0
  137.         BNE.S   @MOVE4
  138.         SUB.W   #1,SONICY
  139. @MOVE4:
  140.         BTST    #J_BUT_A,JOYPAD0
  141.         BNE.S   @NORING
  142. ;ADD A RING
  143.         MOVE.W  SONICX,D3           ;X POS
  144.         MOVE.W  SONICY,D4           ;Y POS
  145.         JSR GETRANDOM           ;RETURNS A RANDOM NUMBER FROM 0-255 IN REGISTER D0
  146.         MOVE.L  D0,D5
  147.         EXT.W   D5              ;NUMBER FROM -126 TO +127
  148.         SWAP    D5              ;ADDS PRECISION
  149.         ASR.L   #6,D5               ;REMOVE A BIT OF PRECISION - X MOMENTUM
  150.         JSR GETRANDOM           ;RETURNS A RANDOM NUMBER FROM 0-255 IN REGISTER D0
  151.         MOVE.L  D0,D6
  152.         EXT.W   D6              ;NUMBER FROM -126 TO +127
  153.         SWAP    D6              ;ADDS PRECISION
  154.         ASR.L   #6,D6               ;REMOVE A BIT OF PRECISION
  155.         ADD.L   #-$30000,D6         ;Y MOMENTUM
  156.         MOVE.L  #$1000,D7           ;GRAVITY
  157.         JSR ADDRING
  158.  
  159. @NORING:
  160.         IF  TIMING
  161.         WDEST   CRAMW,$0000
  162.         MOVE.W  #$0000,VDP_DATA
  163.         ENDC
  164.         BRA MAIN                ;LOOP BACK TO WAIT FOR NEXT FRAME
  165.  
  166. ;----------------------------------------------------------
  167. ;       USER VBI ROUTINES
  168. ;       - PUT TIME CRITICAL CODE THAT MUST CALLED DURING THE VERTICAL BLANK HERE
  169. ;----------------------------------------------------------
  170. USERVBI:    LEA.L   VDP_DATA,A1
  171.         LEA.L   VDP_CONTROL,A2
  172. ;SET HORIZONTAL OFFSETS
  173.         MOVE.L  #$7C000003,(A2)
  174.         MOVE.L  PLAYX,(A1)      ;THIS TELLS THE VDP (VISUAL DISPLAY PROCESSOR) WHAT X POSITION THE PLAYFIELDS SHOULD BE AT
  175.  
  176. ;SET VERTICAL OFFSETS
  177.         MOVE.L  #$40000010,(A2)     ;THIS TELLS THE VDP WHAT Y POSITION THE PLAYFIELDS SHOULD BE AT
  178.         MOVE.L  PLAYY,(A1)
  179.  
  180. ;COPY SPRITE TABLE TO VRAM
  181.         JSR SPRITEDUMP
  182. ;READ JOYPAD
  183.         BSR READJOY         ;READ THE JOYPAD
  184.  
  185.         RTS
  186.  
  187. ;----------------------------------------------------------
  188. ;       PUT DATA BELOW HERE
  189. ;----------------------------------------------------------
  190.  
  191. ;----------------------------------------------------------
  192. ;       CHARACTER CODES TO BUILD OUR PATTERN
  193. ;
  194. ;       THE CODE IS IN THE FORMAT $NNNN
  195. ;
  196. ;       THE LAST TWO NUMBERS ($00NN) REFER TO THE CHARACTER NUMBER IN VRAM TO USE
  197. ;       (THE CHARACTER NUMBER IS THE VRAM ADDRESS DIVIDED BY 32 (OR DIVIDED BY $20 HEXADECIMAL))
  198. ;
  199. ;       IF THE FIRST NUMBER  ($N000) IS '1' IT MEANS MIRROR THE CHARACTER VERTICALLY
  200. ;       IF THE SECOND NUMBER ($0N00) IS '8' IT MEANS MIRROR THE CHARACTER HORIZONTALLY
  201. ;
  202. ;       SO WHEN WE HAVE A DIAGONAL CHARACTER LINE THIS - / WE CAN MIRROR IT TO GET THIS \
  203. ;       SO WE CAN BUILD THIS - /\
  204. ;                      \/   USING ONE DIAGONAL AND MIRRORING
  205. ;----------------------------------------------------------
  206. CHARGFX     incbin  Uncompressed\Mapunc_CHARGFX.bin
  207.  
  208. ;----------------------------------------------------------
  209. ;       MAP GRAPHICS
  210. ;----------------------------------------------------------
  211. MAPGFX      incbin  Uncompressed\Artunc_MAPGFX.smd
  212.  
  213. ;----------------------------------------------------------
  214. ;       SPRITE GRAPHICS
  215. ;       2 X 4 CHARACTERS ARRANGED AS FOLLOWS -
  216. ;
  217. ;       1 5
  218. ;       2 6
  219. ;       3 7
  220. ;       4 8
  221. ;----------------------------------------------------------
  222. SPRITEGFX   incbin  Uncompressed\Artunc_SPRITEGFX.smd
  223.  
  224. ;----------------------------------------------------------
  225. RINGGFX     incbin  Uncompressed\Artunc_RINGGFX.smd
  226.  
  227. ;----------------------------------------------------------
  228. ;       USER PALETTES
  229. ;----------------------------------------------------------
  230. PALETTE1    incbin  Palettes\pallet1.bin
  231.  
  232. PALETTE2    incbin  Palettes\pallet2.bin
  233.  
  234. PALETTE3    incbin  Palettes\pallet3.bin
  235.  
  236. RINGS.S
  237. ;----------------------------------------------------------
  238. ;       RING CODE
  239. ;----------------------------------------------------------
  240. ;RING STRUCTURE STUFF
  241.         RSSET   0
  242. RING_X:     RS.L    1
  243. RING_Y:     RS.L    1
  244. RING_MX:    RS.L    1
  245. RING_MY:    RS.L    1
  246. RING_GRAV:  RS.L    1
  247. RING_LIFE:  RS.W    1
  248. RING_SIZE:  RS.B    0
  249.  
  250. RINGS:      EQU 64  ;TOTAL NUMBER OF RINGS
  251.  
  252.         RSSET   SYSTEMEND
  253. RINGDATA:   RS.B    RINGS*RING_SIZE ;RING SYSTEM
  254.  
  255. RINGEND:    RS.B    0
  256.  
  257. ;-------------------------
  258. ;   INITIALISE RINGS
  259. ;-------------------------
  260. RINGINIT:   LEA.L   RINGDATA,A0
  261.         MOVE.W  #RINGS-1,D0         ;NUMBER OF RINGS TO PROCESS
  262.         MOVE.W  #0,D1
  263. @L1:        MOVE.W  D1,RING_LIFE(A0)        ;SET LIFE SPAN TO 0
  264.         ADD.L   #RING_SIZE,A0
  265.         DBRA    D0,@L1
  266.         RTS
  267.  
  268. ;-------------------------
  269. ;   PROCESS RINGS
  270. ;-------------------------
  271. PROCRING:   LEA.L   RINGDATA,A0
  272.         MOVE.W  #RINGS-1,D0
  273.         AND.W   #$FF,D7             ;CLEAR AWAY ANY PREVIOUS SIZE INFO FROM SPRITE COUNT
  274.         ADD.W   #S_2X2,D7           ;ALL THESE RINGS WILL BE 2X2 IN SIZE
  275.         MOVE.W  #S_PAL2+$1100/32,D6     ;ALL RINGS WILL USE THIS PALETTE AND VRAM LOCATION
  276.  
  277. @L1:        TST.W   RING_LIFE(A0)
  278.         BEQ.S   @SKIP
  279. ;ADD SPRITE TO TABLE
  280.         MOVE.W  RING_Y(A0),(A1)+        ;Y POSITION
  281.         MOVE.W  D7,(A1)+            ;SIZE 2X2 CHARACTERS AND SPRITE NUM
  282.         MOVE.W  D6,(A1)+            ;PALETTE NUMBER+GRAPHIC VRAM LOCATION/32
  283.         MOVE.W  RING_X(A0),(A1)+        ;X POSITION ($80 IS LEFT OF SCREEN)
  284.         ADD.W   #1,D7               ;INCREMENT SPRITE COUNT
  285. ;PROCESS PHYSICS
  286.         MOVE.L  RING_MX(A0),D1
  287.         ADD.L   D1,RING_X(A0)
  288.         MOVE.L  RING_MY(A0),D1
  289.         ADD.L   D1,RING_Y(A0)
  290.         MOVE.L  RING_GRAV(A0),D1
  291.         ADD.L   D1,RING_MY(A0)
  292.         SUB.W   #1,RING_LIFE(A0)
  293. ;CLIP
  294.         MOVE.W  RING_Y(A0),D1           ;Y CLIP
  295.         SUB.W   #$80-16,D1
  296.         CMP.W   #224+16,D1
  297.         BHI.S   @CLIP
  298.         MOVE.W  RING_X(A0),D1           ;X CLIP
  299.         SUB.W   #$80-16,D1
  300.         CMP.W   #320+16,D1
  301.         BLS.S   @SKIP
  302. @CLIP:
  303.         CLR.W   RING_LIFE(A0)
  304.  
  305. @SKIP:      ADD.L   #RING_SIZE,A0
  306.         DBRA    D0,@L1
  307.         RTS
  308.  
  309. ;-------------------------
  310. ;   ADD A RING
  311. ;-------------------------
  312. ADDRING:    LEA.L   RINGDATA,A0
  313.         MOVE.W  #RINGS-1,D0
  314.         MOVE.W  #10000,D2           ;STORE SHORTEST REMAINING RING LIFE HERE
  315.         MOVE.L  A0,A1               ;SHORTEST LIFE RING POSITION
  316.  
  317. @L1:        MOVE.W  RING_LIFE(A0),D1
  318.         BEQ.S   @ADD                ;RING WITH ZERO LIFE, SO FREE SLOT FOUND
  319.         CMP.W   D1,D2               ;SHORTER LIFE THAN CURRENT SHORTEST?
  320.         BLE.S   @SKIP
  321.         MOVE.W  D1,D2               ;NEW SHORTEST
  322.         MOVE.L  A0,A1               ;NEW SHORTEST POSITION
  323. @SKIP:      ADD.L   #RING_SIZE,A0
  324.         DBRA    D0,@L1
  325.  
  326.         MOVE.L  A1,A0               ;REPLACE RING WITH SHORTEST LIFE LEFT IF ZERO NOT FOUND
  327.  
  328. @ADD:       SWAP.W  D3
  329.         CLR.W   D3
  330.         SWAP.W  D4
  331.         CLR.W   D4
  332.         MOVE.L  D3,RING_X(A0)
  333.         MOVE.L  D4,RING_Y(A0)
  334.         MOVE.L  D5,RING_MX(A0)
  335.         MOVE.L  D6,RING_MY(A0)
  336.         MOVE.L  D7,RING_GRAV(A0)
  337.         MOVE.W  #120,RING_LIFE(A0)
  338.         RTS
  339.  
  340. FLAME.S
  341. ;----------------------------------------------------------
  342. ;       FLAME CODE
  343. ;----------------------------------------------------------
  344.         RSSET   0
  345. FLAME_X:    RS.W    1
  346. FLAME_DIR:  RS.W    1
  347. FLAME_TIME: RS.W    1
  348. FLAME_SIZE: RS.B    0
  349.  
  350.         RSSET   RINGEND
  351. ;FLAME STUFF
  352. FBUFFER:    RS.W    1   ;BUFFER FOR FLAME
  353. XPOS:       RS.W    1   ;XPOS FOR FLAME
  354.  
  355. FLAMES:     EQU 12  ;TOTAL NUMBER OF FLAMES
  356. FLAMEDATA:  RS.B    FLAMES*FLAME_SIZE
  357.  
  358. FLAMEEND:   RS.B    0
  359.  
  360. FLAMETABLE: EQU DECRUNCH+4096+1160*2
  361. FLAMEBUF1:  EQU DECRUNCH+4096
  362. FLAMEBUF2:  EQU DECRUNCH+4096+1160
  363.  
  364. ;----------------------------------------------------------
  365. ;       INIT FLAME
  366. ;----------------------------------------------------------
  367. INITFLAME: 
  368.         LEA.L   PALETTE3,A0     ;FLAME PALETTE
  369.         JSR SETPAL3
  370.  
  371.         LEA.L   DECRUNCH,A0     ;SET UP MASK FOR FLAME PLAYFIELD
  372.         MOVE.W  #$8000+S_PAL3,D0
  373.         MOVE.W  #(4096/2)-1,D1
  374. @L1:        MOVE.W  D0,(A0)+
  375.         DBRA    D1,@L1
  376.  
  377.         LEA.L   DECRUNCH+4096,A0    ;CLEAR FLAME BUFFERS
  378.         MOVEQ.L #0,D0
  379.         MOVE.W  #((1160*2)/4)-1,D1
  380. @L3:        MOVE.L  D0,(A0)+
  381.         DBRA    D1,@L3
  382.  
  383. ;INIT FLAME CREATORS
  384.         LEA.L   FLAMEDATA,A1
  385.         MOVE.W  #FLAMES-1,D1
  386. @L2:        MOVE.W  #-10000,(A1)+       ;START
  387.         MOVE.W  #1,(A1)+        ;SPEED
  388.         MOVE.W  #0,(A1)+        ;LIFE
  389.         DBRA    D1,@L2
  390.  
  391.         MOVE.W  #0,FBUFFER
  392.  
  393.         DMADUMP FLAMEGFX1,32*32,$0  ;DUMP 4 CHARACTERS (SIZE 32 BYTES EACH) TO VRAM LOCATION $20 (MAP GRAPHICS)
  394.  
  395.         BSR CALCFLAME       ;CREATE A TABLE USED TO SPEED UP ANTI-ALIAS MATHS
  396.  
  397.         RTS
  398. ;----------------------------------------------------------
  399. ;       CALC FLAME TABLE - TO SPEED UP MATHS
  400. ;----------------------------------------------------------
  401. CALCFLAME:  LEA.L   FLAMETABLE,A0
  402.         MOVEQ.L #0,D0
  403.         MOVEQ.L #0,D2
  404.  
  405.         MOVE.W  #255-1,D1
  406.  
  407.         MOVE.B  #0,(A0)+
  408.  
  409. @L1:        MOVE.B  D0,D2
  410.         ASR.W   #2,D2
  411.  
  412.         MOVE.B  D2,(A0)+
  413.         ADD.B   #1,D0
  414.         DBRA    D1,@L1
  415.  
  416.         RTS
  417.  
  418. ;----------------------------------------------------------
  419. ;       CONVERT FLAME - COPY FLAME TO PLAYFIELD
  420. ;----------------------------------------------------------
  421. CONVFLAME:  LEA.L   DECRUNCH+1,A0
  422.         LEA.L   FLAMEBUF2,A1
  423.         SUB.W   FBUFFER,A1
  424.  
  425.         MOVE.W  #$8000+S_PAL3,D1
  426.         MOVE.W  #28-1,D2
  427. @L2:
  428.         REPT    9
  429.         MOVE.L  (A1)+,D1
  430.         MOVEP.L D1,(0,A0)       ;VERY SNEAKY
  431.         LEA.L   8(A0),A0
  432.         ENDR
  433.         MOVE.L  (A1)+,D1
  434.         MOVEP.L D1,(0,A0)
  435.         LEA.L   -72+128(A0),A0
  436.         DBRA    D2,@L2
  437.  
  438.         RTS
  439.  
  440. ;----------------------------------------------------------
  441. ;       MAIN FLAME CODE
  442. ;----------------------------------------------------------
  443. DRAWFLAME:
  444. ;DUMP FLAME TO VRAM
  445.         DMADUMP DECRUNCH,4096,$E000
  446. ;TOGGLE BUFFERS
  447.         CMP.W   #0,FBUFFER
  448.         BEQ.S   @B1
  449.         MOVE.W  #0,FBUFFER
  450.         BRA.S   @B2
  451. @B1:        MOVE.W  #1160,FBUFFER
  452. @B2:
  453.  
  454. ;ADD AND MOVE FLAME CREATION OBJECTS
  455.         LEA.L   FLAMEBUF2+40*28,A0
  456.         SUB.W   FBUFFER,A0
  457.  
  458.         MOVEQ.L #0,D0           ;CLEAR BOTTOM LINE OF FLAME TO AVOID OVER SATURATION
  459.         REPT    10
  460.         MOVE.L  D0,(A0)+
  461.         ENDR
  462.  
  463.         LEA.L   FLAMEBUF2+40*28+2,A0   
  464.         SUB.W   FBUFFER,A0
  465.  
  466.         LEA.L   FLAMEDATA,A1
  467.         MOVE.W  #FLAMES-1,D2
  468.  
  469.         MOVE.W  #$1F,D1
  470.  
  471. @J1:        MOVE.W  (A1)+,D0        ;POSITION
  472.         ADD.W   (A1)+,D0        ;SPEED/DIR
  473.         BLT.S   @D1
  474.         CMP.W   #38*8,D0
  475.         BLT.S   @D2
  476. @D1:        LEA.L   2(A1),A1
  477.         BRA.S   @D3
  478. @D2:        MOVE.W  D0,-4(A1)
  479.         ASR.W   #3,D0
  480.         LEA.L   (A0,D0.W),A2
  481.  
  482.         MOVE.B  D1,-2(A2)       ;DRAW CROSS AT RANDOM POSITION
  483.         MOVE.B  D1,-1(A2)
  484.         MOVE.B  D1,-(40+1)(A2)
  485.         MOVE.B  D1,(A2)
  486.  
  487.         SUB.W   #1,(A1)+
  488.         BGE.S   @T1
  489. @D3:
  490.         BTST    #5,JOYPAD0
  491.         BNE @SKIP
  492.  
  493.         MOVE.L  A0,A3
  494.         JSR GETRANDOM
  495.         ADD.W   #32,D0
  496.         MOVE.W  D0,-6(A1)       ;POSITION
  497.         JSR GETRANDOM
  498.         AND.W   #$1F,D0
  499.         MOVE.W  D0,-2(A1)       ;TIME
  500.         JSR GETRANDOM
  501.         AND.W   #$7,D0
  502.         SUB.W   #3,D0
  503.         MOVE.W  D0,-4(A1)       ;SPEED
  504.         MOVE.L  A3,A0
  505.         BRA.S   @T1
  506. @SKIP:      MOVE.W  #-10000,-6(A1)
  507. @T1:
  508.         DBRA    D2,@J1
  509.  
  510. ;NOW ANTI ALIAS TO BUFFER 1
  511.         MOVE.W  FBUFFER,D0
  512.         BEQ.S   @PP1
  513.         LEA.L   FLAMEBUF1+40,A0
  514.         LEA.L   FLAMEBUF2+1,A1
  515.         BRA.S   @PP2
  516.  
  517. @PP1:       LEA.L   FLAMEBUF2+40-1,A0
  518.         LEA.L   FLAMEBUF1,A1
  519. @PP2:
  520.         LEA.L   FLAMETABLE,A2   ;FLAME TABLE
  521.         LEA.L   -39(A0),A3
  522.         LEA.L   2(A0),A4
  523.  
  524.         MOVEQ.L #0,D0
  525.  
  526.         MOVE.W  #(28*40)-1,D5
  527.  
  528. @LL1:       MOVE.B  (A0)+,D0
  529.         ADD.B   (A0),D0
  530.         ADD.B   (A4)+,D0
  531.         ADD.B   (A3)+,D0
  532. ;       ASR.W   #2,D0
  533. ;       MOVE.B  D0,(A1)+
  534.         MOVE.B  (A2,D0.W),(A1)+
  535.         DBRA    D5,@LL1
  536.  
  537.         RTS
  538.  
  539. ;----------------------------------------------------------
  540. ;       FLAME GFX
  541. ;----------------------------------------------------------
  542. FLAMEGFX1   incbin  Uncompressed\Artunc_FLAMEGFX1.smd
  543.  
  544. FLAMEGFX2   incbin  Uncompressed\Artunc_FLAMEGFX2.smd
  545.  
  546. SRAM.S
  547. ; https://pastebin.com/EEgPAspc
  548.  
  549. InitSRAM:
  550.         move.b  #1,($A130F1).l    ; Enable SRAM writing
  551.         lea ($200001).l,a1      ; Load SRAM memory into a1
  552.         movep.l 0(a1),d0        ; Get the existing string at the start of SRAM
  553.         move.l  #$5352414D,d1        ; Write the string "SRAM" to d1
  554.         cmp.l   d0,d1            ; Was it already in SRAM?
  555.         beq.s   @Continue           ; If so, skip
  556.         movep.l d1,0(a1)        ; Write string "SRAM"
  557.         ; Insert your values to be initialized, start with 8(a1).
  558.  
  559. @Continue:
  560.         move.b    #0,($A130F1).l    ; Disable SRAM writing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement