Compare commits
	
		
			2 Commits
		
	
	
		
			4fe5bd2e15
			...
			d32386b621
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| d32386b621 | |||
| cc18c20435 | 
							
								
								
									
										12
									
								
								include/gb.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								include/gb.h
									
									
									
									
									
								
							|  | @ -24,9 +24,9 @@ typedef struct gb_timers_t { | ||||||
| 	bool check_fedge; | 	bool check_fedge; | ||||||
| } GBTimers; | } GBTimers; | ||||||
| 
 | 
 | ||||||
| GBTimers *gb_timers_open(RIO *io); | bool gb_timers_init(GBTimers *timers, RIO *io); | ||||||
| void gb_timers_continue(GBTimers *timers, ut32 cycles); | void gb_timers_continue(GBTimers *timers, ut32 cycles); | ||||||
| void gb_timers_close(GBTimers *timers, RIO *io); | void gb_timers_fini(GBTimers *timers, RIO *io); | ||||||
| 
 | 
 | ||||||
| typedef struct gb_joypad_t { | typedef struct gb_joypad_t { | ||||||
| 	ut8 *keys; | 	ut8 *keys; | ||||||
|  | @ -43,9 +43,9 @@ typedef struct gb_joypad_t { | ||||||
| 	ut8 odata; | 	ut8 odata; | ||||||
| } GBJoypad; | } GBJoypad; | ||||||
| 
 | 
 | ||||||
| GBJoypad *gb_joypad_open(RIO *io); | bool gb_joypad_init(GBJoypad *joypad, RIO *io); | ||||||
| void gb_joypad_continue(GBJoypad *joypad); | void gb_joypad_continue(GBJoypad *joypad); | ||||||
| void gb_joypad_close(GBJoypad *joypad, RIO *io); | void gb_joypad_fini(GBJoypad *joypad, RIO *io); | ||||||
| 
 | 
 | ||||||
| typedef struct gb_dma_t { | typedef struct gb_dma_t { | ||||||
| 	ut64 seek;	//17 bit seek and some flags
 | 	ut64 seek;	//17 bit seek and some flags
 | ||||||
|  | @ -172,8 +172,8 @@ typedef struct gb_dmg_ppu_t { | ||||||
| typedef struct gameboy_t { | typedef struct gameboy_t { | ||||||
| 	RIO *io; | 	RIO *io; | ||||||
| 	RArch *arch; | 	RArch *arch; | ||||||
| 	GBTimers *timers; | 	GBTimers timers; | ||||||
| 	GBJoypad *joypad; | 	GBJoypad joypad; | ||||||
| 	GBDMA *dma; | 	GBDMA *dma; | ||||||
| 	GBPPU *ppu; | 	GBPPU *ppu; | ||||||
| 	ut64 addr; | 	ut64 addr; | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								io/joypad.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								io/joypad.c
									
									
									
									
									
								
							|  | @ -80,19 +80,18 @@ RIOPlugin r_io_plugin_gb_joypad = { | ||||||
| 	.write = __write, | 	.write = __write, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| GBJoypad *gb_joypad_open (RIO *io) { | bool gb_joypad_init (GBJoypad *joypad, RIO *io) { | ||||||
| 	GBJoypad *joypad = R_NEW0 (GBJoypad); | 	if (!joypad || !io) { | ||||||
| 	if (!joypad) { | 		return false; | ||||||
| 		return NULL; |  | ||||||
| 	} | 	} | ||||||
|  | 	joypad[0] = (const GBJoypad){0}; | ||||||
| 	char uri[64]; | 	char uri[64]; | ||||||
| 	memset (uri, 0x00, sizeof (char) * 64); | 	memset (uri, 0x00, sizeof (char) * 64); | ||||||
| 	sprintf (uri, "gb_joypad://%p", joypad); | 	sprintf (uri, "gb_joypad://%p", joypad); | ||||||
| 	RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_joypad, | 	RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_joypad, | ||||||
| 		uri, R_PERM_RWX, 0); | 		uri, R_PERM_RWX, 0); | ||||||
| 	if (!desc) { | 	if (!desc) { | ||||||
| 		free (joypad); | 		return false; | ||||||
| 		return NULL; |  | ||||||
| 	} | 	} | ||||||
| 	joypad->fd = desc->fd; | 	joypad->fd = desc->fd; | ||||||
| 	const ut8 *keys = SDL_GetKeyboardState (NULL); | 	const ut8 *keys = SDL_GetKeyboardState (NULL); | ||||||
|  | @ -105,7 +104,7 @@ GBJoypad *gb_joypad_open (RIO *io) { | ||||||
| 	joypad->b = SDL_SCANCODE_K; | 	joypad->b = SDL_SCANCODE_K; | ||||||
| 	joypad->start = SDL_SCANCODE_SPACE; | 	joypad->start = SDL_SCANCODE_SPACE; | ||||||
| 	joypad->select = SDL_SCANCODE_KP_ENTER; | 	joypad->select = SDL_SCANCODE_KP_ENTER; | ||||||
| 	return joypad; | 	return true;; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void gb_joypad_continue(GBJoypad *joypad) { | void gb_joypad_continue(GBJoypad *joypad) { | ||||||
|  | @ -139,10 +138,9 @@ void gb_joypad_continue(GBJoypad *joypad) { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void gb_joypad_close (GBJoypad *joypad, RIO *io) { | void gb_joypad_fini (GBJoypad *joypad, RIO *io) { | ||||||
| 	if (!joypad || !io) { | 	if (!joypad || !io) { | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	r_io_fd_close (io, joypad->fd); | 	r_io_fd_close (io, joypad->fd); | ||||||
| 	free (joypad); |  | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										17
									
								
								io/timers.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								io/timers.c
									
									
									
									
									
								
							|  | @ -101,33 +101,28 @@ RIOPlugin r_io_plugin_gb_timers = { | ||||||
| 	.write = __write, | 	.write = __write, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| GBTimers *gb_timers_open (RIO *io) { | bool gb_timers_init (GBTimers *timers, RIO *io) { | ||||||
| 	if (!io) { | 	if (!timers || !io) { | ||||||
| 		return NULL; | 		return false; | ||||||
| 	} |  | ||||||
| 	GBTimers *timers = R_NEW0 (GBTimers); |  | ||||||
| 	if (!timers) { |  | ||||||
| 		return NULL; |  | ||||||
| 	} | 	} | ||||||
|  | 	timers[0] = (const GBTimers){0}; | ||||||
| 	char uri[64]; | 	char uri[64]; | ||||||
| 	memset (uri, 0x00, sizeof (char) * 64); | 	memset (uri, 0x00, sizeof (char) * 64); | ||||||
| 	sprintf (uri, "gb_timers://%p", timers); | 	sprintf (uri, "gb_timers://%p", timers); | ||||||
| 	RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_timers, | 	RIODesc *desc = r_io_desc_open_plugin (io, &r_io_plugin_gb_timers, | ||||||
| 		uri, R_PERM_RWX, 0); | 		uri, R_PERM_RWX, 0); | ||||||
| 	if (!desc) { | 	if (!desc) { | ||||||
| 		free (timers); |  | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	} | 	} | ||||||
| 	timers->fd = desc->fd; | 	timers->fd = desc->fd; | ||||||
| 	return timers; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void gb_timers_close (GBTimers *timers, RIO *io) { | void gb_timers_fini (GBTimers *timers, RIO *io) { | ||||||
| 	if (!timers || !io) { | 	if (!timers || !io) { | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	r_io_fd_close (io, timers->fd); | 	r_io_fd_close (io, timers->fd); | ||||||
| 	free (timers); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void gb_timers_continue (GBTimers *timers, ut32 cycles) { | void gb_timers_continue (GBTimers *timers, ut32 cycles) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user