no message
This commit is contained in:
		@@ -905,13 +905,6 @@ static void onConsoleConfigCommand(Console* console, const char* param)
 | 
				
			|||||||
	commandDone(console);
 | 
						commandDone(console);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static s32 saveRom(tic_mem* tic, void* buffer)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	s32 size = tic->api.save(&tic->cart, buffer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return size;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void onFileDownloaded(GetResult result, void* data)
 | 
					static void onFileDownloaded(GetResult result, void* data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Console* console = (Console*)data;
 | 
						Console* console = (Console*)data;
 | 
				
			||||||
@@ -1245,6 +1238,8 @@ static void writeMemoryString(MemoryBuffer* memory, const char* str)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void onConsoleExportHtmlCommand(Console* console, const char* name)
 | 
					static void onConsoleExportHtmlCommand(Console* console, const char* name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						tic_mem* tic = console->tic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char cartName[FILENAME_MAX];
 | 
						char cartName[FILENAME_MAX];
 | 
				
			||||||
	strcpy(cartName, name);
 | 
						strcpy(cartName, name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1286,43 +1281,62 @@ static void onConsoleExportHtmlCommand(Console* console, const char* name)
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				writeMemoryString(&output, "var cartridge = [");
 | 
									writeMemoryString(&output, "var cartridge = [");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				s32 size = saveRom(console->tic, buffer);
 | 
									s32 size = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// zip buffer
 | 
									// create cart copy
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					unsigned long outSize = sizeof(tic_cartridge);
 | 
										tic_cartridge* dup = SDL_malloc(sizeof(tic_cartridge));
 | 
				
			||||||
					u8* output = (u8*)SDL_malloc(outSize);
 | 
					
 | 
				
			||||||
 | 
										SDL_memcpy(dup, &tic->cart, sizeof(tic_cartridge));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if(processDoFile())
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											SDL_memcpy(dup->code.data, tic->code.data, sizeof(tic_code));
 | 
				
			||||||
 | 
											
 | 
				
			||||||
 | 
											size = tic->api.save(dup, buffer);
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										SDL_free(dup);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if(size)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										// zip buffer
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											unsigned long outSize = sizeof(tic_cartridge);
 | 
				
			||||||
 | 
											u8* output = (u8*)SDL_malloc(outSize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											compress2(output, &outSize, buffer, size, Z_BEST_COMPRESSION);
 | 
				
			||||||
 | 
											SDL_free(buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											buffer = output;
 | 
				
			||||||
 | 
											size = outSize;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											u8* ptr = buffer;
 | 
				
			||||||
 | 
											u8* end = ptr + size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											char value[] = "999,";
 | 
				
			||||||
 | 
											while(ptr != end)
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
 | 
												sprintf(value, "%i,", *ptr++);
 | 
				
			||||||
 | 
												writeMemoryString(&output, value);
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					compress2(output, &outSize, buffer, size, Z_BEST_COMPRESSION);
 | 
					 | 
				
			||||||
					SDL_free(buffer);
 | 
										SDL_free(buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					buffer = output;
 | 
										writeMemoryString(&output, "];\n");
 | 
				
			||||||
					size = outSize;
 | 
					
 | 
				
			||||||
 | 
										writeMemoryData(&output, EmbedTicJs, EmbedTicJsSize);
 | 
				
			||||||
 | 
										writeMemoryString(&output, "</script>\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										ptr += sizeof(Placeholder)-1;
 | 
				
			||||||
 | 
										writeMemoryData(&output, ptr, EmbedIndexSize - (ptr - EmbedIndex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										fsGetFileData(onFileDownloaded, cartName, output.data, output.size, DEFAULT_CHMOD, console);					
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					u8* ptr = buffer;
 | 
					 | 
				
			||||||
					u8* end = ptr + size;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					char value[] = "999,";
 | 
					 | 
				
			||||||
					while(ptr != end)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						sprintf(value, "%i,", *ptr++);
 | 
					 | 
				
			||||||
						writeMemoryString(&output, value);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				SDL_free(buffer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				writeMemoryString(&output, "];\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				writeMemoryData(&output, EmbedTicJs, EmbedTicJsSize);
 | 
					 | 
				
			||||||
				writeMemoryString(&output, "</script>\n");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				ptr += sizeof(Placeholder)-1;
 | 
					 | 
				
			||||||
				writeMemoryData(&output, ptr, EmbedIndexSize - (ptr - EmbedIndex));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				fsGetFileData(onFileDownloaded, cartName, output.data, output.size, DEFAULT_CHMOD, console);
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -1526,6 +1540,8 @@ static void onConsoleExportCommand(Console* console, const char* param)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static CartSaveResult saveCartName(Console* console, const char* name)
 | 
					static CartSaveResult saveCartName(Console* console, const char* name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						tic_mem* tic = console->tic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool success = false;
 | 
						bool success = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(name && strlen(name))
 | 
						if(name && strlen(name))
 | 
				
			||||||
@@ -1543,7 +1559,7 @@ static CartSaveResult saveCartName(Console* console, const char* name)
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				s32 size = saveRom(console->tic, buffer);
 | 
									s32 size = tic->api.save(&tic->cart, buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				name = getRomName(name);
 | 
									name = getRomName(name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										52
									
								
								src/run.c
									
									
									
									
									
								
							
							
						
						
									
										52
									
								
								src/run.c
									
									
									
									
									
								
							@@ -89,7 +89,7 @@ static const char* getPMemName(Run* run)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void tick(Run* run)
 | 
					static void tick(Run* run)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tic_mem* tic = run->tic;
 | 
						// tic_mem* tic = run->tic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while(pollEvent());
 | 
						while(pollEvent());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -98,53 +98,9 @@ static void tick(Run* run)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if(!run->init)
 | 
						if(!run->init)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// process 'dofile'
 | 
							if(processDoFile())
 | 
				
			||||||
		{
 | 
								return;
 | 
				
			||||||
			memset(tic->code.data, 0, sizeof(tic_code));
 | 
							
 | 
				
			||||||
 | 
					 | 
				
			||||||
			static const char DoFileTag[] = "dofile(";
 | 
					 | 
				
			||||||
			enum {Size = sizeof DoFileTag - 1};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (memcmp(tic->cart.code.data, DoFileTag, Size) == 0)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				const char* start = tic->cart.code.data + Size;
 | 
					 | 
				
			||||||
				const char* end = strchr(start, ')');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if(end && *start == *(end-1) && (*start == '"' || *start == '\''))
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					char filename[FILENAME_MAX] = {0};
 | 
					 | 
				
			||||||
					memcpy(filename, start + 1, end - start - 2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					s32 size = 0;
 | 
					 | 
				
			||||||
					void* buffer = fsReadFile(filename, &size);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if(buffer)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						if(size > 0)
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
							if(size > TIC_CODE_SIZE)
 | 
					 | 
				
			||||||
							{
 | 
					 | 
				
			||||||
								char buffer[256];
 | 
					 | 
				
			||||||
								sprintf(buffer, "code is larger than %i symbols", TIC_CODE_SIZE);
 | 
					 | 
				
			||||||
								onError(run, buffer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
								return;
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
							else SDL_memcpy(tic->code.data, buffer, size);
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					else
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						char buffer[256];
 | 
					 | 
				
			||||||
						sprintf(buffer, "dofile: file '%s' not found", filename);
 | 
					 | 
				
			||||||
						onError(run, buffer);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						return;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		run->tickData.start = run->tickData.counter(),
 | 
							run->tickData.start = run->tickData.counter(),
 | 
				
			||||||
		run->init = true;
 | 
							run->init = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										54
									
								
								src/studio.c
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								src/studio.c
									
									
									
									
									
								
							@@ -1357,6 +1357,60 @@ static void onFullscreen()
 | 
				
			|||||||
	SDL_SetWindowFullscreen(studio.window, studio.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
 | 
						SDL_SetWindowFullscreen(studio.window, studio.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool processDoFile()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						tic_mem* tic = studio.tic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						memset(tic->code.data, 0, sizeof(tic_code));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static const char DoFileTag[] = "dofile(";
 | 
				
			||||||
 | 
						enum {Size = sizeof DoFileTag - 1};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (memcmp(tic->cart.code.data, DoFileTag, Size) == 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							const char* start = tic->cart.code.data + Size;
 | 
				
			||||||
 | 
							const char* end = strchr(start, ')');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(end && *start == *(end-1) && (*start == '"' || *start == '\''))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								char filename[FILENAME_MAX] = {0};
 | 
				
			||||||
 | 
								memcpy(filename, start + 1, end - start - 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								s32 size = 0;
 | 
				
			||||||
 | 
								void* buffer = fsReadFile(filename, &size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if(buffer)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if(size > 0)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										if(size > TIC_CODE_SIZE)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											char buffer[256];
 | 
				
			||||||
 | 
											sprintf(buffer, "code is larger than %i symbols", TIC_CODE_SIZE);
 | 
				
			||||||
 | 
											setStudioMode(TIC_CONSOLE_MODE);
 | 
				
			||||||
 | 
											studio.console.error(&studio.console, buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											return false;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else SDL_memcpy(tic->code.data, buffer, size);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									char buffer[256];
 | 
				
			||||||
 | 
									sprintf(buffer, "dofile: file '%s' not found", filename);
 | 
				
			||||||
 | 
									setStudioMode(TIC_CONSOLE_MODE);
 | 
				
			||||||
 | 
									studio.console.error(&studio.console, buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									return false;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else SDL_memcpy(tic->code.data, tic->cart.code.data, sizeof(tic_code));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void runProject()
 | 
					void runProject()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	studio.tic->api.reset(studio.tic);
 | 
						studio.tic->api.reset(studio.tic);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -193,3 +193,4 @@ void gotoCode();
 | 
				
			|||||||
void gotoSurf();
 | 
					void gotoSurf();
 | 
				
			||||||
void exitFromGameMenu();
 | 
					void exitFromGameMenu();
 | 
				
			||||||
void runProject();
 | 
					void runProject();
 | 
				
			||||||
 | 
					bool processDoFile();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -431,6 +431,8 @@ static void api_reset(tic_mem* memory)
 | 
				
			|||||||
	machine->state.scanline = NULL;
 | 
						machine->state.scanline = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	updateSaveid(memory);
 | 
						updateSaveid(memory);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						memset(memory->code.data, 0, sizeof(tic_code));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void api_pause(tic_mem* memory)
 | 
					static void api_pause(tic_mem* memory)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user