File size: 25,484 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
#ifndef COMPUTER_H_INCLUDED
#define COMPUTER_H_INCLUDED
#include "../engine.h"
#include "../graphics/image.h"

#define ATTRIBUTE_FILE 0
#define ATTRIBUTE_SUBDIRECTORY 1
#define ATTRIBUTE_EXECUTABLE 2
#define ATTRIBUTE_DELETED 3

#define FILE_RESOLUTION 256  //A file must occupy 256 bytes minimum.

#define STACK_START 65535
#define STACK_END 65280

#define OPC_HLT 0x01
#define OPC_NOP 0x00
#define OPC_CLS 0x02
#define OPC_FLS 0x03
#define OPC_INT 0x04

#define OPC_MOV_R0_R1 0x05
#define OPC_MOV_R1_R0 0x06

#define OPC_MOV_R0_INT_VALUE 0x07
#define OPC_MOV_R1_INT_VALUE 0x08

#define OPC_MOV_R0_VALUE_AT_ADDRESS 0x09
#define OPC_MOV_R1_VALUE_AT_ADDRESS 0x0A

#define OPC_PUSH_R0 0x0B
#define OPC_PUSH_R1 0x0C

#define OPC_POP_R0 0x0D
#define OPC_POP_R1 0x0E

#define OPC_PUSH_VALUE_AT_ADDRESS 0x0F

#define OPC_MOV_VALUE_AT_ADDRESS_R0 0x10
#define OPC_MOV_VALUE_AT_ADDRESS_R1 0x11

#define OPC_ADD_R0_R1 0x12
#define OPC_ADD_R1_R0 0x13

#define OPC_SUB_R0_R1 0x14
#define OPC_SUB_R1_R0 0x15

#define OPC_MUL_R0_R1 0x16
#define OPC_MUL_R1_R0 0x17

#define OPC_DIV_R0_R1 0x18
#define OPC_DIV_R1_R0 0x19

#define OPC_COLORMODE 0x1A
#define OPC_MONOCHROMEMODE 0x1B

#define OPC_JMP 0x1C
#define OPC_CALL 0x1D
#define OPC_RETURN 0x1E

#define OPC_CMP_R0_R1 0x1F

#define OPC_JNE 0x20
#define OPC_JE 0x21
#define OPC_JG 0x22
#define OPC_JL 0x23
#define OPC_JGE 0x24
#define OPC_JLE 0x25

#define OPC_CNE 0x26
#define OPC_CE 0x27
#define OPC_CG 0x28
#define OPC_CL 0x29
#define OPC_CGE 0x2A
#define OPC_CLE 0x2B

#define OPC_IN_DPAD_UP_R0 0x2C
#define OPC_IN_DPAD_DOWN_R0 0x2D
#define OPC_IN_DPAD_LEFT_R0 0x2E
#define OPC_IN_DPAD_RIGHT_R0 0x2F

#define OPC_IN_A_BUTTON_R0 0x30
#define OPC_IN_B_BUTTON_R0 0x31

#define OPC_IN_KBD_R0 0x32
#define OPC_IN_MOUSE_X_R0 0x33
#define OPC_IN_MOUSE_Y_R0 0x34
#define OPC_IN_MOUSE_CLICK_R0 0x35

#define OPC_JMP_STACK 0x36

#define OPC_AND 0x37
#define OPC_OR 0x38
#define OPC_XOR 0x39

#define INT_SHUTDOWN_COMPUTER 0x00
#define INT_RESTART_COMPUTER 0x01
#define INT_RENDER_PIXEL 0x02
#define INT_RENDER_LINE 0x03
#define INT_RENDER_IMAGE 0x04
#define INT_RENDER_TILEMAP 0x05
#define INT_LOAD_RAM_BANK 0x06
#define INT_SWITCH_RAM_BANK 0x07
#define INT_RENDER_CURSOR 0x08
#define INT_SET_TIMER 0x09

#define INT_PLAY_TRACK 0x0A
#define INT_PLAY_INSTRUMENT 0x0B
#define INT_STOP_TRACK 0x0C
#define INT_STOP_INSTRUMENT 0x0D

#define INT_CHECK_BBOX_BBOX_COLLISION 0x08

// Ensure compiler doesn't add padding to our structs
#pragma pack(push, 1)

// BIOS Parameter Block (BPB) for standard 1.44MB 3.5" Floppy

//Sector Size: 256 bytesSectors per Bank: 256 sectors ($256 \times 256 = 65,536 \text{ bytes}$)Cluster Size: 1 sector (256 bytes)

typedef struct {
    uint8_t boot_jmp[4];
    char oem_name[16];
    uint8_t root_dir_entries;
} BootSector; //22

// Directory Entry Structure (32 bytes)
typedef struct {
    char File_Name_Encodings[16*4]; //64
    char Extension_Encodings[4*4]; //16
    uint8_t Filename_Length;
    uint8_t File_Attributes; //1

    uint16_t Year_Created; //2 * 12 = 24
    uint16_t Month_Created;
    uint16_t Day_Created;
    uint16_t Time_Created_Seconds;

    uint16_t Year_Accessed;
    uint16_t Month_Accessed;
    uint16_t Day_Accessed;
    uint16_t Time_Accessed_Seconds;

    uint16_t Year_Modified;
    uint16_t Month_Modified;
    uint16_t Day_Modified;
    uint16_t Time_Modified_Seconds;

    uint8_t On_This_Bank;
    uint8_t Start_Resolution;
    uint8_t Number_Of_Resolutions;
    //5
} DirEntry; //111 bytes. 595 entries in Root.




struct _TILEMAP
{
    char Name[16];
    unsigned char Bank;
    unsigned short Address;
    unsigned char Cell_Width;
    unsigned char Cell_Height;
};


struct _ENCODING
{
    char Name[16];
    unsigned char Bank;
    unsigned short Address;
};

struct _TRACK
{
    char Name[16];
    unsigned char Bank;
    unsigned short Address;
    unsigned short Spacing;
    unsigned short Length;
};


struct _DBLOCK
{
    char Name[16];
    unsigned char Bank;
    unsigned short Address;
};

struct _VAR
{
    char Name[16];
    unsigned char Bank;
    unsigned short Address;
    unsigned short Value;
    int Length;
};

struct _LABEL
{
    char Name[16];
    unsigned char Bank;
    unsigned short Address;
};

struct _RAM_Bank
{
    unsigned char Bank[65536];
};

typedef struct {
    uint8_t Instwaveform;
    uint8_t Instattack;
    uint8_t Instdecay;
    uint8_t Instsustain;
    uint8_t Instrelease;
    uint16_t Instpulse_width; // Only matters if waveform is WAVE_PULSE
} Instrument;

typedef struct {
    uint8_t note;          // 0 = Rest/No note, 1-96 = Musical notes (C-1, C#1, etc.)
    uint8_t instrument_id; // Which instrument to play (0 to 3)
    bool gate;             // true = Gate On, false = Gate Off (Tie/Cut note)
} Step;

struct _Channel_Step_Sequence
{
    Step Steps[16];
};

struct _Track_Packet
{
    struct _Channel_Step_Sequence Channels[3]; //3 with 16 steps each
};

struct _Track
{
    struct _Track_Packet Track_Packets[32];
    int Number_Of_Packets;
    int Order[32];
};

#pragma pack(pop)

struct _Audio_Processor
{
    Instrument Track_Instruments[256];

    unsigned char Instruments_Bank;

    unsigned char Track_Bank;
    int Track_Address;
    int Track_Start_Address;
    int Track_End_Address;
    int Current_Step;

    double Last_Time_Step_Triggered;
    double Step_Spacing;
    bool Tracking_On;
};

struct _New_Processor
{
    uint16_t Register_Zero;
    uint16_t Register_One;
    uint16_t Instruction_Pointer;
    uint16_t Stack_Pointer;

    bool Signed_Int_Mode;
    bool Float_Mode;

    bool Zero_Flag;
    bool Carry_Flag;
    bool Sign_Flag;
    bool Overflow_Flag;
    bool Parity_Flag;
    bool Auxiliary_Carry_Flag;
    bool Direction_Flag;
    bool Maskable_Interrupt_Flag;
    bool Trap_Flag;

