finish thr bird,can use

master
unknown 3 years ago
parent 1d837fffb8
commit ae697778f7

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,35 @@
#ifndef __ALL_H__
#define __ALL_H__
struct pho {
long color;
long x;
long y;
long dx;
long dy;
};
struct user_timer{
long init_jiffies;
long jiffies;
int type; // 1为一次闹钟
// 0为无数次闹钟
int pid; // 哪个进程创建的定时器
struct user_timer * next;
};
struct message{
long mid;
long pid; //当前进程为-1
};
extern struct message msg_que[1024];
extern void post_message(int type);
// mid取值
#define MSG_MOUSE_LEFT_DOWN 1
#define MSG_MOUSE_RIGHT_DOWN 2
#define MSG_MOUSE_CENTER_DOWN 3
#define MSG_USER_TIMER 4
#define TYPE_USER_TIMER_INFTY 5
#define TYPE_USER_TIMER_ONCE 6
#endif

@ -99,6 +99,7 @@ extern long sys_getcwd();
extern int sys_init_graphics();
extern int sys_get_message();
extern int sys_repaint();
extern int sys_timercreate();
fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read,
sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link,
@ -117,6 +118,7 @@ sys_setrlimit, sys_getrlimit, sys_getrusage, sys_gettimeofday,
sys_settimeofday, sys_getgroups, sys_setgroups, sys_select, sys_symlink,
sys_lstat, sys_readlink, sys_uselib, sys_execve2, sys_getdents, sys_something ,sys_sleep, sys_getcwd
,sys_init_graphics,sys_get_message,sys_repaint
,sys_timercreate
};
/* So we don't have to do any more manual updating.... */

@ -56,15 +56,6 @@ extern struct tty_struct tty_table[];
struct message{
int mid;
int pid;
struct message *next;
};
struct message *headd;
/* intr=^C quit=^| erase=del kill=^U

@ -1,6 +1,7 @@
#ifndef _UNISTD_H
#define _UNISTD_H
#include<linux/tty.h>
#include<all.h>
/* ok, this may be a joke, but I'm working on it */
#define _POSIX_VERSION 198808L
@ -155,6 +156,7 @@
#define __NR_init_graphics 92
#define __NR_get_message 93
#define __NR_repaint 94
#define __NR_timercreate 95
#define _syscall0(type,name) \
type name(void) \
@ -281,9 +283,6 @@ char* getcwd(char *buf,size_t size);
int something(void);
int sleep(unsigned int seconds);
int execve2(const char *path,char *argv[],char *envp[]);
int init_graphics(void);
int get_message(struct message *msg);
int repaint(int x,int y,int h);
#define __always_inline inline __attribute__((always_inline))

