v1.3.1
This commit is contained in:
		
							parent
							
								
									47236203cc
								
							
						
					
					
						commit
						c7f395339f
					
				
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 194 B After Width: | Height: | Size: 202 B | 
							
								
								
									
										
											BIN
										
									
								
								res/pinkie_pie.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								res/pinkie_pie.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 198 B | 
							
								
								
									
										9
									
								
								res/resources.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								res/resources.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | #include <genesis.h> | ||||||
|  | 
 | ||||||
|  | #ifndef _RES_RESOURCES_H_ | ||||||
|  | #define _RES_RESOURCES_H_ | ||||||
|  | 
 | ||||||
|  | extern const SpriteDefinition FLUTTERSHY; | ||||||
|  | extern const SpriteDefinition PINKIE_PIE; | ||||||
|  | 
 | ||||||
|  | #endif // _RES_RESOURCES_H_
 | ||||||
							
								
								
									
										2
									
								
								res/resources.res
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								res/resources.res
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | |||||||
|  | SPRITE FLUTTERSHY "fluttershy.png" 2 2 NONE 0 | ||||||
|  | SPRITE PINKIE_PIE "pinkie_pie.png" 2 2 NONE 0 | ||||||
							
								
								
									
										67
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								src/main.c
									
									
									
									
									
								
							| @ -1,21 +1,41 @@ | |||||||
| #include "genesis.h" | #include "genesis.h" | ||||||
| #include "mouse.h" | #include "mouse.h" | ||||||
|  | #include "resources.h" | ||||||
| 
 | 
 | ||||||
| #define PORT1 ((volatile u8*)0xA10003) | #define PORT1 ((volatile u8*)0xA10003) | ||||||
| #define PORT2 ((volatile u8*)0xA10005) | #define PORT2 ((volatile u8*)0xA10005) | ||||||
| 
 | 
 | ||||||
|  | Sprite* ptr1; | ||||||
|  | Sprite* ptr2; | ||||||
|  | 
 | ||||||
