Pattern Selector 0.4

- Rewrote with C2 + separated config 06
- Remove label option
This commit is contained in:
sup39 2023-02-01 01:02:24 +09:00
parent 3a730390ac
commit 9207badc08
5 changed files with 161 additions and 235 deletions

268
Codes.xml
View file

@ -3344,8 +3344,8 @@
<title lang="en-US">Pattern Selector</title> <title lang="en-US">Pattern Selector</title>
<title lang="ja-JP">パターン選択</title> <title lang="ja-JP">パターン選択</title>
<author>sup39(サポミク)</author> <author>sup39(サポミク)</author>
<version>0.3</version> <version>0.4</version>
<date>Jan 28, 2023</date> <date>Jan 31, 2023</date>
<dependencies>drawText</dependencies> <dependencies>drawText</dependencies>
<description lang="en-US"> <description lang="en-US">
Ⓑ is the cursor to select the pattern, Ⓑ is the cursor to select the pattern,
@ -3426,28 +3426,31 @@
%object[]{data="/img/PatternSelector/PV1-3.svg"} %object[]{data="/img/PatternSelector/PV1-3.svg"}
</description> </description>
<source version="GMSJ01"> <source version="GMSJ01">
0424F32C 495A9CD5 C224F32C 00000013
042069DC 495F26B8 801F0000 3D80817F
077F9000 00000192 61880440 618A0024
801F0000 3D00817F 6C0C803D 280CA9C0
61089147 3D40817F 41820054 6C0C803D
614A0024 3D80803D 280C87C0 40820034
618CA9C0 7C006040 819F0004 898C0013
41820048 3D80803D 508C442E 39280031
618C87C0 7C006040 88080007 7CEA00AE
40820034 819F0004 A0080005 7C006040
898C0013 508C442E 41820034 39080007
39280031 88080007 7C084840 4180FFE4
7CEA00AE A0080005 3D808026 618C0224
7C006040 41820024 7D8803A6 4E800021
39080007 7C084840 4800002C 2C05FFFF
4180FFE4 4AA671C0 4082FFE8 88EA0000
2C05FFFF 4082FFF8 39080031 7CE73B79
88EA0000 39080031 4182FFD8 7C0838AE
7CE73B79 4182FFE8 280000FF 4182FFCC
7C0838AE 280000FF 7C030378 00000000
4182FFDC 7C030378 C22069DC 00000019
4E800020 3C808040 3C60817F 60630410
38830010 3D808020
618C1EA8 7D8803A6
4E800021 3C808040
A4040D82 3C60817F A4040D82 3C60817F
85630024 70000040 85630024 70000040
41A20050 88840019 41A20050 88840019
@ -3465,45 +3468,37 @@
5C00603E 5405063E 5C00603E 5405063E
5407C63E 5409863E 5407C63E 5409863E
88C30000 89030001 88C30000 89030001
89430002 3C60817F 89430002 3D80817F
60639138 38830045 61830424 61840434
4BFF7109 4AA0D8AC 618C0238 7D8803A6
00100140 00000014 4E800021 00000000
FFFFFFFF FFFFFFFF
452020FF 213200FF
621CFF1D 32005025
25252630 01FF4520
20213001 FFFF621C
1D300151 0707FF08
3102FF36 01FF0231
021E6E20 FF506174
7465726E 20256325
58256325 58256325
58000000 00000000
</source> </source>
<source version="GMSJ0A"> <source version="GMSJ0A">
04027900 497D1701 C2027900 00000013
04125548 496D3B4C 801F0000 3D80817F
077F9000 00000192 61880440 618A0024
801F0000 3D00817F 6C0C803A 280C6D70
61089147 3D40817F 41820054 6C0C803A
614A0024 3D80803A 280C4B80 40820034
618C6D70 7C006040 819F0004 898C0013
41820048 3D80803A 508C442E 39280031
618C4B80 7C006040 88080007 7CEA00AE
40820034 819F0004 A0080005 7C006040
898C0013 508C442E 41820034 39080007
39280031 88080007 7C084840 4180FFE4
7CEA00AE A0080005 3D808003 618C8684
7C006040 41820024 7D8803A6 4E800021
39080007 7C084840 4800002C 2C05FFFF
4180FFE4 4A83F620 4082FFE8 88EA0000
2C05FFFF 4082FFF8 39080031 7CE73B79
88EA0000 39080031 4182FFD8 7C0838AE
7CE73B79 4182FFE8 280000FF 4182FFCC
7C0838AE 280000FF 7C030378 00000000
4182FFDC 7C030378 C2125548 00000019
4E800020 3C80803F 3C60817F 60630410
38830010 3D808012
618C1660 7D8803A6
4E800021 3C80803F
A404545A 3C60817F A404545A 3C60817F
85630024 70000040 85630024 70000040
41A20050 88840019 41A20050 88840019
@ -3521,45 +3516,37 @@
5C00603E 5405063E 5C00603E 5405063E
5407C63E 5409863E 5407C63E 5409863E
88C30000 89030001 88C30000 89030001
89430002 3C60817F 89430002 3D80817F
60639138 38830045 61830424 61840434
4BFF7109 4A92C418 618C0238 7D8803A6
00100140 00000014 4E800021 00000000
FFFFFFFF FFFFFFFF
452020FF 213200FF
621CFF1D 32005025
25252630 01FF4520
20213001 FFFF621C
1D300151 0707FF08
3102FF36 01FF0231
021E6E20 FF506174
7465726E 20256325
58256325 58256325
58000000 00000000
</source> </source>
<source version="GMSP01"> <source version="GMSP01">
0403B54C 497BDAB5 C203B54C 00000013
04138DF8 496C029C 801F0000 3D80817F
077F9000 00000192 61880440 618A0024
801F0000 3D00817F 6C0C803A 280CDF98
61089147 3D40817F 41820054 6C0C803A
614A0024 3D80803A 280CBDA8 40820034
618CDF98 7C006040 819F0004 898C0013
41820048 3D80803A 508C442E 39280031
618CBDA8 7C006040 88080007 7CEA00AE
40820034 819F0004 A0080005 7C006040
898C0013 508C442E 41820034 39080007
39280031 88080007 7C084840 4180FFE4
7CEA00AE A0080005 3D808004 618CC228
7C006040 41820024 7D8803A6 4E800021
39080007 7C084840 4800002C 2C05FFFF
4180FFE4 4A8531C4 4082FFE8 88EA0000
2C05FFFF 4082FFF8 39080031 7CE73B79
88EA0000 39080031 4182FFD8 7C0838AE
7CE73B79 4182FFE8 280000FF 4182FFCC
7C0838AE 280000FF 7C030378 00000000
4182FFDC 7C030378 C2138DF8 00000019
4E800020 3C808040 3C60817F 60630410
38830010 3D808013
618C4F0C 7D8803A6
4E800021 3C808040
A404BC26 3C60817F A404BC26 3C60817F
85630024 70000040 85630024 70000040
41A20050 88840019 41A20050 88840019
@ -3577,45 +3564,37 @@
5C00603E 5405063E 5C00603E 5405063E
5407C63E 5409863E 5407C63E 5409863E
88C30000 89030001 88C30000 89030001
89430002 3C60817F 89430002 3D80817F
60639138 38830045 61830424 61840434
4BFF7109 4A93FCC8 618C0238 7D8803A6
00100140 00000014 4E800021 00000000
FFFFFFFF FFFFFFFF
452020FF 213200FF
621CFF1D 32005025
25252630 01FF4520
20213001 FFFF621C
1D300151 0707FF08
3102FF36 01FF0231
021E6E20 FF506174
7465726E 20256325
58256325 58256325
58000000 00000000
</source> </source>
<source version="GMSE01"> <source version="GMSE01">
0403B6FC 497BD905 C203B6FC 00000013
041441BC 496B4ED8 801F0000 3D80817F
077F9000 00000192 61880440 618A0024
801F0000 3D00817F 6C0C803B 280C6178
61089147 3D40817F 41820054 6C0C803B
614A0024 3D80803B 280C3F88 40820034
618C6178 7C006040 819F0004 898C0013
41820048 3D80803B 508C442E 39280031
618C3F88 7C006040 88080007 7CEA00AE
40820034 819F0004 A0080005 7C006040
898C0013 508C442E 41820034 39080007
39280031 88080007 7C084840 4180FFE4
7CEA00AE A0080005 3D808004 618CD0D4
7C006040 41820024 7D8803A6 4E800021
39080007 7C084840 4800002C 2C05FFFF
4180FFE4 4A854070 4082FFE8 88EA0000
2C05FFFF 4082FFF8 39080031 7CE73B79
88EA0000 39080031 4182FFD8 7C0838AE
7CE73B79 4182FFE8 280000FF 4182FFCC
7C0838AE 280000FF 7C030378 00000000
4182FFDC 7C030378 C21441BC 00000019
4E800020 3C808040 3C60817F 60630410
38830010 3D808014
618C0390 7D8803A6
4E800021 3C808040
A4044486 3C60817F A4044486 3C60817F
85630024 70000040 85630024 70000040
41A20050 88840019 41A20050 88840019
@ -3633,21 +3612,10 @@
5C00603E 5405063E 5C00603E 5405063E
5407C63E 5409863E 5407C63E 5409863E
88C30000 89030001 88C30000 89030001
89430002 3C60817F 89430002 3D80817F
60639138 38830045 61830424 61840434
4BFF7109 4A94B08C 618C0238 7D8803A6
00100140 00000014 4E800021 00000000
FFFFFFFF FFFFFFFF
452020FF 213200FF
621CFF1D 32005025
25252630 01FF4520
20213001 FFFF621C
1D300151 0707FF08
3102FF36 01FF0231
021E6E20 FF506174
7465726E 20256325
58256325 58256325
58000000 00000000
</source> </source>
</code> </code>
<code> <code>

