Project

General

Profile

Revision 269

small chat working with DR.mk

View differences:

proj.c
31 31
#include "list.h"
32 32

  
33 33
#ifdef DIOGO
34
    #include "test7.h"
34
    #include "uart.h"
35
    #include "hltp.h"
35 36
#endif
36 37

  
37 38
int main(int argc, char* argv[]) {
......
59 60
    /// subscribe interrupts
60 61
    if (subscribe_all()) { return 1; }
61 62

  
62
    /// initialize graphics
63
    if(graph_init(GRAPH_MODE)){
64
        printf("%s: failed to initalize graphics.\n", __func__);
65
        if (cleanup()) printf("%s: failed to cleanup.\n", __func__);
66
        return 1;
67
    }
63
    #ifndef DIOGO
64
        /// initialize graphics
65
        if(graph_init(GRAPH_MODE)){
66
            printf("%s: failed to initalize graphics.\n", __func__);
67
            if (cleanup()) printf("%s: failed to cleanup.\n", __func__);
68
            return 1;
69
        }
70
    #endif
68 71

  
69 72
    /// Load stuff
70 73
    basic_sprite_t       *bsp_crosshair = NULL;
......
75 78
    map_t                *map1          = NULL;
76 79
    sprite_t             *sp_crosshair  = NULL;
77 80
    {
78
        graph_clear_screen();
79
        text_t *txt = text_ctor(consolas, "Loading...");
80
        text_draw(txt);
81
        text_dtor(txt);
82
        graph_draw();
81
        #ifndef DIOGO
82
            graph_clear_screen();
83
            text_t *txt = text_ctor(consolas, "Loading...");
84
            text_draw(txt);
85
            text_dtor(txt);
86
            graph_draw();
87
        #endif
83 88

  
84 89
        bsp_crosshair = get_crosshair(); if(bsp_crosshair == NULL) printf("Failed to get crosshair\n");
85 90
        bsp_shooter   = get_shooter  (); if(bsp_shooter   == NULL) printf("Failed to get shooter\n");
......
136 141
    #ifndef DIOGO
137 142
        int click = 0;
138 143
    #endif
144
    #ifdef DIOGO
145
        char *s = NULL;
146
    #endif
139 147

  
140 148
    while (game_state != EXIT) {
141 149
        /* Get a request message. */
......
198 206
                                case MENU:
199 207
                                    if ((scancode[0]) == ESC_BREAK_CODE) game_state = EXIT;
200 208

  
201
                                    else if ((scancode[0]) == A_MAKE_CODE) buffer[buffer_pos++] = 'A';
202

  
209
                                    else if ((scancode[0]) == A_MAKE_CODE){
210
                                        buffer[buffer_pos++] = 'A';
211
                                        printf("%c", buffer[buffer_pos-1]);
212
                                    }
203 213
                                    else if ((scancode[0]) == ENTER_MAKE_CODE) {
204
                                        // func1
205

  
214
                                        buffer[buffer_pos] = '\0';
215
                                        printf("\nSending string -%s-\n", buffer);
216
                                        printf("Send string output: %d\n",
217
                                            hltp_send_string(COM1_ADDR, buffer));
206 218
                                        buffer_pos = 0;
207 219
                                    }
208 220

  
......
249 261
                            #endif
250 262
                            #ifdef DIOGO
251 263
                            case COM1_IRQ:
252
                                char *s = NULL;
253
                                hltp_get_string(1, s);
254
                                printf("You've got mail: %s\n", s);
255
                                break;
264
                                {
265
                                    printf("You've got mail");
266
                                    int r = hltp_get_string(COM1_ADDR, &s);
267
                                    printf(" (return code %d)", r);
268
                                    printf(": -%s-\n", s);
269
                                }break;
256 270
                            #endif
257 271
                            }
258 272
                        }
......
267 281
        }
268 282
    }
269 283

  
284
    #ifdef DIOGO
285
        free(s);
286
    #endif
287

  
270 288
    while(list_size(shooter_list) > 0){
271 289
        gunner_t *p = list_erase(shooter_list, list_begin(shooter_list));
272 290
        gunner_dtor(p);

Also available in: Unified diff