1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-06-01 09:41:36 +00:00

A8 my last examples

This commit is contained in:
zbyti 2020-09-25 03:08:33 +02:00
parent 9f1309c119
commit dc2def7e72
3 changed files with 115 additions and 0 deletions

View File

@ -92,6 +92,8 @@ how to create a program made of multiple files loaded on demand
* [Grand Ttheft Antic](a8/grand_theft_antic.mfk) ANTIC impact on CPU depending on the used graphic mode
* [Quatari Landscape](a8/landscape.mfk) part of Quatari 256B intro
* [System Off example](a8/systemoff_example.mfk) programming with ROM off
* [GR.8 Chessboard Benchmark](a8/gr8_chessboard_benchmark.mfk) chessboard drawing benchmark in GR.8
@ -104,6 +106,8 @@ how to create a program made of multiple files loaded on demand
* [Monte Carlo PI estimation Benchmark](a8/montecarlo_pi_benchmark.mfk) measures the efficiency of multiplication
* [Bubble Sort Benchmark](a8/bubble_sort.mfk) sort 255 elements
## Game Boy examples
* [GB test example](gb/gbtest.mfk) a partial port of the NES example, with a rudimentary experimental text output implementation

View File

@ -0,0 +1,62 @@
pointer screen @ $84
byte i @ $80, n1 @ $81, n2 @ $82, t @ $83
array(byte) sorttable align(fast) = [for x,255,downto,1 [x]]
asm void pause() {
lda os_RTCLOK.b2
.rt_check:
cmp os_RTCLOK.b2
beq .rt_check
rts
}
// print in HEX
void printScore(byte val) {
array(byte) tmp[2]
byte iter
tmp[0] = val >> 4
tmp[1] = val & %00001111
for iter:tmp {
if tmp[iter] < 10 {
screen[0] = tmp[iter] + $10
} else {
screen[0] = tmp[iter] + $17
}
screen += 1
}
screen[0] = 0
screen += 1
}
void main(){
screen = os_SAVMSC
for i:sorttable {
printScore(sorttable[i])
}
pause()
os_RTCLOK.b2 = 0
for t,253,downto,0{
for i,0,to,253{
n1 = sorttable[i]
n2 = sorttable[i+1]
if n1>n2 {
sorttable[i] = n2
sorttable[i+1] = n1
}
}
}
t = os_RTCLOK.b2
screen = os_SAVMSC
for i:sorttable {
printScore(sorttable[i])
}
// print jiffies
printScore(t)
while true {}
}

49
examples/a8/landscape.mfk Normal file
View File

@ -0,0 +1,49 @@
// idea @ilmenit
// https://demozoo.org/productions/280623/
alias prev_x = os_OLDCOL
alias cursor_x = os_COLCRS
alias prev_y = os_OLDROW
alias cursor_y = os_ROWCRS
alias color = os_ATACHR
byte tmp, i
array(byte) color_height = [
170,150,144,144,122,122,110,110,94,94,86,86,82,80
]
asm void openmode(byte register(a) m) @ $ef9c extern
asm void drawto() @ $f9c2 extern
void main(){
openmode(9)
os_COLOR4 = $b0
for i,0,to,79 {
color = 13
prev_y = 1
cursor_x = i
prev_x = i
while color != $ff {
cursor_y = color_height[color]
tmp = color_height[color]
if (pokey_random & 1) != 0 {
tmp += 1
} else {
if (pokey_random & 1) != 0 {
tmp -= 1
}
}
color_height[color] = tmp
drawto()
color -= 1
}
}
while true {}
}