-
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.
Merge pull request #9 from jsmolina/feature/reorder_the_house
Feature/reorder the house
- Loading branch information
Showing
15 changed files
with
922 additions
and
731 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
; =============================================================== | ||
; Dec 2013 | ||
; =============================================================== | ||
; | ||
; size_t strlen(const char *s) | ||
; | ||
; Return length of string s. | ||
; | ||
; =============================================================== | ||
|
||
|
||
SECTION code_clib | ||
SECTION code_string | ||
|
||
PUBLIC asm_strlen | ||
|
||
asm_strlen: | ||
|
||
; enter: hl = char *s | ||
; | ||
; exit : hl = length | ||
; bc = -(length + 1) | ||
; a = 0 | ||
; z flag set if 0 length | ||
; carry reset | ||
; | ||
; uses : af, bc, hl | ||
|
||
xor a | ||
ld c,a | ||
ld b,a | ||
|
||
cpir | ||
|
||
ld hl,$ffff | ||
sbc hl,bc | ||
|
||
ret | ||
|
||
PUBLIC _strlen | ||
|
||
_strlen: | ||
|
||
pop af | ||
pop hl | ||
|
||
push hl | ||
push af | ||
|
||
jp asm_strlen |
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,7 @@ | ||
SECTION FONT | ||
|
||
PUBLIC _game_font | ||
|
||
_game_font: | ||
|
||
BINARY "game.font" |
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,28 @@ | ||
#include <z80.h> | ||
#include <stdlib.h> | ||
#include <arch/zx.h> | ||
#include <arch/zx/sp1.h> | ||
#include "globals.h" | ||
|
||
extern uint8_t strlen(char * chars); | ||
|
||
// temporary buffer to print points (e.g. 65535) | ||
char * chars = "0000000\0"; | ||
|
||
|
||
// reversed order digit extract | ||
void print_points() { | ||
utoa(points, chars, 10); | ||
col = 5 - strlen(chars); | ||
|
||
if(col != 0) { | ||
for(idx = 0; idx != 5; ++idx) { | ||
sp1_PrintAtInv(0, 26 + idx, INK_CYAN | PAPER_BLACK, '0'); | ||
} | ||
} | ||
idx = 0; | ||
while(chars[idx] != '\0') { | ||
sp1_PrintAtInv(0, 26 + idx + col, INK_CYAN | PAPER_BLACK, chars[idx]); | ||
++idx; | ||
} | ||
} |
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,9 @@ | ||
#ifndef GAME_ZX | ||
#define GAME_ZX | ||
|
||
#include <z80.h> | ||
#include <arch/zx.h> | ||
|
||
extern void print_points(); | ||
|
||
#endif |
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,67 @@ | ||
#include "globals.h" | ||
|
||
struct sp1_Rect full_screen = {0, 0, 32, 24}; | ||
|
||
uint8_t random_value; | ||
|
||
// or using UDG from just code | ||
uint8_t map[25][32] = { | ||
{3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,13,14,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4}, | ||
{2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2}, | ||
{2,9,9,9,9,9,9,9,9,9,9,9,9,9,0,8,12,9,9,9,9,9,9,9,9,9,9,9,9,9,0,2}, | ||
{2,9,0,3,1,4,9,0,3,1,1,1,4,9,0,8,12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,0,2,9,0,0,9,0,0,0,0,0,0,0,0,0,0,0,9,0,0,9,0,2,0,2,9,0,2}, | ||
{2,11,0,2,0,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,0,2,0,2,11,0,2}, | ||
{2,9,0,5,1,6,9,0,1,1,1,1,9,0,1,1,1,1,9,0,1,1,1,1,9,0,5,1,6,9,0,2}, | ||
{2,9,0,0,0,0,9,0,0,0,0,0,9,0,0,0,0,0,9,0,0,0,0,0,9,0,0,0,0,9,0,2}, | ||
{2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,0,2}, | ||
{5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,6}, | ||
}; | ||
|
||
|
||
// 15 | ||
uint8_t correspondence[] = {' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'}; | ||
uint8_t colors[] = {INK_BLUE, INK_BLUE, INK_BLUE, INK_BLUE, INK_BLUE, INK_BLUE, INK_BLUE, INK_BLUE, INK_BLUE, INK_WHITE, INK_BLUE, INK_MAGENTA, INK_BLUE, INK_BLUE, INK_BLUE}; | ||
|
||
|
||
|
||
|
||
uint8_t pill_eaten = NONE; | ||
struct sprite pacman; | ||
struct sprite ghost_red; | ||
struct sprite ghost_cyan; | ||
struct sprite ghost_magenta; | ||
struct sprite ghost_yellow; | ||
|
||
struct sprite * ghosts[4] = {&ghost_red, &ghost_cyan, &ghost_magenta, &ghost_yellow}; | ||
|
||
JOYFUNC joy; | ||
// redefine this array to allow define keys | ||
udk_t joy_keys = { IN_KEY_SCANCODE_SPACE, IN_KEY_SCANCODE_p, IN_KEY_SCANCODE_o, IN_KEY_SCANCODE_a, IN_KEY_SCANCODE_q }; | ||
uint16_t in; | ||
// reusable vars | ||
uint8_t row; | ||
uint8_t col; | ||
uint8_t current; | ||
uint16_t points = 0; | ||
|
||
uint8_t frame = 0; | ||
|
||
uint8_t lives = 0; | ||
uint8_t repaint_lives = 1; | ||
uint8_t idx; | ||
struct sprite * collided_sprite; |
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,112 @@ | ||
#ifndef GLOBALS_H | ||
#define GLOBALS_H | ||
|
||
#include <z80.h> | ||
#include <stdlib.h> | ||
#include <arch/zx.h> | ||
#include <arch/zx/sp1.h> | ||
#include <input.h> | ||
|
||
|
||
#define RIGHTC1 1 | ||
#define RIGHTC2 33 | ||
#define LEFTC1 65 | ||
#define LEFTC2 97 | ||
#define UP1 129 | ||
#define UP2 161 | ||
#define DOWN1 193 | ||
#define DOWN2 225 | ||
#define DECIDED_DIRECTION 1 | ||
#define UNDECIDED 0 | ||
|
||
#define GHOST_RED 1 | ||
#define GHOST_RED2 33 | ||
#define GHOST_CYAN 65 | ||
#define GHOST_CYAN2 97 | ||
#define GHOST_YELLOW 129 | ||
#define GHOST_YELLOW2 161 | ||
#define GHOST_MAGENTA 193 | ||
#define GHOST_MAGENTA2 225 | ||
|
||
#define DIR_UP 1 | ||
#define DIR_DOWN 2 | ||
#define DIR_LEFT 3 | ||
#define DIR_RIGHT 4 | ||
#define NONE 250 | ||
#define JAILED 20 | ||
#define JAILED_EXITING 1 | ||
#define ACTIVE 0 | ||
|
||
#define AYCTRL 65533 | ||
#define AYDATA 49149 | ||
|
||
// screen rectangle | ||
extern struct sp1_Rect full_screen; | ||
|
||
// globals are supposed to generate less code and with 128k of memory it's important | ||
struct sprite { | ||
struct sp1_ss* sp; | ||
uint8_t x; | ||
uint8_t y; | ||
uint8_t offset; | ||
uint8_t currentoffset; | ||
uint8_t active; | ||
int8_t dx; | ||
int8_t dy; | ||
uint8_t default_x; | ||
uint8_t default_y; | ||
void *default_color; | ||
}; | ||
|
||
// it comes from built binaries: | ||
extern uint8_t sprite_protar1[]; | ||
extern uint8_t sprite_protar2[]; | ||
// red ghost | ||
extern uint8_t red_ghost1[]; | ||
extern uint8_t red_ghost2[]; | ||
// using UDG from ASM | ||
extern uint8_t horizontal[]; | ||
extern uint8_t vertical[]; | ||
extern uint8_t corner_left[]; | ||
extern uint8_t corner_right[]; | ||
extern uint8_t corner_bottom_right[]; | ||
extern uint8_t corner_bottom_left[]; | ||
extern uint8_t pill[]; | ||
extern uint8_t vertileft[]; | ||
extern uint8_t vertiright[]; | ||
extern uint8_t topvertileft[]; | ||
extern uint8_t topvertiright[]; | ||
extern uint8_t ghostpill[]; | ||
extern uint8_t cartoon0[]; | ||
|
||
extern uint8_t map[25][32]; | ||
extern uint8_t random_value; | ||
extern uint8_t correspondence[]; | ||
extern uint8_t colors[]; | ||
|
||
extern uint8_t pill_eaten; | ||
extern struct sprite pacman; | ||
extern struct sprite ghost_red; | ||
extern struct sprite ghost_cyan; | ||
extern struct sprite ghost_magenta; | ||
extern struct sprite ghost_yellow; | ||
extern struct sprite * ghosts[4]; | ||
|
||
extern JOYFUNC joy; | ||
extern udk_t joy_keys; | ||
extern uint16_t in; | ||
|
||
extern uint8_t row; | ||
extern uint8_t col; | ||
extern uint8_t current; | ||
extern uint16_t points; | ||
|
||
extern uint8_t frame; | ||
|
||
extern uint8_t lives; | ||
extern uint8_t repaint_lives; | ||
extern uint8_t idx; | ||
extern struct sprite * collided_sprite; | ||
|
||
#endif | ||
|
Oops, something went wrong.