diff --git a/examples/c64/rasterbar.mfk b/examples/c64/rasterbar.mfk new file mode 100644 index 00000000..7d203c7b --- /dev/null +++ b/examples/c64/rasterbar.mfk @@ -0,0 +1,46 @@ +void main() { + byte colour + byte colour_index + byte wait_for + byte bar_start + byte direction + colour = 0 + disable_irq() + vic_cr1 = 0 + vic_border = black + bar_start = $50 + direction = 1 + while true { + wait_for = bar_start + for colour_index, 0, until, colours.length { + colour = colours[colour_index] + while wait_for != vic_raster { } + stabilize(8) + vic_border = colour + wait_for += 2 + } + bar_start += direction + if bar_start == $50 { direction = 1 } + if bar_start == $A0 { direction = $ff } + } + +} + +asm void stabilize(byte x){ + burn: + DEX + BNE burn + RTS +} + +array colours = [ + $06, $06, $06, $0e, $06, $0e, + $0e, $06, $0e, $0e, $0e, $03, + $0e, $03, $03, $0e, $03, $03, + $03, $01, $03, $01, $01, $03, + $01, $01, $01, $03, $01, $01, + $03, $01, $03, $03, $03, $0e, + $03, $03, $0e, $03, $0e, $0e, + $0e, $06, $0e, $0e, $06, $0e, + $06, $06, $06, $00, $00, $00 +] \ No newline at end of file diff --git a/examples/c64/softscroll.mfk b/examples/c64/softscroll.mfk new file mode 100644 index 00000000..c17204a9 --- /dev/null +++ b/examples/c64/softscroll.mfk @@ -0,0 +1,128 @@ + +const pointer screen = $400 +const byte row = 15 + +byte letter_index + +void main () { + letter_index = 0 + disable_irq() + init_screen() + main_loop() +} +void init_screen() { + byte i + for i,0,paralleluntil,250 { + screen[i+000] = logo[i-000] + screen[i+250] = logo[i+250] + screen[i+500] = logo[i+500] + screen[i+750] = logo[i+750] + c64_color_ram[i+000] = logo_colours[i+000] + c64_color_ram[i+250] = logo_colours[i+250] + c64_color_ram[i+500] = logo_colours[i+500] + c64_color_ram[i+750] = logo_colours[i+750] + } +} + +void main_loop() { + static byte scroll + scroll = 7 + while true { + while vic_raster != row * 8 - 1 + 50 {} + stabilize(8) + vic_38_columns() + vic_set_scroll(scroll, 3) + while vic_raster != row * 8 + 7 + 50 {} + stabilize(20) + vic_40_columns() + vic_set_scroll(0,3) + if scroll == 0 { + scroll = 7 + hardscroll() + } else { + scroll -= 1 + } + } +} + + +asm void stabilize(byte x){ + burn: + DEX + BNE burn + RTS +} + +void hardscroll() { + byte i + for i,0,until,39 { + screen[40 * row + i] = screen[40 * row + i + 1] + } + screen[40 * row + 39] = scroll_text[letter_index] + letter_index += 1 + if letter_index == scroll_text.length { + letter_index = 0 + } +} + +array scroll_text = [ + "this is a simple scroller demo written in millfork. " scr, + "as you can see, you don't need assembly to do simple effects. " scr, + " " scr +] + +array logo = [ + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 82,70,64,68,69,68,64,70,82,70,64,68,69,68,64,70,82,70,64,68,69,68,64,70,82,70,64,68,69,68,64,70,82,70,64,68,69,68,64,70, + 32,32,32,32,32,108,123,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,108,224,224,123,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,225,97,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,225,97,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,108,32,32,32,225,97,32,225,252,108,224,32,251,236,32,225,97,32,32,225,97,32,32,225,236,226,126,108,236,251,123,225,236,251,123,225,97,254,126, + 108,224,98,98,98,254,97,32,225,236,236,224,32,225,97,32,225,97,32,32,225,97,32,32,225,252,123,32,225,97,225,97,225,252,254,126,225,224,126,32, + 124,224,226,226,226,226,126,32,225,97,32,224,32,225,97,32,225,97,32,32,225,97,32,32,225,97,32,32,225,97,225,97,225,236,252,32,225,236,252,32, + 32,124,32,32,32,32,32,32,124,126,32,226,32,226,226,32,124,226,226,126,124,226,226,126,124,126,32,32,32,226,226,32,124,126,124,126,124,126,124,126, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 82,70,64,68,69,68,64,70,82,70,64,68,69,68,64,70,82,70,64,68,69,68,64,70,82,70,64,68,69,68,64,70,82,70,64,68,69,68,64,70, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, + 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 +] + +array logo_colours = [ +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, +14,14,14,14,14,5,5,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,5,5,5,5,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,5,5,5,14,14,14,0,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,5,5,14,0,14,0,0,14,0,14,0,0,0,14,0,0,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,5,14,14,14,5,5,14,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +5,5,5,5,5,5,5,14,0,0,0,0,14,0,0,14,0,0,14,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14, +5,5,5,5,5,5,5,14,0,0,0,0,14,0,0,14,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +14,5,5,14,14,14,14,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,0,14,14,14,0,0,0,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14, +14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 +] \ No newline at end of file