Check-in [9edcb5e052]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Building of the SquirrelJME ROM.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9edcb5e0524815c453ea83384d3949fe4d14afd5
User & Date: stephanie.gawroriski 2019-07-13 14:21:12
Context
2019-07-13
14:41
Write part of the database fields. check-in: 49d76c6c68 user: stephanie.gawroriski tags: trunk
14:21
Building of the SquirrelJME ROM. check-in: 9edcb5e052 user: stephanie.gawroriski tags: trunk
13:36
Add base for PalmOS distribution; Add base for PalmOS utilities. check-in: cc0e30498e user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added assets/doc/usage-palmos.mkd.

            1  +# PalmOS

Changes to bldt/libs/builder-support/cc/squirreljme/builder/support/dist/PalmOSDist.java.

     5      5   // ---------------------------------------------------------------------------
     6      6   // SquirrelJME is under the GNU General Public License v3+, or later.
     7      7   // See license.mkd for licensing and copyright information.
     8      8   // ---------------------------------------------------------------------------
     9      9   
    10     10   package cc.squirreljme.builder.support.dist;
    11     11   
           12  +import dev.shadowtail.palmos.PalmDatabaseBuilder;
           13  +import dev.shadowtail.palmos.PalmDatabaseType;
           14  +import java.io.DataOutputStream;
    12     15   import java.io.IOException;
    13     16   import java.io.OutputStream;
    14     17   import net.multiphasicapps.javac.ZipCompilerOutput;
    15     18   
    16     19   /**
    17     20    * Palm OS distribution.
    18     21    *
    19     22    * @since 2019/07/13
    20     23    */
    21     24   public class PalmOSDist
    22     25   	extends SummerCoatROM
    23     26   {
           27  +	/** The size of a single fragment of the ROM. */
           28  +	public static final int ROM_FRAGMENT_SIZE =
           29  +		32768;
           30  +	
    24     31   	/**
    25     32   	 * Initializes the builder.
    26     33   	 *
    27     34   	 * @since 2019/07/13
    28     35   	 */
    29     36   	public PalmOSDist()
    30     37   	{
    31     38   		super("palmos");
    32     39   	}
           40  +	
           41  +	/**
           42  +	 * Builds the ROM database.
           43  +	 *
           44  +	 * @param __out The stream to write to.
           45  +	 * @param __bp The build parameters.
           46  +	 * @throws IOException On write errors.
           47  +	 * @throws NullPointerException On null arguments.
           48  +	 * @since 2019/07/13
           49  +	 */
           50  +	protected void buildRomDatabase(OutputStream __out, BuildParameters __bp)
           51  +		throws IOException, NullPointerException
           52  +	{
           53  +		if (__out == null || __bp == null)
           54  +			throw new NullPointerException("NARG");
           55  +		
           56  +		// Build the ROM first and get its bytes
           57  +		byte[] romdata = __bp.minimize();
           58  +		int romlen = romdata.length;
           59  +		
           60  +		// The ROM must be split into multiple fragments due to HotSync
           61  +		// limitation
           62  +		int numfrags = (romlen / ROM_FRAGMENT_SIZE) + 1;
           63  +		
           64  +		// Create builder for the database
           65  +		PalmDatabaseBuilder db = new PalmDatabaseBuilder(
           66  +			PalmDatabaseType.RESOURCE);
           67  +		
           68  +		// Set information on the database
           69  +		db.setName("SquirrelJME ROM");
           70  +		db.setType("mROM");
           71  +		db.setCreator("SjME");
           72  +		
           73  +		// Write ROM length
           74  +		try (DataOutputStream ent = new DataOutputStream(
           75  +			db.addEntry("RlEN", 0)))
           76  +		{
           77  +			ent.writeInt(romlen);
           78  +		}
           79  +		
           80  +		// Write fragment length
           81  +		try (DataOutputStream ent = new DataOutputStream(
           82  +			db.addEntry("FlEN", 0)))
           83  +		{
           84  +			ent.writeInt(ROM_FRAGMENT_SIZE);
           85  +		}
           86  +		
           87  +		// Write fragment count
           88  +		try (DataOutputStream ent = new DataOutputStream(
           89  +			db.addEntry("FnUM", 0)))
           90  +		{
           91  +			ent.writeInt(numfrags);
           92  +		}
           93  +		
           94  +		// Write every fragment to the database
           95  +		for (int i = 0, p = 0; i < numfrags; i++, p += ROM_FRAGMENT_SIZE)
           96  +		{
           97  +			// Write individual fragment
           98  +			try (DataOutputStream ent = new DataOutputStream(
           99  +				db.addEntry("FrOM", i)))
          100  +			{
          101  +				// Write the fragment data
          102  +				ent.write(romdata, p, Math.min(romlen - p, ROM_FRAGMENT_SIZE));
          103  +				
          104  +				// Make sure all fragments are the same size
          105  +				if (ent.size() < ROM_FRAGMENT_SIZE)
          106  +					ent.write(0);
          107  +			}
          108  +		}
          109  +		
          110  +		// Write the output
          111  +		db.write(__out);
          112  +	}
    33    113   	
    34    114   	/**
    35    115   	 * {@inheritDoc}
    36    116   	 * @since 2019/07/13
    37    117   	 */
    38    118   	@Override
    39    119   	protected void generate(ZipCompilerOutput __zip, BuildParameters __bp)
    40    120   		throws IOException, NullPointerException
    41    121   	{
    42    122   		if (__zip == null || __bp == null)
    43    123   			throw new NullPointerException("NARG");
    44    124   		
    45         -		throw new todo.TODO();
          125  +		// PalmOS (especially older versions) do not have a concept of a
          126  +		// file system so a ROM has to exist as a database
          127  +		try (OutputStream out = __zip.output("squirreljme-rom.prc"))
          128  +		{
          129  +			this.buildRomDatabase(out, __bp);
          130  +		}
          131  +		
          132  +		// Include the PRC that can run the actual ROM!
          133  +		todo.TODO.note("Include RatufaCoat squirreljme.prc for now!");
    46    134   	}
    47    135   }
    48    136   

