added the character set
This commit is contained in:
parent
fac5c920de
commit
1dbaf0a6ac
21
Notes.org
21
Notes.org
@ -29,6 +29,27 @@ Chip-8 has a stack that is an array of 16 16-bit values, used to store the
|
||||
addresses that the Chip8 should return to when returning from a subroutine,
|
||||
meaning there can be 16 levels of nested subroutines.
|
||||
|
||||
*** The Character Set
|
||||
|
||||
The Chip8 contains some sprites, called /character set/ which are a group of
|
||||
sprites representing the hexadecimal digits from 0 to F. They are 5 bytes long
|
||||
(8x5 pixels). They are stored in the area reserved for Chip8 (0x00-0x1FF).
|
||||
|
||||
The following are some examples:
|
||||
|
||||
#+begin_src artist
|
||||
+----+--------+----+ +----+--------+----+
|
||||
|"0" |Binary |Hex | |"1" |Binary |Hex |
|
||||
+----+--------+----| +----+--------+----+
|
||||
|****|11110000|0xF0| | 1 |00100000|0x20|
|
||||
|* *|10010000|0x90| | 11 |01100000|0x60|
|
||||
|* *|10010000|0x90| | 1 |00100000|0x20|
|
||||
|* *|10010000|0x90| | 1 |00100000|0x20|
|
||||
|****|11110000|0xF0| | 111|01110000|0x70|
|
||||
+----+--------+----+ +----+--------+----+
|
||||
#+end_src
|
||||
|
||||
|
||||
** Registers
|
||||
|
||||
Chip8 has 16 8-bit data registers, each can hold 1 byte of information.
|
||||
|
@ -12,4 +12,6 @@
|
||||
#define CHIP8_TOTAL_STACK_DEPTH 16
|
||||
#define CHIP8_TOTAL_KEYS 16
|
||||
|
||||
#define CHIP8_CHARACTER_SET_LOAD_ADDRESS 0x00
|
||||
|
||||
#endif
|
||||
|
20
src/chip8.c
20
src/chip8.c
@ -1,8 +1,28 @@
|
||||
#include "chip8.h"
|
||||
#include <memory.h>
|
||||
|
||||
const char chip8_default_character_set[] = {
|
||||
0xf0, 0x90, 0x90, 0x90, 0xf0, // 1
|
||||
0x20, 0x60, 0x20, 0x20, 0x70, // 2
|
||||
0xf0, 0x10, 0xf0, 0x80, 0xf0, // 3
|
||||
0xf0, 0x10, 0xf0, 0x10, 0xf0, // 4
|
||||
0xf0, 0x80, 0xf0, 0x10, 0xf0, // 5
|
||||
0xf0, 0x80, 0xf0, 0x90, 0xf0, // 6
|
||||
0xf0, 0x10, 0x20, 0x40, 0x40, // 7
|
||||
0xf0, 0x90, 0xf0, 0x90, 0xf0, // 8
|
||||
0xf0, 0x90, 0xf0, 0x10, 0xf0, // 9
|
||||
0xf0, 0x90, 0xf0, 0x90, 0x90, // A
|
||||
0xe0, 0x90, 0xe0, 0x90, 0xe0, // B
|
||||
0xf0, 0x80, 0x80, 0x80, 0xf0, // C
|
||||
0xe0, 0x90, 0x90, 0x90, 0xe0, // D
|
||||
0xf0, 0x80, 0xf0, 0x80, 0xf0, // E
|
||||
0xf0, 0x80, 0xf0, 0x80, 0x80 // F
|
||||
};
|
||||
|
||||
void
|
||||
chip8_init (struct chip8 *chip8)
|
||||
{
|
||||
memset (chip8, 0, sizeof (struct chip8));
|
||||
memcpy (&chip8->memory.memory, chip8_default_character_set,
|
||||
sizeof (chip8_default_character_set));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user