Check-in [f1cdff6ee7]

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

Overview
Comment:Set attributes in the ROM database; Write of name and attributes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f1cdff6ee7a0b8a86e3cc272bdb34a0d49f1048d
User & Date: stephanie.gawroriski 2019-07-13 15:47:43
Context
2019-07-13
15:49
Record the epoch difference for UNIX and PalmOS (Mac). check-in: ecce1ba61d user: stephanie.gawroriski tags: trunk
15:47
Set attributes in the ROM database; Write of name and attributes. check-in: f1cdff6ee7 user: stephanie.gawroriski tags: trunk
14:44
Add write to byte array version of the database. check-in: a2e7a01986 user: stephanie.gawroriski tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

5
6
7
8
9
10
11

12
13
14
15
16
17
18
..
65
66
67
68
69
70
71



72
73
74
75
76
77
78
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.builder.support.dist;


import dev.shadowtail.palmos.PalmDatabaseBuilder;
import dev.shadowtail.palmos.PalmDatabaseType;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.javac.ZipCompilerOutput;

................................................................................
		PalmDatabaseBuilder db = new PalmDatabaseBuilder(
			PalmDatabaseType.RESOURCE);
		
		// Set information on the database
		db.setName("SquirrelJME ROM");
		db.setType("mROM");
		db.setCreator("SjME");



		
		// Write ROM length
		try (DataOutputStream ent = new DataOutputStream(
			db.addEntry("RlEN", 0)))
		{
			ent.writeInt(romlen);
		}
................................................................................
		throws IOException, NullPointerException
	{
		if (__zip == null || __bp == null)
			throw new NullPointerException("NARG");
		
		// PalmOS (especially older versions) do not have a concept of a
		// file system so a ROM has to exist as a database
		try (OutputStream out = __zip.output("squirreljme-rom.prc"))
		{
			this.buildRomDatabase(out, __bp);
		}
		
		// Include the PRC that can run the actual ROM!
		todo.TODO.note("Include RatufaCoat squirreljme.prc for now!");
	}
}








>







 







>
>
>







 







|









5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package cc.squirreljme.builder.support.dist;

import dev.shadowtail.palmos.PalmDatabaseAttribute;
import dev.shadowtail.palmos.PalmDatabaseBuilder;
import dev.shadowtail.palmos.PalmDatabaseType;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import net.multiphasicapps.javac.ZipCompilerOutput;

................................................................................
		PalmDatabaseBuilder db = new PalmDatabaseBuilder(
			PalmDatabaseType.RESOURCE);
		
		// Set information on the database
		db.setName("SquirrelJME ROM");
		db.setType("mROM");
		db.setCreator("SjME");
		db.setAttributes(PalmDatabaseAttribute.BACKUP,
			PalmDatabaseAttribute.OK_TO_INSTALL_NEWER,
			PalmDatabaseAttribute.BUNDLE);
		
		// Write ROM length
		try (DataOutputStream ent = new DataOutputStream(
			db.addEntry("RlEN", 0)))
		{
			ent.writeInt(romlen);
		}
................................................................................
		throws IOException, NullPointerException
	{
		if (__zip == null || __bp == null)
			throw new NullPointerException("NARG");
		
		// PalmOS (especially older versions) do not have a concept of a
		// file system so a ROM has to exist as a database
		try (OutputStream out = __zip.output("squirreljme-rom.pdb"))
		{
			this.buildRomDatabase(out, __bp);
		}
		
		// Include the PRC that can run the actual ROM!
		todo.TODO.note("Include RatufaCoat squirreljme.prc for now!");
	}
}

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























































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.palmos;

/**
 * This represents an attribute for the Palm Database.
 *
 * @since 2019/07/13
 */
public enum PalmDatabaseAttribute
{
	/** This is a resource database. */
	RESOURCE_DATABASE(0x0001),
	
	/** Read-only. */
	READ_ONLY(0x0002),
	
	/** Info block is dirty. */
	APP_INFO_DIRTY(0x0004),
	
	/** Database should be packed up to the PC. */
	BACKUP(0x0008),
	
	/** Is okay to install newer version? */
	OK_TO_INSTALL_NEWER(0x0010),
	
	/** Requires a reset after install. */
	RESET_AFTER_INSTALL(0x0020),
	
	/** Copy protection (prevent beaming/copy). */
	COPY_PROTECTION(0x0040),
	
	/** Used as a file stream. */
	STREAM(0x0080),
	
	/** Is hidden. */
	HIDDEN(0x0100),
	
	/** Is a data resource which can be launched. */
	LAUNCHABLE_DATA(0x0200),
	
	/** The database can be recycled. */
	RECYCLABLE(0x0400),
	
	/** Is a bundle, always beam with the same creator type. */
	BUNDLE(0x0800),
	
	/** Database is open and has not been closed properly. */
	OPEN(0x8000),
	
	/** End. */
	;
	
	/** The bit used. */
	public final int bit;
	
	/**
	 * Initializes the attribute.
	 *
	 * @param __b The bit used.
	 * @since 2019/07/13
	 */
	private PalmDatabaseAttribute(int __bit)
	{
		this.bit = __bit;
	}
}

Changes to bldt/libs/palmos-utils/dev/shadowtail/palmos/PalmDatabaseBuilder.java.

6
7
8
9
10
11
12

13
14
15
16


17
18
19
20
21
22
23
24




25
26




