Initial Commit
This commit is contained in:
17
z_gbdk_playground_original/huge_sprite/Makefile
Normal file
17
z_gbdk_playground_original/huge_sprite/Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
AS = lcc -c
|
||||
CC = lcc -Wa-l -Wl-m
|
||||
|
||||
BIN = huge_sprite.gb
|
||||
OBJS = huge_sprite.o
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
%.s: %.ms
|
||||
maccer -o $@ $<
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
$(CC) -o $(BIN) $(OBJS)
|
||||
|
||||
clean:
|
||||
rm -rf $(BIN) $(OBJS) *~ *.lst *.map
|
||||
|
99
z_gbdk_playground_original/huge_sprite/README.md
Normal file
99
z_gbdk_playground_original/huge_sprite/README.md
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
|
||||
|
||||
|
||||
# Huge Sprite
|
||||
<div style="text-align: center"><img src="screenshot.png" alt="" /></div>
|
||||
|
||||
Render a huge 40x64 sprite that can be moved around with the D-pad.
|
||||
|
||||
## Source
|
||||
|
||||
|
||||
|
||||
|
||||
```c
|
||||
|
||||
#include <gb/gb.h>
|
||||
#include <types.h>
|
||||
|
||||
#include "sprite.h"
|
||||
#include "bg.h"
|
||||
|
||||
#define SPR_WIDTH 8
|
||||
#define SPR_HEIGHT 5
|
||||
#define TOTAL_SPR SPR_WIDTH * SPR_HEIGHT
|
||||
|
||||
UINT8 x = 64;
|
||||
UINT8 y = 96;
|
||||
|
||||
void render_huge_sprite() {
|
||||
UINT8 i, j;
|
||||
UINT8 sprite_index;
|
||||
|
||||
set_sprite_tile(0, 1);
|
||||
|
||||
for(i = 0; i < SPR_WIDTH; ++i) {
|
||||
for(j = 0; j < SPR_HEIGHT; ++j) {
|
||||
sprite_index = i * SPR_HEIGHT + j;
|
||||
set_sprite_tile(sprite_index, sprite_index);
|
||||
move_sprite(sprite_index, x + (j * 8), y + (i * 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void load_background() {
|
||||
set_bkg_data(0, 2, bg_tile_data);
|
||||
set_bkg_tiles(0, 0, 20, 18, bg_map_data);
|
||||
}
|
||||
|
||||
void move_huge_sprite(UINT8 nx, UINT8 ny) {
|
||||
UINT8 i, lx, ly;
|
||||
lx = 0;
|
||||
ly = 0;
|
||||
for(i = 0; i < 40; i++) {
|
||||
if(lx == 40) {
|
||||
lx = 0;
|
||||
ly += 8;
|
||||
}
|
||||
move_sprite(i, nx + lx, ny + ly);
|
||||
lx += 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void move_right() {
|
||||
move_huge_sprite(++x, y);
|
||||
}
|
||||
|
||||
void move_left() {
|
||||
move_huge_sprite(--x, y);
|
||||
}
|
||||
|
||||
void main() {
|
||||
SPRITES_8x8;
|
||||
set_sprite_data(0, 40, sprite_tile_data);
|
||||
|
||||
render_huge_sprite();
|
||||
load_background();
|
||||
|
||||
SHOW_SPRITES;
|
||||
SHOW_BKG;
|
||||
|
||||
while(1) {
|
||||
if(joypad() & J_RIGHT) {
|
||||
move_right();
|
||||
}
|
||||
if(joypad() & J_LEFT) {
|
||||
move_left();
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
67
z_gbdk_playground_original/huge_sprite/bg.h
Normal file
67
z_gbdk_playground_original/huge_sprite/bg.h
Normal file
@@ -0,0 +1,67 @@
|
||||
// ///////////////////////
|
||||
// // //
|
||||
// // File Attributes //
|
||||
// // //
|
||||
// ///////////////////////
|
||||
|
||||
// Filename: bg.png
|
||||
// Pixel Width: 144px
|
||||
// Pixel Height: 160px
|
||||
|
||||
// WARNING: Width of input image padded 3px to 144px
|
||||
|
||||
// /////////////////
|
||||
// // //
|
||||
// // Constants //
|
||||
// // //
|
||||
// /////////////////
|
||||
|
||||
const int bg_tile_map_size = 0x0168;
|
||||
const int bg_tile_map_width = 0x12;
|
||||
const int bg_tile_map_height = 0x14;
|
||||
|
||||
const int bg_tile_data_size = 0x20;
|
||||
const int bg_tile_count = 0x0168;
|
||||
|
||||
// ////////////////
|
||||
// // //
|
||||
// // Map Data //
|
||||
// // //
|
||||
// ////////////////
|
||||
|
||||
const unsigned char bg_map_data[] ={
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
|
||||
};
|
||||
|
||||
// /////////////////
|
||||
// // //
|
||||
// // Tile Data //
|
||||
// // //
|
||||
// /////////////////
|
||||
|
||||
const unsigned char bg_tile_data[] ={
|
||||
0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x01,0x01,
|
||||
0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
BIN
z_gbdk_playground_original/huge_sprite/bg.png
Normal file
BIN
z_gbdk_playground_original/huge_sprite/bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 495 B |
2
z_gbdk_playground_original/huge_sprite/docs.sh
Executable file
2
z_gbdk_playground_original/huge_sprite/docs.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
docco -t ../docs/res/readme_c.jst -o ./ huge_sprite.c -c ""
|
||||
mv huge_sprite.html README.md
|
84
z_gbdk_playground_original/huge_sprite/huge_sprite.c
Normal file
84
z_gbdk_playground_original/huge_sprite/huge_sprite.c
Normal file
@@ -0,0 +1,84 @@
|
||||
// # Huge Sprite
|
||||
// <div style="text-align: center"><img src="screenshot.png" alt="" /></div>
|
||||
//
|
||||
// Render a huge 40x64 sprite that can be moved around with the D-pad.
|
||||
//
|
||||
// ## Source
|
||||
|
||||
#include <gb/gb.h>
|
||||
#include <types.h>
|
||||
|
||||
#include "sprite.h"
|
||||
#include "bg.h"
|
||||
|
||||
#define SPR_WIDTH 8
|
||||
#define SPR_HEIGHT 5
|
||||
#define TOTAL_SPR SPR_WIDTH * SPR_HEIGHT
|
||||
|
||||
UINT8 x = 64;
|
||||
UINT8 y = 96;
|
||||
|
||||
void render_huge_sprite() {
|
||||
UINT8 i, j;
|
||||
UINT8 sprite_index;
|
||||
|
||||
set_sprite_tile(0, 1);
|
||||
|
||||
for(i = 0; i < SPR_WIDTH; ++i) {
|
||||
for(j = 0; j < SPR_HEIGHT; ++j) {
|
||||
sprite_index = i * SPR_HEIGHT + j;
|
||||
set_sprite_tile(sprite_index, sprite_index);
|
||||
move_sprite(sprite_index, x + (j * 8), y + (i * 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void load_background() {
|
||||
set_bkg_data(0, 2, bg_tile_data);
|
||||
set_bkg_tiles(0, 0, 20, 18, bg_map_data);
|
||||
}
|
||||
|
||||
void move_huge_sprite(UINT8 nx, UINT8 ny) {
|
||||
UINT8 i, lx, ly;
|
||||
lx = 0;
|
||||
ly = 0;
|
||||
for(i = 0; i < 40; i++) {
|
||||
if(lx == 40) {
|
||||
lx = 0;
|
||||
ly += 8;
|
||||
}
|
||||
move_sprite(i, nx + lx, ny + ly);
|
||||
lx += 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void move_right() {
|
||||
move_huge_sprite(++x, y);
|
||||
}
|
||||
|
||||
void move_left() {
|
||||
move_huge_sprite(--x, y);
|
||||
}
|
||||
|
||||
void main() {
|
||||
SPRITES_8x8;
|
||||
set_sprite_data(0, 40, sprite_tile_data);
|
||||
|
||||
render_huge_sprite();
|
||||
load_background();
|
||||
|
||||
SHOW_SPRITES;
|
||||
SHOW_BKG;
|
||||
|
||||
while(1) {
|
||||
wait_vbl_done();
|
||||
if(joypad() & J_RIGHT) {
|
||||
move_right();
|
||||
}
|
||||
if(joypad() & J_LEFT) {
|
||||
move_left();
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
}
|
BIN
z_gbdk_playground_original/huge_sprite/screenshot.png
Normal file
BIN
z_gbdk_playground_original/huge_sprite/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
82
z_gbdk_playground_original/huge_sprite/sprite.h
Normal file
82
z_gbdk_playground_original/huge_sprite/sprite.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// ///////////////////////
|
||||
// // //
|
||||
// // File Attributes //
|
||||
// // //
|
||||
// ///////////////////////
|
||||
|
||||
// Filename: sprite.png
|
||||
// Pixel Width: 40px
|
||||
// Pixel Height: 64px
|
||||
|
||||
// /////////////////
|
||||
// // //
|
||||
// // Constants //
|
||||
// // //
|
||||
// /////////////////
|
||||
|
||||
const int sprite_tile_map_size = 0x28;
|
||||
const int sprite_tile_map_width = 0x05;
|
||||
const int sprite_tile_map_height = 0x08;
|
||||
|
||||
const int sprite_tile_data_size = 0x0280;
|
||||
const int sprite_tile_count = 0x28;
|
||||
|
||||
// ////////////////
|
||||
// // //
|
||||
// // Map Data //
|
||||
// // //
|
||||
// ////////////////
|
||||
|
||||
const unsigned char sprite_map_data[] ={
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
|
||||
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
|
||||
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27
|
||||
};
|
||||
|
||||
// /////////////////
|
||||
// // //
|
||||
// // Tile Data //
|
||||
// // //
|
||||
// /////////////////
|
||||
|
||||
const unsigned char sprite_tile_data[] ={
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x1F,0x1F,
|
||||
0x00,0x00,0x01,0x01,0x0F,0x0F,0x1F,0x1F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0x3F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0x80,0x80,0xE0,0xE0,0xF0,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,
|
||||
0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0E,0x0F,0x0E,0x0F,0x0F,0x0E,0x02,0x03,
|
||||
0xFD,0xFF,0xDE,0xBD,0x75,0x9E,0xFF,0x0E,0xDA,0x27,0xC6,0x39,0xDB,0x74,0xBD,0x5A,
|
||||
0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xDF,0x3F,0xCF,0x3F,0x1B,0xE7,0xBF,0x5F,0xCF,0x37,
|
||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBD,0xFE,0xDE,0xB9,0xF7,0x9A,
|
||||
0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0x78,0xF8,0xF8,0x78,0xF8,0x78,
|
||||
0x01,0x00,0x01,0x00,0x01,0x00,0x03,0x02,0x02,0x03,0x03,0x02,0x06,0x07,0x00,0x01,
|
||||
0x7B,0x9C,0x3D,0xDE,0xB3,0x4C,0xC8,0x37,0xFB,0x04,0xFA,0x05,0xFF,0x00,0xFF,0x00,
|
||||
0xDF,0x27,0xFD,0x03,0xF9,0x06,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
|
||||
0x92,0xFF,0xB2,0x5F,0xDC,0x33,0xDA,0x37,0xCA,0x35,0xFF,0x23,0x9F,0x6F,0xBF,0x5F,
|
||||
0xF8,0x78,0xF0,0x70,0x70,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
|
||||
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0xFF,0x00,0x7A,0x87,0xFF,0x83,0x7C,0x43,0x0F,0x10,0x04,0x07,0x00,0x01,0x00,0x01,
|
||||
0xAF,0x50,0x9F,0xE0,0xBF,0xC0,0x7D,0x83,0xF7,0x0F,0x3E,0xFF,0x5C,0xBF,0xC5,0x3B,
|
||||
0x5F,0xBF,0xAF,0x7F,0x7B,0xC7,0xAB,0xD7,0xD7,0x6F,0x17,0xFF,0x9F,0x6F,0x0F,0xFF,
|
||||
0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xE8,0xE8,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x02,0x03,0x03,0x0C,0x0F,0x10,0x3E,0x21,0x15,0x2A,0x20,0x5F,0x8A,0xF5,
|
||||
0x4D,0xB3,0x69,0xB6,0x39,0xE6,0x09,0xF6,0x53,0xAC,0x19,0xE6,0xBD,0x42,0xFC,0x03,
|
||||
0xB7,0x4F,0x7B,0x87,0xFD,0x03,0xFE,0x01,0xFF,0x00,0xFF,0x00,0xFE,0x01,0xFB,0x04,
|
||||
0xE8,0xE8,0xE4,0xE4,0xF4,0xF4,0x70,0xF0,0xB0,0x70,0xD8,0x38,0xD8,0x38,0xD8,0x38,
|
||||
0x00,0x00,0x01,0x01,0x01,0x02,0x01,0x02,0x05,0x06,0x07,0x04,0x03,0x0C,0x1B,0x14,
|
||||
0xB7,0xC8,0x77,0x88,0xFB,0x04,0xFB,0x04,0xFA,0x05,0xFB,0x04,0xF9,0x06,0xFB,0x04,
|
||||
0xFA,0x05,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
|
||||
0xF7,0x08,0x6F,0x90,0xAF,0x50,0xBF,0x40,0xBF,0x40,0x3F,0xC0,0xAF,0x50,0x3F,0xC0,
|
||||
0xDC,0x3C,0xFC,0x1C,0xFC,0x1C,0xFE,0x1E,0xFE,0x1E,0xFE,0x1E,0xFF,0x1F,0xFF,0x1F,
|
||||
0x0F,0x10,0x19,0x26,0x10,0x2F,0x3F,0x40,0x3F,0x40,0xFF,0x80,0x7F,0x80,0x3E,0x41,
|
||||
0xFD,0x02,0xFE,0x01,0xFF,0x00,0x4F,0xB0,0xC3,0x7C,0x08,0xF7,0x9F,0xE0,0xBE,0xC1,
|
||||
0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFC,0x03,0x33,0xCC,0x4F,0xB0,0xBF,0xC0,
|
||||
0xB7,0x48,0xB7,0x48,0xFF,0x00,0x9F,0x78,0x77,0xF8,0x17,0xE8,0x9F,0x60,0x4F,0xB0,
|
||||
0xFF,0x1F,0xFF,0x1F,0xFF,0x1F,0xEF,0x1F,0xFF,0x1F,0xEF,0x1F,0xFF,0x1F,0xFF,0x1F,
|
||||
0x06,0x19,0x00,0x03,0x01,0x01,0x00,0x01,0x01,0x00,0x01,0x02,0x01,0x02,0x03,0x00,
|
||||
0x3C,0xC3,0x3C,0xC3,0xBC,0xC3,0x1E,0xE1,0xA0,0x5F,0xFF,0x00,0xFF,0x00,0xFF,0x00,
|
||||
0x7F,0x80,0xFF,0x00,0xFE,0x01,0xFF,0x00,0x04,0xFB,0xEF,0x10,0xFF,0x00,0xEF,0x10,
|
||||
0xBF,0x40,0x3F,0xC0,0x9F,0x60,0x1F,0xE0,0x4F,0xB0,0x40,0xBF,0x5F,0xAF,0xDF,0x2F,
|
||||
0xFF,0x1F,0xFF,0x1F,0xFF,0x1F,0xFF,0x1F,0xFF,0x1F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF};
|
BIN
z_gbdk_playground_original/huge_sprite/sprite.png
Normal file
BIN
z_gbdk_playground_original/huge_sprite/sprite.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1005 B |
Reference in New Issue
Block a user