    bool Equals_Flag;
    bool Less_Flag;
    bool Greater_Flag;

    bool Processor_Halted;

    bool Division_Error;

    struct _Audio_Processor Audio_Processor;
};

struct _New_Computer
{
    unsigned char Red_Color_Balance;
    unsigned char Green_Color_Balance;
    unsigned char Blue_Color_Balance;

    bool Color_Mode;

    bool Power_State;

    struct _New_Processor Processor;
    unsigned char Current_ROM_Bank;
    unsigned char Current_RAM_Bank;
    struct _RAM_Bank ROM_Memory_Zero[256];
    struct _RAM_Bank ROM_Memory_One[256];
    struct _RAM_Bank RAM[256];

    unsigned char Controller_D_Pad_RAM[4];
    unsigned char Controller_Button_RAM[2];

    unsigned char Keyboard_RAM[256];
    unsigned char Mouse_RAM[3];

    unsigned char* Front_Video_Buffer;
    unsigned char* Back_Video_Buffer;

    GLuint Texture_ID;
    int RGBA_Image_Size;
    unsigned char Texture_Made;
    int x;
    int y;
    int Width;
    int Height;
    unsigned char* RGB_Canvas;
    unsigned char* RGBA_Canvas;
    float* Vertices;
    float* Texture_Vertices;

    struct _Timer* Universal_Timer;
    bool Cursor_Visible;
    double Last_Time_Cursor_Was_Visible;
    double Timer;
    bool Timer_Triggered;
    bool Timer_Set;

    unsigned char Text_Input_Buffer[256];
    unsigned char On_The_Fly_Encoding[256*4];
    int Number_Of_Characters;
    int OTF_Encoding_Width;
    int Number_Of_Newlines;
};

struct _New_Compiler
{
    unsigned char Current_ROM_Bank;
    unsigned short Current_ROM_Address;
    struct _RAM_Bank ROM_Memory_Zero[256];

    unsigned char Start_Bank;
    unsigned short Start_Address;

    int Number_Of_DBLOCKS;
    int Number_Of_VARS;
    int Number_Of_LABELS;
    int Number_Of_TILEMAPS;
    int Number_Of_ENCODINGS;
};

void Write_File_System(const char* Filename);
void Write_Boot_Sector();
void Write_Directory();

struct _New_Computer* Create_New_Computer();
void Initialize_New_Computer(struct _Engine* Engine, struct _Seat_Object* Seat);

void Initialize_New_Computer_No_Seat(struct _Engine* Engine, struct _New_Computer* New_Computer);
void Turn_Computer_Off_No_Seat(struct _Engine* Engine, struct _New_Computer* New_Computer);
void Load_Program_No_Seat(struct _New_Computer* New_Computer, const char* Filename);
void Turn_Computer_On_No_Seat(struct _Engine* Engine, struct _New_Computer* New_Computer);
void Render_New_Computer_No_Seat(struct _Engine* Engine, struct _New_Computer* New_Computer);

void Write_ROM_Memory_To_Program(const char* Filename);
void Write_Opcode(struct _New_Compiler* New_Compiler, unsigned char Code, unsigned char Bank, unsigned short Address, unsigned char Size, unsigned char Argument_One, unsigned char Argument_Two,unsigned char Argument_Three);
void Write_Program_To_ROM_Memory(const char* Filename, struct _Seat_Object* Seat);
bool Compile_AQ_BASIC_Program(const char* Filename, const char* Output);
void BMPtoSMI(const char* Filename, const char* Output);

void Load_Program(struct _Seat_Object* Seat, const char* Filename);

void Process_New_Computer_Cycles(struct _Engine* Engine, struct _Seat_Object* Seat, int Cycles, struct _Audio_Chip* Audio_Chip);
void Process_New_Computer(struct _Engine* Engine, struct _Seat_Object* Seat, struct _Audio_Chip* Audio_Chip);

void Process_New_Computer_Cycles_No_Seat(struct _Engine* Engine, struct _New_Computer* New_Computer, int Cycles);
void Process_New_Computer_No_Seat(struct _Engine* Engine, struct _New_Computer* New_Computer);

