Subversion Repositories Shiroi

Rev

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

Rev 1 Rev 3
Line 1... Line 1...
1
/* $Id: main.c 1 2024-08-28 08:10:28Z nishi $ */
1
/* $Id: main.c 3 2024-08-28 09:19:04Z 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 25... Line 25...
25
			return 1;
25
			return 1;
26
		}
26
		}
27
		fprintf(fconf, "slot1=video_mark_1\n");
27
		fprintf(fconf, "slot1=video_mark_1\n");
28
		fprintf(fconf, "slot2=sound_mark_1\n");
28
		fprintf(fconf, "slot2=sound_mark_1\n");
29
		fprintf(fconf, "slot3=math_mark_1\n");
29
		fprintf(fconf, "slot3=math_mark_1\n");
-
 
30
		fprintf(fconf, "slot4=text_mark_1\n");
30
		fprintf(fconf, "rom=shiroi.rom\n");
31
		fprintf(fconf, "rom=shiroi.rom\n");
31
		fclose(fconf);
32
		fclose(fconf);
32
	}
33
	}
33
 
34
 
34
	shiroi_init_cards(&shiroi);
35
	shiroi_init_cards(&shiroi);
Line 52... Line 53...
52
			char oldc = ini[i];
53
			char oldc = ini[i];
53
			ini[i] = 0;
54
			ini[i] = 0;
54
 
55
 
55
			char* line = ini + incr;
56
			char* line = ini + incr;
56
 
57
 
57
			if(strlen(line) != 0) {
58
			if(strlen(line) != 0 && line[0] != '#') {
58
				int j;
59
				int j;
59
				for(j = 0; line[j] != 0; j++) {
60
				for(j = 0; line[j] != 0; j++) {
60
					if(line[j] == '=') {
61
					if(line[j] == '=') {
61
						line[j] = 0;
62
						line[j] = 0;
62
						if(strcmp(line, "rom") == 0) {
63
						if(strcmp(line, "rom") == 0) {
Line 81... Line 82...
81
								dev = SHIROI_SOUND_MARK_I;
82
								dev = SHIROI_SOUND_MARK_I;
82
								n = "Sound Mark I";
83
								n = "Sound Mark I";
83
							} else if(strcmp(line + j + 1, "math_mark_1") == 0) {
84
							} else if(strcmp(line + j + 1, "math_mark_1") == 0) {
84
								dev = SHIROI_MATH_MARK_I;
85
								dev = SHIROI_MATH_MARK_I;
85
								n = "Math Mark I";
86
								n = "Math Mark I";
-
 
87
							} else if(strcmp(line + j + 1, "text_mark_1") == 0) {
-
 
88
								dev = SHIROI_TEXT_MARK_I;
-
 
89
								n = "Text Mark I";
86
							}
90
							}
87
							if(dev == -1) {
91
							if(dev == -1) {
88
								fprintf(stderr, "No such device called `%s' ; ignoring\n", line + j + 1);
92
								fprintf(stderr, "No such device called `%s' ; ignoring\n", line + j + 1);
89
							} else {
93
							} else {
90
								shiroi_install(&shiroi, slot, dev);
94
								shiroi_install(&shiroi, slot, dev);
Line 111... Line 115...
111
	shiroi_card_t* videocard = shiroi_get_video_card(&shiroi);
115
	shiroi_card_t* videocard = shiroi_get_video_card(&shiroi);
112
	shiroi_video_t* video = NULL;
116
	shiroi_video_t* video = NULL;
113
	if(videocard != NULL) {
117
	if(videocard != NULL) {
114
		video = videocard->videoptr;
118
		video = videocard->videoptr;
115
	}
119
	}
-
 
120
	shiroi_card_t* textcard = shiroi_get_text_card(&shiroi);
-
 
121
	shiroi_text_t* text = NULL;
-
 
122
	if(textcard != NULL) {
-
 
123
		text = textcard->textptr;
-
 
124
	}
116
 
125
 
117
	SetTraceLogLevel(LOG_NONE);
126
	SetTraceLogLevel(LOG_NONE);
118
	if(video != NULL) {
127
	if(video != NULL) {
119
		InitWindow(video->width * scx, video->height * scy, "Shiroi Emulator");
128
		InitWindow(video->width * scx, video->height * scy, "Shiroi Emulator");
120
	} else {
129
	} else {
Line 145... Line 154...
145
	while(!WindowShouldClose()) {
154
	while(!WindowShouldClose()) {
146
		BeginDrawing();
155
		BeginDrawing();
147
 
156
 
148
		ClearBackground(BLACK);
157
		ClearBackground(BLACK);
149
 
158
 
-
 
159
		if(text != NULL) {
-
 
160
			text->key = GetCharPressed();
-
 
161
		}
-
 
162
 
150
		if(video != NULL) {
163
		if(video != NULL) {
151
			BeginTextureMode(r);
164
			BeginTextureMode(r);
152
 
165
 
153
			int y, x;
166
			int y, x;
154
			for(y = 0; y < video->height; y++) {
167
			for(y = 0; y < video->height; y++) {