-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.asm
executable file
·97 lines (62 loc) · 1.38 KB
/
utils.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
; /////////////////////////////////////////////////////////////////////////////
; Znake (ZX Spectrum 48K)
; -----------------------------------------------------------------------------
; utils.asm
; -----------------------------------------------------------------------------
; Copyright (C) 2016, Chris Wyatt
; All rights reserved
; Distributed under the Apache 2 license (see LICENSE)
; /////////////////////////////////////////////////////////////////////////////
random:
; Simple pseudo-random number generator.
; Steps a pointer through the ROM (held in seed), returning
; the contents of the byte at that location
; Modifies registers af and hl
; (Lifted from How to Write ZX Spectrum Games 1.0 by Jonathan Cauldwell)
ld hl,(seed)
; Keep it within first 8k of ROM.
ld a,h
and 31
ld h,a
ld a,(hl)
inc hl
ld (seed),hl
ret
modulo:
; Modifies registers af and bc
; Return if divisor = 0
ld a,c
or a
ret z
ld a,b
modulo_sub:
sub c
jr nc,modulo_sub
add a,c
ret
print_next:
inc hl
inc d
print:
ld a,(hl)
or a
cp 0
ret z
push hl
push de
print_char:
ld b,3
ld h,0
ld l,a
print_multiply:
add hl,hl
djnz print_multiply
ex de,hl
ld hl,0x3d00 - (8 * 0x20)
add hl,de
pop de
push de
call draw_char
pop de
pop hl
jp print_next