@ -137,7 +137,10 @@ void main(void) /* This really IS void, no error here. */
buffer_init(buffer_memory_end);
hd_init();
floppy_init();
//init_graphics();
/*if(init_graphics()<0)
printk("error 1\n");*/
sti();
move_to_user_mode();
if (!fork()) { /* we count on this going ok */

@ -26,7 +26,7 @@ CPP =gcc -E -nostdinc -I../include
OBJS = sched.o system_call.o traps.o asm.o fork.o \
panic.o printk.o vsprintf.o sys.o exit.o \
signal.o mktime.o init_graphics.o
signal.o mktime.o init_graphics.o message.o
kernel.o: $(OBJS)
$(LD) -r -o kernel.o $(OBJS)
@ -67,7 +67,7 @@ sched.s sched.o : sched.c ../include/linux/sched.h ../include/linux/head.h \
../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \
../include/signal.h ../include/linux/kernel.h ../include/linux/sys.h \
../include/linux/fdreg.h ../include/asm/system.h ../include/asm/io.h \
../include/asm/segment.h
../include/asm/segment.h ../include/all.h
signal.s signal.o : signal.c ../include/linux/sched.h ../include/linux/head.h \
../include/linux/fs.h ../include/sys/types.h ../include/linux/mm.h \
../include/signal.h ../include/linux/kernel.h ../include/asm/segment.h
@ -82,4 +82,6 @@ traps.s traps.o : traps.c ../include/string.h ../include/linux/head.h \
../include/asm/system.h ../include/asm/segment.h ../include/asm/io.h
vsprintf.s vsprintf.o : vsprintf.c ../include/stdarg.h ../include/string.h
init_graphics.s init_graphi.o:init_graphics.c ../include/linux/kernel.h\
../include/asm/io.h ../include/linux/tty.h
../include/asm/io.h ../include/all.h ../include/asm/segment.h
message.s message.o:message.c ../include/linux/sched.h\
../include/asm/segment.h ../include/all.h

@ -60,7 +60,7 @@ tty_io.s tty_io.o : tty_io.c ../../include/ctype.h ../../include/errno.h \
../../include/linux/sched.h ../../include/linux/head.h \
../../include/linux/fs.h ../../include/linux/mm.h ../../include/linux/tty.h \
../../include/termios.h ../../include/asm/segment.h \
../../include/asm/system.h
../../include/asm/system.h ../../include/all.h
tty_ioctl.s tty_ioctl.o : tty_ioctl.c ../../include/errno.h ../../include/termios.h \
../../include/linux/sched.h ../../include/linux/head.h \
../../include/linux/fs.h ../../include/sys/types.h ../../include/linux/mm.h \

@ -349,7 +349,7 @@ void chr_dev_init(void)
{
}
#include<all.h>
#define MSG_MOUSE_CLICK 1
static unsigned char mouse_input_count = 0; //用来记录是鼠标输入的第几个字节的全局变量
static unsigned char mouse_left_down; //用来记录鼠标左键是否按下
@ -359,17 +359,11 @@ static unsigned char mouse_down_move;//用来记录鼠标是否向下移动
static int mouse_x_position; //用来记录鼠标的 x 轴位置
static int mouse_y_position;//用来记录鼠标的 y 轴位置
static int fcreate=0;
int cnt=0;
extern struct message *headd;
void readmouse(int mousecode)
{
//printk("1\n");
if(fcreate==0)
{
fcreate=1;
cnt=33;
}
//reset the condition of all mouse
if(mousecode==0xFA || mouse_input_count>=4 )
@ -378,10 +372,7 @@ if(mousecode==0xFA || mouse_input_count>=4 )
return ;
}
if(cnt!=mousecode)
{
cnt=mousecode;
}
switch(mouse_input_count)
{
case 1:
@ -394,30 +385,38 @@ case 1:
mouse_input_count++;
if(mouse_left_down==1 && mouse_left_move==0 && mouse_down_move==0)
{
struct message *msg = malloc(sizeof(struct message));
msg -> mid = MSG_MOUSE_CLICK;
msg -> pid = -1;
post_message(msg);
#ifdef CK_DEBUG
printk("[readmouse]MSG_MOUSE_LEFT_DOWN\n");
#endif
post_message(MSG_MOUSE_LEFT_DOWN);
}
if (mouse_right_down)
{
#ifdef CK_DEBUG
printk("[readmouse]MSG_MOUSE_RIGHT_DOWN\n");
#endif
post_message(MSG_MOUSE_RIGHT_DOWN);
}
break;
case 2:
//get the x of mouse
if(mouse_left_move) mouse_x_position +=(int)(0xFFFFFF00|mousecode);
if(mouse_x_position>100) mouse_x_position=100;
if(mouse_x_position<0) mouse_x_position=0;
if(mouse_left_move)
mouse_x_position +=(int)(0xFFFFFF00|mousecode);
/*if(mouse_x_position>100) mouse_x_position=100;
if(mouse_x_position<0) mouse_x_position=0;*/
mouse_input_count++;
break;
case 3:
//get the y of mouse
if(mouse_down_move) mouse_y_position +=(int)(0xFFFFFF00|mousecode);
if(mouse_y_position>100) mouse_y_position=100;
if(mouse_y_position<0) mouse_y_position=0;
if(mouse_down_move)
mouse_y_position +=(int)(0xFFFFFF00|mousecode);
/*if(mouse_y_position>100) mouse_y_position=100;
if(mouse_y_position<0) mouse_y_position=0;*/
mouse_input_count++;
break;
@ -432,25 +431,3 @@ if(mouse_input_count==4)
}
//sys_init_graphics();
}
void post_message(struct message * msg)
{
cli();
//printk("mid:%d pid:%d\n",msg->mid,msg->pid);
if(headd==NULL&& msg!=NULL)
{
headd=msg;
sti();
return ;
}
struct message *curr=headd;
if(msg==NULL)return;
while(curr->next!=NULL)
{
curr=curr->next;
}
curr->next=msg;
sti();
return;
}

