Compare commits

..

No commits in common. "0393ac66537adcfee896e2142e4c5cbe436dfc5d" and "f680f7c425fac829476983b707cb946eb017bb63" have entirely different histories.

5 changed files with 8 additions and 70 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 B

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

View File

@ -1,9 +0,0 @@
#include <genesis.h>
#ifndef _RES_RESOURCES_H_
#define _RES_RESOURCES_H_
extern const SpriteDefinition FLUTTERSHY;
extern const SpriteDefinition PINKIE_PIE;
#endif // _RES_RESOURCES_H_

View File

@ -1,2 +0,0 @@
SPRITE FLUTTERSHY "fluttershy.png" 2 2 NONE 0
SPRITE PINKIE_PIE "pinkie_pie.png" 2 2 NONE 0

View File

@ -1,41 +1,21 @@
#include "genesis.h"
#include "mouse.h"
#include "resources.h"
#define PORT1 ((volatile u8*)0xA10003)
#define PORT2 ((volatile u8*)0xA10005)
Sprite* ptr1;
Sprite* ptr2;
int main() {
VDP_setTextPlane(0);
VDP_drawText("Sega Mega Mouse RAW reader", 7, 27);
VDP_drawText("RAW nibbles:", 14,0);
SPR_init();
PAL_setPalette(PAL1, FLUTTERSHY.palette->data, DMA);
s16 x1=0,y1=0, x2=0,y2=0;
u8 frame = 0;
char buf[40]; //буфер строки для вывода на экран
MouseData m1, m2;
u8 code1[6] = {0};
u8 code2[6] = {0};
u8 ptr_active1=0,ptr_active2=0;
while(TRUE) {
//считывание портов и вывод информации
u8 btnFront1=m1.buttons, btnFront2=m2.buttons;
MouseData m1;
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",
m1.nibbles[0], m1.nibbles[1], m1.nibbles[2], m1.nibbles[3],
m1.nibbles[4], m1.nibbles[5], m1.nibbles[6], m1.nibbles[7],
@ -45,20 +25,8 @@ int main() {
if(m1.valid) {
x1 += m1.dx; y1 += m1.dy;
if(x1>304) x1=304; else if(x1<0) x1=0;
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);
if(x1>9999) x1=-9999; else if(x1<-9999) x1=9999;
if(y1>9999) y1=-9999; else if(y1<-9999) y1=9999;
sprintf(buf, "buttons: %c%c%c%c",
((m1.buttons>>3)&1)+'0',
@ -75,6 +43,8 @@ int main() {
VDP_drawText(buf, 1, 24);
}
MouseData m2;
read_mouse(&m2, PORT2);
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[4], m2.nibbles[5], m2.nibbles[6], m2.nibbles[7],
@ -84,22 +54,9 @@ int main() {
if(m2.valid) {
x2 += m2.dx; y2 += m2.dy;
if(x2>304) x2=304; else if(x2<0) x2=0;
if(y2>208) y2=208; else if(y2<0) y2=0;
if(x2>9999) x2=-9999; else if(x2<-9999) x2=9999;
if(y2>9999) y2=-9999; else if(y2<-9999) y2=9999;
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",
((m2.buttons>>3)&1)+'0',
((m2.buttons>>2)&1)+'0',
@ -114,20 +71,12 @@ int main() {
VDP_clearTextArea(25,23,13,1);
VDP_drawText(buf, 1, 25);
}
//спрайты
SPR_update();
//счётчик кадров для вывода истории нибблов
frame++;
//конец кадра
//Я не уверен почему, но SYS_doVBlankProcess в какой-то момент вызывал странное поведение. После добавления спрайтов, кажется, всё в порядке.
//VDP_waitVSync();
SYS_doVBlankProcess();
VDP_waitVSync();
}
return 0;