| int main() { | int main() { | ||||||
| 	VDP_setTextPlane(0); | 	VDP_setTextPlane(0); | ||||||
| 	VDP_drawText("Sega Mega Mouse RAW reader", 7, 27); | 	VDP_drawText("Sega Mega Mouse RAW reader", 7, 27); | ||||||
| 	VDP_drawText("RAW nibbles:", 14,0); | 	VDP_drawText("RAW nibbles:", 14,0); | ||||||
|  | 
 | ||||||
|  | 	SPR_init(); | ||||||
|  | 	PAL_setPalette(PAL1, FLUTTERSHY.palette->data, DMA); | ||||||
| 	 | 	 | ||||||
| 	s16 x1=0,y1=0, x2=0,y2=0; | 	s16 x1=0,y1=0, x2=0,y2=0; | ||||||
| 	u8 frame = 0; | 	u8 frame = 0; | ||||||
| 	char buf[40]; //буфер строки для вывода на экран
 | 	char buf[40]; //буфер строки для вывода на экран
 | ||||||
|  | 	MouseData m1, m2; | ||||||
|  | 
 | ||||||
|  | 	u8 code1[6] = {0}; | ||||||
|  | 	u8 code2[6] = {0}; | ||||||
|  | 
 | ||||||
|  | 	u8 ptr_active1=0,ptr_active2=0; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 	while(TRUE) { | 	while(TRUE) { | ||||||
| 		MouseData m1; | 		//считывание портов и вывод информации
 | ||||||
|  | 		u8 btnFront1=m1.buttons, btnFront2=m2.buttons; | ||||||
| 		read_mouse(&m1, PORT1); | 		read_mouse(&m1, PORT1); | ||||||
|  | 		read_mouse(&m2, PORT2); | ||||||
|  | 
 | ||||||
|  | 		btnFront1^=m1.buttons; | ||||||
|  | 		btnFront2^=m2.buttons; | ||||||
|  | 
 | ||||||
| 		sprintf(buf, "+%X%X%X%X %X %X %X%X %X%X",  | 		sprintf(buf, "+%X%X%X%X %X %X %X%X %X%X",  | ||||||
| 				m1.nibbles[0], m1.nibbles[1], m1.nibbles[2], m1.nibbles[3], | 				m1.nibbles[0], m1.nibbles[1], m1.nibbles[2], m1.nibbles[3], | ||||||
| 				m1.nibbles[4], m1.nibbles[5], m1.nibbles[6], m1.nibbles[7], | 				m1.nibbles[4], m1.nibbles[5], m1.nibbles[6], m1.nibbles[7], | ||||||
| @ -25,8 +45,20 @@ int main() { | |||||||
| 
 | 
 | ||||||
| 		if(m1.valid) { | 		if(m1.valid) { | ||||||
| 			x1 += m1.dx; y1 += m1.dy; | 			x1 += m1.dx; y1 += m1.dy; | ||||||
| 			if(x1>9999) x1=-9999; else if(x1<-9999) x1=9999; | 			if(x1>304) x1=304; else if(x1<0) x1=0; | ||||||
| 			if(y1>9999) y1=-9999; else if(y1<-9999) y1=9999; | 			if(y1>208) y1=208; else if(y1<0) y1=0; | ||||||
|  | 
 | ||||||
|  | 			if(!ptr_active1 && btnFront1) { | ||||||
|  | 				u8* code = code1; | ||||||
|  | 				for(int i=1;i<6;i++) code[i-1]=code[i]; | ||||||
|  | 				code[5]=btnFront1; | ||||||
|  | 				if(code[0]==0x4&&code[1]==0x1&&code[2]==0x1&&code[3]==0x2&&code[4]==0x2&&code[5]==0x4){ | ||||||
|  | 					ptr_active1=1; | ||||||
|  | 					ptr1 = SPR_addSprite(&FLUTTERSHY, 0, 0, TILE_ATTR(PAL1, TRUE, FALSE, TRUE)); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			if(ptr_active1) SPR_setPosition(ptr1, x1, 208-y1); | ||||||
| 
 | 
 | ||||||
| 			sprintf(buf, "buttons: %c%c%c%c", | 			sprintf(buf, "buttons: %c%c%c%c", | ||||||
| 					((m1.buttons>>3)&1)+'0', | 					((m1.buttons>>3)&1)+'0', | ||||||
| @ -43,8 +75,6 @@ int main() { | |||||||
| 			VDP_drawText(buf, 1, 24); | 			VDP_drawText(buf, 1, 24); | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		MouseData m2; |  | ||||||
| 		read_mouse(&m2, PORT2); |  | ||||||
| 		sprintf(buf, "%X%X%X%X %X %X %X%X %X%X+",  | 		sprintf(buf, "%X%X%X%X %X %X %X%X %X%X+",  | ||||||
| 				m2.nibbles[0], m2.nibbles[1], m2.nibbles[2], m2.nibbles[3], | 				m2.nibbles[0], m2.nibbles[1], m2.nibbles[2], m2.nibbles[3], | ||||||
| 				m2.nibbles[4], m2.nibbles[5], m2.nibbles[6], m2.nibbles[7], | 				m2.nibbles[4], m2.nibbles[5], m2.nibbles[6], m2.nibbles[7], | ||||||
| @ -54,9 +84,22 @@ int main() { | |||||||
| 
 | 
 | ||||||
| 		if(m2.valid) { | 		if(m2.valid) { | ||||||
| 			x2 += m2.dx; y2 += m2.dy; | 			x2 += m2.dx; y2 += m2.dy; | ||||||
| 			if(x2>9999) x2=-9999; else if(x2<-9999) x2=9999; | 			if(x2>304) x2=304; else if(x2<0) x2=0; | ||||||
| 			if(y2>9999) y2=-9999; else if(y2<-9999) y2=9999; | 			if(y2>208) y2=208; else if(y2<0) y2=0; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 			if(!ptr_active2 && btnFront2) { | ||||||
|  | 				u8* code = code2; | ||||||
|  | 				for(int i=1;i<6;i++) code[i-1]=code[i]; | ||||||
|  | 				code[5]=btnFront2; | ||||||
|  | 				if(code[0]==0x4&&code[1]==0x1&&code[2]==0x1&&code[3]==0x2&&code[4]==0x2&&code[5]==0x4){ | ||||||
|  | 					ptr_active2=1; | ||||||
|  | 					ptr2 = SPR_addSprite(&PINKIE_PIE, 0, 0, TILE_ATTR(PAL1, TRUE, FALSE, FALSE)); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			if(ptr_active2) SPR_setPosition(ptr2, x2, 208-y2); | ||||||
|  | 		 | ||||||
| 			sprintf(buf, "buttons: %c%c%c%c", | 			sprintf(buf, "buttons: %c%c%c%c", | ||||||
| 					((m2.buttons>>3)&1)+'0', | 					((m2.buttons>>3)&1)+'0', | ||||||
| 					((m2.buttons>>2)&1)+'0', | 					((m2.buttons>>2)&1)+'0', | ||||||
| @ -71,12 +114,20 @@ int main() { | |||||||
| 			VDP_clearTextArea(25,23,13,1); | 			VDP_clearTextArea(25,23,13,1); | ||||||
| 			VDP_drawText(buf, 1, 25); | 			VDP_drawText(buf, 1, 25); | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		//спрайты
 | ||||||
|  | 
 | ||||||
|  | 		SPR_update(); | ||||||
| 		 | 		 | ||||||
| 		//счётчик кадров для вывода истории нибблов
 | 		//счётчик кадров для вывода истории нибблов
 | ||||||
| 		frame++; | 		frame++; | ||||||
| 
 | 
 | ||||||
| 		//конец кадра
 | 		//конец кадра
 | ||||||
| 		VDP_waitVSync(); | 
 | ||||||
|  | 		//Я не уверен почему, но SYS_doVBlankProcess в какой-то момент вызывал странное поведение. После добавления спрайтов, кажется, всё в порядке.
 | ||||||
|  | 		 | ||||||
|  | 		//VDP_waitVSync();
 | ||||||
|  | 		SYS_doVBlankProcess(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user