Initial Commit
This commit is contained in:
16
z_gbdk_playground_original/save_ram/Makefile
Normal file
16
z_gbdk_playground_original/save_ram/Makefile
Normal 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) *~
|
5
z_gbdk_playground_original/save_ram/README.md
Normal file
5
z_gbdk_playground_original/save_ram/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Save RAM
|
||||
|
||||

|
||||
|
||||
Demonstrates how to load and save variables. Using Save RAM requires additional compiler arguments.
|
22
z_gbdk_playground_original/save_ram/save_ram.c
Normal file
22
z_gbdk_playground_original/save_ram/save_ram.c
Normal 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
|
||||
}
|
BIN
z_gbdk_playground_original/save_ram/screenshot.png
Normal file
BIN
z_gbdk_playground_original/save_ram/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Reference in New Issue
Block a user