View file

@ -67,7 +67,12 @@ Some codes store some states in the games memory starting from address 0x817F000
| ![](./docs/reserved.svg) | `0x110` | `0x237` | QF Timer: Timer Textbox | | ![](./docs/reserved.svg) | `0x110` | `0x237` | QF Timer: Timer Textbox |
| ![](./docs/reserved.svg) | `0x238` | `0x347` | General Function (`drawText`) | | ![](./docs/reserved.svg) | `0x238` | `0x347` | General Function (`drawText`) |
| ![](./docs/buffer.svg) | `0x348` | `0x39B` | Buffer (QF Timer) | | ![](./docs/buffer.svg) | `0x348` | `0x39B` | Buffer (QF Timer) |
| ![](./docs/unallocated.svg) | `0x39C` | `0xFFF` | Not Allocated | | ![](./docs/unallocated.svg) | `0x39C` | `0x40F` | Not Allocated |
| ![](./docs/reserved.svg) | `0x410` | `0x41F` | Pattern Selector: Background Options |
| ![](./docs/reserved.svg) | `0x424` | `0x433` | Pattern Selector: Text Options |
| ![](./docs/reserved.svg) | `0x434` | `0x440` | Pattern Selector: Format String |
| ![](./docs/reserved.svg) | `0x441` | `0x475` | Pattern Selector: Pattern Data |
| ![](./docs/unallocated.svg) | `0x476` | `0xFFF` | Not Allocated |
### Adding translations ### Adding translations

