News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Code Conversion Tools (Convert Amos To PlayBASIC)

Started by kevin, March 28, 2013, 07:39:10 PM

Previous topic - Next topic

kevin


    Amos To PlayBASIC - V0.21 - Cleaning up

        Pretty much completed the GUI stuff yesterday,  which always takes a bit of time hooked up all the little 'nothing' things behind the scene from firing events to saving/loading  preferences, which could thankfully  cut'n paste over.   The end program is simple, but works pretty well, could always work better I guess, but  I'm pretty happy with the result really.   So this is another little legacy tool I can cross off the list.   

       This morning I've been skimming through more AMOS programs tweaking the tables to improve the output.   Can't do everything with tables though.  The PRINT statement is a good example of this.    Print is one areas where PB and traditional BASIC go different ways.   The compiler in PB treats print as any other function,  where BASIC generally incorporates support for using  ; and , as separators. Which allows different data types to be joined (or printed separately)..    So it feels more like an implicit statement.  While this can be handy, in order to  covert these expressions to PB we need to remap the separators into string additions.   

       Remapping the expression is a bit tricky when don't actually know the data types of the items in the expression.  Some things are known such as Variables and Arrays, but AMOS  functions are a bit lottery, but I think with a bit of educated guessing it should be able to give a understandable result more often than not.   


       Bellow are some AMOS examples, 


   PRINT "Hello" ;a$

   PRINT "This" ;a ;"That"
   PRINT "test" ;a +b +c
   PRINT a$ ;45 ;123.456
   PRINT b$ ;123.456 *34
   PRINT "Yeah" ;a$ +b$
   PRINT a$ ;(b *a )

   PRINT Chr$(245 )+Chr$(34 )
   PRINT a ;table(10 )


       
                 
   and the PlayBASIC conversion

PlayBASIC Code: [Select]
   PRINT "Hello" +a$ 

PRINT "This" +Str$(a )+"That"
PRINT "test" +Str$(a +b +c )
PRINT a$ +Str$(45 )+Str$(123.456 )
PRINT b$ +Str$(123.456 *34 )
PRINT "Yeah" +a$ +b$
PRINT a$ ;(b *a )


PRINT Chr$(245 )+Chr$(34 )
PRINT a +Str$(table(10 ))


   

 
    yeah,  it's not 100%, but far from a bad result when the remapping routine is use applying some assumptions to the fragments.  That's the nice thing about converting code that is know to work, once you know the syntax of the input language it's easy to trap the most common circumstances.   

    Anyway, will probably have a few more tweak sessions over the conversion and release it.   


kevin