@ -1,21 +1,16 @@
#include <linux/kernel.h>
#include<asm/io.h>
#include "linux/tty.h"
#define memstart 0xA0000
#define memsize 64000
#define cursor_side 3
#define width 320
#define height 200
#define barrier_width 10
struct message *headd;
static int ff=0;
#include <asm/io.h>
#include <all.h>
#include <asm/segment.h>
#define vga_graph_memstart 0xA0000
#define vga_graph_memsize 64000
#define cursor_side 6
#define vga_width 320
#define vga_heignt 200
int sys_init_graphics()
{
int i,j,x,y;
char *p=0xA0000;
if(ff==0)
{
outb(0x05,0x3CE);
outb(0x05,0x3CE);
outb(0x40,0x3CF);/* shift256=1*/
outb(0x06,0x3CE);
outb(0x05,0x3CF);/*0101 0xA0000*/
@ -46,60 +41,31 @@ outb(0x05,0x3CE);
outb(0x00,0x3D5);/**/
outb(0x0D,0x3D4);/**/
outb(0x00,0x3D5);/*Start Address=0xA0000*/
ff=1;
}
p=memstart;
for(i=0;i<memsize;i++) *p++=3;
//3-blue 4-red 12-purple
x=50;
y=40;
for(i=x-cursor_side;i<=x+cursor_side;i++)
for(j=y-cursor_side;j<=y+cursor_side;j++){
p=(char *) memstart+j*width+i;
*p=12;
}
int i;
char * p;
p = (char *)vga_graph_memstart;
for (i = 0; i < vga_graph_memsize; ++i)
*p++ = 3;
return 0;
}
int sys_get_message(struct message * msg)
int sys_repaint(struct pho * pho)
{
msg=headd;
if(headd->mid!=1)return 0;
headd=headd->next;
int i, j;
char * p;
long color = get_fs_long(&pho->color);
long x = get_fs_long(&pho->x);
long y = get_fs_long(&pho->y);
long dx = get_fs_long(&pho->dx);
long dy = get_fs_long(&pho->dy);
for (i = x; i < x+dx; ++i) if (0 <= i && i < vga_width)
for (j = y; j < y+dy; ++j) if (0 <= j && j < vga_heignt){
p = (char *)vga_graph_memstart + vga_width*j + i;
*p = color;
}
return 0;
}
int sys_repaint(int x,int y,int h)
{
int i,j,w;
char *p;
i=x;
j=y;
p=0xA0000;
w=barrier_width;
if(i+w>=320 || i<20 ) return 0;
if(i==33 || j==33){
p=0xA0000;
for(i=0;i<memsize;i++) *p++=3;
return 0;
}
else if(i==44 || j==44 ){
p=0xA0000;
for(i=0;i<memsize;i++) *p++=4;
return 0;
}else{
for(i=x;i<=x+w;i++){
for(j=y;j<=y+h;j++){
p=0xA0000+j*320+i;
*p=12;
}
}
}
return 0;
}

@ -0,0 +1,28 @@
#include<linux/sched.h>
#include<asm/segment.h>
#include<all.h>
struct message msg_que[1024];
unsigned int msg_que_fron = NULL, msg_que_rear = NULL;
void post_message(int type){
if (msg_que_rear != msg_que_fron - 1) {
struct message msg;
msg.mid = type;
msg.pid = current->pid;
msg_que[msg_que_rear] = msg;
msg_que_rear = (msg_que_rear + 1) % 1024;
}
}
int sys_get_message(struct message *msg) {
struct message tmp;
if(msg_que_rear == msg_que_fron){
put_fs_long(-1,&msg->mid);
put_fs_long(-1,&msg->pid);
return;
}
tmp = msg_que[msg_que_fron];
msg_que[msg_que_fron].mid = 0;
msg_que_fron = (msg_que_fron + 1) % 1024;;
put_fs_long(tmp.mid,&msg->mid);
put_fs_long(current->pid,&msg->pid);
}

