home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / www / f1 / archives / alist.lha / amos_list.asc
Text File  |  1996-09-27  |  47KB  |  1,363 lines

  1. If you are curious to what sort of things go on in the Amos List then
  2. here is a selection of what I found the most interesting messages
  3. from about a year ago.
  4.  
  5.  
  6.  
  7.  
  8. >     When you want to copy two arrays use the following:
  9. >     
  10. >         Dim a(n),b(n)
  11. >         Copy Varptr(a(0)),Varptr(a(0))+n*4 to varptr(b(0))
  12. >         
  13. >         Try it.It's ultra fast.Try to compare it with:
  14. >         For x=1 to n
  15. >             b(x)=a(x)
  16. >         Next
  17. >         
  18. >         When you want to initialize an array just use:
  19. >             Fill varptr(a(0)) to varptr(a(0))+n*4,0 ; fill it with 0
  20. >        
  21. >         You will notice the difference!
  22. >         
  23. >         Also deek(varptr(a(0))-4) gives N!
  24. >                                             Gregory.
  25.  
  26. However, don't do this if your arrays contain more than 65535 elements in
  27. total, as then AMOS doesn't always store them in continous memory addresses.
  28.  
  29. Also, you might have trouble doing this with string arrays, as AMOS will lose
  30. pointers to its strings, or gain duplicate pointers it doesn't know about.
  31.  
  32.  
  33. +-------------------------+------------------------------------+
  34. |                         |    _____                           |
  35. | PAUL HICKMAN            |   /     \   ON A HOT SUMMER NIGHT  |
  36. | (ph@doc.ic.ac.uk)       |  /  O O  \  WOULD YOU  OFFER YOUR  |
  37. | DEPARTMENT OF COMPUTING | |    _    | THROAT  TO  THE  WOLF  |
  38. | IMPERIAL COLLEGE LONDON |  \  / \  /  WITH THE RED  ROSES ?  |
  39. |                         |   \_____/                          |
  40. +-------------------------+------------------------------------+
  41. Machines: Amiga 500  WB1.3 - 1mb Memory - External Disk Drive.
  42.           Amiga 1200 WB3.0 - 6mb Memory - 200Mb Hard Disk.
  43.  
  44.  
  45.  
  46. Procedure H_INPUT[L]
  47.    '
  48.    ' INPUT ROUTINE FOR HEXADECIMAL NUMBERS  
  49.    '
  50.    ' L   : Length of field (Default character "$" exclused).  
  51.    '
  52.    '
  53.    ' This routine accepts only the numbers from 0 to 9 and characters 
  54.    ' from A to F.   
  55.    ' (Plus RETURN to end and BACKSPACE to delete the last character.) 
  56.    ' Characters "$"(for binary numbers) is for default. 
  57.    ' It is therefore more fool-proof than the normal INPUT command. 
  58.    '
  59.    '
  60.    '
  61.    ' Basic routine written in 1994 by Christian Mumenthaler 
  62.    ' Revisioned for Hexadecimal Numbers by Luca Ferraris - 02/95  
  63.    ' This routine is Public Domain. Use it wherever you want to.  
  64.    '
  65.    '
  66.    NA$="$"
  67.    Z=Len(NA$)
  68.    L1=L-Z
  69.    Print NA$+Space$(L1);
  70.    Cmove -L1,0
  71.    Curs On 
  72.    A1=Asc("0") : A2=Asc("F")
  73.    Repeat 
  74.       A$=Inkey$
  75.       A$=Upper$(A$)
  76.       A=Asc(A$)
  77.       If((A>=A1 and A<=A2)) and Z<=L
  78.          Print A$;
  79.          NA$=NA$+A$
  80.          Inc Z
  81.       End If 
  82.       If A$=Chr$(8) and Z>0
  83.          Z=Z-1
  84.          Cmove -1,0 : Print " "; : Cmove -1,0
  85.          NA$=Left$(NA$,Len(NA$)-1)
  86.       End If 
  87.    Until A$=Chr$(13)
  88.    Curs Off 
  89.    A#=Val(NA$)
  90. End Proc[A#]
  91.  
  92. Hallo from Luca Ferraris (aldo@di.unito.it)
  93. -------------------------------------------
  94.  
  95.  
  96. March 95
  97.  
  98.  
  99. ni>     I need a procedure to unpack PowerPacked datafiles. These are data banks and to use'em I need to unpack'em! My problem is that I need to do that (too long to explain why... note I own AmosPro!) using Amos 1.31 and without extensions! I can't use a lot of memory too.
  100.  
  101. Hmmm... Some time ago I wrote some workarounds for PowerPacker saving
  102. using Ppload and Ppsave of the compiler extension. I don't know, if
  103. these are already in the amos creator compiler but they are in the
  104. professional compiler. Another problem is that the bank needs the
  105. double space to load than normally.
  106.  
  107. BTW: For many reasons, I prefer Turbo Imploder to PowerPacker, which
  108. only needs once the memory to load /and/ decrunch and is incredibly
  109. fast! :-)
  110.  
  111. Try out this one: It only needs the music (Sload!) and the compiler
  112. extension. It's a universal routine for AMOS PP banks, normal PP
  113. banks, normal AMOS banks and binary data. If you want to load a bank
  114. into chip ram, use negative bank numbers.
  115.  
  116. Procedure PACLOAD[F$,BK]
  117.   BANK=Abs(BK) : If BK<0 Then CP=2 Else CP=0
  118.   If F$="" Then Print "Error: No filename!" : Stop 
  119.   If Exist(F$)=0 Then Print "Error: File not found" : Stop 
  120.   Open In 1,F$
  121.   A$=Input$(1,4) : B$=Input$(1,4)
  122.   LF=Lof(1)
  123.   If A$="PP20"
  124.     Pof(1)=LF-4
  125.     B$=Chr$(0)+Input$(1,3)
  126.     LE=Leek(Varptr(B$))
  127.     Erase BANK : Reserve As Work BANK,LF+16
  128.     ST=Start(BANK)
  129.     Poke$ ST,"PPbk"
  130.     Doke ST+4,BANK
  131.     Doke ST+6,CP
  132.     Loke ST+8,LE+8
  133.     Loke ST+12,LF-8
  134.     Pof(1)=0
  135.     Sload 1 To ST+16,LF
  136.     Close 1
  137.     Bsave "RAM:PACSAVE.xxx",ST To ST+LF+16
  138.     Erase BANK
  139.     Ppload "RAM:PACSAVE.xxx",BANK
  140.     Kill "RAM:PACSAVE.xxx"
  141.     ST=Start(BANK)
  142.     Copy ST-8,ST+LE-8 To ST
  143.     Poke$ ST-8,"Work    "
  144.     Pop Proc
  145.   End If 
  146.   If A$="PPbk"
  147.     Close 1
  148.     Erase BANK : Ppload F$,BANK
  149.     Pop Proc
  150.   End If 
  151.   If A$="AmBk" or A$="AmSp" or A$="AmIc" or A$="AmBs"
  152.     Close 1
  153.     Load F$,BK
  154.     Pop Proc
  155.   End If 
  156.   If CP=0
  157.     Reserve As Work BANK,LF
  158.   Else 
  159.     Reserve As Chip Work BANK,LF
  160.   End If 
  161.   Pof(1)=0
  162.   Sload 1 To Start(BANK),LF
  163.   Close 1
  164. End Proc
  165.  
  166. Once upon a time I used this procedure to pack ordinary pp20 files
  167. rather then the amos pp banks. It uses bank 16 as temporary bank, so
  168. do not store anything there ;-)
  169.  
  170. Procedure PACSAVE[F$,BK,EF]
  171.   LE=Length(BK)
  172.   Reserve As Work 16,LE-8
  173.   ST=Start(16)
  174.   Copy Start(BK),Start(BK)+LE To ST-8
  175.   Ppsave "RAM:PACSAVE.xxx",16,EF
  176.   Erase 16
  177.   Open In 1,"RAM:PACSAVE.xxx"
  178.     LE=Lof(1)
  179.     Reserve As Work 16,LE-16
  180.     ST=Start(16)
  181.     Pof(1)=16
  182.     Sload 1 To ST,LE-16
  183.   Close 1
  184.   Kill "RAM:PACSAVE.xxx"
  185.   Bsave F$,ST To ST+LE-16
  186.   Erase 16
  187. End Proc
  188.  
  189. ni>     If u know the format of packed files, just write it down, Ill write the procedure I need.
  190.  
  191. The first longword is 'PP20' or 'PX20' (?) for encoded files, then
  192. follows the packed data. The stupid thing about PowerPacker is that
  193. it saves the length of the original data in the last four bytes or
  194. better to say, the upper three bytes of the last longword. Very odd
  195. indeed (and a real mess if you want to rip these files :-{ ).
  196.  
  197. Bye, Chris Hodges <chris@surprise.rhein-ruhr.de> __    __
  198. A500/290/CD/'30er; German Extension-Coder   __  ///   / / _____
  199. GCS d H s-:++ !g p? !au a18 w++ v? C+++     \\\///   / /_/ ___/ LOGOUT
  200. E---- N++ K- W------ -po+ t++@ !5 j-- R+ G?  \XX/    \__/ __/  FASCISM!
  201. tv- b+ D-- B? e+(++)* u++ h! f !r n+ !y+ AMIGA RULEZ!   \/
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208. Well, heres a simple way of finding out what your program is running on,
  209. and a few other tricks :-)
  210.  Change it to suit your program needs.
  211. --------------cut------------------
  212. '$ver:aminfo 1.0(12,3,95)
  213. ' Darryl Lewis 
  214. 'Internet address :  Darryl_lewis@comlink.mpx.com.au 
  215. 'If you use any of 
  216. these ideas in a program it would be nice to mention me 
  217. 'And very nice if you sent me a copy of the program :-)
  218. Screen Open 0,640,320,2,Hires
  219.  
  220. A=Deek(Leek(4)+Equ("LIB_VERSION"))
  221. Print "Kickstart version number",A
  222. Print "KICKSTART :";
  223. If A<33 Then Print "Obsolete! No longer supported"
  224. If A=33 Then Print " 1.2"
  225. If A=34 Then Print " 1.3 (1.2 with autoboot for Harddisk)"
  226. If A=35 Then Print " Obsolete! Early beta-kickstart 1.4"
  227. If A=36 Then Print " Obsolete! Early V2.00 - V2.03 supplied with A3000.
  228. A3000 owners should update to at least Kickstart 2.04"
  229. If A=37 Then Print "2.04. Final release version of kickstart 2"
  230. If A=38 Then Print "Opps! Workbench 2.1. (the exec library should not show
  231. this version as all true V38 libs are disked based!"
  232. If A=39 Then Print "3.0"
  233. If A=40 Then Print "3.01 (Developer Kickstart currently under test)"
  234. If A>40 Then Print "Unknown!!!"
  235.  
  236. L=Deek(Leek(4)+Equ("AttnFlags"))
  237. If Btst(0,L) Then Print "68010 processor fitted (or 68020/30/40)"
  238. If Btst(1,L) Then Print "68020 processor fitted (or 68030/40)"
  239. If Btst(2,L) Then Print "68030 processor fitted [V37+]"
  240. If Btst(3,L) Then Print "68040 processor fitted [V37+]"
  241. If Btst(4,L) Then Print "68881 FPU fitted ( or 68882)"
  242. If Btst(5,L) Then Print "68882 FPU fitted [V37+]"
  243. If Btst(6,L) Then Print "68040 FPU fitted [V37+]"
  244. If Not(Btst(0,L) and Btst(1,L) and Btst(2,L)) Then Print "68000 fitted"
  245.  
  246. ' don't assume that if L>0 then a 68000+ processor is fitted as
  247. '68881 chips are available on add-on boards without a fast processor!
  248.  
  249. 'I still recomend using a timing loop to determine the speed to run
  250. 'your game at. The reason being, that, if there are mulituple tasks  
  251. 'being run (such as raytracing) and playing your game, the system will 
  252. 'be slower than you might assume it would be on a 68000+ 
  253. 'Run the procedure from Amos. Then compile the procedure and see the timing
  254. difference 
  255. 'ie: 
  256. A3000=0
  257. Timer=0
  258. For L=0 To 20000
  259. Next L
  260. If Timer<28 Then A3000=1
  261. If A3000=1 Then Print "Fast machine, put an extra Wait Vbl in main loop"
  262. 'ie: 
  263. 'Main game loop
  264. 'Do
  265. '  _move_bobs_procedure  
  266. '  Wait Vbl
  267. '  if A3000=1 then Wait Vbl
  268. 'Loop
  269.  
  270. If Ntsc=0 Then Print "PAL display at boot up" Else Print "NTSC display at
  271. boot up"
  272. 'This will only indicate what the system was booted as. If the mode
  273. 'is changed after booting, it will not detect it!
  274.  
  275. 'This following little hack will change screen modes, so now you can 
  276. 'make your programs work for all TV standards
  277.  
  278. Print "Press any key to change to NTSC"
  279. Wait Key 
  280. 'NTSC
  281. Poke $DFF1DC,0
  282. Print "Press any key to change to PAL"
  283. Wait Key 
  284. 'PAL 
  285. Poke $DFF1DC,32
  286.  
  287. -------------------------------------------------------------------------
  288. HI!
  289.  
  290. This simple procedure relocates a medmodule so that it can be saved with
  291. a amos program. At the beginning of your program before you play the 
  292. module, you have to remember to call RELOC_MED procedure though.
  293.  
  294. Procedure RELOC_MED[BNK]
  295.    ' BNK - bank #
  296.    '
  297.    ' Open medplayer.library, version 2 or newer
  298.    Lib Open 1,"medplayer.library",2
  299.    ' the address of the med module to a0
  300.    Areg(0)=Start(BNK)
  301.    ' call RelocModule from medplayer.library 
  302.    L=Lib Call(1,-102)
  303.    ' close library
  304.    Lib Close 1
  305. End Proc
  306.  
  307.                ??????????????????????????????????????????????
  308.                ??  Petri Hakkinen       |   A1200/2M/210M  ??
  309.                ??  mystic@tlti.tokem.fi |   C64/64k        ??
  310.                ??????????????????????????????????????????????
  311.  
  312.  
  313. ----------------------------------------------------------------------------
  314.  
  315. This is the Change Font Command that was extraced from the AMCAF-Extension.
  316. The procedure is unopenable not because of the secrets behind but due to the
  317. fact that machine code procedures cannot be opened. Warning: Should only work
  318. with AMOS Pro 1.12 or higher.
  319.  
  320.  
  321. begin 644 ChangeFont.AMOS
  322. M04U/4R!"87-I8R!V,3,T(    B@6 0GJ #X      %P /@   4  7  ^   !
  323. M  !< #X    " %P /@       !$!%$8 5 TT %03W  ^      !4$]( /@  
  324. M  $ 5 NN   : 0 2_^X,@&-H86YG95]F;VYT  "$ "8 !51O<&%Z  !< #X 
  325. M   + %P /@      C   $P$/2@ ^    9 !< #X   !D %P )@ ,2&5L;&\@
  326. M5V]R;&0A   # 0.V   E 0-V   !;  2T   !@  #(!C:&%N9V5?9F]N=   
  327. MA  &   $ FYA;64 7  &  8& &AE:6=H= !<  8 # 8 <W1Y;&4  (P   ,!
  328. M)8S_TB)M!2P@"68&1^L #$YU(FD!2")I #0L#BQMYU).KO^R+$9!^@#R(!L1
  329. M0  &(!LQ0  $$7P  @ '0_H C"")(%LV&%-#$MA1R__\#"D +O_[9Q02_  N
  330. M$OP 9A+\ &\2_ !N$OP =$(1+ XL>  $0_H 1'  3J[]V$'Z *0@@&8"3G4L
  331. M0$'Z )!.KO_B+$9*@&<2($ B;04L(FD!2"QMYU).KO^^(GH >"QX  1.KOYB
  332. M+$9.=61I<VMF;VYT+FQI8G)A<GD                                 
  333. M                                                            
  334. F                                   # 0.0  !!;4)S    
  335.  
  336. end
  337.  
  338. ------------------------------------------------------------------------
  339.  
  340.  
  341.  
  342.  
  343. June 95
  344.  
  345. PW> I`ve written a program in AMOS and I want to be able to distribute 
  346. PW> keyfiles with it, so if you have the keyfile, certain options are enabled!
  347. PW> I`ve mssed around with a few systems, but not found one I`m happy with!
  348.  
  349. Keyfiles should always kept in PROGDIR: (S: or ENVARC: is not a
  350. preferable drawer anymore). Moreover, the keyfiles should at least
  351. contain a serial identification number and (why not?) the full name
  352. and perhaps the address of the registered user. Then there should be
  353. a checksum in the regdata to verify that nothing has been modified
  354. (the checksum could be a simple CRC, but more complicated and
  355. algorithmic checksums are prefered ;-) ). The keyfile should be
  356. encrypted using some very tricky algorithms (there's no chance
  357. cracking an AMOS program, because Francois has written AMOS ;-)) ).
  358. Please look up a encrypting book (which you will certainly find at
  359. your local library). If you think, you don't need such a book, please
  360. take care that even the most wicked looking routine could be really
  361. easy to hack (read the PGP docs for more information on flaws of
  362. crypting if you want to). Optionally, you could add a second checksum
  363. of the encoded data ;-)
  364.  
  365. To do all this encrypting work, the data should be stored in a fixed
  366. size memory bank. This keyfile can then be saved using Bsave.
  367.  
  368. To load the file, reserve a bank and call Bload. Then compare the
  369. outer checksum. If it's correct, then decrypt the reg data, and again
  370. compare the inner checksum. If everything is correct, you've
  371. hopefully got a unmodified registered keyfile.
  372.  
  373. Example of a very simple keyfile:
  374.  
  375. KEYSIZE=256 : Rem Set the size you need for your files.
  376. Reserve As Work 9,KEYSIZE
  377. ST=Start(9)
  378. ' To make the hacking process harder, first fill all bytes with
  379. ' random data.
  380. For A=0 to (KEYSIZE/2)-1 : Rem All data is written
  381.   Doke ST+A*2,Rnd(32767)
  382. Next
  383. Loke ST,SERNUMBER
  384. Poke$ ST+4,NAME$+Chr$(0)
  385. ' You could poke more information if you want.
  386.  
  387. ' Now create the inner checksum (in this case, it's only 16 bit):
  388. SUM=0
  389. For A=0 To (KEYSIZE/2)-3 : Rem the inner checksum itself is excluded
  390.   SUM=(SUM*11+Deek(ST+A*2)) And $FFFF
  391. Next
  392. Doke ST+KEYSIZE-4,SUM
  393.  
  394. ' Now encode the data. Very simple encoding method.
  395. ' Please invent your own.
  396. EC=0
  397. For A=0 To (KEYSIZE/2)-2 : Rem the inner crc is included, but not the outer.
  398.   OD=Deek(ST+A*2)
  399.   OD=(OD And $FFF0)/16+(OD And $F)*$1000
  400.   OD=(OD+EC) and $FFFF
  401.   Doke ST+A*2,OD
  402.   Add EC,$DEAD
  403. Next
  404.  
  405. ' Now create the outer checksum:
  406. SUM=0
  407. For A=0 To (KEYSIZE/2)-2 : Rem the outer checksum is not included
  408.   SUM=(SUM*17+Deek(ST+A*2)) And $FFFF
  409. Next
  410. Doke ST+KEYSIZE-2,SUM
  411.  
  412. ' Now save the keyfile:
  413. Bsave "PROGDIR:Keyfile",ST To ST+KEYSIZE
  414.  
  415.  
  416.  
  417. Ok. Now the appropriate decrypting code:
  418.  
  419. KEYSIZE=256
  420. Reserve As Work 9,KEYSIZE
  421. ST=Start(9)
  422. Bload "PROGDIR:Keyfile",9
  423.  
  424. ' Check the outer checksum:
  425. SUM=0
  426. For A=0 To (KEYSIZE/2)-2
  427.   SUM=(SUM*17+Deek(ST+A*2)) And $FFFF
  428. Next
  429. If Deek(ST+KEYSIZE-2)<>SUM Then Print "Intruder alert! A lamer tried to hack the keyfile!" : Stop
  430.  
  431. ' Now the data has to be decoded.
  432. EC=0
  433. For A=0 To (KEYSIZE/2)-2
  434.   OD=Deek(ST+A*2)
  435.   OD=(OD-EC) and $FFFF
  436.   OD=(OD And $0FFF)*16+(OD And $F000)/$1000
  437.   Doke ST+A*2,OD
  438.   Add EC,$DEAD
  439. Next
  440. ' Check the inner crc:
  441. SUM=0
  442. For A=0 To (KEYSIZE/2)-3
  443.   SUM=(SUM*11+Deek(ST+A*2)) And $FFFF
  444. Next
  445. If Deek(ST+KEYSIZE-4)<>SUM Then Print "A cute guy hacked the first barrier but could not get past the checksum!" : Stop
  446.  
  447. ' And at last, you have your registered data back again:
  448. SERNUMBER=Leek(ST)
  449. NAME$=Peek$(ST+4,80,Chr$(0))
  450.  
  451.  
  452.  
  453. Everything was typed in from scratch and from mind only. :-) I hope
  454. it works ;-)
  455.  
  456. Bye, Chris Hodges <chris@sixpack.pfalz.org>      __    __
  457.  
  458.  
  459.  
  460.  
  461. July 95
  462.  
  463. --------->8---------------->8-------------->8------------------------
  464. Amos and Internet
  465.  
  466. Internet can be useful for Amos programmers. The main reason for this is 
  467. the existance of the Amos Discussion List. The subscribers talk about 
  468. anything related to this basic variant. Often simple programming problems 
  469. are mailed to the list, but also announcements of soon to be appearing 
  470. software, discussions about what should be in new extensions and how Amos 
  471. should be further developed. The special thing about this group of Amos 
  472. users is that some of the top-developers are amongst them. Take Dominic 
  473. Ramsey, programmer of a number of the official Amos Professional demos. 
  474. Dominic managed to capture the attention of the British press with his 
  475. program that successfully predicts the outcome of horse races - the 
  476. program was written in Amos.
  477. Paul Hickman is the author of the Easylife extension. It is the life of 
  478. the professional programmer that is made easier with it. Easylife adds 
  479. structured variables, pattern matching, console I/O and MUI 
  480. compatibility. But those readers that did not understand a thing of the 
  481. last sentence need not dispair. Paul also added some helper programs that 
  482. anybody can use. Amongst these are a variable checker and an Amiga Guide 
  483. viewer. For the latter he converted the Amos Professional on-line 
  484. documentation.
  485. Andy Church maintains the Procedure Library. Have you ever had the 
  486. feeling that you were re-inventing the wheel with a certain procedure you 
  487. were writing? Then there is a chance that someone else has added that 
  488. procedure to the Library. Amongst others it offers you routines for the 
  489. manipulation of screens and palettes, using Bobs with AMAL and 
  490. circumventing the archaic Input command.
  491. Furthermore some projects are inspired by the threating expiring of both 
  492. Amiga and Amos. Mike Sikorsky is working on MARP, Mike's Amos Replacement 
  493. Project [NOTE: Now called M-Lib]. MARP is a library that contains all 
  494. Amos commands as C-procedures. Mike tries to take over as much of the 
  495. programming as possible, so that the Amos programmer's only task is 
  496. converting Amos commands into C-procedure calls. He is even thinking of 
  497. taking away this last task by adding a conversion program. People about 
  498. to leave the Amiga can still benefit from this project, as there are 
  499. plans to make versions for both MS-DOS and X-Windos environments.
  500. The other big project is called ADT, Amos Development Team. A year ago a 
  501. rumour on the net said that Europress would make Amos' source public 
  502. domain. The ADT got founded by the list's subscribers to coordinate the 
  503. further development of Amos. Nobody would benefit from a proliferation of 
  504. badly coded 'improved' Amos versions. Europress did not come true, but 
  505. the ADT still exists. Now the members concentrate on inventing a whole 
  506. new programming language that contains all the good of Amos and more. The 
  507. ADT is of course open for all suggestions.
  508. Besides all this serious stuff people are of course programming games. 
  509. People like Ben Marty (TechnoVenture), Christian Mumenthal (Colonial 
  510. Conquest) and the members of Dark Unicorn Productions (Scorched Tanks) 
  511. know what they are talking about and so they do.
  512. The Amos Discussion List is maintained by Michael Cox. He is not a 
  513. moderator, but keeps track of the subscriptions and the FAQ.
  514.  
  515. Those that have access to the Internet can subscribe by sending an e-mail 
  516. to amos-request@access.digex.net, including the word 'subscribe' in the 
  517. text. The language of choice is English. Not that it is obligatory to 
  518. post in that language, but there are only a few Dutch subscribers, so...
  519. There is also a website, maintained by Andy Church, at 
  520. http://mmm.mbhs.edu/~achurch/amos/.
  521.  
  522. Branko Collin
  523.  
  524. [NOTE: The article contained a screenshot of the website. Originally 
  525. provided by Gareth Edwards. As it was a picture of the old website, the 
  526. editors decided to make a new screenshot of the new site.]
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534. Aug 95
  535.  
  536.  
  537. To show an ascii-text on screen you could try to make use of the Peek$
  538. command (amospro)
  539. So you would load the file into a bank using Bload and then read out
  540. the bank with peek$.
  541. This will work quite happily like:
  542. Open in 1,f$
  543. reserve as work 6,lof(1)
  544. close 1
  545. bload f$,1
  546. print peek$(start(6),length(6))
  547.  
  548. This means you will have to read in all of the file.
  549. Smaller patches of file can be used too:
  550. Reserve As work 6,buffer  <-you choose size
  551. p=0
  552. Open in 1,f$
  553. Repeat
  554. pof(1)=p
  555. Sload 1 to start(6),length(6)
  556. add p,length(6)
  557. print peek$(start(6),length(6))
  558. until p>=lof(1)
  559. close 1
  560.  
  561. This needs some tinkering still, but shows the general idea.
  562. You could still use the 'LineInput'-loop instead of sload and
  563. peek$ but you will see that it is MUCH slower
  564. ---------------------------------------------------------------------------
  565.  
  566. JW>  I'm wanting to write a utility to run under DOpus which means it
  567. JW> needs to be a Shell or CLI executable. I need to be able to pass
  568. JW> arguments to the program at startup (HELP!). Now heres the problem.
  569. JW> I read that 1.36 Compiler will NOT make CLI executables. What can I
  570. JW> do, if anything?
  571.  
  572. There's hardly a difference between WB and CLI executables except
  573. that the WB ones have an icon created and the CLIs not. (Moreover,
  574. there's a bug in the AP Compiler which will always make a cli
  575. executable 'run' type, so it will unhook itself no matter what the
  576. switch has been set to.).
  577.  
  578. So just create a workbench executable and delete the icon. You can
  579. read the command line using the AMOS '=Command Line$' instruction
  580. (but do it early in the program because Francois has located this
  581. string buffer somewhere in the gfx-buffers).
  582.  
  583. However, there are no automatic argument parsing routines in AMOS for
  584. templates like 'FROM/A,TO/A,QUIET/S' etc.
  585.  
  586. ----------------------------------------------------------------------------
  587.  
  588. >     Can anyone explain a way to program platforms for an amos game.  
  589. > Is it easiest to check for bob collisions or is it better to check bobs 
  590. > and zones?  It may be a simple procedure, but I am stumped.
  591.  
  592. You shouldn't use zones for platforms, nor bobs. They slow the game down
  593. and it's "unprofessional". This is the way it should be done, which
  594. happens to be the way commerical m/c programmers do it :-)
  595.  
  596. Use a two dimensional array, say LEV() to hold the map details. You have
  597. to break the map down into 16 by 16 pixel blocks and draw icons of this
  598. size, containing all the graphics needed. Make sure that they fit together
  599. nicely. Then you'll have to create a map editor. There are a few on aminet
  600. but I always prefer to create my own. This code ought to do the trick:
  601.  
  602. ---------------------------------------------------------------------------
  603. Screen Open 0,320,192,32,lowres
  604. Flashoff:Cursoff:Cls 0
  605.  
  606. Load "Icons.abk"
  607. Get Icon Palette
  608. ' B=Block/Icon to draw with
  609. B=1
  610.  
  611. Repeat
  612.  
  613.    XM=Xscreen(Xmouse):YM=Yscreen(Ymouse):MK=Mousekey
  614.    XB=XM/16:YB=YM/16
  615.  
  616.    ' Place a block
  617.    If MK=1
  618.       Paste Icon XB*16,YB*16,B
  619.       LEV(XB,YB)=B
  620.    Endif
  621.  
  622.    ' Delete a block
  623.    If MK=2
  624.       Cls 0,XB*16,YB*16 To XB*16+16,YB*16+16
  625.    Endif
  626.  
  627.    ' You could insert a bit of code in here to alter the block that you
  628.    ' are currently using, maybe using the left and right arrow keys?
  629.  
  630. Until Keystate(69) : Rem Press escape to save the level
  631.  
  632. ' Save the map
  633. Openout 1,"Level"
  634. For x=0 to 320/16-1
  635.    For y=0 to 192/16-1
  636.       Print #1,LEV(x,y)
  637.    Next y
  638. Next x
  639. Close 1
  640. ---------------------------------------------------------------------------
  641.  
  642. That will save your map as a sequential file, not the best way to do it,
  643. but the easiest ;-)
  644.  
  645. Now, the game:
  646. ---------------------------------------------------------------------------
  647. Screen Open 0,320,192,32,lowres
  648. Flashoff:Cursoff:Cls 0
  649.  
  650. Load "Icons.abk"
  651. Get Icon Palette
  652. Load "Sprites.abk"
  653.  
  654. ' Load the map
  655. Openin 1,"Level"
  656. For x=0 to 320/16-1
  657.    For y=0 to 192/16-1
  658.       Input #1,LEV(x,y)
  659.       If LEV(x,y)>0 Then Paste Icon x*16,y*16,LEV(x,y)
  660.    Next y
  661. Next x
  662. Close 1
  663.  
  664. X=x pos of sprite (Sprite is 16 by 16 pixels)
  665. Y=y pos of sprite (and the hot spot is in the top left)
  666.  
  667. XSP=0:YSP=0 : Rem Speed of sprite
  668.  
  669. Repeat
  670.  
  671.    Add X,XSP:Add Y,YSP
  672.    XSP=XSP/1.1
  673.  
  674.    ' Look directly under the sprites feet
  675.    If LEV(X/16,(Y+16)/16)=0 and LEV((X+15)/16,(Y+16)/16)=0
  676.       ' Nothing there so drop
  677.       Inc YSP
  678.    Else
  679.       YSP=0
  680.       ' Jump if push up, it's on land
  681.       If Jup(1):YSP=-10:Endif
  682.    Endif
  683.  
  684.    If Jleft(1):Add XSP,-2:Endif
  685.    If Jright(1):Add XSP,2:Endif
  686.  
  687.    ' Place Sprite, not animated, you can do that yourself :-)
  688.    Sprite 0,XHard(X),Yhard(Y),1
  689.  
  690.    Wait vbl
  691.  
  692. Until KeyState(69)
  693.  
  694. End
  695. ------------
  696.  
  697. This *should* do it, but I've probably missed out something really
  698. obvious, as I often do ;-) It will probably be more slippery and slidey
  699. than Technoventure, but that can be altered by increasing the 1.1 in
  700. XSP=XSP/1.1
  701.  
  702. I hope this has helped, I hope you can follow my code. I can never follow
  703. other people's, but this is pretty simple. To check if the sprite has
  704. walked into a wall, it is pretty much the same thing as looking under
  705. the sprites feet, except you look left or right. Tell me if you want a
  706. better explaination, a more complex explaination or a more confusing
  707. explaination if you need to.
  708.  
  709. Bye  _________________________________
  710.     /                                 \
  711.     > Ben Wyatt - bwyatt@paston.co.uk <
  712.     \_________________________________/ ©1995 Very Interesting Signatures
  713.  
  714. ---------------------------------------------------------------------------
  715. This is from my anim2bob interface.
  716. You'll first need to load the Default resouce bank that's in the interface
  717. tutorial directory. I have another prcedure that searches the harddisk to
  718. find it, to keep memory usage low for the converter.
  719.  
  720. Do
  721.  _Buttons
  722. Loop
  723.  
  724. Procedure _BUTTONS
  725.    'erase resource bank to savechip ram. This means that the resource bank
  726. must be  
  727.    'loaded each time the program is run.
  728.    Resource Bank 16
  729.    Resource Screen Open 0,640,200,0
  730.    'Wait Vbl  
  731.    'each indented box uses the BAse command. Each ellement in the box is  
  732.    'offset relative to the BAse. Thus, by changing the co-ordinates of the
  733.    'Base, every elliment is moved correctly aswell.   
  734.    A$=A$+"BAse     0,0;"
  735.    A$=A$+"BOx     0,0,1,640,200;"
  736.    A$=A$+"BUtton   1,0,0,58,14,0,0,1;[UN 0,0,BP3*43+;PR
  737. 12,4,'Quit',16;][BQ;]KY 128 69+,0;"
  738.    A$=A$+"POutline 258,7,'ANIM2BOB CONVERTER',0,6;"
  739.    A$=A$+"LIne     132,16,10,538;"
  740.    
  741.    A$=A$+"BAse     32,37;"
  742.    A$=A$+"BOx      0,0,82,260,55;"
  743.    A$=A$+"POutline XA80+,YA10-,'LOAD OPTIONS',0,6;"
  744.    A$=A$+"BUtton   2,XA70-,YA12+,32,16,1,0,1;[UN 0,0,BP22+;][BC 3,0;]"
  745.    A$=A$+"PRint    XA34+,YA5+,'Grab Single IFF',7;"
  746.    A$=A$+"BUtton   3,XA34-,YA12+,32,16,0,0,1;[UN 0,0,BP22+;][BC 2,0;]"
  747.    A$=A$+"PRint    XA34+,YA5+,'Grab Anim',7;"
  748.    A$=A$+"BUtton   11,XA34-,YA12+,32,16,0,0,0;[UN 0,0,BP22+;][BC 11,0;]"
  749.    A$=A$+"PRint    XA34+,YA5+,'Imagine Raytraced Files',7;"
  750.    
  751.    
  752.    A$=A$+"BAse     32,110;"
  753.    A$=A$+"BOx      0,0,82,260,71;"
  754.    A$=A$+"POutline XA80+,YA10-,'GRAB METHOD',0,6;"
  755.    A$=A$+"BUtton   4,XA70-,YA12+,32,16,1,0,1;[UN 0,0,BP22+;][BC 5,0;BC
  756. 6,0;]"
  757.    A$=A$+"PRint    XA34+,YA5+,'Overlay Size',7;"
  758.    A$=A$+"BUtton   5,XA34-,YA12+,32,16,0,0,1;[UN 0,0,BP22+;][BC 4,0;BC
  759. 6,0;]"
  760.    A$=A$+"PRint    XA34+,YA5+,'Fixed centre',7;"
  761.    A$=A$+"BUtton   6,XA34-,YA12+,32,16,0,0,0;[UN 0,0,BP22+;][BC 4,0;BC
  762. 5,0;]"
  763.    A$=A$+"PRint    XA34+,YA5+,'Minimum Size',7;"
  764.    A$=A$+"BUtton   13,XA34-,YA12+,32,16,0,0,1;[UN 0,0,BP22+;][BC 10,0;]"
  765.    A$=A$+"PRint    XA34+,YA5+,'Option: Equal Sides',7;"
  766.    
  767.    A$=A$+"BAse     332,37;"
  768.    A$=A$+"BOx      0,0,82,260,55;"
  769.    A$=A$+"POutline XA80+,YA10-,'VIEW',0,6;"
  770.    A$=A$+"BUtton   7,XA70-,YA12+,32,16,0,0,1;[UN 0,0,BP30+;][BC 7,0;]"
  771.    A$=A$+"PRint    XA34+,YA5+,'IFF/Animation',7;"
  772.    A$=A$+"BUtton   12,XA34-,YA12+,32,16,0,0,1;[UN 0,0,BP30+;][BC 12,0;]"
  773.    A$=A$+"PRint    XA34+,YA5+,'Bank(.abk)',7;"
  774.    A$=A$+"BUtton   8,XA34-,YA12+,32,16,0,0,1;[UN 0,0,BP30+;][BC 8,0;]"
  775.    A$=A$+"PRint    XA34+,YA5+,'Instructions',7;"
  776.    A$=A$+"BUtton   14,XA120+,YA22-,32,16,0,0,1;[UN 0,0,BP22+;][BC 14,0;]"
  777.    A$=A$+"PRint    XA34+,YA5+,'Mirror',7;"
  778.    A$=A$+"BUtton   15,XA34-,YA22-,32,16,0,0,0;[UN 0,0,BP22+;][BC 15,0;]"
  779.    A$=A$+"PRint    XA34+,YA5+,'Lock',7;"
  780.    
  781.    A$=A$+"BAse     332,110;"
  782.    A$=A$+"BOx      0,0,82,260,71;"
  783.    A$=A$+"POutline XA80+,YA10-,'START',0,6;"
  784.    A$=A$+"BUtton   9,XA70-,YA12+,32,16,0,0,1;[UN 0,0,BP30+;][BC 9,0;]"
  785.    A$=A$+"PRint    XA34+,YA5+,'Load and process',7;"
  786.    A$=A$+"BUtton   10,XA34-,YA12+,32,16,0,0,0;[UN 0,0,BP22+;][BC 10,0;]"
  787.    A$=A$+"PRint    XA34+,YA5+,'AREXX',7;"
  788.    A$=A$+"BUtton   10,XA34-,YA12+,32,16,0,0,0;[UN 0,0,BP22+;][BC 10,0;]"
  789.    A$=A$+"PRint    XA34+,YA5+,'DXF file',7;"
  790.    A$=A$+"BUtton   10,XA34-,YA12+,32,16,0,0,0;[UN 0,0,BP22+;][BC 10,0;]"
  791.    A$=A$+"PRint    XA34+,YA5+,'Imagine Object Convert',7;"
  792.    
  793.    A$=A$+"EXit;"
  794.    '  Monitor 
  795.    Dialog Open 1,A$
  796.    X=Dialog Run(1)
  797.    ' make sure that there is some initial settings. These will be 
  798.    'changed inside the Do Loop as buttons are pressed.  
  799.    _FILE_OPTION=1
  800.    _METHOD=1
  801.    Do 
  802.       D=Dialog(1)
  803.       If D<0 Then BYE=1 : Exit : Rem end  
  804.       If D=2 Then _FILE_OPTION=1 : Rem Iff
  805.       If D=3 Then _FILE_OPTION=2 : Rem Anim 
  806.       If D=4 Then _METHOD=1 : Rem Overlay  
  807.       If D=5 Then _METHOD=2 : Rem Fixed centre   
  808.       If D=6 Then _METHOD=3 : Rem Minimum    
  809.       If D=7 Then _METHOD=4 : _FILE_OPTION=0 : Exit : Rem Test View iff
  810. /anim  
  811.       If D=8 Then _METHOD=5 : _FILE_OPTION=0 : Exit : Rem Instructions   
  812.       If D=12 Then _METHOD=6 : _FILE_OPTION=0 : Exit : Rem veiw bank
  813.       If D=13 Then _EQUALISE=1 : Rem equalise sides 
  814.       If D=14 Then _MIRROR=1 : Rem MIRROR DISPLAY OF Bob BANK 
  815.       If D=9 Then Exit : Rem start button 
  816.       'if d=10 then nothing, because arrex not written yet.
  817.    Loop 
  818.    Dialog Close 
  819.    'Screen Close 0
  820.    Erase All 
  821.    If BYE=1 Then End 
  822. End Proc
  823.  
  824. The only problem I've had is that when using radio buttons, you can
  825. deselect all buttons by selecting an already selected button. Any
  826. solutions? 
  827.  
  828. Darryl
  829.  
  830. -- Via DLG Pro v1.0
  831.  
  832.  
  833. ---------------------------------------------------------------------------
  834.  
  835. Do
  836.    Proc SEGAFIRE[0]
  837.    Print Bin$(Param,4)
  838.    Proc SEGAFIRE[1]
  839.    Print Bin$(Param,4)
  840. Loop
  841.  
  842. Procedure SEGAFIRE[BUTTON]
  843.    '  Amiga 4-button joystick code...
  844.    '
  845.    '  Stick discovery by Ed Bamber
  846.    '  Code created by Anthony Ball
  847.    '  Converted to AMOS by Brad Gust
  848.    '
  849.    '  (C)1992 Anthony Ball & Edmund Bamber
  850.    '  (C)1994 Brad Gust
  851.    '
  852.    '  Requires a SEGA joystick with wires 5 & 7 swapped
  853.    '
  854.    REG=$0
  855.    If BUTTON
  856.       If Fire(1)
  857.        REG=REG+$4
  858.       End If
  859.       If Not Btst(6,$DFF016)
  860.          REG=REG+$2
  861.       End If
  862.       Doke $DFF034,$E000
  863.       If Fire(1)
  864.          REG=REG+$8
  865.       End If
  866.       If Not Btst(6,$DFF016)
  867.          REG=REG+$1
  868.       End If
  869.    Else
  870.       If Fire(0)
  871.          REG=REG+$4
  872.       End If
  873.       If Not Btst(2,$DFF016)
  874.          REG=REG+$2
  875.       End If
  876.       Doke $DFF034,$E00
  877.       If Fire(0)
  878.          REG=REG+$8
  879.       End If
  880.       If Not Btst(2,$DFF016)
  881.          REG=REG+$1
  882.       End If
  883.    End If
  884. End Proc[REG]
  885.  
  886. That was up here a while back.  Hope it helps.
  887.  
  888. Well met and godspeed,
  889.                       Giark
  890. ----------------------------------------------------------------------------
  891. Just to let ya all know that when using the C: command "BRun" from within 
  892. the Exec command, you will have a multi-tasking Exec command. When you use 
  893. BRun (example: Exec "C:BRun DF0:Amoeba_Invaders") it will load and run your 
  894. program, plus return control back to amos immediately. Without the BRun 
  895. (example: Exec "DF0:Amoeba_Invaders") control won't return to amos until 
  896. you quit the program you executed. So if your looking for a much needed 
  897. type function from within AMOS until someone writes a better command that 
  898. will do the same thing, then I suggest gettin a hold of BRun which is 
  899. available on Aminet.
  900.  
  901. Note: That when using the BRun command, you will need to use Amos To Back 
  902. command if you want to see and use that application.
  903.  
  904. Greg
  905. ---------------------------------------------------------------------------
  906.  
  907. > I would like to see the methods mentioned, Ben Wyatt says
  908. > he can sort 5000 numbers in one second. Now I would like to
  909. > see that.
  910.  
  911. Er... that's *less* than one second ;-)
  912.  
  913. This is my "invented" method, I call it the My Sort ;-)
  914.  
  915. -----------------------------------------------------------------------
  916. Set Buffer a_heck_of_a_lot ;-) (Depends on the max values and repeats)
  917.  
  918. Input "Numbers:";NUMBERS
  919. ' LIST() holds each of the values
  920. Dim LIST(NUMBERS)
  921.  
  922. ' Give each element a random value
  923. For N=0 To NUMBERS
  924.    LIST(N)=Rnd(MXVALUE)
  925. Next N
  926.  
  927. Proc_MYSORT[100,NUMBERS/10]
  928.  
  929. ' Here's the actual sort... short eh? ;)
  930. '   MXVALUE=End of range eg.0-100
  931. ' MXREPEATS=Max number of elements with the same value in the list
  932. Procedure _MYSORT[MXVALUE,MXREPEATS]
  933.    ' Reserve some large arrays
  934.    Dim APOINTER(MXVALUE,MXREPEATS),ACOUNT(MXVALUE),NEWLIST(NUMBERS)
  935.    ' Err.... can't explain this bit, look below for full explaination
  936.    For N=0 To NUMBERS
  937.       APOINTER(LIST(N),ACOUNT(LIST(N)))=N
  938.       Inc ACOUNT(LIST(N))
  939.    Next N
  940.    ' Pointers stuff (look below)
  941.    ELEMENT=0
  942.    For N=0 To MXVALUE
  943.       If ACOUNT(N)>0
  944.          For PLACE=0 To ACOUNT(N)-1
  945.             NEWLIST(ELEMENT)=LIST(APOINTER(N,PLACE))
  946.             Inc ELEMENT
  947.          Next PLACE
  948.       End If 
  949.    Next N
  950. End Proc
  951. -----------------------------------------------------------------------
  952.  
  953. Okay, now the explaination:
  954.  
  955. But first, a diagram to confuse you... ;)
  956.  
  957. Element no.         Your list           Pointers           New list
  958.                     +--------+          +--------+         +--------+
  959.     0               |    4   |          |    9   |         |    0   |
  960.                     +--------+          +--------+         +--------+
  961.     1               |   10   |          |    5   |         |    1   |
  962.                     +--------+          +--------+         +--------+
  963.     2               |    3   |          |   -1   |         |    3   |
  964.                     +--------+          +--------+         +--------+
  965.     3               |   15   |          |    2   |         |    4   |
  966.                     +--------+          +--------+         +--------+
  967.     4               |    8   |          |    0   |         |    5   |
  968.                     +--------+          +--------+         +--------+
  969.     5               |    1   |          |    7   |         |    8   |
  970.                     +--------+          +--------+         +--------+
  971.     6               |   12   |          |   -1   |         |    9   |
  972.                     +--------+          +--------+         +--------+
  973.     7               |    5   |          |   -1   |         |   10   |
  974.                     +--------+          +--------+         +--------+
  975.     8               |    9   |          |    4   |         |   12   |
  976.                     +--------+          +--------+         +--------+
  977.     9               |    0   |          |   -1   |         |   14   |
  978.                     +--------+          +--------+         +--------+
  979.    10               |   14   |          |    1   |         |   15   |
  980.                     +--------+          +--------+         +--------+
  981.    11                                   |   -1   |
  982.                                         +--------+
  983.    12                                   |    6   |
  984.                                         +--------+
  985.    13                                   |   -1   |
  986.                                         +--------+
  987.    14                                   |   10   |
  988.                                         +--------+
  989.    15                                   |    3   |
  990.                                         +--------+
  991. Maximum value in Your list, LIST(), is 15, so the number of elements
  992. in Pointers, APOINTER(), is 15. It then scans through Your list, looks
  993. at each value and puts it's index into Pointers, element "value". Can
  994. you make any sense of that? I struggled to! ;-)
  995.  
  996. For example, lets take element 0 of Your list, it holds "4". So, in
  997. element 4 of Pointers, a pointer to the element in Your list, ie 0.
  998. Follow???
  999.  
  1000. Now, each element in the pointers is gone through and the pointer is
  1001. read. Then the value of your list, element "Pointer", is put into the
  1002. next free space in New list. Another confusing paragraph... ;-)
  1003.  
  1004. For example, the first element in Pointers is 9, pointing to element
  1005. 9 of Your list. This element holds a 0. So the next free element of
  1006. New list holds the value 0.
  1007.  
  1008. Another example, it's up to element 12 in pointers, pointing to element
  1009. 6 in Your list. which is a 12, so the next free element in New list is
  1010. a 12. Understand???
  1011.  
  1012. If you can't understand all this, I understand, just use the procedure
  1013. and don't worry about it. ;-)
  1014.  
  1015. If you do understand it, congratulations, it's easy to program, and it
  1016. would be quite easy to alter it to cope with text. It could also be
  1017. made to take *much* less memory with a linked list, or some sort of
  1018. stack...
  1019.  
  1020. Does this sort sound familiar to anyone?
  1021.  
  1022. I do understand. Quite nice indeed.
  1023. You only go through the list twice to achive full sort. Fast.
  1024. However, on the 'memory'-thing you mention: this is a far greater pro-
  1025. blem than you make it appear. Usually one will have to go through the
  1026. list another time in order to find the 'maxnumbers'
  1027.  
  1028. Furthermore: I do not see quite what you mean by using a linked list or
  1029. the stack. Try to explain. 
  1030.  
  1031. I used a method to get fill the 'bucketsort'-buckets in two goes like
  1032. your program. It also needs the extra memory for a list in which it
  1033. will contain the start and end of each bucket. 
  1034. Maybe this sort can be combined with the 'fast-bucket' so the first goal
  1035. is to sort all in buckets and the second goal is to sort the buckets
  1036. so the memory needed is quite less.
  1037.  
  1038. > Does this sort sound familiar to anyone?
  1039. Not to me anyway. I don't know much about sorts of sorts ;-)
  1040.  
  1041. It's an advantage if you know the maxnumbers in advance. Otherwise it's
  1042. okay to use the maximum possible value that the numbers could hold.
  1043.  
  1044. > Furthermore: I do not see quite what you mean by using a linked list or
  1045. > the stack. Try to explain. 
  1046.  
  1047. With "My Sort" if two or more elements in the array have the same value,
  1048. they'll have to be put elsewhere. Each element of the Pointers could have
  1049. a linked list, each using the same bit of memory to hold the data. That
  1050. way, a lot less memory is used... At the moment, it just uses a two
  1051. dimensional array, with large "buckets" to hold the overflowing data
  1052. for each pointer (look at the program). This is a scrappy explaination,
  1053. sorry... I'll explain it again if it doesn't make sense ;-)
  1054.  
  1055. > I used a method to get fill the 'bucketsort'-buckets in two goes like
  1056. > your program. It also needs the extra memory for a list in which it
  1057. > will contain the start and end of each bucket. 
  1058. > Maybe this sort can be combined with the 'fast-bucket' so the first goal
  1059. > is to sort all in buckets and the second goal is to sort the buckets
  1060. > so the memory needed is quite less.
  1061.  
  1062. Yes, this sounds a bit like my sort, how fast is it?
  1063.  
  1064. > > Does this sort sound familiar to anyone?
  1065. > Not to me anyway. I don't know much about sorts of sorts ;-)
  1066.  
  1067. I've only done a bit at school...
  1068.  
  1069.  
  1070.  
  1071.  
  1072.      _________________________________
  1073.     /                                 \
  1074.     > Ben Wyatt - bwyatt@paston.co.uk <
  1075.     \_________________________________/ ©1995 Very Interesting Signatures
  1076.  
  1077. Why even go to all that trouble?!? If you are going to define an
  1078. array with as many elements as 0 to maxnumber then why not ditch
  1079. all that other stuff and simply increment the array element,
  1080. counting the number of 1's ,2's 3's...and so forth and then
  1081. create the new list using these values.
  1082.  
  1083. For I=0 To NUMBERS
  1084.         Inc SORTARRAY(LIST(I))
  1085. Next I
  1086. POS=0
  1087. For I=0 To MAXNUMBER
  1088.     If SORTARRAY(I)>0
  1089.            For J=1 To SORTARRAY(I)
  1090.               NEWLIST(POS)=I
  1091.               Inc POS
  1092.            Next J
  1093.         End If
  1094. Next I
  1095.  
  1096. Where NUMBERS contains the number of numbers to be sorted
  1097. LIST contains the unsorted numbers
  1098. SORTARRAY is an array that stores the frequency of each number
  1099. MAXNUMBER is the largest number to be sorted
  1100. NEWLIST stores the new array(and you could use LIST to store
  1101. this)
  1102.  
  1103. This uses far less resources and is just as quick.
  1104.  
  1105.  
  1106.             Robert Currie
  1107. It's brilliant. Why didn't I think of that? ;-)
  1108.  
  1109. Now make it work with strings and floating point numbers ;-D
  1110.  
  1111. > P.S. This type of sort is VERY limited and memory hungry but
  1112. > useful for small sorts or very tightly packed data.
  1113.  
  1114. I know :( or I know :-)))))
  1115.  
  1116. -------------------------------------------------------------------------
  1117. I've tried out this Comp Test Off command, and it does appear to 
  1118. speed up programs by about 10% when compiled.  In fact, if you've 
  1119. written an "interesting" program like:
  1120. Comp Test Off
  1121. For A=1 to 1000000
  1122. Next A
  1123.  
  1124. then the speed difference is about 30% (hurrah!).
  1125.  
  1126. However, if like me, your program is based around calling the Synchro 
  1127. command every 50th of a second or so, then you'll realise that there 
  1128. is no speed difference whatsoever.
  1129.  
  1130. It seems that the Synchro command calls the "Comp Test" code - is 
  1131. this true? If, so is there any way around it?
  1132.  
  1133. If anyone's interested (although I doubt it ;-) ) the Comp Test command is 
  1134. normally automatically called every time there is a 
  1135. loop/goto/wait/print etc in the program, and it takes about 5 micro 
  1136. seconds (on a bog standard A1200).
  1137.  
  1138. Cheers,
  1139.  
  1140. Mark
  1141.  
  1142. PH> > I've heard that the Comp Test [On/Off] commands are only dummies.
  1143. PH> > They all point to the same routine doing nothing. (?)
  1144. PH>
  1145. PH> They are until you compile the program. Then they stop it checking
  1146. PH> keyboard/mouse input. I had a database program which sorted
  1147. PH> a huge array 10% faster with comp test off, and copper off.
  1148.  
  1149. Did you use a screen with more than 16 lowres or 4 hires colours?
  1150.  
  1151. Thx for this information ;-))) I'll use it in my next productions
  1152. ;-))
  1153.  
  1154. Bye, Chris Hodges <chris@sixpack.pfalz.org>      __   __
  1155.  
  1156. --------------------------------------------------------------------------
  1157. Greetings Mark, you wrote some text on the subject Compiling Problems, and
  1158. now I'm going to answer it.
  1159.  
  1160. > Here are a couple of problems I had after I compiled my very large game:
  1161. > 1. It seems that when I use Set Font very soon after the Get Disc 
  1162. > Fonts command, I get an error return code 20 (divide by zero?). This 
  1163. > does not happen with the AMOS program.
  1164. > I use the Set Font command straight away,  for all the fonts in my 
  1165. > program, so that I do not get unwanted disk acceses later on.
  1166.  
  1167. I've never had this problem... but I have another suggestion...
  1168.  
  1169. Before doing the Get Disc Fonts, do an Assign "Fonts:" To "Fonts/".
  1170. This will make it so it doesn't load *all* the fonts on disk, only
  1171. your one in the program directory. When you end the program, do
  1172. something like:
  1173.  
  1174. If Exist("Sys:Fonts") Then Assign "Fonts:" To "Sys:Fonts"
  1175.  
  1176. This *might* fix your problem, as Amos could be clearing the fonts
  1177. from memory. This method takes far less memory and is faster.
  1178.  
  1179. Or get Easylife or Amcaf for better font support :)
  1180.  
  1181. > 2. When I choose the Squash program option and then try to load the 
  1182. > compiled program, it simply refuses to load (no problem with 
  1183. > powerpacker library).  I guess this must be a memory problem, 
  1184. > although my A1200 is fitted with an extra 4Mb of Fast RAM (the codes 
  1185. > about 200K long).
  1186. > Are these problems known bugs, or am I doing something wrong :-( ?
  1187.  
  1188. It is a bug. A very obvious one, that Europress *should* have noticed :(
  1189.  
  1190. Maybe they just didn't bother checking that it worked...
  1191.      _________________________________
  1192.     /                                 \
  1193.     > Ben Wyatt - bwyatt@paston.co.uk <
  1194.     \_________________________________/ ©1995 Very Interesting Signatures
  1195.  
  1196. BW> If Exist("Sys:Fonts") Then Assign "Fonts:" To "Sys:Fonts"
  1197.  
  1198. Ieeekkk! I've got my fonts in DH1:Fonts due to disk space reasons.
  1199. ;-)
  1200.  
  1201. Haven't tried this before but:
  1202.  
  1203. ODIR$=Dir$
  1204. Dir$="FONTS:"
  1205. OFONTS$=Path$(Dir$)
  1206. Dir$=ODIR$
  1207.  
  1208. at the beginning and:
  1209.  
  1210. Assign "FONTS:" To OFONTS$
  1211.  
  1212. should work no matter where the user has located his fonts normally
  1213. ;-)
  1214.  
  1215. --------------------------------------------------------------------------
  1216. Btw, in aminet you will find Oberon language archive, it contains
  1217. v40.xx includes ( not in real Commodore format..)
  1218. ------------------------------------------------------------------------
  1219. This is a program that does 8 way scrolling using generic colored blocks 
  1220. as the map icons. It manages around 1 screen every 4/50ths of a second and
  1221. I do not notice any flickering. There are other ways to do this but I did
  1222. not have time to test them all. One other possibility is to use a single
  1223. screen and the Horizontal and Vertical Scroll commands in conjunction with
  1224. the Clip command. This may speed things up but I am not sure.
  1225.  
  1226.  
  1227. 'Example program by Robert Currie
  1228. '----------------------------8 way scroller--------------------------- 
  1229. '
  1230. Set Buffer 50
  1231. Dim MAP(100,100)
  1232. Global MAP()
  1233. Global POX,POY
  1234. '
  1235. '!!MAP could have a third index which could tell information about speed ' 
  1236. 'of travel over that type of background or impassibility.!!'   
  1237. '
  1238. INITIALIZE
  1239. Repeat 
  1240.    Repeat 
  1241.        COM$=Inkey$
  1242.    Until COM$<>""
  1243.    If COM$="7"
  1244.       NEWSCREEN[-1,-1,True,False,True,False]
  1245.    End If 
  1246.    If COM$="8"
  1247.       NEWSCREEN[0,-1,True,False,False,False]
  1248.    End If 
  1249.    If COM$="9"
  1250.       NEWSCREEN[1,-1,True,False,False,True]
  1251.    End If 
  1252.    If COM$="4"
  1253.       NEWSCREEN[-1,0,False,False,True,False]
  1254.    End If 
  1255.    If COM$="6"
  1256.       NEWSCREEN[1,0,False,False,False,True]
  1257.    End If 
  1258.    If COM$="1"
  1259.       NEWSCREEN[-1,1,False,True,True,False]
  1260.    End If 
  1261.    If COM$="2"
  1262.       NEWSCREEN[0,1,False,True,False,False]
  1263.    End If 
  1264.    If COM$="3"
  1265.       NEWSCREEN[1,1,False,True,False,True]
  1266.    End If 
  1267. Until COM$="e"
  1268. '
  1269. '
  1270. Procedure INITIALIZE
  1271. For I=0 To 100
  1272.    For J=0 To 100
  1273.        MAP(I,J)=Rnd(5)+5
  1274.    Next J
  1275. Next I
  1276. ' Initializes map with random map pieces that correspond to icon indexes'  
  1277. Screen Open 1,320,200,16,Lowres
  1278. Screen Hide 1
  1279. ' This is the work screen' 
  1280. Screen Open 2,320,200,16,Lowres
  1281. Screen To Front 2
  1282. ' This is the show screen' 
  1283. Screen 1
  1284. For I=0 To 15
  1285.    Ink I,,
  1286.    Bar 0,0 To 15,15
  1287.    Get Icon 1,I+1,0,0 To 15,15
  1288. Next I
  1289. ' Creates the map peices--icons 1-16'  
  1290. POX=50
  1291. POY=50
  1292. ' Set the player start location
  1293. For X=0 To 16
  1294.    For Y=0 To 8
  1295.        Paste Icon 24+X*16,28+Y*16,MAP(X+POX-8,Y+POY-4)
  1296.    Next Y
  1297. Next X
  1298. ' Initialize the background
  1299. Get Icon 1,17,24,28 To 295,171
  1300. Screen 2
  1301. Paste Icon 24,28,17
  1302. ' Put the background on the front screen 
  1303. End Proc
  1304. Procedure NEWSCREEN[XMOV,YMOV,TP,BT,LT,RT]
  1305. '----------------------
  1306. 'Procedure NEWSCREEN 
  1307. 'XMOV--x direction player movement 
  1308. 'YMOV--y direction player movement 
  1309. 'TP--Boolean, true if top should be drawn
  1310. 'BT--Boolean, true if bottom should be drawn 
  1311. 'LT--Boolean, true if left should be drawn 
  1312. 'RT--Boolean, true if right should be drawn
  1313. '----------------------
  1314. Timer=0
  1315. '                                    Initialize timer to 0'
  1316. Screen 1
  1317. '                                    Flip to work screen'  
  1318. Paste Icon 24+XMOV*(-16),28+YMOV*(-16),17
  1319. '                                    Paste old screen at new position' 
  1320. '                                    !!Could check movement here!! 
  1321. POX=POX+XMOV
  1322. POY=POY+YMOV
  1323. '                                    Update player position' 
  1324. If TP
  1325. '                                    Draw top icons' 
  1326.    For X=0 To 16
  1327.        Paste Icon 24+X*16,28,MAP(X+POX-8,POY-4)
  1328.    Next X
  1329. End If 
  1330. If BT
  1331. '                                    Draw bottom icons'  
  1332.    For X=0 To 16
  1333.        Paste Icon 24+X*16,156,MAP(X+POX-8,POY+4)
  1334.    Next X
  1335. End If 
  1336. If LT
  1337. '                                    Draw left edge icons' 
  1338.    For Y=0 To 8
  1339.       Paste Icon 24,28+Y*16,MAP(POX-8,Y+POY-4)
  1340.    Next Y
  1341. End If 
  1342. If RT
  1343. '                                    Draw right edge icons'
  1344.    For Y=0 To 8
  1345.       Paste Icon 280,28+Y*16,MAP(POX+8,Y+POY-4)
  1346.    Next Y
  1347. End If 
  1348. Get Icon 1,17,24,28 To 295,171
  1349. '                                    Get new background' 
  1350. Screen 2
  1351. Paste Icon 24,28,17
  1352. '                                    Put new background on show screen'
  1353. Locate 0,0 : Print Timer
  1354. '                                    Show # of VTLs' 
  1355. '                                    !!Could place image of player here!!  
  1356. End Proc
  1357.  
  1358.  
  1359.                 Robert Currie
  1360.  
  1361.