diff --git a/Codes.xml b/Codes.xml index 1009226..3a48e50 100644 --- a/Codes.xml +++ b/Codes.xml @@ -3344,8 +3344,8 @@
diff --git a/Readme.md b/Readme.md
index fa9e1d9..5355390 100644
--- a/Readme.md
+++ b/Readme.md
@@ -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) | `0x238` | `0x347` | General Function (`drawText`) |
| ![](./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
diff --git a/changelog.md b/changelog.md
index 44009a4..c535885 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,8 @@
# Changelog
## Jan 31, 2023
+### Updated 'Pattern Selector'
+- Rewrote with C2 + separated config 06
+- Remove label option
### Updated 'Customized Display'
- Rewrote with C2
- Implemented a more complex assembler/compiler to support function call
diff --git a/site/.vuepress/components/codes/PatternSelector/codegen.js b/site/.vuepress/components/codes/PatternSelector/codegen.js
index 9770105..7190ef9 100644
--- a/site/.vuepress/components/codes/PatternSelector/codegen.js
+++ b/site/.vuepress/components/codes/PatternSelector/codegen.js
@@ -1,5 +1,5 @@
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 { int2hex } from '../utils.js';
import { addrs } from '../addrs.js';
@@ -12,20 +12,19 @@ import * as GMSP01 from './code/GMSP01.js';
const codes = { GMSJ01, GMSJ0A, GMSP01 };
export const defaultConfig = {
- x: 16,
- y: 320,
- fontSize: 20,
+ x: 498,
+ y: 462,
+ fontSize: 14,
fgRGB: 0xffffff,
fgA: 0xff,
fgRGB2: null,
fgA2: null,
bgRGB: 0,
- bgA: 0,
- bgLeft: 0,
- bgRight: 0,
- bgTop: 0,
- bgBot: 0,
- label: 'Pattern ',
+ bgA: 128,
+ bgLeft: 2,
+ bgRight: 4,
+ bgTop: 2,
+ bgBot: 2,
};
/** @returns {typeof defaultConfig} */
@@ -33,77 +32,34 @@ export function getConfig() {
const config =
(typeof localStorage !== 'undefined' && parseJSON(localStorage.getItem(lskey))) || {};
const o = { ...defaultConfig, ...config };
- return { ...o, text: getPreviewText(o) };
+ return { ...o, text: getPreviewText() };
}
-/** @param {typeof defaultConfig} config */
-export const getPreviewText = ({ label }) => label + '#0 0 0';
+export const getPreviewText = () => '#0 0 0';
-const codePattern = `
-452020FF 213200FF
-621CFF1D 32005025
-25252630 01FF4520
-20213001 FFFF621C
-1D300151 0707FF08
-3102FF36 01FF0231
-021E6E20 FF
+/**
+ * @param {keyof typeof codes} version
+ * @param {string} baseCode
+ */
+export default function codegen(version, baseCode) {
+ const config = getConfig();
+ let code = baseCode;
+ 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 */
-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, '');
+ return code.replace(/\s/g, '');
}
diff --git a/site/.vuepress/components/codes/PatternSelector/config.vue b/site/.vuepress/components/codes/PatternSelector/config.vue
index b1c174a..fa8f43f 100644
--- a/site/.vuepress/components/codes/PatternSelector/config.vue
+++ b/site/.vuepress/components/codes/PatternSelector/config.vue
@@ -4,9 +4,6 @@
-
- {{l.label}}
-
@@ -46,9 +43,6 @@ export default {
},
},
},
- watch: {
- label: updateConfig,
- },
};