File size: 2,269 Bytes
00e6582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "em_view.h"


struct _Emulator_Viewer_State* Create_Emulator_Viewer_State()
{
    struct _Emulator_Viewer_State* I = (struct _Emulator_Viewer_State*) calloc(1,sizeof (struct _Emulator_Viewer_State));
    return I;
};

void Destroy_Emulator_Viewer_State(struct _Engine* Engine)
{

};

void Initialize_Emulator_Viewer_State(struct _Engine* Engine)
{
    Engine->Emulator_Viewer_State->Seat = (struct _Seat_Object*)calloc(1,sizeof(struct _Seat_Object));
    Engine->Emulator_Viewer_State->Seat->New_Computer = Create_New_Computer();
    Initialize_New_Computer(Engine, Engine->Emulator_Viewer_State->Seat);
    //Load_Program(Engine->Emulator_Viewer_State->Seat, "test.rom");
    Turn_Computer_On(Engine, Engine->Emulator_Viewer_State->Seat);
};


void Render_Emulator_Viewer_State(struct _Engine* Engine)
{
    float _x,_y;
    _x = 0;
    _y = 0;
    Engine->Emulator_Viewer_State->Seat->New_Computer->Width = 256;
    Engine->Emulator_Viewer_State->Seat->New_Computer->Height = 256;


    Render_New_Computer(Engine, Engine->Emulator_Viewer_State->Seat);

    glBindTexture(GL_TEXTURE_2D, Engine->Emulator_Viewer_State->Seat->New_Computer->Texture_ID);

    float Vertices[] = {_x, _y, _x + Engine->Emulator_Viewer_State->Seat->New_Computer->Width, _y, _x + Engine->Emulator_Viewer_State->Seat->New_Computer->Width, _y + Engine->Emulator_Viewer_State->Seat->New_Computer->Height, _x, _y + Engine->Emulator_Viewer_State->Seat->New_Computer->Height};
    float Texture_Vertices[] = {0, 0, 1, 0, 1, -1, 0, -1};
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY_EXT);
    glVertexPointer(2, GL_FLOAT, 0, Vertices);
    glTexCoordPointer(2, GL_FLOAT, 0, Texture_Vertices);
    glDrawArrays(GL_QUADS, 0, 4);
    glDisableClientState(GL_VERTEX_ARRAY);
};

void Input_Emulator_Viewer_State(struct _Engine* Engine, struct _Keypad Keypad)
{
    Handle_New_Computer_Inputs(Engine, Engine->Emulator_Viewer_State->Seat, Keypad);

    if(Keypad.Keyboard_A)
    {
        Turn_Computer_On(Engine, Engine->Emulator_Viewer_State->Seat);
    }
};

void Process_Emulator_Viewer_State(struct _Engine* Engine, struct _Audio_Chip* Audio_Chip)
{

    Process_New_Computer_Cycles(Engine, Engine->Emulator_Viewer_State->Seat, 50, Audio_Chip);
};