1 /* 2 Status 3 */ 4 5 #include "status.h" 6 7 #include "console.h" 8 #include "head.h" 9 #include "infocom.h" 10 #include "object.h" 11 #include "os.h" 12 #include "print.h" 13 #include "shared.h" 14 #include "var.h" 15 #include "wio.h" 16 17 static byte *s_buff_ptr; 18 put_status(word ch)19static void put_status(word ch) 20 { 21 *s_buff_ptr++ = (char) ch; 22 } 23 put_space(void)24static void put_space(void) 25 { 26 put_status(' '); 27 } 28 put_digit(word d)29static void put_digit(word d) 30 { 31 put_status(d + '0'); 32 } 33 copy_string(char * src)34static void copy_string(char *src) 35 { 36 #if 0 37 int len = os_strlen(src); 38 os_mcpy(s_buff_ptr, src, len); 39 s_buff_ptr += len; 40 #else 41 while(*src) 42 { 43 put_status(*src); 44 ++src; 45 } 46 #endif 47 } 48 pad_string(byte * upto)49static void pad_string(byte *upto) 50 { 51 while(s_buff_ptr < upto) 52 put_space(); 53 } 54 print_status(byte * s_buffer)55static void print_status(byte *s_buffer) 56 { 57 int w = hd_width(); 58 start_update(); 59 save_attributes(1); 60 goto_xy(0, 0); 61 out_char(make_font_request(FONT_FIXED_REVS)); 62 while(--w >= 0) 63 out_char(*s_buffer++); 64 erase_to_eoln(); 65 restore_attributes(1); 66 finish_update(); 67 } 68 status(void)69void status(void) 70 { 71 extern bool disable_script; 72 extern void (*PrintChar) (word); 73 74 bool old_disable_script = disable_script; 75 void (*old_procptr) (word) = PrintChar; 76 77 word locn = load_var(0x10); 78 word arg1 = load_var(0x11); 79 word arg2 = load_var(0x12); 80 81 byte s_buffer[MAX_MAX_FIXED]; 82 83 s_buff_ptr = s_buffer; 84 put_space(); 85 disable_script = 1; 86 PrintChar = put_status; 87 88 obj_print(locn); 89 90 if(hd_mode() & USE_TIME) 91 { 92 word hour = arg1; 93 word minutes = arg2; 94 95 pad_string(&s_buffer[hd_width() - 0x10]); 96 copy_string("Time: "); 97 print_num(hour == 0 ? 12 : hour <= 12 ? hour : hour - 12); 98 put_status(':'); 99 put_digit(minutes/10); 100 put_digit(minutes%10); 101 copy_string(hour >= 12 ? " PM" : " AM"); 102 } 103 else 104 { 105 pad_string(&s_buffer[hd_width() - 0x14]); 106 copy_string("Score: "); 107 print_num(arg1); 108 put_status('/'); 109 print_num(arg2); 110 } 111 pad_string(&s_buffer[MAX_MAX_FIXED]); 112 print_status(s_buffer); 113 disable_script = old_disable_script; 114 PrintChar = old_procptr; 115 } 116 117