@ -302,11 +302,65 @@ void add_timer(long jiffies, void (*fn)(void))
sti();
}
#include <all.h>
struct user_timer * user_timer_list = NULL;
int sys_timercreate(long ms, int type)
{
struct user_timer * timer = malloc(sizeof(struct user_timer));
long jiffies = ms / 10;
timer->jiffies = timer->init_jiffies = jiffies;
timer->pid = current->pid;
timer->type = type;
timer->next = user_timer_list;
user_timer_list = timer;
return 0;
}
void do_timer(long cpl)
{
extern int beepcount;
extern void sysbeepstop(void);
struct user_timer * timer = user_timer_list;
struct user_timer * prev = NULL;
while(timer != NULL)
{
if ((--timer->jiffies) <= 0) {
post_message(MSG_USER_TIMER);
switch(timer->type) {
case TYPE_USER_TIMER_INFTY:
timer->jiffies = timer->init_jiffies;
prev = timer;
timer = timer->next;
break;
case TYPE_USER_TIMER_ONCE:
if (prev == NULL) {
free(timer);
timer = NULL;
user_timer_list = NULL;
}
else {
prev->next = timer->next;
free(timer);
timer = prev->next;
}
break;
default:
break;
}
}
else
{
prev = timer;
timer = timer->next;
}
}
if (beepcount)
if (!--beepcount)
sysbeepstop();

@ -58,7 +58,7 @@ sa_mask = 4
sa_flags = 8
sa_restorer = 12
nr_system_calls = 96 /* 72 the number of system*/
nr_system_calls =97 /* 72 the number of system*/
/*
* Ok, I get parallel printer interrupts while using the floppy for some

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,10 @@
#define __LIBRARY__
#include<unistd.h>
#include<all.h>
_syscall0(int,init_graphics)
int main(void)
{
init_graphics();
}

@ -1,19 +1,10 @@
#define __LIBRARY__
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<all.h>
_syscall0(int,initgraphics)
_syscall1(void ,get_message ,struct message ,* msg)
int main()
int main(void)
{
struct message *msg;
int i;
for(i=0;i<10;i++)
{
get_message(msg);
printf("mid:%d pid:%d\n",msg->mid,msg->pid);
}
return 0;
initgraphics();
}

@ -0,0 +1,16 @@
#define __LIBRARY__
#include<all.h>
#include<unistd.h>
_syscall0(int,init_graphics);
_syscall1(int,repaint,struct pho *,pho);
int main(void)
{
struct pho my_rect;
init_graphics();
my_rect.color = 12;
my_rect.x = 50;
my_rect.y = 50;
my_rect.dx = 10;
my_rect.dy = 10;
repaint(&my_rect);
}

@ -0,0 +1,33 @@
#define __LIBRARY__
#include <unistd.h>
#include <stdio.h>
#include <all.h>
_syscall1(int,get_message,struct message *,msg);
_syscall2(int,timercreate,long,ms,int,type);
struct message msg;
int main()
{
timercreate(1000,TYPE_USER_TIMER_INFTY);
while(1)
{
get_message(&msg);
/* printf("msg.mid:%d\n", msg.mid); */
if (msg.mid > 0)
{
switch(msg.mid)
{
case MSG_USER_TIMER:
printf("MSG_USER_TIMER\n");
break;
case MSG_MOUSE_LEFT_DOWN:
printf("MSG_MOUSE_LEFT_DOWN\n");
break;
case MSG_MOUSE_RIGHT_DOWN:
printf("MSG_MOUSE_RIGHT_DOWN\n");
break;
}
}
}
}

@ -0,0 +1,33 @@
#define __LIBRARY__
#include <unistd.h>
#include <stdio.h>
#include <all.h>
_syscall1(void,get_message,struct message *,msg);
_syscall2(int,timercreate,long,ms,int,type);
struct message msg;
int main()
{
timercreate(1000,TYPE_USER_TIMER_INFTY);
while(1)
{
get_message(&msg);
/* printf("msg.mid:%d\n", msg.mid); */
if (msg.mid > 0)
{
switch(msg.mid)
{
case MSG_USER_TIMER:
printf("MSG_USER_TIMER\n");
break;
case MSG_MOUSE_LEFT_DOWN:
printf("MSG_MOUSE_LEFT_DOWN\n");
break;
case MSG_MOUSE_RIGHT_DOWN:
printf("MSG_MOUSE_RIGHT_DOWN\n");
break;
}
}
}
}