27
28
29
30
31
32
33
..
71
72
73
74
75
76
77























78
79
80
81
82
83
84
...
164
165
166
167
168
169
170




























171
172
173
174
175
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.palmos;

import java.io.ByteArrayOutputStream;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;



/**
 * This class is used to build PalmOS databases and resource databases.
 *
 * @since 2019/07/13
 */
public final class PalmDatabaseBuilder
{




	/** The type of database to create. */
	protected final PalmDatabaseType dbtype;




	
	/** The entries within the database. */
	private final List<PalmRecord> _records =
		new ArrayList<>();
	
	/** The creator of the database. */
	private String _creator =
................................................................................
	{
		if (__type == null)
			throw new NullPointerException("NARG");
		
		// Create a record writer to write there
		return new __RecordWriter__(__type, __id, this._records);
	}























	
	/**
	 * Sets the creator of the database.
	 *
	 * @param __creat The creator to use.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
................................................................................
	 * @since 2019/07/13
	 */
	public final void writeTo(OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");




























		
		throw new todo.TODO();
	}
}








>




>
>








>
>
>
>


>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
..
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package dev.shadowtail.palmos;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.util.Set;

/**
 * This class is used to build PalmOS databases and resource databases.
 *
 * @since 2019/07/13
 */
public final class PalmDatabaseBuilder
{
	/** The limit to the name length. */
	private static final int _NAME_LIMIT =
		32;
	
	/** The type of database to create. */
	protected final PalmDatabaseType dbtype;
	
	/** Attributes within the database. */
	private final Set<PalmDatabaseAttribute> _attributes =
		new HashSet<>();
	
	/** The entries within the database. */
	private final List<PalmRecord> _records =
		new ArrayList<>();
	
	/** The creator of the database. */
	private String _creator =
................................................................................
	{
		if (__type == null)
			throw new NullPointerException("NARG");
		
		// Create a record writer to write there
		return new __RecordWriter__(__type, __id, this._records);
	}
	
	/**
	 * Sets the given attributes.
	 *
	 * @param __a The attribute to set.
	 * @return {@code this}.
	 * @since 2019/07/13
	 */
	public final PalmDatabaseBuilder setAttributes(
		PalmDatabaseAttribute... __a)
	{
		if (__a == null)
			return this;
		
		// Add the attributes
		Set<PalmDatabaseAttribute> attributes = this._attributes;
		for (PalmDatabaseAttribute attr : __a)
			if (attr != null)
				attributes.add(attr);
		
		// Return self
		return this;
	}
	
	/**
	 * Sets the creator of the database.
	 *
	 * @param __creat The creator to use.
	 * @return {@code this}.
	 * @throws NullPointerException On null arguments.
................................................................................
	 * @since 2019/07/13
	 */
	public final void writeTo(OutputStream __out)
		throws IOException, NullPointerException
	{
		if (__out == null)
			throw new NullPointerException("NARG");
		
		// Open data output to write to
		DataOutputStream dos = new DataOutputStream(__out);
		
		// Write the name bytes
		byte[] namebytes = this._name.getBytes("utf-8");
		int namelen = namebytes.length;
		dos.write(namebytes, 0, Math.min(namelen, _NAME_LIMIT));
		
		// Pad shorter names
		for (int i = namelen; i < _NAME_LIMIT; i++)
			dos.write(0);
		
		// Determine attribute bit-field
		int attrs = 0;
		for (PalmDatabaseAttribute attr : this._attributes)
			attrs |= attr.bit;
		
		// Make sure the attribute flag is always correct because if it was
		// specified it would make the database not valid to be handled
		PalmDatabaseType dbtype = this.dbtype;
		if (dbtype == PalmDatabaseType.RESOURCE)
			attrs |= PalmDatabaseAttribute.RESOURCE_DATABASE.bit;
		else
			attrs &= ~PalmDatabaseAttribute.RESOURCE_DATABASE.bit;
		
		// Write attributes
		dos.writeShort(attrs);
		
		throw new todo.TODO();
	}
}

Changes to ratufacoat/makefile.palm.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
FILES=sjmerc.c sjmercnm.c sjmercvm.c sys_palm.c

squirreljme.prc:	squirreljme-palm.a
			rm -vf *.grc *.bin
			m68k-palmos-obj-res squirreljme-palm.a
			pilrc palm.rcp
			build-prc -o $@ -t appl -c SjME -n "SquirrelJME" \
				*.grc *.bin

squirreljme-palm.a:	$(FILES)
			m68k-palmos-gcc -o $@ $^ $(CFLAGS) $(LIBS)

clean:				
			rm -f squirreljme-palm.a *.grc *.bin squirreljme.prc







|






10
11
12
13
14
15
16
17
18
19
20
21
22
23
FILES=sjmerc.c sjmercnm.c sjmercvm.c sys_palm.c

squirreljme.prc:	squirreljme-palm.a
			rm -vf *.grc *.bin
			m68k-palmos-obj-res squirreljme-palm.a
			pilrc palm.rcp
			build-prc -o $@ -t appl -c SjME -n "SquirrelJME" \
				--ok-to-install-newer --bundle *.grc *.bin

squirreljme-palm.a:	$(FILES)
			m68k-palmos-gcc -o $@ $^ $(CFLAGS) $(LIBS)

clean:				
			rm -f squirreljme-palm.a *.grc *.bin squirreljme.prc