Home » Archimedes archive » Acorn User » AU 1994-06.adf » !WriteDemo_WriteDemo » Modules/Water/Source

Modules/Water/Source

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1994-06.adf » !WriteDemo_WriteDemo
Filename: Modules/Water/Source
Read OK:
File size: 1CB2 bytes
Load address: 0000
Exec address: 0000
Duplicates

There is 1 duplicate copy of this file in the archive:

File contents
   10REM >Water
   20
   30ON ERROR SYS "Hourglass_Smash":ERROR 0,(REPORT$+" (internal error code "+STR$(ERL)+")")
   40
   50REM Fixed variables :
   60
   70  REM Note : h%*2 cannot be >top% !
   80
   90  trigger$ = "z"
  100  trigger% = TRUE
  110
  120  REM y position of water in pixels
  130  y%       = 170
  140
  150  REM  start y position of water in pixels
  160  start_y% = 255
  170
  180  REM  height of water in pixels (approx)
  190  h%       = (y%/2)
  200
  210  REM  byte=byte OR orr%, for every pixel reflected.
  220  REM  in the format BGgRbrtT where :
  230  REM  R = high red bit,   r = low red bit
  240  REM  G = high green bit, g = low green bit
  250  REM  B = high blue bit,  b = low blue bit
  260  REM  T = high tint bit,  t = low tint bit
  270  orr%     = %10001000
  280
  290
  300
  310module$ = "Water"
  320
  330SYS "Hourglass_On"
  340PROCassemble
  350PROCinit
  360
  370OSCLI"SAVE    <Modules$Dir>."+module$+".Module "+STR$~code%+" "+STR$~P%
  380OSCLI"SETTYPE <Modules$Dir>."+module$+".Module Data"
  390
  400SYS "Hourglass_Off"
  410END
  420
  430
  440
  450DEF PROCassemble
  460  len% = 1024 * 2
  470  DIM code% len%
  480  FOR pass% = 8 TO 10 STEP 2
  490    P% = code%
  500    L% = code% + len%
  510    [OPT pass%
  520
  530
  540.init       EQUD  0
  550.frame      EQUD  wave - code%
  560.end        EQUD  0
  570
  580
  590
  600.wave       STMFD R13!,{R0-R11,R14}
  610            ]
  620            IF trigger% THEN
  630              [OPT pass%
  640              TST   R11,#( 1 << (ASC("z") - ASC(trigger$)) )
  650              BEQ   wave_end
  660              ]
  670            ENDIF
  680            [OPT pass%
  690
  700            
  710            LDR   R0,var%
  720            CMP   R0,#y%
  730            SUBGT R0,R0,#1
  740            STR   R0,var%
  750            MOV   R1,R0,LSL#6
  760            ADD   R1,R1,R0,LSL#8
  770            STR   R1,offset%        ; store scr_offset in offset%
  780            STR   R12,screen%       ; store scr_address in screen%
  790            ADD   R0,R12,#(320*256) ; r0=screen+((bottom+1)*320)
  800            STR   R0,max_scr%       ; store r0 in max_scr%
  810            LDR   R11,offset%       ; r11=screen_offset
  820            
  830            MOV   R2,R0             ;  r2=maximum screen address
  840            ADD   R0,R1,R12         ;  r0=scr_offset+scr_addr
  850            MOV   R3,#0             ;  r3=black word
  860.word_loop  STR   R3,[R0],#320      ; put word at left of line
  870            CMP   R0,R2             ; is scr_addr < max_addr ?
  880            BLT   word_loop         ; if so, go to 'world_loop'
  890
  900            ADD   R1,R12,R11        ; r1=screen+screen_offset
  910            STR   R1,water_pos%     ; store r1 in water_pos%
  920            SUB   R0,R1,#320        ; r0=addr of reflection
  930            MOV   R2,#h%            ; r2=number of rows of water
  940            LDR   R11,wave_pos%     ; r11=position in wave table
  950            ADD   R12,R11,#4        ; increment position by 4
  960            CMP   R12,#(h%*4)       ; if it has exceeded table,
  970            MOVEQ R12,#0            ; then reset it to zero
  980            STR   R12,wave_pos%     ; store position in wave table
  990            ADR   R12,table%        ; r12=addr of wave data table
 1000            ADR   R14,perspect%     ; r14=perspective table addr
 1010
 1020            B     wave_1            ; go to 'wave_1'
 1030
 1040.table%     FNarray(4*h%)           ; water motion offsets table
 1050.perspect%  FNarray(4*h%)           ; perspective factors table
 1060
 1070.wave_1     LDR   R4,[R12,R11]      ; r4=wave height
 1080            SUBS  R11,R11,#4        ; move wave height pointer
 1090            MOVMI R11,#((h%-1)*4)
 1100            LDR   R5,[R14],#4       ; get perspective factor
 1110            CMP   R5,#0             ; is it zero ?
 1120            BEQ   zero              ; if so, go to 'zero'
 1130            MUL   R6,R4,R5          ; r6=wave_height*perspective
 1140            MOV   R6,R6,ASR#20      ; r6=r6>>>20
 1150            CMP   R6,#0             ; is wave_height (r6) <0
 1160            ADDLT R6,R6,#1          ; if so, r6=r6+1
 1170            LDR   R1,water_pos%     ; r1=screen offset for water
 1180            ADD   R1,R1,R6,LSL#6    ; r1=r1+(wave_height*320)
 1190            ADD   R1,R1,R6,LSL#8
 1200            LDR   R3,max_scr%       ; r3=maximum screen address
 1210            CMP   R1,R3             ; does r1 exceed this ?
 1220            BGE   exit              ; if so, exit
 1230            B     skip              ; go to 'skip'
 1240
 1250.zero       LDR   R1,offset%        ; when wave_height=0
 1260            LDR   R3,screen%
 1270            ADD   R1,R1,R3          ; r1=screen_address+offset
 1280
 1290.skip       STR   R11,temp_wave%    ; store wave table pointer
 1300            LDR   R11,orr_word%     ; r11=byte ORing word
 1310            
 1320            ]
 1330            FOR loop% = 1 TO 10
 1340              [OPT pass%
 1350              
 1360            LDMIA R0!,{R3-R10}      ; get screen data
 1370            ORR   R3,R3,R11         ; set blue bits in words
 1380            ORR   R4,R4,R11
 1390            ORR   R5,R5,R11
 1400            ORR   R6,R6,R11
 1410            ORR   R7,R7,R11
 1420            ORR   R8,R8,R11
 1430            ORR   R9,R9,R11
 1440            ORR   R10,R10,R11
 1450            STMIA R1!,{R3-R10}      ; plot reflection
 1460            
 1470              ]
 1480            NEXT
 1490            [OPT pass%
 1500            
 1510            LDR   R11,temp_wave%    ; get wave pointer back
 1520            SUB   R0,R0,#960        ; screen_position-=3 lines
 1530            LDR   R1,water_pos%     ; r1=water_position
 1540            ADD   R1,R1,#320        ; add offset to next line
 1550            STR   R1,water_pos%     ; store water_position
 1560            SUBS  R2,R2,#1          ; another line ?
 1570            BNE   wave_1            ; if so, go to 'wave_1'
 1580
 1590.exit       LDR   R12,screen%       ; r12=screen address
 1600            LDR   R0,offset%        ;  r0=water address offset
 1610            ADD   R0,R0,R12         ;  r0=r0+r12
 1620            LDR   R2,max_scr%       ;  r2=maximum screen address
 1630.fill_loop  LDR   R3,[R0]           ; get word at left of line
 1640            CMP   R3,#0             ; is it black (an empty line)
 1650            BNE   move_fill         ; if not, go to 'move_fill'
 1660            SUB   R1,R0,#320        ; r1=address of line to copy
 1670            
 1680            ]
 1690            FOR loop% = 1 TO 10
 1700              [OPT pass%
 1710              
 1720            LDMIA R1!,{R3-R10}      ; get data of line above
 1730            STMIA R0!,{R3-R10}      ; store it in empty line
 1740            
 1750              ]
 1760            NEXT
 1770            [OPT pass%
 1780            
 1790            B     end_fill          ; jump to 'end_fill'
 1800.move_fill  ADD   R0,R0,#320        ; if not black goto next line
 1810.end_fill   CMP   R0,R2             ; is scr_addr < max_addr ?
 1820            BLT   fill_loop         ; if so, go to 'fill_loop'
 1830
 1840.wave_end   LDMFD R13!,{R0-R11,PC}  ; exit
 1850
 1860
 1870.var%       EQUD  start_y%
 1880.water_pos% EQUD  0
 1890.temp_wave% EQUD  0
 1900.screen%    EQUD  0
 1910.offset%    EQUD  y%*320
 1920.max_scr%   EQUD  0
 1930.wave_pos%  EQUD  0
 1940.orr_word%  EQUD  orr% + (orr%*1<<8) + (orr%*1<<16) + (orr%*1<<24)
 1950
 1960
 1970    ]
 1980  NEXT
 1990ENDPROC
 2000
 2010
 2020
 2030DEF FNarray(size%)
 2040  P% += size%
 2050= 0
 2060
 2070
 2080
 2090DEF PROCinit
 2100  LOCAL I%
 2110
 2120  FOR I% = 0 TO (h% - 1)
 2130    table%!(I%*4) = (h%/10) * SINRAD(I% * (360/(h%/2)) )
 2140  NEXT
 2150
 2160  FOR I% = 0 TO (h% - 1)
 2170    perspect%!(I%*4) = (I% / (h%-1)) * (1 << 20)
 2180  NEXT
 2190
 2200ENDPROC

