home *** CD-ROM | disk | FTP | other *** search
- << Super Magic 320 >> version 2.3B pre-released documentation
-
- By: Lim Thye Chean
-
-
-
- 1. Introduction
-
- Super Magic 320 is a set of assembly routines for designing demo or arcade
- games for the Apple IIGS personal computer. It is intended to be used by novice
- or average assembly programmers.
-
- With Super Magic 320, anybody with a little assembly knowledge can easily
- write a GS program that is fast and beautiful.
-
- Super Magic 320 is written in ORCA/M, and thus ORCA/M is required. APW users
- can also use the routines with some modifications.
-
-
-
- 2. Using Super Magic 320
-
- In your program, includes the following statements:
-
-
- mcopy SM.Macros - Macros file
- copy SM.Header - Super Magic 320 header file
-
-
- in the beginning and:
-
-
- copy SM.Lib - Super Magic 320 library
-
-
- at the end.
-
- You can now use all the Super Magic 320 library. For each or the routines that
- require Super Magic 320, include the statement:
-
-
- using SM.Data
-
-
- at the beginning of the routines.
-
- IN your program, start up Super Magic in the initializing codes of your
- program, and shut down Super Magic, switch to text mode in your ending
- routines. Refer to the routines below for instruction.
-
- After assembling, you will have to change the filetype of your EXE file to a
- S16 file. If you fail to do this, the program will crashed. To change a program
- from EXE to S16 file, type
-
-
- Filetype {your program name} S16
-
-
-
- 3. Calling Super Magic 320 routines
-
- All parameter in Super Magic 320, except for address, is done by variable
- passing. The address parameter is passed through stacks.
-
- No variables, except for the one used by Super Magic 320 (Temp1 .. Temp9),
- will be destroyed after the routine is called. The content of X and Y registers
- will be preserved, while the accumulator's value is gone.
-
- For example, calling a Erase Shape (ErsShp) routine required the following
- parameters:
-
-
- address of background, X, Y, Length, Height
-
-
- So this is how you called it:
-
-
- ph2 #BackAddr - Push 16 bit background address
-
- lda #100 - Variable passing
- sta X
- lda #150
- sta Y
- lda #20
- sta Length
- lda #10
- sta Height
-
- jsr ErsShp
-
-
- That's it. Definitely, if the Erase Shape routine needs to be called second
- time, while Length and Height remains unchanged, your codes can be:
-
-
- ph2 #NewBackAddr
-
- lda #50 - Length and Height need not be
- sta X redefined, since the routine does
- lda #60 not destroyed the variable's content
- sta Y
-
- jsr ErsShp
-
-
-
- 4. Predefined names and constants
-
- The predifined variable names are all declared in the file SM.Header. Names
- like X, Y, Length, Height, etc are declared and should not be used by your
- programs.
-
- Some constants have been defined for user convenience. For example, colour
- names like Yellow, Red can be used instead of the RGB values.
-
-
-
- 5. Colours
-
- There are 3 types of colour parameter used for different purposes:
-
-
- Normal Colour
- -------------
-
- When the standard 320 mode palette is used, user can used names like Red,
- Green, Blue etc to represent the colour. For example:
-
-
- lda #Red
- sta Colour
-
-
- is correct. If non-standard palette is used, user will need to use $0000,
- $1111, $2222, etc to represent colour 0, 1, etc in the palette. For example:
-
-
- lda #$5555 - Colour 5 in the palette
- sta Colour
-
-
- Gradient Colour
- ---------------
-
- When Gradient Fill Palette routine is used, user can use names like GRed,
- GGreen, GBlue to represent the gradient colour to be filled. For example:
-
-
- lda #GRed
- sta GColour
-
-
- RGB Colour
- ----------
-
- When colour is added to the palette, user needs to specify the RGB components
- of the colour. It is a 12-bit value, 4 bits for each component. Users can
- either use names like RRed, RGreen, RBlue to represents the RGB values, or
- a 12-bit value. Thus:
-
-
- lda #RWhite
- sta RGB
-
-
- and:
-
-
- lda #$FFF - R(ed): $F, G(reen): $F, B(lue): $F
- sta RGB
-
-
- means the same thing.
-
-
-
- 6. Animation technique
-
- If you want to do animation using Super Magic 320, you must first know a little
- about Super Hires. Since you are familiar with assembly, I presumed you have
- that knowledge.
-
- To reduce flickers, all draw and erase actions are not done on the Super Hires
- screen, which resides in bank $E1/2000. Instead, you draw and erase on the
- shadow bank $01/2000 and copy the image to $E1/2000.
-
- Therefore, this is what you should do:
-
- 1. Switch off shadowing
-
- 2. Draw/Erase the shapes
-
- 3. Switch on shadowing
-
- 4. For every shape drawm or erased, 'display' it on screen
-
- Remember, for every shape being drawn or erased, it must be displayed on screen.
- The only exception is that, if the shape moves not more than 2 pixels wide,
- you can display the drawn shape with surrounding (the surrounding with display
- the portion that should be erased), instead of two display operations, thus
- speed up the animation.
-
- Study the demo source code that came with the Super Magic 320 for example.
- Currently only dots and shapes can be animated. Lines are not supported.
-
- Masking and background saving are supported in animation.
-
- Mask is exactly the same as the shape except it is inverse of white shape,
- apply the mask on the background will allow the background to be visible
- through the 'holes' of the shapes.
-
- Background must be at least the same size as the shape. The background behind
- the shape will be saved, and redrawn when the shape is erased.
-
-
-
- 7. Routines
-
- Some routines have some restrictions for faster drawing. Error checking is not
- done to increase speed. All variables and X, Y registers are preserved after
- routines are called.
-
- At the beginning of your program, start up Super Magic 320 (and initializes
- 320 mode Super Hires, etc) by calling the Startup routine. Shut down Super
- Magic 320 by calling ShutDown before quiting your application.
-
- Taks note of the restrictions place on some routines. The restrictions are
- there to speed up the drawing, or to avoid some errors. Please be careful.
-
-
- *
- * Startup
- *
-
- Name: Startup
-
- * Note: call this routine at the beginning.
-
-
- *
- * Shut down tools
- *
-
- Name: ShutDown
-
- * Note: call this routine at the end.
-
-
- *
- * Text display
- *
-
- Name: Text
-
- * Note: call this routine at the end.
-
-
- *
- * Switch on shadowing
- *
-
- Name: ShadowOn
-
-
- *
- * Switch off shadowing
- *
-
- Name: ShadowOff
-
-
- *
- * Set standard colours in all palettes
- *
-
- Name: SetSClr
-
-
- *
- * Set all SCB to palette 0
- *
-
- Name: SetSCB0
-
-
- *
- * Set SCB to palette n
- *
-
- Name: SetSCB
-
- Input Y : location of SCB
- Palette: palette number
-
-
- *
- * Plot pixel
- *
-
- Name: Plot
-
- Input X, Y : location of the pixel
- Colour: colour of the pixel
-
-
- *
- * Erase pixel (to colour 0)
- *
-
- Name: Erase
-
- Input X, Y: location of the pixel
-
-
- *
- * Fast erase (background destroyed)
- *
-
- Name: Erase2
-
- Input X, Y: location of the pixel
-
-
- *
- * Display pixel
- *
-
- Name: Display
-
- Input X, Y: location of the pixel
-
-
- *
- * Horizontal line
- *
-
- Name: HorLine
-
- Input X1, X2, Y: start and end position of the line
- Colour : colour of the line
-
- * Note: X1 <= X2, X1 must be even, X2 must be odd.
-
-
- *
- * Vertical line
- *
-
- Name: VerLine
-
- Input X, Y1, Y2: start and end position of the line
- Colour : colour of the line
-
- * Note: Y1 <= Y2
-
-
- *
- * Plot shape
- *
-
- Name: PlotShp
-
- Input 16-bit stack: address of shape
- 16-bit stack: address of mask
- 16-bit stack: address of background
- X, Y : upper left corner of shape
- Length : length of shape
- Height : height of shape
-
- * Note: The length of the shape should be multiple of four, and the
- X value should be even.
-
-
- *
- * Fast plot shape (background not saved)
- *
-
- Name: PlotShp2
-
- Input 16-bit stack: address of shape
- 16-bit stack: address of mask
- X, Y : upper left corner of shape
- Length : length of shape
- Height : height of shape
-
- * Note: The length of the shape should be multiple of four, and the
- X value should be even.
-
-
- *
- * Erase shape
- *
-
- Name: ErsShp
-
- Input 16-bit stack: address of background
- X, Y : upper left corner of background
- Length : length of background
- Height : height of background
-
- * Note: The length of the background should be multiple of four, and
- the X value should be even.
-
-
- *
- * Fast erase shape (background destroyed)
- *
-
- Name: ErsShp2
-
- X, Y : upper left corner of background
- Length: length of background
- Height: height of background
-
- * Note: The length of the background should be multiple of four, and
- the X value should be even.
-
-
- *
- * Display shape
- *
-
- Name: DsplShp
-
- Input X, Y : upper left corner of shape
- Length: length of shape
- Height: height of shape
-
- * Note: The length of the shape should be multiple of four, and the
- X value should be even.
-
-
- *
- * Display shape with surrounding
- *
-
- Name: DsplShp2
-
- Input X, Y : upper left corner of shape
- Length: length of shape
- Height: height of shape
-
- * Note: The length of the shape should be multiple of four, and the
- X value should be even.
-
-
- *
- * Cycle the palette to left (colour 1 to 15)
- *
-
- Name: CycLeft
-
- Input Palette: palette number
-
-
- *
- * Cycle the palette colour to the right
- *
-
- Name: CycRight
-
- Input Palette: palette number
-
-
- *
- * Partial colour cycle to the left
- *
-
- Name: PCycLeft
-
- Input Palette: palette number
- ClrNum1: first colour in the colour range
- ClrNum2: last colour in the colour range
-
- * Note: ClrNum1 < ClrNum2
-
-
- *
- * Partial colour cycle to the right
- *
-
- Name: PCycRight
-
- Input Palette: palette number
- ClrNum1: first colour in the colour range
- ClrNum2: last colour in the colour range
-
- * Note: ClrNum1 < ClrNum2
-
-
- *
- * Gradient fill palette (colour 1 to 15)
- *
-
- Name: GrdFill
-
- Input Palette: palette number to be gradient filled
- GColour: gradient colour
-
-
- *
- * Set Colour
- *
-
- Name: SetClr
-
- Input Palette: palette number
- ClrNum : colour number to be set
- RGB : RGB component of colour to be set
-
-
- *
- * Print message
- *
-
- Name: Print
-
- Input 16-bit stack: address of the message
- X : start column (0..78)
- Y : line (0..199)
- Colour : colour of the message
-
-
- *
- * Print message (background destroyed)
- *
-
- Name: Print2
-
- Input 16-bit stack: address of the message
- X : start column (0..78)
- Y : line (0..199)
- Colour : colour of the message
-
-
- *
- * Start music tool
- *
-
- Name: StartMsT
-
-
- *
- * Load one song
- *
-
- Name: LoadSong
-
- Input 32-bit stack: address of song
-
-
- *
- * Play song
- *
-
- Name: PlaySong
-
- Input Loop: play the song continuously
-
-
- *
- * Stop song
- *
-
- Name: StopSong
-
-
- *
- * Shut down tool
- *
-
- Name: ShutDMsT
-
-
- *
- * Clear screen
- *
-
- Name: ClrScrn
-
- Input Colour: colour of the screen
-
-
- *
- * Clear area
- *
-
- Name: ClrArea
-
- Input Y1, Y2: start and end Y position of the area
- Colour: colour of the area
-
- * Note: Y1 <= Y2
-
-
- *
- * Get key
- *
-
- Name: GetKey
-
-
- *
- * Mouse routine (not working)
- *
-
- Name: GetMouse
-
- Output MouseX : (-64 to 63)
- MouseY : (-64 to 63)
- MouseBtn: 0 (up) or 1 (down)
-
-
- *
- * Delay
- *
-
- Name: Delay
-
- Input Time: delay time (0..$FFFF)
-
-
- *
- * Random number generator
- *
-
- Name: Random
-
- Output RndFlag: 0 or 1
-
- * Note: Do not modify RndFlag.
-