; 共通 ; 1. メモリエディタでコードをdb64以下に配置。 ; 2. ボックスニックネーム版5かいエントリポイントを準備。 ; 3. 5かいを使用。 ; 4. 図鑑領域にカウント結果が書きだされる ; 1stゴミ箱ルーチンの真似 ; 実行すると1024回乱数を取得し、結果をd280-d28eに書きだす ; ゴミ箱0が選ばれた回数がd280、2が選ばれた回数がd282 ... 21 80 d2; ld hl, d280 af; xor a 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22; ldi (hl), a 01 00 00; ld bc, 0000 26 d2; ld h, d2 cd 8c 3e; call 3e8c e6 0e; and a, 0e c6 80; add 80 6f; ld l, a 34; inc (hl) 03; inc bc 3e 04; ld a,04 b8; cp b 20 f1; jr nz -15byte c9; ret ; コピペ用 21 80 d2 af 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 01 00 00 26 d2 cd 8c 3e e6 0e c6 80 6f 34 03 3e 04 b8 20 f1 c9 ; 2ndゴミ箱ルーチンの真似 ; 実行すると256回乱数を取得し、結果をd280-d284に書きだす ; 出力は ; d280: テーブルから溢れた値を読んだ回数 d281: テーブルの1番目を読んだ回数 .. d284: テーブルの4番目を読んだ回数 ; 隣接2のときはテーブル外か2番目しか読まない ; 隣接3のときはテーブル外、1番目、2番目、3番目を読む ; 隣接4のときはテーブル外か4番目しか読まない 21 80 d2; ld hl, d280 af; xor a 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22; ldi (hl), a 1e 00; ld e, 00 01 00 00; ld bc, 0000 26 d2; ld h, d2 cd 8c 3e; call 3e8c cb 37; cb 37 swap a e6 02; and a, 02 <- 隣接2個の場合用のコード。3個の場合はここをe6 03に、4個の場合はe6 04にする c6 80; add 80 6f; ld l, a 34; inc (hl) 03; inc bc 3e 01; ld a,01 b8; cp b 20 ef; jr nz -17 c9; ret ; コピペ用 隣接2 21 80 d2 af 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 1e 00 01 00 00 26 d2 cd 8c 3e cb 37 e6 02 c6 80 6f 34 03 3e 01 b8 20 ef c9 ; 隣接3 21 80 d2 af 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 1e 00 01 00 00 26 d2 cd 8c 3e cb 37 e6 03 c6 80 6f 34 03 3e 01 b8 20 ef c9 ; 隣接4 21 80 d2 af 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 22 1e 00 01 00 00 26 d2 cd 8c 3e cb 37 e6 04 c6 80 6f 34 03 3e 01 b8 20 ef c9 ; 1st - 2ndテーブル対応表 ; 0: 隣接2、1(rand and 02 == 00) or 3(rand and 02 == 02) ; 2: 隣接2、3(rand and 02 == 00) or 5(rand and 02 == 02) ; 4: 隣接4、e(rand and 04 == 00) or 7(rand and 04 == 04) ; 6: 隣接3、e(rand and 03 == 00) or 3(rand and 03 == 01) or 7(rand and 03 == 02) or 9(rand and 03 == 03) ; 8: 隣接3、f(rand and 03 == 00) or 5(rand and 03 == 01) or 7(rand and 03 == 02) or b(rand and 03 == 03) ; a: 隣接4、6(rand and 04 == 00) or d(rand and 04 == 04) ; c: 隣接2、7(rand and 02 == 00) or d(rand and 02 == 02) ; e: 隣接2、3(rand and 02 == 00) or d(rand and 02 == 02)