Skip to content

Commit b208636

Browse files
authored
Merge pull request #9 from tolik518/link-connection
2 parents 4b97ed1 + afc6125 commit b208636

7 files changed

Lines changed: 291 additions & 86 deletions

File tree

code/include/gba-link-connection-c

Submodule gba-link-connection-c updated from cd1c9ea to cca9e7a

code/source/game.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <../include/maxmod.h>
99
#include <../build/soundbank.h>
1010
#include <../build/soundbank_bin.h>
11+
#include <../include/gba-link-connection-c/link_connection.h>
12+
1113

1214
void Game_renderPlayer(Paddle *p)
1315
{
@@ -79,12 +81,14 @@ void Game_removePauseText()
7981
tte_erase_rect((SCREEN_WIDTH/2)-40, (SCREEN_HEIGHT/2)-5, (SCREEN_WIDTH/2)+40, (SCREEN_HEIGHT/2)+6);
8082
}
8183

82-
void Game_gameLoop()
84+
void Game_gameLoop(LinkConnection *conn)
8385
{
8486
int _frame = 0;
8587
int *frame = &_frame;
8688

87-
Scene_showTitlescreen(frame);
88-
Scene_showGamescreen(frame);
89+
lc_activate(conn);
90+
91+
Scene_showTitlescreen(frame, conn);
92+
Scene_showGamescreen(frame, conn);
8993
Scene_showLosingscreen(frame);
9094
}

code/source/game.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
typedef struct paddle Paddle;
55
typedef struct ball Ball;
6+
typedef struct LinkConnection LinkConnection;
67

78
#define BG_COLOR 1
89

@@ -19,7 +20,7 @@ typedef struct game
1920
} Game;
2021

2122

22-
void Game_gameLoop();
23+
void Game_gameLoop(LinkConnection *conn);
2324
void Game_renderPlayer(Paddle *p);
2425
void Game_renderBall(Ball *ball);
2526
void Game_updateScore(const Paddle *p1, const Paddle *p2);

code/source/main.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,52 @@
22
#include <../include/maxmod.h>
33

44
#include "../build/soundbank_bin.h"
5+
#include <../include/gba-link-connection-c/link_connection.h>
56

67
#include "game.h"
78

8-
void on_vblank() {
9-
mmVBlank();
10-
mmFrame();
9+
LinkConnection conn;
10+
11+
void onVBlank() {
12+
mmVBlank();
13+
mmFrame();
14+
lc_on_vblank(&conn);
15+
}
16+
void onSerial() {
17+
lc_on_serial(&conn);
1118
}
19+
void onTimer() {
20+
lc_on_timer(&conn);
21+
}
22+
1223

1324
int main(void)
1425
{
26+
LinkConnectionSettings settings = {
27+
.baud_rate = BAUD_RATE_1,
28+
.timeout = 3,
29+
.remote_timeout = 5,
30+
.buffer_len = 30,
31+
.interval = 50,
32+
.send_timer_id = 3,
33+
};
34+
35+
conn = lc_init(settings);
36+
1537
irq_init(NULL);
1638
irq_enable(II_VBLANK);
1739

18-
irq_add(II_VBLANK, on_vblank);
40+
irq_add(II_VBLANK, onVBlank);
41+
irq_add(II_SERIAL, onSerial);
42+
irq_add(II_TIMER3, onTimer);
1943

2044
mmInitDefault((mm_addr)soundbank_bin, 8);
2145
REG_DISPCNT = DCNT_MODE4 | DCNT_PAGE | DCNT_BG2;
2246
REG_DISPCNT ^= DCNT_PAGE;
2347

24-
Game_gameLoop();
48+
Game_gameLoop(&conn);
49+
50+
lc_destroy(&conn);
2551

2652
return 1;
2753
}

0 commit comments

Comments
 (0)