� >Water

G� � ș "Hourglass_Smash":� 0,(�$+" (internal error code "+�(�)+")")
(
2� Fixed variables :
<
F%  � Note : h%*2 cannot be >top% !
P
Z  trigger$ = "z"
d  trigger% = �
n
x%  � y position of water in pixels
�  y%       = 170
�
�,  �  start y position of water in pixels
�  start_y% = 255
�
�+  �  height of water in pixels (approx)
�  h%       = (y%/2)
�
�6  �  byte=byte OR orr%, for every pixel reflected.
�'  �  in the format BGgRbrtT where :
�,  �  R = high red bit,   r = low red bit
�.  �  G = high green bit, g = low green bit
�-  �  B = high blue bit,  b = low blue bit
-  �  T = high tint bit,  t = low tint bit
  orr%     = %10001000

"
,
6module$ = "Water"
@
Jș "Hourglass_On"
T
�assemble
^	�init
h
rA�"SAVE    <Modules$Dir>."+module$+".Module "+�~code%+" "+�~P%
|4�"SETTYPE <Modules$Dir>."+module$+".Module Data"
�
�ș "Hourglass_Off"
��
�
�
�
�� �assemble
�  len% = 1024 * 2
�  � code% len%
�  � pass% = 8 � 10 � 2
�    P% = code%
�    L% = code% + len%
�    [OPT pass%


.init       EQUD  0
&".frame      EQUD  wave - code%
0.end        EQUD  0
:
D
N
X'.wave       STMFD R13!,{R0-R11,R14}
b            ]
l            � trigger% �
v              [OPT pass%
�<              TST   R11,#( 1 << (�("z") - �(trigger$)) )
�               BEQ   wave_end
�              ]
�            �
�            [OPT pass%
�
�            
�            LDR   R0,var%
�            CMP   R0,#y%
�            SUBGT R0,R0,#1
�            STR   R0,var%
�!            MOV   R1,R0,LSL#6
�$            ADD   R1,R1,R0,LSL#8
E            STR   R1,offset%        ; store scr_offset in offset%
F            STR   R12,screen%       ; store scr_address in screen%
D            ADD   R0,R12,#(320*256) ; r0=screen+((bottom+1)*320)
 >            STR   R0,max_scr%       ; store r0 in max_scr%
*;            LDR   R11,offset%       ; r11=screen_offset
4            
>D            MOV   R2,R0             ;  r2=maximum screen address
HA            ADD   R0,R1,R12         ;  r0=scr_offset+scr_addr
R8            MOV   R3,#0             ;  r3=black word
\B.word_loop  STR   R3,[R0],#320      ; put word at left of line
fB            CMP   R0,R2             ; is scr_addr < max_addr ?
pC            BLT   word_loop         ; if so, go to 'world_loop'
z
�A            ADD   R1,R12,R11        ; r1=screen+screen_offset
�@            STR   R1,water_pos%     ; store r1 in water_pos%
�?            SUB   R0,R1,#320        ; r0=addr of reflection
�D            MOV   R2,#h%            ; r2=number of rows of water
�D            LDR   R11,wave_pos%     ; r11=position in wave table
�A            ADD   R12,R11,#4        ; increment position by 4
�C            CMP   R12,#(h%*4)       ; if it has exceeded table,
�<            �Q R12,#0            ; then reset it to zero
�F            STR   R12,wave_pos%     ; store position in wave table
�E            ADR   R12,table%        ; r12=addr of wave data table
�D            ADR   R14,perspect%     ; r14=perspective table addr
�
�8            B     wave_1            ; go to 'wave_1'

C.table%     �array(4*h%)           ; water motion offsets table
B.perspect%  �array(4*h%)           ; perspective factors table
$
.8.wave_1     LDR   R4,[R12,R11]      ; r4=wave height
8B            SUBS  R11,R11,#4        ; move wave height pointer
B%            MOVMI R11,#((h%-1)*4)
L@            LDR   R5,[R14],#4       ; get perspective factor
V6            CMP   R5,#0             ; is it zero ?
`=            BEQ   zero              ; if so, go to 'zero'
jD            MUL   R6,R4,R5          ; r6=wave_height*perspective
t4            MOV   R6,R6,ASR#20      ; r6=r6>>>20
~@            CMP   R6,#0             ; is wave_height (r6) <0
�8            ADDLT R6,R6,#1          ; if so, r6=r6+1
�D            LDR   R1,water_pos%     ; r1=screen offset for water
�A            ADD   R1,R1,R6,LSL#6    ; r1=r1+(wave_height*320)
�$            ADD   R1,R1,R6,LSL#8
�C            LDR   R3,max_scr%       ; r3=maximum screen address
�?            CMP   R1,R3             ; does r1 exceed this ?
�5            BGE   exit              ; if so, exit
�6            B     skip              ; go to 'skip'
�
�<.zero       LDR   R1,offset%        ; when wave_height=0
�             LDR   R3,screen%
�B            ADD   R1,R1,R3          ; r1=screen_address+offset


B.skip       STR   R11,temp_wave%    ; store wave table pointer
<            LDR   R11,orr_word%     ; r11=byte �ing word
            
(            ]
2             � loop% = 1 � 10
<              [OPT pass%
F              
P9            LDMIA R0!,{R3-R10}      ; get screen data
Z?            �R   R3,R3,R11         ; set blue bits in words
d            �R   R4,R4,R11
n            �R   R5,R5,R11
x            �R   R6,R6,R11
�            �R   R7,R7,R11
�            �R   R8,R8,R11
�            �R   R9,R9,R11
�             �R   R10,R10,R11
�9            STMIA R1!,{R3-R10}      ; plot reflection
�            
�              ]
�            �
�            [OPT pass%
�            
�?            LDR   R11,temp_wave%    ; get wave pointer back
�B            SUB   R0,R0,#960        ; screen_position-=3 lines
�;            LDR   R1,water_pos%     ; r1=water_position
A            ADD   R1,R1,#320        ; add offset to next line
>            STR   R1,water_pos%     ; store water_position
8            SUBS  R2,R2,#1          ; another line ?
"?            BNE   wave_1            ; if so, go to 'wave_1'
,
6<.exit       LDR   R12,screen%       ; r12=screen address
@B            LDR   R0,offset%        ;  r0=water address offset
J4            ADD   R0,R0,R12         ;  r0=r0+r12
TD            LDR   R2,max_scr%       ;  r2=maximum screen address
^B.fill_loop  LDR   R3,[R0]           ; get word at left of line
hE            CMP   R3,#0             ; is it black (an empty line)
rC            BNE   move_fill         ; if not, go to 'move_fill'
|D            SUB   R1,R0,#320        ; r1=address of line to copy
�            
�            ]
�             � loop% = 1 � 10
�              [OPT pass%
�              
�@            LDMIA R1!,{R3-R10}      ; get data of line above
�@            STMIA R0!,{R3-R10}      ; store it in empty line
�            
�              ]
�            �
�            [OPT pass%
�            
�<            B     end_fill          ; jump to 'end_fill'
E.move_fill  ADD   R0,R0,#320        ; if not black goto next line
B.end_fill   CMP   R0,R2             ; is scr_addr < max_addr ?
B            BLT   fill_loop         ; if so, go to 'fill_loop'
&
0..wave_end   LDMFD R13!,{R0-R11,PC}  ; exit
:
D
N.var%       EQUD  start_y%
X.water_pos% EQUD  0
b.temp_wave% EQUD  0
l.screen%    EQUD  0
v.offset%    EQUD  y%*320
�.max_scr%   EQUD  0
�.wave_pos%  EQUD  0
�F.orr_word%  EQUD  orr% + (orr%*1<<8) + (orr%*1<<16) + (orr%*1<<24)
�
�
�	    ]
�  �
��
�
�
�
�� �array(size%)
�  P% += size%
= 0


 
*� �init
4
  � I%
>
H  � I% = 0 � (h% - 1)
R8    table%!(I%*4) = (h%/10) * ��(I% * (360/(h%/2)) )
\  �
f
p  � I% = 0 � (h% - 1)
z4    perspect%!(I%*4) = (I% / (h%-1)) * (1 << 20)
�  �
�
��
�
00000000  0d 00 0a 0c f4 20 3e 57  61 74 65 72 0d 00 14 04  |..... >Water....|
00000010  0d 00 1e 47 ee 20 85 20  c8 99 20 22 48 6f 75 72  |...G. . .. "Hour|
00000020  67 6c 61 73 73 5f 53 6d  61 73 68 22 3a 85 20 30  |glass_Smash":. 0|
00000030  2c 28 f6 24 2b 22 20 28  69 6e 74 65 72 6e 61 6c  |,(.$+" (internal|
00000040  20 65 72 72 6f 72 20 63  6f 64 65 20 22 2b c3 28  | error code "+.(|
00000050  9e 29 2b 22 29 22 29 0d  00 28 04 0d 00 32 17 f4  |.)+")")..(...2..|
00000060  20 46 69 78 65 64 20 76  61 72 69 61 62 6c 65 73  | Fixed variables|
00000070  20 3a 0d 00 3c 04 0d 00  46 25 20 20 f4 20 4e 6f  | :..<...F%  . No|
00000080  74 65 20 3a 20 68 25 2a  32 20 63 61 6e 6e 6f 74  |te : h%*2 cannot|
00000090  20 62 65 20 3e 74 6f 70  25 20 21 0d 00 50 04 0d  | be >top% !..P..|
000000a0  00 5a 14 20 20 74 72 69  67 67 65 72 24 20 3d 20  |.Z.  trigger$ = |
000000b0  22 7a 22 0d 00 64 12 20  20 74 72 69 67 67 65 72  |"z"..d.  trigger|
000000c0  25 20 3d 20 b9 0d 00 6e  04 0d 00 78 25 20 20 f4  |% = ...n...x%  .|
000000d0  20 79 20 70 6f 73 69 74  69 6f 6e 20 6f 66 20 77  | y position of w|
000000e0  61 74 65 72 20 69 6e 20  70 69 78 65 6c 73 0d 00  |ater in pixels..|
000000f0  82 14 20 20 79 25 20 20  20 20 20 20 20 3d 20 31  |..  y%       = 1|
00000100  37 30 0d 00 8c 04 0d 00  96 2c 20 20 f4 20 20 73  |70.......,  .  s|
00000110  74 61 72 74 20 79 20 70  6f 73 69 74 69 6f 6e 20  |tart y position |
00000120  6f 66 20 77 61 74 65 72  20 69 6e 20 70 69 78 65  |of water in pixe|
00000130  6c 73 0d 00 a0 14 20 20  73 74 61 72 74 5f 79 25  |ls....  start_y%|
00000140  20 3d 20 32 35 35 0d 00  aa 04 0d 00 b4 2b 20 20  | = 255.......+  |
00000150  f4 20 20 68 65 69 67 68  74 20 6f 66 20 77 61 74  |.  height of wat|
00000160  65 72 20 69 6e 20 70 69  78 65 6c 73 20 28 61 70  |er in pixels (ap|
00000170  70 72 6f 78 29 0d 00 be  17 20 20 68 25 20 20 20  |prox)....  h%   |
00000180  20 20 20 20 3d 20 28 79  25 2f 32 29 0d 00 c8 04  |    = (y%/2)....|
00000190  0d 00 d2 36 20 20 f4 20  20 62 79 74 65 3d 62 79  |...6  .  byte=by|
000001a0  74 65 20 4f 52 20 6f 72  72 25 2c 20 66 6f 72 20  |te OR orr%, for |
000001b0  65 76 65 72 79 20 70 69  78 65 6c 20 72 65 66 6c  |every pixel refl|
000001c0  65 63 74 65 64 2e 0d 00  dc 27 20 20 f4 20 20 69  |ected....'  .  i|
000001d0  6e 20 74 68 65 20 66 6f  72 6d 61 74 20 42 47 67  |n the format BGg|
000001e0  52 62 72 74 54 20 77 68  65 72 65 20 3a 0d 00 e6  |RbrtT where :...|
000001f0  2c 20 20 f4 20 20 52 20  3d 20 68 69 67 68 20 72  |,  .  R = high r|
00000200  65 64 20 62 69 74 2c 20  20 20 72 20 3d 20 6c 6f  |ed bit,   r = lo|
00000210  77 20 72 65 64 20 62 69  74 0d 00 f0 2e 20 20 f4  |w red bit....  .|
00000220  20 20 47 20 3d 20 68 69  67 68 20 67 72 65 65 6e  |  G = high green|
00000230  20 62 69 74 2c 20 67 20  3d 20 6c 6f 77 20 67 72  | bit, g = low gr|
00000240  65 65 6e 20 62 69 74 0d  00 fa 2d 20 20 f4 20 20  |een bit...-  .  |
00000250  42 20 3d 20 68 69 67 68  20 62 6c 75 65 20 62 69  |B = high blue bi|
00000260  74 2c 20 20 62 20 3d 20  6c 6f 77 20 62 6c 75 65  |t,  b = low blue|
00000270  20 62 69 74 0d 01 04 2d  20 20 f4 20 20 54 20 3d  | bit...-  .  T =|
00000280  20 68 69 67 68 20 74 69  6e 74 20 62 69 74 2c 20  | high tint bit, |
00000290  20 74 20 3d 20 6c 6f 77  20 74 69 6e 74 20 62 69  | t = low tint bi|
000002a0  74 0d 01 0e 1a 20 20 6f  72 72 25 20 20 20 20 20  |t....  orr%     |
000002b0  3d 20 25 31 30 30 30 31  30 30 30 0d 01 18 04 0d  |= %10001000.....|
000002c0  01 22 04 0d 01 2c 04 0d  01 36 15 6d 6f 64 75 6c  |."...,...6.modul|
000002d0  65 24 20 3d 20 22 57 61  74 65 72 22 0d 01 40 04  |e$ = "Water"..@.|
000002e0  0d 01 4a 15 c8 99 20 22  48 6f 75 72 67 6c 61 73  |..J... "Hourglas|
000002f0  73 5f 4f 6e 22 0d 01 54  0d f2 61 73 73 65 6d 62  |s_On"..T..assemb|
00000300  6c 65 0d 01 5e 09 f2 69  6e 69 74 0d 01 68 04 0d  |le..^..init..h..|
00000310  01 72 41 ff 22 53 41 56  45 20 20 20 20 3c 4d 6f  |.rA."SAVE    <Mo|
00000320  64 75 6c 65 73 24 44 69  72 3e 2e 22 2b 6d 6f 64  |dules$Dir>."+mod|
00000330  75 6c 65 24 2b 22 2e 4d  6f 64 75 6c 65 20 22 2b  |ule$+".Module "+|
00000340  c3 7e 63 6f 64 65 25 2b  22 20 22 2b c3 7e 50 25  |.~code%+" "+.~P%|
00000350  0d 01 7c 34 ff 22 53 45  54 54 59 50 45 20 3c 4d  |..|4."SETTYPE <M|
00000360  6f 64 75 6c 65 73 24 44  69 72 3e 2e 22 2b 6d 6f  |odules$Dir>."+mo|
00000370  64 75 6c 65 24 2b 22 2e  4d 6f 64 75 6c 65 20 44  |dule$+".Module D|
00000380  61 74 61 22 0d 01 86 04  0d 01 90 16 c8 99 20 22  |ata".......... "|
00000390  48 6f 75 72 67 6c 61 73  73 5f 4f 66 66 22 0d 01  |Hourglass_Off"..|
000003a0  9a 05 e0 0d 01 a4 04 0d  01 ae 04 0d 01 b8 04 0d  |................|
000003b0  01 c2 0f dd 20 f2 61 73  73 65 6d 62 6c 65 0d 01  |.... .assemble..|
000003c0  cc 15 20 20 6c 65 6e 25  20 3d 20 31 30 32 34 20  |..  len% = 1024 |
000003d0  2a 20 32 0d 01 d6 12 20  20 de 20 63 6f 64 65 25  |* 2....  . code%|
000003e0  20 6c 65 6e 25 0d 01 e0  1a 20 20 e3 20 70 61 73  | len%....  . pas|
000003f0  73 25 20 3d 20 38 20 b8  20 31 30 20 88 20 32 0d  |s% = 8 . 10 . 2.|
00000400  01 ea 12 20 20 20 20 50  25 20 3d 20 63 6f 64 65  |...    P% = code|
00000410  25 0d 01 f4 19 20 20 20  20 4c 25 20 3d 20 63 6f  |%....    L% = co|
00000420  64 65 25 20 2b 20 6c 65  6e 25 0d 01 fe 12 20 20  |de% + len%....  |
00000430  20 20 5b 4f 50 54 20 70  61 73 73 25 0d 02 08 04  |  [OPT pass%....|
00000440  0d 02 12 04 0d 02 1c 17  2e 69 6e 69 74 20 20 20  |.........init   |
00000450  20 20 20 20 45 51 55 44  20 20 30 0d 02 26 22 2e  |    EQUD  0..&".|
00000460  66 72 61 6d 65 20 20 20  20 20 20 45 51 55 44 20  |frame      EQUD |
00000470  20 77 61 76 65 20 2d 20  63 6f 64 65 25 0d 02 30  | wave - code%..0|
00000480  17 2e 65 6e 64 20 20 20  20 20 20 20 20 45 51 55  |..end        EQU|
00000490  44 20 20 30 0d 02 3a 04  0d 02 44 04 0d 02 4e 04  |D  0..:...D...N.|
000004a0  0d 02 58 27 2e 77 61 76  65 20 20 20 20 20 20 20  |..X'.wave       |
000004b0  53 54 4d 46 44 20 52 31  33 21 2c 7b 52 30 2d 52  |STMFD R13!,{R0-R|
000004c0  31 31 2c 52 31 34 7d 0d  02 62 11 20 20 20 20 20  |11,R14}..b.     |
000004d0  20 20 20 20 20 20 20 5d  0d 02 6c 1c 20 20 20 20  |       ]..l.    |
000004e0  20 20 20 20 20 20 20 20  e7 20 74 72 69 67 67 65  |        . trigge|
000004f0  72 25 20 8c 0d 02 76 1c  20 20 20 20 20 20 20 20  |r% ...v.        |
00000500  20 20 20 20 20 20 5b 4f  50 54 20 70 61 73 73 25  |      [OPT pass%|
00000510  0d 02 80 3c 20 20 20 20  20 20 20 20 20 20 20 20  |...<            |
00000520  20 20 54 53 54 20 20 20  52 31 31 2c 23 28 20 31  |  TST   R11,#( 1|
00000530  20 3c 3c 20 28 97 28 22  7a 22 29 20 2d 20 97 28  | << (.("z") - .(|
00000540  74 72 69 67 67 65 72 24  29 29 20 29 0d 02 8a 20  |trigger$)) )... |
00000550  20 20 20 20 20 20 20 20  20 20 20 20 20 20 42 45  |              BE|
00000560  51 20 20 20 77 61 76 65  5f 65 6e 64 0d 02 94 13  |Q   wave_end....|
00000570  20 20 20 20 20 20 20 20  20 20 20 20 20 20 5d 0d  |              ].|
00000580  02 9e 11 20 20 20 20 20  20 20 20 20 20 20 20 cd  |...            .|
00000590  0d 02 a8 1a 20 20 20 20  20 20 20 20 20 20 20 20  |....            |
000005a0  5b 4f 50 54 20 70 61 73  73 25 0d 02 b2 04 0d 02  |[OPT pass%......|
000005b0  bc 10 20 20 20 20 20 20  20 20 20 20 20 20 0d 02  |..            ..|
000005c0  c6 1d 20 20 20 20 20 20  20 20 20 20 20 20 4c 44  |..            LD|
000005d0  52 20 20 20 52 30 2c 76  61 72 25 0d 02 d0 1c 20  |R   R0,var%.... |
000005e0  20 20 20 20 20 20 20 20  20 20 20 43 4d 50 20 20  |           CMP  |
000005f0  20 52 30 2c 23 79 25 0d  02 da 1e 20 20 20 20 20  | R0,#y%....     |
00000600  20 20 20 20 20 20 20 53  55 42 47 54 20 52 30 2c  |       SUBGT R0,|
00000610  52 30 2c 23 31 0d 02 e4  1d 20 20 20 20 20 20 20  |R0,#1....       |
00000620  20 20 20 20 20 53 54 52  20 20 20 52 30 2c 76 61  |     STR   R0,va|
00000630  72 25 0d 02 ee 21 20 20  20 20 20 20 20 20 20 20  |r%...!          |
00000640  20 20 4d 4f 56 20 20 20  52 31 2c 52 30 2c 4c 53  |  MOV   R1,R0,LS|
00000650  4c 23 36 0d 02 f8 24 20  20 20 20 20 20 20 20 20  |L#6...$         |
00000660  20 20 20 41 44 44 20 20  20 52 31 2c 52 31 2c 52  |   ADD   R1,R1,R|
00000670  30 2c 4c 53 4c 23 38 0d  03 02 45 20 20 20 20 20  |0,LSL#8...E     |
00000680  20 20 20 20 20 20 20 53  54 52 20 20 20 52 31 2c  |       STR   R1,|
00000690  6f 66 66 73 65 74 25 20  20 20 20 20 20 20 20 3b  |offset%        ;|
000006a0  20 73 74 6f 72 65 20 73  63 72 5f 6f 66 66 73 65  | store scr_offse|
000006b0  74 20 69 6e 20 6f 66 66  73 65 74 25 0d 03 0c 46  |t in offset%...F|
000006c0  20 20 20 20 20 20 20 20  20 20 20 20 53 54 52 20  |            STR |
000006d0  20 20 52 31 32 2c 73 63  72 65 65 6e 25 20 20 20  |  R12,screen%   |
000006e0  20 20 20 20 3b 20 73 74  6f 72 65 20 73 63 72 5f  |    ; store scr_|
000006f0  61 64 64 72 65 73 73 20  69 6e 20 73 63 72 65 65  |address in scree|
00000700  6e 25 0d 03 16 44 20 20  20 20 20 20 20 20 20 20  |n%...D          |
00000710  20 20 41 44 44 20 20 20  52 30 2c 52 31 32 2c 23  |  ADD   R0,R12,#|
00000720  28 33 32 30 2a 32 35 36  29 20 3b 20 72 30 3d 73  |(320*256) ; r0=s|
00000730  63 72 65 65 6e 2b 28 28  62 6f 74 74 6f 6d 2b 31  |creen+((bottom+1|
00000740  29 2a 33 32 30 29 0d 03  20 3e 20 20 20 20 20 20  |)*320).. >      |
00000750  20 20 20 20 20 20 53 54  52 20 20 20 52 30 2c 6d  |      STR   R0,m|
00000760  61 78 5f 73 63 72 25 20  20 20 20 20 20 20 3b 20  |ax_scr%       ; |
00000770  73 74 6f 72 65 20 72 30  20 69 6e 20 6d 61 78 5f  |store r0 in max_|
00000780  73 63 72 25 0d 03 2a 3b  20 20 20 20 20 20 20 20  |scr%..*;        |
00000790  20 20 20 20 4c 44 52 20  20 20 52 31 31 2c 6f 66  |    LDR   R11,of|
000007a0  66 73 65 74 25 20 20 20  20 20 20 20 3b 20 72 31  |fset%       ; r1|
000007b0  31 3d 73 63 72 65 65 6e  5f 6f 66 66 73 65 74 0d  |1=screen_offset.|
000007c0  03 34 10 20 20 20 20 20  20 20 20 20 20 20 20 0d  |.4.            .|
000007d0  03 3e 44 20 20 20 20 20  20 20 20 20 20 20 20 4d  |.>D            M|
000007e0  4f 56 20 20 20 52 32 2c  52 30 20 20 20 20 20 20  |OV   R2,R0      |
000007f0  20 20 20 20 20 20 20 3b  20 20 72 32 3d 6d 61 78  |       ;  r2=max|
00000800  69 6d 75 6d 20 73 63 72  65 65 6e 20 61 64 64 72  |imum screen addr|
00000810  65 73 73 0d 03 48 41 20  20 20 20 20 20 20 20 20  |ess..HA         |
00000820  20 20 20 41 44 44 20 20  20 52 30 2c 52 31 2c 52  |   ADD   R0,R1,R|
00000830  31 32 20 20 20 20 20 20  20 20 20 3b 20 20 72 30  |12         ;  r0|
00000840  3d 73 63 72 5f 6f 66 66  73 65 74 2b 73 63 72 5f  |=scr_offset+scr_|
00000850  61 64 64 72 0d 03 52 38  20 20 20 20 20 20 20 20  |addr..R8        |
00000860  20 20 20 20 4d 4f 56 20  20 20 52 33 2c 23 30 20  |    MOV   R3,#0 |
00000870  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 20 72  |            ;  r|
00000880  33 3d 62 6c 61 63 6b 20  77 6f 72 64 0d 03 5c 42  |3=black word..\B|
00000890  2e 77 6f 72 64 5f 6c 6f  6f 70 20 20 53 54 52 20  |.word_loop  STR |
000008a0  20 20 52 33 2c 5b 52 30  5d 2c 23 33 32 30 20 20  |  R3,[R0],#320  |
000008b0  20 20 20 20 3b 20 70 75  74 20 77 6f 72 64 20 61  |    ; put word a|
000008c0  74 20 6c 65 66 74 20 6f  66 20 6c 69 6e 65 0d 03  |t left of line..|
000008d0  66 42 20 20 20 20 20 20  20 20 20 20 20 20 43 4d  |fB            CM|
000008e0  50 20 20 20 52 30 2c 52  32 20 20 20 20 20 20 20  |P   R0,R2       |
000008f0  20 20 20 20 20 20 3b 20  69 73 20 73 63 72 5f 61  |      ; is scr_a|
00000900  64 64 72 20 3c 20 6d 61  78 5f 61 64 64 72 20 3f  |ddr < max_addr ?|
00000910  0d 03 70 43 20 20 20 20  20 20 20 20 20 20 20 20  |..pC            |
00000920  42 4c 54 20 20 20 77 6f  72 64 5f 6c 6f 6f 70 20  |BLT   word_loop |
00000930  20 20 20 20 20 20 20 20  3b 20 69 66 20 73 6f 2c  |        ; if so,|
00000940  20 67 6f 20 74 6f 20 27  77 6f 72 6c 64 5f 6c 6f  | go to 'world_lo|
00000950  6f 70 27 0d 03 7a 04 0d  03 84 41 20 20 20 20 20  |op'..z....A     |
00000960  20 20 20 20 20 20 20 41  44 44 20 20 20 52 31 2c  |       ADD   R1,|
00000970  52 31 32 2c 52 31 31 20  20 20 20 20 20 20 20 3b  |R12,R11        ;|
00000980  20 72 31 3d 73 63 72 65  65 6e 2b 73 63 72 65 65  | r1=screen+scree|
00000990  6e 5f 6f 66 66 73 65 74  0d 03 8e 40 20 20 20 20  |n_offset...@    |
000009a0  20 20 20 20 20 20 20 20  53 54 52 20 20 20 52 31  |        STR   R1|
000009b0  2c 77 61 74 65 72 5f 70  6f 73 25 20 20 20 20 20  |,water_pos%     |
000009c0  3b 20 73 74 6f 72 65 20  72 31 20 69 6e 20 77 61  |; store r1 in wa|
000009d0  74 65 72 5f 70 6f 73 25  0d 03 98 3f 20 20 20 20  |ter_pos%...?    |
000009e0  20 20 20 20 20 20 20 20  53 55 42 20 20 20 52 30  |        SUB   R0|
000009f0  2c 52 31 2c 23 33 32 30  20 20 20 20 20 20 20 20  |,R1,#320        |
00000a00  3b 20 72 30 3d 61 64 64  72 20 6f 66 20 72 65 66  |; r0=addr of ref|
00000a10  6c 65 63 74 69 6f 6e 0d  03 a2 44 20 20 20 20 20  |lection...D     |
00000a20  20 20 20 20 20 20 20 4d  4f 56 20 20 20 52 32 2c  |       MOV   R2,|
00000a30  23 68 25 20 20 20 20 20  20 20 20 20 20 20 20 3b  |#h%            ;|
00000a40  20 72 32 3d 6e 75 6d 62  65 72 20 6f 66 20 72 6f  | r2=number of ro|
00000a50  77 73 20 6f 66 20 77 61  74 65 72 0d 03 ac 44 20  |ws of water...D |
00000a60  20 20 20 20 20 20 20 20  20 20 20 4c 44 52 20 20  |           LDR  |
00000a70  20 52 31 31 2c 77 61 76  65 5f 70 6f 73 25 20 20  | R11,wave_pos%  |
00000a80  20 20 20 3b 20 72 31 31  3d 70 6f 73 69 74 69 6f  |   ; r11=positio|
00000a90  6e 20 69 6e 20 77 61 76  65 20 74 61 62 6c 65 0d  |n in wave table.|
00000aa0  03 b6 41 20 20 20 20 20  20 20 20 20 20 20 20 41  |..A            A|
00000ab0  44 44 20 20 20 52 31 32  2c 52 31 31 2c 23 34 20  |DD   R12,R11,#4 |
00000ac0  20 20 20 20 20 20 20 3b  20 69 6e 63 72 65 6d 65  |       ; increme|
00000ad0  6e 74 20 70 6f 73 69 74  69 6f 6e 20 62 79 20 34  |nt position by 4|
00000ae0  0d 03 c0 43 20 20 20 20  20 20 20 20 20 20 20 20  |...C            |
00000af0  43 4d 50 20 20 20 52 31  32 2c 23 28 68 25 2a 34  |CMP   R12,#(h%*4|
00000b00  29 20 20 20 20 20 20 20  3b 20 69 66 20 69 74 20  |)       ; if it |
00000b10  68 61 73 20 65 78 63 65  65 64 65 64 20 74 61 62  |has exceeded tab|
00000b20  6c 65 2c 0d 03 ca 3c 20  20 20 20 20 20 20 20 20  |le,...<         |
00000b30  20 20 20 ec 51 20 52 31  32 2c 23 30 20 20 20 20  |   .Q R12,#0    |
00000b40  20 20 20 20 20 20 20 20  3b 20 74 68 65 6e 20 72  |        ; then r|
00000b50  65 73 65 74 20 69 74 20  74 6f 20 7a 65 72 6f 0d  |eset it to zero.|
00000b60  03 d4 46 20 20 20 20 20  20 20 20 20 20 20 20 53  |..F            S|
00000b70  54 52 20 20 20 52 31 32  2c 77 61 76 65 5f 70 6f  |TR   R12,wave_po|
00000b80  73 25 20 20 20 20 20 3b  20 73 74 6f 72 65 20 70  |s%     ; store p|
00000b90  6f 73 69 74 69 6f 6e 20  69 6e 20 77 61 76 65 20  |osition in wave |
00000ba0  74 61 62 6c 65 0d 03 de  45 20 20 20 20 20 20 20  |table...E       |
00000bb0  20 20 20 20 20 41 44 52  20 20 20 52 31 32 2c 74  |     ADR   R12,t|
00000bc0  61 62 6c 65 25 20 20 20  20 20 20 20 20 3b 20 72  |able%        ; r|
00000bd0  31 32 3d 61 64 64 72 20  6f 66 20 77 61 76 65 20  |12=addr of wave |
00000be0  64 61 74 61 20 74 61 62  6c 65 0d 03 e8 44 20 20  |data table...D  |
00000bf0  20 20 20 20 20 20 20 20  20 20 41 44 52 20 20 20  |          ADR   |
00000c00  52 31 34 2c 70 65 72 73  70 65 63 74 25 20 20 20  |R14,perspect%   |
00000c10  20 20 3b 20 72 31 34 3d  70 65 72 73 70 65 63 74  |  ; r14=perspect|
00000c20  69 76 65 20 74 61 62 6c  65 20 61 64 64 72 0d 03  |ive table addr..|
00000c30  f2 04 0d 03 fc 38 20 20  20 20 20 20 20 20 20 20  |.....8          |
00000c40  20 20 42 20 20 20 20 20  77 61 76 65 5f 31 20 20  |  B     wave_1  |
00000c50  20 20 20 20 20 20 20 20  20 20 3b 20 67 6f 20 74  |          ; go t|
00000c60  6f 20 27 77 61 76 65 5f  31 27 0d 04 06 04 0d 04  |o 'wave_1'......|
00000c70  10 43 2e 74 61 62 6c 65  25 20 20 20 20 20 a4 61  |.C.table%     .a|
00000c80  72 72 61 79 28 34 2a 68  25 29 20 20 20 20 20 20  |rray(4*h%)      |
00000c90  20 20 20 20 20 3b 20 77  61 74 65 72 20 6d 6f 74  |     ; water mot|
00000ca0  69 6f 6e 20 6f 66 66 73  65 74 73 20 74 61 62 6c  |ion offsets tabl|
00000cb0  65 0d 04 1a 42 2e 70 65  72 73 70 65 63 74 25 20  |e...B.perspect% |
00000cc0  20 a4 61 72 72 61 79 28  34 2a 68 25 29 20 20 20  | .array(4*h%)   |
00000cd0  20 20 20 20 20 20 20 20  3b 20 70 65 72 73 70 65  |        ; perspe|
00000ce0  63 74 69 76 65 20 66 61  63 74 6f 72 73 20 74 61  |ctive factors ta|
00000cf0  62 6c 65 0d 04 24 04 0d  04 2e 38 2e 77 61 76 65  |ble..$....8.wave|
00000d00  5f 31 20 20 20 20 20 4c  44 52 20 20 20 52 34 2c  |_1     LDR   R4,|
00000d10  5b 52 31 32 2c 52 31 31  5d 20 20 20 20 20 20 3b  |[R12,R11]      ;|
00000d20  20 72 34 3d 77 61 76 65  20 68 65 69 67 68 74 0d  | r4=wave height.|
00000d30  04 38 42 20 20 20 20 20  20 20 20 20 20 20 20 53  |.8B            S|
00000d40  55 42 53 20 20 52 31 31  2c 52 31 31 2c 23 34 20  |UBS  R11,R11,#4 |
00000d50  20 20 20 20 20 20 20 3b  20 6d 6f 76 65 20 77 61  |       ; move wa|
00000d60  76 65 20 68 65 69 67 68  74 20 70 6f 69 6e 74 65  |ve height pointe|
00000d70  72 0d 04 42 25 20 20 20  20 20 20 20 20 20 20 20  |r..B%           |
00000d80  20 4d 4f 56 4d 49 20 52  31 31 2c 23 28 28 68 25  | MOVMI R11,#((h%|
00000d90  2d 31 29 2a 34 29 0d 04  4c 40 20 20 20 20 20 20  |-1)*4)..L@      |
00000da0  20 20 20 20 20 20 4c 44  52 20 20 20 52 35 2c 5b  |      LDR   R5,[|
00000db0  52 31 34 5d 2c 23 34 20  20 20 20 20 20 20 3b 20  |R14],#4       ; |
00000dc0  67 65 74 20 70 65 72 73  70 65 63 74 69 76 65 20  |get perspective |
00000dd0  66 61 63 74 6f 72 0d 04  56 36 20 20 20 20 20 20  |factor..V6      |
00000de0  20 20 20 20 20 20 43 4d  50 20 20 20 52 35 2c 23  |      CMP   R5,#|
00000df0  30 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |0             ; |
00000e00  69 73 20 69 74 20 7a 65  72 6f 20 3f 0d 04 60 3d  |is it zero ?..`=|
00000e10  20 20 20 20 20 20 20 20  20 20 20 20 42 45 51 20  |            BEQ |
00000e20  20 20 7a 65 72 6f 20 20  20 20 20 20 20 20 20 20  |  zero          |
00000e30  20 20 20 20 3b 20 69 66  20 73 6f 2c 20 67 6f 20  |    ; if so, go |
00000e40  74 6f 20 27 7a 65 72 6f  27 0d 04 6a 44 20 20 20  |to 'zero'..jD   |
00000e50  20 20 20 20 20 20 20 20  20 4d 55 4c 20 20 20 52  |         MUL   R|
00000e60  36 2c 52 34 2c 52 35 20  20 20 20 20 20 20 20 20  |6,R4,R5         |
00000e70  20 3b 20 72 36 3d 77 61  76 65 5f 68 65 69 67 68  | ; r6=wave_heigh|
00000e80  74 2a 70 65 72 73 70 65  63 74 69 76 65 0d 04 74  |t*perspective..t|
00000e90  34 20 20 20 20 20 20 20  20 20 20 20 20 4d 4f 56  |4            MOV|
00000ea0  20 20 20 52 36 2c 52 36  2c 41 53 52 23 32 30 20  |   R6,R6,ASR#20 |
00000eb0  20 20 20 20 20 3b 20 72  36 3d 72 36 3e 3e 3e 32  |     ; r6=r6>>>2|
00000ec0  30 0d 04 7e 40 20 20 20  20 20 20 20 20 20 20 20  |0..~@           |
00000ed0  20 43 4d 50 20 20 20 52  36 2c 23 30 20 20 20 20  | CMP   R6,#0    |
00000ee0  20 20 20 20 20 20 20 20  20 3b 20 69 73 20 77 61  |         ; is wa|
00000ef0  76 65 5f 68 65 69 67 68  74 20 28 72 36 29 20 3c  |ve_height (r6) <|
00000f00  30 0d 04 88 38 20 20 20  20 20 20 20 20 20 20 20  |0...8           |
00000f10  20 41 44 44 4c 54 20 52  36 2c 52 36 2c 23 31 20  | ADDLT R6,R6,#1 |
00000f20  20 20 20 20 20 20 20 20  20 3b 20 69 66 20 73 6f  |         ; if so|
00000f30  2c 20 72 36 3d 72 36 2b  31 0d 04 92 44 20 20 20  |, r6=r6+1...D   |
00000f40  20 20 20 20 20 20 20 20  20 4c 44 52 20 20 20 52  |         LDR   R|
00000f50  31 2c 77 61 74 65 72 5f  70 6f 73 25 20 20 20 20  |1,water_pos%    |
00000f60  20 3b 20 72 31 3d 73 63  72 65 65 6e 20 6f 66 66  | ; r1=screen off|
00000f70  73 65 74 20 66 6f 72 20  77 61 74 65 72 0d 04 9c  |set for water...|
00000f80  41 20 20 20 20 20 20 20  20 20 20 20 20 41 44 44  |A            ADD|
00000f90  20 20 20 52 31 2c 52 31  2c 52 36 2c 4c 53 4c 23  |   R1,R1,R6,LSL#|
00000fa0  36 20 20 20 20 3b 20 72  31 3d 72 31 2b 28 77 61  |6    ; r1=r1+(wa|
00000fb0  76 65 5f 68 65 69 67 68  74 2a 33 32 30 29 0d 04  |ve_height*320)..|
00000fc0  a6 24 20 20 20 20 20 20  20 20 20 20 20 20 41 44  |.$            AD|
00000fd0  44 20 20 20 52 31 2c 52  31 2c 52 36 2c 4c 53 4c  |D   R1,R1,R6,LSL|
00000fe0  23 38 0d 04 b0 43 20 20  20 20 20 20 20 20 20 20  |#8...C          |
00000ff0  20 20 4c 44 52 20 20 20  52 33 2c 6d 61 78 5f 73  |  LDR   R3,max_s|
00001000  63 72 25 20 20 20 20 20  20 20 3b 20 72 33 3d 6d  |cr%       ; r3=m|
00001010  61 78 69 6d 75 6d 20 73  63 72 65 65 6e 20 61 64  |aximum screen ad|
00001020  64 72 65 73 73 0d 04 ba  3f 20 20 20 20 20 20 20  |dress...?       |
00001030  20 20 20 20 20 43 4d 50  20 20 20 52 31 2c 52 33  |     CMP   R1,R3|
00001040  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 64  |             ; d|
00001050  6f 65 73 20 72 31 20 65  78 63 65 65 64 20 74 68  |oes r1 exceed th|
00001060  69 73 20 3f 0d 04 c4 35  20 20 20 20 20 20 20 20  |is ?...5        |
00001070  20 20 20 20 42 47 45 20  20 20 65 78 69 74 20 20  |    BGE   exit  |
00001080  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 69 66  |            ; if|
00001090  20 73 6f 2c 20 65 78 69  74 0d 04 ce 36 20 20 20  | so, exit...6   |
000010a0  20 20 20 20 20 20 20 20  20 42 20 20 20 20 20 73  |         B     s|
000010b0  6b 69 70 20 20 20 20 20  20 20 20 20 20 20 20 20  |kip             |
000010c0  20 3b 20 67 6f 20 74 6f  20 27 73 6b 69 70 27 0d  | ; go to 'skip'.|
000010d0  04 d8 04 0d 04 e2 3c 2e  7a 65 72 6f 20 20 20 20  |......<.zero    |
000010e0  20 20 20 4c 44 52 20 20  20 52 31 2c 6f 66 66 73  |   LDR   R1,offs|
000010f0  65 74 25 20 20 20 20 20  20 20 20 3b 20 77 68 65  |et%        ; whe|
00001100  6e 20 77 61 76 65 5f 68  65 69 67 68 74 3d 30 0d  |n wave_height=0.|
00001110  04 ec 20 20 20 20 20 20  20 20 20 20 20 20 20 4c  |..             L|
00001120  44 52 20 20 20 52 33 2c  73 63 72 65 65 6e 25 0d  |DR   R3,screen%.|
00001130  04 f6 42 20 20 20 20 20  20 20 20 20 20 20 20 41  |..B            A|
00001140  44 44 20 20 20 52 31 2c  52 31 2c 52 33 20 20 20  |DD   R1,R1,R3   |
00001150  20 20 20 20 20 20 20 3b  20 72 31 3d 73 63 72 65  |       ; r1=scre|
00001160  65 6e 5f 61 64 64 72 65  73 73 2b 6f 66 66 73 65  |en_address+offse|
00001170  74 0d 05 00 04 0d 05 0a  42 2e 73 6b 69 70 20 20  |t.......B.skip  |
00001180  20 20 20 20 20 53 54 52  20 20 20 52 31 31 2c 74  |     STR   R11,t|
00001190  65 6d 70 5f 77 61 76 65  25 20 20 20 20 3b 20 73  |emp_wave%    ; s|
000011a0  74 6f 72 65 20 77 61 76  65 20 74 61 62 6c 65 20  |tore wave table |
000011b0  70 6f 69 6e 74 65 72 0d  05 14 3c 20 20 20 20 20  |pointer...<     |
000011c0  20 20 20 20 20 20 20 4c  44 52 20 20 20 52 31 31  |       LDR   R11|
000011d0  2c 6f 72 72 5f 77 6f 72  64 25 20 20 20 20 20 3b  |,orr_word%     ;|
000011e0  20 72 31 31 3d 62 79 74  65 20 84 69 6e 67 20 77  | r11=byte .ing w|
000011f0  6f 72 64 0d 05 1e 10 20  20 20 20 20 20 20 20 20  |ord....         |
00001200  20 20 20 0d 05 28 11 20  20 20 20 20 20 20 20 20  |   ..(.         |
00001210  20 20 20 5d 0d 05 32 20  20 20 20 20 20 20 20 20  |   ]..2         |
00001220  20 20 20 20 e3 20 6c 6f  6f 70 25 20 3d 20 31 20  |    . loop% = 1 |
00001230  b8 20 31 30 0d 05 3c 1c  20 20 20 20 20 20 20 20  |. 10..<.        |
00001240  20 20 20 20 20 20 5b 4f  50 54 20 70 61 73 73 25  |      [OPT pass%|
00001250  0d 05 46 12 20 20 20 20  20 20 20 20 20 20 20 20  |..F.            |
00001260  20 20 0d 05 50 39 20 20  20 20 20 20 20 20 20 20  |  ..P9          |
00001270  20 20 4c 44 4d 49 41 20  52 30 21 2c 7b 52 33 2d  |  LDMIA R0!,{R3-|
00001280  52 31 30 7d 20 20 20 20  20 20 3b 20 67 65 74 20  |R10}      ; get |
00001290  73 63 72 65 65 6e 20 64  61 74 61 0d 05 5a 3f 20  |screen data..Z? |
000012a0  20 20 20 20 20 20 20 20  20 20 20 84 52 20 20 20  |           .R   |
000012b0  52 33 2c 52 33 2c 52 31  31 20 20 20 20 20 20 20  |R3,R3,R11       |
000012c0  20 20 3b 20 73 65 74 20  62 6c 75 65 20 62 69 74  |  ; set blue bit|
000012d0  73 20 69 6e 20 77 6f 72  64 73 0d 05 64 1e 20 20  |s in words..d.  |
000012e0  20 20 20 20 20 20 20 20  20 20 84 52 20 20 20 52  |          .R   R|
000012f0  34 2c 52 34 2c 52 31 31  0d 05 6e 1e 20 20 20 20  |4,R4,R11..n.    |
00001300  20 20 20 20 20 20 20 20  84 52 20 20 20 52 35 2c  |        .R   R5,|
00001310  52 35 2c 52 31 31 0d 05  78 1e 20 20 20 20 20 20  |R5,R11..x.      |
00001320  20 20 20 20 20 20 84 52  20 20 20 52 36 2c 52 36  |      .R   R6,R6|
00001330  2c 52 31 31 0d 05 82 1e  20 20 20 20 20 20 20 20  |,R11....        |
00001340  20 20 20 20 84 52 20 20  20 52 37 2c 52 37 2c 52  |    .R   R7,R7,R|
00001350  31 31 0d 05 8c 1e 20 20  20 20 20 20 20 20 20 20  |11....          |
00001360  20 20 84 52 20 20 20 52  38 2c 52 38 2c 52 31 31  |  .R   R8,R8,R11|
00001370  0d 05 96 1e 20 20 20 20  20 20 20 20 20 20 20 20  |....            |
00001380  84 52 20 20 20 52 39 2c  52 39 2c 52 31 31 0d 05  |.R   R9,R9,R11..|
00001390  a0 20 20 20 20 20 20 20  20 20 20 20 20 20 84 52  |.             .R|
000013a0  20 20 20 52 31 30 2c 52  31 30 2c 52 31 31 0d 05  |   R10,R10,R11..|
000013b0  aa 39 20 20 20 20 20 20  20 20 20 20 20 20 53 54  |.9            ST|
000013c0  4d 49 41 20 52 31 21 2c  7b 52 33 2d 52 31 30 7d  |MIA R1!,{R3-R10}|
000013d0  20 20 20 20 20 20 3b 20  70 6c 6f 74 20 72 65 66  |      ; plot ref|
000013e0  6c 65 63 74 69 6f 6e 0d  05 b4 10 20 20 20 20 20  |lection....     |
000013f0  20 20 20 20 20 20 20 0d  05 be 13 20 20 20 20 20  |       ....     |
00001400  20 20 20 20 20 20 20 20  20 5d 0d 05 c8 11 20 20  |         ]....  |
00001410  20 20 20 20 20 20 20 20  20 20 ed 0d 05 d2 1a 20  |          ..... |
00001420  20 20 20 20 20 20 20 20  20 20 20 5b 4f 50 54 20  |           [OPT |
00001430  70 61 73 73 25 0d 05 dc  10 20 20 20 20 20 20 20  |pass%....       |
00001440  20 20 20 20 20 0d 05 e6  3f 20 20 20 20 20 20 20  |     ...?       |
00001450  20 20 20 20 20 4c 44 52  20 20 20 52 31 31 2c 74  |     LDR   R11,t|
00001460  65 6d 70 5f 77 61 76 65  25 20 20 20 20 3b 20 67  |emp_wave%    ; g|
00001470  65 74 20 77 61 76 65 20  70 6f 69 6e 74 65 72 20  |et wave pointer |
00001480  62 61 63 6b 0d 05 f0 42  20 20 20 20 20 20 20 20  |back...B        |
00001490  20 20 20 20 53 55 42 20  20 20 52 30 2c 52 30 2c  |    SUB   R0,R0,|
000014a0  23 39 36 30 20 20 20 20  20 20 20 20 3b 20 73 63  |#960        ; sc|
000014b0  72 65 65 6e 5f 70 6f 73  69 74 69 6f 6e 2d 3d 33  |reen_position-=3|
000014c0  20 6c 69 6e 65 73 0d 05  fa 3b 20 20 20 20 20 20  | lines...;      |
000014d0  20 20 20 20 20 20 4c 44  52 20 20 20 52 31 2c 77  |      LDR   R1,w|
000014e0  61 74 65 72 5f 70 6f 73  25 20 20 20 20 20 3b 20  |ater_pos%     ; |
000014f0  72 31 3d 77 61 74 65 72  5f 70 6f 73 69 74 69 6f  |r1=water_positio|
00001500  6e 0d 06 04 41 20 20 20  20 20 20 20 20 20 20 20  |n...A           |
00001510  20 41 44 44 20 20 20 52  31 2c 52 31 2c 23 33 32  | ADD   R1,R1,#32|
00001520  30 20 20 20 20 20 20 20  20 3b 20 61 64 64 20 6f  |0        ; add o|
00001530  66 66 73 65 74 20 74 6f  20 6e 65 78 74 20 6c 69  |ffset to next li|
00001540  6e 65 0d 06 0e 3e 20 20  20 20 20 20 20 20 20 20  |ne...>          |
00001550  20 20 53 54 52 20 20 20  52 31 2c 77 61 74 65 72  |  STR   R1,water|
00001560  5f 70 6f 73 25 20 20 20  20 20 3b 20 73 74 6f 72  |_pos%     ; stor|
00001570  65 20 77 61 74 65 72 5f  70 6f 73 69 74 69 6f 6e  |e water_position|
00001580  0d 06 18 38 20 20 20 20  20 20 20 20 20 20 20 20  |...8            |
00001590  53 55 42 53 20 20 52 32  2c 52 32 2c 23 31 20 20  |SUBS  R2,R2,#1  |
000015a0  20 20 20 20 20 20 20 20  3b 20 61 6e 6f 74 68 65  |        ; anothe|
000015b0  72 20 6c 69 6e 65 20 3f  0d 06 22 3f 20 20 20 20  |r line ?.."?    |
000015c0  20 20 20 20 20 20 20 20  42 4e 45 20 20 20 77 61  |        BNE   wa|
000015d0  76 65 5f 31 20 20 20 20  20 20 20 20 20 20 20 20  |ve_1            |
000015e0  3b 20 69 66 20 73 6f 2c  20 67 6f 20 74 6f 20 27  |; if so, go to '|
000015f0  77 61 76 65 5f 31 27 0d  06 2c 04 0d 06 36 3c 2e  |wave_1'..,...6<.|
00001600  65 78 69 74 20 20 20 20  20 20 20 4c 44 52 20 20  |exit       LDR  |
00001610  20 52 31 32 2c 73 63 72  65 65 6e 25 20 20 20 20  | R12,screen%    |
00001620  20 20 20 3b 20 72 31 32  3d 73 63 72 65 65 6e 20  |   ; r12=screen |
00001630  61 64 64 72 65 73 73 0d  06 40 42 20 20 20 20 20  |address..@B     |
00001640  20 20 20 20 20 20 20 4c  44 52 20 20 20 52 30 2c  |       LDR   R0,|
00001650  6f 66 66 73 65 74 25 20  20 20 20 20 20 20 20 3b  |offset%        ;|
00001660  20 20 72 30 3d 77 61 74  65 72 20 61 64 64 72 65  |  r0=water addre|
00001670  73 73 20 6f 66 66 73 65  74 0d 06 4a 34 20 20 20  |ss offset..J4   |
00001680  20 20 20 20 20 20 20 20  20 41 44 44 20 20 20 52  |         ADD   R|
00001690  30 2c 52 30 2c 52 31 32  20 20 20 20 20 20 20 20  |0,R0,R12        |
000016a0  20 3b 20 20 72 30 3d 72  30 2b 72 31 32 0d 06 54  | ;  r0=r0+r12..T|
000016b0  44 20 20 20 20 20 20 20  20 20 20 20 20 4c 44 52  |D            LDR|
000016c0  20 20 20 52 32 2c 6d 61  78 5f 73 63 72 25 20 20  |   R2,max_scr%  |
000016d0  20 20 20 20 20 3b 20 20  72 32 3d 6d 61 78 69 6d  |     ;  r2=maxim|
000016e0  75 6d 20 73 63 72 65 65  6e 20 61 64 64 72 65 73  |um screen addres|
000016f0  73 0d 06 5e 42 2e 66 69  6c 6c 5f 6c 6f 6f 70 20  |s..^B.fill_loop |
00001700  20 4c 44 52 20 20 20 52  33 2c 5b 52 30 5d 20 20  | LDR   R3,[R0]  |
00001710  20 20 20 20 20 20 20 20  20 3b 20 67 65 74 20 77  |         ; get w|
00001720  6f 72 64 20 61 74 20 6c  65 66 74 20 6f 66 20 6c  |ord at left of l|
00001730  69 6e 65 0d 06 68 45 20  20 20 20 20 20 20 20 20  |ine..hE         |
00001740  20 20 20 43 4d 50 20 20  20 52 33 2c 23 30 20 20  |   CMP   R3,#0  |
00001750  20 20 20 20 20 20 20 20  20 20 20 3b 20 69 73 20  |           ; is |
00001760  69 74 20 62 6c 61 63 6b  20 28 61 6e 20 65 6d 70  |it black (an emp|
00001770  74 79 20 6c 69 6e 65 29  0d 06 72 43 20 20 20 20  |ty line)..rC    |
00001780  20 20 20 20 20 20 20 20  42 4e 45 20 20 20 6d 6f  |        BNE   mo|
00001790  76 65 5f 66 69 6c 6c 20  20 20 20 20 20 20 20 20  |ve_fill         |
000017a0  3b 20 69 66 20 6e 6f 74  2c 20 67 6f 20 74 6f 20  |; if not, go to |
000017b0  27 6d 6f 76 65 5f 66 69  6c 6c 27 0d 06 7c 44 20  |'move_fill'..|D |
000017c0  20 20 20 20 20 20 20 20  20 20 20 53 55 42 20 20  |           SUB  |
000017d0  20 52 31 2c 52 30 2c 23  33 32 30 20 20 20 20 20  | R1,R0,#320     |
000017e0  20 20 20 3b 20 72 31 3d  61 64 64 72 65 73 73 20  |   ; r1=address |
000017f0  6f 66 20 6c 69 6e 65 20  74 6f 20 63 6f 70 79 0d  |of line to copy.|
00001800  06 86 10 20 20 20 20 20  20 20 20 20 20 20 20 0d  |...            .|
00001810  06 90 11 20 20 20 20 20  20 20 20 20 20 20 20 5d  |...            ]|
00001820  0d 06 9a 20 20 20 20 20  20 20 20 20 20 20 20 20  |...             |
00001830  e3 20 6c 6f 6f 70 25 20  3d 20 31 20 b8 20 31 30  |. loop% = 1 . 10|
00001840  0d 06 a4 1c 20 20 20 20  20 20 20 20 20 20 20 20  |....            |
00001850  20 20 5b 4f 50 54 20 70  61 73 73 25 0d 06 ae 12  |  [OPT pass%....|
00001860  20 20 20 20 20 20 20 20  20 20 20 20 20 20 0d 06  |              ..|
00001870  b8 40 20 20 20 20 20 20  20 20 20 20 20 20 4c 44  |.@            LD|
00001880  4d 49 41 20 52 31 21 2c  7b 52 33 2d 52 31 30 7d  |MIA R1!,{R3-R10}|
00001890  20 20 20 20 20 20 3b 20  67 65 74 20 64 61 74 61  |      ; get data|
000018a0  20 6f 66 20 6c 69 6e 65  20 61 62 6f 76 65 0d 06  | of line above..|
000018b0  c2 40 20 20 20 20 20 20  20 20 20 20 20 20 53 54  |.@            ST|
000018c0  4d 49 41 20 52 30 21 2c  7b 52 33 2d 52 31 30 7d  |MIA R0!,{R3-R10}|
000018d0  20 20 20 20 20 20 3b 20  73 74 6f 72 65 20 69 74  |      ; store it|
000018e0  20 69 6e 20 65 6d 70 74  79 20 6c 69 6e 65 0d 06  | in empty line..|
000018f0  cc 10 20 20 20 20 20 20  20 20 20 20 20 20 0d 06  |..            ..|
00001900  d6 13 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |..              |
00001910  5d 0d 06 e0 11 20 20 20  20 20 20 20 20 20 20 20  |]....           |
00001920  20 ed 0d 06 ea 1a 20 20  20 20 20 20 20 20 20 20  | .....          |
00001930  20 20 5b 4f 50 54 20 70  61 73 73 25 0d 06 f4 10  |  [OPT pass%....|
00001940  20 20 20 20 20 20 20 20  20 20 20 20 0d 06 fe 3c  |            ...<|
00001950  20 20 20 20 20 20 20 20  20 20 20 20 42 20 20 20  |            B   |
00001960  20 20 65 6e 64 5f 66 69  6c 6c 20 20 20 20 20 20  |  end_fill      |
00001970  20 20 20 20 3b 20 6a 75  6d 70 20 74 6f 20 27 65  |    ; jump to 'e|
00001980  6e 64 5f 66 69 6c 6c 27  0d 07 08 45 2e 6d 6f 76  |nd_fill'...E.mov|
00001990  65 5f 66 69 6c 6c 20 20  41 44 44 20 20 20 52 30  |e_fill  ADD   R0|
000019a0  2c 52 30 2c 23 33 32 30  20 20 20 20 20 20 20 20  |,R0,#320        |
000019b0  3b 20 69 66 20 6e 6f 74  20 62 6c 61 63 6b 20 67  |; if not black g|
000019c0  6f 74 6f 20 6e 65 78 74  20 6c 69 6e 65 0d 07 12  |oto next line...|
000019d0  42 2e 65 6e 64 5f 66 69  6c 6c 20 20 20 43 4d 50  |B.end_fill   CMP|
000019e0  20 20 20 52 30 2c 52 32  20 20 20 20 20 20 20 20  |   R0,R2        |
000019f0  20 20 20 20 20 3b 20 69  73 20 73 63 72 5f 61 64  |     ; is scr_ad|
00001a00  64 72 20 3c 20 6d 61 78  5f 61 64 64 72 20 3f 0d  |dr < max_addr ?.|
00001a10  07 1c 42 20 20 20 20 20  20 20 20 20 20 20 20 42  |..B            B|
00001a20  4c 54 20 20 20 66 69 6c  6c 5f 6c 6f 6f 70 20 20  |LT   fill_loop  |
00001a30  20 20 20 20 20 20 20 3b  20 69 66 20 73 6f 2c 20  |       ; if so, |
00001a40  67 6f 20 74 6f 20 27 66  69 6c 6c 5f 6c 6f 6f 70  |go to 'fill_loop|
00001a50  27 0d 07 26 04 0d 07 30  2e 2e 77 61 76 65 5f 65  |'..&...0..wave_e|
00001a60  6e 64 20 20 20 4c 44 4d  46 44 20 52 31 33 21 2c  |nd   LDMFD R13!,|
00001a70  7b 52 30 2d 52 31 31 2c  50 43 7d 20 20 3b 20 65  |{R0-R11,PC}  ; e|
00001a80  78 69 74 0d 07 3a 04 0d  07 44 04 0d 07 4e 1e 2e  |xit..:...D...N..|
00001a90  76 61 72 25 20 20 20 20  20 20 20 45 51 55 44 20  |var%       EQUD |
00001aa0  20 73 74 61 72 74 5f 79  25 0d 07 58 17 2e 77 61  | start_y%..X..wa|
00001ab0  74 65 72 5f 70 6f 73 25  20 45 51 55 44 20 20 30  |ter_pos% EQUD  0|
00001ac0  0d 07 62 17 2e 74 65 6d  70 5f 77 61 76 65 25 20  |..b..temp_wave% |
00001ad0  45 51 55 44 20 20 30 0d  07 6c 17 2e 73 63 72 65  |EQUD  0..l..scre|
00001ae0  65 6e 25 20 20 20 20 45  51 55 44 20 20 30 0d 07  |en%    EQUD  0..|
00001af0  76 1c 2e 6f 66 66 73 65  74 25 20 20 20 20 45 51  |v..offset%    EQ|
00001b00  55 44 20 20 79 25 2a 33  32 30 0d 07 80 17 2e 6d  |UD  y%*320.....m|
00001b10  61 78 5f 73 63 72 25 20  20 20 45 51 55 44 20 20  |ax_scr%   EQUD  |
00001b20  30 0d 07 8a 17 2e 77 61  76 65 5f 70 6f 73 25 20  |0.....wave_pos% |
00001b30  20 45 51 55 44 20 20 30  0d 07 94 46 2e 6f 72 72  | EQUD  0...F.orr|
00001b40  5f 77 6f 72 64 25 20 20  45 51 55 44 20 20 6f 72  |_word%  EQUD  or|
00001b50  72 25 20 2b 20 28 6f 72  72 25 2a 31 3c 3c 38 29  |r% + (orr%*1<<8)|
00001b60  20 2b 20 28 6f 72 72 25  2a 31 3c 3c 31 36 29 20  | + (orr%*1<<16) |
00001b70  2b 20 28 6f 72 72 25 2a  31 3c 3c 32 34 29 0d 07  |+ (orr%*1<<24)..|
00001b80  9e 04 0d 07 a8 04 0d 07  b2 09 20 20 20 20 5d 0d  |..........    ].|
00001b90  07 bc 07 20 20 ed 0d 07  c6 05 e1 0d 07 d0 04 0d  |...  ...........|
00001ba0  07 da 04 0d 07 e4 04 0d  07 ee 13 dd 20 a4 61 72  |............ .ar|
00001bb0  72 61 79 28 73 69 7a 65  25 29 0d 07 f8 11 20 20  |ray(size%)....  |
00001bc0  50 25 20 2b 3d 20 73 69  7a 65 25 0d 08 02 07 3d  |P% += size%....=|
00001bd0  20 30 0d 08 0c 04 0d 08  16 04 0d 08 20 04 0d 08  | 0.......... ...|
00001be0  2a 0b dd 20 f2 69 6e 69  74 0d 08 34 0a 20 20 ea  |*.. .init..4.  .|
00001bf0  20 49 25 0d 08 3e 04 0d  08 48 19 20 20 e3 20 49  | I%..>...H.  . I|
00001c00  25 20 3d 20 30 20 b8 20  28 68 25 20 2d 20 31 29  |% = 0 . (h% - 1)|
00001c10  0d 08 52 38 20 20 20 20  74 61 62 6c 65 25 21 28  |..R8    table%!(|
00001c20  49 25 2a 34 29 20 3d 20  28 68 25 2f 31 30 29 20  |I%*4) = (h%/10) |
00001c30  2a 20 b5 b2 28 49 25 20  2a 20 28 33 36 30 2f 28  |* ..(I% * (360/(|
00001c40  68 25 2f 32 29 29 20 29  0d 08 5c 07 20 20 ed 0d  |h%/2)) )..\.  ..|
00001c50  08 66 04 0d 08 70 19 20  20 e3 20 49 25 20 3d 20  |.f...p.  . I% = |
00001c60  30 20 b8 20 28 68 25 20  2d 20 31 29 0d 08 7a 34  |0 . (h% - 1)..z4|
00001c70  20 20 20 20 70 65 72 73  70 65 63 74 25 21 28 49  |    perspect%!(I|
00001c80  25 2a 34 29 20 3d 20 28  49 25 20 2f 20 28 68 25  |%*4) = (I% / (h%|
00001c90  2d 31 29 29 20 2a 20 28  31 20 3c 3c 20 32 30 29  |-1)) * (1 << 20)|
00001ca0  0d 08 84 07 20 20 ed 0d  08 8e 04 0d 08 98 05 e1  |....  ..........|
00001cb0  0d ff                                             |..|
00001cb2