View file

@ -1,5 +1,8 @@
# Changelog # Changelog
## Jan 31, 2023 ## Jan 31, 2023
### Updated 'Pattern Selector'
- Rewrote with C2 + separated config 06
- Remove label option
### Updated 'Customized Display' ### Updated 'Customized Display'
- Rewrote with C2 - Rewrote with C2
- Implemented a more complex assembler/compiler to support function call - Implemented a more complex assembler/compiler to support function call

View file

@ -1,5 +1,5 @@
import { parseJSON } from '../codegen.js'; import { parseJSON } from '../codegen.js';
import { ASM, liDX, str2hex, inst2gecko, getFillRectParams } from '../asm.js'; import { ASM, liDX, str2hex, insts2hex, getFillRectParams, getDrawTextOpt } from '../asm.js';
import { measureText } from '../text.js'; import { measureText } from '../text.js';
import { int2hex } from '../utils.js'; import { int2hex } from '../utils.js';
import { addrs } from '../addrs.js'; import { addrs } from '../addrs.js';
@ -12,20 +12,19 @@ import * as GMSP01 from './code/GMSP01.js';
const codes = { GMSJ01, GMSJ0A, GMSP01 }; const codes = { GMSJ01, GMSJ0A, GMSP01 };
export const defaultConfig = { export const defaultConfig = {
x: 16, x: 498,
y: 320, y: 462,
fontSize: 20, fontSize: 14,
fgRGB: 0xffffff, fgRGB: 0xffffff,
fgA: 0xff, fgA: 0xff,
fgRGB2: null, fgRGB2: null,
fgA2: null, fgA2: null,
bgRGB: 0, bgRGB: 0,
bgA: 0, bgA: 128,
bgLeft: 0, bgLeft: 2,
bgRight: 0, bgRight: 4,
bgTop: 0, bgTop: 2,
bgBot: 0, bgBot: 2,
label: 'Pattern ',
}; };
/** @returns {typeof defaultConfig} */ /** @returns {typeof defaultConfig} */
@ -33,77 +32,34 @@ export function getConfig() {
const config = const config =
(typeof localStorage !== 'undefined' && parseJSON(localStorage.getItem(lskey))) || {}; (typeof localStorage !== 'undefined' && parseJSON(localStorage.getItem(lskey))) || {};
const o = { ...defaultConfig, ...config }; const o = { ...defaultConfig, ...config };
return { ...o, text: getPreviewText(o) }; return { ...o, text: getPreviewText() };
} }
/** @param {typeof defaultConfig} config */ export const getPreviewText = () => '#0 0 0';
export const getPreviewText = ({ label }) => label + '#0 0 0';
const codePattern = ` /**
452020FF 213200FF * @param {keyof typeof codes} version
621CFF1D 32005025 * @param {string} baseCode
25252630 01FF4520 */
20213001 FFFF621C export default function codegen(version, baseCode) {
1D300151 0707FF08 const config = getConfig();
3102FF36 01FF0231 let code = baseCode;
021E6E20 FF code += '077F0410 00000066';
// fillRectOpt
code += insts2hex(getFillRectParams(config, measureText(getPreviewText(), version)));
// drawTextOpt
code += insts2hex(getDrawTextOpt(config));
// fmt
code += '25632558256325582563255800';
// pattern data
code += `452020 FF213200
FF621CFF 1D320050
25252526 3001FF45
20202130 01FFFF62
1C1D3001 510707FF
083102FF 3601FF02
31021E6E 20FF0000
`; `;
/** @param {keyof typeof codes} version */ return code.replace(/\s/g, '');
export default function codegen(version) {
const config = getConfig();
const { x, y, fontSize, fgRGB, fgA, fgRGB2, fgA2, bgA, label } = config;
const colorTop = (fgRGB << 8) | fgA;
const colorBot = fgRGB2 == null || fgA2 == null ? colorTop : (fgRGB2 << 8) | fgA;
const text = label + '%c%X%c%X%c%X';
const { code04, codeBase } = codes[version];
const code07 = [
codeBase,
// drawTextOpt
int2hex(x, 2),
int2hex(y, 2),
int2hex(fontSize, 4),
int2hex(colorTop, 4),
int2hex(colorBot, 4),
// pattern.s
codePattern,
// fmt
str2hex(text, version),
]
.map((s) => s.replace(/\s+/g, ''))
.join('');
const head07 = [
'077F9000',
// byte count = hex length >> 1
int2hex(code07.length >> 1, 4),
].join('');
// align code 07 (1 line = 16 hex digits)
const tail07 = ''.padEnd(code07.length % 16 ? 16 - (code07.length % 16) : 0, '0');
// background
const addrFillRect = addrs.fillRect[version];
const codeBg = bgA
? [
0xc2000000 + ((addrs.drawWater[version] - 0x28) & 0x01ffffff),
0x00000007,
0x48000019, // bl trick
// rect, color
...getFillRectParams(config, measureText(label + '#0 0 0', version)),
0x7c6802a6, // mtlr r3
0x38830010, // addi r4, r3, 0x10
0x3d800000 | (addrFillRect >>> 16), // lis r12, fill_rect@h
0x618c0000 | (addrFillRect & 0xffff), // ori r12, r12, fill_rect@l
0x7d8803a6, // mtlr r12
0x4e800021, // blrl
0x60000000, // nop
0x00000000, // End of C2
]
.map(inst2gecko)
.join('')
: '';
return (code04 + head07 + code07 + tail07 + codeBg).replace(/\s+/g, '');
} }

View file

@ -4,9 +4,6 @@
<Preview :config="previewConfig" /> <Preview :config="previewConfig" />
<div class="config-spacer" /> <div class="config-spacer" />
<TextConfig v-model="textConfig" /> <TextConfig v-model="textConfig" />
<div>
{{l.label}} <input v-model="label">
</div>
</section> </section>
</template> </template>
@ -46,9 +43,6 @@ export default {
}, },
}, },
}, },
watch: {
label: updateConfig,
},
}; };
</script> </script>