void Handle_New_Computer_Inputs(struct _Engine* Engine, struct _Seat_Object* Seat, struct _Keypad Keypad);
void Render_New_Computer(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_NOP(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_HLT(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_CLS(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_FLS(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_INT(struct _Engine* Engine, struct _Seat_Object* Seat, struct _Audio_Chip* Audio_Chip);


void Process_Opcode_MOV_R0_INT_VALUE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_PUSH_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_POP_R0(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_MOV_R1_INT_VALUE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_PUSH_R1(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_POP_R1(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_MOV_R0_R1(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_MOV_R1_R0(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_INT_Load_RAM_Bank(struct _Engine* Engine, struct _Seat_Object* Seat);

void Turn_Computer_Off(struct _Engine* Engine, struct _Seat_Object* Seat);
void Turn_Computer_On(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_INT_Shutdown_Computer(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_INT_Restart_Computer(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_INT_Render_Pixel(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_INT_Render_Line(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_INT_Render_Image(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_INT_Render_Tilemap(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_INT_Render_Cursor(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_INT_Set_Timer(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_INT_Play_Instrument(struct _Engine* Engine, struct _Seat_Object* Seat, struct _Audio_Chip* Audio_Chip);
void Process_INT_Play_Track(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_INT_Stop_Instrument(struct _Engine* Engine, struct _Seat_Object* Seat, struct _Audio_Chip* Audio_Chip);
void Process_INT_Stop_Track(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_MOV_VALUE_AT_ADDRESS_R1(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_MOV_VALUE_AT_ADDRESS_R0(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_MOV_R0_VALUE_AT_ADDRESS(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_MOV_R1_VALUE_AT_ADDRESS(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_ADD_R0_R1(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_ADD_R1_R0(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_SUB_R0_R1(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_SUB_R1_R0(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_MUL_R0_R1(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_MUL_R1_R0(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_DIV_R0_R1(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_DIV_R1_R0(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_COLORMODE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_MONOCHROMEMODE(struct _Engine* Engine, struct _Seat_Object* Seat);

bool Handle_Aqueous_Basic_Text_GOTO(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address);

bool Handle_Aqueous_Basic_Text_GOIFCTRLUP(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address);

bool Handle_Aqueous_Basic_Text_GOIFCTRLDOWN(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address);

bool Handle_Aqueous_Basic_Text_GOIFCTRLLEFT(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address);
bool Handle_Aqueous_Basic_Text_GOIFCTRLRIGHT(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address);

bool Handle_Aqueous_Basic_Text_GOIFCTRLA(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address);
bool Handle_Aqueous_Basic_Text_GOIFCTRLB(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address);

bool Handle_Aqueous_Basic_Text_ADDVVL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned short New_Value);

bool Handle_Aqueous_Basic_Text_SUBVVL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned short New_Value);

bool Handle_Aqueous_Basic_Text_MULVVL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned short New_Value);

bool Handle_Aqueous_Basic_Text_DIVVVL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned short New_Value);

bool Handle_Aqueous_Basic_Text_SETVVL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned short New_Value);
bool Handle_Aqueous_Basic_Text_SETVVR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_ADDVVR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_SUBVVR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_MULVVR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_DIVVVR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_GOIFVARNEQVAR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short Goto_Address, unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_GOIFVAREQVAR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short Goto_Address, unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_GOIFVARGEQVAR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short Goto_Address, unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_GOIFVARLEQVAR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short Goto_Address, unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_GOIFVARLSVAR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short Goto_Address, unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);

bool Handle_Aqueous_Basic_Text_GOIFVARGRVAR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short Goto_Address, unsigned char Bank,unsigned short Address,unsigned char BankTwo,unsigned short AddressTwo);


bool Handle_Aqueous_Basic_Text_GOIFVAREQVAL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short GotoAddress, unsigned char Bank,unsigned short Address,unsigned short Value);

bool Handle_Aqueous_Basic_Text_GOIFVARNEQVAL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short GotoAddress, unsigned char Bank,unsigned short Address,unsigned short Value);

bool Handle_Aqueous_Basic_Text_GOIFVARGEQVAL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short GotoAddress, unsigned char Bank,unsigned short Address,unsigned short Value);

bool Handle_Aqueous_Basic_Text_GOIFVARLEQVAL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short GotoAddress, unsigned char Bank,unsigned short Address,unsigned short Value);

bool Handle_Aqueous_Basic_Text_GOIFVARLSVAL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short GotoAddress, unsigned char Bank,unsigned short Address,unsigned short Value);

bool Handle_Aqueous_Basic_Text_GOIFVARGRVAL(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char GotoBank, unsigned short GotoAddress, unsigned char Bank,unsigned short Address,unsigned short Value);




bool Handle_Aqueous_Basic_Text_JUMPEX(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank_Bank,unsigned short Bank_Address,unsigned char Address_Bank,unsigned short Address_Address);

bool Handle_Aqueous_Basic_Text_CLS(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address);
bool Handle_Aqueous_Basic_Text_FLS(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address);
bool Handle_Aqueous_Basic_Text_RENDER(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address, unsigned char DBLOCKBank, unsigned short DBLOCKAddr, unsigned char xBank, unsigned short xAddress, unsigned char yBank, unsigned short yAddress);

void Process_Opcode_JMP(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_CALL(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_RETURN(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_CMP_R0_R1(struct _Engine* Engine, struct _Seat_Object* Seat);

void Process_Opcode_JNE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_JE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_JG(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_JL(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_JGE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_JLE(struct _Engine* Engine, struct _Seat_Object* Seat);


void Process_Opcode_CNE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_CE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_CG(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_CL(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_CGE(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_CLE(struct _Engine* Engine, struct _Seat_Object* Seat);


bool Handle_Aqueous_Basic_Text_GOSUB(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank,unsigned short Address);

bool Handle_Aqueous_Basic_Text_RETURN(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address);

bool Handle_Aqueous_Basic_Text_COLORMODE(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address);
bool Handle_Aqueous_Basic_Text_MONOCHROMEMODE(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address);

void Process_Opcode_IN_DPAD_UP_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_DPAD_DOWN_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_DPAD_LEFT_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_DPAD_RIGHT_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_A_BUTTON_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_B_BUTTON_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_KBD_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_MOUSE_X_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_MOUSE_Y_R0(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_IN_MOUSE_CLICK_R0(struct _Engine* Engine, struct _Seat_Object* Seat);




void Process_Opcode_AND(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_OR(struct _Engine* Engine, struct _Seat_Object* Seat);
void Process_Opcode_XOR(struct _Engine* Engine, struct _Seat_Object* Seat);

bool Handle_Aqueous_Basic_Text_RENTILEMAP(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank, unsigned short Address,unsigned char XBank,unsigned short XAddress,unsigned char YBank,unsigned short YAddress,unsigned char EncodingBank,unsigned short EncodingAddress,unsigned char EncodingLengthBank,unsigned short EncodingLengthAddress,unsigned char TPRBank,unsigned short TPRAddress,unsigned char TileWidth,unsigned char TileHeight);

void Encode_Text_As_File(char Text[256], unsigned short Encoding_Length, const char* Output_File);

bool Handle_Aqueous_Basic_Text_RENCURSOR(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address,unsigned char Bank, unsigned short Address,unsigned char XBank,unsigned short XAddress,unsigned char YBank,unsigned short YAddress,unsigned char TileWidth,unsigned char TileHeight);

bool Handle_Aqueous_Basic_Text_DELAY(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address, unsigned char XBank,unsigned short XAddress);

bool Handle_Aqueous_Basic_Text_PLAYINSTRUMENT(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address, unsigned char Bank,unsigned short Address);

bool Handle_Aqueous_Basic_Text_STOPINSTRUMENT(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address, unsigned char Bank,unsigned short Address);

bool Handle_Aqueous_Basic_Text_PLAYTRACK(struct _New_Compiler* New_Compiler,unsigned char Current_ROM_Bank,unsigned short Current_ROM_Address, unsigned char Bank,unsigned short Address, unsigned short Spacing, unsigned short Length);

void Write_Instrument_Onto_ROM(struct _New_Compiler* New_Compiler, unsigned char Bank, unsigned short Address);


#endif // COMPUTER_H_INCLUDED