Show us yer programming projects!

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
Post Reply
User avatar
GoatFoam
Baaaaa!
Baaaaa!
Posts: 1255
Joined: Tue Dec 12, 2006 11:05 am 0
Location: Brizzle
Contact:

Re: Show us yer programming projects!

Post by GoatFoam »

This talk of impostors has me thinking I could use them to make a game engine that I have been thinking about more tractable.
User avatar
gravy
Sheepie Whore
Sheepie Whore
Posts: 19572
Joined: Wed May 01, 2002 1:28 pm 0
Location: The Other Place

Re: Show us yer programming projects!

Post by gravy »

What was the name of that rendering system Intel / MS were working on that was impostor based?
User avatar
sack
Baaaaaaa!
Baaaaaaa!
Posts: 7077
Joined: Fri May 10, 2002 4:13 pm 0
XBL Gamertag: evilgopher
PSN: sixFiveOhTwo
Location: Rijswijk, The Netherlands
Contact:

Re: Show us yer programming projects!

Post by sack »

gravy wrote:What was the name of that rendering system Intel / MS were working on that was impostor based?
Talisman perhaps?
User avatar
gravy
Sheepie Whore
Sheepie Whore
Posts: 19572
Joined: Wed May 01, 2002 1:28 pm 0
Location: The Other Place

Re: Show us yer programming projects!

Post by gravy »

That's the fella. I kept thinking Taligent but that's an entirely separate failed project :)
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Show us yer programming projects!

Post by tufty »

Needed to do some reverse engineering of a bit of 68k Mac driver code. So I've been fiddling with a reverse-engineering disassembler, written in scheme.

This code :

Code: Select all

   1509c:	41f9 0001 53ce 	lea 0x153ce,%a0
   150a2:	2d48 fff8      	movel %a0,%fp@(-8)
   150a6:	2d6a 0016 fffc 	movel %a2@(22),%fp@(-4)
   150ac:	256a 0016 000c 	movel %a2@(22),%a2@(12)
   150b2:	206a 000c      	moveal %a2@(12),%a0
   150b6:	214a 00b8      	movel %a2,%a0@(184)
   150ba:	41ee fff8      	lea %fp@(-8),%a0
   150be:	102a 001a      	moveb %a2@(26),%d0
   150c2:	a07a           	_SetADBInfo
Looks like this

Code: Select all