#16
  Amos Bank Viewer

     Amos source codes are really binary files with mixed hunks in them.   There's the leading code hunk, which is what the conversion stuff above deals with, but then there's the options for the various graphics,sound & data hunks.    I didn't think i'd ever used them in my programs, but to my surprise found a few programs with Sprite banks in them.   The the art in them isn't particularly interesting, but that got me thinking that for those moving old AMOS games to the PC then they're bound to have better art.   It's not that I see that as an all in one solution, but being able to export the original art can be a handy references for updating the originals.  I said references since these titles are running in much lower resolutions than modern day games.

     The same could be said for sound and data hunks.    Found one program that's literally only 50 odd lines long, that builds these large assembly includes.  Initially thought the conversion was broken, since the amos file is much bigger than the output code,  but there seems to be attached data fragments.   The program isn't of any use to me today, but writing a chunk from memory to disc isn't difficult, so might as well dump them all out..  

     The Amiga used bitplane display modes, so it's no great surprise to find that Amos Sprite and Icon banks are stored in raw planar, although it's a little surprising  they're not interleaved planar, but anyway.    To convert these to something we can use, first we convert the planar back to chunk pixels, then render out a picture using the palette which is thankfully stored with the sprites.  Otherwise, you'd have to work out the palette yourself.. I.e. You'd be fat out of luck.    

     Bellow we see the results of the convertor running over a bunch of sprite banks I found with a little googling.   While the code seems to work pretty well, there's the odd bank that it has an issue with..   But ya get that.   While searching around found a few programs that basically do the same thing, so I suggest trying those if Amos To PlayBASIC won't export the media correctly.


    Amos Examples

    (login required)

 


  Export Amos Sounds Bank To Wave Files

       Been have a playing with exporting more of the Amos bank types, focusing upon pulling the raw samples out from the bank and writing them to separate wave files, which turned out to be pretty easy.     Now since  Amos (due to Amiga's sound hardware) only has 8bit sample resolution, the exported sounds are still 8bit.   But, they actually sound fairly decent.  

       You can find an attached example which includes the original data block and exported samples in it..  The actual samples seem to be mostly ripped from movies from what I can tell..  But it works..


kevin

#17
  Amos Bank Viewer  - Pac:Pic exporter

      When looking at the picture format yesterday I'd assumed it was RLE encoded in horizontal spans, like the IFF image files, but it turns out that they actually use vertical spans.  After a bit of googling found a good document on the  Pic:Pac Format,  but even with that it's still taken most of the afternoon to get it working.   The routine as it stands and pull the picture data as a 8bit chunky.

      The legacy Amiga chipset include HAM6 (Hold and Modify mode) which are a type of special picture format, boosting the on screen colour count from 64 colours (Half bright mode) to 4096 colours.    Later Amiga models include HAM8 which gives you an approximately an 18bit image using only 8bits of colour data per pixel.   Variations of the same core concept are used in modern texture compression today.

      So far the test program can converting folder full of pictures (decompress, planar to chunky  & render) in about 180->190 milliseconds.   Which is not too bad for an 8 year old system.  


 

kevin


    Amos Bank Viewer  - Exports All Banks

           The test exporter now supports all the known banks (there's probably some others), the main types such as SPRITES, ICONS,  SAMPLES & PICTURE are converted into either bitmap or wav files.   The only exception is the MUSIC banks which are in a custom format.  These banks are exported to disc, but you'll have to convert them yourself.    There's a few tools that do this on the AMIGA  (  Abk2Mod-II  &  NoiseConverter ), but i'm unsure if there's something on the PC version.    But there probably is. 

           All banks are exported regardless, ones that are unknown are just dumped as raw data.   When data banks are stored within the main source code, they're given that source code name as the root file, with the bank index and media name in the output file name. So they all end up together in the folder.     One thing that would be handy when dropping sprites, is dropping a little table with all the Hot spot data in it.  Which would just be  text file.   

           While looking around I found some power packer depack source code/dll.  Power Packer was  popular file compression program on the Amiga, and I would seem AMOS supports packed banks..  So have slapped together a little wrapper to decompress such files.   Most of my files on A1200 HD image are all PP'd so it should come in very handy. 




kevin

#19
   Amos To PlayBASIC - V0.24 - Sicking it all together

     Dropped the various bank exporters in the main project yesterday and they all seem to work ok thus far.  They don't have error detection in them though, so if the file is damaged in some way or just uses some rare feature then they'll more than likely die.    All the test AMOS source codes seem to decode fine though, so hopefully that's a really rare situation.

     It's not all rosie though , as after finding some public domain examples that use encrypted procedures (something I never used) it gets a bit crash happy.   I'd assumed this was going to be none issue, since the decoding routine is posted all over the place (like here ) but for some reason the resulting code just won't decode in any sensible manner, leading to a crash. (Also tried Unlocker but no go)   Getting more than  little annoyed, decided to track down the AmosPRO source code.   It's written in 68K, so it's just matter of pulling out the decrypt routine.  Not hard tracking it down and initially there does seem like there might some differences.    But we'll see.

    Amos Procedure Decrypt



;----------------------> PROCEDURES

******* Codage / Decodage procedure LOCKEE
* A6---> "PROC"
ProCode movem.l d0-d7/a0-a6,-(sp)
move.l 2(a6),d0
lea 10+2+4(a6,d0.l),a2 * A2---> ENDPROC
move.w -2(a6),d0
lsr.w #8,d0
lsl.w #1,d0
lea -2(a6,d0.w),a1 * A1---> Ligne suivante
move.l 2(a6),d5
rol.l #8,d5
move.b 9(a6),d5
moveq #1,d4
move.w 6(a6),d3
bra.s PrCo2
PrCo1 eor.w d5,(a0)+
add.w d4,d5
add.w d3,d4
ror.l #1,d5
cmp.l a0,a1
bne.s PrCo1
PrCo2 move.l a1,a0
move.w (a0)+,d0
lsr.w #8,d0
lsl.w #1,d0
lea -2(a0,d0.w),a1
addq.l #2,a0
cmp.l a0,a2
bne.s PrCo1
* Change le flag
bchg #5,8(a6)
movem.l (sp)+,d0-d7/a0-a6
rts





     Anyway, hoping to get this out there over the weekend, even if the procedure decryption stuff is a bit iffy, it's still working pretty well.


     EDIT: - Ported the above routine and it all works as expected, using the new version Amos To PlayBASIC successfully decodes all the decrypted procedures in the example programs with out issue. 



kevin


Amos To PlayBASIC - V0.27 - Final Testing

       Haven't really done much of anything the past few days, due to  mothers day and then helping my brother move house among other things.   Fired  it this morning and have been testing it over the entire collection of AMOS sources.  Haven't seen any crashes or nasty surprises at all now.    There's is one strange thing, when you covert a path with lots of large source codes and leave the 'show source in console' option selected, the conversion gets progressively slower over time.    So rather than take a few minutes, it can take 10 or 20 minutes for the same folder.    Which i think is due to the amount of string trashing that's going when it syntax highlights and dump the result to the console display.   The console never releases the data so it's just constantly heaping.   It certainly wasn't really designed to have megs and megs of string fragments constantly dumped into it that's for sure.

       The plan for the rest of afternoon is just tweak up the AMOS command set tables a bit more and put online.   The command set /extensions mapping are far from fully mapped (it does support a lot of the core stuff though), but it's pretty easy to add new mappings for those people who are interested.     If you do, then please post them in this thread so we can include them into later editions of the package. 




 

kevin

#21

 
 
Amos To PlayBASIC - V0.27 - Download


     Here's the current build of the Amos To PlayBASIC conversion tool.    


  Download

  Amos To PlayBASIC (V0.27) (login required)



calder

Hi, the link to download the tool has expired. Is this software still available somewhere? Thanks.

kevin


kevin

#24
PlayBASIC LIVE :  Intro Converting Amos To PlayBASIC  (2017-12-03)


 Welcome... Today we'll take a look back at a free tool created to help Amos & AmosPro programmers begin the conversion process to PlayBASIC. The tool is simply called AmosToPlayBASIC and can be found on our forums and includes conversion support for the core Amos to PlayBASIC syntax through to exporting the various hidden data banks within Amos such as Sprites/Pictures/Samples and Music modules.

Note: Later in the video we go through how to improve the conversion by adding your  own Amos command tokens to the instruction sets.


Video:





mister_smythe

Is this tool still available? I clicked the link above but got "Hotlinked - Please link the page and not the file"

kevin


  yes it should, but it appears those links aren't working because of the change to the https:  -  I'll look at fixing it tonight

kevin

Quote from: mister_smythe on November 01, 2018, 05:03:10 AM
Is this tool still available? I clicked the link above but got "Hotlinked - Please link the page and not the file"


Seems to be fixed now.