@ -0,0 +1,35 @@
#ifndef __ALL_H__
#define __ALL_H__
struct pho {
long color;
long x;
long y;
long dx;
long dy;
};
struct user_timer{
long init_jiffies;
long jiffies;
int type;
int pid;
struct user_timer * next;
};
struct message{
long mid;
long pid;
} message;
extern struct message msg_que[1024];
extern void post_message(int type);
#define MSG_MOUSE_LEFT_DOWN 1
#define MSG_MOUSE_RIGHT_DOWN 2
#define MSG_MOUSE_CENTER_DOWN 3
#define MSG_USER_TIMER 4
#define TYPE_USER_TIMER_INFTY 5
#define TYPE_USER_TIMER_ONCE 6
#endif

@ -0,0 +1,35 @@
#ifndef __ALL_H__
#define __ALL_H__
struct pho {
long color;
long x;
long y;
long dx;
long dy;
};
struct user_timer{
long init_jiffies;
long jiffies;
int type; // 1为一次闹钟
// 0为无数次闹钟
int pid; // 哪个进程创建的定时器
struct user_timer * next;
};
struct message{
long mid;
long pid; //当前进程为-1
} message;
extern struct message msg_que[1024];
extern void post_message(int type);
// mid取值
#define MSG_MOUSE_LEFT_DOWN 1
#define MSG_MOUSE_RIGHT_DOWN 2
#define MSG_MOUSE_CENTER_DOWN 3
#define MSG_USER_TIMER 4
#define TYPE_USER_TIMER_INFTY 5
#define TYPE_USER_TIMER_ONCE 6
#endif

