File tree 10 files changed +41
-30
lines changed
10 files changed +41
-30
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ build-uno
2
2
bin
3
3
* .swp
4
4
* .exe
5
- libgame /emulator /emulator
5
+ * .o
6
+ game /emulator /emulator
Original file line number Diff line number Diff line change 1
- # BackspaceInvaders
2
- Game for Arduino and LED display 64x64
1
+ # libgame
2
+ Game library for Arduino and LED display 64x64
3
3
4
4
This project uses Adafruit-like display:
5
5
https://learn.adafruit.com/32x16-32x32-rgb-led-matrix
@@ -38,3 +38,6 @@ Therefore this is logically 128x32 display.
38
38
Arduino shifts 128 pixels into display registers at every iteration.
39
39
40
40
Demonstration of the working prototype: https://www.youtube.com/watch?v=gy7oADJboqM
41
+
42
+ ## Tutorial
43
+ See game/Template.cpp
Original file line number Diff line number Diff line change 1
1
#pragma GCC optimize ("-O3")
2
2
3
+ #ifndef EMULATED
3
4
#include " libgame.h"
4
5
#include " font.h"
5
6
#include < avr/eeprom.h>
@@ -79,3 +80,4 @@ game_instance Dump = {
79
80
sizeof (DumpData),
80
81
(void **)(&data)
81
82
};
83
+ #endif
Original file line number Diff line number Diff line change 17
17
* Version 1.0.1 *
18
18
* Maximilan Rosenblattl, Andreas Wolf 2007-02-07 *
19
19
****************************************************************/
20
- #ifndef TEST_ON_PC
20
+ #ifndef EMULATED
21
21
22
22
#include < avr/io.h>
23
23
#include < avr/interrupt.h>
24
24
/* #include <avr/signal.h>*/
25
25
#include < avr/pgmspace.h>
26
+ #else
27
+ #include < stdint.h>
28
+ #endif
26
29
27
30
#include " avrfix.h"
28
31
#include " avrfix_config.h"
29
-
30
- #endif
31
32
#if BYTE_ORDER == BIG_ENDIAN
32
33
typedef struct {
33
34
unsigned short ll;
Original file line number Diff line number Diff line change 22
22
#define _AVRFIX_H
23
23
24
24
25
- #ifndef TEST_ON_PC
25
+ #ifndef EMULATED
26
26
#include <avr/io.h>
27
27
#include <avr/interrupt.h>
28
28
/*#include <avr/signal.h>*/
29
29
#include <avr/pgmspace.h>
30
30
// #include "avrfix_config.h"
31
+ #else
32
+ #include <stdint.h>
31
33
#endif
32
34
33
35
/* Only two datatypes are used from the ISO/IEC standard:
Original file line number Diff line number Diff line change 1
1
CPP_FILES := $(wildcard ../* .cpp)
2
2
OBJ_FILES := $(notdir $(CPP_FILES:.cpp=.o ) )
3
- CXXFLAGS := -DEMULATED -Wno-narrowing
3
+ CXXFLAGS := -I.. -DEMULATED -Wall -fexec-charset=windows-1251 -std=c++11
4
+ LIBS := -lsfml-graphics -lsfml-window -lsfml-system
4
5
5
- emulator : main.cpp ../* .cpp ../* .h
6
- $(CXX ) -I.. -DEMULATED -Wall -fexec-charset=windows-1251 main.cpp ../* .cpp -lsfml-graphics -lsfml-window -lsfml-system -o emulator -std=c++11
6
+ emulator : main.cpp ${OBJ_FILES}
7
+ $(CXX ) $(CXXFLAGS ) $^ $(LIBS ) -o $@
8
+
9
+ % .o : ../% .cpp
10
+ $(CXX ) $(CXXFLAGS ) $^ -c -o $@
7
11
8
12
clean :
9
- rm -f emulator*
13
+ rm -f emulator* ${OBJ_FILES}
10
14
11
15
run : emulator
12
16
./emulator
Original file line number Diff line number Diff line change 1
1
CPP_FILES := $(wildcard ../*.cpp)
2
2
OBJ_FILES := $(notdir $(CPP_FILES:.cpp=.o))
3
- CXXFLAGS := -DEMULATED -Wno-narrowing
3
+ CXXFLAGS := -I.. -DEMULATED -Wall -fexec-charset=windows-1251 -mwindows -std=c++11
4
+ LIBS := -lsfml-graphics -lsfml-window -lsfml-system
4
5
5
- emulator: main.cpp ../*.cpp
6
- $(CXX) -I.. -DEMULATED -Wall -fexec-charset=windows-1251 main.cpp ../*.cpp -lsfml-graphics -lsfml-window -lsfml-system -mwindows -o emulator -std=c++11
6
+ emulator: main.cpp ${OBJ_FILES}
7
+ $(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@
8
+
9
+ %.o: ../%.cpp
10
+ $(CXX) $(CXXFLAGS) $^ -c -o $@
7
11
8
12
clean:
9
- rm -f emulator*
13
+ rm -f emulator* ${OBJ_FILES}
10
14
11
15
run: emulator
12
16
./emulator
Original file line number Diff line number Diff line change @@ -51,20 +51,8 @@ unsigned long millis()
51
51
void storage_init () {}
52
52
void storage_format () {}
53
53
54
- uint8_t storage_open (const char *name, uint8_t mode) { return 0 ; }
55
-
56
- void storage_write_byte (uint8_t sd, uint8_t value) {}
57
- void storage_write_word (uint8_t sd, uint16_t value) {}
58
- void storage_write_dword (uint8_t sd, uint32_t value) {}
59
- size_t storage_write (uint8_t sd, void * buffer, size_t size) { return 0 ; }
60
-
61
- uint8_t storage_read_byte (uint8_t sd) { return 0 ; }
62
- uint16_t storage_read_word (uint8_t sd) { return 0 ; }
63
- uint32_t storage_read_dword (uint8_t sd) { return 0 ; }
64
- size_t storage_read (uint8_t sd, void * buffer, size_t size) { return 0 ; }
65
-
66
- void storage_delete (uint8_t sd) {}
67
- void storage_close (uint8_t sd) {}
54
+ void storage_read (const char *name, void *buffer, size_t size){};
55
+ bool storage_write (const char *name, const void *buffer, size_t size){return 0 ;};
68
56
69
57
uint8_t game_sprite_width (const struct game_sprite *s)
70
58
{
Original file line number Diff line number Diff line change @@ -6,8 +6,9 @@ extern game_instance BackspaceInvaders;
6
6
extern game_instance Snake ;
7
7
extern game_instance Tester ;
8
8
extern game_instance Raycaster ;
9
+ #ifndef EMULATED /* for use only on real hardware */
9
10
extern game_instance Dump ;
10
-
11
+ #endif
11
12
/* Register your game like so:
12
13
*
13
14
* extern game_instance YOUR_GAME_NAME;
@@ -20,7 +21,9 @@ game_instance instances[] = {
20
21
Snake ,
21
22
Raycaster ,
22
23
Tester ,
24
+ #ifndef EMULATED /* for use only on real hardware */
23
25
Dump ,
26
+ #endif
24
27
25
28
/* Register your game like so:
26
29
*
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ using namespace std;
18
18
#define pgm_read_byte (addr ) (*(addr))
19
19
#define pgm_read_word (addr ) (*(addr))
20
20
#define pgm_read_dword (addr ) (*(addr))
21
+ #define pgm_read_byte_near (addr ) (*((uint8_t *)(addr)))
22
+ #define pgm_read_word_near (addr ) (*((uint16_t *)(addr)))
23
+ #define pgm_read_dword_near (addr ) (*((uint32_t *)(addr)))
21
24
#define pgm_read_pointer (addr ) (*(addr))
22
25
#else
23
26
#if !defined(__INT_MAX__) || (__INT_MAX__ > 0xFFFF)
You can’t perform that action at this time.
0 commit comments