Skip to content

Commit

Permalink
points working
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmolina committed Apr 28, 2019
1 parent de97614 commit 7cf4371
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 11 deletions.
50 changes: 50 additions & 0 deletions asm_strlen.asm
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
28 changes: 19 additions & 9 deletions game_zx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
#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(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;
}
}
2 changes: 1 addition & 1 deletion game_zx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#include <z80.h>
#include <arch/zx.h>

extern void print_points(uint16_t number);
extern void print_points();

#endif
8 changes: 8 additions & 0 deletions alley.c → msnampac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -157,6 +164,7 @@ int main()

if(frame == 5) {
frame = 0;
print_points();
}

wait();
Expand Down
3 changes: 2 additions & 1 deletion zproject.lst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ game_zx.c
logic.c
sprites.c
globals.c
alley.c
int.c
msnampac.c
asm_strlen

0 comments on commit 7cf4371

Please sign in to comment.