Added bldt/libs/palmos-utils/dev/shadowtail/palmos/PalmDatabaseBuilder.java.

            1  +// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
            2  +// ---------------------------------------------------------------------------
            3  +// Multi-Phasic Applications: SquirrelJME
            4  +//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
            5  +// ---------------------------------------------------------------------------
            6  +// SquirrelJME is under the GNU General Public License v3+, or later.
            7  +// See license.mkd for licensing and copyright information.
            8  +// ---------------------------------------------------------------------------
            9  +
           10  +package dev.shadowtail.palmos;
           11  +
           12  +import java.io.IOException;
           13  +import java.io.OutputStream;
           14  +
           15  +/**
           16  + * This class is used to build PalmOS databases and resource databases.
           17  + *
           18  + * @since 2019/07/13
           19  + */
           20  +public final class PalmDatabaseBuilder
           21  +{
           22  +	/** The type of database to create. */
           23  +	protected final PalmDatabaseType type;
           24  +	
           25  +	/**
           26  +	 * Initializes the database builder.
           27  +	 *
           28  +	 * @param __type The database type.
           29  +	 * @throws NullPointerException On null arguments.
           30  +	 * @since 2019/07/13
           31  +	 */
           32  +	public PalmDatabaseBuilder(PalmDatabaseType __type)
           33  +		throws NullPointerException
           34  +	{
           35  +		if (__type == null)
           36  +			throw new NullPointerException("NARG");
           37  +		
           38  +		this.type = __type;
           39  +	}
           40  +	
           41  +	/**
           42  +	 * Adds the specified entry.
           43  +	 *
           44  +	 * @param __type The entry type.
           45  +	 * @param __id The ID to use.
           46  +	 * @return The stream to the entry data.
           47  +	 * @throws NullPointerException On null arguments.
           48  +	 * @since 2019/07/13
           49  +	 */
           50  +	public final OutputStream addEntry(String __type, int __id)
           51  +		throws NullPointerException
           52  +	{
           53  +		if (__type == null)
           54  +			throw new NullPointerException("NARG");
           55  +		
           56  +		throw new todo.TODO();
           57  +	}
           58  +	
           59  +	/**
           60  +	 * Sets the creator of the database.
           61  +	 *
           62  +	 * @param __creat The creator to use.
           63  +	 * @return {@code this}.
           64  +	 * @throws NullPointerException On null arguments.
           65  +	 * @since 2019/07/13
           66  +	 */
           67  +	public final PalmDatabaseBuilder setCreator(String __creat)
           68  +		throws NullPointerException
           69  +	{
           70  +		if (__creat == null)
           71  +			throw new NullPointerException("NARG");
           72  +		
           73  +		throw new todo.TODO();
           74  +	}
           75  +	
           76  +	/**
           77  +	 * Sets the name of the database.
           78  +	 *
           79  +	 * @param __name The name to use.
           80  +	 * @return {@code this}.
           81  +	 * @throws NullPointerException On null arguments.
           82  +	 * @since 2019/07/13
           83  +	 */
           84  +	public final PalmDatabaseBuilder setName(String __name)
           85  +		throws NullPointerException
           86  +	{
           87  +		if (__name == null)
           88  +			throw new NullPointerException("NARG");
           89  +		
           90  +		throw new todo.TODO();
           91  +	}
           92  +	
           93  +	/**
           94  +	 * Sets the type of the database.
           95  +	 *
           96  +	 * @param __type The type to use.
           97  +	 * @return {@code this}.
           98  +	 * @throws NullPointerException On null arguments.
           99  +	 * @since 2019/07/13
          100  +	 */
          101  +	public final PalmDatabaseBuilder setType(String __type)
          102  +		throws NullPointerException
          103  +	{
          104  +		if (__type == null)
          105  +			throw new NullPointerException("NARG");
          106  +		
          107  +		throw new todo.TODO();
          108  +	}
          109  +	
          110  +	/**
          111  +	 * Writes the database to the output.
          112  +	 *
          113  +	 * @param __out The output stream.
          114  +	 * @throws IOException On write errors.
          115  +	 * @throws NullPointerException On null arguments.
          116  +	 * @since 2019/07/13
          117  +	 */
          118  +	public final void write(OutputStream __out)
          119  +		throws IOException, NullPointerException
          120  +	{
          121  +		if (__out == null)
          122  +			throw new NullPointerException("NARG");
          123  +		
          124  +		throw new todo.TODO();
          125  +	}
          126  +}
          127  +

