Jump to content

Moj Mikro listings: Fast Pattern Fill routine


1 reply to this topic

#1  

    Dragonstomper

  • 771 posts
  • Joined: 13-July 05

Posted Tue Jun 1, 2010 5:41 PM

In this article I introduce you fast fill routine, which completely replaces usual slow fill routine implemented in Atari OS. New routine is fast and fills area with custom patterns.

Moj Mikro magazine article listings are available as zipped file in download section. It contains ATR disk image file with Atari DOS system for using with disk based, real Atari machine or any Atari 8-bit emulator. To load Atari BASIC programs properly, Atari must be powered with Atari BASIC enabled, or you can try them with any compatible BASIC.

Posted Image

You can try, use and modify the programs and routines for whatever purpose you want.


Description

The routine is used to fill any area with any 8-byte pattern with no slowdown. It is written in machine language for fast execution. Unfortunately, author of the routine didn't put assembly language source code for the routine, only the Atari BASIC listing in the form of DATA lines. You can check algorithm used for the routine in the last example of this article, written in pure Atari BASIC.

The routine works in graphics mode 8 and is called from BASIC like this:

M=USR(27400,X,Y,ADDRESS)

27400 is the starting memory address of machine language fill pattern routine. Parameters X and Y are coordinates of any chosen pixel in the area to be filled. Last parameter is starting address of the pattern, which will be used to fill the area. Pattern is set of 8 bytes. So, for example, you can use internal character set or any other memory address as basis for displaying interesting area patterns with your favourite characters. The routine takes only 491 bytes and uses 4K as stack for saving all unfilled pixels. For your programs in BASIC there is still 25K of free RAM memory remaining.


Fast fill pattern routine example 1

Magazine: Moj Mikro, 1989/11
Author : Milonja Bjelic
Page : 39
Atari BASIC listing on disk (tokenized): M8911391.BAS
Atari BASIC listing (listed): M8911391.LST

Posted Image Posted Image

The original listing didn't include any demonstration code, so I modified it.


Fast fill pattern routine example 2

Next example is similar, with another demonstration. Every time you press any key, new random character patterns are shown.

Magazine: Moj Mikro, 1989/11
Author : Milonja Bjelic
Modification: Bostjan Gorisek
Page : 39
Atari BASIC listing on disk (tokenized): M8911393.BAS
Atari BASIC listing (listed): M8911393.LST

Posted Image Posted Image Posted Image


Fill pattern algorithm in Atari BASIC


And here is the last example, written in pure Atari BASIC, to show you algorithm used in main machine language routine. You may experiment with it and follow the inner workings of the mentioned routine.

Magazine: Moj Mikro, 1989/11
Author : Milonja Bjelic
Page : 39
Atari BASIC listing on disk (tokenized): M8911392.BAS
Atari BASIC listing (listed): M8911392.LST

Posted Image Posted Image Posted Image


Have fun!
Gury

Attached Files


Edited by Gury, Tue Jun 1, 2010 5:56 PM.


#2  

    River Patroller

  • 4,953 posts
  • Joined: 23-November 08
  • Jumping through hOOPs...
  • Location:United Kingdom

Posted Wed Jun 2, 2010 5:14 AM

Great - thanks. Been looking for something like this.







1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users