diff --git a/asm_strlen.asm b/asm_strlen.asm new file mode 100644 index 0000000..5eb0a38 --- /dev/null +++ b/asm_strlen.asm @@ -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 diff --git a/game_zx.c b/game_zx.c index fb6bbcc..a96b4b1 100644 --- a/game_zx.c +++ b/game_zx.c @@ -2,17 +2,27 @@ #include #include #include +#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(uint16_t number) { - uint8_t pos = 18; +void print_points() { + utoa(points, chars, 10); + col = 5 - strlen(chars); - while (number > 0) - { - number = number % 10; - number /= 10; - //print digit - sp1_PrintAtInv(0, pos, INK_CYAN | PAPER_BLACK, 48 + number); - --pos; + 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; } } \ No newline at end of file diff --git a/game_zx.h b/game_zx.h index 105f7ca..cfc01ee 100644 --- a/game_zx.h +++ b/game_zx.h @@ -4,6 +4,6 @@ #include #include -extern void print_points(uint16_t number); +extern void print_points(); #endif diff --git a/alley.c b/msnampac.c similarity index 92% rename from alley.c rename to msnampac.c index fa12200..cce17c9 100644 --- a/alley.c +++ b/msnampac.c @@ -68,6 +68,13 @@ void all_lives_lost() { } + sp1_PrintAtInv(0, 19, INK_RED | PAPER_BLACK, 'P'); + sp1_PrintAtInv(0, 20, INK_RED | PAPER_BLACK, 'O'); + sp1_PrintAtInv(0, 21, INK_RED | PAPER_BLACK, 'I'); + sp1_PrintAtInv(0, 22, INK_RED | PAPER_BLACK, 'N'); + sp1_PrintAtInv(0, 23, INK_RED | PAPER_BLACK, 'T'); + sp1_PrintAtInv(0, 24, INK_RED | PAPER_BLACK, 'S'); + sp1_PrintAt(0, 2, INK_RED | PAPER_BLACK, 'L'); sp1_PrintAt(0, 3, INK_RED | PAPER_BLACK, 'I'); sp1_PrintAt(0, 4, INK_RED | PAPER_BLACK, 'V'); @@ -157,6 +164,7 @@ int main() if(frame == 5) { frame = 0; + print_points(); } wait(); diff --git a/zproject.lst b/zproject.lst index 76f0742..83dc8ad 100644 --- a/zproject.lst +++ b/zproject.lst @@ -4,5 +4,6 @@ game_zx.c logic.c sprites.c globals.c -alley.c int.c +msnampac.c +asm_strlen