mirror of
https://github.com/KarolS/millfork.git
synced 2025-02-04 03:31:49 +00:00
commit
e0572fa3aa
@ -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
|
||||
|
62
examples/a8/bubble_sort.mfk
Normal file
62
examples/a8/bubble_sort.mfk
Normal 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 {}
|
||||
}
|
44
examples/a8/landscape.mfk
Normal file
44
examples/a8/landscape.mfk
Normal file
@ -0,0 +1,44 @@
|
||||
// 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 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 {
|
||||
cursor_x = i
|
||||
prev_x = i
|
||||
color = 13
|
||||
prev_y = 1
|
||||
|
||||
while color != $ff {
|
||||
cursor_y = color_height[color]
|
||||
if (pokey_random & 1) != 0 {
|
||||
color_height[color] += 1
|
||||
} else {
|
||||
if (pokey_random & 1) != 0 {
|
||||
color_height[color] -= 1
|
||||
}
|
||||
}
|
||||
drawto()
|
||||
color -= 1
|
||||
}
|
||||
}
|
||||
|
||||
while true {}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user