Subversion Repositories Shiroi

Rev

Rev 6 | Rev 10 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6 Rev 7
Line 1... Line 1...
1
/* $Id: main.c 6 2024-08-28 10:29:32Z nishi $ */
1
/* $Id: main.c 7 2024-08-28 14:02:52Z nishi $ */
2
 
2
 
3
#include <stdio.h>
3
#include <stdio.h>
4
#include <stdbool.h>
4
#include <stdbool.h>
5
#include <sys/stat.h>
5
#include <sys/stat.h>
6
#include <stdlib.h>
6
#include <stdlib.h>
Line 76... Line 76...
76
							const char* n = "";
76
							const char* n = "";
77
							int dev = -1;
77
							int dev = -1;
78
							if(strcmp(line + j + 1, "video_mark_1") == 0) {
78
							if(strcmp(line + j + 1, "video_mark_1") == 0) {
79
								dev = SHIROI_VIDEO_MARK_I;
79
								dev = SHIROI_VIDEO_MARK_I;
80
								n = "Video Mark I";
80
								n = "Video Mark I";
-
 
81
							} else if(strcmp(line + j + 1, "video_mark_2") == 0) {
-
 
82
								dev = SHIROI_VIDEO_MARK_II;
-
 
83
								n = "Video Mark II";
81
							} else if(strcmp(line + j + 1, "sound_mark_1") == 0) {
84
							} else if(strcmp(line + j + 1, "sound_mark_1") == 0) {
82
								dev = SHIROI_SOUND_MARK_I;
85
								dev = SHIROI_SOUND_MARK_I;
83
								n = "Sound Mark I";
86
								n = "Sound Mark I";
84
							} else if(strcmp(line + j + 1, "math_mark_1") == 0) {
87
							} else if(strcmp(line + j + 1, "math_mark_1") == 0) {
85
								dev = SHIROI_MATH_MARK_I;
88
								dev = SHIROI_MATH_MARK_I;
Line 157... Line 160...
157
		ClearBackground(BLACK);
160
		ClearBackground(BLACK);
158
 
161
 
159
		if(text != NULL) {
162
		if(text != NULL) {
160
			/*
163
			/*
161
			 * / 1 2 3 4 5 6 7 8 9 10 11 12 13
164
			 * / 1 2 3 4 5 6 7 8 9 10 11 12 13
162
			 * 1 1 2 3 4 5 6 7 8 9 0  -  =
165
			 * 1 1 2 3 4 5 6 7 8 9 0  -  =  bs
163
			 * 2 q w e r t y u i o p  [  ]  rt
166
			 * 2 q w e r t y u i o p  [  ]  rt
164
			 * 3 a s d f g h j k l ;  '  \  cl
167
			 * 3 a s d f g h j k l ;  '  \  cl
165
			 * 4 z x c v b n m , . /  sp
168
			 * 4 z x c v b n m , . /  sp
166
			 */
169
			 */
167
			int c = GetKeyPressed();
170
			int c = GetKeyPressed();
168
			if(c == 0) {
-
 
169
				text->key = 0;
-
 
170
			} else if(KEY_ONE <= c && c <= KEY_NINE) {
171
			if(KEY_ONE <= c && c <= KEY_NINE) {
171
				text->key = (1 << 4) | (c - KEY_ONE + 1);
172
				text->key = (1 << 4) | (c - KEY_ONE + 1);
172
			} else if(c == KEY_ZERO) {
173
			} else if(c == KEY_ZERO) {
173
				text->key = (1 << 4) | 10;
174
				text->key = (1 << 4) | 10;
174
			} else if(c == KEY_MINUS) {
175
			} else if(c == KEY_MINUS) {
175
				text->key = (1 << 4) | 11;
176
				text->key = (1 << 4) | 11;
176
			} else if(c == KEY_EQUAL) {
177
			} else if(c == KEY_EQUAL) {
177
				text->key = (1 << 4) | 12;
178
				text->key = (1 << 4) | 12;
-
 
179
			} else if(c == KEY_BACKSPACE) {
-
 
180
				text->key = (1 << 4) | 13;
178
			} else if(c == KEY_LEFT_BRACKET) {
181
			} else if(c == KEY_LEFT_BRACKET) {
179
				text->key = (2 << 4) | 11;
182
				text->key = (2 << 4) | 11;
180
			} else if(c == KEY_RIGHT_BRACKET) {
183
			} else if(c == KEY_RIGHT_BRACKET) {
181
				text->key = (2 << 4) | 12;
184
				text->key = (2 << 4) | 12;
182
			} else if(c == KEY_ENTER) {
185
			} else if(c == KEY_ENTER) {
Line 257... Line 260...
257
			BeginTextureMode(r);
260
			BeginTextureMode(r);
258
 
261
 
259
			int y, x;
262
			int y, x;
260
			for(y = 0; y < video->height; y++) {
263
			for(y = 0; y < video->height; y++) {
261
				for(x = 0; x < video->width; x++) {
264
				for(x = 0; x < video->width; x++) {
262
					if(video->fb[y * video->width + x] != fb[y * TMS9918_PIXELS_X + x]) {
265
					if(video->fb[y * video->width + x] != fb[y * video->width + x]) {
263
						uint32_t c = video->fb[y * video->width + x];
266
						uint32_t c = video->fb[y * video->width + x];
264
						// printf("%X\n", c);
-
 
265
						DrawPixel(x, y, (Color){(c >> 24) & 0xff, (c >> 16) & 0xff, (c >> 8) & 0xff, 0xff});
267
						DrawPixel(x, y, (Color){(c >> 24) & 0xff, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff});
266
						fb[y * video->width + x] = c;
268
						fb[y * video->width + x] = c;
267
					}
269
					}
268
				}
270
				}
269
			}
271
			}
270
 
272
 
271
			EndTextureMode();
273
			EndTextureMode();
272
 
274
 
273
			DrawTexturePro(r.texture, (Rectangle){0, 0, video->width, -video->height}, (Rectangle){text == NULL ? 0 : 100, 0, GetScreenWidth() - (text == NULL ? 0 : 100), GetScreenHeight()}, (Vector2){0, 0}, 0, WHITE);
275
			DrawTexturePro(r.texture, (Rectangle){0, 0, video->width, -video->height}, (Rectangle){text == NULL ? 0 : 100, 0, GetScreenWidth() - (text == NULL ? 0 : 100), GetScreenHeight()}, (Vector2){0, 0}, 0, WHITE);
274
		} else {
276
		} else {
275
			DrawText("No Video", 0, 0, 20, WHITE);
277
			DrawText("No Video", 0, 20, 20, WHITE);
276
		}
278
		}
277
 
279
 
278
		DrawText("Caps Lock", 5, 5, 10, WHITE);
280
		DrawText("Caps Lock", 5, 5, 10, WHITE);
279
 
281
 
280
		DrawCircle(100 - 10, 10, 5, text->caps ? RED : BLACK);
282
		DrawCircle(100 - 10, 10, 5, text->caps ? RED : BLACK);