Add check for snprintf in the event it is not supported.
[SquirrelJME.git] / assets / snippets / AlphaTable.java
blob41f2f48b4f01e94b4749c5f2c654795f8eb1f1a7
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 Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 /**
11 * Generates 4-bit alpha table.
13 * @since 2024/07/13
15 public class AlphaTable
17 /**
18 * Main entry point.
20 * @param __args Ignored.
21 * @since 2024/07/13
23 public static void main(String... __args)
25 for (int ah = 0x00; ah < 0x100; ah += 0x10)
27 // Full value for A
28 int dX = ah | (ah >>> 4);
30 for (int bh = 0x00; bh < 0x100; bh += 0x10)
32 // Full value for B
33 int sX = bh | (bh >>> 4);
35 // Convert alpha to float
36 double dD = (dX / 255.0);
37 double sD = (sX / 255.0);
39 double mD = sD + dD - (sD * dD);
41 System.out.printf("");
43 int iD = Math.max(0, Math.min(255,
44 (int)Math.round(mD * 255.0)));
46 System.out.printf("%02");
48 /*int da = ca = sa + da - sjme_fixed_mul(sa, da);*/