Initial Commit

This commit is contained in:
2020-07-11 08:41:14 -05:00
parent 55c0f7f3cd
commit 1478a597cf
176 changed files with 11933 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m -Wl-yt3 -Wl-yo4 -Wl-ya4
BIN = save_ram.gb
OBJS = save_ram.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,5 @@
# Save RAM
![](screenshot.png)
Demonstrates how to load and save variables. Using Save RAM requires additional compiler arguments.

View File

@@ -0,0 +1,22 @@
#include <stdio.h>
#include <gb/gb.h>
char *saved = (char *)0xa000; // Pointer to memory address
int *num = (int *)0xa001;
void main()
{
ENABLE_RAM_MBC1; // Enable RAM
if (saved[0] != 's') { // Check to see if the variable's ever been saved before
num[0]=0; // Assign the variable an initial value
saved[0] = 's'; // Assign saved an 's' value so the if statement isn't executed on next load
}
printf("The value of num is: %d\n", num[0]);
num[0]++; // Increment so on next load there's a new number
DISABLE_RAM_MBC1; // Disable RAM
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB