File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11
22exception BoxFittingError of string
33
4+ type rewrite_rules = (int list * int list ) list
5+ let parse_code s =
6+ let n = String. length s in
7+ if n mod 8 <> 0 then failwith " Invalid byte sequence length" ;
8+ List. init (n / 2 ) (fun i -> int_of_string (" 0x" ^ String. sub s (i * 2 ) 2 ))
9+ let parse_rewrite_rule s =
10+ match String. split_on_char ':' s with
11+ | [pre; post] -> (parse_code pre, parse_code post)
12+ | _ -> failwith " Invalid rule format"
13+ let parse_rewrite_rules str =
14+ List. map parse_rewrite_rule (String. split_on_char ';' str)
15+
416type fillers =
5- { nop_code :int list ; nop_code_alt :int list ; fillers :int list array ; rewriting :( int list * int list ) list }
17+ { nop_code :int list ; nop_code_alt :int list ; fillers :int list array ; rewriting :rewrite_rules }
618let default_fillers () = {
719 nop_code =
820 if ! Settings. game = Ruby || ! Settings. game = Sapphire then
@@ -41,7 +53,10 @@ let default_fillers () = {
4153 [0x00 ; 0x00 ; 0x00 ; 0xFF ](* FF000000 *) ;
4254 |]
4355 ;
44- rewriting = []
56+ rewriting = [
57+ parse_rewrite_rule " FFBBBBBB00000000FFFFBBBB:FFBBFFFFFFFFFFFFFFFFBBBB" ;
58+ parse_rewrite_rule " FFFFBBBB00000000FFFFFFBB:FFFFBBFFFFFFFFFFFFFFFFBB"
59+ ]
4560 }
4661
4762let padding = [0x00 ; 0x00 ; 0x00 ; 0x00 ]
Original file line number Diff line number Diff line change 11
22exception BoxFittingError of string
33
4+ type rewrite_rules = (int list * int list ) list
5+ val parse_rewrite_rules : string -> rewrite_rules
46type fillers =
5- { nop_code :int list ; nop_code_alt :int list ; fillers :int list array ; rewriting :( int list * int list ) list }
7+ { nop_code :int list ; nop_code_alt :int list ; fillers :int list array ; rewriting :rewrite_rules }
68val default_fillers : unit -> fillers
79
810val fit_codes_into_boxes :
Original file line number Diff line number Diff line change @@ -33,19 +33,6 @@ let compare_and_print_commands fmt data descr exit =
3333 in
3434 aux data descr false 0
3535
36- let parse_rewrite str =
37- let parse_code s =
38- let n = String. length s in
39- if n mod 8 <> 0 then failwith " Invalid byte sequence length" ;
40- List. init (n / 2 ) (fun i -> int_of_string (" 0x" ^ String. sub s (i * 2 ) 2 ))
41- in
42- let parse_rule s =
43- match String. split_on_char ':' s with
44- | [pre; post] -> (parse_code pre, parse_code post)
45- | _ -> failwith " Invalid rule format"
46- in
47- List. map parse_rule (String. split_on_char ';' str)
48-
4936let main fmt env (headers ,headers2 ) parsed exit =
5037 let onlyraw =
5138 match Preprocess. get_param headers " onlyraw" with
@@ -89,7 +76,7 @@ let main fmt env (headers,headers2) parsed exit =
8976 let rewriting =
9077 match Preprocess. get_param headers " rewrite" with
9178 | HNone -> default_fillers.rewriting
92- | HString str -> parse_rewrite str
79+ | HString str -> Boxes. parse_rewrite_rules str
9380 | _ -> failwith " Invalid headers."
9481 in
9582 let fill_last =
You can’t perform that action at this time.
0 commit comments