(define *code* #vu8(#x41 #xf9 #x00 #x01 #x53 #xce #x2d #x48 #xff #xf8 #x2d #x6a #x00 #x16 #xff #xfc #x25 #x6a #x00 #x16 #x00 #x0c #x20 #x6a #x00 #x0c #x21 #x4a #x00 #xb8 #x41 #xee #xff #xf8 #x10 #x2a #x00 #x1a #xa0 #x7a))


> (disassemble-68k-instruction *code* 0)
((lea) (amode-absolute-long 86990) (amode-address-register-direct (a 0)))
> (disassemble-68k-instruction *code* 6)
((move l) (amode-address-register-direct (a 0)) (amode-indirect-displacement (a 6) 65528))
> (disassemble-68k-instruction *code* 10)
((move l) (amode-indirect-displacement (a 2) 22) (amode-indirect-displacement (a 6) 65532))
> (disassemble-68k-instruction *code* 16)
((move l) (amode-indirect-displacement (a 2) 22) (amode-indirect-displacement (a 2) 12))
> (disassemble-68k-instruction *code* 22)
((movea l) (amode-indirect-displacement (a 2) 12) (amode-address-register-direct (a 0)))
> (disassemble-68k-instruction *code* 26)
((move l) (amode-address-register-direct (a 2)) (amode-indirect-displacement (a 0) 184))
> (disassemble-68k-instruction *code* 30)
((lea) (amode-indirect-displacement (a 6) 65528) (amode-address-register-direct (a 0)))
> (disassemble-68k-instruction *code* 34)
((move b) (amode-indirect-displacement (a 2) 26) (amode-data-register-direct (d 0)))
> (disassemble-68k-instruction *code* 38)
((trap-a) (amode-immediate 41082) ())
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
User avatar
Partz
Baaaaa!
Baaaaa!
Posts: 1511
Joined: Tue Apr 23, 2002 8:46 pm 0
Location: Chippenham, Wiltshire

Re: Show us yer programming projects!

Post by Partz »

tufty wrote:Needed to do some reverse engineering of a bit of 68k Mac driver code. So I've been fiddling with a reverse-engineering disassembler, written in scheme.

Nice - makes me feel less out of touch seeing someone else writing a disassembler.

I'm just finishing off a 6502 disassembler in python. There are plenty but I wanted one that
gave a clue as to cycle usage.

The plan is for it to take a .prg file format, regular bin file or a vice snapshot. Currently vice snapshotting is in:

Code: Select all

Python 3.2.2 (default, Sep  4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 
          **** VMC64 Commodore 64 Virtual Machine ****          
          64K RAM SYSTEM 65024 Machine Code Bytes Free          

Ready.
:>lb c:\sheep.vsf
:>ls c:\sheep.vsf
Loading C:\SHEEP.VSF
info: C:\SHEEP.VSF RAM segment found. Loaded 65536 bytes into virtual ram space
ERROR: C:\SHEEP.VSF does not contain a ROM header.
:>IRQ
IRQ Vector: $80D2
:>d $80d2 $8100
80D2 :  AD  19  D0        LDA $D019         :  4 Cycles
80D5 :  29  01            AND #$01          :  2 Cycles
80D7 :  D0  03            BNE $80DC         :  2++ Cycles
80D9 :  4C  31  EA        JMP $EA31         :  3 Cycles
80DC :  E6  20            INC $20           :  5 Cycles
80DE :  4C  D0  83        JMP $83D0         :  3 Cycles
80E1 :  A5  20            LDA $20           :  3 Cycles
80E3 :  AA                TAX               :  2 Cycles
80E4 :  BD  C8  83        LDA $83C8,X       :  4+ Cycles
80E7 :  8D  12  D0        STA $D012         :  4 Cycles
80EA :  AD  11  D0        LDA $D011         :  4 Cycles
80ED :  29  7F            AND #$7F          :  2 Cycles
80EF :  1D  CC  83        ORA $83CC,X       :  4+ Cycles
80F2 :  8D  11  D0        STA $D011         :  4 Cycles
80F5 :  A9  81            LDA #$81          :  2 Cycles
80F7 :  8D  19  D0        STA $D019         :  4 Cycles
80FA :  8D  1A  D0        STA $D01A         :  4 Cycles
80FD :  68                PLA               :  4 Cycles
80FE :  A8                TAY               :  2 Cycles
80FF :  68                PLA               :  4 Cycles
8100 :  AA                TAX               :  2 Cycles
:>

The IRQ command just displays $0314/$0315 address vector. In this case, Jeff put the IRQ to $80D2 so disassembling from there gives the interrupt service routine for sheep in space

It does some other interesting stuff too. I can hunt for sprites which are displayed as text:

Code: Select all

:>SPR 175 177
2BC0 :          #########       
2BC3 :       ######    ######   
2BC6 :      ###             ### 
2BC9 :     ####                 
2BCC :    ##  ###               
2BCF :   ###########            
2BD2 :  #####  #######          
2BD5 :   ##   #########         
2BD8 :       ### ######         
2BDB :      ###  #######        
2BDE :      ###  #######        
2BE1 :      ##   #######        
2BE4 :           #######        
2BE7 :          ###   ###       
2BEA :          ###   ###       
2BED :         ###     ###      
2BF0 :         ###     ###      
2BF3 :        ####      ###     
2BF6 :        ###       ###     
2BF9 :      #####      ####     
2BFC :     #####      ####      
2C00 :          #########       
2C03 :       ######    ######   
2C06 :      ###             ### 
2C09 :     ####                 
2C0C :    ##  ###               
2C0F :   ###########            
2C12 :  #####  #######          
2C15 :   ##   #########         
2C18 :       ### ######         
2C1B :       ### #######        
2C1E :       ### #######        
2C21 :        ## #######        
2C24 :           #######        
2C27 :           ### ####       
2C2A :          ###  ####       
2C2D :          ###  #####      
2C30 :          ###    #####    
2C33 :          ###      ###    
2C36 :          ###     ####    
2C39 :        #####      ##     
2C3C :        #####             
:>
...Thats the ancipital sprite from S.I.S.... A further SPM command gives you sprites in multicolour mode replacing the colour with the numbers 0, 1, 2 or 3 depending on pixel pair bit settings.

It allows viewing of font data too:

Code: Select all

:>CHR 2000 2100
2000 :          
2001 :          
2002 :          
2003 :          
2004 :          
2005 :          
2006 :          
2007 :          
2008 :    ##### 
2009 :  ###  ## 
200A :   ##  ## 
200B :  ####### 
200C :   ##  ## 
200D :  ##   ## 
200E :  ##  ### 
200F :          
2010 :   #####  
2011 :  ###  ## 
2012 :   ##  ## 
2013 :  ######  
2014 :   ##  ## 
2015 :  ##   ## 
2016 :  ######  
2017 :          
2018 :    ####  
2019 :  ###  ## 
201A :   ##     
201B :  ###     
201C :   ##     
201D :   ##  ## 
201E :    ####  
201F :          
2020 :   ####   
2021 :  ### ##  
2022 :   ##  ## 
2023 :  ###  ## 
2024 :   ##  ## 
2025 :  ##  ##  
2026 :  #####   
2027 :          
2028 :   ###### 
2029 :  ###  ## 
202A :   ##     
202B :  #####   
202C :   ##     
202D :  ##   ## 
202E :  ####### 
202F :          
2030 :   ###### 
2031 :  ###  ## 
2032 :   ##     
2033 :  ######  
2034 :   ##     
2035 :  ##      
2036 :  ##      
2037 :          
2038 :    ####  
2039 :  ###  ## 
203A :   ##     
203B :  ### ### 
203C :   ##  ## 
203D :   ##  ## 
203E :    ##### 

....Again, thats the sheep in space font - I used a vice snapshot of it a LOT during testing

Not there yet, got some save features to add and I also want to suck out full VIC state from the the vice snapshot so grabbing graphics isnt such a chore. I want to add an option to be able to save memory as a set of dc.b values too so people can optionally drop data straight into there 6502 source. The big thing that isnt yet in place is the line assembler though - spending too long playing with it right now.

Good job on the 68k stuff - I considered doing one but banging in those op codes and allowing for different addressing modes... its something of a labour of love and im not really sure if anyone wants this stuff, so i know what you've been through there. Of course, if anyone is interested in this or has a clue where it could be made more publicly available then let me know.
User avatar
Istar
Baaaaaa!
Baaaaaa!
Posts: 4869
Joined: Mon Apr 22, 2002 4:42 pm 0
Location: London, UK.

Re: Show us yer programming projects!

Post by Istar »

On a vaguely related note, and running worryingly contrary to my standard form (i.e. this project is still going strong after three months and actually making tangible, visible progress) here's a short video of VIC++

NorthWay
Baaaa!
Baaaa!
Posts: 806
Joined: Sat Apr 27, 2002 7:45 pm 0
Location: Grimstad, Norway

Re: Show us yer programming projects!

Post by NorthWay »

Just a minor quip; those of you making disassemblers, any chance of making it interactive in the style of ReSource or IDA? (I know, much more work...)
Those are so much cooler to use. Don't know how many hours I have sunk into ReSource - staring at the screen and putting in comments and labeling OS calls and subroutines.
User avatar
Partz
Baaaaa!
Baaaaa!
Posts: 1511
Joined: Tue Apr 23, 2002 8:46 pm 0
Location: Chippenham, Wiltshire

Re: Show us yer programming projects!

Post by Partz »

NorthWay wrote:Just a minor quip; those of you making disassemblers, any chance of making it interactive in the style of ReSource or IDA? (I know, much more work...)
Those are so much cooler to use. Don't know how many hours I have sunk into ReSource - staring at the screen and putting in comments and labeling OS calls and subroutines.
I think about this and then start wondering how tools that do this cope with self modifying code for dynamic branches. I guess they can only make a best first stab based on current state information? I only wrote the script as an introduction to Python - I previously had zero scripting experience and its been something of a revelation. The disassembly function itself comes in around 50 lines of code and i'm sure an experienced Python developer would tell me 'You're doing it all wrong!'. I guess I am using some Python features - Tuples and such like. It being a script rather than an app it would be inherently open source so freely extensible. I've satisfied a lot of my urges but its not such a shabby hack that someone couldn't pick it up and do whatever they wanted with it.
User avatar
tufty
Sheepie Whore
Sheepie Whore
Posts: 12524
Joined: Fri Jan 07, 2005 4:52 pm 0
Location: French Alps

Re: Show us yer programming projects!

Post by tufty »

NorthWay wrote:Just a minor quip; those of you making disassemblers, any chance of making it interactive in the style of ReSource or IDA? (I know, much more work...)
Those are so much cooler to use. Don't know how many hours I have sunk into ReSource - staring at the screen and putting in comments and labeling OS calls and subroutines.
Well, mine's designed to be used from the Scheme REPL, but I don't know if that really qualifies as "interactive". The output at the moment is a pair of lists, one of which defines ranges of disassembled blocks (it's a list of lists, each "block" contains type (code or data), offset from the start of code, length, a list of internal labels (offset and label), an optional label for the block itself), and the other defines the actual assembly itself, again as a list of lists.

The process can be iterative, the first list can be modified and reused as input to the disassembler. So I guess "all" I'd need to write is a gui of some sort.

And then there's the postprocessing stages that I haven't even started yet. Unwinding the assembler to "strip off" the function pre and postambles, detecting the parameters and variables, that sort of thing.

Partz. Nice work. I'd suggest throwing it up on github or similar.

Simon
"massive retard™", "full of shit™", "tiny bitch™", "retarted™", "a bit of a one trick pony™", "petty™", "simple minded idealistic twat™", "miserable humourless fucker™"
NorthWay
Baaaa!
Baaaa!
Posts: 806
Joined: Sat Apr 27, 2002 7:45 pm 0
Location: Grimstad, Norway

Re: Show us yer programming projects!

Post by NorthWay »

Partz wrote:I think about this and then start wondering how tools that do this cope with self modifying code for dynamic branches.
How do you do it yourself?

I think ReSource has something like 32 bits representing every byte in the "source". For every place in the disassembly you set a type (code, relative value, long, word, byte, ascii, label) it forces a "flow" conversion. The disassembler will only work from where you are now until the next flowpoint, unless there are some branches or subroutine calls it can follow.
If there is a 16bit branch instruction and the code you disassemble writes to the "offset" part of the branch instruction it sees that this is part of an opcode and sets a label at the opcode start and uses 'label+1' for the destination address.

Code: Select all

  move.b #32,dynamic+1
dynamic
   bcc.b  someplace
   bvc.b  otherplace
   and.l   #7,d1  ; and on and on
There are some other and legal versions of this where you end up with a "cmp.l # ,dX" that has an actual instruction in the 32 bits you use for the compare. SAS/C 6.x does this.

Code: Select all

   bcc   IsSet+2
IsSet
   cmp.l #$ffffeeee,d0
; move.w #$ddcc,d0 is the real instruction being executed here (no, the values are not correct, please don't force me to look them up)
User avatar
sdetoni
Baaaaa!
Baaaaa!
Posts: 1368
Joined: Tue Jun 18, 2002 4:14 am 0
Location: New Sheepland

Re: Show us yer programming projects!

Post by sdetoni »

This may be of some use to some one, some where. It stamps a .png or .jpg water mark image (with suitable transparency layer) on a PDF doc.
Spent far to much time on this trying to find a simpler solution with ghost script (none worked). There was a Perl example also but decided
against that as it required me install another lib (i'm all about the default installs if I can get away with it), so used Java and itext lib wrapped
in a .jar file.
A gotcha with itext was getting the actual document page size, I needed to read it from sourcePDF2Watermark.getPageSizeWithRotation(i);
and not add_watermark.getPageSize(); as you would normally think ... Grrr!

Code: Select all

import java.io.FileOutputStream;
import java.util.Map;
import java.util.Set;

import com.itextpdf.text.Image;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfLayer;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;

public class watermark 
{
	public static void help ()
	{
		System.out.println ("\nWater Mark PDF Stamper");
		System.out.println ("----------------------");
		System.out.println ("Written by Steven De Toni : May 2012\n");
		System.out.println ("Usage: java -jar watermark.jar [parameters]");
		System.out.println ("-out_pdf  <out_filename.pdf>");
		System.out.println ("-src_pdf  <src_filename.pdf>");
		System.out.println ("-wm_img   <watermark_filename.png>");
		System.out.println ("-overlay  [over/under] (optional : default is over, over/under lay graphic onto of PDF content)\n\n");
		
		System.out.println ("These parameters will override automatic positioning!");
		System.out.println ("-xpos     [number] (optional : default is 0, and be any number to reposition watermark on X Plane)");
		System.out.println ("-ypos     [number] (optional : default is 0, and be any number to reposition watermark on Y Plane)");
		System.out.println ("-xpercent [number] (optional : default is 100.0 to resize watermark on X Plane)");
		System.out.println ("-ypercent [number] (optional : default is 100.0 to resize watermark on y Plane)");

		System.out.println ("e.g. : java -jar watermark.jar -src_pdf blah.pdf -out_pdf blah_wm.pdf -wm watermark.png -overlay over -xpercent 50 -ypercent 50");    	    	
	}
		
    public static void main(String[] args) 
    {
    	// read parameters from the command line
    	String   outFile    = null;
    	String   srcFile    = null;
    	String   wmFile     = null;
    	boolean overLayWM  = true;
    	boolean autoResize = true;
    	
    	// Optional resize variables/parameters
    	float   xPos     = 0.0f;
    	float   yPos     = 0.0f;    	
    	float   xPercent = 100.0f;
    	float   yPercent = 100.0f;    	
    	
    	if (args.length <= 0 )
    	{
    		help ();
    		return;
    	}
    	
    	for (int idx = 0; idx < args.length; idx++)
    	{
    		if (args[idx].equalsIgnoreCase("-out_pdf") != false)
    		{	
    			idx++;
    			if (idx < args.length)
    				outFile = args[idx]; 
    			else
    			{
    				System.err.println("Expect parameter for -out_pdf");
    				help();
    				return;
    			}
    		}
    		else if (args[idx].equalsIgnoreCase("-src_pdf") != false)
    		{	
    			idx++;
    			if (idx < args.length)
    				srcFile = args[idx]; 
    			else
    			{
    				System.err.println("Expect parameter for -src_pdf");
    				help();
    				return;
    			}
    		}
    		else if (args[idx].equalsIgnoreCase("-wm_img") != false)
    		{	
    			idx++;
    			if (idx < args.length)
    				wmFile = args[idx]; 
    			else
    			{
    				System.err.println("Expect parameter for -wm_img");
    				help();
    				return;
    			}
    		}    		    		
    		else if (args[idx].equalsIgnoreCase("-xpos") != false)
    		{	
    			idx++;
    			if (idx < args.length)
    			{
    				xPos = Integer.parseInt(args[idx]);
    				autoResize = false;
    			}
    			else
    			{
    				System.err.println("Expect parameter for -xpos");
    				help();
    				return;
    			}
    		}     		
    		else if (args[idx].equalsIgnoreCase("-ypos") != false)
    		{	
    			idx++;
    			if (idx < args.length)
    			{
    				yPos = Integer.parseInt(args[idx]);
    				autoResize = false;
    			}
    			else
    			{
    				System.err.println("Expect parameter for -ypos");
    				help();
    				return;
    			}
    		}    		    		    	
    		else if (args[idx].equalsIgnoreCase("-xpercent") != false)
    		{	
    			idx++;
    			if (idx < args.length)
    			{
    				xPercent = Float.parseFloat(args[idx]);
    				autoResize = false;
    			}
    			else
    			{
    				System.err.println("Expect parameter for -xpercent");
    				help();
    				return;
    			}
    		}     		
    		else if (args[idx].equalsIgnoreCase("-ypercent") != false)
    		{	
    			idx++;
    			if (idx < args.length)
    			{
    				yPercent = Float.parseFloat(args[idx]);
    				autoResize = false;
    			}
    			else
    			{
    				System.err.println("Expect parameter for -ypercent");
    				help();
    				return;
    			}
    		}    		
    		else if (args[idx].equalsIgnoreCase("-overlay") != false)
    		{	
    			idx++;
    			if (idx < args.length)
    			{
    				if (args[idx].equalsIgnoreCase("over") != false)
    				{
    					overLayWM = true;
    				}
    				else if (args[idx].equalsIgnoreCase("under") != false)
    				{
    					overLayWM = false;
    				}    				
    				else
    				{
    					System.err.println("-overlay unknown parameter " + args[idx]);
    					help();
    					return;    					
    				}
    			}
    			else
    			{
    				System.err.println("Expect parameter for -overlay");
    				help();
    				return;
    			}
    		}
    		else
			{
				System.err.println("Unknown parameter " + args[idx]);
				help();
				return;
			}
    			
    	}
    	
    	if (outFile == null)
		{
			System.err.println("Missing output pdf filename parameter");
			help();
			return;
		}
    	else if (srcFile == null)
		{
			System.err.println("Missing source pdf filename parameter");
			help();
			return;
		}
    	else if (wmFile == null)
		{
			System.err.println("Missing water mark png image filename parameter");
			help();
			return;
		} 
    	
    	System.out.println ("Processing PDF doc: " + srcFile);
    	System.out.println ("Output     PDF doc: " + outFile);
    	System.out.println ("Stamp Watere Mark : " + wmFile);
    	System.out.print   ("Stamp Method      : "); if (overLayWM != false) System.out.println ("overlay"); else System.out.println ("underlay");
    	if (autoResize != false)
    		System.out.println ("Stamping automatic resizing using image and document sizes");
    	else
    	{
    		System.out.println ("Stamping document using:");
    		System.out.println ("XPos : " + xPos + " YPos : " + yPos);
    		System.out.println ("XPercent : " + xPercent + "% YPercent : " + yPercent + "%");
    	}
    	System.out.println ("");
    	    	
        try 
        {
        	PdfReader  sourcePDF2Watermark = new PdfReader(srcFile);
        	int 	   pdfPageNum	       = sourcePDF2Watermark.getNumberOfPages();
        	PdfStamper pdfStamper          = new PdfStamper(sourcePDF2Watermark, new FileOutputStream(outFile));
        	int        i				   = 0;
        	     	
        	Image watermarkImg = Image.getInstance(wmFile);            
        	PdfContentByte add_watermark;            

        	System.out.println ("Watermark Size : Width=" + watermarkImg.getWidth() + " Height=" + watermarkImg.getHeight() ) ;
        	
        	while (i < pdfPageNum) 
        	{
        		System.out.println ("Processing page " + (i+1) + " of " + pdfPageNum);
        		
        		i++;
        		if (overLayWM != false)
        			add_watermark = pdfStamper.getOverContent(i);
        		else
        			add_watermark = pdfStamper.getUnderContent(i);
        		                 
				Rectangle rect = sourcePDF2Watermark.getPageSizeWithRotation(i);
        		
        		System.out.println ("Document Size : Width=" + rect.getWidth() + " Height=" + rect.getHeight() ) ;
        		
        		if (autoResize != false)
        		{        										
					// Resize and keep aspect ratio
        			float docWidth  = rect.getWidth();
        			float docHeight = rect.getHeight();   			
        			
					float x_stretch = (docWidth / watermarkImg.getWidth());
					float y_stretch = docHeight / watermarkImg.getHeight();
					
					if ( x_stretch < 1 || y_stretch < 1 )
						y_stretch = x_stretch < y_stretch ? x_stretch : y_stretch;
					else
						y_stretch = x_stretch < y_stretch ? x_stretch : y_stretch;
					
					float destWidth  = (watermarkImg.getWidth()  * x_stretch);     
					float destHeight = (watermarkImg.getHeight() * y_stretch);
					
					float xPosAR = (docWidth  - destWidth) / 2;
					float yPosAR = (docHeight - destHeight) / 2;
					
					float xPercentAR = (int)((100.0f / watermarkImg.getWidth())  * destWidth);
					float yPercentAR = (int)((100.0f / watermarkImg.getHeight()) * destHeight);
					
					System.out.println ("WM Plot X: " + xPosAR + " WM Plot Y : " + yPosAR);
					System.out.println ("WM Resize Width : " + destWidth + " WM Resize Height : " + destHeight);
					System.out.println ("WM Resize X Precent : " + xPercentAR + "% WM Resize Y Percent : " + yPercentAR + "%");					
					
					watermarkImg.setAbsolutePosition (xPosAR,   yPosAR);
					watermarkImg.scaleAbsolute(destWidth,       destHeight);
        		}
        		else
        		{
                	watermarkImg.setAbsolutePosition (xPos,     yPos);
                	watermarkImg.scalePercent        (xPercent, xPercent);            		        		
        		}
        		
        		add_watermark.addImage(watermarkImg);        		
            }
            pdfStamper.close();
        }
        catch (Exception i1) 
        {
            i1.printStackTrace();
        }
    }
}
User avatar
bcass
Baaaaa!
Baaaaa!
Posts: 1932
Joined: Mon Apr 22, 2002 7:54 pm 0
Location: Island of Dots
Contact:

Re: Show us yer programming projects!

Post by bcass »

Here's a small game project I've been working on in my spare time over the last 12 months.

Image

Image

Image

You can download the PC version from here:

https://skydrive.live.com/?lc=2057#cid= ... 2900AB!102

It's XNA so you'll need to install the Microsoft XNA Framework Redistributable first (6.7MB):

http://www.microsoft.com/en-us/download ... x?id=20914

The basic idea is to destroy all the droids on each stage in order to progress to the next one. The How To Play option on the title screen gives a few more details, but it doesn't give everything away. There are a number of other secret scoring techniques. One survival tip for beginners is that the player droid is invincible whilst teleporting.

I think I'm almost finished with it now. It started off as a super simple mobile game for Windows Phone 7 but gradually grew in complexity. In the mobile version the droid fires continually and you simply touch a teleporter to move to it.

Use the WASD keys to move around the screen and left/right cursor keys to fire left/right. Use JoyToKey if you'd prefer to use a joypad of your choice. JoyToKey and a config file for a PS2 pad are included in the SkyDrive link above. The game natively supports a 360 pad but I haven't put an option in yet to change from keys to pad as I'm not sure if I'll bother releasing the full game for anything other than mobile devices.
User avatar
bcass
Baaaaa!
Baaaaa!
Posts: 1932
Joined: Mon Apr 22, 2002 7:54 pm 0
Location: Island of Dots
Contact:

Re: Show us yer programming projects!

Post by bcass »

Incidentally, what Android platform version would people suggest for developing a simple game like this? I have a San Francisco (ZTE-BLADE) phone which is running 2.2. Should I aim for anything lower than this?
User avatar
toxibunny
Baaaaaaa!
Baaaaaaa!
Posts: 5906
Joined: Thu Jun 17, 2004 11:59 pm 0
Location: limb clock land

Re: Show us yer programming projects!

Post by toxibunny »

I dunno, but if you're thinking of targeting budget android phones, I was in the shop the other day and lots of them seem to be rocking a 320*240 screen...

I picked up a ZTE blade back when they were a superbargain - doesn't seem like the feat's been repeated in the intervening months...

*edit* - actually, my uninformed opinion says no. Aim it for ZTE Blade and up.
I made a deviantart page.
'....The baron is a gay old rogue with an eye for the ladies....'
Post Reply