1
0
mirror of https://github.com/KarolS/millfork.git synced 2026-04-21 09:16:34 +00:00

Library improvements:

– random module
– ensure_mixedcase() function
This commit is contained in:
Karol Stasiak
2018-12-30 18:59:32 +01:00
parent fc56c11b31
commit 75e572f58c
9 changed files with 158 additions and 54 deletions
+2 -50
View File
@@ -1,4 +1,6 @@
import random
array reverse_palette[256] align(256)
#if CBM
@@ -119,53 +121,3 @@ void fire() {
p += COLUMN_COUNT
}
}
word rand_seed
#if CPU_6502
asm byte rand() {
ldx #8
lda rand_seed+0
__rand_loop:
asl
rol rand_seed+1
bcc __no_eor
eor #$2D
__no_eor:
dex
bne __rand_loop
sta rand_seed+0
? rts
}
#elseif CPU_Z80
inline asm byte rand() {
ld b,8
ld hl,(rand_seed)
__rand_loop:
add hl,hl
jp nc, __no_eor
ld a,l
xor $2D
ld l,a
__no_eor:
djnz __rand_loop
ld (rand_seed),hl
? ret
}
#endif
#if CBM_64
inline void init_rand_seed() {
poke($D40E, $ff)
poke($D40F, $ff)
poke($D412, $80)
while vic_raster != $70 {}
rand_seed.hi = peek($D41B)
while vic_raster != $40 {}
rand_seed.lo = peek($D41B)
}
#else
inline void init_rand_seed() {
rand_seed = 1
}
#endif
+3 -2
View File
@@ -3,9 +3,10 @@
import stdio
array hello_world = "hello world"
array hello_world = "Hello world"
void main() {
ensure_mixedcase()
#if CBM_64 || CBM_264
set_bg_color(green)
@@ -16,7 +17,7 @@ void main() {
putstr(hello_world, hello_world.length)
new_line()
putstrz("hello world again"z)
putstrz("Hello world again"z)
#if not(CPM)
while(true){}