@ -1,100 +1,178 @@
#define __LIBRARY__
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<errno.h>
#include<time.h>
#include<linux/tty.h>
#define vga_graph_memstart 0xA0000
#define vga_graph_memsize 64000
#define cursor_side 6
#define vga_width 320
#define vga_height 200
#include<all.h>
#define BIRD_X 120
#define BIRD_Y 100
#define BIRD_WIDTH 10
#define BIRD_HEIGHT 8
#define MAX 40
char *p;
int i,j,x_pos,y_pos,k;
struct message *msg;
int cnt;
int bird_y;
int px[MAX];
int py[MAX];
int h[MAX];
char *pp;
int ii,jj;
int nn;
#define MAX_BARRIER 20
#define CLOCK_TRIGGER 400
#define DROP_PER_TRIGGER 1
#define UP_PER_CLICK 10
#define LEFT_PER_TRIGGER 1
#define BIRD_COLOR 12
#define BARRIER_COLOR 12
#define BACKGROUND_COLOR 3
#define GAME_OVER_COLOR 12
#define VAG_WIDTH 320
#define VGA_HEIGHT 200
#define BARRIER_WIDTH 10
#define BARRIER_INTERVAL 20
#define BARRIER_HEIGHT (rand()%(VGA_HEIGHT*3/4))
_syscall0(int,init_graphics)
_syscall1(int,get_message,struct message * ,msg)
_syscall3(int,repaint,int ,x,int ,y,int ,h)
_syscall1(int,repaint,struct pho *,pho)
_syscall2(int,timercreate,long,ms,int,type)
int fron, rear;
struct pho barrier[MAX_BARRIER];
int i;
struct message msg;
struct pho obj;
struct pho background0,gameover;
struct pho bird;
int init_all()
{
bird.x = BIRD_X;
bird.y = BIRD_Y;
bird.dx = BIRD_WIDTH;
bird.dy = BIRD_HEIGHT;
bird.color = BIRD_COLOR;
fron = rear = 0;
background0.color = BACKGROUND_COLOR;
background0.x = 0;
background0.y = 0;
background0.dx = VAG_WIDTH;
background0.dy = VGA_HEIGHT;
gameover.color = GAME_OVER_COLOR;
gameover.x = 0;
gameover.y = 0;
gameover.dx = VAG_WIDTH;
gameover.dy = VGA_HEIGHT;
return 0;
}
/*paint*/
int paint_barrier(void) /*paint barrier*/
{
int i;
struct pho rect;
for (i = fron; i != rear; i = (i+1)%MAX_BARRIER) {
rect.color = BARRIER_COLOR;
rect.x = barrier[i].x;
rect.y = barrier[i].y;
rect.dx = barrier[i].dx;
rect.dy = barrier[i].dy;
if (repaint(&rect) < 0)
return -1;
}
return 0;
}
int paint_all()/*all*/
{
if (repaint(&background0) < 0)
return -1;
if (repaint(&bird) < 0)
return -1;
if (paint_barrier() < 0)
return -1;
return 0;
}
int push_obj(struct pho * obj) {
if (rear != (fron + MAX_BARRIER - 1) % MAX_BARRIER) {
barrier[rear].x = obj->x;
barrier[rear].y = obj->y;
barrier[rear].dx = obj->dx;
barrier[rear].dy = obj->dy;
rear = (rear + 1) % MAX_BARRIER;
return 0;
}
return -1;
}
int pop_obj(struct pho * obj) {
if (rear == fron)
return -1;
if (obj != NULL) {
obj->x = barrier[fron].x;
obj->y = barrier[fron].y;
obj->dx = barrier[fron].dx;
obj->dy = barrier[fron].dy;
}
fron = (fron + 1) % MAX_BARRIER;
return 0;
}
int main()
{
x_pos=20;
y_pos=20;
bird_y=BIRD_Y;
init_graphics();
px[0]=BIRD_X;
py[0]=bird_y;
h[0]=BIRD_HEIGHT;
cnt=30;
for(i=1;i<cnt;i++)
{
if(i%2==0)
{
px[i]=120+20*i;
py[i]=0;
h[i]=90+i*2;
}
timercreate(CLOCK_TRIGGER, TYPE_USER_TIMER_INFTY); /* create time */
init_graphics(); /*Graphical interface*/
if(init_all()!=0)/*initialize*/
{printf("bird error 1\n");return -1;}
while(1)
{ //sleep(1);
get_message(&msg);
if(msg.mid<0)
continue;
if(msg.mid==MSG_MOUSE_LEFT_DOWN)
{bird.y -= UP_PER_CLICK;}
else
{
px[i]=30+20*i;
h[i]=h[i-1]-13*i%17;
py[i]=200-1-h[i];
}
}
msg=NULL;
nn=50;
while(--nn)
{
repaint(px[0],py[0],h[0]);
for(i=1;i<cnt;i++)
{
px[i]-=20;
repaint(px[i],py[i],h[i]);
}
k=3;
while(k>0)
{
--k;
get_message(msg);
if(msg!=NULL)py[0]-=10;
sleep(2);
}
sleep(4);
for(k=1;k<cnt;k++)
{
if(k%2==0)
if(px[0]+6>px[k] && px[0]+6<px[k]+10 && py[0]<h[k])
{
repaint(44,44,44);
return 0;
}else{
if(px[0]+6>px[k] && px[0]+6<px[k]+10 && py[0]+6+h[k]>199)
{
repaint(44,44,44);
return 0;
}
}
}
{bird.y += DROP_PER_TRIGGER;}
if(paint_all() != 0)
{printf("bird error 2\n");return -1;}
for (i = fron; i != rear; i = (i+1)%MAX_BARRIER) /*Determine if the game has failed*/
if (barrier[i].x < bird.x+bird.dx && bird.x < barrier[i].x+barrier[i].dx)
if (barrier[i].y < bird.y+bird.dy && bird.y < barrier[i].y+barrier[i].dy)
{
repaint(&gameover);
return 0;
}
for (i = fron; i != rear; i = (i+1)%MAX_BARRIER) /* bird is stationary ,need barriers move*/
barrier[i].x -= LEFT_PER_TRIGGER;
if (fron == rear) /* there is no barriers,add barriers */
{
obj.dx = BARRIER_WIDTH;
obj.dy = BARRIER_HEIGHT;
obj.x = VAG_WIDTH;
obj.y = 0;
push_obj(&obj);
}
else /* add new barriers,delete old barriers */
{
if (barrier[(rear+MAX_BARRIER-1)%MAX_BARRIER].x+barrier[(rear+MAX_BARRIER-1)%MAX_BARRIER].dx+BARRIER_INTERVAL <= VAG_WIDTH) {
obj.dx = BARRIER_WIDTH;
obj.dy = BARRIER_HEIGHT;
obj.x = VAG_WIDTH;
if (barrier[(rear+MAX_BARRIER-1)%MAX_BARRIER].y)
obj.y = 0;
else
obj.y = VGA_HEIGHT - obj.dy;
push_obj(&obj);
}
if (barrier[fron].x+barrier[fron].dx <= 0)
pop_obj(NULL);
}
}
repaint(44,44,44);
repaint(&gameover);
return 0;
}

Binary file not shown.

@ -1,19 +0,0 @@
#define __LIBRARY__
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
_syscall1(void ,get_message ,struct message ,* msg)
int main()
{
struct message *msg;
int i;
for(i=0;i<10;i++)
{
get_message(msg);
printf("mid:%d pid:%d\n",msg->mid,msg->pid);
}
return 0;
}

@ -99,6 +99,7 @@ extern long sys_getcwd();
extern int sys_init_graphics();
extern int sys_get_message();
extern int sys_repaint();
extern int sys_timercreate();
fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read,
sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link,
@ -117,6 +118,7 @@ sys_setrlimit, sys_getrlimit, sys_getrusage, sys_gettimeofday,
sys_settimeofday, sys_getgroups, sys_setgroups, sys_select, sys_symlink,
sys_lstat, sys_readlink, sys_uselib, sys_execve2, sys_getdents, sys_something ,sys_sleep, sys_getcwd
,sys_init_graphics,sys_get_message,sys_repaint
,sys_timercreate
};
/* So we don't have to do any more manual updating.... */

