@@ -72,6 +72,7 @@ fn translate(string: usize) -> (String, usize) {
7272}
7373
7474#[ cfg_attr( target_os = "linux" , hook( by_symbol) ) ]
75+ #[ cfg_attr( target_os = "windows" , hook( by_offset) ) ]
7576fn addst ( gps : usize , string : usize , just : u8 , space : i32 ) {
7677 let ( x, y) = gps_get_screen_coord ( gps) ;
7778 let ( content, width) = translate ( string) ;
@@ -81,6 +82,7 @@ fn addst(gps: usize, string: usize, just: u8, space: i32) {
8182}
8283
8384#[ cfg_attr( target_os = "linux" , hook( by_symbol) ) ]
85+ #[ cfg_attr( target_os = "windows" , hook( by_offset) ) ]
8486fn addst_top ( gps : usize , string : usize , just : u8 , space : i32 ) {
8587 let ( x, y) = gps_get_screen_coord ( gps) ;
8688 let ( content, width) = translate ( string) ;
@@ -90,6 +92,7 @@ fn addst_top(gps: usize, string: usize, just: u8, space: i32) {
9092}
9193
9294#[ cfg_attr( target_os = "linux" , hook( by_symbol) ) ]
95+ #[ cfg_attr( target_os = "windows" , hook( by_offset) ) ]
9396fn addst_flag ( gps : usize , string : usize , just : u8 , space : i32 , sflag : u32 ) {
9497 let ( x, y) = gps_get_screen_coord ( gps) ;
9598 let ( content, width) = translate ( string) ;
@@ -99,20 +102,32 @@ fn addst_flag(gps: usize, string: usize, just: u8, space: i32, sflag: u32) {
99102}
100103
101104#[ cfg_attr( target_os = "linux" , hook( by_symbol) ) ]
105+ #[ cfg_attr( target_os = "windows" , hook( by_offset) ) ]
102106fn erasescreen ( gps : usize ) {
103107 unsafe { original ! ( gps) } ;
104108 SCREEN . write ( ) . clear ( ) ;
105109 SCREEN_TOP . write ( ) . clear ( ) ;
106110}
107111
112+ #[ cfg( target_os = "linux" ) ]
108113#[ cfg_attr( target_os = "linux" , hook( by_symbol) ) ]
109114fn resize ( renderer : usize , w : u32 , h : u32 ) {
110115 unsafe { original ! ( renderer, w, h) } ;
111116 SCREEN . write ( ) . resize ( w, h) ;
112117 SCREEN_TOP . write ( ) . resize ( w, h) ;
113118}
114119
120+ // Windows function is optimized to inline function, so the signature is different
121+ #[ cfg( target_os = "windows" ) ]
122+ #[ cfg_attr( target_os = "windows" , hook( by_offset) ) ]
123+ fn resize ( renderer : usize , w : u32 , h : u32 , screen_x : u32 , screen_y : u32 , tile_dim_x : u32 , tile_dim_y : u32 ) {
124+ unsafe { original ! ( renderer, w, h, screen_x, screen_y, tile_dim_x, tile_dim_y) } ;
125+ SCREEN . write ( ) . resize ( w, h) ;
126+ SCREEN_TOP . write ( ) . resize ( w, h) ;
127+ }
128+
115129#[ cfg_attr( target_os = "linux" , hook( by_symbol) ) ]
130+ #[ cfg_attr( target_os = "windows" , hook( by_offset) ) ]
116131fn update_all ( renderer : usize ) {
117132 unsafe { original ! ( renderer) } ;
118133 SCREEN_TOP . write ( ) . render ( renderer) ;
@@ -123,10 +138,17 @@ struct Dimension {
123138 y : i32 ,
124139}
125140
141+ // TODO: move to config
142+ #[ cfg( target_os = "linux" ) ]
143+ const DIMENSION_OFFSET : usize = 0xa00 ;
144+ #[ cfg( target_os = "windows" ) ]
145+ const DIMENSION_OFFSET : usize = 0x6cc ;
146+
126147#[ cfg_attr( target_os = "linux" , hook( by_symbol) ) ]
148+ #[ cfg_attr( target_os = "windows" , hook( by_offset) ) ]
127149fn update_tile ( renderer : usize , x : i32 , y : i32 ) {
128150 unsafe { original ! ( renderer, x, y) } ;
129- let dim = raw:: deref :: < Dimension > ( GPS . to_owned ( ) + 0xa00 ) ;
151+ let dim = raw:: deref :: < Dimension > ( GPS . to_owned ( ) + DIMENSION_OFFSET ) ;
130152
131153 // hack to render text after the last update_tile in update_all
132154 // TODO: consider re-write update_all function completely according to g_src
0 commit comments