Skip to content

Commit 329b5c8

Browse files
committed
modify a lot of file to support stoneQ
- Makefiles. - move stone.c directory - change name to stoneQ to datablock
1 parent bb81930 commit 329b5c8

8 files changed

Lines changed: 43 additions & 23 deletions

File tree

step_3/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ LOADER=loader
1111
ROOT=..
1212
FILESYSTEM=filesystem
1313
USER=user
14-
all: $(USER)/stone.bin $(KERNEL)/kernel.bin $(LOADER)/loader.bin build cleangch
14+
STONE=stone
15+
all: $(USER)/$(STONE)/stoneQ.bin $(KERNEL)/kernel.bin $(LOADER)/loader.bin build cleangch
1516

1617
$(KERNEL)/kernel.bin:
1718
echo "\n"
@@ -43,7 +44,7 @@ $(FILESYSTEM)/datablock.bin:
4344
cd $(FILESYSTEM)/ && make
4445
cd $(ROOT)/
4546

46-
$(USER)/stone.bin:
47+
$(USER)/$(STONE)/stoneQ.bin:
4748
echo "\n"
4849
cd $(USER)/ && make
4950
cd $(ROOT)/
@@ -56,7 +57,7 @@ build: $(LOADER)/loader.bin $(FILESYSTEM)/DBR.bin $(FILESYSTEM)/FAT.bin $(FILESY
5657
dd if=$(FILESYSTEM)/FAT.bin of=OS.img conv=notrunc oflag=seek_bytes seek=3584
5758
dd if=$(FILESYSTEM)/datablock.bin of=OS.img conv=notrunc oflag=seek_bytes seek=6656
5859
dd if=$(KERNEL)/kernel.bin of=OS.img conv=notrunc oflag=seek_bytes seek=7680
59-
dd if=$(USER)/stone.bin of=OS.img conv=notrunc oflag=seek_bytes seek=12800
60+
dd if=$(USER)/$(STONE)/stoneQ.bin of=OS.img conv=notrunc oflag=seek_bytes seek=12800
6061
clean:
6162
echo "\n"
6263
find . -name "*.bin" -type f -delete

step_3/filesystem/datablock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ FAT_ITEM msg = {
6464
0
6565
};
6666
FAT_ITEM user_program = {
67-
"stone",
67+
"stoneQ",
6868
"bin",
6969
FAT_rw,
7070
0, 0, 0, 0, 0, 0,

step_3/kernel/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ ROOT=..
99
INCLUDE=../include
1010
USER=../user
1111
FILESYSTEM=../filesystem
12+
STONE=stone
1213

1314
USER_HEADER=$(USER)/user.h $(USER)/terminal.h
14-
USER_OBJ=$(USER)/user.o $(USER)/terminal.o $(USER)/stone.o
15+
USER_OBJ=$(USER)/user.o $(USER)/terminal.o $(USER)/$(STONE)/stoneQ.o
1516

1617
all: kernel.bin
1718

@@ -31,6 +32,9 @@ $(INCLUDE)/mystring.o:
3132
$(FILESYSTEM)/fsutilities.o:
3233
cd $(FILESYSTEM)/ && make
3334
cd ../kernel
35+
$(USER)/$(STONE)/stoneQ.o:
36+
cd $(USER)/ && make
37+
cd ../kernel
3438
clean:
3539
rm *.bin -f
3640
rm *.o -f

step_3/user/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ AS=nasm
66
ASFLAGS=
77

88
UTILITIES=../include
9-
10-
all: user.o terminal.o stone.bin
9+
STONE=stone
10+
all: user.o terminal.o $(STONE)/stoneQ.bin
1111

1212
user.o: user.c $(UTILITIES)/utilities.h
1313
$(CC) $(CCFLAGS) -c $^
14-
terminal.o: terminal.c $(UTILITIES)/utilities.h stone.h
14+
terminal.o: terminal.c $(UTILITIES)/utilities.h
1515
$(CC) $(CCFLAGS) -c $^
1616

17-
stone.bin: stone.o $(UTILITIES)/utilities.o
17+
$(STONE)/stoneQ.bin: $(STONE)/stoneQ.o $(UTILITIES)/utilities.o
1818
$(LD) $(LDFLAGS) -Ttext 0x6C00 --oformat binary -o $@ $^
19-
stone.o: stone.c $(UTILITIES)/utilities.h
20-
$(CC) $(CCFLAGS) -c $^
19+
$(STONE)/stoneQ.o: $(STONE)/stone.c $(UTILITIES)/utilities.h
20+
$(CC) $(CCFLAGS) -c $< -D UL -o $@
2121

2222
$(UTILITIES)/utilities.o:
2323
cd $(UTILITIES)/ && make

step_3/user/stone.h

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
__asm__("jmpl $0, $stone\n");
22

3-
#include "../include/utilities.h"
3+
#include "../../include/utilities.h"
4+
#include "stone.h"
45
#define DELAY (1e5)
56
int getKbHit();
67
void checkBound();
@@ -11,8 +12,8 @@ int deltax;
1112
int deltay;
1213
int stone() {
1314
// return 0;
14-
x = 5;
15-
y = 5;
15+
x = _X;
16+
y = _Y;
1617
deltax = 1;
1718
deltay = 1;
1819

@@ -41,8 +42,8 @@ int getKbHit() {
4142
return 0;
4243
}
4344
void checkBound() {
44-
if (x == 0) deltax = 1;
45-
if (x == 79) deltax = -1;
46-
if (y == 0) deltay = 1;
47-
if (y == 24) deltay = -1;
45+
if (x <= LEFT_B) deltax = 1;
46+
if (x >= RIGHT_B) deltax = -1;
47+
if (y <= UP_B) deltay = 1;
48+
if (y >= DOWN_B) deltay = -1;
4849
}

step_3/user/stone/stone.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef __STONE_H_
2+
#define __STONE_H_
3+
#if defined(UL)
4+
#define _X 5
5+
#define _Y 5
6+
#define LEFT_B 1
7+
#define RIGHT_B 40
8+
#define UP_B 1
9+
#define DOWN_B 12
10+
#elif defined(UR)
11+
#define _X 70
12+
#define _Y 5
13+
#define LEFT_B 40
14+
#define RIGHT_B 79
15+
#define UP_B 1
16+
#define DOWN_B 12
17+
#endif
18+
19+
#endif

step_3/user/terminal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "../include/utilities.h"
22
#include "../include/mystring.h"
3-
#include "stone.h"
43
#include "../filesystem/API/fsapi.h"
54

65
#define BACK_SPACE 8

0 commit comments

Comments
 (0)