Added bldt/libs/palmos-utils/dev/shadowtail/palmos/PalmDatabaseType.java.

            1  +// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
            2  +// ---------------------------------------------------------------------------
            3  +// Multi-Phasic Applications: SquirrelJME
            4  +//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
            5  +// ---------------------------------------------------------------------------
            6  +// SquirrelJME is under the GNU General Public License v3+, or later.
            7  +// See license.mkd for licensing and copyright information.
            8  +// ---------------------------------------------------------------------------
            9  +
           10  +package dev.shadowtail.palmos;
           11  +
           12  +/**
           13  + * This represents the database type to use when creating databases.
           14  + *
           15  + * @since 2019/07/13
           16  + */
           17  +public enum PalmDatabaseType
           18  +{
           19  +	/** Resource database. */
           20  +	RESOURCE,
           21  +	
           22  +	/** Record database. */
           23  +	RECORD,
           24  +	
           25  +	/** End. */
           26  +	;
           27  +}
           28  +

Added bldt/libs/palmos-utils/dev/shadowtail/palmos/PalmRecord.java.

            1  +// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
            2  +// ---------------------------------------------------------------------------
            3  +// Multi-Phasic Applications: SquirrelJME
            4  +//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
            5  +// ---------------------------------------------------------------------------
            6  +// SquirrelJME is under the GNU General Public License v3+, or later.
            7  +// See license.mkd for licensing and copyright information.
            8  +// ---------------------------------------------------------------------------
            9  +
           10  +package dev.shadowtail.palmos;
           11  +
           12  +/**
           13  + * DESCRIBE THIS.
           14  + *
           15  + * @since 2019/07/13
           16  + */
           17  +public class PalmRecord
           18  +{
           19  +}
           20  +