Binary file not shown.

@ -56,15 +56,6 @@ extern struct tty_struct tty_table[];
struct message{
int mid;
int pid;
struct message *next;
};
struct message *headd;
/* intr=^C quit=^| erase=del kill=^U

@ -1,6 +1,7 @@
#ifndef _UNISTD_H
#define _UNISTD_H
#include<linux/tty.h>
#include<all.h>
/* ok, this may be a joke, but I'm working on it */
#define _POSIX_VERSION 198808L
@ -155,6 +156,7 @@
#define __NR_init_graphics 92
#define __NR_get_message 93
#define __NR_repaint 94
#define __NR_timercreate 95
#define _syscall0(type,name) \
type name(void) \
@ -281,9 +283,6 @@ char* getcwd(char *buf,size_t size);
int something(void);
int sleep(unsigned int seconds);
int execve2(const char *path,char *argv[],char *envp[]);
int init_graphics(void);
int get_message(struct message *msg);
int repaint(int x,int y,int h);
#define __always_inline inline __attribute__((always_inline))

@ -31,7 +31,7 @@
00000000000i[ ] Sound support: no
00000000000i[ ] USB support: no
00000000000i[ ] VGA extension support: vbe
00000000000i[MEM0 ] allocated memory at 0xb591b008. after alignment, vector=0xb591c000
00000000000i[MEM0 ] allocated memory at 0xb5852008. after alignment, vector=0xb5853000
00000000000i[MEM0 ] 16.00MB
00000000000i[MEM0 ] mem block size = 0x00020000, blocks=128
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/local/share/bochs/BIOS-bochs-latest')
@ -42,7 +42,7 @@
00000000000i[DEV ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
00000000000i[PLUGIN] init_dev of 'cmos' plugin device by virtual method
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Fri Jul 1 04:51:49 2022 (time0=1656647509)
00000000000i[CMOS ] Setting initial clock to: Sun Jul 3 18:58:25 2022 (time0=1656871105)
00000000000i[PLUGIN] init_dev of 'dma' plugin device by virtual method
00000000000i[DMA ] channel 4 used by cascade
00000000000i[PLUGIN] init_dev of 'pic' plugin device by virtual method
@ -60,7 +60,7 @@
00000000000i[FLOPPY] fd0: 'cur/linux/Image' ro=0, h=2,t=80,spt=18
00000000000i[IMG ] redolog : Standard Header : magic='Bochs Virtual HD Image', type='Redolog', subtype='Volatile', version = 2.0
00000000000i[IMG ] redolog : Specific Header : #entries=512, bitmap size=1, exent size = 4096 disk size = 1474560
00000000000i[IMG ] 'vvfat' disk opened: directory is 'b/', redolog is 'b//vvfat.dir.3Ca5jm'
00000000000i[IMG ] 'vvfat' disk opened: directory is 'b/', redolog is 'b//vvfat.dir.WB8N6e'
00000000000i[FLOPPY] fd1: 'vvfat:b/' ro=0, h=2,t=80,spt=18
00000000000i[FLOPPY] Using boot sequence floppy, none, none
00000000000i[FLOPPY] Floppy boot signature check is enabled
@ -185,12 +185,11 @@
00001647811i[BXVGA ] VBE known Display Interface b0c0
00001647843i[BXVGA ] VBE known Display Interface b0c5
00001650768i[VBIOS ] VBE Bios $Id: vbe.c,v 1.64 2011/07/19 18:25:05 vruppert Exp $
00001869270i[XGUI ] charmap update. Font is 9 x 16
00001995333i[BIOS ] ata0-0: PCHS=512/2/20 translation=none LCHS=512/2/20
00002706255i[XGUI ] charmap update. Font is 9 x 16
00005872240i[BIOS ] IDE time out
00051753879i[BIOS ] Booting from 0000:7c00
00096790235i[FLOPPY] partial read() on floppy image returns 400/512
00096956900i[FLOPPY] read() on floppy image returns 0
00096956900i[FLOPPY] partial read() on floppy image returns 176/512
00097123565i[FLOPPY] read() on floppy image returns 0
00097290230i[FLOPPY] read() on floppy image returns 0
00097456895i[FLOPPY] read() on floppy image returns 0
@ -308,27 +307,29 @@
00116129680i[FLOPPY] read() on floppy image returns 0
00116296345i[FLOPPY] read() on floppy image returns 0
00116467319i[BIOS ] int13_harddisk: function 15, unmapped device for ELDL=81
00227715000i[XGUI ] Mouse capture on
00576540000i[ ] cpu loop quit, shutting down simulator
00576540000i[CPU0 ] CPU is in protected mode (active)
00576540000i[CPU0 ] CS.mode = 32 bit
00576540000i[CPU0 ] SS.mode = 32 bit
00576540000i[CPU0 ] EFER = 0x00000000
00576540000i[CPU0 ] | EAX=0001eb04 EBX=00090080 ECX=0001da20 EDX=00000000
00576540000i[CPU0 ] | ESP=0001e9cc EBP=0002482c ESI=000900a0 EDI=00023840
00576540000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf sf zf af pf cf
00576540000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00576540000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 00ffffff 1 1
00576540000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 00ffffff 1 1
00576540000i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 00ffffff 1 1
00576540000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 00ffffff 1 1
00576540000i[CPU0 ] | FS:0017( 0002| 1| 3) 00000000 0009ffff 1 1
00576540000i[CPU0 ] | GS:0017( 0002| 1| 3) 00000000 0009ffff 1 1
00576540000i[CPU0 ] | EIP=00006e3e (00006e3e)
00576540000i[CPU0 ] | CR0=0x8000001b CR2=0x0804253c
00576540000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
00576540000i[CPU0 ] 0x00006e3e>> mov eax, dword ptr ds:[eax] : 8B00
00576540000i[CMOS ] Last time is 1656647547 (Fri Jul 1 04:52:27 2022)
00576540000i[XGUI ] Exit
00576540000i[ ] restoring default signal behavior
00576540000i[SIM ] quit_sim called with exit code 1
00466849828i[FLOPPY] controller reset in software
00474778409i[FLOPPY] io_write: config control register: 0x00
01161045000i[XGUI ] Mouse capture on
04416915000i[ ] cpu loop quit, shutting down simulator
04416915000i[CPU0 ] CPU is in protected mode (active)
04416915000i[CPU0 ] CS.mode = 32 bit
04416915000i[CPU0 ] SS.mode = 32 bit
04416915000i[CPU0 ] EFER = 0x00000000
04416915000i[CPU0 ] | EAX=00fc1000 EBX=00090080 ECX=000055f0 EDX=00000000
04416915000i[CPU0 ] | ESP=0001eaec EBP=0002692c ESI=000900a0 EDI=00023940
04416915000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf sf zf AF pf cf
04416915000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
04416915000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 00ffffff 1 1
04416915000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 00ffffff 1 1
04416915000i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 00ffffff 1 1
04416915000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 00ffffff 1 1
04416915000i[CPU0 ] | FS:0017( 0002| 1| 3) 00000000 0009ffff 1 1
04416915000i[CPU0 ] | GS:0017( 0002| 1| 3) 00000000 0009ffff 1 1
04416915000i[CPU0 ] | EIP=00006dce (00006dce)
04416915000i[CPU0 ] | CR0=0x8000001b CR2=0x0805740c
04416915000i[CPU0 ] | CR3=0x00000000 CR4=0x00000000
04416915000i[CPU0 ] 0x00006dce>> mov eax, dword ptr ss:[esp+16] : 8B442410
04416915000i[CMOS ] Last time is 1656871399 (Sun Jul 3 19:03:19 2022)
04416915000i[XGUI ] Exit
04416915000i[ ] restoring default signal behavior
04416915000i[SIM ] quit_sim called with exit code 1

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save