Home » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199804.adf » Features » Diffdim/Program1

Diffdim/Program1

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 » Recent acquisitions » Acorn ADFS disks » adfs_AcornUser_199804.adf » Features
Filename: Diffdim/Program1
Read OK:
File size: 26B1 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM Program 1
   20REM
   30REM Demostrate the fractal terrain generator
   40:
   50ON ERROR MODE0:PRINT REPORT$;" at line ";ERL:END
   60PROCassemble
   70:
   80wid%=USR(setup)
   90DIM sx%(wid%),sy%(wid%)
  100CASE wid% OF
  110WHEN 160: dep%=30:v%=200:dist%=5
  120WHEN 80 : dep%=30:v%=400:dist%=5
  130WHEN 40 : dep%=15:v%=400:dist%=10
  140WHEN 20 : dep%=15:v%=800:dist%=15
  150ENDCASE
  160div=15/dep%:wid2%=wid%/2:wid3%=wid2%-1
  170FORn%=0 TO 15:COLOUR n%,n%<<4,n%<<4,n%<<4:NEXT
  180OFF
  190:
  200bk%=1:vx=0:vz=0
  210ORIGIN 640,512
  220MOUSE x,y,b%
  230REPEAT
  240SYS"OS_Byte",112,bk%
  250bk%=3-bk%
  260SYS"OS_Byte",113,bk%
  270WAIT
  280CLS
  290ox%=x:oy%=y
  300MOUSE x,y,b%
  310IF x=ox% THEN x=x*0.8
  320IF y=oy% THEN y=y*0.8
  330MOUSE TO x,y
  340vx+=x/64:vz+=y/64
  350PROCdisplay(vx,vz)
  360UNTIL FALSE
  370END
  380:
  390DEFPROCdisplay(vx,vz)
  400A%=vx:B%=vz:height%=USR(get_frac)/8
  410FORz%=vz+dep% TO vz STEP -1
  420GCOL 15-(z%-vz)*div
  430sx=v%/(z%-vz+dist%)
  440i%=1
  450sx%=(INT(vx-wid2%)-vx)*sx:sy%=FNh(vx-wid2%,z%)*sx
  460IF z%<vz+dep% THEN LINE sx%(0),sy%(0),sx%,sy% ELSE MOVE sx%,sy%
  470sx%(0)=sx%:sy%(0)=sy%
  480FORx%=vx-wid3% TO vx+wid2%
  490sx%=(x%-vx)*sx:sy%=FNh(x%,z%)*sx
  500DRAW sx%,sy%
  510IF z%<vz+dep% THEN LINE sx%(i%),sy%(i%),sx%,sy%
  520sx%(i%)=sx%:sy%(i%)=sy%
  530i%+=1
  540NEXT
  550NEXT
  560ENDPROC
  570:
  580DEFFNh(A%,B%)=USR(get_frac)/8-10-height%
  590:
  600DEFPROCassemble
  610DIM code% 1024,noise_tab% 262144,noise_tab2% 262144,bezier_factor_table% 16384
  620FORpass%=0 TO 2 STEP 2
  630P%=code%
  640[OPT pass%
  650
  660.setup
  670mov r0,#0
  680swi &2006D
  690movvs r10,#40
  700bvs not_ro37
  710tst r0,#1
  720moveq r10,#40                   ; non-SA
  730movne r10,#160                  ; SA-CPU
  740.not_ro37
  750swi 256+22
  760swi &20100+20
  770bvs try_mode_12
  780mov r0,#2
  790swi "OS_ReadDynamicArea"
  800cmp r1,#360*1024
  810movge r0,r10
  820movge pc,r14
  830mov r0,#2
  840rsb r1,r1,#360*1024
  850swi "XOS_ChangeDynamicArea"     ; Try to set up 360k of screen memory
  860movvc r0,r10
  870movvc pc,r14
  880.try_mode_12
  890mov r10,r10,asr#1
  900swi 256+22
  910swi 256+12
  920mov r0,#2
  930swi "OS_ReadDynamicArea"
  940cmp r1,#160*1024
  950movge r0,r10
  960movge pc,r14
  970mov r0,#2
  980rsb r1,r1,#160*1024
  990swi "XOS_ChangeDynamicArea"     ; Try to set up 160k of screen memory
 1000movvc r0,r10
 1010movvc pc,r14
 1020adr r0,not_enough_memory_error
 1030orrs pc,r14,#1<<28
 1040
 1050.not_enough_memory_error
 1060dcd 0
 1070equs"Needs at least 160k of screen memory"+CHR$0
 1080ALIGN
 1090
 1100.noise_tab
 1110dcd noise_tab%
 1120.noise_tab2
 1130dcd noise_tab2%
 1140
 1150; Generate table of random numbers and smooth a few times
 1160
 1170.gen_noise                      ; r0 = log base 2 size of table (8=256x256)
 1180                                ; r1 = destination
 1190mov r11,#1
 1200mov r8,r11,lsl r0               ; column size
 1210mov r11,r8,lsl r0               ; size in bytes
 1220sub r9,r11,#1                   ; mask
 1230mov r12,r1
 1240swi "OS_ReadMonotonicTime"
 1250mov r1,#1
 1260and r3,r0,#255
 1270.rnd_loop
 1280tst r1,r1,lsr#1
 1290movs r2,r0,rrx
 1300adc r1,r1,r1
 1310eor r2,r2,r0,lsl#12
 1320eor r0,r2,r2,lsr#20
 1330subs r3,r3,#1
 1340bgt rnd_loop
 1350
 1360mov r3,r12                      ; destination
 1370mov r4,r11                      ; size
 1380.gen_loop
 1390tst r1,r1,lsr#1
 1400movs r2,r0,rrx
 1410adc r1,r1,r1
 1420eor r2,r2,r0,lsl#12
 1430eor r0,r2,r2,lsr#20             ; random number
 1440str r0,[r3],#4
 1450subs r4,r4,#4
 1460bgt gen_loop
 1470mov r1,#2                       ; n
 1480.smoothtab
 1490ldr r6,noise_tab2
 1500.nloop
 1510mov r2,r11                      ; size
 1520.sloop
 1530ldrb r3,[r12,r2]                ; middle
 1540sub r5,r2,#1
 1550and r5,r5,r9
 1560ldrb r4,[r12,r5]                ; left
 1570add r3,r3,r4
 1580add r5,r2,#1
 1590and r5,r5,r9
 1600ldrb r4,[r12,r5]                ; right
 1610add r3,r3,r4
 1620sub r5,r2,r8                    ; column size
 1630and r5,r5,r9
 1640ldrb r4,[r12,r5]                ; top
 1650add r3,r3,r4
 1660sub r5,r5,#1
 1670and r5,r5,r9
 1680ldrb r4,[r12,r5]                ; top-left
 1690add r3,r3,r4
 1700add r5,r5,#2
 1710and r5,r5,r9
 1720ldrb r4,[r12,r5]                ; top-right
 1730add r3,r3,r4
 1740add r5,r2,r8                    ; column size
 1750and r5,r5,r9
 1760ldrb r4,[r12,r5]                ; bottom
 1770add r3,r3,r4
 1780sub r5,r5,#1
 1790and r5,r5,r9
 1800ldrb r4,[r12,r5]                ; bottom-left
 1810add r3,r3,r4
 1820add r5,r5,#2
 1830and r5,r5,r9
 1840ldrb r4,[r12,r5]                ; bottom-right
 1850add r3,r3,r4
 1860
 1870mov r4,r3,lsr#3
 1880sub r4,r4,r3,lsr#7
 1890add r4,r4,r3,lsr#10
 1900add r4,r4,r3,lsr#11
 1910adds r3,r4,r3,lsr#12
 1920movlt r3,#0
 1930cmp r3,#255
 1940movgt r3,#255
 1950strb r3,[r6,r2]                 ; restore - in other bank
 1960
 1970subs r2,r2,#1
 1980bge sloop
 1990
 2000mov r3,r12                      ; destination
 2010mov r4,r6                       ; second bank
 2020add r5,r3,r11                   ; size
 2030.clp
 2040ldr r0,[r4],#4
 2050str r0,[r3],#4
 2060cmp r3,r5
 2070blt clp
 2080
 2090subs r1,r1,#1
 2100bgt nloop
 2110mov pc,r14
 2120
 2130.bezier_factors
 2140dcd bezier_factor_table%
 2150
 2160.stackp
 2170dcd 0
 2180
 2190
 2200; Read a value from the noise table
 2210; at fractional coordinates so interpolate using a cubic function
 2220
 2230.get_noise                      ; r0 = noise table
 2240                                ; r8 = x<<10
 2250                                ; r9 = z<<10
 2260stmfd r13!,{r1-r7,r9-r12,r14}
 2270str r13,stackp
 2280mov r12,r8,lsl#22
 2290mov r12,r12,lsr#22              ; x and 1023 = frac(x)
 2300ldr r1,bezier_factors
 2310add r2,r1,r12,lsl#4
 2320ldmia r2,{r6,r7,r12,r13}        ; r6 = (1-x)^3 << 10
 2330                                ; r7 = 3x(1-x)^2 << 10
 2340                                ; r12 = 3x^2(1-x) << 10
 2350                                ; r13 = x^3 << 10
 2360                                ; x = (1/3)+frac(x)/3
 2370mov r14,r9,lsl#22
 2380mov r14,r14,lsr#22              ; z and 1023  = frac(z)
 2390add r14,r1,r14,lsl#4            ; r14 -> bezier_fractors(frac(z))
 2400
 2410mov r8,r8,lsl#13                ; r8 = x<<23
 2420mov r9,r9,lsl#13                ; r9 = z<<23
 2430sub r10,r8,#1<<23               ; x-1 and 511
 2440sub r11,r9,#1<<23               ; z-1 and 511
 2450mov r11,r11,lsr#23              ; int(z-1)
 2460add r11,r0,r11,lsl#9
 2470ldrb r1,[r11,r10,lsr#23]        ; noise(x-1,z-1)
 2480ldrb r2,[r11,r8,lsr#23]         ; noise(x,z-1)
 2490add r10,r8,#1<<23               ; x+1 and 1023
 2500ldrb r3,[r11,r10,lsr#23]        ; noise(x+1,z-1)
 2510add r10,r8,#2<<23               ; x+2 and 1023
 2520ldrb r4,[r11,r10,lsr#23]        ; noise(x+2,z-1)
 2530
 2540mul r1,r6,r1
 2550mla r1,r7,r2,r1
 2560mla r1,r12,r3,r1
 2570mla r1,r13,r4,r1                ; cubic blend Noise(z-1)
 2580ldr r2,[r14],#4
 2590mul r1,r2,r1                    ; first cubic point
 2600
 2610sub r10,r8,#1<<23               ; x-1 and 1023
 2620mov r11,r9,lsr#23               ; int(z)
 2630add r11,r0,r11,lsl#9
 2640ldrb r2,[r11,r10,lsr#23]        ; noise(x-1,z)
 2650ldrb r3,[r11,r8,lsr#23]         ; noise(x,z)
 2660add r10,r8,#1<<23               ; x+1 and 1023
 2670ldrb r4,[r11,r10,lsr#23]        ; noise(x+1,z)
 2680add r10,r8,#2<<23               ; x+2 and 1023
 2690ldrb r5,[r11,r10,lsr#23]        ; noise(x+2,z)
 2700
 2710mul r2,r6,r2
 2720mla r2,r7,r3,r2
 2730mla r2,r12,r4,r2
 2740mla r2,r13,r5,r2                ; cubic blend Noise(z)
 2750ldr r3,[r14],#4
 2760mla r1,r2,r3,r1                 ; second cubic point
 2770
 2780sub r10,r8,#1<<23               ; x-1 and 1023
 2790add r11,r9,#1<<23               ; z+1 and 1023
 2800mov r11,r11,lsr#23
 2810add r11,r0,r11,lsl#9
 2820ldrb r2,[r11,r10,lsr#23]        ; noise(x-1,z+1)
 2830ldrb r3,[r11,r8,lsr#23]         ; noise(x,z+1)
 2840add r10,r8,#1<<23               ; x+1 and 1023
 2850ldrb r4,[r11,r10,lsr#23]        ; noise(x+1,z+1)
 2860add r10,r8,#2<<23               ; x+2 and 1023
 2870ldrb r5,[r11,r10,lsr#23]        ; noise(x+2,z+1)
 2880
 2890mul r2,r6,r2
 2900mla r2,r7,r3,r2
 2910mla r2,r12,r4,r2
 2920mla r2,r13,r5,r2                ; cubic blend Noise(z)
 2930ldr r3,[r14],#4
 2940mla r1,r2,r3,r1                 ; third cubic point
 2950
 2960sub r10,r8,#1<<23               ; x-1 and 1023
 2970add r11,r9,#2<<23               ; z+2 and 1023
 2980mov r11,r11,lsr#23
 2990add r11,r0,r11,lsl#9
 3000ldrb r2,[r11,r10,lsr#23]        ; noise(x-1,z+1)
 3010ldrb r3,[r11,r8,lsr#23]         ; noise(x,z+1)
 3020add r10,r8,#1<<23               ; x+1 and 1023
 3030ldrb r4,[r11,r10,lsr#23]        ; noise(x+1,z+1)
 3040add r10,r8,#2<<23               ; x+2 and 1023
 3050ldrb r5,[r11,r10,lsr#23]        ; noise(x+2,z+1)
 3060
 3070mul r2,r6,r2
 3080mla r2,r7,r3,r2
 3090mla r2,r12,r4,r2
 3100mla r2,r13,r5,r2                ; cubic blend Noise(z)
 3110ldr r3,[r14],#4
 3120mla r1,r2,r3,r1                 ; fourth cubic point
 3130
 3140; r1 = cubic blended noise at (x,z) << 18
 3150mov r8,r1,asr#20
 3160ldr r13,stackp
 3170ldmfd r13!,{r1-r7,r9-r12,r15}
 3180
 3190
 3200; Calculate the fractal
 3210
 3220.get_frac                       ; r0 = x
 3230                                ; r1 = y
 3240
 3250stmfd r13!,{r14}
 3260adr r11,exp_table
 3270mov r2,r0
 3280mov r3,r1
 3290ldr r0,noise_tab
 3300mov r8,r2,lsl#5                 ; = asr#6
 3310mov r9,r3,lsl#5
 3320bl get_noise                    ; get first octave
 3330mov r4,r8
 3340mov r5,r2,lsl#15                ; x'=x*lac (lac=2) = asr#5
 3350mov r6,r3,lsl#15                ; y'=y*lac
 3360
 3370mov r7,#4                       ; octaves
 3380.oct_loop
 3390mov r8,r5,asr#10
 3400mov r9,r6,asr#10
 3410bl get_noise
 3420
 3430ldr r9,[r11,r7,lsl#2]           ; exp(i) << 10
 3440mul r8,r9,r8                    ; inc=noise(x',y')*exp(i) << 18
 3450mul r8,r4,r8                    ; inc*=val << 26
 3460add r4,r4,r8,asr#17             ; val+=inc << 8
 3470add r4,r4,r8,asr#19
 3480mov r5,r5,lsl#1                 ; x'*=lac
 3490mov r6,r6,lsl#1                 ; y'*=lac
 3500subs r7,r7,#1
 3510bgt oct_loop
 3520
 3530mov r0,r4,asr#2                 ; return value
 3540ldmfd r13!,{r15}
 3550
 3560.exp_table
 3570
 3580]
 3590NEXT
 3600
 3610REM Generate the exponent_array table
 3620freq=2
 3630FORn%=4 TO 0 STEP -1
 3640exp_table!(n%<<2)=1024*(freq^-0.1)
 3650freq=freq*2
 3660NEXT
 3670:
 3680REM Generate the cubic interpolation lookup table
 3690p%=bezier_factor_table%
 3700FORx%=0 TO 1023
 3710x=(1/3)+x%/3072:xx=x*x
 3720x2=1-x:xx2=x2*x2
 3730!p%=1024*xx2*x2
 3740p%!4=3072*x*xx2
 3750p%!8=3072*xx*x2
 3760p%!12=1024*x*xx
 3770p%+=16
 3780NEXT
 3790:
 3800REM Call the noise generator code
 3810A%=9:B%=noise_tab%:CALL gen_noise
 3820
 3830ENDPROC

� Program 1
�
.� Demostrate the fractal terrain generator
(:
2� � �0:� �$;" at line ";�:�
<
�assemble
F:
Pwid%=�(setup)
Z� sx%(wid%),sy%(wid%)
d
Ȏ wid% �
n!� 160: dep%=30:v%=200:dist%=5
x!� 80 : dep%=30:v%=400:dist%=5
�"� 40 : dep%=15:v%=400:dist%=10
�"� 20 : dep%=15:v%=800:dist%=15
��
�*div=15/dep%:wid2%=wid%/2:wid3%=wid2%-1
�'�n%=0 � 15:� n%,n%<<4,n%<<4,n%<<4:�
��
�:
�bk%=1:vx=0:vz=0
�ȑ 640,512
�
ȗ x,y,b%
��
�ș"OS_Byte",112,bk%
�
bk%=3-bk%
ș"OS_Byte",113,bk%
Ȗ
�
"ox%=x:oy%=y
,
ȗ x,y,b%
6� x=ox% � x=x*0.8
@� y=oy% � y=y*0.8
Jȗ � x,y
Tvx+=x/64:vz+=y/64
^�display(vx,vz)
h� �
r�
|:
���display(vx,vz)
�%A%=vx:B%=vz:height%=�(get_frac)/8
��z%=vz+dep% � vz � -1
�� 15-(z%-vz)*div
�sx=v%/(z%-vz+dist%)
�i%=1
�2sx%=(�(vx-wid2%)-vx)*sx:sy%=�h(vx-wid2%,z%)*sx
�6� z%<vz+dep% � � sx%(0),sy%(0),sx%,sy% � � sx%,sy%
�sx%(0)=sx%:sy%(0)=sy%
��x%=vx-wid3% � vx+wid2%
�#sx%=(x%-vx)*sx:sy%=�h(x%,z%)*sx
�
� sx%,sy%
�,� z%<vz+dep% � � sx%(i%),sy%(i%),sx%,sy%
sx%(i%)=sx%:sy%(i%)=sy%
	i%+=1
�
&�
0�
::
D'ݤh(A%,B%)=�(get_frac)/8-10-height%
N:
X��assemble
bP� code% 1024,noise_tab% 262144,noise_tab2% 262144,bezier_factor_table% 16384
l�pass%=0 � 2 � 2
vP%=code%
�[OPT pass%
�
�
.setup
�
mov r0,#0
�swi &2006D
�movvs r10,#40
�bvs not_ro37
�
tst r0,#1
�,moveq r10,#40                   ; non-SA
�,movne r10,#160                  ; SA-CPU
�
.not_ro37
�swi 256+22
�swi &20100+20
bvs try_mode_12

mov r0,#2
swi "OS_ReadDynamicArea"
 cmp r1,#360*1024
*movge r0,r10
4movge pc,r14
>
mov r0,#2
Hrsb r1,r1,#360*1024
RIswi "XOS_ChangeDynamicArea"     ; Try to set up 360k of screen memory
\movvc r0,r10
fmovvc pc,r14
p.try_mode_12
zmov r10,r10,asr#1
�swi 256+22
�swi 256+12
�
mov r0,#2
�swi "OS_ReadDynamicArea"
�cmp r1,#160*1024
�movge r0,r10
�movge pc,r14
�
mov r0,#2
�rsb r1,r1,#160*1024
�Iswi "XOS_ChangeDynamicArea"     ; Try to set up 160k of screen memory
�movvc r0,r10
�movvc pc,r14
�"adr r0,not_enough_memory_error
orrs pc,r14,#1<<28

.not_enough_memory_error
$	dcd 0
.1equs"Needs at least 160k of screen memory"+�0
8	ALIGN
B
L.noise_tab
Vdcd noise_tab%
`.noise_tab2
jdcd noise_tab2%
t
~=; Generate table of random numbers and smooth a few times
�
�O.gen_noise                      ; r0 = log base 2 size of table (8=256x256)
�6                                ; r1 = destination
�mov r11,#1
�1mov r8,r11,lsl r0               ; column size
�3mov r11,r8,lsl r0               ; size in bytes
�*sub r9,r11,#1                   ; mask
�mov r12,r1
�swi "OS_ReadMonotonicTime"
�
mov r1,#1
�and r3,r0,#255
�
.rnd_loop
tst r1,r1,lsr#1

movs r2,r0,rrx
adc r1,r1,r1
eor r2,r2,r0,lsl#12
(eor r0,r2,r2,lsr#20
2subs r3,r3,#1
<bgt rnd_loop
F
P1mov r3,r12                      ; destination
Z*mov r4,r11                      ; size
d
.gen_loop
ntst r1,r1,lsr#1
xmovs r2,r0,rrx
�adc r1,r1,r1
�eor r2,r2,r0,lsl#12
�3eor r0,r2,r2,lsr#20             ; random number
�str r0,[r3],#4
�subs r4,r4,#4
�bgt gen_loop
�'mov r1,#2                       ; n
�.smoothtab
�ldr r6,noise_tab2
�
.nloop
�*mov r2,r11                      ; size
�
.sloop
�,ldrb r3,[r12,r2]                ; middle
sub r5,r2,#1
and r5,r5,r9
*ldrb r4,[r12,r5]                ; left
"add r3,r3,r4
,add r5,r2,#1
6and r5,r5,r9
@+ldrb r4,[r12,r5]                ; right
Jadd r3,r3,r4
T1sub r5,r2,r8                    ; column size
^and r5,r5,r9
h)ldrb r4,[r12,r5]                ; top
radd r3,r3,r4
|sub r5,r5,#1
�and r5,r5,r9
�.ldrb r4,[r12,r5]                ; top-left
�add r3,r3,r4
�add r5,r5,#2
�and r5,r5,r9
�/ldrb r4,[r12,r5]                ; top-right
�add r3,r3,r4
�1add r5,r2,r8                    ; column size
�and r5,r5,r9
�,ldrb r4,[r12,r5]                ; bottom
�add r3,r3,r4
�sub r5,r5,#1
�and r5,r5,r9
1ldrb r4,[r12,r5]                ; bottom-left
add r3,r3,r4
add r5,r5,#2
&and r5,r5,r9
02ldrb r4,[r12,r5]                ; bottom-right
:add r3,r3,r4
D
Nmov r4,r3,lsr#3
Xsub r4,r4,r3,lsr#7
badd r4,r4,r3,lsr#10
ladd r4,r4,r3,lsr#11
vadds r3,r4,r3,lsr#12
�movlt r3,#0
�cmp r3,#255
�movgt r3,#255
�=strb r3,[r6,r2]                 ; restore - in other bank
�
�subs r2,r2,#1
�
bge sloop
�
�1mov r3,r12                      ; destination
�1mov r4,r6                       ; second bank
�*add r5,r3,r11                   ; size
�.clp
�ldr r0,[r4],#4
str r0,[r3],#4

cmp r3,r5
blt clp
 
*subs r1,r1,#1
4
bgt nloop
>mov pc,r14
H
R.bezier_factors
\dcd bezier_factor_table%
f
p.stackp
z	dcd 0
�
�
�'; Read a value from the noise table
�E; at fractional coordinates so interpolate using a cubic function
�
�6.get_noise                      ; r0 = noise table
�0                                ; r8 = x<<10
�0                                ; r9 = z<<10
�!stmfd r13!,{r1-r7,r9-r12,r14}
�str r13,stackp
�mov r12,r8,lsl#22
�:mov r12,r12,lsr#22              ; x and 1023 = frac(x)
�ldr r1,bezier_factors
	add r2,r1,r12,lsl#4
	8ldmia r2,{r6,r7,r12,r13}        ; r6 = (1-x)^3 << 10
	:                                ; r7 = 3x(1-x)^2 << 10
	$;                                ; r12 = 3x^2(1-x) << 10
	.5                                ; r13 = x^3 << 10
	89                                ; x = (1/3)+frac(x)/3
	Bmov r14,r9,lsl#22
	L;mov r14,r14,lsr#22              ; z and 1023  = frac(z)
	VEadd r14,r1,r14,lsl#4            ; r14 -> bezier_fractors(frac(z))
	`
	j0mov r8,r8,lsl#13                ; r8 = x<<23
	t0mov r9,r9,lsl#13                ; r9 = z<<23
	~1sub r10,r8,#1<<23               ; x-1 and 511
	�1sub r11,r9,#1<<23               ; z-1 and 511
	�.mov r11,r11,lsr#23              ; int(z-1)
	�add r11,r0,r11,lsl#9
	�4ldrb r1,[r11,r10,lsr#23]        ; noise(x-1,z-1)
	�2ldrb r2,[r11,r8,lsr#23]         ; noise(x,z-1)
	�2add r10,r8,#1<<23               ; x+1 and 1023
	�4ldrb r3,[r11,r10,lsr#23]        ; noise(x+1,z-1)
	�2add r10,r8,#2<<23               ; x+2 and 1023
	�4ldrb r4,[r11,r10,lsr#23]        ; noise(x+2,z-1)
	�
	�mul r1,r6,r1
	�mla r1,r7,r2,r1
mla r1,r12,r3,r1

<mla r1,r13,r4,r1                ; cubic blend Noise(z-1)
ldr r2,[r14],#4
7mul r1,r2,r1                    ; first cubic point
(
22sub r10,r8,#1<<23               ; x-1 and 1023
<,mov r11,r9,lsr#23               ; int(z)
Fadd r11,r0,r11,lsl#9
P2ldrb r2,[r11,r10,lsr#23]        ; noise(x-1,z)
Z0ldrb r3,[r11,r8,lsr#23]         ; noise(x,z)
d2add r10,r8,#1<<23               ; x+1 and 1023
n2ldrb r4,[r11,r10,lsr#23]        ; noise(x+1,z)
x2add r10,r8,#2<<23               ; x+2 and 1023
�2ldrb r5,[r11,r10,lsr#23]        ; noise(x+2,z)
�
�mul r2,r6,r2
�mla r2,r7,r3,r2
�mla r2,r12,r4,r2
�:mla r2,r13,r5,r2                ; cubic blend Noise(z)
�ldr r3,[r14],#4
�8mla r1,r2,r3,r1                 ; second cubic point
�
�2sub r10,r8,#1<<23               ; x-1 and 1023
�2add r11,r9,#1<<23               ; z+1 and 1023
�mov r11,r11,lsr#23
�add r11,r0,r11,lsl#9
4ldrb r2,[r11,r10,lsr#23]        ; noise(x-1,z+1)
2ldrb r3,[r11,r8,lsr#23]         ; noise(x,z+1)
2add r10,r8,#1<<23               ; x+1 and 1023
"4ldrb r4,[r11,r10,lsr#23]        ; noise(x+1,z+1)
,2add r10,r8,#2<<23               ; x+2 and 1023
64ldrb r5,[r11,r10,lsr#23]        ; noise(x+2,z+1)
@
Jmul r2,r6,r2
Tmla r2,r7,r3,r2
^mla r2,r12,r4,r2
h:mla r2,r13,r5,r2                ; cubic blend Noise(z)
rldr r3,[r14],#4
|7mla r1,r2,r3,r1                 ; third cubic point
�
�2sub r10,r8,#1<<23               ; x-1 and 1023
�2add r11,r9,#2<<23               ; z+2 and 1023
�mov r11,r11,lsr#23
�add r11,r0,r11,lsl#9
�4ldrb r2,[r11,r10,lsr#23]        ; noise(x-1,z+1)
�2ldrb r3,[r11,r8,lsr#23]         ; noise(x,z+1)
�2add r10,r8,#1<<23               ; x+1 and 1023
�4ldrb r4,[r11,r10,lsr#23]        ; noise(x+1,z+1)
�2add r10,r8,#2<<23               ; x+2 and 1023
�4ldrb r5,[r11,r10,lsr#23]        ; noise(x+2,z+1)
�
�mul r2,r6,r2
mla r2,r7,r3,r2
mla r2,r12,r4,r2
:mla r2,r13,r5,r2                ; cubic blend Noise(z)
&ldr r3,[r14],#4
08mla r1,r2,r3,r1                 ; fourth cubic point
:
D-; r1 = cubic blended noise at (x,z) << 18
Nmov r8,r1,asr#20
Xldr r13,stackp
b!ldmfd r13!,{r1-r7,r9-r12,r15}
l
v
�; Calculate the fractal
�
�,.get_frac                       ; r0 = x
�,                                ; r1 = y
�
�stmfd r13!,{r14}
�adr r11,exp_table
�
mov r2,r0
�
mov r3,r1
�ldr r0,noise_tab
�-mov r8,r2,lsl#5                 ; = asr#6
�mov r9,r3,lsl#5
�6bl get_noise                    ; get first octave


mov r4,r8

>mov r5,r2,lsl#15                ; x'=x*lac (lac=2) = asr#5

.mov r6,r3,lsl#15                ; y'=y*lac

 

*-mov r7,#4                       ; octaves

4
.oct_loop

>mov r8,r5,asr#10

Hmov r9,r6,asr#10

Rbl get_noise

\

f2ldr r9,[r11,r7,lsl#2]           ; exp(i) << 10

pCmul r8,r9,r8                    ; inc=noise(x',y')*exp(i) << 18

z4mul r8,r4,r8                    ; inc*=val << 26

�3add r4,r4,r8,asr#17             ; val+=inc << 8

�add r4,r4,r8,asr#19

�-mov r5,r5,lsl#1                 ; x'*=lac

�-mov r6,r6,lsl#1                 ; y'*=lac

�subs r7,r7,#1

�bgt oct_loop

�

�2mov r0,r4,asr#2                 ; return value

�ldmfd r13!,{r15}

�

�.exp_table

�

�]
�

'� Generate the exponent_array table
$
freq=2
.�n%=4 � 0 � -1
8&exp_table!(n%<<2)=1024*(freq^-0.1)
Bfreq=freq*2
L�
V:
`3� Generate the cubic interpolation lookup table
jp%=bezier_factor_table%
t�x%=0 � 1023
~x=(1/3)+x%/3072:xx=x*x
�x2=1-x:xx2=x2*x2
�!p%=1024*xx2*x2
�p%!4=3072*x*xx2
�p%!8=3072*xx*x2
�p%!12=1024*x*xx
�
p%+=16
��
�:
�#� Call the noise generator code
�"A%=9:B%=noise_tab%:� gen_noise
�
��
�
00000000  0d 00 0a 0f f4 20 50 72  6f 67 72 61 6d 20 31 0d  |..... Program 1.|
00000010  00 14 05 f4 0d 00 1e 2e  f4 20 44 65 6d 6f 73 74  |......... Demost|
00000020  72 61 74 65 20 74 68 65  20 66 72 61 63 74 61 6c  |rate the fractal|
00000030  20 74 65 72 72 61 69 6e  20 67 65 6e 65 72 61 74  | terrain generat|
00000040  6f 72 0d 00 28 05 3a 0d  00 32 1f ee 20 85 20 eb  |or..(.:..2.. . .|
00000050  30 3a f1 20 f6 24 3b 22  20 61 74 20 6c 69 6e 65  |0:. .$;" at line|
00000060  20 22 3b 9e 3a e0 0d 00  3c 0d f2 61 73 73 65 6d  | ";.:...<..assem|
00000070  62 6c 65 0d 00 46 05 3a  0d 00 50 11 77 69 64 25  |ble..F.:..P.wid%|
00000080  3d ba 28 73 65 74 75 70  29 0d 00 5a 19 de 20 73  |=.(setup)..Z.. s|
00000090  78 25 28 77 69 64 25 29  2c 73 79 25 28 77 69 64  |x%(wid%),sy%(wid|
000000a0  25 29 0d 00 64 0d c8 8e  20 77 69 64 25 20 ca 0d  |%)..d... wid% ..|
000000b0  00 6e 21 c9 20 31 36 30  3a 20 64 65 70 25 3d 33  |.n!. 160: dep%=3|
000000c0  30 3a 76 25 3d 32 30 30  3a 64 69 73 74 25 3d 35  |0:v%=200:dist%=5|
000000d0  0d 00 78 21 c9 20 38 30  20 3a 20 64 65 70 25 3d  |..x!. 80 : dep%=|
000000e0  33 30 3a 76 25 3d 34 30  30 3a 64 69 73 74 25 3d  |30:v%=400:dist%=|
000000f0  35 0d 00 82 22 c9 20 34  30 20 3a 20 64 65 70 25  |5...". 40 : dep%|
00000100  3d 31 35 3a 76 25 3d 34  30 30 3a 64 69 73 74 25  |=15:v%=400:dist%|
00000110  3d 31 30 0d 00 8c 22 c9  20 32 30 20 3a 20 64 65  |=10...". 20 : de|
00000120  70 25 3d 31 35 3a 76 25  3d 38 30 30 3a 64 69 73  |p%=15:v%=800:dis|
00000130  74 25 3d 31 35 0d 00 96  05 cb 0d 00 a0 2a 64 69  |t%=15........*di|
00000140  76 3d 31 35 2f 64 65 70  25 3a 77 69 64 32 25 3d  |v=15/dep%:wid2%=|
00000150  77 69 64 25 2f 32 3a 77  69 64 33 25 3d 77 69 64  |wid%/2:wid3%=wid|
00000160  32 25 2d 31 0d 00 aa 27  e3 6e 25 3d 30 20 b8 20  |2%-1...'.n%=0 . |
00000170  31 35 3a fb 20 6e 25 2c  6e 25 3c 3c 34 2c 6e 25  |15:. n%,n%<<4,n%|
00000180  3c 3c 34 2c 6e 25 3c 3c  34 3a ed 0d 00 b4 05 87  |<<4,n%<<4:......|
00000190  0d 00 be 05 3a 0d 00 c8  13 62 6b 25 3d 31 3a 76  |....:....bk%=1:v|
000001a0  78 3d 30 3a 76 7a 3d 30  0d 00 d2 0e c8 91 20 36  |x=0:vz=0...... 6|
000001b0  34 30 2c 35 31 32 0d 00  dc 0d c8 97 20 78 2c 79  |40,512...... x,y|
000001c0  2c 62 25 0d 00 e6 05 f5  0d 00 f0 17 c8 99 22 4f  |,b%..........."O|
000001d0  53 5f 42 79 74 65 22 2c  31 31 32 2c 62 6b 25 0d  |S_Byte",112,bk%.|
000001e0  00 fa 0d 62 6b 25 3d 33  2d 62 6b 25 0d 01 04 17  |...bk%=3-bk%....|
000001f0  c8 99 22 4f 53 5f 42 79  74 65 22 2c 31 31 33 2c  |.."OS_Byte",113,|
00000200  62 6b 25 0d 01 0e 06 c8  96 0d 01 18 05 db 0d 01  |bk%.............|
00000210  22 0f 6f 78 25 3d 78 3a  6f 79 25 3d 79 0d 01 2c  |".ox%=x:oy%=y..,|
00000220  0d c8 97 20 78 2c 79 2c  62 25 0d 01 36 15 e7 20  |... x,y,b%..6.. |
00000230  78 3d 6f 78 25 20 8c 20  78 3d 78 2a 30 2e 38 0d  |x=ox% . x=x*0.8.|
00000240  01 40 15 e7 20 79 3d 6f  79 25 20 8c 20 79 3d 79  |.@.. y=oy% . y=y|
00000250  2a 30 2e 38 0d 01 4a 0c  c8 97 20 b8 20 78 2c 79  |*0.8..J... . x,y|
00000260  0d 01 54 15 76 78 2b 3d  78 2f 36 34 3a 76 7a 2b  |..T.vx+=x/64:vz+|
00000270  3d 79 2f 36 34 0d 01 5e  13 f2 64 69 73 70 6c 61  |=y/64..^..displa|
00000280  79 28 76 78 2c 76 7a 29  0d 01 68 07 fd 20 a3 0d  |y(vx,vz)..h.. ..|
00000290  01 72 05 e0 0d 01 7c 05  3a 0d 01 86 14 dd f2 64  |.r....|.:......d|
000002a0  69 73 70 6c 61 79 28 76  78 2c 76 7a 29 0d 01 90  |isplay(vx,vz)...|
000002b0  25 41 25 3d 76 78 3a 42  25 3d 76 7a 3a 68 65 69  |%A%=vx:B%=vz:hei|
000002c0  67 68 74 25 3d ba 28 67  65 74 5f 66 72 61 63 29  |ght%=.(get_frac)|
000002d0  2f 38 0d 01 9a 19 e3 7a  25 3d 76 7a 2b 64 65 70  |/8.....z%=vz+dep|
000002e0  25 20 b8 20 76 7a 20 88  20 2d 31 0d 01 a4 14 e6  |% . vz . -1.....|
000002f0  20 31 35 2d 28 7a 25 2d  76 7a 29 2a 64 69 76 0d  | 15-(z%-vz)*div.|
00000300  01 ae 17 73 78 3d 76 25  2f 28 7a 25 2d 76 7a 2b  |...sx=v%/(z%-vz+|
00000310  64 69 73 74 25 29 0d 01  b8 08 69 25 3d 31 0d 01  |dist%)....i%=1..|
00000320  c2 32 73 78 25 3d 28 a8  28 76 78 2d 77 69 64 32  |.2sx%=(.(vx-wid2|
00000330  25 29 2d 76 78 29 2a 73  78 3a 73 79 25 3d a4 68  |%)-vx)*sx:sy%=.h|
00000340  28 76 78 2d 77 69 64 32  25 2c 7a 25 29 2a 73 78  |(vx-wid2%,z%)*sx|
00000350  0d 01 cc 36 e7 20 7a 25  3c 76 7a 2b 64 65 70 25  |...6. z%<vz+dep%|
00000360  20 8c 20 86 20 73 78 25  28 30 29 2c 73 79 25 28  | . . sx%(0),sy%(|
00000370  30 29 2c 73 78 25 2c 73  79 25 20 8b 20 ec 20 73  |0),sx%,sy% . . s|
00000380  78 25 2c 73 79 25 0d 01  d6 19 73 78 25 28 30 29  |x%,sy%....sx%(0)|
00000390  3d 73 78 25 3a 73 79 25  28 30 29 3d 73 79 25 0d  |=sx%:sy%(0)=sy%.|
000003a0  01 e0 1b e3 78 25 3d 76  78 2d 77 69 64 33 25 20  |....x%=vx-wid3% |
000003b0  b8 20 76 78 2b 77 69 64  32 25 0d 01 ea 23 73 78  |. vx+wid2%...#sx|
000003c0  25 3d 28 78 25 2d 76 78  29 2a 73 78 3a 73 79 25  |%=(x%-vx)*sx:sy%|
000003d0  3d a4 68 28 78 25 2c 7a  25 29 2a 73 78 0d 01 f4  |=.h(x%,z%)*sx...|
000003e0  0d df 20 73 78 25 2c 73  79 25 0d 01 fe 2c e7 20  |.. sx%,sy%...,. |
000003f0  7a 25 3c 76 7a 2b 64 65  70 25 20 8c 20 86 20 73  |z%<vz+dep% . . s|
00000400  78 25 28 69 25 29 2c 73  79 25 28 69 25 29 2c 73  |x%(i%),sy%(i%),s|
00000410  78 25 2c 73 79 25 0d 02  08 1b 73 78 25 28 69 25  |x%,sy%....sx%(i%|
00000420  29 3d 73 78 25 3a 73 79  25 28 69 25 29 3d 73 79  |)=sx%:sy%(i%)=sy|
00000430  25 0d 02 12 09 69 25 2b  3d 31 0d 02 1c 05 ed 0d  |%....i%+=1......|
00000440  02 26 05 ed 0d 02 30 05  e1 0d 02 3a 05 3a 0d 02  |.&....0....:.:..|
00000450  44 27 dd a4 68 28 41 25  2c 42 25 29 3d ba 28 67  |D'..h(A%,B%)=.(g|
00000460  65 74 5f 66 72 61 63 29  2f 38 2d 31 30 2d 68 65  |et_frac)/8-10-he|
00000470  69 67 68 74 25 0d 02 4e  05 3a 0d 02 58 0e dd f2  |ight%..N.:..X...|
00000480  61 73 73 65 6d 62 6c 65  0d 02 62 50 de 20 63 6f  |assemble..bP. co|
00000490  64 65 25 20 31 30 32 34  2c 6e 6f 69 73 65 5f 74  |de% 1024,noise_t|
000004a0  61 62 25 20 32 36 32 31  34 34 2c 6e 6f 69 73 65  |ab% 262144,noise|
000004b0  5f 74 61 62 32 25 20 32  36 32 31 34 34 2c 62 65  |_tab2% 262144,be|
000004c0  7a 69 65 72 5f 66 61 63  74 6f 72 5f 74 61 62 6c  |zier_factor_tabl|
000004d0  65 25 20 31 36 33 38 34  0d 02 6c 14 e3 70 61 73  |e% 16384..l..pas|
000004e0  73 25 3d 30 20 b8 20 32  20 88 20 32 0d 02 76 0c  |s%=0 . 2 . 2..v.|
000004f0  50 25 3d 63 6f 64 65 25  0d 02 80 0e 5b 4f 50 54  |P%=code%....[OPT|
00000500  20 70 61 73 73 25 0d 02  8a 04 0d 02 94 0a 2e 73  | pass%.........s|
00000510  65 74 75 70 0d 02 9e 0d  6d 6f 76 20 72 30 2c 23  |etup....mov r0,#|
00000520  30 0d 02 a8 0e 73 77 69  20 26 32 30 30 36 44 0d  |0....swi &2006D.|
00000530  02 b2 11 6d 6f 76 76 73  20 72 31 30 2c 23 34 30  |...movvs r10,#40|
00000540  0d 02 bc 10 62 76 73 20  6e 6f 74 5f 72 6f 33 37  |....bvs not_ro37|
00000550  0d 02 c6 0d 74 73 74 20  72 30 2c 23 31 0d 02 d0  |....tst r0,#1...|
00000560  2c 6d 6f 76 65 71 20 72  31 30 2c 23 34 30 20 20  |,moveq r10,#40  |
00000570  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000580  20 3b 20 6e 6f 6e 2d 53  41 0d 02 da 2c 6d 6f 76  | ; non-SA...,mov|
00000590  6e 65 20 72 31 30 2c 23  31 36 30 20 20 20 20 20  |ne r10,#160     |
000005a0  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 53  |             ; S|
000005b0  41 2d 43 50 55 0d 02 e4  0d 2e 6e 6f 74 5f 72 6f  |A-CPU.....not_ro|
000005c0  33 37 0d 02 ee 0e 73 77  69 20 32 35 36 2b 32 32  |37....swi 256+22|
000005d0  0d 02 f8 11 73 77 69 20  26 32 30 31 30 30 2b 32  |....swi &20100+2|
000005e0  30 0d 03 02 13 62 76 73  20 74 72 79 5f 6d 6f 64  |0....bvs try_mod|
000005f0  65 5f 31 32 0d 03 0c 0d  6d 6f 76 20 72 30 2c 23  |e_12....mov r0,#|
00000600  32 0d 03 16 1c 73 77 69  20 22 4f 53 5f 52 65 61  |2....swi "OS_Rea|
00000610  64 44 79 6e 61 6d 69 63  41 72 65 61 22 0d 03 20  |dDynamicArea".. |
00000620  14 63 6d 70 20 72 31 2c  23 33 36 30 2a 31 30 32  |.cmp r1,#360*102|
00000630  34 0d 03 2a 10 6d 6f 76  67 65 20 72 30 2c 72 31  |4..*.movge r0,r1|
00000640  30 0d 03 34 10 6d 6f 76  67 65 20 70 63 2c 72 31  |0..4.movge pc,r1|
00000650  34 0d 03 3e 0d 6d 6f 76  20 72 30 2c 23 32 0d 03  |4..>.mov r0,#2..|
00000660  48 17 72 73 62 20 72 31  2c 72 31 2c 23 33 36 30  |H.rsb r1,r1,#360|
00000670  2a 31 30 32 34 0d 03 52  49 73 77 69 20 22 58 4f  |*1024..RIswi "XO|
00000680  53 5f 43 68 61 6e 67 65  44 79 6e 61 6d 69 63 41  |S_ChangeDynamicA|
00000690  72 65 61 22 20 20 20 20  20 3b 20 54 72 79 20 74  |rea"     ; Try t|
000006a0  6f 20 73 65 74 20 75 70  20 33 36 30 6b 20 6f 66  |o set up 360k of|
000006b0  20 73 63 72 65 65 6e 20  6d 65 6d 6f 72 79 0d 03  | screen memory..|
000006c0  5c 10 6d 6f 76 76 63 20  72 30 2c 72 31 30 0d 03  |\.movvc r0,r10..|
000006d0  66 10 6d 6f 76 76 63 20  70 63 2c 72 31 34 0d 03  |f.movvc pc,r14..|
000006e0  70 10 2e 74 72 79 5f 6d  6f 64 65 5f 31 32 0d 03  |p..try_mode_12..|
000006f0  7a 15 6d 6f 76 20 72 31  30 2c 72 31 30 2c 61 73  |z.mov r10,r10,as|
00000700  72 23 31 0d 03 84 0e 73  77 69 20 32 35 36 2b 32  |r#1....swi 256+2|
00000710  32 0d 03 8e 0e 73 77 69  20 32 35 36 2b 31 32 0d  |2....swi 256+12.|
00000720  03 98 0d 6d 6f 76 20 72  30 2c 23 32 0d 03 a2 1c  |...mov r0,#2....|
00000730  73 77 69 20 22 4f 53 5f  52 65 61 64 44 79 6e 61  |swi "OS_ReadDyna|
00000740  6d 69 63 41 72 65 61 22  0d 03 ac 14 63 6d 70 20  |micArea"....cmp |
00000750  72 31 2c 23 31 36 30 2a  31 30 32 34 0d 03 b6 10  |r1,#160*1024....|
00000760  6d 6f 76 67 65 20 72 30  2c 72 31 30 0d 03 c0 10  |movge r0,r10....|
00000770  6d 6f 76 67 65 20 70 63  2c 72 31 34 0d 03 ca 0d  |movge pc,r14....|
00000780  6d 6f 76 20 72 30 2c 23  32 0d 03 d4 17 72 73 62  |mov r0,#2....rsb|
00000790  20 72 31 2c 72 31 2c 23  31 36 30 2a 31 30 32 34  | r1,r1,#160*1024|
000007a0  0d 03 de 49 73 77 69 20  22 58 4f 53 5f 43 68 61  |...Iswi "XOS_Cha|
000007b0  6e 67 65 44 79 6e 61 6d  69 63 41 72 65 61 22 20  |ngeDynamicArea" |
000007c0  20 20 20 20 3b 20 54 72  79 20 74 6f 20 73 65 74  |    ; Try to set|
000007d0  20 75 70 20 31 36 30 6b  20 6f 66 20 73 63 72 65  | up 160k of scre|
000007e0  65 6e 20 6d 65 6d 6f 72  79 0d 03 e8 10 6d 6f 76  |en memory....mov|
000007f0  76 63 20 72 30 2c 72 31  30 0d 03 f2 10 6d 6f 76  |vc r0,r10....mov|
00000800  76 63 20 70 63 2c 72 31  34 0d 03 fc 22 61 64 72  |vc pc,r14..."adr|
00000810  20 72 30 2c 6e 6f 74 5f  65 6e 6f 75 67 68 5f 6d  | r0,not_enough_m|
00000820  65 6d 6f 72 79 5f 65 72  72 6f 72 0d 04 06 16 6f  |emory_error....o|
00000830  72 72 73 20 70 63 2c 72  31 34 2c 23 31 3c 3c 32  |rrs pc,r14,#1<<2|
00000840  38 0d 04 10 04 0d 04 1a  1c 2e 6e 6f 74 5f 65 6e  |8.........not_en|
00000850  6f 75 67 68 5f 6d 65 6d  6f 72 79 5f 65 72 72 6f  |ough_memory_erro|
00000860  72 0d 04 24 09 64 63 64  20 30 0d 04 2e 31 65 71  |r..$.dcd 0...1eq|
00000870  75 73 22 4e 65 65 64 73  20 61 74 20 6c 65 61 73  |us"Needs at leas|
00000880  74 20 31 36 30 6b 20 6f  66 20 73 63 72 65 65 6e  |t 160k of screen|
00000890  20 6d 65 6d 6f 72 79 22  2b bd 30 0d 04 38 09 41  | memory"+.0..8.A|
000008a0  4c 49 47 4e 0d 04 42 04  0d 04 4c 0e 2e 6e 6f 69  |LIGN..B...L..noi|
000008b0  73 65 5f 74 61 62 0d 04  56 12 64 63 64 20 6e 6f  |se_tab..V.dcd no|
000008c0  69 73 65 5f 74 61 62 25  0d 04 60 0f 2e 6e 6f 69  |ise_tab%..`..noi|
000008d0  73 65 5f 74 61 62 32 0d  04 6a 13 64 63 64 20 6e  |se_tab2..j.dcd n|
000008e0  6f 69 73 65 5f 74 61 62  32 25 0d 04 74 04 0d 04  |oise_tab2%..t...|
000008f0  7e 3d 3b 20 47 65 6e 65  72 61 74 65 20 74 61 62  |~=; Generate tab|
00000900  6c 65 20 6f 66 20 72 61  6e 64 6f 6d 20 6e 75 6d  |le of random num|
00000910  62 65 72 73 20 61 6e 64  20 73 6d 6f 6f 74 68 20  |bers and smooth |
00000920  61 20 66 65 77 20 74 69  6d 65 73 0d 04 88 04 0d  |a few times.....|
00000930  04 92 4f 2e 67 65 6e 5f  6e 6f 69 73 65 20 20 20  |..O.gen_noise   |
00000940  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000950  20 20 20 3b 20 72 30 20  3d 20 6c 6f 67 20 62 61  |   ; r0 = log ba|
00000960  73 65 20 32 20 73 69 7a  65 20 6f 66 20 74 61 62  |se 2 size of tab|
00000970  6c 65 20 28 38 3d 32 35  36 78 32 35 36 29 0d 04  |le (8=256x256)..|
00000980  9c 36 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.6              |
00000990  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000009a0  20 20 3b 20 72 31 20 3d  20 64 65 73 74 69 6e 61  |  ; r1 = destina|
000009b0  74 69 6f 6e 0d 04 a6 0e  6d 6f 76 20 72 31 31 2c  |tion....mov r11,|
000009c0  23 31 0d 04 b0 31 6d 6f  76 20 72 38 2c 72 31 31  |#1...1mov r8,r11|
000009d0  2c 6c 73 6c 20 72 30 20  20 20 20 20 20 20 20 20  |,lsl r0         |
000009e0  20 20 20 20 20 20 3b 20  63 6f 6c 75 6d 6e 20 73  |      ; column s|
000009f0  69 7a 65 0d 04 ba 33 6d  6f 76 20 72 31 31 2c 72  |ize...3mov r11,r|
00000a00  38 2c 6c 73 6c 20 72 30  20 20 20 20 20 20 20 20  |8,lsl r0        |
00000a10  20 20 20 20 20 20 20 3b  20 73 69 7a 65 20 69 6e  |       ; size in|
00000a20  20 62 79 74 65 73 0d 04  c4 2a 73 75 62 20 72 39  | bytes...*sub r9|
00000a30  2c 72 31 31 2c 23 31 20  20 20 20 20 20 20 20 20  |,r11,#1         |
00000a40  20 20 20 20 20 20 20 20  20 20 3b 20 6d 61 73 6b  |          ; mask|
00000a50  0d 04 ce 0e 6d 6f 76 20  72 31 32 2c 72 31 0d 04  |....mov r12,r1..|
00000a60  d8 1e 73 77 69 20 22 4f  53 5f 52 65 61 64 4d 6f  |..swi "OS_ReadMo|
00000a70  6e 6f 74 6f 6e 69 63 54  69 6d 65 22 0d 04 e2 0d  |notonicTime"....|
00000a80  6d 6f 76 20 72 31 2c 23  31 0d 04 ec 12 61 6e 64  |mov r1,#1....and|
00000a90  20 72 33 2c 72 30 2c 23  32 35 35 0d 04 f6 0d 2e  | r3,r0,#255.....|
00000aa0  72 6e 64 5f 6c 6f 6f 70  0d 05 00 13 74 73 74 20  |rnd_loop....tst |
00000ab0  72 31 2c 72 31 2c 6c 73  72 23 31 0d 05 0a 12 6d  |r1,r1,lsr#1....m|
00000ac0  6f 76 73 20 72 32 2c 72  30 2c 72 72 78 0d 05 14  |ovs r2,r0,rrx...|
00000ad0  10 61 64 63 20 72 31 2c  72 31 2c 72 31 0d 05 1e  |.adc r1,r1,r1...|
00000ae0  17 65 6f 72 20 72 32 2c  72 32 2c 72 30 2c 6c 73  |.eor r2,r2,r0,ls|
00000af0  6c 23 31 32 0d 05 28 17  65 6f 72 20 72 30 2c 72  |l#12..(.eor r0,r|
00000b00  32 2c 72 32 2c 6c 73 72  23 32 30 0d 05 32 11 73  |2,r2,lsr#20..2.s|
00000b10  75 62 73 20 72 33 2c 72  33 2c 23 31 0d 05 3c 10  |ubs r3,r3,#1..<.|
00000b20  62 67 74 20 72 6e 64 5f  6c 6f 6f 70 0d 05 46 04  |bgt rnd_loop..F.|
00000b30  0d 05 50 31 6d 6f 76 20  72 33 2c 72 31 32 20 20  |..P1mov r3,r12  |
00000b40  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000b50  20 20 20 20 3b 20 64 65  73 74 69 6e 61 74 69 6f  |    ; destinatio|
00000b60  6e 0d 05 5a 2a 6d 6f 76  20 72 34 2c 72 31 31 20  |n..Z*mov r4,r11 |
00000b70  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000b80  20 20 20 20 20 3b 20 73  69 7a 65 0d 05 64 0d 2e  |     ; size..d..|
00000b90  67 65 6e 5f 6c 6f 6f 70  0d 05 6e 13 74 73 74 20  |gen_loop..n.tst |
00000ba0  72 31 2c 72 31 2c 6c 73  72 23 31 0d 05 78 12 6d  |r1,r1,lsr#1..x.m|
00000bb0  6f 76 73 20 72 32 2c 72  30 2c 72 72 78 0d 05 82  |ovs r2,r0,rrx...|
00000bc0  10 61 64 63 20 72 31 2c  72 31 2c 72 31 0d 05 8c  |.adc r1,r1,r1...|
00000bd0  17 65 6f 72 20 72 32 2c  72 32 2c 72 30 2c 6c 73  |.eor r2,r2,r0,ls|
00000be0  6c 23 31 32 0d 05 96 33  65 6f 72 20 72 30 2c 72  |l#12...3eor r0,r|
00000bf0  32 2c 72 32 2c 6c 73 72  23 32 30 20 20 20 20 20  |2,r2,lsr#20     |
00000c00  20 20 20 20 20 20 20 20  3b 20 72 61 6e 64 6f 6d  |        ; random|
00000c10  20 6e 75 6d 62 65 72 0d  05 a0 12 73 74 72 20 72  | number....str r|
00000c20  30 2c 5b 72 33 5d 2c 23  34 0d 05 aa 11 73 75 62  |0,[r3],#4....sub|
00000c30  73 20 72 34 2c 72 34 2c  23 34 0d 05 b4 10 62 67  |s r4,r4,#4....bg|
00000c40  74 20 67 65 6e 5f 6c 6f  6f 70 0d 05 be 27 6d 6f  |t gen_loop...'mo|
00000c50  76 20 72 31 2c 23 32 20  20 20 20 20 20 20 20 20  |v r1,#2         |
00000c60  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00000c70  6e 0d 05 c8 0e 2e 73 6d  6f 6f 74 68 74 61 62 0d  |n.....smoothtab.|
00000c80  05 d2 15 6c 64 72 20 72  36 2c 6e 6f 69 73 65 5f  |...ldr r6,noise_|
00000c90  74 61 62 32 0d 05 dc 0a  2e 6e 6c 6f 6f 70 0d 05  |tab2.....nloop..|
00000ca0  e6 2a 6d 6f 76 20 72 32  2c 72 31 31 20 20 20 20  |.*mov r2,r11    |
00000cb0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000cc0  20 20 3b 20 73 69 7a 65  0d 05 f0 0a 2e 73 6c 6f  |  ; size.....slo|
00000cd0  6f 70 0d 05 fa 2c 6c 64  72 62 20 72 33 2c 5b 72  |op...,ldrb r3,[r|
00000ce0  31 32 2c 72 32 5d 20 20  20 20 20 20 20 20 20 20  |12,r2]          |
00000cf0  20 20 20 20 20 20 3b 20  6d 69 64 64 6c 65 0d 06  |      ; middle..|
00000d00  04 10 73 75 62 20 72 35  2c 72 32 2c 23 31 0d 06  |..sub r5,r2,#1..|
00000d10  0e 10 61 6e 64 20 72 35  2c 72 35 2c 72 39 0d 06  |..and r5,r5,r9..|
00000d20  18 2a 6c 64 72 62 20 72  34 2c 5b 72 31 32 2c 72  |.*ldrb r4,[r12,r|
00000d30  35 5d 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |5]              |
00000d40  20 20 3b 20 6c 65 66 74  0d 06 22 10 61 64 64 20  |  ; left..".add |
00000d50  72 33 2c 72 33 2c 72 34  0d 06 2c 10 61 64 64 20  |r3,r3,r4..,.add |
00000d60  72 35 2c 72 32 2c 23 31  0d 06 36 10 61 6e 64 20  |r5,r2,#1..6.and |
00000d70  72 35 2c 72 35 2c 72 39  0d 06 40 2b 6c 64 72 62  |r5,r5,r9..@+ldrb|
00000d80  20 72 34 2c 5b 72 31 32  2c 72 35 5d 20 20 20 20  | r4,[r12,r5]    |
00000d90  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 72 69  |            ; ri|
00000da0  67 68 74 0d 06 4a 10 61  64 64 20 72 33 2c 72 33  |ght..J.add r3,r3|
00000db0  2c 72 34 0d 06 54 31 73  75 62 20 72 35 2c 72 32  |,r4..T1sub r5,r2|
00000dc0  2c 72 38 20 20 20 20 20  20 20 20 20 20 20 20 20  |,r8             |
00000dd0  20 20 20 20 20 20 20 3b  20 63 6f 6c 75 6d 6e 20  |       ; column |
00000de0  73 69 7a 65 0d 06 5e 10  61 6e 64 20 72 35 2c 72  |size..^.and r5,r|
00000df0  35 2c 72 39 0d 06 68 29  6c 64 72 62 20 72 34 2c  |5,r9..h)ldrb r4,|
00000e00  5b 72 31 32 2c 72 35 5d  20 20 20 20 20 20 20 20  |[r12,r5]        |
00000e10  20 20 20 20 20 20 20 20  3b 20 74 6f 70 0d 06 72  |        ; top..r|
00000e20  10 61 64 64 20 72 33 2c  72 33 2c 72 34 0d 06 7c  |.add r3,r3,r4..||
00000e30  10 73 75 62 20 72 35 2c  72 35 2c 23 31 0d 06 86  |.sub r5,r5,#1...|
00000e40  10 61 6e 64 20 72 35 2c  72 35 2c 72 39 0d 06 90  |.and r5,r5,r9...|
00000e50  2e 6c 64 72 62 20 72 34  2c 5b 72 31 32 2c 72 35  |.ldrb r4,[r12,r5|
00000e60  5d 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |]               |
00000e70  20 3b 20 74 6f 70 2d 6c  65 66 74 0d 06 9a 10 61  | ; top-left....a|
00000e80  64 64 20 72 33 2c 72 33  2c 72 34 0d 06 a4 10 61  |dd r3,r3,r4....a|
00000e90  64 64 20 72 35 2c 72 35  2c 23 32 0d 06 ae 10 61  |dd r5,r5,#2....a|
00000ea0  6e 64 20 72 35 2c 72 35  2c 72 39 0d 06 b8 2f 6c  |nd r5,r5,r9.../l|
00000eb0  64 72 62 20 72 34 2c 5b  72 31 32 2c 72 35 5d 20  |drb r4,[r12,r5] |
00000ec0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 3b  |               ;|
00000ed0  20 74 6f 70 2d 72 69 67  68 74 0d 06 c2 10 61 64  | top-right....ad|
00000ee0  64 20 72 33 2c 72 33 2c  72 34 0d 06 cc 31 61 64  |d r3,r3,r4...1ad|
00000ef0  64 20 72 35 2c 72 32 2c  72 38 20 20 20 20 20 20  |d r5,r2,r8      |
00000f00  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00000f10  63 6f 6c 75 6d 6e 20 73  69 7a 65 0d 06 d6 10 61  |column size....a|
00000f20  6e 64 20 72 35 2c 72 35  2c 72 39 0d 06 e0 2c 6c  |nd r5,r5,r9...,l|
00000f30  64 72 62 20 72 34 2c 5b  72 31 32 2c 72 35 5d 20  |drb r4,[r12,r5] |
00000f40  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 3b  |               ;|
00000f50  20 62 6f 74 74 6f 6d 0d  06 ea 10 61 64 64 20 72  | bottom....add r|
00000f60  33 2c 72 33 2c 72 34 0d  06 f4 10 73 75 62 20 72  |3,r3,r4....sub r|
00000f70  35 2c 72 35 2c 23 31 0d  06 fe 10 61 6e 64 20 72  |5,r5,#1....and r|
00000f80  35 2c 72 35 2c 72 39 0d  07 08 31 6c 64 72 62 20  |5,r5,r9...1ldrb |
00000f90  72 34 2c 5b 72 31 32 2c  72 35 5d 20 20 20 20 20  |r4,[r12,r5]     |
00000fa0  20 20 20 20 20 20 20 20  20 20 20 3b 20 62 6f 74  |           ; bot|
00000fb0  74 6f 6d 2d 6c 65 66 74  0d 07 12 10 61 64 64 20  |tom-left....add |
00000fc0  72 33 2c 72 33 2c 72 34  0d 07 1c 10 61 64 64 20  |r3,r3,r4....add |
00000fd0  72 35 2c 72 35 2c 23 32  0d 07 26 10 61 6e 64 20  |r5,r5,#2..&.and |
00000fe0  72 35 2c 72 35 2c 72 39  0d 07 30 32 6c 64 72 62  |r5,r5,r9..02ldrb|
00000ff0  20 72 34 2c 5b 72 31 32  2c 72 35 5d 20 20 20 20  | r4,[r12,r5]    |
00001000  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 62 6f  |            ; bo|
00001010  74 74 6f 6d 2d 72 69 67  68 74 0d 07 3a 10 61 64  |ttom-right..:.ad|
00001020  64 20 72 33 2c 72 33 2c  72 34 0d 07 44 04 0d 07  |d r3,r3,r4..D...|
00001030  4e 13 6d 6f 76 20 72 34  2c 72 33 2c 6c 73 72 23  |N.mov r4,r3,lsr#|
00001040  33 0d 07 58 16 73 75 62  20 72 34 2c 72 34 2c 72  |3..X.sub r4,r4,r|
00001050  33 2c 6c 73 72 23 37 0d  07 62 17 61 64 64 20 72  |3,lsr#7..b.add r|
00001060  34 2c 72 34 2c 72 33 2c  6c 73 72 23 31 30 0d 07  |4,r4,r3,lsr#10..|
00001070  6c 17 61 64 64 20 72 34  2c 72 34 2c 72 33 2c 6c  |l.add r4,r4,r3,l|
00001080  73 72 23 31 31 0d 07 76  18 61 64 64 73 20 72 33  |sr#11..v.adds r3|
00001090  2c 72 34 2c 72 33 2c 6c  73 72 23 31 32 0d 07 80  |,r4,r3,lsr#12...|
000010a0  0f 6d 6f 76 6c 74 20 72  33 2c 23 30 0d 07 8a 0f  |.movlt r3,#0....|
000010b0  63 6d 70 20 72 33 2c 23  32 35 35 0d 07 94 11 6d  |cmp r3,#255....m|
000010c0  6f 76 67 74 20 72 33 2c  23 32 35 35 0d 07 9e 3d  |ovgt r3,#255...=|
000010d0  73 74 72 62 20 72 33 2c  5b 72 36 2c 72 32 5d 20  |strb r3,[r6,r2] |
000010e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000010f0  3b 20 72 65 73 74 6f 72  65 20 2d 20 69 6e 20 6f  |; restore - in o|
00001100  74 68 65 72 20 62 61 6e  6b 0d 07 a8 04 0d 07 b2  |ther bank.......|
00001110  11 73 75 62 73 20 72 32  2c 72 32 2c 23 31 0d 07  |.subs r2,r2,#1..|
00001120  bc 0d 62 67 65 20 73 6c  6f 6f 70 0d 07 c6 04 0d  |..bge sloop.....|
00001130  07 d0 31 6d 6f 76 20 72  33 2c 72 31 32 20 20 20  |..1mov r3,r12   |
00001140  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001150  20 20 20 3b 20 64 65 73  74 69 6e 61 74 69 6f 6e  |   ; destination|
00001160  0d 07 da 31 6d 6f 76 20  72 34 2c 72 36 20 20 20  |...1mov r4,r6   |
00001170  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001180  20 20 20 20 3b 20 73 65  63 6f 6e 64 20 62 61 6e  |    ; second ban|
00001190  6b 0d 07 e4 2a 61 64 64  20 72 35 2c 72 33 2c 72  |k...*add r5,r3,r|
000011a0  31 31 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |11              |
000011b0  20 20 20 20 20 3b 20 73  69 7a 65 0d 07 ee 08 2e  |     ; size.....|
000011c0  63 6c 70 0d 07 f8 12 6c  64 72 20 72 30 2c 5b 72  |clp....ldr r0,[r|
000011d0  34 5d 2c 23 34 0d 08 02  12 73 74 72 20 72 30 2c  |4],#4....str r0,|
000011e0  5b 72 33 5d 2c 23 34 0d  08 0c 0d 63 6d 70 20 72  |[r3],#4....cmp r|
000011f0  33 2c 72 35 0d 08 16 0b  62 6c 74 20 63 6c 70 0d  |3,r5....blt clp.|
00001200  08 20 04 0d 08 2a 11 73  75 62 73 20 72 31 2c 72  |. ...*.subs r1,r|
00001210  31 2c 23 31 0d 08 34 0d  62 67 74 20 6e 6c 6f 6f  |1,#1..4.bgt nloo|
00001220  70 0d 08 3e 0e 6d 6f 76  20 70 63 2c 72 31 34 0d  |p..>.mov pc,r14.|
00001230  08 48 04 0d 08 52 13 2e  62 65 7a 69 65 72 5f 66  |.H...R..bezier_f|
00001240  61 63 74 6f 72 73 0d 08  5c 1c 64 63 64 20 62 65  |actors..\.dcd be|
00001250  7a 69 65 72 5f 66 61 63  74 6f 72 5f 74 61 62 6c  |zier_factor_tabl|
00001260  65 25 0d 08 66 04 0d 08  70 0b 2e 73 74 61 63 6b  |e%..f...p..stack|
00001270  70 0d 08 7a 09 64 63 64  20 30 0d 08 84 04 0d 08  |p..z.dcd 0......|
00001280  8e 04 0d 08 98 27 3b 20  52 65 61 64 20 61 20 76  |.....'; Read a v|
00001290  61 6c 75 65 20 66 72 6f  6d 20 74 68 65 20 6e 6f  |alue from the no|
000012a0  69 73 65 20 74 61 62 6c  65 0d 08 a2 45 3b 20 61  |ise table...E; a|
000012b0  74 20 66 72 61 63 74 69  6f 6e 61 6c 20 63 6f 6f  |t fractional coo|
000012c0  72 64 69 6e 61 74 65 73  20 73 6f 20 69 6e 74 65  |rdinates so inte|
000012d0  72 70 6f 6c 61 74 65 20  75 73 69 6e 67 20 61 20  |rpolate using a |
000012e0  63 75 62 69 63 20 66 75  6e 63 74 69 6f 6e 0d 08  |cubic function..|
000012f0  ac 04 0d 08 b6 36 2e 67  65 74 5f 6e 6f 69 73 65  |.....6.get_noise|
00001300  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001310  20 20 20 20 20 20 3b 20  72 30 20 3d 20 6e 6f 69  |      ; r0 = noi|
00001320  73 65 20 74 61 62 6c 65  0d 08 c0 30 20 20 20 20  |se table...0    |
00001330  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001340  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 72 38  |            ; r8|
00001350  20 3d 20 78 3c 3c 31 30  0d 08 ca 30 20 20 20 20  | = x<<10...0    |
00001360  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001370  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 72 39  |            ; r9|
00001380  20 3d 20 7a 3c 3c 31 30  0d 08 d4 21 73 74 6d 66  | = z<<10...!stmf|
00001390  64 20 72 31 33 21 2c 7b  72 31 2d 72 37 2c 72 39  |d r13!,{r1-r7,r9|
000013a0  2d 72 31 32 2c 72 31 34  7d 0d 08 de 12 73 74 72  |-r12,r14}....str|
000013b0  20 72 31 33 2c 73 74 61  63 6b 70 0d 08 e8 15 6d  | r13,stackp....m|
000013c0  6f 76 20 72 31 32 2c 72  38 2c 6c 73 6c 23 32 32  |ov r12,r8,lsl#22|
000013d0  0d 08 f2 3a 6d 6f 76 20  72 31 32 2c 72 31 32 2c  |...:mov r12,r12,|
000013e0  6c 73 72 23 32 32 20 20  20 20 20 20 20 20 20 20  |lsr#22          |
000013f0  20 20 20 20 3b 20 78 20  61 6e 64 20 31 30 32 33  |    ; x and 1023|
00001400  20 3d 20 66 72 61 63 28  78 29 0d 08 fc 19 6c 64  | = frac(x)....ld|
00001410  72 20 72 31 2c 62 65 7a  69 65 72 5f 66 61 63 74  |r r1,bezier_fact|
00001420  6f 72 73 0d 09 06 17 61  64 64 20 72 32 2c 72 31  |ors....add r2,r1|
00001430  2c 72 31 32 2c 6c 73 6c  23 34 0d 09 10 38 6c 64  |,r12,lsl#4...8ld|
00001440  6d 69 61 20 72 32 2c 7b  72 36 2c 72 37 2c 72 31  |mia r2,{r6,r7,r1|
00001450  32 2c 72 31 33 7d 20 20  20 20 20 20 20 20 3b 20  |2,r13}        ; |
00001460  72 36 20 3d 20 28 31 2d  78 29 5e 33 20 3c 3c 20  |r6 = (1-x)^3 << |
00001470  31 30 0d 09 1a 3a 20 20  20 20 20 20 20 20 20 20  |10...:          |
00001480  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001490  20 20 20 20 20 20 3b 20  72 37 20 3d 20 33 78 28  |      ; r7 = 3x(|
000014a0  31 2d 78 29 5e 32 20 3c  3c 20 31 30 0d 09 24 3b  |1-x)^2 << 10..$;|
000014b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000014d0  3b 20 72 31 32 20 3d 20  33 78 5e 32 28 31 2d 78  |; r12 = 3x^2(1-x|
000014e0  29 20 3c 3c 20 31 30 0d  09 2e 35 20 20 20 20 20  |) << 10...5     |
000014f0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001500  20 20 20 20 20 20 20 20  20 20 20 3b 20 72 31 33  |           ; r13|
00001510  20 3d 20 78 5e 33 20 3c  3c 20 31 30 0d 09 38 39  | = x^3 << 10..89|
00001520  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00001540  3b 20 78 20 3d 20 28 31  2f 33 29 2b 66 72 61 63  |; x = (1/3)+frac|
00001550  28 78 29 2f 33 0d 09 42  15 6d 6f 76 20 72 31 34  |(x)/3..B.mov r14|
00001560  2c 72 39 2c 6c 73 6c 23  32 32 0d 09 4c 3b 6d 6f  |,r9,lsl#22..L;mo|
00001570  76 20 72 31 34 2c 72 31  34 2c 6c 73 72 23 32 32  |v r14,r14,lsr#22|
00001580  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00001590  7a 20 61 6e 64 20 31 30  32 33 20 20 3d 20 66 72  |z and 1023  = fr|
000015a0  61 63 28 7a 29 0d 09 56  45 61 64 64 20 72 31 34  |ac(z)..VEadd r14|
000015b0  2c 72 31 2c 72 31 34 2c  6c 73 6c 23 34 20 20 20  |,r1,r14,lsl#4   |
000015c0  20 20 20 20 20 20 20 20  20 3b 20 72 31 34 20 2d  |         ; r14 -|
000015d0  3e 20 62 65 7a 69 65 72  5f 66 72 61 63 74 6f 72  |> bezier_fractor|
000015e0  73 28 66 72 61 63 28 7a  29 29 0d 09 60 04 0d 09  |s(frac(z))..`...|
000015f0  6a 30 6d 6f 76 20 72 38  2c 72 38 2c 6c 73 6c 23  |j0mov r8,r8,lsl#|
00001600  31 33 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |13              |
00001610  20 20 3b 20 72 38 20 3d  20 78 3c 3c 32 33 0d 09  |  ; r8 = x<<23..|
00001620  74 30 6d 6f 76 20 72 39  2c 72 39 2c 6c 73 6c 23  |t0mov r9,r9,lsl#|
00001630  31 33 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |13              |
00001640  20 20 3b 20 72 39 20 3d  20 7a 3c 3c 32 33 0d 09  |  ; r9 = z<<23..|
00001650  7e 31 73 75 62 20 72 31  30 2c 72 38 2c 23 31 3c  |~1sub r10,r8,#1<|
00001660  3c 32 33 20 20 20 20 20  20 20 20 20 20 20 20 20  |<23             |
00001670  20 20 3b 20 78 2d 31 20  61 6e 64 20 35 31 31 0d  |  ; x-1 and 511.|
00001680  09 88 31 73 75 62 20 72  31 31 2c 72 39 2c 23 31  |..1sub r11,r9,#1|
00001690  3c 3c 32 33 20 20 20 20  20 20 20 20 20 20 20 20  |<<23            |
000016a0  20 20 20 3b 20 7a 2d 31  20 61 6e 64 20 35 31 31  |   ; z-1 and 511|
000016b0  0d 09 92 2e 6d 6f 76 20  72 31 31 2c 72 31 31 2c  |....mov r11,r11,|
000016c0  6c 73 72 23 32 33 20 20  20 20 20 20 20 20 20 20  |lsr#23          |
000016d0  20 20 20 20 3b 20 69 6e  74 28 7a 2d 31 29 0d 09  |    ; int(z-1)..|
000016e0  9c 18 61 64 64 20 72 31  31 2c 72 30 2c 72 31 31  |..add r11,r0,r11|
000016f0  2c 6c 73 6c 23 39 0d 09  a6 34 6c 64 72 62 20 72  |,lsl#9...4ldrb r|
00001700  31 2c 5b 72 31 31 2c 72  31 30 2c 6c 73 72 23 32  |1,[r11,r10,lsr#2|
00001710  33 5d 20 20 20 20 20 20  20 20 3b 20 6e 6f 69 73  |3]        ; nois|
00001720  65 28 78 2d 31 2c 7a 2d  31 29 0d 09 b0 32 6c 64  |e(x-1,z-1)...2ld|
00001730  72 62 20 72 32 2c 5b 72  31 31 2c 72 38 2c 6c 73  |rb r2,[r11,r8,ls|
00001740  72 23 32 33 5d 20 20 20  20 20 20 20 20 20 3b 20  |r#23]         ; |
00001750  6e 6f 69 73 65 28 78 2c  7a 2d 31 29 0d 09 ba 32  |noise(x,z-1)...2|
00001760  61 64 64 20 72 31 30 2c  72 38 2c 23 31 3c 3c 32  |add r10,r8,#1<<2|
00001770  33 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |3               |
00001780  3b 20 78 2b 31 20 61 6e  64 20 31 30 32 33 0d 09  |; x+1 and 1023..|
00001790  c4 34 6c 64 72 62 20 72  33 2c 5b 72 31 31 2c 72  |.4ldrb r3,[r11,r|
000017a0  31 30 2c 6c 73 72 23 32  33 5d 20 20 20 20 20 20  |10,lsr#23]      |
000017b0  20 20 3b 20 6e 6f 69 73  65 28 78 2b 31 2c 7a 2d  |  ; noise(x+1,z-|
000017c0  31 29 0d 09 ce 32 61 64  64 20 72 31 30 2c 72 38  |1)...2add r10,r8|
000017d0  2c 23 32 3c 3c 32 33 20  20 20 20 20 20 20 20 20  |,#2<<23         |
000017e0  20 20 20 20 20 20 3b 20  78 2b 32 20 61 6e 64 20  |      ; x+2 and |
000017f0  31 30 32 33 0d 09 d8 34  6c 64 72 62 20 72 34 2c  |1023...4ldrb r4,|
00001800  5b 72 31 31 2c 72 31 30  2c 6c 73 72 23 32 33 5d  |[r11,r10,lsr#23]|
00001810  20 20 20 20 20 20 20 20  3b 20 6e 6f 69 73 65 28  |        ; noise(|
00001820  78 2b 32 2c 7a 2d 31 29  0d 09 e2 04 0d 09 ec 10  |x+2,z-1)........|
00001830  6d 75 6c 20 72 31 2c 72  36 2c 72 31 0d 09 f6 13  |mul r1,r6,r1....|
00001840  6d 6c 61 20 72 31 2c 72  37 2c 72 32 2c 72 31 0d  |mla r1,r7,r2,r1.|
00001850  0a 00 14 6d 6c 61 20 72  31 2c 72 31 32 2c 72 33  |...mla r1,r12,r3|
00001860  2c 72 31 0d 0a 0a 3c 6d  6c 61 20 72 31 2c 72 31  |,r1...<mla r1,r1|
00001870  33 2c 72 34 2c 72 31 20  20 20 20 20 20 20 20 20  |3,r4,r1         |
00001880  20 20 20 20 20 20 20 3b  20 63 75 62 69 63 20 62  |       ; cubic b|
00001890  6c 65 6e 64 20 4e 6f 69  73 65 28 7a 2d 31 29 0d  |lend Noise(z-1).|
000018a0  0a 14 13 6c 64 72 20 72  32 2c 5b 72 31 34 5d 2c  |...ldr r2,[r14],|
000018b0  23 34 0d 0a 1e 37 6d 75  6c 20 72 31 2c 72 32 2c  |#4...7mul r1,r2,|
000018c0  72 31 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |r1              |
000018d0  20 20 20 20 20 20 3b 20  66 69 72 73 74 20 63 75  |      ; first cu|
000018e0  62 69 63 20 70 6f 69 6e  74 0d 0a 28 04 0d 0a 32  |bic point..(...2|
000018f0  32 73 75 62 20 72 31 30  2c 72 38 2c 23 31 3c 3c  |2sub r10,r8,#1<<|
00001900  32 33 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |23              |
00001910  20 3b 20 78 2d 31 20 61  6e 64 20 31 30 32 33 0d  | ; x-1 and 1023.|
00001920  0a 3c 2c 6d 6f 76 20 72  31 31 2c 72 39 2c 6c 73  |.<,mov r11,r9,ls|
00001930  72 23 32 33 20 20 20 20  20 20 20 20 20 20 20 20  |r#23            |
00001940  20 20 20 3b 20 69 6e 74  28 7a 29 0d 0a 46 18 61  |   ; int(z)..F.a|
00001950  64 64 20 72 31 31 2c 72  30 2c 72 31 31 2c 6c 73  |dd r11,r0,r11,ls|
00001960  6c 23 39 0d 0a 50 32 6c  64 72 62 20 72 32 2c 5b  |l#9..P2ldrb r2,[|
00001970  72 31 31 2c 72 31 30 2c  6c 73 72 23 32 33 5d 20  |r11,r10,lsr#23] |
00001980  20 20 20 20 20 20 20 3b  20 6e 6f 69 73 65 28 78  |       ; noise(x|
00001990  2d 31 2c 7a 29 0d 0a 5a  30 6c 64 72 62 20 72 33  |-1,z)..Z0ldrb r3|
000019a0  2c 5b 72 31 31 2c 72 38  2c 6c 73 72 23 32 33 5d  |,[r11,r8,lsr#23]|
000019b0  20 20 20 20 20 20 20 20  20 3b 20 6e 6f 69 73 65  |         ; noise|
000019c0  28 78 2c 7a 29 0d 0a 64  32 61 64 64 20 72 31 30  |(x,z)..d2add r10|
000019d0  2c 72 38 2c 23 31 3c 3c  32 33 20 20 20 20 20 20  |,r8,#1<<23      |
000019e0  20 20 20 20 20 20 20 20  20 3b 20 78 2b 31 20 61  |         ; x+1 a|
000019f0  6e 64 20 31 30 32 33 0d  0a 6e 32 6c 64 72 62 20  |nd 1023..n2ldrb |
00001a00  72 34 2c 5b 72 31 31 2c  72 31 30 2c 6c 73 72 23  |r4,[r11,r10,lsr#|
00001a10  32 33 5d 20 20 20 20 20  20 20 20 3b 20 6e 6f 69  |23]        ; noi|
00001a20  73 65 28 78 2b 31 2c 7a  29 0d 0a 78 32 61 64 64  |se(x+1,z)..x2add|
00001a30  20 72 31 30 2c 72 38 2c  23 32 3c 3c 32 33 20 20  | r10,r8,#2<<23  |
00001a40  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 78  |             ; x|
00001a50  2b 32 20 61 6e 64 20 31  30 32 33 0d 0a 82 32 6c  |+2 and 1023...2l|
00001a60  64 72 62 20 72 35 2c 5b  72 31 31 2c 72 31 30 2c  |drb r5,[r11,r10,|
00001a70  6c 73 72 23 32 33 5d 20  20 20 20 20 20 20 20 3b  |lsr#23]        ;|
00001a80  20 6e 6f 69 73 65 28 78  2b 32 2c 7a 29 0d 0a 8c  | noise(x+2,z)...|
00001a90  04 0d 0a 96 10 6d 75 6c  20 72 32 2c 72 36 2c 72  |.....mul r2,r6,r|
00001aa0  32 0d 0a a0 13 6d 6c 61  20 72 32 2c 72 37 2c 72  |2....mla r2,r7,r|
00001ab0  33 2c 72 32 0d 0a aa 14  6d 6c 61 20 72 32 2c 72  |3,r2....mla r2,r|
00001ac0  31 32 2c 72 34 2c 72 32  0d 0a b4 3a 6d 6c 61 20  |12,r4,r2...:mla |
00001ad0  72 32 2c 72 31 33 2c 72  35 2c 72 32 20 20 20 20  |r2,r13,r5,r2    |
00001ae0  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 63 75  |            ; cu|
00001af0  62 69 63 20 62 6c 65 6e  64 20 4e 6f 69 73 65 28  |bic blend Noise(|
00001b00  7a 29 0d 0a be 13 6c 64  72 20 72 33 2c 5b 72 31  |z)....ldr r3,[r1|
00001b10  34 5d 2c 23 34 0d 0a c8  38 6d 6c 61 20 72 31 2c  |4],#4...8mla r1,|
00001b20  72 32 2c 72 33 2c 72 31  20 20 20 20 20 20 20 20  |r2,r3,r1        |
00001b30  20 20 20 20 20 20 20 20  20 3b 20 73 65 63 6f 6e  |         ; secon|
00001b40  64 20 63 75 62 69 63 20  70 6f 69 6e 74 0d 0a d2  |d cubic point...|
00001b50  04 0d 0a dc 32 73 75 62  20 72 31 30 2c 72 38 2c  |....2sub r10,r8,|
00001b60  23 31 3c 3c 32 33 20 20  20 20 20 20 20 20 20 20  |#1<<23          |
00001b70  20 20 20 20 20 3b 20 78  2d 31 20 61 6e 64 20 31  |     ; x-1 and 1|
00001b80  30 32 33 0d 0a e6 32 61  64 64 20 72 31 31 2c 72  |023...2add r11,r|
00001b90  39 2c 23 31 3c 3c 32 33  20 20 20 20 20 20 20 20  |9,#1<<23        |
00001ba0  20 20 20 20 20 20 20 3b  20 7a 2b 31 20 61 6e 64  |       ; z+1 and|
00001bb0  20 31 30 32 33 0d 0a f0  16 6d 6f 76 20 72 31 31  | 1023....mov r11|
00001bc0  2c 72 31 31 2c 6c 73 72  23 32 33 0d 0a fa 18 61  |,r11,lsr#23....a|
00001bd0  64 64 20 72 31 31 2c 72  30 2c 72 31 31 2c 6c 73  |dd r11,r0,r11,ls|
00001be0  6c 23 39 0d 0b 04 34 6c  64 72 62 20 72 32 2c 5b  |l#9...4ldrb r2,[|
00001bf0  72 31 31 2c 72 31 30 2c  6c 73 72 23 32 33 5d 20  |r11,r10,lsr#23] |
00001c00  20 20 20 20 20 20 20 3b  20 6e 6f 69 73 65 28 78  |       ; noise(x|
00001c10  2d 31 2c 7a 2b 31 29 0d  0b 0e 32 6c 64 72 62 20  |-1,z+1)...2ldrb |
00001c20  72 33 2c 5b 72 31 31 2c  72 38 2c 6c 73 72 23 32  |r3,[r11,r8,lsr#2|
00001c30  33 5d 20 20 20 20 20 20  20 20 20 3b 20 6e 6f 69  |3]         ; noi|
00001c40  73 65 28 78 2c 7a 2b 31  29 0d 0b 18 32 61 64 64  |se(x,z+1)...2add|
00001c50  20 72 31 30 2c 72 38 2c  23 31 3c 3c 32 33 20 20  | r10,r8,#1<<23  |
00001c60  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 78  |             ; x|
00001c70  2b 31 20 61 6e 64 20 31  30 32 33 0d 0b 22 34 6c  |+1 and 1023.."4l|
00001c80  64 72 62 20 72 34 2c 5b  72 31 31 2c 72 31 30 2c  |drb r4,[r11,r10,|
00001c90  6c 73 72 23 32 33 5d 20  20 20 20 20 20 20 20 3b  |lsr#23]        ;|
00001ca0  20 6e 6f 69 73 65 28 78  2b 31 2c 7a 2b 31 29 0d  | noise(x+1,z+1).|
00001cb0  0b 2c 32 61 64 64 20 72  31 30 2c 72 38 2c 23 32  |.,2add r10,r8,#2|
00001cc0  3c 3c 32 33 20 20 20 20  20 20 20 20 20 20 20 20  |<<23            |
00001cd0  20 20 20 3b 20 78 2b 32  20 61 6e 64 20 31 30 32  |   ; x+2 and 102|
00001ce0  33 0d 0b 36 34 6c 64 72  62 20 72 35 2c 5b 72 31  |3..64ldrb r5,[r1|
00001cf0  31 2c 72 31 30 2c 6c 73  72 23 32 33 5d 20 20 20  |1,r10,lsr#23]   |
00001d00  20 20 20 20 20 3b 20 6e  6f 69 73 65 28 78 2b 32  |     ; noise(x+2|
00001d10  2c 7a 2b 31 29 0d 0b 40  04 0d 0b 4a 10 6d 75 6c  |,z+1)..@...J.mul|
00001d20  20 72 32 2c 72 36 2c 72  32 0d 0b 54 13 6d 6c 61  | r2,r6,r2..T.mla|
00001d30  20 72 32 2c 72 37 2c 72  33 2c 72 32 0d 0b 5e 14  | r2,r7,r3,r2..^.|
00001d40  6d 6c 61 20 72 32 2c 72  31 32 2c 72 34 2c 72 32  |mla r2,r12,r4,r2|
00001d50  0d 0b 68 3a 6d 6c 61 20  72 32 2c 72 31 33 2c 72  |..h:mla r2,r13,r|
00001d60  35 2c 72 32 20 20 20 20  20 20 20 20 20 20 20 20  |5,r2            |
00001d70  20 20 20 20 3b 20 63 75  62 69 63 20 62 6c 65 6e  |    ; cubic blen|
00001d80  64 20 4e 6f 69 73 65 28  7a 29 0d 0b 72 13 6c 64  |d Noise(z)..r.ld|
00001d90  72 20 72 33 2c 5b 72 31  34 5d 2c 23 34 0d 0b 7c  |r r3,[r14],#4..||
00001da0  37 6d 6c 61 20 72 31 2c  72 32 2c 72 33 2c 72 31  |7mla r1,r2,r3,r1|
00001db0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001dc0  20 3b 20 74 68 69 72 64  20 63 75 62 69 63 20 70  | ; third cubic p|
00001dd0  6f 69 6e 74 0d 0b 86 04  0d 0b 90 32 73 75 62 20  |oint.......2sub |
00001de0  72 31 30 2c 72 38 2c 23  31 3c 3c 32 33 20 20 20  |r10,r8,#1<<23   |
00001df0  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 78 2d  |            ; x-|
00001e00  31 20 61 6e 64 20 31 30  32 33 0d 0b 9a 32 61 64  |1 and 1023...2ad|
00001e10  64 20 72 31 31 2c 72 39  2c 23 32 3c 3c 32 33 20  |d r11,r9,#2<<23 |
00001e20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00001e30  7a 2b 32 20 61 6e 64 20  31 30 32 33 0d 0b a4 16  |z+2 and 1023....|
00001e40  6d 6f 76 20 72 31 31 2c  72 31 31 2c 6c 73 72 23  |mov r11,r11,lsr#|
00001e50  32 33 0d 0b ae 18 61 64  64 20 72 31 31 2c 72 30  |23....add r11,r0|
00001e60  2c 72 31 31 2c 6c 73 6c  23 39 0d 0b b8 34 6c 64  |,r11,lsl#9...4ld|
00001e70  72 62 20 72 32 2c 5b 72  31 31 2c 72 31 30 2c 6c  |rb r2,[r11,r10,l|
00001e80  73 72 23 32 33 5d 20 20  20 20 20 20 20 20 3b 20  |sr#23]        ; |
00001e90  6e 6f 69 73 65 28 78 2d  31 2c 7a 2b 31 29 0d 0b  |noise(x-1,z+1)..|
00001ea0  c2 32 6c 64 72 62 20 72  33 2c 5b 72 31 31 2c 72  |.2ldrb r3,[r11,r|
00001eb0  38 2c 6c 73 72 23 32 33  5d 20 20 20 20 20 20 20  |8,lsr#23]       |
00001ec0  20 20 3b 20 6e 6f 69 73  65 28 78 2c 7a 2b 31 29  |  ; noise(x,z+1)|
00001ed0  0d 0b cc 32 61 64 64 20  72 31 30 2c 72 38 2c 23  |...2add r10,r8,#|
00001ee0  31 3c 3c 32 33 20 20 20  20 20 20 20 20 20 20 20  |1<<23           |
00001ef0  20 20 20 20 3b 20 78 2b  31 20 61 6e 64 20 31 30  |    ; x+1 and 10|
00001f00  32 33 0d 0b d6 34 6c 64  72 62 20 72 34 2c 5b 72  |23...4ldrb r4,[r|
00001f10  31 31 2c 72 31 30 2c 6c  73 72 23 32 33 5d 20 20  |11,r10,lsr#23]  |
00001f20  20 20 20 20 20 20 3b 20  6e 6f 69 73 65 28 78 2b  |      ; noise(x+|
00001f30  31 2c 7a 2b 31 29 0d 0b  e0 32 61 64 64 20 72 31  |1,z+1)...2add r1|
00001f40  30 2c 72 38 2c 23 32 3c  3c 32 33 20 20 20 20 20  |0,r8,#2<<23     |
00001f50  20 20 20 20 20 20 20 20  20 20 3b 20 78 2b 32 20  |          ; x+2 |
00001f60  61 6e 64 20 31 30 32 33  0d 0b ea 34 6c 64 72 62  |and 1023...4ldrb|
00001f70  20 72 35 2c 5b 72 31 31  2c 72 31 30 2c 6c 73 72  | r5,[r11,r10,lsr|
00001f80  23 32 33 5d 20 20 20 20  20 20 20 20 3b 20 6e 6f  |#23]        ; no|
00001f90  69 73 65 28 78 2b 32 2c  7a 2b 31 29 0d 0b f4 04  |ise(x+2,z+1)....|
00001fa0  0d 0b fe 10 6d 75 6c 20  72 32 2c 72 36 2c 72 32  |....mul r2,r6,r2|
00001fb0  0d 0c 08 13 6d 6c 61 20  72 32 2c 72 37 2c 72 33  |....mla r2,r7,r3|
00001fc0  2c 72 32 0d 0c 12 14 6d  6c 61 20 72 32 2c 72 31  |,r2....mla r2,r1|
00001fd0  32 2c 72 34 2c 72 32 0d  0c 1c 3a 6d 6c 61 20 72  |2,r4,r2...:mla r|
00001fe0  32 2c 72 31 33 2c 72 35  2c 72 32 20 20 20 20 20  |2,r13,r5,r2     |
00001ff0  20 20 20 20 20 20 20 20  20 20 20 3b 20 63 75 62  |           ; cub|
00002000  69 63 20 62 6c 65 6e 64  20 4e 6f 69 73 65 28 7a  |ic blend Noise(z|
00002010  29 0d 0c 26 13 6c 64 72  20 72 33 2c 5b 72 31 34  |)..&.ldr r3,[r14|
00002020  5d 2c 23 34 0d 0c 30 38  6d 6c 61 20 72 31 2c 72  |],#4..08mla r1,r|
00002030  32 2c 72 33 2c 72 31 20  20 20 20 20 20 20 20 20  |2,r3,r1         |
00002040  20 20 20 20 20 20 20 20  3b 20 66 6f 75 72 74 68  |        ; fourth|
00002050  20 63 75 62 69 63 20 70  6f 69 6e 74 0d 0c 3a 04  | cubic point..:.|
00002060  0d 0c 44 2d 3b 20 72 31  20 3d 20 63 75 62 69 63  |..D-; r1 = cubic|
00002070  20 62 6c 65 6e 64 65 64  20 6e 6f 69 73 65 20 61  | blended noise a|
00002080  74 20 28 78 2c 7a 29 20  3c 3c 20 31 38 0d 0c 4e  |t (x,z) << 18..N|
00002090  14 6d 6f 76 20 72 38 2c  72 31 2c 61 73 72 23 32  |.mov r8,r1,asr#2|
000020a0  30 0d 0c 58 12 6c 64 72  20 72 31 33 2c 73 74 61  |0..X.ldr r13,sta|
000020b0  63 6b 70 0d 0c 62 21 6c  64 6d 66 64 20 72 31 33  |ckp..b!ldmfd r13|
000020c0  21 2c 7b 72 31 2d 72 37  2c 72 39 2d 72 31 32 2c  |!,{r1-r7,r9-r12,|
000020d0  72 31 35 7d 0d 0c 6c 04  0d 0c 76 04 0d 0c 80 1b  |r15}..l...v.....|
000020e0  3b 20 43 61 6c 63 75 6c  61 74 65 20 74 68 65 20  |; Calculate the |
000020f0  66 72 61 63 74 61 6c 0d  0c 8a 04 0d 0c 94 2c 2e  |fractal.......,.|
00002100  67 65 74 5f 66 72 61 63  20 20 20 20 20 20 20 20  |get_frac        |
00002110  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 3b  |               ;|
00002120  20 72 30 20 3d 20 78 0d  0c 9e 2c 20 20 20 20 20  | r0 = x...,     |
00002130  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002140  20 20 20 20 20 20 20 20  20 20 20 3b 20 72 31 20  |           ; r1 |
00002150  3d 20 79 0d 0c a8 04 0d  0c b2 14 73 74 6d 66 64  |= y........stmfd|
00002160  20 72 31 33 21 2c 7b 72  31 34 7d 0d 0c bc 15 61  | r13!,{r14}....a|
00002170  64 72 20 72 31 31 2c 65  78 70 5f 74 61 62 6c 65  |dr r11,exp_table|
00002180  0d 0c c6 0d 6d 6f 76 20  72 32 2c 72 30 0d 0c d0  |....mov r2,r0...|
00002190  0d 6d 6f 76 20 72 33 2c  72 31 0d 0c da 14 6c 64  |.mov r3,r1....ld|
000021a0  72 20 72 30 2c 6e 6f 69  73 65 5f 74 61 62 0d 0c  |r r0,noise_tab..|
000021b0  e4 2d 6d 6f 76 20 72 38  2c 72 32 2c 6c 73 6c 23  |.-mov r8,r2,lsl#|
000021c0  35 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |5               |
000021d0  20 20 3b 20 3d 20 61 73  72 23 36 0d 0c ee 13 6d  |  ; = asr#6....m|
000021e0  6f 76 20 72 39 2c 72 33  2c 6c 73 6c 23 35 0d 0c  |ov r9,r3,lsl#5..|
000021f0  f8 36 62 6c 20 67 65 74  5f 6e 6f 69 73 65 20 20  |.6bl get_noise  |
00002200  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002210  20 20 3b 20 67 65 74 20  66 69 72 73 74 20 6f 63  |  ; get first oc|
00002220  74 61 76 65 0d 0d 02 0d  6d 6f 76 20 72 34 2c 72  |tave....mov r4,r|
00002230  38 0d 0d 0c 3e 6d 6f 76  20 72 35 2c 72 32 2c 6c  |8...>mov r5,r2,l|
00002240  73 6c 23 31 35 20 20 20  20 20 20 20 20 20 20 20  |sl#15           |
00002250  20 20 20 20 20 3b 20 78  27 3d 78 2a 6c 61 63 20  |     ; x'=x*lac |
00002260  28 6c 61 63 3d 32 29 20  3d 20 61 73 72 23 35 0d  |(lac=2) = asr#5.|
00002270  0d 16 2e 6d 6f 76 20 72  36 2c 72 33 2c 6c 73 6c  |...mov r6,r3,lsl|
00002280  23 31 35 20 20 20 20 20  20 20 20 20 20 20 20 20  |#15             |
00002290  20 20 20 3b 20 79 27 3d  79 2a 6c 61 63 0d 0d 20  |   ; y'=y*lac.. |
000022a0  04 0d 0d 2a 2d 6d 6f 76  20 72 37 2c 23 34 20 20  |...*-mov r7,#4  |
000022b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000022c0  20 20 20 20 20 3b 20 6f  63 74 61 76 65 73 0d 0d  |     ; octaves..|
000022d0  34 0d 2e 6f 63 74 5f 6c  6f 6f 70 0d 0d 3e 14 6d  |4..oct_loop..>.m|
000022e0  6f 76 20 72 38 2c 72 35  2c 61 73 72 23 31 30 0d  |ov r8,r5,asr#10.|
000022f0  0d 48 14 6d 6f 76 20 72  39 2c 72 36 2c 61 73 72  |.H.mov r9,r6,asr|
00002300  23 31 30 0d 0d 52 10 62  6c 20 67 65 74 5f 6e 6f  |#10..R.bl get_no|
00002310  69 73 65 0d 0d 5c 04 0d  0d 66 32 6c 64 72 20 72  |ise..\...f2ldr r|
00002320  39 2c 5b 72 31 31 2c 72  37 2c 6c 73 6c 23 32 5d  |9,[r11,r7,lsl#2]|
00002330  20 20 20 20 20 20 20 20  20 20 20 3b 20 65 78 70  |           ; exp|
00002340  28 69 29 20 3c 3c 20 31  30 0d 0d 70 43 6d 75 6c  |(i) << 10..pCmul|
00002350  20 72 38 2c 72 39 2c 72  38 20 20 20 20 20 20 20  | r8,r9,r8       |
00002360  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 69  |             ; i|
00002370  6e 63 3d 6e 6f 69 73 65  28 78 27 2c 79 27 29 2a  |nc=noise(x',y')*|
00002380  65 78 70 28 69 29 20 3c  3c 20 31 38 0d 0d 7a 34  |exp(i) << 18..z4|
00002390  6d 75 6c 20 72 38 2c 72  34 2c 72 38 20 20 20 20  |mul r8,r4,r8    |
000023a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000023b0  3b 20 69 6e 63 2a 3d 76  61 6c 20 3c 3c 20 32 36  |; inc*=val << 26|
000023c0  0d 0d 84 33 61 64 64 20  72 34 2c 72 34 2c 72 38  |...3add r4,r4,r8|
000023d0  2c 61 73 72 23 31 37 20  20 20 20 20 20 20 20 20  |,asr#17         |
000023e0  20 20 20 20 3b 20 76 61  6c 2b 3d 69 6e 63 20 3c  |    ; val+=inc <|
000023f0  3c 20 38 0d 0d 8e 17 61  64 64 20 72 34 2c 72 34  |< 8....add r4,r4|
00002400  2c 72 38 2c 61 73 72 23  31 39 0d 0d 98 2d 6d 6f  |,r8,asr#19...-mo|
00002410  76 20 72 35 2c 72 35 2c  6c 73 6c 23 31 20 20 20  |v r5,r5,lsl#1   |
00002420  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00002430  78 27 2a 3d 6c 61 63 0d  0d a2 2d 6d 6f 76 20 72  |x'*=lac...-mov r|
00002440  36 2c 72 36 2c 6c 73 6c  23 31 20 20 20 20 20 20  |6,r6,lsl#1      |
00002450  20 20 20 20 20 20 20 20  20 20 20 3b 20 79 27 2a  |           ; y'*|
00002460  3d 6c 61 63 0d 0d ac 11  73 75 62 73 20 72 37 2c  |=lac....subs r7,|
00002470  72 37 2c 23 31 0d 0d b6  10 62 67 74 20 6f 63 74  |r7,#1....bgt oct|
00002480  5f 6c 6f 6f 70 0d 0d c0  04 0d 0d ca 32 6d 6f 76  |_loop.......2mov|
00002490  20 72 30 2c 72 34 2c 61  73 72 23 32 20 20 20 20  | r0,r4,asr#2    |
000024a0  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 72  |             ; r|
000024b0  65 74 75 72 6e 20 76 61  6c 75 65 0d 0d d4 14 6c  |eturn value....l|
000024c0  64 6d 66 64 20 72 31 33  21 2c 7b 72 31 35 7d 0d  |dmfd r13!,{r15}.|
000024d0  0d de 04 0d 0d e8 0e 2e  65 78 70 5f 74 61 62 6c  |........exp_tabl|
000024e0  65 0d 0d f2 04 0d 0d fc  05 5d 0d 0e 06 05 ed 0d  |e........]......|
000024f0  0e 10 04 0d 0e 1a 27 f4  20 47 65 6e 65 72 61 74  |......'. Generat|
00002500  65 20 74 68 65 20 65 78  70 6f 6e 65 6e 74 5f 61  |e the exponent_a|
00002510  72 72 61 79 20 74 61 62  6c 65 0d 0e 24 0a 66 72  |rray table..$.fr|
00002520  65 71 3d 32 0d 0e 2e 12  e3 6e 25 3d 34 20 b8 20  |eq=2.....n%=4 . |
00002530  30 20 88 20 2d 31 0d 0e  38 26 65 78 70 5f 74 61  |0 . -1..8&exp_ta|
00002540  62 6c 65 21 28 6e 25 3c  3c 32 29 3d 31 30 32 34  |ble!(n%<<2)=1024|
00002550  2a 28 66 72 65 71 5e 2d  30 2e 31 29 0d 0e 42 0f  |*(freq^-0.1)..B.|
00002560  66 72 65 71 3d 66 72 65  71 2a 32 0d 0e 4c 05 ed  |freq=freq*2..L..|
00002570  0d 0e 56 05 3a 0d 0e 60  33 f4 20 47 65 6e 65 72  |..V.:..`3. Gener|
00002580  61 74 65 20 74 68 65 20  63 75 62 69 63 20 69 6e  |ate the cubic in|
00002590  74 65 72 70 6f 6c 61 74  69 6f 6e 20 6c 6f 6f 6b  |terpolation look|
000025a0  75 70 20 74 61 62 6c 65  0d 0e 6a 1b 70 25 3d 62  |up table..j.p%=b|
000025b0  65 7a 69 65 72 5f 66 61  63 74 6f 72 5f 74 61 62  |ezier_factor_tab|
000025c0  6c 65 25 0d 0e 74 10 e3  78 25 3d 30 20 b8 20 31  |le%..t..x%=0 . 1|
000025d0  30 32 33 0d 0e 7e 1a 78  3d 28 31 2f 33 29 2b 78  |023..~.x=(1/3)+x|
000025e0  25 2f 33 30 37 32 3a 78  78 3d 78 2a 78 0d 0e 88  |%/3072:xx=x*x...|
000025f0  14 78 32 3d 31 2d 78 3a  78 78 32 3d 78 32 2a 78  |.x2=1-x:xx2=x2*x|
00002600  32 0d 0e 92 13 21 70 25  3d 31 30 32 34 2a 78 78  |2....!p%=1024*xx|
00002610  32 2a 78 32 0d 0e 9c 13  70 25 21 34 3d 33 30 37  |2*x2....p%!4=307|
00002620  32 2a 78 2a 78 78 32 0d  0e a6 13 70 25 21 38 3d  |2*x*xx2....p%!8=|
00002630  33 30 37 32 2a 78 78 2a  78 32 0d 0e b0 13 70 25  |3072*xx*x2....p%|
00002640  21 31 32 3d 31 30 32 34  2a 78 2a 78 78 0d 0e ba  |!12=1024*x*xx...|
00002650  0a 70 25 2b 3d 31 36 0d  0e c4 05 ed 0d 0e ce 05  |.p%+=16.........|
00002660  3a 0d 0e d8 23 f4 20 43  61 6c 6c 20 74 68 65 20  |:...#. Call the |
00002670  6e 6f 69 73 65 20 67 65  6e 65 72 61 74 6f 72 20  |noise generator |
00002680  63 6f 64 65 0d 0e e2 22  41 25 3d 39 3a 42 25 3d  |code..."A%=9:B%=|
00002690  6e 6f 69 73 65 5f 74 61  62 25 3a d6 20 67 65 6e  |noise_tab%:. gen|
000026a0  5f 6e 6f 69 73 65 0d 0e  ec 04 0d 0e f6 05 e1 0d  |_noise..........|
000026b0  ff                                                |.|
000026b1