-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added extra memory regions and default value of memory
- Loading branch information
1 parent
8b6e976
commit a15ad51
Showing
7 changed files
with
257 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "memory.h" | ||
|
||
void execute_load_1(GameboyMemory *memory, GameboyRegisters *registers); | ||
void execute_load_2(GameboyMemory *memory, GameboyRegisters *registers); | ||
void execute_load_3(GameboyMemory *memory, GameboyRegisters *registers); | ||
void execute_load_4(GameboyMemory *memory, GameboyRegisters *registers); | ||
void execute_load_5(GameboyMemory *memory, GameboyRegisters *registers); | ||
void execute_load_6(GameboyMemory *memory, GameboyRegisters *registers); | ||
void execute_load_7(GameboyMemory *memory, GameboyRegisters *registers); | ||
void execute_load_8(GameboyMemory *memory, GameboyRegisters *registers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <stdio.h> | ||
#include "INS_load.h" | ||
|
||
void execute_load_1(GameboyMemory *memory, GameboyRegisters *registers){ | ||
uint16_t valueLoc = registers->pc + 0x01; | ||
uint16_t value = read_memory_16_le(memory, valueLoc); | ||
printf("LOAD HL 0x%04X\n", value); | ||
registers->hl = value; | ||
registers->pc += 0x03; | ||
} | ||
|
||
void execute_load_2(GameboyMemory *memory, GameboyRegisters *registers){ | ||
uint16_t valueLoc = registers->pc + 0x01; | ||
uint16_t value = read_memory(memory, valueLoc); | ||
printf("LOAD C 0x%02X\n", value); | ||
registers->c = value; | ||
registers->pc += 0x02; | ||
} | ||
|
||
void execute_load_3(GameboyMemory *memory, GameboyRegisters *registers){ | ||
uint16_t valueLoc = registers->pc + 0x01; | ||
uint16_t value = read_memory(memory, valueLoc); | ||
printf("LOAD B 0x%02X\n", value); | ||
registers->b = value; | ||
registers->pc += 0x02; | ||
} | ||
|
||
void execute_load_4(GameboyMemory *memory, GameboyRegisters *registers){ | ||
uint8_t value = registers->a; | ||
printf("LOAD *HL A\n"); | ||
write_memory(memory, registers->hl, value); | ||
registers->hl -= 0x01; | ||
registers->pc += 0x01; | ||
} | ||
|
||
void execute_load_5(GameboyMemory *memory, GameboyRegisters *registers){ | ||
printf("LOAD L C\n"); | ||
registers->l = registers->c; | ||
registers->pc += 0x01; | ||
} | ||
|
||
void execute_load_6(GameboyMemory *memory, GameboyRegisters *registers){ | ||
uint16_t valueLoc = registers->pc + 0x01; | ||
uint8_t value = read_memory(memory, valueLoc); | ||
printf("LOAD A 0x%02X\n", value); | ||
registers->a = value; | ||
registers->pc += 0x02; | ||
} | ||
|
||
void execute_load_7(GameboyMemory *memory, GameboyRegisters *registers){ | ||
uint16_t valueLoc = registers->pc + 0x01; | ||
uint8_t value = read_memory(memory, valueLoc); | ||
printf("LOAD FF00+ 0x%02X, A\n", value); | ||
|
||
uint16_t address = 0xFF00 + value; | ||
write_memory(memory, address, registers->a); | ||
|
||
registers->pc += 0x02; | ||
} | ||
|
||
void execute_load_8(GameboyMemory *memory, GameboyRegisters *registers){ | ||
uint16_t valueLoc = registers->pc + 0x01; | ||
uint8_t value = read_memory(memory, valueLoc); | ||
uint16_t address = 0xFF00 + value; | ||
value = read_memory(memory, address); | ||
printf("LOAD A, FF00+ 0x%02X, A\n", value); | ||
registers->a = value; | ||
registers->pc += 0x02; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.